(function(){"use strict";page.disableAutoBuild=true;page.using={texts:["button_text","xsel_text","xsel_resultset_text"]};var e=null;var t;var a;page.commandBindings=$.extend(page.commandBindings,{Save:i,Cancel:u});function n(){var t=e.tag.query.parameters;if(t&&e.tag.query.statement.getParameters){var a=e.tag.query.statement.getParameters();for(var n in t){if(!t.hasOwnProperty(n)){continue}if(a[n]&&a[n].rValue){a[n].rValue._parameter={value:t[n]}}}}}page.onLoad=function(){e=u8.Base.Widgets.Popup.getFromElement(document.body);e.setTitle($t("TXT_xsel_resultset_text_10"));t=e.tag;$assert(t,"Missing property 'tag' on popup object!");if(!t.options){t.options={}}a=$("#contents");var n=s();r(n,function(){a.css("visibility","inherit");e.show()})};function s(){var e=t.query;var a={containsSummedCondition:false,name:t.options.name||"",privateItems:[{key:"Private",text:$t("TXT_xsel_text_19")},{key:"Public",text:$t("TXT_xsel_text_20")}],privateValue:"Private"};var n=u8.services.queries.getMaxRowsOptions({value:o().maxRows||1e3});a.maxRowItems=n.items;a.maxRowValue=n.value;e.statement.each(function(e){if(e.linkType==u8.Crm.QueryLinkType.WithSummed||e.linkType==u8.Crm.QueryLinkType.PlusSummed){a.containsSummedCondition=true}});return a}function r(e,t){a.utml({itemOptions:{parent:page},data:e},t)}function i(){page.notify(null);var a=m();if(!a.name){page.notify("TXT_xsel_resultset_text_18");$widget("name").focus();return}u8.request("QueryChannel.GetSnapshotByName",{name:a.name,isPrivate:a.isPrivate},s);function s(s,r){if(r.error){return}var i=r.response;if(i&&i.name){page.notify($t("TXT_xsel_resultset_text_16"));$widget("name").focus();return}e.busy();if(e.tag.query&&e.tag.query.parameters&&e.tag.query.statement&&e.tag.query.statement.root){n()}t.save(a)}}function u(){e.tag.query.update();e.close()}function o(){return u8.tools.defaults(u8.services.settings.get("QueryResultSnapshots")||{},{maxRows:1e3})}function m(){var e=t.options;e.name=$v("name");e.isPrivate=$v("private")=="Private"?true:false;e.maxRows=parseInt($v("maxRows"));var a=o();a.maxRows=e.maxRows;return e}})();