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));n=new DlButton({parent:e,label:t,focusable:!0});return i&&n.onClick(i),n}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,n;null==e?a.addSeparator():e.widget?a.appendWidget(e.widget):("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),(n=e.h||o)&&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);var e;t._CONFIRM_IN_PROGRESS||(t._CONFIRM_IN_PROGRESS=!0,(e=Object.makeCopy(n instanceof Function?n.call(t):n)).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)return!1;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},Array.prototype.equalLists=function(e,t){if(this.length!=e.length)return!1;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},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)return EQL(e,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},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 USER,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)}),XMSG=(Date.formatNice=function(e,t){if(!e)return t;if(DATE_PLAIN)return e.print("%Y-%m-%d %H:%M");t=new Date;if(t.dateEqualsTo(e))return e.print("Today, %l:%M %P");t.setHours(0),t.setMinutes(0),t.setSeconds(0);var n=t.getTime()-e.getTime();if(0<=n){if(n<Date.DAY)return e.print("Yesterday, %l:%M %P");if(n<2*Date.DAY)return e.print("2 days ago, %l:%M %P");if(n<3*Date.DAY)return e.print("3 days ago, %l:%M %P");if(n<4*Date.DAY)return e.print("4 days ago, %l:%M %P");if(t.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");t=new Date;if(t.dateEqualsTo(e))return e.getHours()==t.getHours()&&e.getMinutes()==t.getMinutes()?"Now":e.print("Today, %l:%M %P");t.setHours(0),t.setMinutes(0),t.setSeconds(0);var n=t.getTime()-e.getTime();if(0<=n){if(n<Date.DAY)return e.print("Yesterday");if(n<2*Date.DAY)return e.print("2 days ago");if(n<3*Date.DAY)return e.print("3 days ago");if(n<4*Date.DAY)return e.print("4 days ago")}return t.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=e.getElement(),n=t.parentNode,i=t.nextSibling;return DlContainer.getHiddenContainer().getElement().appendChild(t),e=e.getOuterSize(),n&&n.insertBefore(t,i),e},DlDesktop.prototype._handle_focusKeys=function(e){var t;e.altKey||e.ctrlKey||e.keyCode==DlKeyboard.TAB&&(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){e=new DlContainer({parent:e});return e.setContent("<table align='center' style='height:100%;' cellspacing='0' cellpadding='0'><tbody><tr><td></td></tr></tbody></table>"),e.getContentElement=function(){return this.getElement().firstChild.firstChild.firstChild.firstChild},e},DlEntry.withClearButton=function(e){var t=new DlEntry(e),e=t._makeButton(null,null,"X-DropDownBigBtn Icon-Cancel",{hover:"X-DropDownBtn-hover",active:"X-DropDownBtn-active"});return e.onClick(function(){t.clear(),t.callHooks("onKey-ENTER")}),e.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){var t;this._popupVisible||((t=this._getContextMenuPopup()).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),e=new Date(e),n=Math.floor(t.getMonth()/4);return t.setDate(1),t.setMonth(n),e.setDate(1),e.setMonth(n+3),e.setDate(e.getDate()-1),[t,e]}}),DEFINE_CLASS("XDialog",DlDialog,function(o,e){function a(){this.getElement().parentNode.style.display=this.display()?"":"none"}function l(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:var t;e instanceof Function?(e=e.call(n))&&e.id&&(i[e.id]=e.widget):(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)}o.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)},o.DEFAULT_EVENTS=["onTitleChange"],o.DEFAULT_ARGS={__noParentKeyBindings:["noParentKB",!0],__noPropEvents:["dontBubbleEvents",/^onKey/i],_winlist:["winlist",!0]},e.FINISH_OBJECT_DEF=function(){o.BASE.FINISH_OBJECT_DEF.apply(this,arguments);var n,i=this.constructor;i.show||(i.show=function(t){function e(e){e&&(t=Object.merge(t,e));e=(n=new i(t||{})).initialSize;return e&&(e.x<=1?n.setPercentSize(e.x,e.y||e.x):n.setOuterSize(e)),n.on("onDestroy",function(){n=null}),n.show(!0),n}return n?n.show(!0):(t=t||{},i.PREINIT?i.PREINIT(e):e()),n},i.killInstance=i.prototype.killInstance=function(){n&&n.destroy(),n=null})},e.initDOM=function(){o.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(){var e;this._my_isMinimized||(this._winlist_btn||((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)}))._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=o.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},o.makeActionButtons=l,o.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"}},o.BUTTONS_WIZARD=["filler",o.BUTTONS.prev,o.BUTTONS.next,o.BUTTONS.finish],o.BUTTONS_OK_CANCEL=["filler",o.BUTTONS.ok,o.BUTTONS.cancel],o.BUTTONS_CLOSE=["filler",o.BUTTONS.close],e.onClose=e.onCancel=function(){this.__quitBtn&&this.__quitBtn.keyClicked()},o.createStandardLayout=function(e,t,n){t&&!n&&(n=t);var i,o,a,u,r=[(e=null==e?{}:e).outerSpace,e.spacing,5].firstNotNull(),t=e.fixed?new DlVbox({parent:t,borderSpacing:r}):new DlLayout({parent:t,outerSpace:r}),r={},s={};return!e.fixed&&e.bigIcon&&((i=new DlWidget).setStyle("padding","20px"),i.setContent("<div class='X-Dialog-Icon "+e.bigIcon+"'></div>"),t.packWidget(i,{pos:"left",after:5})),e.toolbar&&(e.toolbar instanceof DlWidget?o=e.toolbar:(u=(o=new DlContainer({className:"DlToolbar DlToolbar2"})).box=new DlHbox({parent:o,className:"HBoxPadLeft"}),l.call(n,u,r,e.toolbar))),e.bottombar&&(u=(a=new DlContainer({className:e.bottomClass})).box=new DlHbox({parent:a,className:"HBoxPadLeft"}),l.call(n,u,s,e.bottombar)),i=e.content||new DlContainer({className:e.contentClass}),t instanceof DlLayout?(o&&t.packWidget(o,{pos:"top",after:5}),a&&(t.packWidget(a,{pos:"bottom",after:5}),e.noBottombarSeparator||t.packWidget($H_SEP(),{pos:"bottom",after:5})),t.packWidget(i,{pos:"top",fill:"*"})):(o&&t.appendWidget(o),i&&t.appendWidget(i),a&&(e.noBottombarSeparator||t.addSeparator(),t.appendWidget(a))),{layout:t,toolbar:o,tb_buttons:r,content:i,bottombar:a,bb_buttons:s}},e.createStandardLayout=function(e,t){return this.x_standard_layout=o.createStandardLayout(e,this,t)},o.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},o.showError=function(e,t,n){e=new XDialog({title:e,parent:t,modal:!0,quitBtn:"destroy"}),t=e.withIcon("Icon-Dlg-Error");new DlWidget({parent:t}).setContent(n),e.createStandardLayout({fixed:!0,content:t,bottombar:XDialog.BUTTONS_CLOSE}),e.show(!0)}}),{sayRecordSaved:function(){XMSG.addMsg("info","Record saved")},sayRecordRemoved:function(){XMSG.addMsg("info","Record removed")}}),NOTF=(!function(){var e,i=!1,o=!1,a=!1,u=DynarchDomUtils,r=2e3,t=Math,s=DlAnimation.easing.accel_b,l=function(e){return 1-t.cos(3*e*t.PI/2)/t.exp(3*e)},n=DlAnimation.easing.accel_ab;function c(){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(){var e,t;i&&!a&&(o&&o.stop(),e=new DlAnimation,a=e,t=c().getPos().y,e.addEventListener({onUpdate:function(e){c().opacity(s(e).map(1,0)),c().setPos(null,n(e).map(t,t-20))},onStop:function(){i=!1,c().visibility(!1),c().destroyChildWidgets(),a=!1}}),e.start(50,70))};var d=[],p=null,f=0;function h(){var e;d.shift()(),p=0==d.length?null:(e=r-500*f,h.delayed(e=e<=1e3?1e3:e))}function g(e,t,n){var e=new DlWidget({className:"X-Message X-Message-"+e,parent:c()});e.setContent(t),t=function(t){{var e,n;!t||c().children().length<=1?XMSG.popdown():(e=new DlAnimation,n=t.getSize().y,e.addEventListener({onUpdate:function(e){t.opacity(s(e).map(1,0)),t.setStyle({marginTop:l(e).map(0,-n)+"px"})},onStop:function(){t.destroy()}}),e.start(50,100))}}.$C(e),e=n,d.push(t),p?f++:(f=0,p=h.delayed(e||r))}XMSG.addMsg=function(e,t,n){g(e,t,n),e=u.getWindowSize(),t=c().getSize(),n=(e.x-t.x)/2,e=(e.y-t.y)/3,c().setPos(n,2.5*e),i||o||(a&&a.stop(),c().visibility(!0),t=new DlAnimation,(o=t).addEventListener({onUpdate:function(e){c().opacity(s(e))},onStop:function(){o=!(i=!0)}}),t.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,i,o,a=XGenericWidgets.Create(t,this);a&&(n=t.label||null,this.addField({widget:a,name:t.id,tabIndex:this._tabIndex,label:n,valign:t.valign,vtop:t.vtop,align:t.align},null,n={}),n.c1.setStyle({width:"0.01%"}),a.userData=n,a instanceof DlEntry&&a.connectEvents("onKey-ENTER onKey-ESCAPE".qw(),this),(t.x_fill||!t.x_nofill&&a instanceof DlEntry&&!(a instanceof DlSpinner))&&this.fillWidgets.push(a),t.id&&(this.widgets[t.id]={w:a,f:t}),t.h&&(o=new DlButton({parent:this._getActBox(),label:t.h,data:t.id}),this.getField(t.id).refNode("_button",o),(i=n.row.getElement()).parentNode.removeChild(i),o.refNode("showRow",i),o.onClick(this._showRow.$(this,o))),e&&(n.c3=this.addCell(n.row),t.help)&&(o=new DlButton({parent:n.c3,iconClass:"Icon-Help",tooltip:"string"==typeof t.help?t.help:null}),t.help instanceof Function?o.onClick(t.help):o.onClick(XMSG.addMsg.$C("info",t.help))),t.hidden&&n.row.display(!1),"htmlarea"==t.type)&&a.init.delayed(10,a)},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){var t;e&&void 0!==(t=(t=n&&e.id in n?n[e.id]:e.value)instanceof Function?t(e,this):t)&&(i[e.id]=t)},this),this.setValue(i)},t.getAllIds=function(){return this.fields.grep(NOT_NULL).map("id")},t.showValidationErrors=function(e){for(var t in e=e||{},this.getField()){var n=this.getField(t),i=n.parent.parent,t=(n instanceof DlEntry&&n.condClass(t in e,"DlEntry-ValidationError"),i.condClass(t in e,"X-ValidationError"),e[t]);i.setTooltip(t),n.setTooltip(t)}},t.genericErrorHandler=function(o){var a=this;return function(n){var i;n.info instanceof Array&&(i={},n.info.foreach(function(e){var t;a.getField(e.info)?(t=e.text,i[e.info]?i[e.info]+="<br />"+t:i[e.info]=t):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 n,e=t.userData;e.row.display()&&(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){e=XGenericWidgets.Create(e,this);return e instanceof DlEntry&&e.connectEvents("onKey-ENTER onKey-ESCAPE".qw(),this),e},t.addField=function(e){var t,n=this._createField(e),i=(e.id&&(this.widgets[e.id]={w:n,f:e}),n);e.label&&(t=e.label||null,i=new DlHbox,new DlLabel({parent:i,widget:n,label:t}).addParentClass("X-FreeFormLabel"),i.appendWidget(n)),e.x_place?(t=this.id+"-"+e.x_place,n=$("#"+t,this.getElement()).get(0),this._htmlLayout.appendWidget(i,n)):this._htmlLayout.appendWidget(i)},t.getValue=function(){var o={};return Object.foreach(this.widgets,function(e,t){var n,i=(e=e.w).getFormValue||e.getValue;i instanceof Function&&(e instanceof DlAbstractButton&&e._checkTwoState(!0)?"boolean"==typeof(n=i.call(e))?o[t]=n:null==n?o[t]=e.checked():e.checked()&&(o[t]=n):o[t]=i.call(e))}),o},t.setValue=function(e){Object.foreach(e,function(e,t){var n,t=this.getField(t);t&&(n=t.setFormValue||t.setValue)instanceof Function&&(t instanceof DlAbstractButton&&t._checkTwoState(!0)?t.checked("string"==typeof e?"0"!=e:!!e):n.call(t,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){for(var t in e=e||{},this.getField()){var n=this.getField(t),i=n.parent.parent,t=(n instanceof DlEntry&&n.condClass(t in e,"DlEntry-ValidationError"),i.condClass(t in e,"X-ValidationError"),e[t]);i.setTooltip(t),n.setTooltip(t)}},t.genericErrorHandler=function(){var n=this;return function(e){e.info instanceof Array&&e.info.foreach(function(e){var t=n.getField(e.info),e=e.text;t instanceof DlEntry?(t.addClass("DlEntry-ValidationError"),t.setInvalidTooltip(e.htmlEscape())):t.setValidationError&&t.setValidationError(e)})}}}),!function(){function o(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 n(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}),i=(n.set=e.set||o.set(),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 e=o.integers?parseInt(e):e});return e=o.multiple?e:0<e.length?e[0]:null},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,i=e.type instanceof Function?e.type(e):XGenericWidgets[e.type](e);for(n in e)/^on/.test(n)&&i.addEventListener(n,e[n].$(i,t));return i},_mkEntryArgs:o,entry:function(e){return new DlEntry(o(e))},cl_entry:function(e){return DlEntry.withClearButton(o(e))},password:function(e){e=o(e);return e.type="password",new DlEntry(e)},textarea:function(e){var t=o(e),t=(t.type="textarea",new DlEntry(t));return e.fixedHeight||n(t),t},htmlarea:function(e){return new XRichTextEditor},c_entry:function(e){var t,n=o(e),n=(Object.mergeDefined(n,{electric:e.electric,smart:"smart"in e&&e.smart,noTab:!("noTab"in e)||e.noTab}),new DlCompletionEntry(n));return n.addEventListener("onCompletion",e.complete),e.ms_cache&&(t=n._makeButton("Select..."),n.on("onKey-ENTER",t.keyClicked.$(t)),t.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))),n},c_area:function(e){var t=o(e),t=(Object.mergeDefined(t,{electric:e.electric,type:"textarea"}),new DlCompletionEntry(t));return t.addEventListener("onCompletion",e.complete),e.fixedHeight||n(t),t},spinner:function(e){var t=o(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=o(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=o(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=o(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,n=(e instanceof Function&&(e=e()),new(t.vertical?DlVbox:DlHbox)({className:t.vertical?"HBoxPadRight":"VBoxPadDown"})),i=DlRadioGroup.get(),o=(n.registerEvents(["onChange"]),i.connectEvents("onChange",n),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=o(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"}),e=(t.registerEvents(["onChange"]),o(e)),n=(Object.mergeUndefined(e,{decimals:2,size:10}),e.parent=t,new DlSpinner(e)),i=new DlRadioSelect({parent:t,value:"EUR",disabled:e.readonly||e.disabled,options:[{label:"EUR",value:"EUR"},{label:"USD",value:"USD"}]});return[n,i].map("connectEvents","onChange",t),t.setValue=function(e,t){n.setValue(e.amount,!0),i.setValue(e.currency,!0,!0),t||this.callHooks("onChange")},t.getValue=function(){var e=parseFloat(n.getValue());return{amount:e=isNaN(e)?null:e,currency:i.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=e&&(isNaN(e.getTime())?null:e))&&new Date(e),this._dateValidator._date=e,this._updateValue()},e.getFormValue=function(){var e,t;return/\S/.test(this.getValue())?(e=this.getDate(),null!=(t=this._outFormat)?e.print(t):e):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,u=new DlHbox({parent:n,borderSpacing:4});return e.buttons?e.buttons.foreach(function(e){null==e?u.addFiller():new DlButton({parent:u,focusable:!("focusable"in e)||e.focusable,label:e.label,tooltip:e.tooltip,iconClass:e.iconClass}).onClick(function(){e.onClick&&e.onClick()||t.destroy()})}):(u.addFiller(),o=$BUTTON(u,e.okLabel,5).onClick(XConfirmDialog.onBtn.$(t,e.onOK)),(e.onOK||e.onCancel)&&(a=$BUTTON(u,e.cancelLabel,5).onClick(XConfirmDialog.onBtn.$(t,e.onCancel))),t._focusedWidget=e.focusCancel?a:o),t.show(!0),t},onBtn:function(e){this.destroy(),e&&e()}},DEFINE_CLASS("XFileRecord",DlRecord,function(e,t,o){function n(t,n,i){null==i&&(i=Function.noop);var e=new FileReader;return o.addEvent(e,{load:function(e){t.set("progress",1),i(1),n(e.target.result)},progress:function(e){e.lengthComputable&&(e=e.loaded/e.total,t.set("progress",e),i(e))},error:function(e){n(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=[],e=e.get("progress");return 1==e?t.push("UploadRecord-Complete"):null!=e&&t.push("UploadRecord-Working"),t.join(" ")},e.upload=function(e,n,i){var o=new XMLHttpRequest,a=(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)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)}n(e,t)}else{t=new XError_RPC_Fatal({text:o.responseText,code:o.status});n(null,t)}},new FormData);this.getAllRecords().foreach(function(e,t){a.append("upload"+t,e.get("file"))}),o.send(a)},e.addFile=function(e,t){e=new XFileRecord(e);return e.listenOnce("onLoad",t),(this._data[e.id()]=e)._set=this,e.id()}}),DEFINE_CLASS("XFileUploadButton",DlButton,function(t,e,n){t.DEFAULT_ARGS={_multiple:["multiple",!1],_withRecord:["withRecord",!1]},e.initDOM=function(){t.BASE.initDOM.apply(this,arguments),this.setStyle({position:"relative",overflow:"hidden"});var e=this.getElement(),e=n.createElement("input",{position:"absolute",right:"-3px",top:"-3px",width:"100%",height:"100%",padding:"6px"},{type:"file",multiple:this._multiple},e);this.refNode("_input",e),n.setOpacity(e,0),n.addEvent(e,"change",this.$("_on_fileChange"))},e._setupFiles=function(e){var t,n=(e=Array.$(e)).length;this._withRecord?this._multiple?this.setValue(e.map(function(e){e=new XFileRecord(e);return e.listenOnce("onLoad",function(e){e&&0==--n&&this.callHooks("onChange")}.$(this)),e},this)):((t=new XFileRecord(e[0])).listenOnce("onLoad",function(e){this.callHooks("onChange")}.$(this)),this.setValue(t)):(this.setValue(e),this.callHooks("onChange"),this._input.value="")},e._on_fileChange=function(){this._setupFiles(this._input.files)},e.x_acceptFilesDnD=function(){t.BASE.x_acceptFilesDnD.call(this,function(e){this._setupFiles(e)})},e.getFormValue=function(){var e=this.getValue();return e=null!=e&&this._withRecord?this._multiple?e.map("getFormValue"):e.getFormValue():e},DlWidget.prototype.x_acceptFilesDnD=function(t){n.addEvent(this.getElement(),{dragenter:n.stopEvent,dragover:n.stopEvent,drop:function(e){n.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}]}),i=(e.resetIDS([]),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,i=(this.__quitBtn=null,new DlDialog({parent:this,title:"Sending data",modal:!0})),e=new DlContainer({parent:i}),o=(e.setStyle({padding:"20px"}),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 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 o(e){return t.letter.test(e)}function u(e){return 48<=(e=e.charCodeAt(0))&&e<=57}var r={is_letter:o,is_digit:u,is_alphanumeric:function(e){return u(e)||o(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){for(var t={},n=(e="string"==typeof e?e.split(/\s+/):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 C(e,t){this.tag=e,this.klass=t}function s(i,t){i=i.replace(/\r\n/g,"\n");var n="",o=0,a=1,u=0,e=0,r=o,s=[];function l(){return 1e3<=e&&h("peek() has been called 1000 times.  Endless loop?"),o===r?e++:(e=0,r=o),o<i.length?i.charAt(o):null}function c(){var e=l();return++o,"\n"==e?(++a,u=0):++u,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,n;return e instanceof RegExp?(t=e.exec(d()),n=t?t.index:i.length):"string"==typeof e&&(n=i.indexOf(e,o))<0&&(n=i.length),p(function(){return o<n})}function h(e){throw new Error(e+"["+a+":"+u+","+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 D(e){if("string"==typeof(e=e instanceof Array?e.join(" "):e)?s.push(e=new C("span",e)):s.push(e=new C(e.tag,e.klass)),n+=e.open(),1<arguments.length){for(var t=1;t<arguments.length;++t)m(arguments[t]);_()}}function _(){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){for(var t="",n=(D("string"),m(["string-start",e]),D("string-body"),!1);l();){this.coop();var i=c();if(n)t+=i,m(i),n=!1;else if("\\"==i)t+=i,m(i),n=!0;else{if(i==e)break;t+=i,m(i)}}return _(),m(["string-end",e]),_(),t},read_to:f,eat:function(e){if((e=e.exec(d()))&&e[0]){for(var t=e[0].length;0<t--;)c();return e}},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 1}});return m(t),t},skip_to:function(e,t){e=f(e),m(t?[t,e]:e)},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:D,pop:_,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 u},coop:function(){var e=t&&t.coop;if(e)return e()},set_lang:function(e){t=e},output:function(){return n}}}C.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){a[e]=(e,t)(r)},highlight:function(e,t,n){var i=a[e],o=s(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"),F=y.to_regexp("with(out)?-[^\\s]+ define-[^\\s]+ def-[^\\s]+","i"),w=y.to_hash("t nil"),k=y.to_hash("error assert warn croak"),i=/^[(){}\[\]#\s`'"\\]$/i;return function(p){var f=!1,h=0,g=null,m=null;function D(e){return!(m&&0<=m.indexOf(e)||i.test(e))}function _(){var e=p.read_while(D);if(0<e.length)return t.test(e)?[["number"],e]:y.satisfies(e,n)?[["keyword"],e]:[["symbol"],e]}function C(e){var t=g;g=0,p.push("list"),p.skip(p.peek(),"list-start");e:for(;;){switch(p.skip_ws(),p.peek()){case e:p.skip(e,"list-end");break e;case null:break e;case";":A();break;case".":p.skip(".","list-dot");break;default:b()}++g}p.pop(),g=t}function A(){p.push("comment"),p.skip(/^;+/,"comment-start"),p.skip(/.*/,"comment-body"),p.pop()}function E(){var e;return p.push("string",["string-start",p.next()],["string-body",e=p.read_escaped('"')],["string-end",'"']),e.replace(/\\(.)/g,"$1")}function b(e,t){var n,i,o,a=m;try{if(m=e,p.skip_ws(),!p.coop()){switch(p.skip_ws(),p.peek()){case";":return A();case'"':return E();case"(":return C(")");case"[":return C("]");case"`":return o=h,++h,p.push("quasiquote"),p.skip(p.peek(),"quasiquote-start"),b(),p.pop(),void(h=o);case",":return i=h,--h,p.push("unquote"),p.skip(/^,@?/,"unquote-start"),b(),p.pop(),void(h=i);case"'":return n=f,f=!0,p.push("quote"),p.skip(p.peek(),"quote-start"),b(),p.pop(),void(f=n);case"#":switch(p.next(),p.peek()){case"/":p.next();var u=p.read_escaped("/"),r=p.read_while(function(e){return 0<="gmiy".indexOf(e)});p.push("regexp",["regexp-start","#/"],["regexp-body",u],["regexp-end","/"+r]);break;case"'":p.next();u=_();u[0].push("function"),p.put("#'"),p.put(u);break;case"\\":p.next();r=p.next()+p.read_while(D);p.put(["char","#\\"+r]);break;case"x":p.push("number"),p.put("#"),p.skip(/^x[a-f0-9]+/i),p.pop();break;case"o":p.push("number"),p.put("#"),p.skip(/^x[0-7]+/i),p.pop();break;case"+":case"-":p.push("declaration"),p.put("#"),p.put(_()),p.pop();break;case"t":case"T":case"f":case"F":p.push("constant"),p.put("#"),p.put(p.next()),p.pop();break;case"(":p.push("array"),p.put("#"),C(")"),p.pop();break;case":":p.next(),p.push("uninterned-symbol","#:",_());break;default:p.put("#"),p.skip(p.peek())}return;case null:return!1}var s,l,c=p.col(),d=_();d?(s=d[0],l=d[1].toLowerCase(),h||f||(y.satisfies(l,w)&&s.push("constant"),/^:/.test(l)&&s.push("keyword-symbol"),/^&/.test(l)&&s.push("keyword-symbol","lambdaword"),(/^\*.*\*$/.test(l)||/^\+.*\+$/.test(l))&&s.push("global"),(0==g||t)&&(s.push("formpos"),y.satisfies(l,F)&&s.push("macro"),y.satisfies(l,k))&&s.push("assert"),/>$/.test(l)&&0==c&&s.push("repl-package")),p.put(d)):p.skip(/./,"error")}}finally{m=a}}return{next:b,read_comment:A,read_string:E,read_token:b}}}),ColoroloC.deflang("xml",function(l){return function(a,u){var r=[];function e(){for(;!a.eof()&&!a.coop();)switch(a.peek()){case"<":if(a.looking_at("\x3c!--"))a.push(["comment","xmlcomment"]),a.skip(/^<!--/,["comment-start","xmlcomment-start"]),a.skip_to("--\x3e",["comment-body","xmlcomment-body"]),a.skip(/^-->/,["comment-end","xmlcomment-end"]),a.pop();else if(a.looking_at("<![CDATA["))a.push(["quote","xmlcdata"]),a.skip(/^<!\[CDATA\[/,["quote-start","xmlcdata-start"]),a.skip_to("]]>",["quote-body","xmlcdata-body"]),a.skip(/^\]\]>/,["quote-end","xmlcdata-end"]),a.pop();else if(a.looking_at(/^<[!?]/))a.push(["declaration","xmldecl"]),a.skip(/^<[!?]/,["declaration-start","xmldecl-start"]),a.skip(/^[^>]*/,["declaration-body","xmldecl-body"],!0),a.skip(/^>/,["declaration-end","xmldecl-end"]),a.pop();else{var e,t;if(a.looking_at("</"))t=e=n=void 0,n=r.at(-1)?.id,a.push(["list-end"]),a.skip(/^<\x2f/,"xmltag-start"),e=["keyword","xmltag"],t=s(),n&&(t!=n&&e.push("error"),r.pop()),a.put([e,t]),a.skip_ws(),a.skip(/^>/,"xmltag-end"),a.pop();else{o=i=n=void 0,a.push(["list-start"]),a.skip("<","xmltag-start");var n=s(),i=Object.create(null);for(a.put([["keyword","xmltag"],n]),a.skip_ws();!a.looking_at(/^[\x2f>]/);){a.skip_ws(),a.coop();var o=a.peek();l.is_letter(o)||l.is_digit(o)||":"==o||"_"==o||"-"==o?function(e){var t=s(),n=null;a.put([["keyword-symbol","attribute"],t]),a.skip_ws(),a.looking_at("=")&&(a.skip("="),a.skip_ws(),a.looking_at(/^['"]/)?n=void a.read_string_coop(a.next()):a.skip(/^[^\s>]*/,"string"));e[t]=n}(i):a.looking_at(/^[\x2f>]/)||a.put(a.next())}a.looking_at("/>")?(a.skip("/",["keyword","xmltag"]),a.skip(">","xmltag-end"),a.pop()):(a.skip_to(">"),a.skip(">","xmltag-end"),a.pop(),u?.RX_EMPTY_TAG?.test(n)||r.push({id:n,attr:i}))}}break;case"&":a.looking_at(/^&.*?;/)?a.skip(/^&.*?;/,["constant","xmlentity"]):a.put(a.next());break;default:a.skip()}}function s(){return a.read_while(function(e){return l.is_letter(e)||l.is_digit(e)||":"==e||"-"==e||"_"==e})}return{tags:r,next:e,read_text:e}}}),ColoroloC.deflang("syt",function(e){return function(i,e){var o=ColoroloC.langdef("lisp")(i),a=ColoroloC.langdef("xml")(i),u=e.start_lisp?o:a,r="{",s="}";return{next:u.next,coop:function(){if(u===a){if(0==i.col()){if(i.looking_at("\\;"))return i.skip("\\","comment"),i.skip(";"),i.coop();if(";"==i.peek())return o.read_comment(),i.coop()}if(i.looking_at("\\"+r)||i.looking_at("\\"+s))i.skip(i.peek(),"comment"),i.skip(i.peek());else if(i.looking_at(/^\\~$/m))i.skip(i.peek(),"comment"),i.skip(i.peek());else if(i.looking_at(/^~$/m))i.skip("~",["assert","syt-join-lines"]);else{if(i.peek()!=r)return i.peek()==s?"break":void 0;if(u=o,i.push(["sublang","sublang-lisp","syt-lisp"]),i.skip(r,["sublang-start","sublang-lisp-start","syt-lisp-start"]),i.skip_ws(),i.looking_at(/^\.syntax/i)){i.skip(/\.syntax/i,"declaration syt-declaration"),i.skip_ws();var e=o.read_string(),t=(i.skip_ws(),o.read_string());i.skip_ws(),r=e,s=t,i.skip(null,["sublang-end","sublang-lisp-end","syt-lisp-end"])}else{for(var e="\\"==i.peek(),n=(e&&(i.push("syt-escaped"),i.skip("\\","assert")),0);;)if(o.read_token(r+s,0==n++),i.skip_ws(),!i.peek()||i.looking_at("|")||i.looking_at(s))break;if(e&&i.pop(),"|"==i.peek()){for(i.push("syt-lisp-filters"),i.skip("|",["assert","syt-lisp-filters-start"]),i.skip_ws();!i.eof()&&!i.looking_at(s);)o.read_token(r+s),i.skip_ws();i.pop()}i.skip(s,["sublang-end","sublang-lisp-end","syt-lisp-end"])}i.pop(),u=a}return i.coop()}if(u===o&&i.peek()==r)return u=a,i.push(["sublang","sublang-xml","syt-xml"]),i.skip(r,["sublang-start","sublang-xml-start","syt-xml-start"]),a.next(),i.skip(s,["sublang-end","sublang-xml-end","syt-xml-end"]),i.pop(),u=o,"break"}}}}),ColoroloC.deflang("js",function(t){var r=t.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"),s=t.to_regexp("boolean byte char double float int long short"),l=t.to_regexp("false null this true"),c=t.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"),d=/^0x[0-9a-f]+$/i,p=/^0[0-7]+$/,f=/^\d*\.?\d*(?:e[+-]?\d*(?:\d\.?|\.?\d)\d*)?$/i;function h(e){return t.is_digit(e)||(e=e,t.is_letter(e))||"$"==e||"_"==e}return function(o){function a(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()}function u(){var e;for(o.push("string template-string"),o.skip("`","string-start"),o.push("string-body");e=o.peek();)if("\\"==e)o.put(o.next()),o.put(o.next());else{if("`"==e)break;if(o.looking_at("${")){for(o.push("embedded"),o.skip("${","embedded-start"),o.push("embedded-body");o.peek()&&(o.skip_ws(),"}"!=o.peek());)t();o.pop(),o.looking_at("}")&&o.skip("}","embedded-end"),o.pop()}else o.put(o.next())}o.pop(),"`"==e&&o.skip("`","string-end"),o.pop()}function t(){o.skip_ws();var e,t,n,i=o.peek();if(i){if(o.looking_at("//"))o.push("comment"),o.skip(/^\/\//,"comment-start"),o.skip(/.*/,"comment-body");else{if(!o.looking_at("/*"))return h(i)?o.put((t=o.read_while(h),d.test(t)||p.test(t)||f.test(t)?[["number"],t]:r.test(t)?[["macro"],t]:s.test(t)?[["type"],t]:l.test(t)?[["constant"],t]:c.test(t)?[["keyword"],t]:(e=[["symbol"],t],t.toUpperCase()==t&&e[0].push("global"),e))):o.looking_at("(")?a(")"):o.looking_at("{")?a("}"):o.looking_at("[")?a("]"):o.looking_at(/^[\'\"]/)?(t=o.next(),o.push("string",["string-start",t],["string-body",e=o.read_escaped(t)],["string-end",t]),e.replace(/\\(.)/g,"$1")):o.looking_at("`")?u():void((n=o.looking_at(/^(?:=>|\.\.\.)/))?o.skip(n[0],"keyword"):o.looking_at(/^#!\s*/)?(o.push("declaration"),o.skip(/^#!\s*/,"declaration-start"),o.skip(/.*/,"declaration-body"),o.pop()):o.looking_at(/^==>/)?o.skip("==>","assert"):(n=o.looking_at(/^==\((.*?)\)==>/))?(o.skip("==(","assert"),o.skip(n[1],"comment"),o.skip(")==>","assert")):("/"==i&&o.looking_back(/(return|else|do|(for|if|while)\s*\(.*\)|[\(\[\{?+:\/-])\s*$/)&&(o.next(),n=o.read_escaped("/"),i=o.read_while(function(e){return 0<="gmsiyu".indexOf(e)}),o.push("regexp",["regexp-start","/"],["regexp-body",n],["regexp-end","/"+i])),o.put(o.next())));o.push("comment"),o.looking_at(/^\/\*+\//)?o.skip(/^\/\*+\//,"comment-body"):(o.skip(/^\/\*+/,"comment-start"),n=o.read_to("*/"),o.put(n,"comment-body"),o.skip(/^\*\//,"comment-end"))}o.pop()}}return{next:t}}}),ColoroloC.deflang("css",function(t){var o=/^@[a-z]+/i,a=/^\.[a-z0-9_-]+/i,u=/^#[a-z0-9-]+/i,r=/^[a-z0-9-]+:/i,s=/^:[a-z0-9-]+/i,l=/^(#[0-9a-f]+|[0-9.]+(?:e[+-]?\d*(?:\d\.?|\.?\d)\d*)?)(em|cm|px|pt|in|s|%|rem|vw|vh|vmin)?/i;function c(e){return t.is_letter(e)||"$"==e||"_"==e||"-"==e}function d(e){return c(e)||t.is_digit(e)}return function(n){function i(e){for(n.push("list"),n.skip(n.peek(),"list-start");n.peek();){if(n.skip_ws(),n.peek()==e){n.skip(e,"list-end");break}t()}n.pop()}function t(){n.skip_ws();var e,t=n.peek();if(t){if(n.looking_at("//"))n.push("comment"),n.skip(/^\/\//,"comment-start"),n.skip(/.*/,"comment-body");else{if(!n.looking_at("/*"))return(e=n.eat(a))?n.put([["function "],e[0]]):(e=n.eat(u))?n.put([["constant "],e[0]]):(e=n.eat(o))?n.put([["macro"],e[0]]):(e=n.eat(s))?n.put([["keyword-symbol"],e[0]]):(e=n.eat(r))?n.put([["keyword"],e[0]]):(e=n.eat(l))?(n.put([["number"],e[1]]),void(e[2]&&n.put([["regexp"],e[2]]))):c(t)?n.put((e=n.read_while(d),t=[["symbol"],e],e.toUpperCase()==e&&t[0].push("global"),t)):n.looking_at("(")?i(")"):n.looking_at("{")?i("}"):n.looking_at("[")?i("]"):n.looking_at(/^[\'\"]/)?(e=n.next(),n.push("string",["string-start",e],["string-body",t=n.read_escaped(e)],["string-end",e]),t.replace(/\\(.)/g,"$1")):void n.put(n.next());n.push("comment"),n.looking_at(/^\/\*+\//)?n.skip(/^\/\*+\//,"comment-body"):(n.skip(/^\/\*+/,"comment-start"),e=n.read_to("*/"),n.put(e,"comment-body"),n.skip(/^\*\//,"comment-end"))}n.pop()}}return{next:t}}}),ColoroloC.deflang("lambda",function(e){var r=e.to_regexp("false null true"),s=e.to_regexp("let if then else lambda λ"),l=e.to_regexp("js:raw error assert croak"),c=/^\d*\.?\d*(?:e[+-]?\d*(?:\d\.?|\.?\d)\d*)?$/i;return function(n){function i(){n.push("comment"),n.skip(/^(#+|\/\/+)/,"comment-start"),n.skip(/.*/,"comment-body"),n.pop()}function o(e){return/[a-zλ_0-9]/i.test(e)}function a(e){return o(e)||0<="?!-<:>=0123456789".indexOf(e)}function t(){if(n.skip_ws(),!n.eof())return n.looking_at("#")||n.looking_at("//")?i():n.looking_at('"')?(t=n.next(),n.push("string",["string-start",t],["string-body",e=n.read_escaped(t)],["string-end",t]),e.replace(/\\(.)/g,"$1")):n.looking_at("(")?u(")"):n.looking_at("{")?u("}"):n.looking_at("[")?u("]"):o(n.peek())?n.put((t=n.looking_back(/(lambda|λ|let)\s*$/),e=n.read_while(a),s.test(e)?[["keyword"],e]:l.test(e)?[["assert"],e]:r.test(e)?[["constant"],e]:c.test(e)?[["number"],e]:t?[["macro"],e]:[["symbol"],e])):void n.put(n.next());var e,t}function u(e){for(n.push("list"),n.skip(n.peek(),"list-start");n.peek();){if(n.skip_ws(),n.peek()==e){n.skip(e,"list-end");break}t()}n.pop()}return{next:t}}}),ColoroloC.deflang("html",function(e){return function(e){var t=ColoroloC.langdef("xml")(e,{RX_EMPTY_TAG:/^(?:area|base|br|col|embed|hr|img|input|link|meta|param|source|track|wbr)$/i}),n=ColoroloC.langdef("js")(e),i=ColoroloC.langdef("css")(e),o=t;return{coop:function(){if(o===t){var e=o.tags.at(-1);if(e&&!e.parsed)return e.parsed=!0,"script"==e.id?o=n:"style"==e.id?o=i:void 0}},next:function(){return e.skip_ws(),(o=(o=o===n&&e.looking_at(/^<\/script/i)?t:o)===i&&e.looking_at(/^<\/style/i)?t:o).next()}}}}),!function(F,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,F(".theme-css").each(function(){this.disabled=F(this).attr("name")!=t}),document.documentElement.className="theme-"+t},e.toggleColorTheme=function(){e.setColorTheme("light"==e.getColorTheme()?"dark":"light")},e.getColorTheme=function(){return t("colorTheme")||(e.matchMedia&&e.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light")},e.getProp=t,e.setProp=i,e.ITS_ALIVE_HAHAHA=function(){setTimeout(function(){F("pre.ColoroloC, code.ColoroloC").each(function(){var e,t,n,i,o,a,u=F(this).attr("lang");u&&(a=(a=F(this).text()).replace(/^\n+|\s+$/g,""),e=null!=(e=F(this).attr("options"))?new Function("return {"+e+"}")():{},e=ColoroloC.highlight(u,a,e),F(this).html(e),/^pre$/i.test(this.tagName))&&(t=this,n=u,i=a,o=e,u=new DlHbox({className:"DlToolbar action-buttons"}),t.appendChild(u.getElement()),a=new DlButton({parent:u,iconClass:"Icon-NewWindow",tooltip:"Popup in dialog"}),F(t).attr("editor")&&new DlButton({parent:u,iconClass:"Icon-Ymacs",tooltip:"Edit in Ymacs"}).onClick(function(){var e=F(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)}))});var e=document.getElementById("bazon-fractal"),t=e.offsetWidth,n=e.offsetHeight,i=e.getContext("2d"),o=.7<=Math.random()?1:-1,a=160*(.7<=Math.random()?1:-1)*Math.random(),u=140+40*Math.random(),r=140+40*Math.random(),s=250+200*Math.random(),l=n*s;for(var c=[],d=0,p=1/(8-1);d<=1;d+=p){var f=d.mapInt(0,255),h=d.mapInt(0,255),g=d.mapInt(0,255);c.push(f<<16|h<<8|g)}e.width=t,e.height=n;for(var m,D,_,c=c.concat(c.slice(c.length/3).reverse()),C=i.createImageData(t,n),A=0;A<t;++A)for(var E=0;E<n;++E){var b=A-t/2,y=E-n/2,y=0<(b=(u*b*b+a*y*b+o*r*y*y)%l)?b:l+b;b=C,m=A,D=E,_=y,_=Math.floor(c.length*(y/l)),y=c[_],D=D*b.width+m<<2,(m=b.data)[D]=(16711680&y)>>16,m[1+D]=(65280&y)>>8,m[2+D]=255&y,m[3+D]=255}i.putImageData(C,0,0)},10)}}($,window),$(document).ready(function(){var e=new DlContainer,t=($("#x-desktop").append(e.getElement()),X.desktop={cont:DlDialog.getTopWM(),winlist_bar:e,winlist:[]},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 t=new XGenericForm({fields:[{id:"user",label:"User:"},{id:"pass",label:"Password:",type:"password"}]}),n=(this.onOK=function(){var e=t.getValue();RPC("login",e.user,e.pass,function(e){null!=e?window.location.reload(!0):XMSG.addMsg("error","Something went wrong.")})},this.createStandardLayout({content:t,fixed:!0,bottombar:XDialog.BUTTONS_OK_CANCEL}));"user pass".qw().foreach(function(e){t.getField(e).on("onKey-ENTER",n.bb_buttons.ok.$("keyClicked"))}),this._focusedWidget=t.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.setPercentSize(.5,.5)},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"}]});e&&(e.parent&&(t.parent_page=e.parent),(e=Object.makeDeepCopy(e)).tags&&(e.tags=e.tags.map("label").join(", ")),n.setValues(e)),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,t){var n=this;n._fetchRecords(e,function(e){e=e.map(function(e){e=new n.RecordClass({data:e,recordSet:n});return n._data[e.get("id")]=e});e.map(function(e){n.callHooks("onChange",e)}),t&&t(e)})},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=String.template("<table cellspacing='0' cellpadding='0'><tr>",n("search"),n("all_pages"),"</tr></table>");function n(e){return"<td style='padding-right: 5px' id='$id-"+e+"'></td>"}e.CONSTRUCT=function(){var n,i=this,a=(i.page,this.set=new AttcRecordSet),u=(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},this.sel=new DlSelectionModel({multiple:!0})),o=new DlDataGrid({selection:u,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){e=e.get("size");return null==e?"—":"<div>"+e.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"}]}),r=(a.connectGrid(o),a.$("fetchIds",null)),s=r.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){"Enter"==t.key?(r(),DlException.stopEventBubbling()):"Escape"==t.key?(this.clear(),r(),DlException.stopEventBubbling()):s()},onChange:r},null!=i.page&&{id:"all_pages",label:"In all pages",type:"checkbox",x_place:"all_pages",onChange:r}].flatten()})},"fill",{id:"view",icon:"Icon-View",label:"View",action:function(){var e=u.getFirst();null!=e&&(e=a.get(e),window.open(e.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:u.getArray().integers(),hard:!0},r)}})}},{id:"edit",icon:"Icon-Edit",label:"Edit"},{id:"link",icon:"Icon-Edit-InsertLink",label:"Link",action:function(){var t=(window.location+"").replace(/^(https?:\/\/[^\/]+).*$/,"$1"),e=u.getArray().map(function(e){e=a.get(e);return t+e.getURL()}),n=new XDialog({title:"File URLs",parent:this,modal:!0,quitBtn:"destroy",resizable:!0}),i=new DlLayout({parent:n,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(),n._focusedWidget=o,n.show(!0)}}],content:o,noBottombarSeparator:!0,bottombar:i.bottombar}),t=e.tb_buttons;e.bb_buttons;function l(e){var t;null!=i.page?(t=e.map("id"),RPC("attachment.add-to-page",t,i.page,function(){a.fetchIds(function(e){u.reset(t),setTimeout(function(){o.scrollToRecord(t.peek())},10)})})):r()}function c(){var e=u.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==u.size()&&i.onDblClick()}),o.on("onKeyPress",function(e){if(0<u.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(),u.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()}}),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){this.__eventHooks[e="onNotf_"+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){this.hasHooks(e="onNotf_"+e)&&this.applyHooks(e,Array.$(arguments))},t.notify=function(e){this.__eventHooks[e="onNotf_"+e]||this.registerEvents([e]),this.applyHooks(e,Array.$(arguments,1))}}))),RPC=(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]}}),function(){var o=[],a={},u=0;function e(e){var t=Array.$(arguments,1),n=t.peek()instanceof Function?t.pop():null,i=++u;return o.push([i,e].concat(t)),a[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){e.success&&((e=e.text.decodeJSON(!0))instanceof Array?e.foreach(function(e){2==e.length&&e.unshift(null);var t,n=e[0],i=e[1],e=e[2];n?(t=a[n],delete a[n],n=e&&e.error?new XError_RPC(e.error):null,t.handler&&t.handler(e,n)):NOTF.notify(i,e)}):(e=new XError_RPC_Fatal(e.error),console.log(e)))}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(t,n){RPC("who-am-i",function(e){USER=e,CommentDialog.newComment({id:t},n)})}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)}