function EQL(e,t){return e==t||null==e&&0==t||null==t&&0==e||""==e&&null==t||""==t&&null==e||"string"==typeof e&&"string"==typeof t&&e.replace(/\r/g,"")==t.replace(/\r/g,"")}function $HTML(e){return e instanceof Array?e.map($HTML).join(""):e instanceof Function?$HTML(e()):null==e||!1===e?"":e}function $V_SEP(e){return new DlWidget({parent:e,className:"Dl-Vertical-Separator"})}function $H_SEP(e){return new DlWidget({parent:e,className:"Dl-Horizontal-Separator"})}function $RB(e,t,n){var i=e.x_resizeBar=new DlResizeBar({widget:e,horiz:t,invert:n});return e.on("onDisplay",function(e,t,n){"display"==n&&i.display(e)}),i}function $V_RB(e){return $RB(e,!1,!1)}function $H_RB(e){return $RB(e,!0,!1)}function $V_IRB(e){return $RB(e,!1,!0)}function $H_IRB(e){return $RB(e,!0,!0)}function $BUTTON(e,t,n,i){n&&(t=$W(t,n));var o=new DlButton({parent:e,label:t,focusable:!0});return i&&o.onClick(i),o}function $W(e,t){return t?/^[0-9]+$/.test(t)&&(t+="em"):t="7em",e.fixedWidth(t)}function $AK(e,t){return e.replace(new RegExp("("+t+")","i"),"<u>$1</u>")}function $makeMenus(e,i,o){var a=new DlVMenu;return e.foreach(function(e){var t;if(null==e)a.addSeparator();else if(e.widget)a.appendWidget(e.widget);else{"string"==typeof e&&(e={id:e}),t=new DlMenuItem({parent:a,label:e.l||e.id,iconClass:e.i,data:e}),i&&(i[e.id]=t);var n=e.h||o;n&&t.addEventListener("onSelect",n.$(t,e.id,e)),e.s&&(e.s instanceof DlWidget||e.s instanceof Function?t.setMenu(e.s):e.s instanceof Array&&t.setMenu($makeMenus(e.s,i,n)))}}),a}function REQUIRE_CONFIRMATION(t,e,n){var i=t[e];t[e]=function(){if(n.when&&!n.when.call(t))return i.apply(t,arguments);if(!t._CONFIRM_IN_PROGRESS){t._CONFIRM_IN_PROGRESS=!0;var e=Object.makeCopy(n instanceof Function?n.call(t):n);e.parent=e.parent||t.getParentDialog()||t,e.onOK=e.onOK||i.$A(t,Array.$(arguments)),XConfirmDialog.ask(e).on("onDestroy",function(){t._CONFIRM_IN_PROGRESS=!1})}}}function with_dynamic_vars(e,t){var n={};Object.foreach(e,function(e,t){Object.HOP(window,t)&&(n[t]=window[t]),window[t]=e});try{return t()}finally{Object.foreach(e,function(e,t){Object.HOP(n,t)?window[t]=n[t]:delete window[t]})}}X={},DlEntry.DEFAULT_ARGS._trim=["trim",!0],Array.prototype.integers=function(){return this.map(function(e){return parseInt(e,10)})},Array.prototype.firstNotNull=function(){for(var e=0;e<this.length;++e)if(null!=this[e])return this[e]},Array.prototype.equalSets=function(e){if(this.length==e.length){var t,n=this.toHash(!0),i=e.toHash(!0);for(t in n)if(n.hasOwnProperty(t)&&!(t in i))return!1;return!0}return!1},Array.prototype.equalLists=function(e,t){if(this.length==e.length){if(t){for(var n=this.length;0<=--n;)if(!t(this[n],e[n]))return!1}else for(n=this.length;0<=--n;)if(this[n]!==e[n])return!1;return!0}return!1},Array.prototype.remove=function(e){for(var t=this.length;0<=--t;)this[t]==e&&this.splice(t,1);return this},Array.prototype.joinDefined=function(e){return this.grep(function(e){return null!=e&&/\S/.test(e)}).join(e)},Object.equal=function(e,t){if(e instanceof Array&&t instanceof Array)return e.equalSets(t);if(e instanceof Date&&t instanceof Date)return String(e)==String(t);if("object"==typeof e&&"object"==typeof t){if(!Array.hashKeys(e).equalSets(Array.hashKeys(t)))return!1;for(var n in e)if(e.hasOwnProperty(n)&&!Object.equal(e[n],t[n]))return!1;return!0}return EQL(e,t)},Object.slice=function(t,e){return e.map(function(e){return t[e]})},Object.equalsTo=function(e,t,n){var i=Array.hashKeys(e);return i.equalSets(Array.hashKeys(t))&&Object.slice(e,i).equalLists(Object.slice(t,i),n)},Object.makeShortcuts(DlEventProxy.prototype,{on:"addEventListener"}),DEFINE_CLASS("XInfoTooltip",DlPopup,function(e,t){e.FIXARGS=function(e){e.zIndex=2e3,e.focusable=!1}}),DlWidget.inject({onClick:DlWidget.prototype.on.$(window.undefined,"onClick"),addParentClass:function(e){DynarchDomUtils.addClass(this.getElement().parentNode,e)},showSomeInfo:function(e,t){t||(t={prefer:"cR",fallX1:"_R",fallX2:"_L",fallY1:"B_",fallY2:"T_"});var n=new XInfoTooltip;try{n.popup({timeout:0,content:e,align:t,anchor:this.getElement(),isContext:!0,widget:this})}catch(e){}}}),DlDataGrid.prototype.x_resetIDS=function(e){this.resetIDS(e),this.displayPage(0),this.scrollHome(),this._recompDynamicWidths()},String.prototype.W=function(e){return $W(this,e)},String.prototype.where_ilike=function(){return"%"+this.trim()+"%"},String.prototype.where_ilike_words=function(){return"%"+this.trim().replace(/\s+/g,"%")+"%"},String.prototype.quote_regexp_chars=function(){return this.replace(/[\\\/\(\)\{\}\[\]\.\?\*\+\^\$]/gi,function(e){return"\\"+e})},String.prototype.where_ilike_words_regexp=function(){return new RegExp("("+this.trim().quote_regexp_chars().replace(/\s+/g,"|")+")","ig")},DlEntry.removeComma=function(e){this.setValue(this.getValue().replace(/\s*[,;]\s*$/,""))};var DATE_PLAIN=!(Date.prototype.dynarchlib_toJSON=function(){return Math.round(Date.UTC(this.getUTCFullYear(),this.getUTCMonth(),this.getUTCDate(),this.getUTCHours(),this.getUTCMinutes(),this.getUTCSeconds(),this.getUTCMilliseconds())/1e3)});Date.formatNice=function(e,t){if(!e)return t;if(DATE_PLAIN)return e.print("%Y-%m-%d %H:%M");var n=new Date;if(n.dateEqualsTo(e))return e.print("Today, %l:%M %P");n.setHours(0),n.setMinutes(0),n.setSeconds(0);var i=n.getTime()-e.getTime();if(0<=i){if(i<Date.DAY)return e.print("Yesterday, %l:%M %P");if(i<2*Date.DAY)return e.print("2 days ago, %l:%M %P");if(i<3*Date.DAY)return e.print("3 days ago, %l:%M %P");if(i<4*Date.DAY)return e.print("4 days ago, %l:%M %P");if(n.getFullYear()==e.getFullYear())return e.print("%b %e, %l:%M %P")}return e.print("%d %b %Y, %l:%M %P")},Date.formatNiceDate=function(e,t){if(!e)return t;if(DATE_PLAIN)return e.print("%Y-%m-%d");var n=new Date;if(n.dateEqualsTo(e))return e.getHours()==n.getHours()&&e.getMinutes()==n.getMinutes()?"Now":e.print("Today, %l:%M %P");n.setHours(0),n.setMinutes(0),n.setSeconds(0);var i=n.getTime()-e.getTime();if(0<=i){if(i<Date.DAY)return e.print("Yesterday");if(i<2*Date.DAY)return e.print("2 days ago");if(i<3*Date.DAY)return e.print("3 days ago");if(i<4*Date.DAY)return e.print("4 days ago")}return n.getFullYear()==e.getFullYear()?e.print("%e %b"):e.print("%e %b %Y")},String.prototype.quote=function(){return'"'+this.replace(/\x5c/,"\\\\").replace(/\x22/,'\\"')+'"'},String.prototype.highlightWords=function(e){for(var t,n=[],i=[],o=0,a=0;t=e.exec(this);)n[a++]=this.substring(o,t.index),o=e.lastIndex,i[a++]=t[0].htmlEscape().htmlEmbed("b","match");for(n[a++]=this.substring(o);0<=a--;)n[a]=i[a]||n[a]&&n[a].htmlEscape()||"";return n.join("")},DlWidget.getSize=function(e){var t,n=e.getElement(),i=n.parentNode,o=n.nextSibling;return DlContainer.getHiddenContainer().getElement().appendChild(n),t=e.getOuterSize(),i&&i.insertBefore(n,o),t},DlDesktop.prototype._handle_focusKeys=function(e){if(!e.altKey&&!e.ctrlKey&&e.keyCode==DlKeyboard.TAB){var t=e.focusedWidget;(t=e.shiftKey?this.getPrevFocusWidget(t):this.getNextFocusWidget(t))&&t.focus(),e.domStop=!0,DlException.stopEventBubbling()}this._handleKeybinding(e)},DlContainer.prototype.setBusy=function(e,t){this.isBusy=e;var n=this._busyVeil;!n&&e&&(n=this._busyVeil=new DlWidget({parent:this,focusable:!0,className:"X-BusyVeil"})).on("onMouseDown onMouseUp onClick onMouseWheel".qw(),DlException.stopEventBubbling),n&&(e&&1<arguments.length&&(t||(t="Please wait..."),n.setContent(String.buffer("<table cellspacing='0' cellpadding='0' style='height: 100%' align='center'><tr><td>",t,"</td></tr></table>").get())),n.display(e)?(this.__x_prevFocus=DlEvent.focusedWidget(),n.focus()):this.__x_prevFocus&&this.__x_prevFocus.focus())},DEFINE_CLASS("XCenteredContainer",DlContainer,function(t,e){t.DEFAULT_ARGS={_horizontal:["horizontal",!1]},t.FIXARGS=function(e){e.tagName="table"},e._createElement=function(){t.BASE._createElement.apply(this,arguments);var e=this.getElement();e.appendChild(DlElementCache.get("TBODY_RC")),e.style.height="100%",this._horizontal&&(e.style.width="100%",e.style.textAlign="center"),e.style.borderCollapse="collapse",e.align="center",e.cellspacing=0,e.cellpadding=0},e.getContentElement=function(){return this.getElement().rows[0].cells[0]}}),DEFINE_CLASS("XError",null,function(e,t){e.DEFAULT_ARGS={text:["text",null],code:["code",null],info:["info",null]}}),DEFINE_CLASS("XError_RPC",XError,function(e,t){e.INTERNAL_SERVER_ERROR=500,t.handle=function(e){e&&e(this)||XMSG.addMsg("error",this.text),$CONTINUE()}}),DEFINE_CLASS("XError_RPC_Fatal",XError_RPC,function(e,t){e.DEFAULT_ARGS={text:["text","InternalServerError"],code:["code",XError_RPC.INTERNAL_SERVER_ERROR]}}),DlDialog.prototype.setPercentSize=function(e,t){var n=this.parent.getInnerSize();this.setSize({x:e*n.x,y:t*n.y})},DlDataGrid.prototype._setFocusedStyle=function(e){this.condClass(e,"DlDataGrid-focus")},DEFINE_CLASS("DlLiteTree_RecordItem",DlLiteTree.Item,function(e,t){e.CONSTRUCT=function(e){this.rec=e,this._children=[]},t.formatHTML=function(e){e(this.rec.getShortLabel())},t.addClassNames=Function.noop,t.id=function(){return this.rec.id()},t.children=function(){return this._children},t.isSelectable=Function.returnTrue}),DlContainer.CENTER=function(e){var t=new DlContainer({parent:e});return t.setContent("<table align='center' style='height:100%;' cellspacing='0' cellpadding='0'><tbody><tr><td></td></tr></tbody></table>"),t.getContentElement=function(){return this.getElement().firstChild.firstChild.firstChild.firstChild},t},DlEntry.withClearButton=function(e){var t=new DlEntry(e),n=t._makeButton(null,null,"X-DropDownBigBtn Icon-Cancel",{hover:"X-DropDownBtn-hover",active:"X-DropDownBtn-active"});return n.onClick(function(){t.clear(),t.callHooks("onKey-ENTER")}),n.setTooltip("Clear"),t},EXTEND_CLASS(Date,function(e,t){function n(e,t,n){var i=new Date(e);switch(n){case"year":case"years":i.setFullYear(i.getFullYear()+t);break;case"month":case"months":i.setMonth(i.getMonth()+t);break;case"day":case"days":i.setDate(i.getDate()+t);break;case"hour":case"hours":i.setHours(i.getHours()+t);break;case"minute":case"minutes":i.setMinutes(i.getMinutes()+t);break;case"second":case"seconds":i.setSeconds(i.getSeconds()+t)}return i}t.plus=function(e,t){return n(this,e,t)},t.minus=function(e,t){return n(this,-e,t)}}),DEFINE_CLASS("XButtonMenu",DlButton,function(t,e,n){t.DEFAULT_ARGS={_noCapture:["noCapture",!0]},t.CONSTRUCT=function(){DlMenuBase.apply(this,arguments),this.on("onMouseDown",this._do_popupMenu)},t.DEFAULT_EVENTS=["onSelect","onPopup","onHide","onClick"],e.ALIGN={prefer:"Br",fallX1:"_r",fallX2:"_l",fallY1:"B_",fallY2:"T_"},e.activateSubmenu=function(e){this.condClass(e,"DlButton-1")},e._do_popupMenu=function(e){if(!this._popupVisible){var t=this._getContextMenuPopup();t.popup({timeout:0,content:this.getMenu(),align:this.ALIGN,anchor:this.getElement(),isContext:!0,widget:this,onHide:this.callHooks.$(this,"onHide")}),e instanceof DlEvent&&(e._justFocusedWidget=t),this.callHooks("onPopup")}},e.label=function(e){t.BASE.label.call(this,e+"<span class='Dropdown'>&nbsp;&nbsp;&nbsp;&nbsp;</span>")},e.getMenu=function(){return this._menu},e.setMenu=function(e){this._menu instanceof DlWidget&&this._menu.destroy(),e instanceof DlWidget&&e.ref(),this._menu=e}}),EXTEND_CLASS(Date,function(e,t){t.addDays=function(e){return this.setDate(this.getDate()+e),this},t.addMonths=function(e){return this.setMonth(this.getMonth()+e),this},t.plusDays=function(e){return new Date(this).addDays(e)},t.plusMonths=function(e){return new Date(this).addMonths(e)},t.diffDays=function(e){var t=new Date(this);return e=new Date(e),t.setHours(12,0,0,0),e.setHours(12,0,0,0),(t-e)/864e5},e.getQuarter=function(e){null==e&&(e=new Date);var t=new Date(e),n=new Date(e),i=Math.floor(t.getMonth()/4);return t.setDate(1),t.setMonth(i),n.setDate(1),n.setMonth(i+3),n.setDate(n.getDate()-1),[t,n]}}),DEFINE_CLASS("XDialog",DlDialog,function(n,e){function a(){this.getElement().parentNode.style.display=this.display()?"":"none"}function p(n,i,e){var o=this;e.foreach(function(e){if(e)switch(e){case"space":n.addSpace();break;case"separator":case"sep":n.addSeparator("wide-separator");break;case"fill":case"filler":n.addFiller();break;default:if(e instanceof Function)(e=e.call(n))&&e.id&&(i[e.id]=e.widget);else{var t=new DlButton({parent:n,className:e.klass,label:e.label,iconClass:e.icon,tooltip:e.tooltip,focusable:e.focusable});e.action&&(e.action instanceof Function?t.onClick(e.action):o[e.action]instanceof Function?t.onClick(o[e.action].$(o)):t.onClick(function(){o[e.action].apply(this,arguments)})),e.id&&(i[e.id]=t),t.on("onDisplay",a)}}},o)}n.FIXARGS=function(e){"parent"in e?!e.parent||e.parent instanceof DlDialog||(e.parent=e.parent.getParentDialog()):(e.parent=X.desktop.cont,!e.modal||"winlist"in e||(e.winlist=!1)),"winlist"in e||e.parent==X.desktop.cont||(e.winlist=!1)},n.DEFAULT_EVENTS=["onTitleChange"],n.DEFAULT_ARGS={__noParentKeyBindings:["noParentKB",!0],__noPropEvents:["dontBubbleEvents",/^onKey/i],_winlist:["winlist",!0]},e.FINISH_OBJECT_DEF=function(){n.BASE.FINISH_OBJECT_DEF.apply(this,arguments);var i,o=this.constructor;o.show||(o.show=function(n){if(i)i.show(!0);else{function e(e){e&&(n=Object.merge(n,e));var t=(i=new o(n||{})).initialSize;return t&&(t.x<=1?i.setPercentSize(t.x,t.y||t.x):i.setOuterSize(t)),i.on("onDestroy",function(){i=null}),i.show(!0),i}n||(n={}),o.PREINIT?o.PREINIT(e):e()}return i},o.killInstance=o.prototype.killInstance=function(){i&&i.destroy(),i=null})},e.initDOM=function(){n.BASE.initDOM.apply(this,arguments),this._winlist&&(this.__minBtn=new DlAbstractButton({parent:this,className:"DlDialog-MinimizeBtn",appendArgs:this.getButtonsElement(),classes:{hover:"DlDialog-MinimizeBtn-hover",active:"DlDialog-MinimizeBtn-active"}}),this.__minBtn.addEventListener("onClick",this._my_minimize.$(this)),this.addEventListener({onShow:this._my_onShow,onHide:this._my_onHide,onDestroy:this._my_onDestroy,onActivate:this._my_onActivate}),this._my_isMinimized=!1),this.addEventListener(["onKeyPress","onKeyDown"],DlException.stopWidgetBubbling)},e._my_minimize=function(){this._my_isMinimized||(this._my_isMinimized=!0,this.hide())},e._my_onShow=function(){if(!this._my_isMinimized){if(!this._winlist_btn){var e=this._winlist_btn=new DlButton({parent:X.desktop.winlist_bar,className:"X-WinListBtn",iconClass:this._iconClass,label:this.title(),type:DlButton.TYPE.TWOSTATE,tooltip:this._getWinlistTooltip.$(this)});e._isWinListButton=!0,e.addEventListener("onClick",function(e){this.checked()?e.show():e._my_minimize()}.$(null,this))}this._winlist_btn.display(!0),X.desktop.winlist.remove(this),X.desktop.winlist.push(this)}this._winlist_btn.delClass("X-WinListBtn-minimized"),this._my_isMinimized=!1},e._my_onActivate=function(e){this._winlist_btn&&this._winlist_btn.checked(e,!0)},e._my_onDestroy=function(){this._winlist_btn.destroy(),this._winlist_btn=null,X.desktop.winlist.remove(this)},e._my_onHide=function(){this.destroying||(this._my_isMinimized?(this._winlist_btn.addClass("X-WinListBtn-minimized"),this._winlist_btn.flash()):(this._winlist_btn.display(!1),X.desktop.winlist.remove(this)))},e._getWinlistTooltip=function(){return this.title()},e.title=function(){var e=n.BASE.title.apply(this,arguments);return 0<arguments.length&&(this._winlist_btn&&this._winlist_btn.label(e),this.hasHooks("onTitleChange")&&this.callHooks("onTitleChange",e)),e},n.makeActionButtons=p,n.BUTTONS={ok:{id:"ok",label:"OK".fixedWidth("5em"),focusable:!0,action:"onOK"},send:{id:"send",label:"Send".fixedWidth("5em"),focusable:!0,action:"onSend"},cancel:{id:"cancel",label:"Cancel".fixedWidth("5em"),focusable:!0,action:"onCancel"},close:{id:"close",label:"Close".fixedWidth("5em"),focusable:!0,action:"onClose"},next:{id:"next",label:"Next »".fixedWidth("5em"),focusable:!0,action:"onNext"},prev:{id:"prev",label:"« Prev".fixedWidth("5em"),focusable:!0,action:"onPrev"},finish:{id:"finish",label:"Finish".fixedWidth("5em"),focusable:!0,action:"onFinish"}},n.BUTTONS_WIZARD=["filler",n.BUTTONS.prev,n.BUTTONS.next,n.BUTTONS.finish],n.BUTTONS_OK_CANCEL=["filler",n.BUTTONS.ok,n.BUTTONS.cancel],n.BUTTONS_CLOSE=["filler",n.BUTTONS.close],e.onClose=e.onCancel=function(){this.__quitBtn&&this.__quitBtn.keyClicked()},n.createStandardLayout=function(e,t,n){null==e&&(e={}),t&&!n&&(n=t);var i,o,a,r=[e.outerSpace,e.spacing,5].firstNotNull(),u=e.fixed?new DlVbox({parent:t,borderSpacing:r}):new DlLayout({parent:t,outerSpace:r}),s={},l={};if(!e.fixed&&e.bigIcon){var c=new DlWidget;c.setStyle("padding","20px"),c.setContent("<div class='X-Dialog-Icon "+e.bigIcon+"'></div>"),u.packWidget(c,{pos:"left",after:5})}if(e.toolbar)if(e.toolbar instanceof DlWidget)i=e.toolbar;else{var d=(i=new DlContainer({className:"DlToolbar DlToolbar2"})).box=new DlHbox({parent:i,className:"HBoxPadLeft"});p.call(n,d,s,e.toolbar)}if(e.bottombar){d=(a=new DlContainer({className:e.bottomClass})).box=new DlHbox({parent:a,className:"HBoxPadLeft"});p.call(n,d,l,e.bottombar)}return o=e.content||new DlContainer({className:e.contentClass}),u instanceof DlLayout?(i&&u.packWidget(i,{pos:"top",after:5}),a&&(u.packWidget(a,{pos:"bottom",after:5}),e.noBottombarSeparator||u.packWidget($H_SEP(),{pos:"bottom",after:5})),u.packWidget(o,{pos:"top",fill:"*"})):(i&&u.appendWidget(i),o&&u.appendWidget(o),a&&(e.noBottombarSeparator||u.addSeparator(),u.appendWidget(a))),{layout:u,toolbar:i,tb_buttons:s,content:o,bottombar:a,bb_buttons:l}},e.createStandardLayout=function(e,t){return this.x_standard_layout=n.createStandardLayout(e,this,t)},n.withIcon=e.withIcon=function(e,t){var n=new DlHbox({borderSpacing:5}),i=n.createCellElement();return i.className="X-Dialog-Icon",i.innerHTML="<div class='X-Dialog-Icon "+e+"'>&nbsp</div>",t&&t(n),n},n.showError=function(e,t,n){var i=new XDialog({title:e,parent:t,modal:!0,quitBtn:"destroy"}),o=i.withIcon("Icon-Dlg-Error");new DlWidget({parent:o}).setContent(n),i.createStandardLayout({fixed:!0,content:o,bottombar:XDialog.BUTTONS_CLOSE}),i.show(!0)}});var XMSG={sayRecordSaved:function(){XMSG.addMsg("info","Record saved")},sayRecordRemoved:function(){XMSG.addMsg("info","Record removed")}};!function(){var e,u=!1,s=!1,l=!1,c=DynarchDomUtils,n=2e3,t=Math,d=DlAnimation.easing.accel_b,o=function(e){return 1-t.cos(3*e*t.PI/2)/t.exp(3*e)},i=DlAnimation.easing.accel_ab;function p(){return e||((e=new DlContainer({className:"X-Messages"})).setStyle({visibility:"hidden"}),e.opacity(0),e.addEventListener("onClick",XMSG.popdown),document.body.appendChild(e.getElement())),e}XMSG.popdown=function(){if(u&&!l){s&&s.stop();var e=new DlAnimation;l=e;var t=p().getPos().y;e.addEventListener({onUpdate:function(e){p().opacity(d(e).map(1,0)),p().setPos(null,i(e).map(t,t-20))},onStop:function(){u=!1,p().visibility(!1),p().destroyChildWidgets(),l=!1}}),e.start(50,70)}};var a=[],r=null,f=0;function h(e,t){a.push(e),r?f++:(f=0,r=function e(){a.shift()();if(0==a.length)r=null;else{var t=n-500*f;t<=1e3&&(t=1e3),r=e.delayed(t)}}.delayed(t||n))}function g(e,t,n){var i=new DlWidget({className:"X-Message X-Message-"+e,parent:p()});i.setContent(t),h(function(t){if(!t||p().children().length<=1)XMSG.popdown();else{var e=new DlAnimation,n=t.getSize().y;e.addEventListener({onUpdate:function(e){t.opacity(d(e).map(1,0)),t.setStyle({marginTop:o(e).map(0,-n)+"px"})},onStop:function(){t.destroy()}}),e.start(50,100)}}.$C(i),n)}XMSG.addMsg=function(e,t,n){var i,o,a,r;g(e,t,n),i=c.getWindowSize(),o=p().getSize(),a=(i.x-o.x)/2,r=(i.y-o.y)/3,p().setPos(a,2.5*r),function(){if(!u&&!s){l&&l.stop(),p().visibility(!0);var e=new DlAnimation;(s=e).addEventListener({onUpdate:function(e){p().opacity(d(e))},onStop:function(){s=!(u=!0)}}),e.start(50,100)}}()}}(),DEFINE_CLASS("XGenericForm",DlFieldGrid,function(e,t,n){e.DEFAULT_EVENTS="onKey-ENTER onKey-ESCAPE".qw(),e.DEFAULT_ARGS={fields:["fields",null],__cellSpacing:["cellSpacing",0],__cellPadding:["cellPadding",2]},e.CONSTRUCT=function(){this.widgets={},this.fillWidgets=[];var e=this.fields.grep_first(function(e){return e&&!!e.help});this.fields.foreach(this._mg_addField.$(this,e))},t.setFieldLabel=function(e,t){this.getField(e).userData.label.setLabel(t),this.parent.__doLayout()},t.addText=function(e){var t=new DlWidget;return t.setContent(e),this.addField({widget:t})},t._mg_addField=function(e,t){if(null==t)return this.addSeparator();if("string"==typeof t)return this.addText(t);t=Object.makeCopy(t);var n=XGenericWidgets.Create(t,this);if(n){var i={},o=t.label?t.label:null;if(this.addField({widget:n,name:t.id,tabIndex:this._tabIndex,label:o,valign:t.valign,vtop:t.vtop,align:t.align},null,i),i.c1.setStyle({width:"0.01%"}),n.userData=i,n instanceof DlEntry&&n.connectEvents("onKey-ENTER onKey-ESCAPE".qw(),this),(t.x_fill||!t.x_nofill&&n instanceof DlEntry&&!(n instanceof DlSpinner))&&this.fillWidgets.push(n),t.id&&(this.widgets[t.id]={w:n,f:t}),t.h){var a=new DlButton({parent:this._getActBox(),label:t.h,data:t.id});this.getField(t.id).refNode("_button",a);var r=i.row.getElement();r.parentNode.removeChild(r),a.refNode("showRow",r),a.onClick(this._showRow.$(this,a))}if(e&&(i.c3=this.addCell(i.row),t.help)){a=new DlButton({parent:i.c3,iconClass:"Icon-Help",tooltip:"string"==typeof t.help?t.help:null});t.help instanceof Function?a.onClick(t.help):a.onClick(XMSG.addMsg.$C("info",t.help))}t.hidden&&i.row.display(!1),"htmlarea"==t.type&&n.init.delayed(10,n)}},t._getActBox=function(){return this._actBox||(this._actBox=new DlHbox({className:"HBoxPadLeft"}),this.addField({widget:this._actBox})),this._actBox},t._showRow=function(e,t){var n=this._getActBox().parent.parent,i=this.getField(e.userData),o=e.showRow;e.destroy(),n.getElement().parentNode.insertBefore(o,n.getElement()),t&&this.parent.__doLayout(),0==this._getActBox().children().length&&n.destroy(),i.focus()},t.resetFields=function(n){var i={};this.fields.foreach(function(e){if(e){var t=n&&e.id in n?n[e.id]:e.value;t instanceof Function&&(t=t(e,this)),void 0!==t&&(i[e.id]=t)}},this),this.setValue(i)},t.getAllIds=function(){return this.fields.grep(NOT_NULL).map("id")},t.showValidationErrors=function(e){e||(e={});var t=this.getField();for(var n in t){var i=this.getField(n),o=i.parent.parent;i instanceof DlEntry&&i.condClass(n in e,"DlEntry-ValidationError"),o.condClass(n in e,"X-ValidationError");var a=e[n];o.setTooltip(a),i.setTooltip(a)}},t.genericErrorHandler=function(o){var a=this;return function(n){if(n.info instanceof Array){var i={};n.info.foreach(function(e){if(a.getField(e.info)){var t=e.text;i[e.info]?i[e.info]+="<br />"+t:i[e.info]=t}else o&&o.foreach(function(e){e.genericErrorHandler()(n)})}),Object.foreach(i,function(e,t){(t=a.getField(t))instanceof DlEntry?(t.addClass("DlEntry-ValidationError"),t.setInvalidTooltip(e.htmlEscape())):t.setValidationError&&t.setValidationError(e),t.showSomeInfo(e)})}}},t.setSize=t.setOuterSize=function(e){var i=e.x-n.getScrollbarSize(this.parent.getElement()).x;this.fillWidgets.foreach(function(t){var e=t.userData;if(e.row.display()){var n=i-this.__cellPadding*this._colSpan;e.row.children().foreach(function(e){e!=t.parent&&(n-=e.getOuterSize().x)}),t.setSize({x:n})}},this)},t.setRecord=function(e){this.setValue(this.getAllIds().map_hash(e.get,e))},t.wrapForResizableTextarea=function(i,e){var o=this,a=new DlContainer({parent:e});return a.appendWidget(o),o._fillParent=!0,a.setOuterSize=a.setSize=function(e){DlContainer.prototype.setOuterSize.apply(this,arguments),function(){var e=o.getField(i),t=e.getOuterSize(),n=a.getSize().y-o.getSize().y;e.setSize({y:t.y+n})}.delayed(10,this)},a}}),DEFINE_CLASS("XFreeForm",DlContainer,function(e,t){e.DEFAULT_EVENTS="onKey-ENTER onKey-ESCAPE".qw(),e.DEFAULT_ARGS={_htmlLayout:["htmlLayout",null],fields:["fields",null]},e.CONSTRUCT=function(){this.widgets={};var e=this._htmlLayout;e instanceof Function&&(e=e.call(this,this.id,this)),this.setContent(e),this._htmlLayout=e instanceof DlContainer?e:this,this.fields.foreach(this.addField,this)},t._createField=function(e){var t=XGenericWidgets.Create(e,this);return t instanceof DlEntry&&t.connectEvents("onKey-ENTER onKey-ESCAPE".qw(),this),t},t.addField=function(e){var t=this._createField(e);e.id&&(this.widgets[e.id]={w:t,f:e});var n=t;if(e.label){var i=e.label?e.label:null;n=new DlHbox,new DlLabel({parent:n,widget:t,label:i}).addParentClass("X-FreeFormLabel"),n.appendWidget(t)}if(e.x_place){var o=this.id+"-"+e.x_place,a=$("#"+o,this.getElement()).get(0);this._htmlLayout.appendWidget(n,a)}else this._htmlLayout.appendWidget(n)},t.getValue=function(){var o={};return Object.foreach(this.widgets,function(e,t){var n=(e=e.w).getFormValue||e.getValue;if(n instanceof Function)if(e instanceof DlAbstractButton&&e._checkTwoState(!0)){var i=n.call(e);"boolean"==typeof i?o[t]=i:null==i?o[t]=e.checked():e.checked()&&(o[t]=i)}else o[t]=n.call(e)}),o},t.setValue=function(e){Object.foreach(e,function(e,t){var n,i=this.getField(t);i&&(n=i.setFormValue||i.setValue)instanceof Function&&(i instanceof DlAbstractButton&&i._checkTwoState(!0)?i.checked("string"==typeof e?"0"!=e:!!e):n.call(i,e))},this)},t.getField=function(e){return this.widgets[e].w},t.setRecord=function(e){this.setValue(this.getAllIds().map_hash(e.get,e))},t.getAllIds=function(){return this.fields.grep(NOT_NULL).map("id")},t.showValidationErrors=function(e){e||(e={});var t=this.getField();for(var n in t){var i=this.getField(n),o=i.parent.parent;i instanceof DlEntry&&i.condClass(n in e,"DlEntry-ValidationError"),o.condClass(n in e,"X-ValidationError");var a=e[n];o.setTooltip(a),i.setTooltip(a)}},t.genericErrorHandler=function(){var i=this;return function(e){e.info instanceof Array&&e.info.foreach(function(e){var t=i.getField(e.info),n=e.text;t instanceof DlEntry?(t.addClass("DlEntry-ValidationError"),t.setInvalidTooltip(n.htmlEscape())):t.setValidationError&&t.setValidationError(n)})}}}),function(){function a(e){var t={};return Object.mergeDefined(t,{disabled:e.disabled,className:e.className,emptyText:e.emptyText,emptyValue:e.emptyValue,allowEmpty:e.allowEmpty,validators:e.validators,size:e.size,readonly:e.readonly,width:e.width,maxlength:e.maxlength,value:e.value,timeout:e.timeout,rows:e.rows,textMode:e.textMode,tooltip:e.tooltip}),t}function i(t){var e=document.createElement("tr"),n=document.createElement("td");e.appendChild(n),t.getElement().firstChild.appendChild(e),new DlResizeBar({parent:t,horiz:!0,min:30,widget:t.getInputElement(),continuous:!0,appendArgs:n}).on("onResizing",function(){var e=t.getParent(DlLayout,!0);e&&e.doLayout()})}function e(e){this.addClass("X-ValidationError"),this.setTooltip(e)}DlBox.prototype.setValidationError=e,DlButton.prototype.setValidationError=e,DlContainer.prototype.setValidationError=e,window.XGenericWidgets={_makeLiteTreeSelector:function(o){return function(e){var t=new XButtonMenu({iconClass:o.icon,label:o.btnLabel||"None"}),n=o.makeTree?o.makeTree():new DlLiteTree({sort:o.treeSort||Function.identity,className:"X-Padding DlLiteTree-focus",toggleSelection:null==o.unsel||o.unsel,focusable:!0});n.set=e.set||o.set();var i=new DlSelectionModel({multiple:!!o.multiple});return n.setSelectionModel(i),o.patchTree&&o.patchTree(n),t.setMenu(function(){return o.resetTree(n),n}),t.setValue=function(e){null!=e?(e instanceof Array||(e=[e]),i.reset(e)):i.clear()},t.getValue=function(){var e=i.getArray().map(function(e){return o.integers&&(e=parseInt(e)),e});return o.multiple||(e=0<e.length?e[0]:null),e},i.on("onReset onChange".qw(),function(){var e=t.getValue();o.makeLabel?o.makeLabel(e):null==e||o.multiple&&0==e.length?t.label(o.btnLabel||"None"):(e instanceof Array||(e=[e]),t.label(e.map(function(e){return n.set.get(e).getShortLabel()}).join(", ")))}),t}},Create:function(e,t){e.type||(e.type="entry"),t&&"function"==typeof e.value&&(e.value=e.value(e,t));var n=e.type instanceof Function?e.type(e):XGenericWidgets[e.type](e);for(var i in e)/^on/.test(i)&&n.addEventListener(i,e[i].$(n,t));return n},_mkEntryArgs:a,entry:function(e){return new DlEntry(a(e))},cl_entry:function(e){return DlEntry.withClearButton(a(e))},password:function(e){var t=a(e);return t.type="password",new DlEntry(t)},textarea:function(e){var t=a(e);t.type="textarea";var n=new DlEntry(t);return e.fixedHeight||i(n),n},htmlarea:function(e){return new XRichTextEditor},c_entry:function(e){var t=a(e);Object.mergeDefined(t,{electric:e.electric,smart:"smart"in e&&e.smart,noTab:!("noTab"in e)||e.noTab});var n=new DlCompletionEntry(t);if(n.addEventListener("onCompletion",e.complete),e.ms_cache){var i=n._makeButton("Select...");n.on("onKey-ENTER",i.keyClicked.$(i)),i.onClick(function(e,t){var n=t.getValue().trim().toLowerCase().split(/\s*[,;]+\s*/).toHash(!0),i=new DlVMenu({}),o=DlRadioGroup.get();o.maxChecked(null),e.getAllRecords().foreach(function(e){var t=e.getDisplayLabel();new DlCheckbox({focusable:!0,parent:i,label:t,group:o,value:e.id(),checked:n[t.toLowerCase()]})}),o.on("onChange",function(){t.setValue(this.getValue().map(e.get.$(e)).map("getDisplayLabel").join(", "))}),t._getContextMenuPopup().popup({timeout:0,content:i,anchor:t.getElement(),align:{prefer:"Bl",fallX1:"_r",fallX2:"_l",fallY1:"B_",fallY2:"T_"},widget:t,onHide:function(){o.removeAllListeners("onChange"),i.destroy()},isContext:!0}),o.getButtons()[0].focus()}.$C(e.ms_cache,n))}return n},c_area:function(e){var t=a(e);Object.mergeDefined(t,{electric:e.electric,type:"textarea"});var n=new DlCompletionEntry(t);return n.addEventListener("onCompletion",e.complete),e.fixedHeight||i(n),n},spinner:function(e){var t=a(e);return Object.mergeDefined(t,{minVal:e.min,maxVal:e.max,step:e.step,decimals:e.decimals,integer:e.integer,size:e.size||6}),new DlSpinner(t)},fee:function(e){var t=a(e);return Object.mergeDefined(t,{minVal:e.min||0,maxVal:e.max,step:e.step,size:e.size||6,decimals:2}),new DlSpinner(t)},integer:function(e){var t=a(e);return Object.mergeDefined(t,{minVal:e.min||0,maxVal:e.max,step:e.step,integer:!0,size:e.size||6,decimals:0}),new DlSpinner(t)},combo:function(e){var t=a(e);return t.options=e.options,new DlComboBox(t)},select:function(e){var t=e.options;return t instanceof Function&&(t=t()),new DlRadioSelect({options:t,focusable:!0,value:e.value,disabled:e.disabled})},multiselect:function(e){return new XMultiSelect({iconClass:e.iconClass,options:e.options,focusable:!0,value:e.value,label:e.btn_label,multi:e.multi,disabled:e.disabled})},radiogroup:function(t){var e=t.options;e instanceof Function&&(e=e());var n=new(t.vertical?DlVbox:DlHbox)({className:t.vertical?"HBoxPadRight":"VBoxPadDown"}),i=DlRadioGroup.get();n.registerEvents(["onChange"]),i.connectEvents("onChange",n);var o=t.checkboxes?DlCheckbox:DlRadioButton;return t.maxChecked?i.maxChecked(t.maxChecked):t.checkboxes&&i.maxChecked(null),e.foreach(function(e){new o({parent:n,focusable:!0,label:e.label,group:i,value:e.value,checked:e.value==t.value,disabled:!!t.disabled})}),n.getValue=function(){return 1!=i.maxChecked()?i.getValue():i.getValue()[0]},n.setValue=function(e,t){1!=i.maxChecked()?i.setValue(e,t):i.setValue([e],t)},n},checkbox:function(e){var t=new DlCheckbox({checked:!!e.value,label:e.label,focusable:!0});return e.label=null,t.getValue=t.setValue=t.checked,t},button:function(e){var t=new DlButton({label:e.label,focusable:!0});return e.label=null,t},date:function(e){var t=a(e);return Object.mergeDefined(t,{dateFormat:e.dateFormat,outFormat:e.outFormat}),new XDatePicker(t)},attachment:function(e){var t=new XFileUploadButton({label:"Browse...",withRecord:!0,multiple:!1});return t.x_acceptFilesDnD(),t},finance_cash:function(e){var t=new DlHbox({className:"HBoxPadRight"});t.registerEvents(["onChange"]);var n=a(e);Object.mergeUndefined(n,{decimals:2,size:10}),n.parent=t;var i=new DlSpinner(n),o=new DlRadioSelect({parent:t,value:"EUR",disabled:n.readonly||n.disabled,options:[{label:"EUR",value:"EUR"},{label:"USD",value:"USD"}]});return[i,o].map("connectEvents","onChange",t),t.setValue=function(e,t){i.setValue(e.amount,!0),o.setValue(e.currency,!0,!0),t||this.callHooks("onChange")},t.getValue=function(){var e=parseFloat(i.getValue());return isNaN(e)&&(e=null),{amount:e,currency:o.getValue()}},t}}}(),DEFINE_CLASS("XDatePicker",DlEntry,function(t,e){t.DEFAULT_EVENTS="onCalendarShow onCalendarHide onSelect".qw(),t.DEFAULT_ARGS={_emptyText:["emptyText","Select date..."],_dateFormat:["dateFormat","%A, %e %B %Y"],_outFormat:["outFormat",null],_size:["size",22]},t.BEFORE_BASE=function(e){this._dateValidator=new DlValidator(DlValidator.Date,this._dateFormat),this._validators=[this._dateValidator]},t.CONSTRUCT=function(){this._makeButton(null,null,"DlComboBox-dropDownBtn",{hover:"DlComboBox-dropDownBtn-hover"}).on("onMouseDown",this.$("_popupCalendar")),this._calendarEvents={onSelect:this.$("_on_calSelect")}},e.ALIGN={prefer:"Bl",fallX1:"_r",fallX2:"_l",fallY1:"B_",fallY2:"T_"},e.getDate=function(){var e=this._dateValidator._date;return e&&((e=new Date(e)).setUTCHours(12),e.setUTCMinutes(0),e.setUTCSeconds(0),e.setUTCMilliseconds(0)),e},e._popupCalendar=function(){var e=this._getContextMenuPopup(),t=i();t.enabled(!this._readonly),e.popup({timeout:0,content:t,align:this.ALIGN,anchor:this._btn.getElement(),isContext:!0,widget:this,onHide:this.$("_onHide")}),this._onShow()},e._onShow=function(){this._btn.addClass("DlComboBox-dropDownBtn-active");var e=this.getDate();e?i().selectDate(e,!0):i().clearSelection(),i().addEventListener(this._calendarEvents)},e._onHide=function(){this._btn.delClass("DlComboBox-dropDownBtn-active"),i().removeEventListener(this._calendarEvents)},e._on_calSelect=function(e,t,n){e||(this.setValue(i().date),DlPopup.clearAllPopups())},e.setValue=function(e){"number"==typeof e?e=new Date(1e3*e):"string"==typeof e&&(e=new Date(e)),e&&(e=isNaN(e.getTime())?null:e),e&&(e=new Date(e)),this._dateValidator._date=e,this._updateValue()},e.getFormValue=function(){if(/\S/.test(this.getValue())){var e=this.getDate(),t=this._outFormat;return null!=t?e.print(t):e}return null},e._updateValue=function(){var e=this.getDate();t.BASE.setValue.call(this,e?e.print(this._dateFormat):"",!0),this.callHooks("onSelect")};var i=function(){return new DlCalendar({withMenu:!0,weekNumbers:!0})}.memoize()}),XConfirmDialog={DEFAULT_ARGS:{title:["title","Warning"],icon:["icon","Icon-Dlg-Warning"],modal:["modal",!0],text:["text",null],onOK:["onOK",null],onCancel:["onCancel",null],okLabel:["okLabel","OK"],cancelLabel:["cancelLabel","Cancel"],focusCancel:["focusCancel",!1],buttons:["buttons",null]},ask:function(e){Dynarch.setDefaults.call(e,XConfirmDialog.DEFAULT_ARGS,e);var t=new(X.desktop?XDialog:DlDialog)({title:e.title,parent:e.parent,noShadows:e.noShadows,className:"X-ConfirmDialog",quitBtn:"destroy",modal:e.modal}),n=new DlVbox({parent:t}),i=new DlHbox({parent:n,borderSpacing:5}),o=i.createCellElement();o.className="X-Dialog-Icon",o.innerHTML="<div class='X-Dialog-Icon "+e.icon+"'>&nbsp</div>",new DlContainer({parent:i,className:"X-ConfirmDialog-Text"}).setContent(e.text),n.addSeparator();var a=new DlHbox({parent:n,borderSpacing:4});if(e.buttons)e.buttons.foreach(function(e){null==e?a.addFiller():new DlButton({parent:a,focusable:!("focusable"in e)||e.focusable,label:e.label,tooltip:e.tooltip,iconClass:e.iconClass}).onClick(function(){e.onClick&&e.onClick()||t.destroy()})});else{a.addFiller();var r=$BUTTON(a,e.okLabel,5).onClick(XConfirmDialog.onBtn.$(t,e.onOK));if(e.onOK||e.onCancel)var u=$BUTTON(a,e.cancelLabel,5).onClick(XConfirmDialog.onBtn.$(t,e.onCancel));t._focusedWidget=e.focusCancel?u:r}return t.show(!0),t},onBtn:function(e){this.destroy(),e&&e()}},DEFINE_CLASS("XFileRecord",DlRecord,function(e,t,o){function n(n,t,i){null==i&&(i=Function.noop);var e=new FileReader;return o.addEvent(e,{load:function(e){n.set("progress",1),i(1),t(e.target.result)},progress:function(e){if(e.lengthComputable){var t=e.loaded/e.total;n.set("progress",t),i(t)}},error:function(e){t(null)}}),e}e.DEFAULT_EVENTS=["onLoad"],e.CONSTRUCT=function(e){this._data={id:Dynarch.ID("file"),name:e.name,size:e.size,type:e.type,file:e}},t.readAsDataURL=function(e,t){n(this,e,t).readAsDataURL(this.get("file"))},t.readAsBinaryString=function(e,t){n(this,e,t).readAsBinaryString(this.get("file"))},t.readAsArrayBuffer=function(e,t){n(this,e,t).readAsArrayBuffer(this.get("file"))},t.getName=function(){return this.get("name")},t.getFile=function(){return this.get("file")},t.getFormValue=function(){return{name:this.get("name"),type:this.get("type"),body:this.get("content")}}}),DEFINE_CLASS("XFileCache",DlRecordCache,function(o,e,t){e.formatHTML=function(e,t,n){switch(t){case"size":return n(parseInt(e.get("size")).formatBytes(2));case"name":var i=e.get("progress");return null!=i&&i<1&&n("(",Math.round(100*i),"%) "),n(e.getName().htmlEscape());default:return o.BASE.formatHTML.apply(this,arguments)}},e.getRecClass=function(e){var t=[],n=e.get("progress");return 1==n?t.push("UploadRecord-Complete"):null!=n&&t.push("UploadRecord-Working"),t.join(" ")},e.upload=function(e,n,i){var o=new XMLHttpRequest;i&&t.addEvent(o.upload,{progress:function(e){e.lengthComputable&&i(e.loaded/e.total,e.total)}}),o.open("POST",e,!0),o.onreadystatechange=function(){if(4!=o.readyState);else{if(i&&i(1),200==o.status||304==o.status){try{var e=DlJSON.decode(o.responseText,!0),t=e&&e.error&&new XError_RPC(e.error)}catch(e){t=new XError_RPC_Fatal({text:String(e),code:o.status});return void n(null,t)}return void n(e,t)}t=new XError_RPC_Fatal({text:o.responseText,code:o.status});n(null,t)}};var a=new FormData;this.getAllRecords().foreach(function(e,t){a.append("upload"+t,e.get("file"))}),o.send(a)},e.addFile=function(e,t){var n=new XFileRecord(e);return n.listenOnce("onLoad",t),(this._data[n.id()]=n)._set=this,n.id()}}),DEFINE_CLASS("XFileUploadButton",DlButton,function(n,e,i){n.DEFAULT_ARGS={_multiple:["multiple",!1],_withRecord:["withRecord",!1]},e.initDOM=function(){n.BASE.initDOM.apply(this,arguments),this.setStyle({position:"relative",overflow:"hidden"});var e=this.getElement(),t=i.createElement("input",{position:"absolute",right:"-3px",top:"-3px",width:"100%",height:"100%",padding:"6px"},{type:"file",multiple:this._multiple},e);this.refNode("_input",t),i.setOpacity(t,0),i.addEvent(t,"change",this.$("_on_fileChange"))},e._setupFiles=function(e){var n=(e=Array.$(e)).length;if(this._withRecord)if(this._multiple)this.setValue(e.map(function(e){var t=new XFileRecord(e);return t.listenOnce("onLoad",function(e){e&&0==--n&&this.callHooks("onChange")}.$(this)),t},this));else{var t=new XFileRecord(e[0]);t.listenOnce("onLoad",function(e){this.callHooks("onChange")}.$(this)),this.setValue(t)}else this.setValue(e),this.callHooks("onChange"),this._input.value=""},e._on_fileChange=function(){this._setupFiles(this._input.files)},e.x_acceptFilesDnD=function(){n.BASE.x_acceptFilesDnD.call(this,function(e){this._setupFiles(e)})},e.getFormValue=function(){var e=this.getValue();return null!=e&&this._withRecord&&(e=this._multiple?e.map("getFormValue"):e.getFormValue()),e},DlWidget.prototype.x_acceptFilesDnD=function(t){i.addEvent(this.getElement(),{dragenter:i.stopEvent,dragover:i.stopEvent,drop:function(e){i.stopEvent(e),t.call(this,Array.$(e.dataTransfer.files))}.$(this)})}}),DEFINE_CLASS("XAttachDlg",XDialog,function(e,t,n){e.DEFAULT_EVENTS=["onUploadFinished"],e.DEFAULT_ARGS={_multiple:["multiple",!1],_postURL:["postURL","/@upload"]},e.FIXARGS=function(e){Object.mergeUndefined(e,{title:"Upload files",quitBtn:"destroy",resizable:!0})},e.CONSTRUCT=function(){var t=this,n=this.selection=new DlSelectionModel,e=this.grid=new DlDataGrid({selection:n,data:this.set=new XFileCache,cols:[{id:"name",label:"File name",fill:.5},{id:"size",label:"Size",width:70,style:{textAlign:"right"}},{id:"type",label:"Content-type",fill:.4999}]});e.resetIDS([]);var i=this.createStandardLayout({toolbar:[function(){var e=t.browseBtn=new XFileUploadButton({parent:this,label:"Browse...",iconClass:"Icon-Add",multiple:t._multiple});e.on("onChange",function(){t._addFiles(e.getValue())})},{id:"del",label:"Delete",icon:"Icon-Delete",action:"_on_delClick"}],content:e,bottombar:["filler",{id:"ok",label:"Upload".fixedWidth("5em"),focusable:!0,action:"onOK"},XDialog.BUTTONS.cancel],noBottombarSeparator:!0});this.__updateButtonState=function(){var e=n.getArray();i.tb_buttons.del.enabled(0<e.length),i.bb_buttons.ok.enabled(0<t.set.getAllIds().length&&!t.set.getAllRecords().grep_first(function(e){return e.get("progress")<1}))},this.__updateButtonState(),n.on("onChange onReset".qw(),this.__updateButtonState),this.setSize({x:400,y:300}),e.x_acceptFilesDnD(this.$("_addFiles"))},t._addFiles=function(e){this._refreshGrid(e.grep(function(e){return 0<e.size}).map(this._addFile,this))},t._addFile=function(e){return this.set.addFile(e,function(e){e?this.__updateButtonState():alert("Error while reading "+rec.getName())}.$(this))},t._refreshGrid=function(e){this.grid.x_resetIDS(this.set.getAllIds()),e&&(this.grid.scrollToRecord(e[0]),this.selection.reset(e),e.foreach(function(e){this.set.callHooks("onChange",this.set.get(e))},this)),this.__updateButtonState()},t._on_delClick=function(){this.selection.getArray().foreach(function(e){delete this._data[e]},this.set),this._refreshGrid()},t.onOK=function(){this.getButtonsElement().style.display="none";var n=this.__quitBtn;this.__quitBtn=null;var i=new DlDialog({parent:this,title:"Sending data",modal:!0}),e=new DlContainer({parent:i});e.setStyle({padding:"20px"});var o=new DlProgressBar({parent:e,min:0,max:1});e.setSize({x:300}),i.show(!0),this.set.upload(this._postURL,function(e,t){this.__quitBtn=n,this.getButtonsElement().style.display="",i.destroy(),t&&t.handle(),this.callHooks("onUploadFinished",e),this.destroy()}.$(this),function(e,t){o.setValue(e),1===e?o.setLabel("Done"):o.setLabel((e*t).formatBytes(2)+" of "+parseInt(t,10).formatBytes(2))})}}),function(){var n=Object.prototype.hasOwnProperty;function i(e,t){return n.call(e,t)}var o={},a={},t={letter:new RegExp("[\\u0041-\\u005A\\u0061-\\u007A\\u00AA\\u00B5\\u00BA\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02C1\\u02C6-\\u02D1\\u02E0-\\u02E4\\u02EC\\u02EE\\u0370-\\u0374\\u0376\\u0377\\u037A-\\u037D\\u0386\\u0388-\\u038A\\u038C\\u038E-\\u03A1\\u03A3-\\u03F5\\u03F7-\\u0481\\u048A-\\u0523\\u0531-\\u0556\\u0559\\u0561-\\u0587\\u05D0-\\u05EA\\u05F0-\\u05F2\\u0621-\\u064A\\u066E\\u066F\\u0671-\\u06D3\\u06D5\\u06E5\\u06E6\\u06EE\\u06EF\\u06FA-\\u06FC\\u06FF\\u0710\\u0712-\\u072F\\u074D-\\u07A5\\u07B1\\u07CA-\\u07EA\\u07F4\\u07F5\\u07FA\\u0904-\\u0939\\u093D\\u0950\\u0958-\\u0961\\u0971\\u0972\\u097B-\\u097F\\u0985-\\u098C\\u098F\\u0990\\u0993-\\u09A8\\u09AA-\\u09B0\\u09B2\\u09B6-\\u09B9\\u09BD\\u09CE\\u09DC\\u09DD\\u09DF-\\u09E1\\u09F0\\u09F1\\u0A05-\\u0A0A\\u0A0F\\u0A10\\u0A13-\\u0A28\\u0A2A-\\u0A30\\u0A32\\u0A33\\u0A35\\u0A36\\u0A38\\u0A39\\u0A59-\\u0A5C\\u0A5E\\u0A72-\\u0A74\\u0A85-\\u0A8D\\u0A8F-\\u0A91\\u0A93-\\u0AA8\\u0AAA-\\u0AB0\\u0AB2\\u0AB3\\u0AB5-\\u0AB9\\u0ABD\\u0AD0\\u0AE0\\u0AE1\\u0B05-\\u0B0C\\u0B0F\\u0B10\\u0B13-\\u0B28\\u0B2A-\\u0B30\\u0B32\\u0B33\\u0B35-\\u0B39\\u0B3D\\u0B5C\\u0B5D\\u0B5F-\\u0B61\\u0B71\\u0B83\\u0B85-\\u0B8A\\u0B8E-\\u0B90\\u0B92-\\u0B95\\u0B99\\u0B9A\\u0B9C\\u0B9E\\u0B9F\\u0BA3\\u0BA4\\u0BA8-\\u0BAA\\u0BAE-\\u0BB9\\u0BD0\\u0C05-\\u0C0C\\u0C0E-\\u0C10\\u0C12-\\u0C28\\u0C2A-\\u0C33\\u0C35-\\u0C39\\u0C3D\\u0C58\\u0C59\\u0C60\\u0C61\\u0C85-\\u0C8C\\u0C8E-\\u0C90\\u0C92-\\u0CA8\\u0CAA-\\u0CB3\\u0CB5-\\u0CB9\\u0CBD\\u0CDE\\u0CE0\\u0CE1\\u0D05-\\u0D0C\\u0D0E-\\u0D10\\u0D12-\\u0D28\\u0D2A-\\u0D39\\u0D3D\\u0D60\\u0D61\\u0D7A-\\u0D7F\\u0D85-\\u0D96\\u0D9A-\\u0DB1\\u0DB3-\\u0DBB\\u0DBD\\u0DC0-\\u0DC6\\u0E01-\\u0E30\\u0E32\\u0E33\\u0E40-\\u0E46\\u0E81\\u0E82\\u0E84\\u0E87\\u0E88\\u0E8A\\u0E8D\\u0E94-\\u0E97\\u0E99-\\u0E9F\\u0EA1-\\u0EA3\\u0EA5\\u0EA7\\u0EAA\\u0EAB\\u0EAD-\\u0EB0\\u0EB2\\u0EB3\\u0EBD\\u0EC0-\\u0EC4\\u0EC6\\u0EDC\\u0EDD\\u0F00\\u0F40-\\u0F47\\u0F49-\\u0F6C\\u0F88-\\u0F8B\\u1000-\\u102A\\u103F\\u1050-\\u1055\\u105A-\\u105D\\u1061\\u1065\\u1066\\u106E-\\u1070\\u1075-\\u1081\\u108E\\u10A0-\\u10C5\\u10D0-\\u10FA\\u10FC\\u1100-\\u1159\\u115F-\\u11A2\\u11A8-\\u11F9\\u1200-\\u1248\\u124A-\\u124D\\u1250-\\u1256\\u1258\\u125A-\\u125D\\u1260-\\u1288\\u128A-\\u128D\\u1290-\\u12B0\\u12B2-\\u12B5\\u12B8-\\u12BE\\u12C0\\u12C2-\\u12C5\\u12C8-\\u12D6\\u12D8-\\u1310\\u1312-\\u1315\\u1318-\\u135A\\u1380-\\u138F\\u13A0-\\u13F4\\u1401-\\u166C\\u166F-\\u1676\\u1681-\\u169A\\u16A0-\\u16EA\\u1700-\\u170C\\u170E-\\u1711\\u1720-\\u1731\\u1740-\\u1751\\u1760-\\u176C\\u176E-\\u1770\\u1780-\\u17B3\\u17D7\\u17DC\\u1820-\\u1877\\u1880-\\u18A8\\u18AA\\u1900-\\u191C\\u1950-\\u196D\\u1970-\\u1974\\u1980-\\u19A9\\u19C1-\\u19C7\\u1A00-\\u1A16\\u1B05-\\u1B33\\u1B45-\\u1B4B\\u1B83-\\u1BA0\\u1BAE\\u1BAF\\u1C00-\\u1C23\\u1C4D-\\u1C4F\\u1C5A-\\u1C7D\\u1D00-\\u1DBF\\u1E00-\\u1F15\\u1F18-\\u1F1D\\u1F20-\\u1F45\\u1F48-\\u1F4D\\u1F50-\\u1F57\\u1F59\\u1F5B\\u1F5D\\u1F5F-\\u1F7D\\u1F80-\\u1FB4\\u1FB6-\\u1FBC\\u1FBE\\u1FC2-\\u1FC4\\u1FC6-\\u1FCC\\u1FD0-\\u1FD3\\u1FD6-\\u1FDB\\u1FE0-\\u1FEC\\u1FF2-\\u1FF4\\u1FF6-\\u1FFC\\u2071\\u207F\\u2090-\\u2094\\u2102\\u2107\\u210A-\\u2113\\u2115\\u2119-\\u211D\\u2124\\u2126\\u2128\\u212A-\\u212D\\u212F-\\u2139\\u213C-\\u213F\\u2145-\\u2149\\u214E\\u2183\\u2184\\u2C00-\\u2C2E\\u2C30-\\u2C5E\\u2C60-\\u2C6F\\u2C71-\\u2C7D\\u2C80-\\u2CE4\\u2D00-\\u2D25\\u2D30-\\u2D65\\u2D6F\\u2D80-\\u2D96\\u2DA0-\\u2DA6\\u2DA8-\\u2DAE\\u2DB0-\\u2DB6\\u2DB8-\\u2DBE\\u2DC0-\\u2DC6\\u2DC8-\\u2DCE\\u2DD0-\\u2DD6\\u2DD8-\\u2DDE\\u2E2F\\u3005\\u3006\\u3031-\\u3035\\u303B\\u303C\\u3041-\\u3096\\u309D-\\u309F\\u30A1-\\u30FA\\u30FC-\\u30FF\\u3105-\\u312D\\u3131-\\u318E\\u31A0-\\u31B7\\u31F0-\\u31FF\\u3400\\u4DB5\\u4E00\\u9FC3\\uA000-\\uA48C\\uA500-\\uA60C\\uA610-\\uA61F\\uA62A\\uA62B\\uA640-\\uA65F\\uA662-\\uA66E\\uA67F-\\uA697\\uA717-\\uA71F\\uA722-\\uA788\\uA78B\\uA78C\\uA7FB-\\uA801\\uA803-\\uA805\\uA807-\\uA80A\\uA80C-\\uA822\\uA840-\\uA873\\uA882-\\uA8B3\\uA90A-\\uA925\\uA930-\\uA946\\uAA00-\\uAA28\\uAA40-\\uAA42\\uAA44-\\uAA4B\\uAC00\\uD7A3\\uF900-\\uFA2D\\uFA30-\\uFA6A\\uFA70-\\uFAD9\\uFB00-\\uFB06\\uFB13-\\uFB17\\uFB1D\\uFB1F-\\uFB28\\uFB2A-\\uFB36\\uFB38-\\uFB3C\\uFB3E\\uFB40\\uFB41\\uFB43\\uFB44\\uFB46-\\uFBB1\\uFBD3-\\uFD3D\\uFD50-\\uFD8F\\uFD92-\\uFDC7\\uFDF0-\\uFDFB\\uFE70-\\uFE74\\uFE76-\\uFEFC\\uFF21-\\uFF3A\\uFF41-\\uFF5A\\uFF66-\\uFFBE\\uFFC2-\\uFFC7\\uFFCA-\\uFFCF\\uFFD2-\\uFFD7\\uFFDA-\\uFFDC]"),non_spacing_mark:new RegExp("[\\u0300-\\u036F\\u0483-\\u0487\\u0591-\\u05BD\\u05BF\\u05C1\\u05C2\\u05C4\\u05C5\\u05C7\\u0610-\\u061A\\u064B-\\u065E\\u0670\\u06D6-\\u06DC\\u06DF-\\u06E4\\u06E7\\u06E8\\u06EA-\\u06ED\\u0711\\u0730-\\u074A\\u07A6-\\u07B0\\u07EB-\\u07F3\\u0816-\\u0819\\u081B-\\u0823\\u0825-\\u0827\\u0829-\\u082D\\u0900-\\u0902\\u093C\\u0941-\\u0948\\u094D\\u0951-\\u0955\\u0962\\u0963\\u0981\\u09BC\\u09C1-\\u09C4\\u09CD\\u09E2\\u09E3\\u0A01\\u0A02\\u0A3C\\u0A41\\u0A42\\u0A47\\u0A48\\u0A4B-\\u0A4D\\u0A51\\u0A70\\u0A71\\u0A75\\u0A81\\u0A82\\u0ABC\\u0AC1-\\u0AC5\\u0AC7\\u0AC8\\u0ACD\\u0AE2\\u0AE3\\u0B01\\u0B3C\\u0B3F\\u0B41-\\u0B44\\u0B4D\\u0B56\\u0B62\\u0B63\\u0B82\\u0BC0\\u0BCD\\u0C3E-\\u0C40\\u0C46-\\u0C48\\u0C4A-\\u0C4D\\u0C55\\u0C56\\u0C62\\u0C63\\u0CBC\\u0CBF\\u0CC6\\u0CCC\\u0CCD\\u0CE2\\u0CE3\\u0D41-\\u0D44\\u0D4D\\u0D62\\u0D63\\u0DCA\\u0DD2-\\u0DD4\\u0DD6\\u0E31\\u0E34-\\u0E3A\\u0E47-\\u0E4E\\u0EB1\\u0EB4-\\u0EB9\\u0EBB\\u0EBC\\u0EC8-\\u0ECD\\u0F18\\u0F19\\u0F35\\u0F37\\u0F39\\u0F71-\\u0F7E\\u0F80-\\u0F84\\u0F86\\u0F87\\u0F90-\\u0F97\\u0F99-\\u0FBC\\u0FC6\\u102D-\\u1030\\u1032-\\u1037\\u1039\\u103A\\u103D\\u103E\\u1058\\u1059\\u105E-\\u1060\\u1071-\\u1074\\u1082\\u1085\\u1086\\u108D\\u109D\\u135F\\u1712-\\u1714\\u1732-\\u1734\\u1752\\u1753\\u1772\\u1773\\u17B7-\\u17BD\\u17C6\\u17C9-\\u17D3\\u17DD\\u180B-\\u180D\\u18A9\\u1920-\\u1922\\u1927\\u1928\\u1932\\u1939-\\u193B\\u1A17\\u1A18\\u1A56\\u1A58-\\u1A5E\\u1A60\\u1A62\\u1A65-\\u1A6C\\u1A73-\\u1A7C\\u1A7F\\u1B00-\\u1B03\\u1B34\\u1B36-\\u1B3A\\u1B3C\\u1B42\\u1B6B-\\u1B73\\u1B80\\u1B81\\u1BA2-\\u1BA5\\u1BA8\\u1BA9\\u1C2C-\\u1C33\\u1C36\\u1C37\\u1CD0-\\u1CD2\\u1CD4-\\u1CE0\\u1CE2-\\u1CE8\\u1CED\\u1DC0-\\u1DE6\\u1DFD-\\u1DFF\\u20D0-\\u20DC\\u20E1\\u20E5-\\u20F0\\u2CEF-\\u2CF1\\u2DE0-\\u2DFF\\u302A-\\u302F\\u3099\\u309A\\uA66F\\uA67C\\uA67D\\uA6F0\\uA6F1\\uA802\\uA806\\uA80B\\uA825\\uA826\\uA8C4\\uA8E0-\\uA8F1\\uA926-\\uA92D\\uA947-\\uA951\\uA980-\\uA982\\uA9B3\\uA9B6-\\uA9B9\\uA9BC\\uAA29-\\uAA2E\\uAA31\\uAA32\\uAA35\\uAA36\\uAA43\\uAA4C\\uAAB0\\uAAB2-\\uAAB4\\uAAB7\\uAAB8\\uAABE\\uAABF\\uAAC1\\uABE5\\uABE8\\uABED\\uFB1E\\uFE00-\\uFE0F\\uFE20-\\uFE26]"),space_combining_mark:new RegExp("[\\u0903\\u093E-\\u0940\\u0949-\\u094C\\u094E\\u0982\\u0983\\u09BE-\\u09C0\\u09C7\\u09C8\\u09CB\\u09CC\\u09D7\\u0A03\\u0A3E-\\u0A40\\u0A83\\u0ABE-\\u0AC0\\u0AC9\\u0ACB\\u0ACC\\u0B02\\u0B03\\u0B3E\\u0B40\\u0B47\\u0B48\\u0B4B\\u0B4C\\u0B57\\u0BBE\\u0BBF\\u0BC1\\u0BC2\\u0BC6-\\u0BC8\\u0BCA-\\u0BCC\\u0BD7\\u0C01-\\u0C03\\u0C41-\\u0C44\\u0C82\\u0C83\\u0CBE\\u0CC0-\\u0CC4\\u0CC7\\u0CC8\\u0CCA\\u0CCB\\u0CD5\\u0CD6\\u0D02\\u0D03\\u0D3E-\\u0D40\\u0D46-\\u0D48\\u0D4A-\\u0D4C\\u0D57\\u0D82\\u0D83\\u0DCF-\\u0DD1\\u0DD8-\\u0DDF\\u0DF2\\u0DF3\\u0F3E\\u0F3F\\u0F7F\\u102B\\u102C\\u1031\\u1038\\u103B\\u103C\\u1056\\u1057\\u1062-\\u1064\\u1067-\\u106D\\u1083\\u1084\\u1087-\\u108C\\u108F\\u109A-\\u109C\\u17B6\\u17BE-\\u17C5\\u17C7\\u17C8\\u1923-\\u1926\\u1929-\\u192B\\u1930\\u1931\\u1933-\\u1938\\u19B0-\\u19C0\\u19C8\\u19C9\\u1A19-\\u1A1B\\u1A55\\u1A57\\u1A61\\u1A63\\u1A64\\u1A6D-\\u1A72\\u1B04\\u1B35\\u1B3B\\u1B3D-\\u1B41\\u1B43\\u1B44\\u1B82\\u1BA1\\u1BA6\\u1BA7\\u1BAA\\u1C24-\\u1C2B\\u1C34\\u1C35\\u1CE1\\u1CF2\\uA823\\uA824\\uA827\\uA880\\uA881\\uA8B4-\\uA8C3\\uA952\\uA953\\uA983\\uA9B4\\uA9B5\\uA9BA\\uA9BB\\uA9BD-\\uA9C0\\uAA2F\\uAA30\\uAA33\\uAA34\\uAA4D\\uAA7B\\uABE3\\uABE4\\uABE6\\uABE7\\uABE9\\uABEA\\uABEC]"),connector_punctuation:new RegExp("[\\u005F\\u203F\\u2040\\u2054\\uFE33\\uFE34\\uFE4D-\\uFE4F\\uFF3F]")};function r(e){return t.letter.test(e)}function u(e){return 48<=(e=e.charCodeAt(0))&&e<=57}var s={is_letter:r,is_digit:u,is_alphanumeric:function(e){return u(e)||r(e)},is_unicode_combining_mark:function(e){return t.non_spacing_mark.test(e)||t.space_combining_mark.test(e)},is_unicode_connector_punctuation:function(e){return t.connector_punctuation.test(e)},hop:i,to_hash:function(e){"string"==typeof e&&(e=e.split(/\s+/));for(var t={},n=e.length;0<=--n;)t[e[n]]=!0;return t},to_regexp:function(e,t){return"string"==typeof e&&(e=e.split(/\s+/)),new RegExp("^("+e.join("|")+")$",t?"i":"")},satisfies:function(e,t){return t instanceof RegExp?t.test(e):i(t,e)}};function D(e,t){this.tag=e,this.klass=t}D.prototype={open:function(){var e="<"+this.tag;return this.klass&&(e+=" class='"+this.klass+"'"),e+=">"},close:function(){return"</"+this.tag+">"}},this.ColoroloC={deflang:function(e,t){o[e]=t,a[e]=t(s)},highlight:function(e,t,n){var i=a[e],o=function(i,t){i=i.replace(/\r\n/g,"\n");var n="",o=0,a=1,r=0,e=0,u=o,s=[];function l(){return 1e3<=e&&h("peek() has been called 1000 times.  Endless loop?"),o===u?e++:(e=0,u=o),o<i.length?i.charAt(o):null}function c(){var e=l();return++o,"\n"==e?(++a,r=0):++r,e}function d(){return i.substr(o)}function p(e){for(var t,n="";(t=l())&&e(t);)n+=c();return n}function f(e){var t;if(e instanceof RegExp){var n=e.exec(d());t=n?n.index:i.length}else"string"==typeof e&&(t=i.indexOf(e,o))<0&&(t=i.length);return p(function(){return o<t})}function h(e){throw new Error(e+"["+a+":"+r+","+o+"]")}function g(e){return String(e).replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/\x22/g,"&quot;").replace(/\u00A0/g,"&#xa0;")}function m(e){e instanceof Array?e[1]&&(n+="<span class='"+(e[0]instanceof Array?e[0].join(" "):e[0])+"'>"+g(e[1])+"</span>"):"string"==typeof e&&(n+=g(e))}function _(e){if(e instanceof Array&&(e=e.join(" ")),"string"==typeof e?s.push(e=new D("span",e)):s.push(e=new D(e.tag,e.klass)),n+=e.open(),1<arguments.length){for(var t=1;t<arguments.length;++t)m(arguments[t]);C()}}function C(){n+=s.pop().close()}return{peek:l,next:c,rest:d,read_while:p,read_escaped:function(e,t){t||(t="\\");for(var n=!1,i="";l();){var o=c();if(n)i+=o,n=!1;else if(o==t)i+=o,n=!0;else{if(o==e)break;i+=o}}return i},read_string_coop:function(e){_("string"),m(["string-start",e]),_("string-body");for(var t=!1;l();){this.coop();var n=c();if(t)m(n),t=!1;else if("\\"==n)m(n),t=!0;else{if(n==e)break;m(n)}}C(),m(["string-end",e]),C()},read_to:f,eat:function(e){var t=e.exec(d());if(t&&t[0]){for(var n=t[0].length;0<n--;)c();return t}},skip:function(e,t){if(e instanceof RegExp){var n=e.exec(d());if(n)for(var i=(e=n[0]).length;0<i--;)c();else h("Parse error XXX: "+e)}else if(null==e)e=c();else for(i=e.length;0<i--;)c();m(t?[t,e]:e)},skip_ws:function(e){var t=p(function(e){switch(e){case" ":case"\n":case"\t":case"\f":case"\u2028":case"\u2029":case" ":return!0}});return m(t),t},skip_to:function(e,t){var n=f(e);m(t?[t,n]:n)},looking_at:function(e){return e instanceof RegExp?e.exec(d()):"string"==typeof e?i.substr(o,e.length)==e:void 0},looking_back:function(e){var t=i.substr(0,o);return e instanceof RegExp?e.exec(t):"string"==typeof e?t.substr(-e.length)==e:void 0},put:m,push:_,pop:C,eof:function(){return o>=i.length},prev:function(){return i.charAt(o-1)},encode:g,pos:function(){return o},line:function(){return a},col:function(){return r},coop:function(){var e=t&&t.coop;if(e)return e()},set_lang:function(e){t=e},output:function(){return n}}}(t);if(i){for(i=i(o,n||{}),o.set_lang(i);!o.eof();)i.next();return o.output()}return o.encode(t)},langdef:function(e){return a[e]}}}.call(this),ColoroloC.deflang("lisp",function(y){var t=/^(\d*\.\d+|\d+)(e[0-9]+)?$/,n=y.to_regexp("and or not eq eql equal list cons c[ad]{1,4}r equalp defvar defparameter deftype defstruct defclass defsetf destructuring-bind defmacro defun defmethod defgeneric defpackage in-package defreadtable in-readtable define defglobal when cond unless etypecase typecase ctypecase lambda λ let let\\* load-time-value quote macrolet progn prog1 prog2 progv begin go flet the if throw eval-when[^\\s]* multiple-value-prog1 unwind-protect ignore-errors handler-case handler-bind invoke-restart restart-case restart-bind case labels function symbol-macrolet block tagbody catch locally return return-from setq setf set! multiple-value-call loop do while","i"),E=y.to_regexp("with(out)?-[^\\s]+ define-[^\\s]+ def-[^\\s]+","i"),b=y.to_hash("t nil"),v=y.to_hash("error assert warn croak"),i=/^[(){}\[\]#\s`'"\\]$/i;return function(c){var d=!1,p=0,f=null,h=null;function g(e){return!(h&&0<=h.indexOf(e))&&!i.test(e)}function m(){var e=c.read_while(g);if(0<e.length)return t.test(e)?[["number"],e]:y.satisfies(e,n)?[["keyword"],e]:[["symbol"],e]}function _(e){var t=f;f=0,c.push("list"),c.skip(c.peek(),"list-start");e:for(;;){switch(c.skip_ws(),c.peek()){case e:c.skip(e,"list-end");break e;case null:break e;case";":C();break;case".":c.skip(".","list-dot");break;default:A()}++f}c.pop(),f=t}function C(){c.push("comment"),c.skip(/^;+/,"comment-start"),c.skip(/.*/,"comment-body"),c.pop()}function D(){var e;return c.push("string",["string-start",c.next()],["string-body",e=c.read_escaped('"')],["string-end",'"']),e.replace(/\\(.)/g,"$1")}function A(e,t){var n,i,o,a=h;try{if(h=e,c.skip_ws(),c.coop())return;switch(c.skip_ws(),c.peek()){case";":return C();case'"':return D();case"(":return _(")");case"[":return _("]");case"`":return o=p,++p,c.push("quasiquote"),c.skip(c.peek(),"quasiquote-start"),A(),c.pop(),void(p=o);case",":return i=p,--p,c.push("unquote"),c.skip(/^,@?/,"unquote-start"),A(),c.pop(),void(p=i);case"'":return n=d,d=!0,c.push("quote"),c.skip(c.peek(),"quote-start"),A(),c.pop(),void(d=n);case"#":return function(){switch(c.next(),c.peek()){case"/":c.next();var e=c.read_escaped("/"),t=c.read_while(function(e){return 0<="gmiy".indexOf(e)});c.push("regexp",["regexp-start","#/"],["regexp-body",e],["regexp-end","/"+t]);break;case"'":c.next();var n=m();n[0].push("function"),c.put("#'"),c.put(n);break;case"\\":c.next();var i=c.next()+c.read_while(g);c.put(["char","#\\"+i]);break;case"x":c.push("number"),c.put("#"),c.skip(/^x[a-f0-9]+/i),c.pop();break;case"o":c.push("number"),c.put("#"),c.skip(/^x[0-7]+/i),c.pop();break;case"+":case"-":c.push("declaration"),c.put("#"),c.put(m()),c.pop();break;case"t":case"T":case"f":case"F":c.push("constant"),c.put("#"),c.put(c.next()),c.pop();break;case"(":c.push("array"),c.put("#"),_(")"),c.pop();break;case":":c.next(),c.push("uninterned-symbol","#:",m());break;default:c.put("#"),c.skip(c.peek())}}();case null:return!1}var r=c.col(),u=m();if(u){var s=u[0],l=u[1].toLowerCase();p||d||(y.satisfies(l,b)&&s.push("constant"),/^:/.test(l)&&s.push("keyword-symbol"),/^&/.test(l)&&s.push("keyword-symbol","lambdaword"),(/^\*.*\*$/.test(l)||/^\+.*\+$/.test(l))&&s.push("global"),(0==f||t)&&(s.push("formpos"),y.satisfies(l,E)&&s.push("macro"),y.satisfies(l,v)&&s.push("assert")),/>$/.test(l)&&0==r&&s.push("repl-package")),c.put(u)}else c.skip(/./,"error")}finally{h=a}}return{next:A,read_comment:C,read_string:D,read_token:A}}}),ColoroloC.deflang("xml",function(d){return function(i){var n=0;function o(){for(;!i.eof()&&!i.coop();)switch(i.peek()){case"<":if(i.looking_at("\x3c!--"))s();else if(i.looking_at("<![CDATA["))c();else if(i.looking_at(/^<[!?]/))t();else if(i.looking_at("</")){if(n)return;r()}else e();break;case"&":l();break;default:i.skip()}}function a(){return i.read_while(function(e){return d.is_letter(e)||d.is_digit(e)||":"==e||"-"==e||"_"==e})}function e(){i.push("list"),i.push(["list-start"]),i.skip("<","xmltag-start");var e=a();for(i.put([["keyword","xmltag"],e]),i.skip_ws();!i.looking_at(/^[\x2f>]/);){i.skip_ws(),i.coop();var t=i.peek();d.is_letter(t)||d.is_digit(t)||":"==t||"_"==t||"-"==t?u():i.looking_at(/^[\x2f>]/)||i.put(i.next())}i.looking_at("/>")?(i.skip("/",["keyword","xmltag"]),i.skip(">","xmltag-end"),i.pop()):(i.skip_to(">"),i.skip(">","xmltag-end"),i.pop(),++n,o(),--n,i.looking_at("</")&&(i.push(["list-end"]),r(e),i.pop())),i.pop()}function r(e){i.skip(/^<\x2f/,"xmltag-start");var t=["keyword","xmltag"],n=a();e&&n!=e&&t.push("error"),i.put([t,n]),i.skip_ws(),i.skip(/^>/,"xmltag-end")}function u(){i.put([["keyword-symbol","attribute"],a()]),i.skip_ws(),i.looking_at("=")&&(i.skip("="),i.skip_ws(),i.looking_at(/^['"]/)?i.read_string_coop(i.next()):i.skip(/^[^\s>]*/,"string"))}function t(){i.push(["declaration","xmldecl"]),i.skip(/^<[!?]/,["declaration-start","xmldecl-start"]),i.skip(/^[^>]*/,["declaration-body","xmldecl-body"],!0),i.skip(/^>/,["declaration-end","xmldecl-end"]),i.pop()}function s(){i.push(["comment","xmlcomment"]),i.skip(/^<!--/,["comment-start","xmlcomment-start"]),i.skip_to("--\x3e",["comment-body","xmlcomment-body"]),i.skip(/^-->/,["comment-end","xmlcomment-end"]),i.pop()}function l(){i.looking_at(/^&.*?;/)?i.skip(/^&.*?;/,["constant","xmlentity"]):i.put(i.next())}function c(){i.push(["quote","xmlcdata"]),i.skip(/^<!\[CDATA\[/,["quote-start","xmlcdata-start"]),i.skip_to("]]>",["quote-body","xmlcdata-body"]),i.skip(/^\]\]>/,["quote-end","xmlcdata-end"]),i.pop()}return{next:o,read_text:o}}}),ColoroloC.deflang("syt",function(e){return function(o,e){var a=ColoroloC.langdef("lisp")(o),r=ColoroloC.langdef("xml")(o),u=e.start_lisp?a:r,s="{",l="}",c="\\";return{next:u.next,coop:function(){if(u===r){if(0==o.col()){if(o.looking_at(c+";"))return o.skip(c,"comment"),o.skip(";"),o.coop();if(";"==o.peek())return a.read_comment(),o.coop()}if(o.looking_at(c+s)||o.looking_at(c+l))return o.skip(o.peek(),"comment"),o.skip(o.peek()),o.coop();if(o.looking_at(/^\\~$/m))return o.skip(o.peek(),"comment"),o.skip(o.peek()),o.coop();if(o.looking_at(/^~$/m))return o.skip("~",["assert","syt-join-lines"]),o.coop();if(o.peek()==s){if(u=a,o.push(["sublang","sublang-lisp","syt-lisp"]),o.skip(s,["sublang-start","sublang-lisp-start","syt-lisp-start"]),o.skip_ws(),o.looking_at(/^\.syntax/i)){o.skip(/\.syntax/i,"declaration syt-declaration"),o.skip_ws();var e=a.read_string();o.skip_ws();var t=a.read_string();o.skip_ws(),s=e,l=t,o.skip(null,["sublang-end","sublang-lisp-end","syt-lisp-end"])}else{var n="\\"==o.peek();n&&(o.push("syt-escaped"),o.skip("\\","assert"));for(var i=0;a.read_token(s+l,0==i++),o.skip_ws(),o.peek()&&!o.looking_at("|")&&!o.looking_at(l););if(n&&o.pop(),"|"==o.peek()){for(o.push("syt-lisp-filters"),o.skip("|",["assert","syt-lisp-filters-start"]),o.skip_ws();!o.eof()&&!o.looking_at(l);)a.read_token(s+l),o.skip_ws();o.pop()}o.skip(l,["sublang-end","sublang-lisp-end","syt-lisp-end"])}return o.pop(),u=r,o.coop()}if(o.peek()==l)return"break"}else if(u===a&&o.peek()==s)return u=r,o.push(["sublang","sublang-xml","syt-xml"]),o.skip(s,["sublang-start","sublang-xml-start","syt-xml-start"]),r.read_text(),o.skip(l,["sublang-end","sublang-xml-end","syt-xml-end"]),o.pop(),u=a,"break"}}}}),ColoroloC.deflang("js",function(n){var l=n.to_regexp("Array Date Function Infinity Math NaN Number Object Error Packages RegExp String alert decodeURI decodeURIComponent document encodeURI encodeURIComponent arguments eval isFinite isNaN parseFloat parseInt undefined window"),c=n.to_regexp("boolean byte char double float int long short"),d=n.to_regexp("false null this true"),p=n.to_regexp("abstract break case catch class const continue debugger default delete do else enum export extends final finally for function goto if implements import in instanceof interface let const of import export constructor native new package private protected public return static super switch synchronized throw throws transient try typeof var void volatile while with"),f=/^0x[0-9a-f]+$/i,h=/^0[0-7]+$/,g=/^\d*\.?\d*(?:e[+-]?\d*(?:\d\.?|\.?\d)\d*)?$/i;function m(e){return n.is_digit(e)||(t=e,n.is_letter(t)||"$"==t||"_"==t);var t}return function(r){function u(e){for(r.push("list"),r.skip(r.peek(),"list-start");r.peek();){if(r.skip_ws(),r.peek()==e){r.skip(e,"list-end");break}t()}r.pop()}function s(){for(r.push("embedded"),r.skip("${","embedded-start"),r.push("embedded-body");r.peek()&&(r.skip_ws(),"}"!=r.peek());)t();r.pop(),r.looking_at("}")&&r.skip("}","embedded-end"),r.pop()}function t(){r.skip_ws();var e,t,n,i=r.peek();if(i){if(r.looking_at("//"))return r.push("comment"),r.skip(/^\/\//,"comment-start"),r.skip(/.*/,"comment-body"),void r.pop();if(r.looking_at("/*"))return function(){if(r.push("comment"),r.looking_at(/^\/\*+\//))r.skip(/^\/\*+\//,"comment-body");else{r.skip(/^\/\*+/,"comment-start");var e=r.read_to("*/");r.put(e,"comment-body"),r.skip(/^\*\//,"comment-end")}r.pop()}();if(m(i))return r.put(function(){var e=r.read_while(m);if(f.test(e)||h.test(e)||g.test(e))return[["number"],e];if(l.test(e))return[["macro"],e];if(c.test(e))return[["type"],e];if(d.test(e))return[["constant"],e];if(p.test(e))return[["keyword"],e];var t=[["symbol"],e];return e.toUpperCase()==e&&t[0].push("global"),t}());if(r.looking_at("("))return u(")");if(r.looking_at("{"))return u("}");if(r.looking_at("["))return u("]");if(r.looking_at(/^[\'\"]/))return n=r.next(),r.push("string",["string-start",n],["string-body",t=r.read_escaped(n)],["string-end",n]),t.replace(/\\(.)/g,"$1");if(r.looking_at("`"))return function(){var e;for(r.push("string template-string"),r.skip("`","string-start"),r.push("string-body");e=r.peek();)if("\\"==e)r.put(r.next()),r.put(r.next());else{if("`"==e)break;r.looking_at("${")?s():r.put(r.next())}r.pop(),"`"==e&&r.skip("`","string-end"),r.pop()}();if(e=r.looking_at(/^(?:=>|\.\.\.)/))return void r.skip(e[0],"keyword");if(r.looking_at(/^#!\s*/))return r.push("declaration"),r.skip(/^#!\s*/,"declaration-start"),r.skip(/.*/,"declaration-body"),void r.pop();if(r.looking_at(/^==>/))return void r.skip("==>","assert");if(e=r.looking_at(/^==\((.*?)\)==>/))return r.skip("==(","assert"),r.skip(e[1],"comment"),void r.skip(")==>","assert");if("/"==i&&r.looking_back(/(return|else|do|(for|if|while)\s*\(.*\)|[\(\[\{?+:\/-])\s*$/)){r.next();var o=r.read_escaped("/"),a=r.read_while(function(e){return 0<="gmiy".indexOf(e)});r.push("regexp",["regexp-start","/"],["regexp-body",o],["regexp-end","/"+a])}r.put(r.next())}}return{next:t}}}),ColoroloC.deflang("css",function(t){var s=/^@[a-z]+/i,l=/^\.[a-z0-9_-]+/i,c=/^#[a-z0-9-]+/i,d=/^[a-z0-9-]+:/i,p=/^:[a-z0-9-]+/i,f=/^(#[0-9a-f]+|[0-9.]+(?:e[+-]?\d*(?:\d\.?|\.?\d)\d*)?)(em|cm|px|pt|in|s|%|rem|vw|vh|vmin)?/i;function h(e){return t.is_letter(e)||"$"==e||"_"==e||"-"==e}function g(e){return h(e)||t.is_digit(e)}return function(r){function u(e){for(r.push("list"),r.skip(r.peek(),"list-start");r.peek();){if(r.skip_ws(),r.peek()==e){r.skip(e,"list-end");break}t()}r.pop()}function t(){r.skip_ws();var e,t,n,i,o,a=r.peek();if(a){if(r.looking_at("//"))return r.push("comment"),r.skip(/^\/\//,"comment-start"),r.skip(/.*/,"comment-body"),void r.pop();if(r.looking_at("/*"))return function(){if(r.push("comment"),r.looking_at(/^\/\*+\//))r.skip(/^\/\*+\//,"comment-body");else{r.skip(/^\/\*+/,"comment-start");var e=r.read_to("*/");r.put(e,"comment-body"),r.skip(/^\*\//,"comment-end")}r.pop()}();if(e=r.eat(l))return r.put([["function "],e[0]]);if(e=r.eat(c))return r.put([["constant "],e[0]]);if(e=r.eat(s))return r.put([["macro"],e[0]]);if(e=r.eat(p))return r.put([["keyword-symbol"],e[0]]);if(e=r.eat(d))return r.put([["keyword"],e[0]]);if(e=r.eat(f))return r.put([["number"],e[1]]),void(e[2]&&r.put([["regexp"],e[2]]));if(h(a))return r.put((i=r.read_while(g),o=[["symbol"],i],i.toUpperCase()==i&&o[0].push("global"),o));if(r.looking_at("("))return u(")");if(r.looking_at("{"))return u("}");if(r.looking_at("["))return u("]");if(r.looking_at(/^[\'\"]/))return n=r.next(),r.push("string",["string-start",n],["string-body",t=r.read_escaped(n)],["string-end",n]),t.replace(/\\(.)/g,"$1");r.put(r.next())}}return{next:t}}}),ColoroloC.deflang("lambda",function(e){var l=e.to_regexp("false null true"),c=e.to_regexp("let if then else lambda λ"),d=e.to_regexp("js:raw error assert croak"),p=/^\d*\.?\d*(?:e[+-]?\d*(?:\d\.?|\.?\d)\d*)?$/i;return function(o){function a(){o.push("comment"),o.skip(/^(#+|\/\/+)/,"comment-start"),o.skip(/.*/,"comment-body"),o.pop()}function r(e){return/[a-zλ_0-9]/i.test(e)}function u(e){return r(e)||0<="?!-<:>=0123456789".indexOf(e)}function t(){if(o.skip_ws(),!o.eof()){if(o.looking_at("#"))return a();if(o.looking_at("//"))return a();if(o.looking_at('"'))return i=o.next(),o.push("string",["string-start",i],["string-body",n=o.read_escaped(i)],["string-end",i]),n.replace(/\\(.)/g,"$1");if(o.looking_at("("))return s(")");if(o.looking_at("{"))return s("}");if(o.looking_at("["))return s("]");if(r(o.peek()))return o.put((e=o.looking_back(/(lambda|λ|let)\s*$/),t=o.read_while(u),c.test(t)?[["keyword"],t]:d.test(t)?[["assert"],t]:l.test(t)?[["constant"],t]:p.test(t)?[["number"],t]:e?[["macro"],t]:[["symbol"],t]));o.put(o.next())}var e,t,n,i}function s(e){for(o.push("list"),o.skip(o.peek(),"list-start");o.peek();){if(o.skip_ws(),o.peek()==e){o.skip(e,"list-end");break}t()}o.pop()}return{next:t}}}),function(r,e){var n=e.localStorage;function t(e){if(n)return n.getItem(e)}function i(e,t){if(n)return n.setItem(e,t)}e.setColorTheme=function(e){var t;i("colorTheme",e),t=e,r(".theme-css").each(function(){this.disabled=r(this).attr("name")!=t}),document.documentElement.className="theme-"+t},e.getColorTheme=function(){return t("colorTheme")},e.getProp=t,e.setProp=i,e.ITS_ALIVE_HAHAHA=function(){setTimeout(function(){r("pre.ColoroloC, code.ColoroloC").each(function(){var e=r(this).attr("lang");if(e){var t=r(this).text();t=t.replace(/^\n+|\s+$/g,"");var n=r(this).attr("options");n=null!=n?new Function("return {"+n+"}")():{};var i=ColoroloC.highlight(e,t,n);r(this).html(i),/^pre$/i.test(this.tagName)&&function(t,n,i,o){var e=new DlHbox({className:"DlToolbar action-buttons"});t.appendChild(e.getElement());var a=new DlButton({parent:e,iconClass:"Icon-NewWindow",tooltip:"Popup in dialog"});r(t).attr("editor")&&new DlButton({parent:e,iconClass:"Icon-Ymacs",tooltip:"Edit in Ymacs"}).onClick(function(){var e=r(t).attr("editor");YmacsDialog.editArbitraryCode(e,i)}),a.onClick(function(){var e=new XDialog({title:"View code",quitBtn:"destroy",resizable:!0}),t=new DlWidget({parent:e,tagName:"pre",className:"ColoroloC in-dialog"}).getElement();t.lang=n,t.innerHTML=o,e.setPercentSize(.7,.8),e.show(!0)})}(this,e,t,i)}});var _=document.getElementById("bazon-fractal"),C=_.offsetWidth,D=_.offsetHeight,A=_.getContext("2d"),y=.7<=Math.random()?1:-1,E=160*(.7<=Math.random()?1:-1)*Math.random(),b=140+40*Math.random(),v=140+40*Math.random(),e=250+200*Math.random(),w=D*e;!function(a){var r=[];!function(){for(var e=0,t=1/(a-1);e<=1;e+=t){var n,i,o;n=e.mapInt(0,255),i=e.mapInt(0,255),o=e.mapInt(0,255),r.push(n<<16|i<<8|o)}}(),_.width=C,_.height=D,r=r.concat(r.slice(r.length/3).reverse());for(var e,t,n,i,o,u,s,l,c,d=A.createImageData(C,D),p=0;p<C;++p)for(var f=0;f<D;++f){var h=p-C/2,g=f-D/2,m=0<(c=(b*h*h+E*g*h+y*v*g*g)%w)?c:w+c;e=d,t=p,n=f,s=m,l=Math.floor(r.length*(s/w)),i=r[l],u=void 0,o=n*e.width+t<<2,(u=e.data)[o+0]=(16711680&i)>>16,u[o+1]=(65280&i)>>8,u[o+2]=255&i,u[o+3]=255}A.putImageData(d,0,0)}(8)},10)}}($,window),Ymacs_Buffer.setGlobal("indent_level",4),DEFINE_CLASS("YmacsDialog",XDialog,function(e,t){e.DEFAULT_ARGS={_title:["title","Ymacs Editor"],_resizable:["resizable",!0],__quitBtn:["quitBtn","hide"]},e.CONSTRUCT=function(){(this.ymacs=new Ymacs({parent:this})).setColorTheme("light"==getColorTheme()?["light","standard"]:["dark","mishoo2"]),this.setPercentSize(.8,.8)};var n=null;function i(){return n||(n=new e({modal:!0}))}e.get=i,t.editPage=function(e){var t=this.ymacs,n=e.id+":"+e.title,i=t.getBuffer(n);i||((i=t.createBuffer({name:n,code:e.content})).cmd(function(e){switch(e.content_type.toLowerCase()){case"text/syt":return"sytes_mode";case"text/javascript":return"javascript_mode";case"text/css":return"css_mode";case"text/xml":case"text/html":return"xml_mode"}return"markdown_mode"}(e)),i.setq({page:e,page_id:e.id})),t.switchToBuffer(i)},e.editPageContent=function(e){var t=i();t.editPage(e),t.show(!0)},t.copyToClipboard=function(e){this.ymacs.killRingToMaster(),this.ymacs.pushToKillRing(e)},t.editArbitraryCode=function(e,t){var n=this.ymacs,i=e,o=n.getBuffer(i);o||(o=n.createBuffer({name:e,code:t})).cmd(function(e){switch(e.substr(e.indexOf(".")+1)){case"js":return"javascript_mode";case"css":return"css_mode";case"xml":case"html":return"xml_mode"}return"markdown_mode"}(e)),n.switchToBuffer(o)},e.editArbitraryCode=function(e,t){var n=i();n.editArbitraryCode(e,t),n.show(!0)}}),DEFINE_SINGLETON("Ymacs_Keymap_Sytes",Ymacs_Keymap_LispMode().constructor,function(e,t){}),Ymacs_Keymap_Sytes().defineKeys({"C-c C-c":"sytes_preview","C-c C-p":"sytes_edit_page_props","C-c C-a":"sytes_link_attachment","C-x C-s":"sytes_save_file","C-x C-f":"sytes_load_file","C-c /":"close_last_xml_tag","C-c j && C-c C-j":"sytes_insert_js_code"}),Ymacs_Keymap_Emacs().defineKeys({"{":["lisp_open_paren","{"],"}":["lisp_close_paren","}"]}),window.LOGGED_IN&&function(){var e,t,n,i;e="sytes",t="xml",Ymacs_Tokenizer.define(e,function(r,i){var p,f,h,g,m={next:l,copy:function(){var e=_.slice(),t=A.copy(),n=y.copy(),i=m.next,o=m.indentation,a=C.slice(),r=D.slice(),u=p,s=f,l=h,c=g;function d(){return _=e.slice(),C=a.slice(),D=r.slice(),A=t(),y=n(),p=u,f=s,h=l,g=c,m.next=i,m.indentation=o,m}return d.context={passedParens:function(){return C.concat(t.context.passedParens)}},d},indentation:function(e){try{return y.indentation(e)}catch(e){return 0}}},_=[],C=[],D=[],n={};o("{","}");var A=i.getLanguage("lisp",n),y=i.getLanguage(t);function o(e,t){p=e,f=t,h=new RegExp("^\\"+e),g=new RegExp("^\\s*\\"+t),n.rx_special=new RegExp("[\\"+e+"\\"+t+"]")}var u=/^(fmt|include|require|esc)(\s|\x29|$)/i;function s(e,t,n){i.onToken(r.line,e,t,n)}function a(){var o=m.indentation,a=m.next;m.indentation=A.indentation,m.next=function(){if(0<_.length)return _.peek()();var e,t,n;if(r.checkStop(),r.peek()==f){var i=D.pop();i.closed={line:r.line,col:r.col,opened:i},C.push(i),s(r.col,++r.col,"regexp-stopper"),m.indentation=o,m.next=a}else r.peek()==p?(D.push({line:r.line,col:r.col,type:p}),s(r.col,++r.col,"regexp-starter"),t=m.indentation,n=m.next,m.indentation=y.indentation,m.next=function(){if(0<_.length)return _.peek()();if(r.checkStop(),r.lookingAt(f)){var e=D.pop();e?(e.closed={line:r.line,col:r.col,opened:e},C.push(e),s(r.col,++r.col,"regexp-stopper"),m.indentation=t,m.next=n):s(r.col,++r.col,"error")}else l()}):(e=r.lookingAt(u))?s(r.col,r.col+=e[1].length,"keyword"):A.next()}}function l(){if(0<_.length)return _.peek()();var e;if(r.checkStop(),r.lookingAt("\\"+p))s(r.col,++r.col,"comment"),s(r.col,++r.col);else if(r.lookingAt(/^\\;/)&&0==r.col)s(r.col,++r.col,"comment"),s(r.col,++r.col);else if((e=r.lookingAt(/^(;+)(.*)/))&&0==r.col)s(r.col,r.col+=e[1].length,"comment-starter"),s(r.col,r.col+=e[2].length,"comment");else if(e=r.lookingAt(g))(t=D.pop())&&(t.closed={line:r.line,col:r.col+=e[0].length-1,opened:t},C.push(t),t.new_syntax&&o(t.new_syntax[0],t.new_syntax[1])),s(r.col,++r.col,"regexp-stopper");else if(r.lookingAt(h)){var t={line:r.line,col:r.col,type:p};D.push(t),s(r.col,++r.col,"regexp-starter"),r.lookingAt(".SYNTAX")?(s(r.col,r.col+=7,"builtin"),(e=r.lookingAt(/^(\s*)(".")(\s+)(".")/i))?(s(r.col+=e[1].length,r.col+=e[2].length,"string"),s(r.col+=e[3].length,r.col+=e[4].length,"string"),t.new_syntax=[e[2].charAt(1),e[4].charAt(1)]):s(r.col,++r.col)):a()}else y.next()}return m}),n="sytes_mode",i="sytes",Ymacs_Buffer.newMode(n,function(){var e=this.setTokenizer(new Ymacs_Tokenizer({type:i,buffer:this})),t=this.cmd("paren_match_mode",!0),n=this.setq({indent_level:2});return this.setq("fill_column",120),this.pushKeymap(Ymacs_Keymap_XML()),this.pushKeymap(Ymacs_Keymap_Sytes()),this.newCommands({sytes_commit:Ymacs_Interactive(function(){var e=this.getq("page");if(!e)throw new Ymacs_Exception("Not editing a sytes page");RPC("page.commit",e.id,function(e){XMSG.addMsg("info","Hopefully done. ;-)")})}),sytes_preview:Ymacs_Interactive(function(){var n=this;RPC("page.edit-content",{id:n.getq("page_id"),content:n.getCode()},function(e,t){t||(n.dirty(!1),RPC("page.get-url",n.getq("page").id,function(e){window.open(e+"?preview","SYTESPREVIEW")}))})}),sytes_edit_page_props:Ymacs_Interactive(function(){var t=this,e=t.getq("page");PagePropsDialog.editPageProps(e,t.ymacs,function(e){t.cmd("rename_buffer",e.title)})}),sytes_save_file:Ymacs_Interactive(function(){var n=this;RPC("page.edit-content",{id:this.getq("page_id"),content:this.getCode()},function(e,t){t||(XMSG.addMsg("info","Probably saved. ;-)"),n.dirty(!1))})}),sytes_add_subpage:Ymacs_Interactive(function(){var e=this.getq("page");PagePropsDialog.newPage(e.id)}),sytes_read_page_name:Ymacs_Interactive(function(i){var t=this,e=t.getq("page");RPC("page.get-subpages",e.id,function(n){var e=n.map("urlpart");t.cmd("minibuffer_prompt","Load page: "),t.cmd("minibuffer_read_string",e,function(t){var e=n.grep_first(function(e){return e.urlpart=t});i(e)})})}),sytes_load_file:Ymacs_Interactive(function(){this.cmd("sytes_read_page_name",function(e){YmacsDialog.editPageContent(e)})}),sytes_link_attachment:Ymacs_Interactive(function(){var n=this,e=n.ymacs,t=n.getq("page"),i=new AttcListDialog({page:t.id,parent:e,modal:!0,bottombar:XDialog.BUTTONS_OK_CANCEL});i.onOK=function(){var e=i.sel.getFirst();if(null!=e){var t=i.set.get(e);n.cmd("insert",t.getDynamicLink()),i.destroy()}else XMSG.addMsg("error","No file selected")},i.onDblClick=function(){this.x_standard_layout.bb_buttons.ok.keyClicked()},i.on("onDestroy",e.$("focus").clearingTimeout(10)),i.show(!0)}),sytes_insert_js_code:Ymacs_Interactive(function(){this.cmd("insert","«hl-js«»»"),this.cmd("backward_char",2)})}),function(){this.setq(n),this.popKeymap(Ymacs_Keymap_Sytes()),this.popKeymap(Ymacs_Keymap_XML()),this.setTokenizer(e),t||this.cmd("paren_match_mode",!1)}})}(),$(document).ready(function(){var e=new DlContainer;$("#x-desktop").append(e.getElement()),X.desktop={cont:DlDialog.getTopWM(),winlist_bar:e,winlist:[]};var t=document.querySelector("button.toggle-toc");t&&t.addEventListener("click",function(){var e=document.querySelector(".toc");e&&(e.classList.toggle("visible"),t.classList.toggle("active"))})}),DEFINE_CLASS("LoginDialog",XDialog,function(e,t){e.DEFAULT_EVENTS=["onLogin"],e.FIXARGS=function(e){Object.mergeUndefined(e,{quitBtn:"destroy",title:"Login",modal:!0})},e.CONSTRUCT=function(){var n=new XGenericForm({fields:[{id:"user",label:"User:"},{id:"pass",label:"Password:",type:"password"}]});this.onOK=function(){var t=n.getValue();RPC("set-login-token",function(e){RPC("login",t.user,hex_sha1(hex_sha1(t.pass)+e),function(e){null!=e?window.location.reload(!0):XMSG.addMsg("error","Something went wrong.")})})};var t=this.createStandardLayout({content:n,fixed:!0,bottombar:XDialog.BUTTONS_OK_CANCEL});"user pass".qw().foreach(function(e){n.getField(e).on("onKey-ENTER",t.bb_buttons.ok.$("keyClicked"))}),this._focusedWidget=n.getField("user")}}),DEFINE_CLASS("CommentDialog",XDialog,function(n,e){n.DEFAULT_ARGS={page:["page",null],parent_comment:["parent_comment",null]},n.FIXARGS=function(e){Object.mergeUndefined(e,{quitBtn:"destroy",title:"Add comment",resizable:!0})},n.CONSTRUCT=function(){var n=this,i=(n.page,new XGenericForm({fields:["If you leave this blank, your comment will display as <em>“anonymous”</em>.",{id:"author_name",label:"Your name:"},null,"Optionally provide your email address (we don't share it).  If you do, we will send you an email with a link to validate your comment; otherwise I'll validate it myself when I get a chance to see the notification.",{id:"email",label:"Your email:"},null,"<b><a target='_blank' href='/baretext' title='Opens new window'>BareText™</a></b> — comments are plain text.  Links are not hyperlinked, HTML is displayed literally, your asterisks will be left intact and your indentation is kept faithfully, except that long lines will wrap.  Enjoy simplicity!",{id:"content",label:"Message:",type:"textarea",fixedHeight:!0,valign:"top",className:"X-Monospace"}]}));USER&&i.setValue({author_name:USER.name,email:USER.email}),n.onOK=function(){var e=i.getValue();e.page=n.page.id,null!=n.parent_comment&&(e.parent=n.parent_comment),RPC("comment.post",e,function(e,t){t&&t.handle(i.genericErrorHandler()),n.destroy(),"pending-validation"==e?XConfirmDialog.ask({title:"SPAM prevention",text:"Your comment is pending validation. <br /> If you entered an email address, please check your mail."}):e&&(window.location.replace(e),window.location.reload(!0))})},n.createStandardLayout({content:i.wrapForResizableTextarea("content"),bottombar:XDialog.BUTTONS_OK_CANCEL}),n._focusedWidget=i.getField(USER?"content":"author_name"),n.setSize({x:700,y:500})},n.newComment=function(e,t){new n({page:e,parent_comment:t}).show(!0)}}),DEFINE_CLASS("PagePropsDialog",XDialog,function(o,e){o.DEFAULT_EVENTS=["onOK"],o.DEFAULT_ARGS={page:["page",null],parent_page:["parent_page",null]},o.FIXARGS=function(e){Object.mergeUndefined(e,{quitBtn:"destroy",title:"Edit page",resizable:!0})},o.CONSTRUCT=function(){var t=this,e=t.page,n=t.form=new XGenericForm({fields:[{id:"title",label:"Title:",onBlur:function(){var e=n.getField("urlpart");e.isEmpty()&&e.setValue(this.getValue().replace(/[^a-z0-9.:_-]+/gi,"-").replace(/^-+|-+$/,"").toLowerCase()),(e=n.getField("breadcrumb")).isEmpty()&&e.setValue(this.getValue())}},{id:"urlpart",label:"URL part:"},{id:"breadcrumb",label:"Breadcrumb:"},{id:"content_type",label:"Content type:",value:"text/syt"},{id:"tags",label:"Tags:"},{id:"allow_comments",label:"Allow comments",type:"checkbox",value:!0},{id:"publish_now",label:"Publish now",type:"checkbox",onChange:function(){var e=n.getField("t_published");e.disabled(this.checked()),e.setValue(this.checked()?new Date:null)}},{id:"t_published",label:"Publish date:",type:"date"},null,{id:"abstract",label:"Abstract:",type:"textarea",fixedHeight:!0,valign:"top"}]});if(e){e.parent&&(t.parent_page=e.parent);var i=Object.makeDeepCopy(e);i.tags&&(i.tags=i.tags.map("label").join(", ")),n.setValues(i)}t.onOK=function(){var e=n.getValue();t.parent_page&&(e.parent=t.parent_page),t.callHooks("onOK",e)},t.createStandardLayout({content:n.wrapForResizableTextarea("abstract"),bottombar:XDialog.BUTTONS_OK_CANCEL}),t._focusedWidget=n.getField("title"),t.setSize({x:400,y:350})},o.newPage=function(e){var n=new o({title:"New page",parent_page:e});n.on("onOK",function(e){RPC("page.new",e,function(e,t){t&&t.handle(n.form.genericErrorHandler()),n.destroy(),YmacsDialog.editPageContent(e)})}),n.show(!0)},o.editPageProps=function(t,e,n){var i=new o({page:t,parent:e,modal:!0});i.on("onOK",function(e){e.id=t.id,RPC("page.edit-props",e,function(e,t){t&&t.handle(i.form.genericErrorHandler()),i.destroy(),n&&n(e)})}),i.on("onDestroy",e.focus.clearingTimeout(10,e)),i.show(!0)}}),DEFINE_CLASS("RecordSet",DlRecordCache,function(o,e){o.DEFAULT_EVENTS=["onGetRecords"];var a=DEFINE_HIDDEN_CLASS(null,DlRecord,function(e,t){});o.DEFAULT_ARGS={RecordClass:["RecordClass",DlRecord]},o.CONSTRUCT=function(){},e.getRecords=function(e,t,n){var i=[],o=e.map(function(e){var t=this.get(e);return t||(i.push(e),new a({data:{id:e}}))},this);t.call(n,o),0<i.length?(this.callHooks("onGetRecords",e,i),this.fetchRecords(i)):this.callHooks("onGetRecords",e)},e.formatHTML=function(e,t,n,i){if(!(e instanceof a&&"id"!=t))return o.BASE.formatHTML.apply(this,arguments);n("...")},e.fetchRecords=function(e,n){var i=this;i._fetchRecords(e,function(e){var t=e.map(function(e){e=new i.RecordClass({data:e,recordSet:i});return i._data[e.get("id")]=e});t.map(function(e){i.callHooks("onChange",e)}),n&&n(t)})},e.fetchIds=function(t){var n=this;n._fetchIds(function(e){n.callHooks("onRefresh",e),t&&t(e)})},e.connectGrid=function(e){this.on("onRefresh",e.$("x_resetIDS"),null,e),e.on("onDestroy",this.$("destroy"))}}),DEFINE_CLASS("AttcRecord",DlRecord,function(e,t){t.getURL=function(){return"/@file/"+this.id()+"/"+this.get("checksum")+"/"+this.get("filename")},t.getDynamicLink=function(){return"{(FILE-LINK "+this.id()+" #|"+this.get("filename")+"|#)}"}}),DEFINE_CLASS("AttcRecordSet",RecordSet,function(e,t){e.FIXARGS=function(e){e.RecordClass=AttcRecord},t.makeOptions=function(){return{}},t._fetchIds=function(e){RPC("query.attachments",this.makeOptions(),e)},t._fetchRecords=function(e,t){var n=this.makeOptions();n.ids=e,RPC("query.attachments",n,t)}}),DEFINE_CLASS("AttcListDialog",XDialog,function(e,t){e.DEFAULT_ARGS={page:["page",null],bottombar:["bottombar",XDialog.BUTTONS_CLOSE]},e.FIXARGS=function(e){Object.mergeUndefined(e,{quitBtn:"destroy",title:"Files",resizable:!0})};var d=function(){function e(e){return"<td style='padding-right: 5px' id='$id-"+e+"'></td>"}return String.template("<table cellspacing='0' cellpadding='0'><tr>",e("search"),e("all_pages"),"</tr></table>")}();e.CONSTRUCT=function(){var n,i=this,a=(i.page,this.set=new AttcRecordSet);a.makeOptions=function(){var e={},t=n.getValue();return t.all_pages||null==i.page||(e.page=i.page),/\S/.test(t.search)&&(e.search=t.search),e};var r=this.sel=new DlSelectionModel({multiple:!0}),o=new DlDataGrid({selection:r,data:a,cols:[{id:"id",width:50,label:"ID"},{id:"filename",fill:.5,label:"File name"},{id:"size",width:70,label:"Size",format:function(e){var t=e.get("size");return null==t?"—":"<div>"+t.formatBytes(2)+"</div>"}},{id:"content_type",fill:.49,label:"Content type"},{id:"t_created",width:100,label:"Created"},{id:"t_modified",width:100,label:"Modified"}]});a.connectGrid(o);var u=a.$("fetchIds",null),s=u.clearingTimeout(400);var e=i.createStandardLayout({toolbar:[function(){n=new XFreeForm({parent:this,htmlLayout:function(e){return d({id:e})},fields:[{id:"search",label:"Search:",x_place:"search",onKeyDown:function(e,t){t.keyCode==DlKeyboard.ENTER?(u(),DlException.stopEventBubbling()):t.keyCode==DlKeyboard.ESCAPE?(this.clear(),u(),DlException.stopEventBubbling()):s()},onChange:u},null!=i.page&&{id:"all_pages",label:"In all pages",type:"checkbox",x_place:"all_pages",onChange:u}].flatten()})},"fill",{id:"view",icon:"Icon-View",label:"View",action:function(){var e=r.getFirst();if(null!=e){var t=a.get(e);window.open(t.getURL(),"LISPERATORATTC")}}},"sep",{id:"add",icon:"Icon-Add",label:"New",action:function(){var e=new XAttachDlg({parent:this,modal:!0});e.on("onUploadFinished",l),e.show(!0)}},{id:"del",icon:"Icon-Delete",label:"Delete",action:function(){XConfirmDialog.ask({text:"Are you sure you want to delete the selected file(s)? <br /> They'll be gone forever.",focusCancel:!0,onOK:function(){RPC("attachment.delete",{id:r.getArray().integers(),hard:!0},u)}})}},{id:"edit",icon:"Icon-Edit",label:"Edit"},{id:"link",icon:"Icon-Edit-InsertLink",label:"Link",action:function(){var n=(window.location+"").replace(/^(https?:\/\/[^\/]+).*$/,"$1"),e=r.getArray().map(function(e){var t=a.get(e);return n+t.getURL()}),t=new XDialog({title:"File URLs",parent:this,modal:!0,quitBtn:"destroy",resizable:!0}),i=new DlLayout({parent:t,outerSpace:5}),o=new DlEntry({type:"textarea"});o.setValue(e.join("\n")),i.packWidget(o,{pos:"top",fill:"*"}),i.setSize({x:300,y:200}),o.select(),t._focusedWidget=o,t.show(!0)}}],content:o,noBottombarSeparator:!0,bottombar:i.bottombar}),t=e.tb_buttons;e.bb_buttons;function l(e){if(null!=i.page){var t=e.map("id");RPC("attachment.add-to-page",t,i.page,function(){a.fetchIds(function(e){r.reset(t),setTimeout(function(){o.scrollToRecord(t.peek())},10)})})}else u()}function c(){var e=r.size();t.del.enabled(0<e),t.edit.enabled(1==e),t.view.enabled(1==e),t.link.enabled(0<e)}o.on("onRowDblClick",function(){1==r.size()&&i.onDblClick()}),o.on("onKeyPress",function(e){if(0<r.size())if(e.keyCode==DlKeyboard.ENTER)i.onDblClick();else switch(e.keyStr.toLowerCase()){case"v":return t.view.keyClicked();case"e":return t.edit.keyClicked()}}),c(),r.on("onReset onChange".qw(),c),i.fform=n,a.fetchIds(),i.setSize({x:700,y:400}),i.x_acceptFilesDnD(function(e){var t=new XAttachDlg({parent:i,modal:!0});t.on("onUploadFinished",l),t._addFiles(e),t.show(!0)}),i._focusedWidget=o},t.onDblClick=function(){this.x_standard_layout.tb_buttons.view.keyClicked()}});var NOTF=new(DEFINE_HIDDEN_CLASS(null,DlEventProxy,function(e,t){e.DEFAULT_EVENTS=["onNotify"],e.CONSTRUCT=function(){this.addEventListener("onNotify",this._onNotify)},t.listen=function(e,t,n,i){e="onNotf_"+e,this.__eventHooks[e]||this.registerEvents([e]),this.addEventListener(e,t,n,i)},t.listenOnce=function(e,t){var n=function(){t.apply(this,arguments),this.unlisten(e,n)}.$(this);this.listen(e,n)},t.unlisten=function(e,t){this.removeEventListener("onNotf_"+e,t)},t._onNotify=function(e){e="onNotf_"+e,this.hasHooks(e)&&this.applyHooks(e,Array.$(arguments))},t.notify=function(e){e="onNotf_"+e,this.__eventHooks[e]||this.registerEvents([e]),this.applyHooks(e,Array.$(arguments,1))}}));DEFINE_CLASS("XError_RPC",XError,function(e,t){e.INTERNAL_SERVER_ERROR=500,t.handle=function(e){e&&e(this)||XMSG.addMsg("error",this.text),$CONTINUE()}}),DEFINE_CLASS("XError_RPC_Fatal",XError_RPC,function(e,t){e.DEFAULT_ARGS={text:["text","Internal server error"],code:["code",XError_RPC.INTERNAL_SERVER_ERROR],info:["info",null]}});var USER,RPC=function(){var o=[],r={},a=0;function e(e){var t=Array.$(arguments,1),n=t.peek()instanceof Function?t.pop():null,i=++a;return o.push([i,e].concat(t)),r[i]={cmd:e,args:t,handler:n},i}function t(){0<o.length&&(new DlRPC({url:"/@json",data:DlJSON.encode(o),callback:n}).call(),o=[])}function n(e){if(e.success){var t=e.text.decodeJSON(!0);if(t instanceof Array)t.foreach(function(e){2==e.length&&e.unshift(null);var t=e[0],n=e[1],i=e[2];if(t){var o=r[t];delete r[t];var a=i&&i.error?new XError_RPC(i.error):null;o.handler&&o.handler(i,a)}else NOTF.notify(n,i)});else{var n=new XError_RPC_Fatal(t.error);console.log(n)}}}function i(){e.apply(this,arguments),t()}return i.push=e,i.go=t,i}();function TIME_SPENT(e){$("#TIME-SPENT").each(function(){this.innerHTML=e+"s"})}function new_blog_post(){PagePropsDialog.newPage()}function edit_page(e){RPC("page.get-for-edit",e,function(e){YmacsDialog.editPageContent(e)})}function edit_last_page(){RPC("page.get-last-for-edit",function(e){YmacsDialog.editPageContent(e)})}function delete_page(e){XConfirmDialog.ask({text:"Are you absolutely sure to delete this page? <br /> There is no undo!",focusCancel:!0,onOK:function(){RPC("page.delete",e,function(){XMSG.addMsg("info","Done")})}})}function add_comment(e,t){RPC.push("who-am-i",function(e){USER=e}),RPC("page.get",e,function(e){CommentDialog.newComment(e,t)})}function mark_comment_spam(e,t){XConfirmDialog.ask({text:"Are you sure to mark this SPAM?",onOK:function(){window.location.replace("/@validate-comment/"+e+"/"+t+"?spam")}})}function edit_attachments(e){new AttcListDialog({page:e}).show(!0)}