if(!window.jGroupdocs)window.jGroupdocs={};window.jGroupdocs.stringExtensions={format:function(c){var b=c,a=arguments.length;while(--a)b=b.replace(new RegExp("\\{"+(a-1)+"\\}","gm"),arguments[a]);return b},trim:function(b,a){var c=new RegExp("^["+a+"]+|["+a+"]+$","g");return b.replace(c,"")},trimStart:function(a,b){var c=new RegExp("^["+b+"]+","g");return a.replace(c,"")},trimEnd:function(a,b){var c=new RegExp("["+b+"]+$","g");return a.replace(c,"")},getAccentInsensitiveRegexFromString:function(f){for(var b=[["A","ÀÁÂÃÄÅÆ"],["C","Ç"],["E","ÈÉÊËÆ"],["I","ÌÍÎÏ"],["N","Ñ"],["O","ÒÓÔÕÖØ"],["S","ß"],["U","ÙÚÛÜ"],["Y","Ÿ"],["У","Ў"],["a","àáâãäåæ"],["c","ç"],["e","èéêëæ"],["i","ìíîï"],["n","ñ"],["o","òóôõöø"],["s","ß"],["u","ùúûü"],["y","ÿ"],["у","ў"]],c="",a=0;a<b.length;a++)c+=b[a][0];var d=new RegExp("["+c+"]","g");function e(c){return c.replace(d,function(d){var c=null;for(a=0;a<b.length;a++)if(b[a][0]==d){c=b[a][1];break}if(c===null)c="";return"["+d+c+"]"})}return e(f)},_padWithLeadingZeros:function(a){return(new Array(5-a.length)).join("0")+a},_unicodeCharEscape:function(a){return"\\u"+this._padWithLeadingZeros(a.toString(16))},unicodeEscape:function(a){var b=this;return a.split("").map(function(a){var c=a.charCodeAt(0);return c>127?b._unicodeCharEscape(c):a}).join("")}};window.jGroupdocs.http={splitUrl:function(){var a=new RegExp("(\\w+)://([^/]+)([^?]*)([?].+)?");return function(e){var b=e.match(a),d=b.length>3?b[3]:null,c=b.length>4?b[4]:null;return{schema:b[1],authority:b.length>2?b[2]:null,path:d,query:c,queryDict:$.fn.q(c),pathAndQuery:c?d+c:d}}}()};JsInject={Container:function(){this.serviceEntries=[];this.disposables=[]}};JsInject.Container.prototype.Resolve=function(a,c,b,d,e,f,g,h,i,j){return this.ResolveInternal(a,!0,c,b,d,e,f,g,h,i,j)};JsInject.Container.prototype.TryResolve=function(a,c,b,d,e,f,g,h,i,j){return this.ResolveInternal(a,!1,c,b,d,e,f,g,h,i,j)};JsInject.Container.prototype.RegisterInternal=function(a,c,b,d){if(this.RegisteredInternal(a))throw"Factory with name '"+a+"' alredy registered";this.serviceEntries[a]={factory:c,scope:b,owner:d,instance:null}};JsInject.Container.prototype.Dispose=function(){for(var a in this.disposables)this.disposables[a].Dispose()};JsInject.Container.prototype.ResolveInternal=function(a,k,b,c,d,e,f,g,h,i,j){if(!this.RegisteredInternal(a))if(k)throw"Factory with name '"+a+"' is not registered";else return null;a=this.serviceEntries[a];if(a.scope==="container"){if(a.instance===null)a.instance=this.CreateInstanceInternal(a.factory,a.owner,b,c,d,e,f,g,h,i,j);return a.instance}return this.CreateInstanceInternal(a.factory,a.owner,b,c,d,e,f,g,h,i,j)};JsInject.Container.prototype.CreateInstanceInternal=function(a,c,b,d,e,f,g,h,i,j,k){a=a(this,b,d,e,f,g,h,i,j,k);c==="container"&&typeof a.Dispose==="function"&&this.disposables.push(a);return a};JsInject.Container.prototype.RegisteredInternal=function(a){return this.serviceEntries[a]!==void 0};JsInject.Registration=function(a,b){this.name=a;this.factory=b;this.scope="none";this.owner="consumer"};JsInject.Registration.prototype.Reused=function(){this.scope="container";this.Owned();return this};JsInject.Registration.prototype.Owned=function(){this.owner="container";return this};JsInject.ContainerBuilder=function(){this.registrations=[]};JsInject.ContainerBuilder.prototype.Register=function(b,c){var a=new JsInject.Registration(b,c);this.registrations.push(a);return a};JsInject.ContainerBuilder.prototype.Create=function(){var b=new JsInject.Container,c;for(c in this.registrations){var a=this.registrations[c];b.RegisterInternal(a.name,a.factory,a.scope,a.owner)}return b};JsInject.Container.prototype.Register=function(a,c,b){a=new JsInject.Registration(a,c);b&&a.Reused();this.RegisterInternal(a.name,a.factory,a.scope,a.owner)};if(!window.jSaaspose)window.jSaaspose={};if(!window.Container){window.Container=new JsInject.Container;Container.Register("Cacher",function(){return $.jCacher},true);Container.Register("Rx.Observable",function(){return Rx.Observable},true);Container.Register("RequestObservable",function(){return $.ajaxAsObservable},true);Container.Register("AsyncSubject",function(){return new Rx.AsyncSubject},false);var host=window.location.hostname+(window.location.port?":"+window.location.port:""),applicationPath=$.ui.groupdocsViewer.prototype.applicationPath;if(applicationPath=="/"){applicationPath=window.location.protocol+"//"+host+"/";$.ui.groupdocsViewer.prototype.applicationPath=applicationPath}if(applicationPath!="/"){var slashPosition=applicationPath.indexOf("//");if(slashPosition==-1){var newApplicationPath=window.location.protocol+"//"+host+applicationPath;$.ui.groupdocsViewer.prototype.applicationPath=newApplicationPath}var hostNamePosition=slashPosition+2;if(applicationPath.indexOf(host,hostNamePosition)!=hostNamePosition)$.ui.groupdocsViewer.prototype.isWorkingCrossDomain=true}Container.Register("PortalService",function(){return new jSaaspose.PortalService($.ui.groupdocsViewer.prototype.applicationPath,$.ui.groupdocsViewer.prototype.useHttpHandlers,$.ui.groupdocsViewer.prototype.isWorkingCrossDomain)},true);Container.Register("HttpProvider",function(){return{buildUrl:function(d,b,c){var a=jGroupdocs.stringExtensions.trimEnd(d,"/");if(b&&b.length>0)a+="/"+jGroupdocs.stringExtensions.trimStart(b,"/");if(c)a+=(a.indexOf("&")!=-1||a.indexOf("?")!=-1?"&":"?")+jQuery.param(c);return a},signUrl:function(){return""}}},true)}(function(a){a.fn.ellipsis=function(c){var b=document.documentElement.style;return!("textOverflow"in b||"OTextOverflow"in b)?this.each(function(){var b=a(this);if(b.css("overflow")=="hidden"){var f=b.html(),h=b.width(),e=a(this.cloneNode(true)).hide().css({position:"absolute",width:"auto",overflow:"visible","max-width":"inherit"});b.after(e);var d=f;while(d.length>0&&e.width()>b.width()){d=d.substr(0,d.length-1);e.html(d+"...")}b.html(e.html());e.remove();if(c==true){var g=b.width();setInterval(function(){if(b.width()!=g){g=b.width();b.html(f);b.ellipsis()}},200)}}}):this}})(jQuery);(function(a){a.fn.innerTip=function(b){return this.each(function(){var c=a(this);c.focusin(function(){if(c.hasClass("empty")){c.val("");c.removeClass("empty")}});c.focusout(function(){if(c.val()==""){c.val(b.text);c.addClass("empty")}});c.bind("reset",function(){c.val(b.text);c.addClass("empty")});c.val(b.text);c.addClass("empty")})}})(jQuery);(function(a){var b={classes:[]};a.fn.corners=function(c){return this.each(function(){var d=a(this);if(a.inArray(c.id,b.classes)===-1){b.classes.push(c.id);a("body").append('<style type="text/css">.'+c.id+"> .c_tl_"+c.id+", ."+c.id+"> .c_tr_"+c.id+", ."+c.id+"> .c_bl_"+c.id+", ."+c.id+"> .c_br_"+c.id+" { width:"+c.r+";height:"+c.r+"; position: absolute; } .c_tl_"+c.id+" {background: url(/images/corners/c_tl_"+c.id+".png) top left no-repeat;top: -1px;left: -1px; } .c_tr_"+c.id+" {background: url(/images/corners/c_tr_"+c.id+".png) top right no-repeat;top: -1px;right: -1px; } .c_bl_"+c.id+" {background: url(/images/corners/c_bl_"+c.id+".png) bottom left no-repeat;bottom: -1px;left: -1px; } .c_br_"+c.id+" {background: url(/images/corners/c_br_"+c.id+".png) bottom right no-repeat;bottom: -1px;right: -1px; } </style>")}d.css({position:"relative"});d.prepend('<div class="c_tl_'+c.id+'"></div><div class="c_tr_'+c.id+'"></div>');d.append('<div class="c_bl_'+c.id+'"></div><div class="c_br_'+c.id+'"></div>')})}})(jQuery);(function(a){a.fn.hitch=function(c,d,a,b){return this.bind(c,b,function(){return d.apply(a||this,Array.prototype.slice.call(arguments))})}})(jQuery);(function(a){a.fn.q=function(b){var c={};if(b){var b=b.replace(/^\?/,"").replace(/\&$/,"");a.each(b.split("&"),function(){var b=this.split("=")[0],a=this.split("=")[1];if(/^[0-9.]+$/.test(a))a=parseFloat(a);if(a)c[b]=a})}return c}})(jQuery);(function(a){var c=function(a){a.preventDefault()},b=function(a){a.click(c);a.is("input[type='submit'],input[type='button']")&&a.attr("disabled","disabled")},d=function(d,e,f){var c=d.data("clone");if(!c){c=d.clone(false);a.each(c[0].attributes,function(b,a){a!=null&&a.name!="class"&&c.attr(a.name,"")});e!=""&&c.addClass(e);b(c);d.data("clone",c);d.after(c)}c.attr("title",f);d.hide();c.show()},e=function(b){var a=b.data("clone");if(a){b.show();a.hide()}};a.fn.activator=function(b){return this.each(function(){var c=a(this);if(b.action=="enable"){e(c);return}b.action=="disable"&&d(c,b.cl,b.tip)})};a.fn.isEnable=function(){var c=a(this),b=c.data("clone");return b&&b.is(":visible")?false:true}})(jQuery);var ZeroClipboard={version:"1.0.7",clients:{},moviePath:"ZeroClipboard.swf",nextId:1,$:function(a){if(typeof a=="string")a=document.getElementById(a);if(!a.addClass){a.hide=function(){this.style.display="none"};a.show=function(){this.style.display=""};a.addClass=function(a){this.removeClass(a);this.className+=" "+a};a.removeClass=function(d){for(var a=this.className.split(/\s+/),c=-1,b=0;b<a.length;b++)if(a[b]==d){c=b;b=a.length}if(c>-1){a.splice(c,1);this.className=a.join(" ")}return this};a.hasClass=function(a){return!!this.className.match(new RegExp("\\s*"+a+"\\s*"))}}return a},setMoviePath:function(a){this.moviePath=a},dispatch:function(d,b,c){var a=this.clients[d];a&&a.receiveEvent(b,c)},register:function(b,a){this.clients[b]=a},getDOMObjectPosition:function(a){return{left:0,top:0,width:a.width?a.width:a.offsetWidth,height:a.height?a.height:a.offsetHeight}},Client:function(a){this.handlers={};this.id=ZeroClipboard.nextId++;this.movieId="ZeroClipboardMovie_"+this.id;ZeroClipboard.register(this.id,this);a&&this.glue(a)}};ZeroClipboard.Client.prototype={id:0,ready:false,movie:null,clipText:"",handCursorEnabled:true,cssEffects:true,handlers:null,glue:function(f,a,d){this.domElement=ZeroClipboard.$(f);var e=99;if(this.domElement.style.zIndex)e=parseInt(this.domElement.style.zIndex,10)+1;if(typeof a=="string")a=ZeroClipboard.$(a);else if(typeof a=="undefined")a=document.getElementsByTagName("body")[0];var c=ZeroClipboard.getDOMObjectPosition(this.domElement,a);this.div=document.createElement("div");var b=this.div.style;b.position="absolute";b.left=""+c.left+"px";b.top=""+c.top+"px";b.width=""+c.width+"px";b.height=""+c.height*2+"px";b.zIndex=e;if(typeof d=="object")for(addedStyle in d)b[addedStyle]=d[addedStyle];a.appendChild(this.div);this.div.innerHTML=this.getHTML(c.width,c.height)},getHTML:function(b,a){var c="",d="id="+this.id+"&width="+b+"&height="+a;if(navigator.userAgent.match(/MSIE/)){var e=location.href.match(/^https/i)?"https://":"http://";c+='<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="'+e+'download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="'+b+'" height="'+a*2+'" id="'+this.movieId+'" align="middle"><param name="allowScriptAccess" value="always" /><param name="allowFullScreen" value="false" /><param name="movie" value="'+ZeroClipboard.moviePath+'" /><param name="loop" value="false" /><param name="menu" value="false" /><param name="quality" value="best" /><param name="bgcolor" value="#ffffff" /><param name="flashvars" value="'+d+'"/><param name="wmode" value="transparent"/></object>'}else c+='<embed id="'+this.movieId+'" src="'+ZeroClipboard.moviePath+'" loop="false" menu="false" quality="best" bgcolor="#ffffff" width="'+b+'" height="'+a*2+'" name="'+this.movieId+'" align="middle" allowScriptAccess="always" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" flashvars="'+d+'" wmode="transparent" />';return c},hide:function(){if(this.div)this.div.style.left="-2000px"},show:function(){this.reposition()},destroy:function(){if(this.domElement&&this.div){this.hide();this.div.innerHTML="";var a=document.getElementsByTagName("body")[0];try{a.removeChild(this.div)}catch(b){}this.domElement=null;this.div=null}},reposition:function(b){if(b){this.domElement=ZeroClipboard.$(b);!this.domElement&&this.hide()}if(this.domElement&&this.div){var c=ZeroClipboard.getDOMObjectPosition(this.domElement),a=this.div.style;a.left=""+c.left+"px";a.top=""+c.top+"px"}},setText:function(a){this.clipText=a;this.ready&&this.movie.setText(a)},addEventListener:function(a,b){a=a.toString().toLowerCase().replace(/^on/,"");if(!this.handlers[a])this.handlers[a]=[];this.handlers[a].push(b)},setHandCursor:function(a){this.handCursorEnabled=a;this.ready&&this.movie.setHandCursor(a)},setCSSEffects:function(a){this.cssEffects=!!a},receiveEvent:function(b,c){b=b.toString().toLowerCase().replace(/^on/,"");switch(b){case"load":this.movie=document.getElementById(this.movieId);if(!this.movie){var e=this;setTimeout(function(){e.receiveEvent("load",null)},1);return}if(!this.ready&&navigator.userAgent.match(/Firefox/)&&navigator.userAgent.match(/Windows/)){var e=this;setTimeout(function(){e.receiveEvent("load",null)},100);this.ready=true;return}this.ready=true;this.movie.setText(this.clipText);this.movie.setHandCursor(this.handCursorEnabled);break;case"mouseover":if(this.domElement&&this.cssEffects){this.domElement.addClass("hover");this.recoverActive&&this.domElement.addClass("active")}break;case"mouseout":if(this.domElement&&this.cssEffects){this.recoverActive=false;if(this.domElement.hasClass("active")){this.domElement.removeClass("active");this.recoverActive=true}this.domElement.removeClass("hover")}break;case"mousedown":this.domElement&&this.cssEffects&&this.domElement.addClass("active");break;case"mouseup":if(this.domElement&&this.cssEffects){this.domElement.removeClass("active");this.recoverActive=false}}if(this.handlers[b])for(var d=0,f=this.handlers[b].length;d<f;d++){var a=this.handlers[b][d];if(typeof a=="function")a(this,c);else if(typeof a=="object"&&a.length==2)a[0][a[1]](this,c);else typeof a=="string"&&window[a](this,c)}}};(function(a,b){a.jCacher=new function(){var f=this,o=a(this);f.version="1.0.0";f.count=0;var h,i,c,g=new e(false),l=function(b,a){return new Date(b.getTime()+a)},k=function(a,h){var c=g.getCacheItem(a);if(a!==null&&a!==b&&c!==null){f.count--;var e=g.getDependencyMappings(a);g.removeCacheItem(a);p(c,h);for(var d=0;d<e.length;d++)k(e[d],"dependencyChanged")}return c!==b},n=function(){for(var e=new Date,c=g.getCacheItems(),b=false,a=0;a<c.length;a++){var d=c[a];if(d.expires<=e){b=true;k(d.key,"expired")}}b&&j()},j=function(d){if(d===b){c=null;i=null;h&&clearTimeout(h);for(var f=g.getCacheItems(),e=0;e<f.length;e++){var a=f[e];if(c){if(a.expires<c){c=a.expires;i=a.key}}else{c=a.expires;i=a.key}}if(c)m();else h=null}else if(c==b||c&&d.expires<c){h&&clearTimeout(h);c=d.expires;m()}},m=function(){if(c){var b=new Date,a=c.getTime()-b.getTime()+100;if(a>0)h=setTimeout(n,a);else n()}},p=function(b,a){o.trigger("itemremoved",[b,a])};f.itemremoved=function(a){o.bind("itemremoved",a)};f.add=function(k,o,h,m,n){if(o!==b){if(a.inArray(k,g.getCacheKeys())==-1)f.count++;var e;if(h||m)if(h)e=l(new Date,h*1e3);else if(m)e=m;n&&g.registerDependencies(k,n);var p=new d(k,o,e,h);g.addCacheItem(p);(e&&(c===b||e<c)||(i==k||c===null))&&j(p)}};f.get=function(b){var a=g.getCacheItem(b);if(a){var d=new Date;if(a.slidingExpiration){a.expires=l(d,a.slidingExpiration*1e3);if(b==i||c&&a.expires<c)j();else var e=true}return a.expires&&a.expires<d?null:a}return null};f.remove=function(a){if(a!==b&&a!==null&&a!==NaN&&f.count>0){return k(a,"removed");i==a&&j()}};f.clear=function(){if(f.count>0){f.count=0;g.clear();if(h!==null){clearTimeout(h);h=null}}};g.getCacheItems().length>0&&j()};function d(d,c,b,a){this.key=d;this.value=c;this.expires=b;this.slidingExpiration=a}function c(b,a){this.key=b;this.mappings=a}function e(f){var d=[],b=[],e=[];(function(){if(f&&window.localStorage){if(!window.localStorage.jCacher)window.localStorage.jCacher=jQuery.toJSON({items:[],dependencyMappings:[]});else{for(var c=jQuery.parseJSON(window.localStorage.jCacher),a=0;a<c.items.length;a++){var g=c.items[a];g.expires=new Date(g.expires);d.push(g)}e=c.dependencyMappings}for(var a=0;a<d.length;a++)b.push(d[a].key)}})();this.getCacheItem=function(e){var c=a.inArray(e,b);return c>-1?d[c]:null};this.getCacheItems=function(){return d};this.removeCacheItem=function(h){var c=a.inArray(h,b);if(f&&window.localStorage){var g=jQuery.parseJSON(window.localStorage.jCacher);g.dependencyMappings.splice(c,1);g.items.splice(c,1);window.localStorage.jCacher=jQuery.toJSON(g)}d.splice(c,1);b.splice(c,1);e.splice(c,1)};this.addCacheItem=function(g){var i=a.inArray(g.key,b);if(i==-1){var j=new c(g.key,[]);d.push(g);b.push(g.key);e.push(j);if(f&&window.localStorage){var h=jQuery.parseJSON(window.localStorage.jCacher),k=function(){var a={};a.expires=g.expires.getTime();a.key=g.key;a.value=g.value;a.slidingExpiration=g.slidingExpiration;return a}();h.items.push(k);h.dependencyMappings.push(j);window.localStorage.jCacher=jQuery.toJSON(h)}}else{d[i]=g;if(f&&window.localStorage){var h=jQuery.parseJSON(window.localStorage.jCacher);h.items[i]=g;window.localStorage.jCacher=jQuery.toJSON(h)}}};this.getCacheKeys=function(){return b};this.registerDependencies=function(d,h){for(var g=0;g<h.length;g++){var c=a.inArray(h[g],b);if(c!=-1)if(a.inArray(d,e[c].mappings)==-1){e[c].mappings.push(d);if(f&&window.localStorage){var i=jQuery.parseJSON(window.localStorage.jCacher);i.dependencyMappings[c].mappings.push(d);window.localStorage.jCacher=jQuery.toJSON(i)}}}};this.getDependencyMappings=function(d){var c=a.inArray(d,b);return c>-1?e[c].mappings:null};this.clear=function(){window.localStorage&&window.localStorage.removeItem("jCacher");d=[];e=[];b=[]}}})(jQuery);ko.exportSymbol=function(d,e){for(var a=d.split("."),c=window,b=0;b<a.length-1;b++)c=c[a[b]];c[a[a.length-1]]=e};ko.exportProperty=function(a,c,b){a[c]=b};(function(){function n(c,b){for(var a in b)b.hasOwnProperty(a)&&b[a]&&(c[a]&&!(c[a]instanceof Array)?n(c[a],b[a]):(c[a]=b[a]))}function p(b,c){var a={};n(a,b);n(a,c);return a}function c(a){return a&&typeof a==="object"&&a.constructor==(new Date).constructor?"date":typeof a}function o(b,c){b=b||{};if(b.create instanceof Function||b.update instanceof Function||b.key instanceof Function||b.arrayChanged instanceof Function)b={"":b};if(c)b.ignore=d(c.ignore,b.ignore),b.include=d(c.include,b.include),b.copy=d(c.copy,b.copy);b.ignore=d(b.ignore,a.ignore);b.include=d(b.include,a.include);b.copy=d(b.copy,a.copy);b.mappedProperties=b.mappedProperties||{};return b}function d(a,b){a instanceof Array||(a=c(a)==="undefined"?[]:[a]);b instanceof Array||(b=c(b)==="undefined"?[]:[b]);return a.concat(b)}function u(a,c){var b=ko.dependentObservable;ko.dependentObservable=function(b,e,c){var c=c||{},g=c.deferEvaluation;b&&typeof b=="object"&&(c=b);var d=!1,f=function(b){var c=h({read:function(){d||(ko.utils.arrayRemoveItem(a,b),d=!0);return b.apply(b,arguments)},write:function(a){return b(a)},deferEvaluation:!0});c.__ko_proto__=h;return c};c.deferEvaluation=!0;b=new h(b,e,c);b.__ko_proto__=h;g||(a.push(b),b=f(b));return b};var d=c();ko.dependentObservable=b;return d}function j(a,d,h,m,F,A){var E=ko.utils.unwrapObservable(d)instanceof Array,A=A||"";if(ko.mapping.isMapped(a))var y=ko.utils.unwrapObservable(a)[b],h=p(y,h);var D=function(){return h[m]&&h[m].create instanceof Function},C=function(a){return u(k,function(){return h[m].create({data:a||d,parent:F})})},t=function(){return h[m]&&h[m].update instanceof Function},o=function(a,c){var b={data:c||d,parent:F,target:ko.utils.unwrapObservable(a)};if(ko.isWriteableObservable(a))b.observable=a;return h[m].update(b)};if(f.get(d))return a;m=m||"";if(E){var E=[],y=!1,i=function(a){return a};if(h[m]&&h[m].key)i=h[m].key,y=!0;if(!ko.isObservable(a))a=ko.observableArray([]),a.mappedRemove=function(b){var c=typeof b=="function"?b:function(a){return a===i(b)};return a.remove(function(a){return c(i(a))})},a.mappedRemoveAll=function(b){var c=e(b,i);return a.remove(function(a){return ko.utils.arrayIndexOf(c,i(a))!=-1})},a.mappedDestroy=function(b){var c=typeof b=="function"?b:function(a){return a===i(b)};return a.destroy(function(a){return c(i(a))})},a.mappedDestroyAll=function(b){var c=e(b,i);return a.destroy(function(a){return ko.utils.arrayIndexOf(c,i(a))!=-1})},a.mappedIndexOf=function(b){var c=e(a(),i),b=i(b);return ko.utils.arrayIndexOf(c,b)},a.mappedCreate=function(b){if(a.mappedIndexOf(b)!==-1)throw Error("There already is an object with the key that you specified.");var c=D()?C(b):b;t()&&(b=o(c,b),ko.isWriteableObservable(c)?c(b):(c=b));a.push(c);return c};var n=e(ko.utils.unwrapObservable(a),i).sort(),x=e(d,i);y&&x.sort();for(var y=ko.utils.compareArrays(n,x),n={},x=[],B=0,G=y.length;B<G;B++){var w=y[B],v,s=A+"["+B+"]";switch(w.status){case"added":var z=g(ko.utils.unwrapObservable(d),w.value,i);v=ko.utils.unwrapObservable(j(void 0,z,h,m,a,s));s=q(ko.utils.unwrapObservable(d),z,n);x[s]=v;n[s]=!0;break;case"retained":z=g(ko.utils.unwrapObservable(d),w.value,i);v=g(a,w.value,i);j(v,z,h,m,a,s);s=q(ko.utils.unwrapObservable(d),z,n);x[s]=v;n[s]=!0;break;case"deleted":v=g(a,w.value,i)}E.push({event:w.status,item:v})}a(x);h[m]&&h[m].arrayChanged&&ko.utils.arrayForEach(E,function(a){h[m].arrayChanged(a.event,a.item)})}else if(l(d)){a=ko.utils.unwrapObservable(a);if(!a)if(D())return n=C(),t()&&(n=o(n)),n;else{if(t())return o(n);a={}}t()&&(a=o(a));f.save(d,a);r(d,function(b){var c=A.length?A+"."+b:b;if(ko.utils.arrayIndexOf(h.ignore,c)==-1)if(ko.utils.arrayIndexOf(h.copy,c)!=-1)a[b]=d[b];else{var e=f.get(d[b])||j(a[b],d[b],h,b,a,c);if(ko.isWriteableObservable(a[b]))a[b](ko.utils.unwrapObservable(e));else a[b]=e;h.mappedProperties[c]=!0}})}else switch(c(d)){case"function":t()?ko.isWriteableObservable(d)?(d(o(d)),a=d):(a=o(d)):(a=d);break;default:ko.isWriteableObservable(a)?t()?a(o(a)):a(ko.utils.unwrapObservable(d)):(a=D()?C():ko.observable(ko.utils.unwrapObservable(d)),t()&&a(o(a)))}return a}function q(b,d,c){for(var a=0,e=b.length;a<e;a++)if(c[a]!==!0&&b[a]===d)return a;return null}function s(b,d){var a;d&&(a=d(b));c(a)==="undefined"&&(a=b);return ko.utils.unwrapObservable(a)}function g(a,b,c){a=ko.utils.arrayFilter(ko.utils.unwrapObservable(a),function(a){return s(a,c)===b});if(a.length==0)throw Error("When calling ko.update*, the key '"+b+"' was not found!");if(a.length>1&&l(a[0]))throw Error("When calling ko.update*, the key '"+b+"' was not unique!");return a[0]}function e(b,a){return ko.utils.arrayMap(ko.utils.unwrapObservable(b),function(b){return a?s(b,a):b})}function r(b,c){if(b instanceof Array)for(var a=0;a<b.length;a++)c(a);else for(a in b)c(a)}function l(a){var b=c(a);return b==="object"&&a!==null&&b!=="undefined"}function t(){var a=[],b=[];this.save=function(c,d){var e=ko.utils.arrayIndexOf(a,c);e>=0?(b[e]=d):(a.push(c),b.push(d))};this.get=function(c){c=ko.utils.arrayIndexOf(a,c);if(c>=0)return b[c]}}ko.mapping={};var b="__ko_mapping__",h=ko.dependentObservable,m=0,k,f,i={include:["_destroy"],ignore:[],copy:[]},a=i;ko.mapping.isMapped=function(a){return(a=ko.utils.unwrapObservable(a))&&a[b]};ko.mapping.fromJS=function(e){if(arguments.length==0)throw Error("When calling ko.fromJS, pass the object you want to convert.");window.setTimeout(function(){m=0},0);m++||(k=[],f=new t);var a,c;arguments.length==2&&(arguments[1][b]?(c=arguments[1]):(a=arguments[1]));arguments.length==3&&(a=arguments[1],c=arguments[2]);c&&(a=p(a,c[b]));a=o(a);var d=j(c,e,a);c&&(d=c);--m||window.setTimeout(function(){ko.utils.arrayForEach(k,function(a){a&&a()})},0);d[b]=p(d[b],a);return d};ko.mapping.fromJSON=function(a){var b=ko.utils.parseJson(a);arguments[0]=b;return ko.mapping.fromJS.apply(this,arguments)};ko.mapping.updateFromJS=function(){throw Error("ko.mapping.updateFromJS, use ko.mapping.fromJS instead. Please note that the order of parameters is different!");};ko.mapping.updateFromJSON=function(){throw Error("ko.mapping.updateFromJSON, use ko.mapping.fromJSON instead. Please note that the order of parameters is different!");};ko.mapping.toJS=function(d,c){a||ko.mapping.resetDefaultOptions();if(arguments.length==0)throw Error("When calling ko.mapping.toJS, pass the object you want to convert.");if(!(a.ignore instanceof Array))throw Error("ko.mapping.defaultOptions().ignore should be an array.");if(!(a.include instanceof Array))throw Error("ko.mapping.defaultOptions().include should be an array.");if(!(a.copy instanceof Array))throw Error("ko.mapping.defaultOptions().copy should be an array.");c=o(c,d[b]);return ko.mapping.visitModel(d,function(a){return ko.utils.unwrapObservable(a)},c)};ko.mapping.toJSON=function(a,c){var b=ko.mapping.toJS(a,c);return ko.utils.stringifyJson(b)};ko.mapping.defaultOptions=function(){if(arguments.length>0)a=arguments[0];else return a};ko.mapping.resetDefaultOptions=function(){a={include:i.include.slice(0),ignore:i.ignore.slice(0),copy:i.copy.slice(0)}};ko.mapping.visitModel=function(f,g,a){a=a||{};a.visitedObjects=a.visitedObjects||new t;a.parentName||(a=o(a));var e,d=ko.utils.unwrapObservable(f);if(l(d))g(f,a.parentName),e=d instanceof Array?[]:{};else return g(f,a.parentName);a.visitedObjects.save(f,e);var h=a.parentName;r(d,function(f){if(!(a.ignore&&ko.utils.arrayIndexOf(a.ignore,f)!=-1)){var i=d[f],j=a,k=h||"";d instanceof Array?h&&(k+="["+f+"]"):(h&&(k+="."),k+=f);j.parentName=k;if(!(ko.utils.arrayIndexOf(a.copy,f)===-1&&ko.utils.arrayIndexOf(a.include,f)===-1&&d[b]&&d[b].mappedProperties&&!d[b].mappedProperties[f]&&!(d instanceof Array)))switch(c(ko.utils.unwrapObservable(i))){case"object":case"undefined":j=a.visitedObjects.get(i);e[f]=c(j)!=="undefined"?j:ko.mapping.visitModel(i,g,a);break;default:e[f]=g(i,a.parentName)}}});return e};ko.exportSymbol("ko.mapping",ko.mapping);ko.exportSymbol("ko.mapping.fromJS",ko.mapping.fromJS);ko.exportSymbol("ko.mapping.fromJSON",ko.mapping.fromJSON);ko.exportSymbol("ko.mapping.isMapped",ko.mapping.isMapped);ko.exportSymbol("ko.mapping.defaultOptions",ko.mapping.defaultOptions);ko.exportSymbol("ko.mapping.toJS",ko.mapping.toJS);ko.exportSymbol("ko.mapping.toJSON",ko.mapping.toJSON);ko.exportSymbol("ko.mapping.updateFromJS",ko.mapping.updateFromJS);ko.exportSymbol("ko.mapping.updateFromJSON",ko.mapping.updateFromJSON);ko.exportSymbol("ko.mapping.visitModel",ko.mapping.visitModel)})();(function(){var a,h,t=this,y="Index out of range";if(typeof ProvideCustomRxRootObject=="undefined")h=t.Rx={};else h=ProvideCustomRxRootObject();var u=function(){},z=function(){return(new Date).getTime()},A=function(a,b){return a===b},x=function(a){return a},n=function(a){return{Dispose:a}},o={Dispose:u};h.Disposable={Create:n,Empty:o};var H=h.BooleanDisposable=function(){var a=false;this.GetIsDisposed=function(){return a};this.Dispose=function(){a=true}},S=function(a){var b=false;a.a++;this.Dispose=function(){var b=false;if(!a.b)if(!this.c){this.c=true;a.a--;if(a.a==0&&a.d){a.b=true;b=true}}b&&a.e.Dispose()}},T=h.RefCountDisposable=function(a){this.d=false;this.b=false;this.e=a;this.a=0;this.Dispose=function(){var a=false;if(!this.b)if(!this.d){this.d=true;if(this.a==0){this.b=true;a=true}}a&&this.e.Dispose()};this.GetDisposable=function(){return this.b?o:new S(this)}},d=h.CompositeDisposable=function(){for(var a=new r,c=0;c<arguments.length;c++)a.Add(arguments[c]);var b=false;this.GetCount=function(){return a.GetCount()};this.Add=function(c){if(!b)a.Add(c);else c.Dispose()};this.Remove=function(c,d){if(!b){var e=a.Remove(c);!d&e&&c.Dispose()}};this.Dispose=function(){if(!b){b=true;this.Clear()}};this.Clear=function(){for(var b=0;b<a.GetCount();b++)a.GetItem(b).Dispose();a.Clear()}},e=h.MutableDisposable=function(){var c=false,b;this.Get=function(){return b},this.Replace=function(d){if(c&&d!==a)d.Dispose();else{b!==a&&b.Dispose();b=d}};this.Dispose=function(){if(!c){c=true;b!==a&&b.Dispose()}}},J=function(b){for(var c=[],a=0;a<b.length;a++)c.push(b[a]);return c},r=h.List=function(d){var c=[],b=0,e=d!==a?d:A;this.Add=function(a){c[b]=a;b++};this.RemoveAt=function(a){if(a<0||a>=b)throw y;if(a==0){c.shift();b--}else{c.splice(a,1);b--}};this.IndexOf=function(d){for(var a=0;a<b;a++)if(e(d,c[a]))return a;return-1};this.Remove=function(b){var a=this.IndexOf(b);if(a==-1)return false;this.RemoveAt(a);return true};this.Clear=function(){c=[];b=0};this.GetCount=function(){return b};this.GetItem=function(a){if(a<0||a>=b)throw y;return c[a]};this.SetItem=function(a,d){if(a<0||a>=b)throw y;c[a]=d};this.ToArray=function(){for(var b=[],a=0;a<this.GetCount();a++)b.push(this.GetItem(a));return b}},k=function(a){if(a===null)a=A;this.f=a;var b=4;this.g=new Array(b);this.h=0};k.prototype.i=function(a,b){return this.f(this.g[a],this.g[b])<0};k.prototype.j=function(a){if(a>=this.h||a<0)return;var b=a-1>>1;if(b<0||b==a)return;if(this.i(a,b)){var c=this.g[a];this.g[a]=this.g[b];this.g[b]=c;this.j(b)}};k.prototype.k=function(b){if(b===a)b=0;var d=2*b+1,e=2*b+2,c=b;if(d<this.h&&this.i(d,c))c=d;if(e<this.h&&this.i(e,c))c=e;if(c!=b){var f=this.g[b];this.g[b]=this.g[c];this.g[c]=f;this.k(c)}};k.prototype.GetCount=function(){return this.h};k.prototype.Peek=function(){if(this.h==0)throw"Heap is empty.";return this.g[0]};k.prototype.Dequeue=function(){var a=this.Peek();this.g[0]=this.g[--this.h];delete this.g[this.h];this.k();return a};k.prototype.Enqueue=function(b){var a=this.h++;this.g[a]=b;this.j(a)};var s=h.Scheduler=function(a,b,c){this.Schedule=a;this.ScheduleWithTime=b;this.Now=c;this.ScheduleRecursive=function(e){var c=this,a=new d,b;b=function(){e(function(){var e=false,f=false,d;d=c.Schedule(function(){b();if(e)a.Remove(d);else f=true});if(!f){a.Add(d);e=true}})};a.Add(c.Schedule(b));return a};this.ScheduleRecursiveWithTime=function(e,f){var c=this,a=new d,b;b=function(){e(function(g){var e=false,f=false,d;d=c.ScheduleWithTime(function(){b();if(e)a.Remove(d);else f=true},g);if(!f){a.Add(d);e=true}})};a.Add(c.ScheduleWithTime(b,f));return a}},W=h.VirtualScheduler=function(b,c,d,e){var a=new s(function(a){return this.ScheduleWithTime(a,0)},function(a,b){return this.ScheduleVirtual(a,e(b))},function(){return d(this.l)});a.ScheduleVirtual=function(e,f){var a=new H,g=c(this.l,f),b=function(){!a.IsDisposed&&e()},d=new L(b,g);this.m.Enqueue(d);return a};a.Run=function(){while(this.m.GetCount()>0){var a=this.m.Dequeue();this.l=a.n;a.o()}};a.RunTo=function(b){while(this.m.GetCount()>0&&this.f(this.m.Peek().n,b)<=0){var a=this.m.Dequeue();this.l=a.n;a.o()}};a.GetTicks=function(){return this.l};a.l=0;a.m=new k(function(a,c){return b(a.n,c.n)});a.f=b;return a},ob=h.TestScheduler=function(){return new W(function(a,b){return a-b},function(a,b){return a+b},function(a){return new Date(a)},function(a){return a<=0?1:a})},j=new s(function(a){return this.ScheduleWithTime(a,0)},function(d,e){var f=this.Now()+e,b=new L(d,f);if(this.m===a){var c=new K;try{this.m.Enqueue(b);c.p()}finally{c.q()}}else this.m.Enqueue(b);return b.r()},z);j.s=function(b){if(this.m===a){var c=new K;try{b();c.p()}finally{c.q()}}else b()};s.CurrentThread=j;var K=function(){j.m=new k(function(a,b){try{return a.n-b.n}catch(c){}});this.q=function(){j.m=a};this.p=function(){while(j.m.GetCount()>0){var a=j.m.Dequeue();if(!a.t()){while(a.n-j.Now()>0);!a.t()&&a.o()}}}},Z=0,L=function(a,b){this.u=Z++;this.o=a;this.n=b;this.v=new H;this.t=function(){return this.v.GetIsDisposed()};this.r=function(){return this.v}},f=new s(function(a){a();return o},function(a,b){while(this.Now<b);a()},z);s.Immediate=f;var i=new s(function(a){var b=t.setTimeout(a,0);return n(function(){t.clearTimeout(b)})},function(a,b){var c=t.setTimeout(a,b);return n(function(){t.clearTimeout(c)})},z);s.Timeout=i;var g=h.Observer=function(b,c,d){this.OnNext=b===a?u:b;this.OnError=c===a?function(a){throw a;}:c;this.OnCompleted=d===a?u:d;this.AsObserver=function(){var a=this;return new g(function(b){a.OnNext(b)},function(b){a.OnError(b)},function(){a.OnCompleted()})}},ib=g.Create=function(a,b,c){return new g(a,b,c)},c=h.Observable=function(a){this.w=a},b=c.CreateWithDisposable=function(a){return new c(a)},E=c.Create=function(a){return b(function(b){return n(a(b))})},F=function(){return this.Select(function(a){return a.Value})};c.prototype={Subscribe:function(a,c,d){var b;if(arguments.length==0||arguments.length>1||typeof a=="function")b=new g(a,c,d);else b=a;return this.x(b)},x:function(c){var a=false,b=new e,f=this;j.s(function(){var d=new g(function(b){!a&&c.OnNext(b)},function(d){if(!a){a=true;b.Dispose();c.OnError(d)}},function(){if(!a){a=true;b.Dispose();c.OnCompleted()}});b.Replace(f.w(d))});return new d(b,n(function(){a=true}))},Select:function(a){var c=this;return b(function(b){var d=0;return c.Subscribe(new g(function(e){var c;try{c=a(e,d++)}catch(f){b.OnError(f);return}b.OnNext(c)},function(a){b.OnError(a)},function(){b.OnCompleted()}))})},Let:function(c,f){if(f===a)return c(this);var g=this;return b(function(a){var h=f(),i;try{i=c(h)}catch(l){return I(l).Subscribe(a)}var j=new e,k=new e,b=new d(k,j);j.Replace(i.Subscribe(function(b){a.OnNext(b)},function(c){a.OnError(c);b.Dispose()},function(){a.OnCompleted();b.Dispose()}));k.Replace(g.Subscribe(h));return b})},MergeObservable:function(){var a=this;return b(function(c){var f=false,b=new d,g=new e;b.Add(g);g.Replace(a.Subscribe(function(d){var a=new e;b.Add(a);a.Replace(d.Subscribe(function(a){c.OnNext(a)},function(a){c.OnError(a)},function(){b.Remove(a);b.GetCount()==1&&f&&c.OnCompleted()}))},function(a){c.OnError(a)},function(){f=true;b.GetCount()==1&&c.OnCompleted()}));return b})},y:function(b,c){var a=J(c);a.unshift(this);return b(a)},Concat:function(){return this.y(G,arguments)},Merge:function(){return this.y(Q,arguments)},Catch:function(){return this.y(V,arguments)},OnErrorResumeNext:function(){return this.y(Y,arguments)},Zip:function(e,c){var f=this;return b(function(b){var m=false,h=[],i=[],j=false,k=false,g=new d,l=function(c){g.Dispose();h=a;i=a;b.OnError(c)};g.Add(f.Subscribe(function(a){if(k){b.OnCompleted();return}if(i.length>0){var e=i.shift(),d;try{d=c(a,e)}catch(f){g.Dispose();b.OnError(f);return}b.OnNext(d)}else h.push(a)},l,function(){if(k){b.OnCompleted();return}j=true}));g.Add(e.Subscribe(function(a){if(j){b.OnCompleted();return}if(h.length>0){var e=h.shift(),d;try{d=c(e,a)}catch(f){g.Dispose();b.OnError(f);return}b.OnNext(d)}else i.push(a)},l,function(){if(j){b.OnCompleted();return}k=true}));return g})},CombineLatest:function(c,a){var e=this;return b(function(b){var n=false,j=false,k=false,l,m,g=false,h=false,f=new d,i=function(a){f.Dispose();b.OnError(a)};f.Add(e.Subscribe(function(c){if(h){b.OnCompleted();return}if(k){var d;try{d=a(c,m)}catch(e){f.Dispose();b.OnError(e);return}b.OnNext(d)}l=c;j=true},i,function(){if(h){b.OnCompleted();return}g=true}));f.Add(c.Subscribe(function(c){if(g){b.OnCompleted();return}if(j){var d;try{d=a(l,c)}catch(e){f.Dispose();b.OnError(e);return}b.OnNext(d)}m=c;k=true},i,function(){if(g){b.OnCompleted();return}h=true}))})},Switch:function(){var c=this;return b(function(f){var g=false,b=new e,h=new e;h.Replace(c.Subscribe(function(d){if(!g){var c=new e;c.Replace(d.Subscribe(function(a){f.OnNext(a)},function(a){h.Dispose();b.Dispose();f.OnError(a)},function(){b.Replace(a);g&&f.OnCompleted()}));b.Replace(c)}},function(a){b.Dispose();f.OnError(a)},function(){g=true;b.Get()===a&&f.OnCompleted()}));return new d(h,b)})},TakeUntil:function(a){var c=this;return b(function(e){var b=new d;b.Add(a.Subscribe(function(){e.OnCompleted();b.Dispose()},function(a){e.OnError(a)},function(){}));b.Add(c.Subscribe(e));return b})},SkipUntil:function(a){var c=this;return b(function(b){var e=true,f=new d;f.Add(a.Subscribe(function(){e=false},function(a){b.OnError(a)},u));f.Add(c.Subscribe(new g(function(a){!e&&b.OnNext(a)},function(a){b.OnError(a)},function(){!e&&b.OnCompleted()})));return f})},Scan1:function(a){var b=this;return q(function(){var c,d=false;return b.Select(function(b){if(d)c=a(c,b);else{c=b;d=true}return c})})},Scan:function(b,a){var c=this;return q(function(){var d,e=false;return c.Select(function(c){if(e)d=a(d,c);else{d=a(b,c);e=true}return d})})},Scan0:function(a,c){var d=this;return b(function(b){var e=a,f=true;return d.Subscribe(function(a){if(f){f=false;b.OnNext(e)}try{e=c(e,a)}catch(d){b.OnError(d);return}b.OnNext(e)},function(a){f&&b.OnNext(e);b.OnError(a)},function(){f&&b.OnNext(e);b.OnCompleted()})})},Finally:function(a){var b=this;return E(function(c){var d=b.Subscribe(c);return function(){try{d.Dispose();a()}catch(b){a();throw b;}}})},Do:function(d,e,f){var c;if(arguments.length==0||arguments.length>1||typeof d=="function")c=new g(d,e!==a?e:u,f);else c=d;var h=this;return b(function(b){return h.Subscribe(new g(function(a){try{c.OnNext(a)}catch(d){b.OnError(d);return}b.OnNext(a)},function(d){if(e!==a)try{c.OnError(d)}catch(f){b.OnError(f);return}b.OnError(d)},function(){if(f!==a)try{c.OnCompleted()}catch(d){b.OnError(d);return}b.OnCompleted()}))})},Where:function(a){var c=this;return b(function(b){var d=0;return c.Subscribe(new g(function(c){var e=false;try{e=a(c,d++)}catch(f){b.OnError(f);return}e&&b.OnNext(c)},function(a){b.OnError(a)},function(){b.OnCompleted()}))})},Take:function(d,c){if(c===a)c=f;var e=this;return b(function(a){if(d<=0){e.Subscribe().Dispose();return B(c).Subscribe(a)}var b=d;return e.Subscribe(new g(function(c){if(b-->0){a.OnNext(c);b==0&&a.OnCompleted()}},function(b){a.OnError(b)},function(){a.OnCompleted()}))})},GroupBy:function(c,f,g){if(c===a)c=x;if(f===a)f=x;if(g===a)g=function(a){return a.toString()};var h=this;return b(function(j){var i={},k=new e,l=new T(k);k.Replace(h.Subscribe(function(r){var h;try{h=c(r)}catch(s){for(var n in i)i[n].OnError(s);j.OnError(s);return}var o=false,e;try{var k=g(h);if(i[k]===a){e=new m;i[k]=e;o=true}else e=i[k]}catch(s){for(var n in i)i[n].OnError(s);j.OnError(s);return}if(o){var p=b(function(a){return new d(l.GetDisposable(),e.Subscribe(a))});p.Key=h;j.OnNext(p)}var q;try{q=f(r)}catch(s){for(var n in i)i[n].OnError(s);j.OnError(s);return}e.OnNext(q)},function(a){for(var b in i)i[b].OnError(a);j.OnError(a)},function(){for(var a in i)i[a].OnCompleted();j.OnCompleted()}));return l})},TakeWhile:function(a){var c=this;return b(function(b){var d=true;return c.Subscribe(new g(function(c){if(d){try{d=a(c)}catch(e){b.OnError(e);return}if(d)b.OnNext(c);else b.OnCompleted()}},function(a){b.OnError(a)},function(){b.OnCompleted()}))})},SkipWhile:function(a){var c=this;return b(function(b){var d=false;return c.Subscribe(new g(function(c){if(!d)try{d=!a(c)}catch(e){b.OnError(e);return}d&&b.OnNext(c)},function(a){b.OnError(a)},function(){b.OnCompleted()}))})},Skip:function(a){var c=this;return b(function(b){var d=a;return c.Subscribe(new g(function(a){d--<=0&&b.OnNext(a)},function(a){b.OnError(a)},function(){b.OnCompleted()}))})},SelectMany:function(a){return this.Select(a).MergeObservable()},TimeInterval:function(b){if(b===a)b=f;var c=this;return q(function(){var a=b.Now();return c.Select(function(d){var c=b.Now(),e=c-a;a=c;return{Interval:e,Value:d}})})},RemoveInterval:F,Timestamp:function(b){if(b===a)b=f;return this.Select(function(a){return{Timestamp:b.Now(),Value:a}})},RemoveTimestamp:F,Materialize:function(){var a=this;return b(function(b){return a.Subscribe(new g(function(a){b.OnNext(new l("N",a))},function(a){b.OnNext(new l("E",a));b.OnCompleted()},function(){b.OnNext(new l("C"));b.OnCompleted()}))})},Dematerialize:function(){return this.SelectMany(function(a){return a})},AsObservable:function(){var a=this;return b(function(b){return a.Subscribe(b)})},Delay:function(f,c){if(c===a)c=i;var g=this;return b(function(j){var b=[],h=false,i=new e,k=g.Materialize().Timestamp().Subscribe(function(d){if(d.Value.Kind=="E"){j.OnError(d.Value.Value);b=[];h&&i.Dispose();return}b.push({Timestamp:c.Now()+f,Value:d.Value});if(!h){i.Replace(c.ScheduleRecursiveWithTime(function(e){var d;do{d=a;if(b.length>0&&b[0].Timestamp<=c.Now())d=b.shift().Value;d!==a&&d.Accept(j)}while(d!==a);if(b.length>0){e(Math.max(0,b[0].Timestamp-c.Now()));h=true}else h=false},f));h=true}});return new d(k,i)})},Throttle:function(f,c){if(c===a)c=i;var g=this;return b(function(h){var j,a=false,i=new e,b=0,k=g.Subscribe(function(d){a=true;j=d;b++;var e=b;i.Replace(c.ScheduleWithTime(function(){a&&b==e&&h.OnNext(j);a=false},f))},function(c){i.Dispose();h.OnError(c);a=false;b++},function(){i.Dispose();a&&h.OnNext(j);h.OnCompleted();a=false;b++});return new d(k,i)})},Timeout:function(g,f,c){if(c===a)c=i;if(f===a)f=I("Timeout",c);var h=this;return b(function(i){var j=new e,k=new e,b=0,l=b,a=false;k.Replace(c.ScheduleWithTime(function(){a=b==l;a&&j.Replace(f.Subscribe(i))},g));j.Replace(h.Subscribe(function(e){var d=0;if(!a){b++;d=b;i.OnNext(e);k.Replace(c.ScheduleWithTime(function(){a=b==d;a&&j.Replace(f.Subscribe(i))},g))}},function(c){if(!a){b++;i.OnError(c)}},function(){if(!a){b++;i.OnCompleted()}}));return new d(j,k)})},Sample:function(e,c){if(c===a)c=i;var f=this;return b(function(a){var g=false,h,i=false,b=new d;b.Add(ab(e,c).Subscribe(function(){if(g){a.OnNext(h);g=false}i&&a.OnCompleted()},function(b){a.OnError(b)},function(){a.OnCompleted()}));b.Add(f.Subscribe(function(a){g=true;h=a},function(c){a.OnError(c);b.Dispose()},function(){i=true}));return b})},Repeat:function(c,g){var h=this;if(g===a)g=f;if(c===a)c=-1;return b(function(a){var b=c,f=new e,i=new d(f),j=function(c){f.Replace(h.Subscribe(function(b){a.OnNext(b)},function(b){a.OnError(b)},function(){if(b>0){b--;if(b==0){a.OnCompleted();return}}c()}))};i.Add(g.ScheduleRecursive(j));return i})},Retry:function(c,g){var h=this;if(g===a)g=f;if(c===a)c=-1;return b(function(a){var b=c,f=new e,i=new d(f),j=function(c){f.Replace(h.Subscribe(function(b){a.OnNext(b)},function(d){if(b>0){b--;if(b==0){a.OnError(d);return}}c()},function(){a.OnCompleted()}))};i.Add(g.ScheduleRecursive(j));return i})},BufferWithTime:function(f,e,c){if(c===a)c=i;if(e===a)e=f;var g=this;return b(function(b){var a=new r,k=c.Now(),l=function(){for(var c=[],b=0;b<a.GetCount();b++){var d=a.GetItem(b);d.Timestamp-k>=0&&c.push(d.Value)}return c},h=new d,i=function(a){b.OnError(a)},j=function(){b.OnNext(l());b.OnCompleted()};h.Add(g.Subscribe(function(b){a.Add({Value:b,Timestamp:c.Now()})},i,j));h.Add(C(f,e,c).Subscribe(function(){var g=l(),d=c.Now()+e-f;while(a.GetCount()>0&&a.GetItem(0).Timestamp-d<=0)a.RemoveAt(0);b.OnNext(g);k=d},i,j));return h})},BufferWithTimeOrCount:function(f,g,c){if(c===a)c=i;var h=this;return b(function(j){var b=0,a=new r,k=function(){j.OnNext(a.ToArray());a.Clear();b++},l=new e,i;i=function(a){var d=c.ScheduleWithTime(function(){var c=false,d=0;if(a==b){k();d=b;c=true}c&&i(d)},f);l.Replace(d)};i(b);var m=h.Subscribe(function(e){var c=false,d=0;a.Add(e);if(a.GetCount()==g){k();d=b;c=true}c&&i(d)},function(b){j.OnError(b);a.Clear()},function(){j.OnNext(a.ToArray());b++;j.OnCompleted();a.Clear()});return new d(m,l)})},BufferWithCount:function(d,c){if(c===a)c=d;var e=this;return b(function(b){var a=[],f=0;return e.Subscribe(function(j){if(f==0)a.push(j);else f--;var g=a.length;if(g==d){var h=a;a=[];for(var i=Math.min(c,g),e=i;e<g;e++)a.push(h[e]);f=Math.max(0,c-d);b.OnNext(h)}},function(a){b.OnError(a)},function(){a.length>0&&b.OnNext(a);b.OnCompleted()})})},StartWith:function(c,e){if(!(c instanceof Array))c=[c];if(e===a)e=f;var g=this;return b(function(f){var a=new d,b=0;a.Add(e.ScheduleRecursive(function(d){if(b<c.length){f.OnNext(c[b]);b++;d()}else a.Add(g.Subscribe(f))}));return a})},DistinctUntilChanged:function(c,d){if(c===a)c=x;if(d===a)d=A;var e=this;return b(function(a){var f,b=false;return e.Subscribe(function(g){var e;try{e=c(g)}catch(i){a.OnError(i);return}var h=false;if(b)try{h=d(f,e)}catch(i){a.OnError(i);return}if(!b||!h){b=true;f=e;a.OnNext(g)}},function(b){a.OnError(b)},function(){a.OnCompleted()})})},Publish:function(c){if(c===a)return new p(this,new m);var e=this;return b(function(){var a=new p(e,new m);return new d(c(a).Subscribe(g),a.Connect())})},Prune:function(e,c){if(c===a)c=f;if(e===a)return new p(this,new v(c));var h=this;return b(function(){var a=new p(h,new v(c));return new d(e(a).Subscribe(g),a.Connect())})},Replay:function(e,f,h,c){if(c===a)c=j;if(e===a)return new p(this,new w(f,h,c));var i=this;return b(function(){var a=new p(i,new w(f,h,c));return new d(e(a).Subscribe(g),a.Connect())})},SkipLast:function(a){var c=this;return b(function(b){var d=[];return c.Subscribe(function(c){d.push(c);d.length>a&&b.OnNext(d.shift())},function(a){b.OnError(a)},function(){b.OnCompleted()})})},TakeLast:function(a){var c=this;return b(function(d){var b=[];return c.Subscribe(function(c){b.push(c);b.length>a&&b.shift()},function(a){d.OnError(a)},function(){while(b.length>0)d.OnNext(b.shift());d.OnCompleted()})})}};var Q=c.Merge=function(c,b){if(b===a)b=f;return R(c,b).MergeObservable()},G=c.Concat=function(g,c){if(c===a)c=f;return b(function(a){var f=new e,b=0,h=c.ScheduleRecursive(function(d){if(b<g.length){var h=g[b];b++;var c=new e;f.Replace(c);c.Replace(h.Subscribe(function(b){a.OnNext(b)},function(b){a.OnError(b)},d))}else a.OnCompleted()});return new d(f,h)})},R=c.FromArray=function(d,c){if(c===a)c=f;return b(function(a){var b=0;return c.ScheduleRecursive(function(c){if(b<d.length){a.OnNext(d[b++]);c()}else a.OnCompleted()})})},jb=c.Return=function(d,c){if(c===a)c=f;return b(function(a){return c.Schedule(function(){a.OnNext(d);a.OnCompleted()})})},I=c.Throw=function(d,c){if(c===a)c=f;return b(function(a){return c.Schedule(function(){a.OnError(d)})})},U=c.Never=function(){return b(function(){return o})},B=c.Empty=function(c){if(c===a)c=f;return b(function(a){return c.Schedule(function(){a.OnCompleted()})})},q=c.Defer=function(a){return b(function(b){var c;try{c=a()}catch(d){b.OnError(d);return o}return c.Subscribe(b)})},V=c.Catch=function(g,c){if(c===a)c=f;return b(function(a){var f=new e,b=0,h=c.ScheduleRecursive(function(d){var h=g[b];b++;var c=new e;f.Replace(c);c.Replace(h.Subscribe(function(b){a.OnNext(b)},function(c){if(b<g.length)d();else a.OnError(c)},function(){a.OnCompleted()}))});return new d(f,h)})},kb=c.Using=function(c,e){return b(function(g){var h,b=o;try{var f=c();if(f!==a)b=f;h=e(f)}catch(i){return new d(Throw(i).Subscribe(g),b)}return new d(h.Subscribe(g),b)})},lb=c.Range=function(c,d,b){if(b===a)b=f;var e=c+d-1;return X(c,function(a){return a<=e},function(a){return a+1},x,b)},mb=c.Repeat=function(g,c,d){if(d===a)d=f;if(c===a)c=-1;var e=c;return b(function(a){return d.ScheduleRecursive(function(b){a.OnNext(g);if(e>0){e--;if(e==0){a.OnCompleted();return}}b()})})},X=c.Generate=function(d,e,g,h,c){if(c===a)c=f;return b(function(b){var a=d,f=true;return c.ScheduleRecursive(function(i){var c=false,d;try{if(f)f=false;else a=g(a);c=e(a);if(c)d=h(a)}catch(j){b.OnError(j);return}if(c){b.OnNext(d);i()}else b.OnCompleted()})})},nb=c.GenerateWithTime=function(d,e,f,g,h,c){if(c===a)c=i;return new b(function(i){var a=d,l=true,b=false,j,k;return c.ScheduleRecursiveWithTime(function(c){b&&i.OnNext(j);try{if(l)l=false;else a=f(a);b=e(a);if(b){j=g(a);k=h(a)}}catch(d){i.OnError(d);return}if(b)c(k);else i.OnCompleted()},0)})},Y=c.OnErrorResumeNext=function(g,c){if(c===a)c=f;return b(function(b){var f=new e,a=0,h=c.ScheduleRecursive(function(c){if(a<g.length){var h=g[a];a++;var d=new e;f.Replace(d);d.Replace(h.Subscribe(function(a){b.OnNext(a)},c,c))}else b.OnCompleted()});return new d(f,h)})},pb=c.Amb=function(){var a=arguments;return b(function(f){var c=new d,b=new e;b.Replace(c);for(var j=false,h=0;h<a.length;h++){var l=a[h],i=new e,k=new g(function(a){if(!j){c.Remove(this.z,true);c.Dispose();b.Replace(this.z);j=true}f.OnNext(a)},function(a){f.OnError(a);b.Dispose()},function(){f.OnCompleted();b.Dispose()});k.z=i;i.Replace(l.Subscribe(k));c.Add(i)}return b})},qb=c.ForkJoin=function(){var c=arguments;return b(function(b){for(var e=[],g=[],f=[],i=new d,h=0;h<c.length;h++)(function(d){i.Add(c[d].Subscribe(function(a){e[d]=true;f[d]=a},function(a){b.OnError(a)},function(){if(!e[d]){b.OnCompleted();f=a;e=a;return}g[d]=true;for(var i=true,h=0;h<c.length;h++)if(!g[h])i=false;if(i){b.OnNext(f);b.OnCompleted();f=a;g=a;e=a}}))})(h);return i})},ab=c.Interval=function(a,b){return C(a,a,b)},M=function(a){return Math.max(0,a)},C=c.Timer=function(e,f,d){if(d===a)d=i;if(e===a)return U();if(e instanceof Date)return q(function(){return c.Timer(e-new Date,f,d)});var g=M(e);if(f===a)return b(function(a){return d.ScheduleWithTime(function(){a.OnNext(0);a.OnCompleted()},g)});var h=M(f);return b(function(a){var b=0;return d.ScheduleRecursiveWithTime(function(c){a.OnNext(b++);c(h)},g)})},N=c.While=function(a,c){return b(function(b){var g=new e,h=new d(g);h.Add(f.ScheduleRecursive(function(e){var d;try{d=a()}catch(f){b.OnError(f);return}if(d)g.Replace(c.Subscribe(function(a){b.OnNext(a)},function(a){b.OnError(a)},function(){e()}));else b.OnCompleted()}));return h})},bb=c.If=function(c,d,b){if(b===a)b=B();return q(function(){return c()?d:b})},cb=c.DoWhile=function(a,b){return G([a,N(b,a)])},db=c.Case=function(d,e,b,c){if(c===a)c=f;if(b===a)b=B(c);return q(function(){var c=e[d()];if(c===a)c=b;return c})},eb=c.For=function(a,c){return b(function(b){var e=new d,g=0;e.Add(f.ScheduleRecursive(function(f){if(g<a.length){var d;try{d=c(a[g])}catch(h){b.OnError(h);return}e.Add(d.Subscribe(function(a){b.OnNext(a)},function(a){b.OnError(a)},function(){g++;f()}))}else b.OnCompleted()}));return e})},fb=c.Let=function(a,b){return q(function(){return b(a)})},l=h.Notification=function(a,b){this.Kind=a;this.Value=b;this.toString=function(){return this.Kind+": "+this.Value};this.Accept=function(a){switch(this.Kind){case"N":a.OnNext(this.Value);break;case"E":a.OnError(this.Value);break;case"C":a.OnCompleted()}return o};this.w=function(b){var c=this.Accept(b);a=="N"&&b.OnCompleted();return c}};l.prototype=new c;var m=h.Subject=function(){var a=new r,b=false;this.OnNext=function(e){if(!b)for(var d=a.ToArray(),c=0;c<d.length;c++){var f=d[c];f.OnNext(e)}};this.OnError=function(e){if(!b){for(var d=a.ToArray(),c=0;c<d.length;c++){var f=d[c];f.OnError(e)}b=true;a.Clear()}};this.OnCompleted=function(){if(!b){for(var d=a.ToArray(),c=0;c<d.length;c++){var e=d[c];e.OnCompleted()}b=true;a.Clear()}};this.w=function(c){if(!b){a.Add(c);return n(function(){a.Remove(c)})}else return o}};m.prototype=new c;for(var D in g.prototype)m.prototype[D]=g.prototype[D];var v=h.AsyncSubject=function(e){var b=new r,c,d=false;if(e===a)e=f;this.OnNext=function(a){if(!d)c=new l("N",a)};this.OnError=function(f){if(!d){c=new l("E",f);for(var g=b.ToArray(),e=0;e<g.length;e++){var h=g[e];h!==a&&h.OnError(f)}d=true;b.Clear()}};this.OnCompleted=function(){if(!d){if(c===a)c=new l("C");for(var f=b.ToArray(),e=0;e<f.length;e++){var g=f[e];g!==a&&c.w(g)}d=true;b.Clear()}};this.w=function(a){if(!d){b.Add(a);return n(function(){b.Remove(a)})}else return e.Schedule(function(){c.w(a)})}};v.prototype=new m;var gb=h.BehaviorSubject=function(b,c){var a=new w(1,-1,c);a.OnNext(b);return a},w=h.ReplaySubject=function(h,i,e){var c=new r,b=new r,f=false;if(e===a)e=j;var k=i>0,g=function(c,a){b.Add({Value:new l(c,a),Timestamp:e.Now()})};this.A=function(){if(h!==a)while(b.GetCount()>h)b.RemoveAt(0);if(k)while(b.GetCount()>0&&e.Now()-b.GetItem(0).Timestamp>i)b.RemoveAt(0)};this.OnNext=function(d){if(!f){for(var b=c.ToArray(),a=0;a<b.length;a++){var e=b[a];e.OnNext(d)}g("N",d)}};this.OnError=function(d){if(!f){for(var b=c.ToArray(),a=0;a<b.length;a++){var e=b[a];e.OnError(d)}f=true;c.Clear();g("E",d)}};this.OnCompleted=function(){if(!f){for(var b=c.ToArray(),a=0;a<b.length;a++){var d=b[a];d.OnCompleted()}f=true;c.Clear();g("C")}};this.w=function(f){var a=new O(this,f),g=new d(a),h=this;g.Add(e.Schedule(function(){if(!a.B){h.A();for(var d=0;d<b.GetCount();d++)b.GetItem(d).Value.Accept(f);c.Add(f);a.C=true}}));return g};this.D=function(a){c.Remove(a)}};w.prototype=new m;var O=function(a,b){this.E=a;this.F=b;this.C=false;this.B=false;this.Dispose=function(){this.C&&this.E.D(this.F);this.B=true}},P=c.ToAsync=function(c,b){if(b===a)b=i;return function(){var a=new v(b),d=function(){var b;try{b=c.apply(this,arguments)}catch(d){a.OnError(d);return}a.OnNext(b);a.OnCompleted()},e=this,f=J(arguments);b.Schedule(function(){d.apply(e,f)});return a}},hb=c.Start=function(c,d,b,e){if(b===a)b=[];return P(c,e).apply(d,b)},p=h.ConnectableObservable=function(c,b){if(b===a)b=new m;this.E=b;this.G=c;this.H=false;this.Connect=function(){var a,e=false;if(!this.H){this.H=true;var b=this;a=new d(n(function(){b.H=false}));this.I=a;a.Add(c.Subscribe(this.E))}return this.I};this.w=function(a){return this.E.Subscribe(a)};this.RefCount=function(){var a=0,b=this,c;return E(function(e){var d=false;a++;d=a==1;var f=b.Subscribe(e);if(d)c=b.Connect();return function(){f.Dispose();a--;a==0&&c.Dispose()}})}};p.prototype=new c})();(function(){var c=jQuery,a=c.fn,h=this,e;if(typeof ProvideCustomRxRootObject=="undefined")e=h.Rx;else e=ProvideCustomRxRootObject();var g=e.Observable,b=e.AsyncSubject,f=g.Create,i=e.Disposable.Empty;a.toObservable=function(a,c){var b=this;return f(function(e){var d=function(a){e.OnNext(a)};b.bind(a,c,d);return function(){b.unbind(a,d)}})};a.toLiveObservable=function(a,c){var b=this;return f(function(e){var d=function(a){e.OnNext(a)};b.live(a,c,d);return function(){b.die(a,d)}})};a.hideAsObservable=function(c){var a=new b;this.hide(c,function(){a.OnNext(this);a.OnCompleted()});return a};a.showAsObservable=function(c){var a=new b;this.show(c,function(){a.OnNext(this);a.OnCompleted()});return a};a.animateAsObservable=function(c,d,e){var a=new b;this.animate(c,d,e,function(){a.OnNext(this);a.OnCompleted()});return a};a.fadeInAsObservable=function(c){var a=new b;this.fadeIn(c,function(){a.OnNext(this);a.OnCompleted()});return a};a.fadeToAsObservable=function(c,d){var a=new b;this.fadeTo(c,d,function(){a.OnNext(this);a.OnCompleted()});return a};a.fadeOutAsObservable=function(c){var a=new b;this.fadeOut(c,function(){a.OnNext(this);a.OnCompleted()});return a};a.slideDownAsObservable=function(c){var a=new b;this.slideDown(c,function(){a.OnNext(this);a.OnCompleted()});return a};a.slideUpAsObservable=function(c){var a=new b;this.slideUp(c,function(){a.OnNext(this);a.OnCompleted()});return a};a.slideToggleAsObservable=function(c){var a=new b;this.slideToggle(c,function(){a.OnNext(this);a.OnCompleted()});return a};var d=c.ajaxAsObservable=function(e){var a={};for(var f in e)a[f]=e[f];var d=new b;a.success=function(c,b,a){d.OnNext({data:c,textStatus:b,xmlHttpRequest:a});d.OnCompleted()};a.error=function(a,c,b){d.OnError({xmlHttpRequest:a,textStatus:c,errorThrown:b})};c.ajax(a);return d};c.getJSONAsObservable=function(b,a){return d({url:b,dataType:"json",data:a})};c.getScriptAsObservable=function(b,a){return d({url:b,dataType:"script",data:a})};c.postAsObservable=function(b,a){return d({url:b,type:"POST",data:a})};a.loadAsObservable=function(e,d){var a=new b,c=function(d,b,c){if(b==="error")a.OnError({response:d,status:b,xmlHttpRequest:c});else{a.OnNext({response:d,status:b,xmlHttpRequest:c});a.OnCompleted()}};this.load(e,d,c);return a};c.getScriptAsObservable=function(a){return d({url:a,dataType:"script"})};c.postAsObservable=function(c,a,b){return d({url:c,dataType:b,data:a,type:"POST"})}})();var dateFormat=function(){var d=/d{1,4}|m{1,4}|yy(?:yy)?|([HhMsTt])\1?|[LloSZ]|"[^"]*"|'[^']*'/g,c=/\b(?:[PMCEA][SDP]T|(?:Pacific|Mountain|Central|Eastern|Atlantic) (?:Standard|Daylight|Prevailing) Time|(?:GMT|UTC)(?:[-+]\d{4})?)\b/g,b=/[^-+\dA-Z]/g,a=function(a,b){a=String(a);b=b||2;while(a.length<b)a="0"+a;return a};return function(e,f,k){var i=dateFormat;if(arguments.length==1&&Object.prototype.toString.call(e)=="[object String]"&&!/\d/.test(e)){f=e;e=undefined}e=e?new Date(e):new Date;if(isNaN(e))throw SyntaxError("invalid date");f=String(i.masks[f]||f||i.masks["default"]);if(f.slice(0,4)=="UTC:"){f=f.slice(4);k=true}var h=k?"getUTC":"get",j=e[h+"Date"](),p=e[h+"Day"](),m=e[h+"Month"](),s=e[h+"FullYear"](),g=e[h+"Hours"](),q=e[h+"Minutes"](),r=e[h+"Seconds"](),l=e[h+"Milliseconds"](),n=k?0:e.getTimezoneOffset(),o={d:j,dd:a(j),ddd:i.i18n.dayNames[p],dddd:i.i18n.dayNames[p+7],m:m+1,mm:a(m+1),mmm:i.i18n.monthNames[m],mmmm:i.i18n.monthNames[m+12],yy:String(s).slice(2),yyyy:s,h:g%12||12,hh:a(g%12||12),H:g,HH:a(g),M:q,MM:a(q),s:r,ss:a(r),l:a(l,3),L:a(l>99?Math.round(l/10):l),t:g<12?"a":"p",tt:g<12?"am":"pm",T:g<12?"A":"P",TT:g<12?"AM":"PM",Z:k?"UTC":(String(e).match(c)||[""]).pop().replace(b,""),o:(n>0?"-":"+")+a(Math.floor(Math.abs(n)/60)*100+Math.abs(n)%60,4),S:(["th","st","nd","rd"])[j%10>3?0:(j%100-j%10!=10)*j%10]};return f.replace(d,function(a){return a in o?o[a]:a.slice(1,a.length-1)})}}();dateFormat.masks={"default":"ddd mmm dd yyyy HH:MM:ss",shortDate:"m/d/yy",mediumDate:"mmm d, yyyy",longDate:"mmmm d, yyyy",fullDate:"dddd, mmmm d, yyyy",shortTime:"h:MM TT",mediumTime:"h:MM:ss TT",longTime:"h:MM:ss TT Z",isoDate:"yyyy-mm-dd",isoTime:"HH:MM:ss",isoDateTime:"yyyy-mm-dd'T'HH:MM:ss",isoUtcDateTime:"UTC:yyyy-mm-dd'T'HH:MM:ss'Z'"};dateFormat.i18n={dayNames:["Sun","Mon","Tue","Wed","Thu","Fri","Sat","Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],monthNames:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec","January","February","March","April","May","June","July","August","September","October","November","December"]};Date.prototype.format=function(a,b){return dateFormat(this,a,b)};(function(){var a=8,m="",l=0,i=function(c){for(var d=[],f=(1<<a)-1,e=c.length*a,b=0;b<e;b+=a)d[b>>5]|=(c.charCodeAt(b/a)&f)<<32-a-b%32;return d},h=function(c){for(var d=[],e=c.length,b,a=0;a<e;a+=2){b=parseInt(c.substr(a,2),16);if(!isNaN(b))d[a>>3]|=b<<24-4*(a%8);else return"INVALID HEX STRING"}return d},g=function(d){for(var e=l?"0123456789ABCDEF":"0123456789abcdef",c="",f=d.length*4,b,a=0;a<f;a+=1){b=d[a>>2]>>(3-a%4)*8;c+=e.charAt(b>>4&15)+e.charAt(b&15)}return c},f=function(b){for(var g="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",d="",f=b.length*4,c,e,a=0;a<f;a+=3){e=(b[a>>2]>>8*(3-a%4)&255)<<16|(b[a+1>>2]>>8*(3-(a+1)%4)&255)<<8|b[a+2>>2]>>8*(3-(a+2)%4)&255;for(c=0;c<4;c+=1)if(a*8+c*6<=b.length*32)d+=g.charAt(e>>6*(3-c)&63);else d+=m}return d},b=function(b,a){return b<<a|b>>>32-a},j=function(a,b,c){return a^b^c},o=function(a,b,c){return a&b^~a&c},n=function(a,b,c){return a&b^a&c^b&c},c=function(b,c){var a=(b&65535)+(c&65535),d=(b>>>16)+(c>>>16)+(a>>>16);return(d&65535)<<16|a&65535},d=function(a,b,c,d,e){var f=(a&65535)+(b&65535)+(c&65535)+(d&65535)+(e&65535),g=(a>>>16)+(b>>>16)+(c>>>16)+(d>>>16)+(e>>>16)+(f>>>16);return(g&65535)<<16|f&65535},e=function(p,q){var f=[],g,h,i,k,l,m,r,a,t,e=[1732584193,4023233417,2562383102,271733878,3285377520],s=[1518500249,1518500249,1518500249,1518500249,1518500249,1518500249,1518500249,1518500249,1518500249,1518500249,1518500249,1518500249,1518500249,1518500249,1518500249,1518500249,1518500249,1518500249,1518500249,1518500249,1859775393,1859775393,1859775393,1859775393,1859775393,1859775393,1859775393,1859775393,1859775393,1859775393,1859775393,1859775393,1859775393,1859775393,1859775393,1859775393,1859775393,1859775393,1859775393,1859775393,2400959708,2400959708,2400959708,2400959708,2400959708,2400959708,2400959708,2400959708,2400959708,2400959708,2400959708,2400959708,2400959708,2400959708,2400959708,2400959708,2400959708,2400959708,2400959708,2400959708,3395469782,3395469782,3395469782,3395469782,3395469782,3395469782,3395469782,3395469782,3395469782,3395469782,3395469782,3395469782,3395469782,3395469782,3395469782,3395469782,3395469782,3395469782,3395469782,3395469782];p[q>>5]|=128<<24-q%32;p[(q+65>>9<<4)+15]=q;t=p.length;for(r=0;r<t;r+=16){g=e[0];h=e[1];i=e[2];k=e[3];l=e[4];for(a=0;a<80;a+=1){if(a<16)f[a]=p[a+r];else f[a]=b(f[a-3]^f[a-8]^f[a-14]^f[a-16],1);if(a<20)m=d(b(g,5),o(h,i,k),l,s[a],f[a]);else if(a<40)m=d(b(g,5),j(h,i,k),l,s[a],f[a]);else if(a<60)m=d(b(g,5),n(h,i,k),l,s[a],f[a]);else m=d(b(g,5),j(h,i,k),l,s[a],f[a]);l=k;k=i;i=b(h,30);h=g;g=m}e[0]=c(g,e[0]);e[1]=c(h,e[1]);e[2]=c(i,e[2]);e[3]=c(k,e[3]);e[4]=c(l,e[4])}return e},k=function(b,c){this.sha1=null;this.strBinLen=null;this.strToHash=null;if("HEX"===c){if(0!==b.length%2)return"TEXT MUST BE IN BYTE INCREMENTS";this.strBinLen=b.length*4;this.strToHash=h(b)}else if("ASCII"===c||"undefined"===typeof c){this.strBinLen=b.length*a;this.strToHash=i(b)}else return"UNKNOWN TEXT INPUT TYPE"};k.prototype={getHash:function(c){var a=null,b=this.strToHash.slice();switch(c){case"HEX":a=g;break;case"B64":a=f;break;default:return"FORMAT NOT RECOGNIZED"}if(null===this.sha1)this.sha1=e(b,this.strBinLen);return a(this.sha1)},getHMAC:function(j,o,p){var l,b,c,k,d,m=[],n=[];switch(p){case"HEX":l=g;break;case"B64":l=f;break;default:return"FORMAT NOT RECOGNIZED"}if("HEX"===o){if(0!==j.length%2)return"KEY MUST BE IN BYTE INCREMENTS";b=h(j);d=j.length*4}else if("ASCII"===o){b=i(j);d=j.length*a}else return"UNKNOWN KEY INPUT TYPE";if(64<d/8){b=e(b,d);b[15]&=4294967040}else if(64>d/8)b[15]&=4294967040;for(c=0;c<=15;c+=1){m[c]=b[c]^909522486;n[c]=b[c]^1549556828}k=e(m.concat(this.strToHash),512+this.strBinLen);k=e(n.concat(k),672);return l(k)}};window.jsSHA=k})();jSaaspose.PortalService=function(b,c,a){this._init(b,c,a)};$.extend(jSaaspose.PortalService.prototype,{_urlSuffix:"",_lastError:null,_service:null,_cacheTimeout:300,applicationPath:null,useJSONP:false,_useHttpHandlers:false,urlPrefix:"",_init:function(c,a,b){this.applicationPath=c;this._useHttpHandlers=a;if(a)this._urlSuffix="Handler";if($.browser.msie&&$.browser.version==8&&b)this.useJSONP=true},viewDocumentAsHtml:function(v,t,x,k,m,d,c,s,p,l,q,g,i,e,f,b,h,o,r,a,n,u,j){var w={userId:v,privateKey:t,path:x,useHtmlBasedEngine:true,preloadPagesCount:k,fileDisplayName:m,usePngImagesForHtmlBasedEngine:d,convertWordDocumentsCompletely:c,ignoreDocumentAbsence:g,supportPageRotation:i,supportListOfContentControls:e,supportListOfBookmarks:f,watermarkText:s,watermarkColor:p,watermarkPosition:l,watermarkWidth:q,embedImagesIntoHtmlForWordFiles:b,instanceIdToken:n,locale:u,passwordForOpening:j,saveFontsInAllFormats:h};this._runServiceAsync(this.applicationPath+this.urlPrefix+"/ViewDocument"+this._urlSuffix,w,o,r,a!=null?a:false)},getDocumentPageHtml:function(j,g,f,a,b,d,e,c,h){var i={path:j,pageIndex:g,usePngImages:f,embedImagesIntoHtmlForWordFiles:a,instanceIdToken:c,locale:h,saveFontsInAllFormats:b};this._runServiceAsync(this.applicationPath+this.urlPrefix+"/GetDocumentPageHtml"+this._urlSuffix,i,d,e,false)},viewDocument:function(v,t,q,s,g,p,i,o,l,h,m,d,e,b,c,k,n,a,j,r,f){var u={path:v,width:t,quality:q,usePdf:s,preloadPagesCount:g,password:p,fileDisplayName:i,watermarkText:o,watermarkColor:l,watermarkPosition:h,watermarkWidth:m,ignoreDocumentAbsence:d,supportPageRotation:e,supportListOfContentControls:b,supportListOfBookmarks:c,instanceIdToken:j,locale:r,passwordForOpening:f};this._runServiceAsync(this.applicationPath+this.urlPrefix+"/ViewDocument"+this._urlSuffix,u,k,n,a!=null?a:false)},getPdf2JavaScript:function(g,f,e,a,b,c){var d={path:e,descForHtmlBasedEngine:a};return this._runServiceAsync(this.applicationPath+this.urlPrefix+"/GetPdf2JavaScript"+this._urlSuffix,d,b,c,false)},getImageUrlsAsync:function(r,l,v,t,s,m,n,o,q,k,j,g,d,h,a,c,b,f,i,e,p){var u={userId:r,privateKey:l,path:v,width:t,token:s,firstPage:m,pageCount:n,quality:o,usePdf:q,docVersion:k,watermarkText:j,watermarkColor:g,watermarkPosition:d,watermarkWidth:h,ignoreDocumentAbsence:a,useHtmlBasedEngine:c,supportPageRotation:b,instanceIdToken:e,locale:p};return this._runServiceAsync(this.applicationPath+this.urlPrefix+"/GetImageUrls"+this._urlSuffix,u,f,i,false)},loadFileBrowserTreeData:function(m,e,o,g,j,k,i,l,f,h,c,d,a,b){var n={userId:m,privateKey:e,path:o,pageIndex:g,pageSize:j,orderBy:k,orderAsc:i,filter:l,fileTypes:f,extended:h,instanceIdToken:b};return this._runServiceAsync(this.applicationPath+this.urlPrefix+"/LoadFileBrowserTreeData"+this._urlSuffix,n,c,d,a!=null?a:true)},getPrintableHtml:function(m,b,d,j,g,c,h,a,f,i,e,k){var l={path:m,useHtmlBasedEngine:b,displayName:d,watermarkText:j,watermarkColor:g,watermarkPosition:c,watermarkWidth:h,ignoreDocumentAbsence:a,instanceIdToken:e,locale:k};return this._runServiceAsync(this.applicationPath+this.urlPrefix+"/GetPrintableHtml"+this._urlSuffix,l,f,i,false)},reorderPage:function(g,e,d,b,c,a){var f={path:g,oldPosition:e,newPosition:d,instanceIdToken:a};return this._runServiceAsync(this.applicationPath+this.urlPrefix+"/ReorderPage"+this._urlSuffix,f,b,c,false)},rotatePage:function(g,e,c,b,d,a){var f={path:g,pageNumber:e,rotationAmount:c,instanceIdToken:a};return this._runServiceAsync(this.applicationPath+this.urlPrefix+"/RotatePage"+this._urlSuffix,f,b,d,false)},_runServiceSync:function(f,e,d){var a=null,b=false,c=function(c){b=true;a=c.data};this._runService(f,e,false,c,null,d);return a},_runServiceAsync:function(f,e,a,b,d,c){return this._runService(f,e,true,a,b,d,c)},_runService:function(h,k,m,i,c,j,l){var e=JSON.stringify(k),g=null;if(j){g=Container.Resolve("Cacher");var f=g.get(h+e);if(f){f.value.Subscribe(function(a){this._successHandler(a,i)}.bind(this),function(a){this._errorHandler(a,c)}.bind(this));return f.value}}var d;if(this.useJSONP)if(this._useHttpHandlers)d="data="+e.toString();else d=k;else d=e;var b=Container.Resolve("RequestObservable")({url:h,type:this.useJSONP?"GET":"POST",contentType:"application/json; charset=utf-8",dataType:this.useJSONP?"jsonp"+(l?" xml":""):null,data:d,async:m}),a=Container.Resolve("AsyncSubject");b.Finally=function(b){a.Subscribe(b)};b.Subscribe(function(b){if(b)if(b.data.success===false){var d={code:b.data.code,Reason:b.data?b.data.Reason:null};c&&c(d)}else this._successHandler(b,i);a.OnNext();a.OnCompleted()}.bind(this),function(b){this._errorHandler(b,c);a.OnNext();a.OnCompleted()}.bind(this));j&&g.add(h+e,b,this._cacheTimeout);return b},_errorHandler:function(b,c){var a=null;if(b.xmlHttpRequest.readyState==0)if(b.xmlHttpRequest.status===0)a={Reason:"Can't connect to server"};else return;var d=b.xmlHttpRequest.status;if(!a)a={Reason:b.xmlHttpRequest.responseText};try{c&&c(a)}catch(e){}},_successHandler:function(a,b){if(b){if(a.xmlHttpRequest.responseText=="")a.data=null;b(a)}}});(function(){var a=jQuery.event.special,b="D"+ +new Date,c="D"+(+new Date+1);a.scrollstart={setup:function(){var c,d=function(d){var b=this,e=arguments;if(c)clearTimeout(c);else{d.type="scrollstart";$(b).trigger("scrollstart")}c=setTimeout(function(){c=null},a.scrollstop.latency)};jQuery(this).bind("scroll",d).data(b,d)},teardown:function(){jQuery(this).unbind("scroll",jQuery(this).data(b))}};a.scrollstop={latency:300,setup:function(){var b,d=function(d){var c=this,e=arguments;b&&clearTimeout(b);b=setTimeout(function(){b=null;d.type="scrollstop";$(c).trigger("scrollstop")},a.scrollstop.latency)};jQuery(this).bind("scroll",d).data(c,d)},teardown:function(){jQuery(this).unbind("scroll",jQuery(this).data(c))}}})();(function(a,b){a.widget("ui.docViewer",{_viewModel:null,options:{fileId:0,fileVersion:1,userId:0,userKey:null,baseUrl:null,_mode:"full",_docGuid:"",quality:null,use_pdf:"true",showHyperlinks:true},_create:function(){a.extend(this.options,{documentSpace:this.element,emptyImageUrl:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNgYAAAAAMAASsJTYQAAAAASUVORK5CYII="});this.options.createHtml&&this._createHtml();this._viewModel=this.getViewModel();ko.applyBindings(this._viewModel,this.element.get(0))},_init:function(){a(this._viewModel).bind("getPagesCount",function(c,b){a(this.element).trigger("getPagesCount",[b])}.bind(this));a(this._viewModel).bind("onDocumentLoaded",function(b,a){this.element.trigger("onDocumentLoaded",a)}.bind(this));a(this._viewModel).bind("onDocumentPasswordRequired",function(){a(this.element).trigger("onDocumentPasswordRequired")}.bind(this));a(this._viewModel).bind("_onProcessPages",function(c,b){a(this.element).trigger("_onProcessPages",[b])}.bind(this));a(this._viewModel).bind("onProcessPages",function(c,b){a(this.element).trigger("onProcessPages",[b])}.bind(this));a(this._viewModel).bind("onScrollDocView",function(c,b){a(this.element).trigger("onScrollDocView",[b])}.bind(this));a(this._viewModel).bind("onBeforeScrollDocView",function(c,b){a(this.element).trigger("onBeforeScrollDocView",[b])}.bind(this));a(this._viewModel).bind("onDocumentLoadComplete",function(d,c,b){a(this.element).trigger("onDocumentLoadComplete",[c,b])}.bind(this));a(this._viewModel).bind("onSearchPerformed",function(c,b){a(this.element).trigger("onSearchPerformed",[b])}.bind(this));a(this._viewModel).bind("onPageImageLoaded",function(){a(this.element).trigger("onPageImageLoaded")}.bind(this));a(this._viewModel).bind("onDocViewScrollPositionSet",function(c,b){a(this.element).trigger("onDocViewScrollPositionSet",[b])}.bind(this));a(this._viewModel).bind("onDocumentPageSet",function(c,b){a(this.element).trigger("onDocumentPageSet",[b])}.bind(this))},getViewModel:function(){if(this._viewModel==null)this._viewModel=this._createViewModel();return this._viewModel},_createViewModel:function(){return new docViewerViewModel(this.options)},applyBindings:function(){ko.applyBindings(this._viewModel,this.element.get(0))},_createHtml:function(){var b;if(this.options.supportPageRotation)b=" + ' translateY(' + (($root.isHtmlDocument() && $data.rotation() == 180) ? '100%' : '0') + ') ' + 'rotate(' + $data.rotation() + 'deg)' + ' translateX(' + (($data.rotation() == 180 || $data.rotation() == 270) ? '-100%' : '0') + ')' + ' translateY(' + (($data.rotation() == 90 || (!$root.isHtmlDocument() && $data.rotation() == 180)) ? '-100%' : '0') + ') '  ";else b="";var c="'-ms-transform': 'scale(' + $data.heightRatio() * $root.zoom() / 100.0 + ')' ";if(this.options.pageContentType=="html"&&a.browser.msie)if(a.browser.version==8)c="zoom: $data.heightRatio() * $root.zoom() / 100.0 ";else c+=b;c+=",";var e;if(this.options.watermarkText)e='<svg xmlns="http://www.w3.org/2000/svg" class="html_watermark" data-bind="attr:{width: $root.pageWidth() + $root.imageHorizontalMargin + \'px\', height: $root.pageWidth() * $data.prop() + \'px\', viewBox:\'0 0 100 \' + 100 * $data.prop()}" pointer-events="none"><text data-bind="text:$root.watermarkText, style:{fill:$root.intToColor($root.watermarkColor)}, attr:{transform:$root.watermarkTransform($data, $element), y:$root.watermarkPosition.indexOf(\'Top\') == -1 ? 100 * $data.prop() :\'10\'}" font-family="Verdana" font-size="10" x="0" y="0" ></text></svg>';else e="";var i='           <div class="html_page_contents"                 data-bind="'+(this.options.useVirtualScrolling?"parsedHtml":"html")+": htmlContent(), attr: { id:'"+this.options.docViewerId+"pageHtml-' + number }, searchText: searchText,                         css: {chrome: $root.browserIsChrome(), 'page-image': !$root.useTabsForPages()},                         style: {                                  width: $root.rotatedWidth(), "+c+"                                 MozTransform: 'scale(' + $data.heightRatio() * $root.zoom() / 100.0  + ')' "+b+",                                  '-webkit-transform': 'scale(' + $data.heightRatio() * $root.zoom() / 100.0  + ')' "+b+'                               }">            </div>'+e,j='           <div class="page-image html_page_contents"                 data-bind="html: htmlContent, attr: { id:\''+this.options.docViewerId+"pageHtml-' + number },                         searchText: searchText,                         style:{fontSize: ($data.heightRatio() * 100.0) + '%'},                        css: {chrome: $root.browserIsChrome()} \">            </div>",g;if(this.options.useEmScaling)g=j;else g=i;var d,f=this.options.pageContentType=="html";if(f&&this.options.useEmScaling)d='class="pages_container html_pages_container" data-bind="style:{fontSize: (16.* $root.zoom() / 100.0) + \'px\'}"';else d='class="pages_container '+(f?"html_pages_container":"")+"\" data-bind=\"style: { height: $root.useVirtualScrolling ? ($root.documentHeight() + 'px') : 'auto', width: ($root.layout() == $root.Layouts.TwoPagesInRow || $root.layout() == $root.Layouts.CoverThenTwoPagesInRow) ? ($root.pageWidth() + $root.imageHorizontalMargin) * 2 + 'px': 'auto'}\"";var k='<div id="'+this.options.docViewerId+'PagesContainer" '+d+'><!-- ko foreach: { data: $root.useVirtualScrolling ? pages.slice(firstVisiblePageForVirtualMode(), lastVisiblePageForVirtualMode() + 1) : pages, afterRender: function(){$root.highlightSearch();} } --><div class="doc-page" data-bind="attr: {id: $root.pagePrefix + (($root.useVirtualScrolling ? $root.firstVisiblePageForVirtualMode() : 0) + $index() + 1)}, style: $root.pageElementStyle($index()), css: {cover_page: ($root.layout() == $root.Layouts.CoverThenTwoPagesInRow && ($root.useVirtualScrolling ? $root.firstVisiblePageForVirtualMode() : 0) + $index() == 0)}" >       <div class="viewer_loading_overlay" data-bind="visible: ($root.alwaysShowLoadingSpinner() || $root.inprogress() || !visible()), style: { zIndex: ($root.inprogress() || !visible() ? 2 : 0), width: $root.pageWidth() + \'px\', height: $parent.pageWidth() * $data.prop() + \'px\', backgroundColor: ($root.inprogress() || !visible() ? \'\' : \'transparent\')}" style="width: 850px; height: 1100px;position: absolute;left:0;top:0">           <div class="loading_overlay_message">               <span class="progresspin"></span>               <p data-localize="LoadingYourContent">Loading your content...</p>           </div>       </div>'+(f?g:'           <div class="button-pane"></div>           <div class="highlight-pane"></div>           <div class="custom-pane"></div>           <div class="search-pane"></div>           <img class="page-image" src="'+this.options.emptyImageUrl+'" data-bind="event: {load: function(item, e){$root.firePageImageLoadedEvent($index(), e);}, error: function(item, e){$root.firePageImageLoadErrorEvent($index(), e);} }, attr: { id: \''+this.options.docViewerId+"' + '-img-' + ($index() + 1), src: (visible() ? url : $root.emptyImageUrl) },            style: { width: $parent.pageWidth() + 'px', height: $parent.pageWidth() * $data.prop() + 'px' }\"/>")+'   </div><!-- /ko --></div><div class="tab_control_wrapper" data-bind="visible: useTabsForPages && tabs().length > 0"><ul class="doc_viewer_tab_control" data-bind="foreach: tabs, visible: useTabsForPages && tabs().length > 0">   <li data-bind="css:{active:$index() == $root.activeTab()}">      <a href="#" data-bind="text:name, click: function(){$root.activateTab($index());}"></a>   </li></ul></div>',h=this.element;a(k).appendTo(h);h.trigger("onHtmlCreated");this.element=a("#"+this.options.docViewerId)}});docViewerModel=function(b){a.extend(this,b);this._init()};a.extend(docViewerModel.prototype,{_init:function(){this._portalService=Container.Resolve("PortalService")},loadDocument:function(d,f,b,k,g,j,h,e,i,n,o,l,m,q,r,a,s,p){var t=this,c=function(b){var c;if(b.data!=null){if(b.data.path&&typeof b.data.guid=="undefined")b.data.guid=b.data.path;if(t._mode=="webComponent")c=b.data.path;else c=b.data.guid}if(typeof c!=="undefined")r.apply(this,[b.data]);else a.apply(this,[{code:b.data.code,Reason:b.data?b.data.Reason:null}])};switch(this._mode){case"embed":this._portalService.viewEmbedDocumentAllAsync(this.userId,this.userKey,d,b,this.quality,this.use_pdf,this.preloadPagesCount,k,g,c,a);break;case"webComponent":this._portalService.viewDocument(d,b,this.quality,this.usePdf,this.preloadPagesCount,k,g,j,h,e,i,n,o,l,m,c,a,false,q,s,p);break;case"annotatedDocument":this._portalService.viewAnnotatedDocumentAsync(this.userId,this.userKey,d,null,f,b,null,this.quality,this.use_pdf,{text:j,color:h,position:e,fontSize:i},c,a,false);break;default:this._portalService.viewDocumentAllAsync(this.userId,this.userKey,d,null,f,b,null,this.quality,this.use_pdf,c,a,false)}},loadDocumentAsHtml:function(r,t,k,p,c,o,m,j,n,f,h,d,e,b,l,g,q,a,s,i){this._portalService.viewDocumentAsHtml(this.userId,this.userKey,r,this.preloadPagesCount,k,p,c,o,m,j,n,f,h,d,e,b,g,function(b){if(b.data&&typeof b.data.path!=="undefined")q.apply(this,[b.data]);else a.apply(this)},function(b){a.apply(this,[b])},false,l,s,i)},loadProperties:function(b,a){this._portalService.getDocInfoAsync(this.userId,this.userKey,b,function(b){a.apply(this,[b.data])})},loadHyperlinks:function(c,b,a){this._portalService.getDocumentHyperlinks(c,function(a){b.apply(this,[a.data])},function(b){a.apply(this,[b])})},retrieveImageUrls:function(m,o,k,f,j,g,d,h,a,c,b,e,l,i,n){this._portalService.getImageUrlsAsync(this.userId,this.userKey,m,f,o,0,k,this.quality==null?"":this.quality,this.use_pdf,this.fileVersion,j,g,d,h,a,c,b,function(a){l.apply(this,[a.data])},function(a){i.apply(this,[a])},e,n)},getDocumentPageHtml:function(h,f,e,a,c,b,g,d,i){this._portalService.getDocumentPageHtml(h,f,e,a,b,function(a){g.apply(this,[a.data])},function(a){d.apply(this,[a])},c,i)},reorderPage:function(f,d,c,a,e,b){this._portalService.reorderPage(f,d,c,function(a){e.apply(this,[a.data])},function(a){b.apply(this,[a])},a)},rotatePage:function(f,e,c,a,b,d){this._portalService.rotatePage(f,e,c,function(a){b.apply(this,[a.data])},function(a){d.apply(this,[a])},a)}});docViewerViewModel=function(b){a.extend(this,b);this._create(b)};a.extend(docViewerViewModel.prototype,{Layouts:{ScrollMode:1,BookMode:2,OnePageInRow:3,TwoPagesInRow:4,CoverThenTwoPagesInRow:5},_model:null,pagesDimension:null,pageImageWidth:0,imageHorizontalMargin:34,imageVerticalMargin:0,initialZoom:100,zoom:null,scale:null,docWasLoadedInViewer:false,scrollPosition:[0,0],inprogress:null,pages:null,pageInd:null,pageWidth:null,pageHeight:null,pageCount:null,docType:null,fileId:null,_dvselectable:null,_thumbnailHeight:140,_firstPage:null,_sessionToken:"",imageUrls:[],pagePrefix:"page-",documentName:null,fit90PercentWidth:false,_pageBounds:null,unscaledPageHeight:null,unscaledPageWidth:null,pageLeft:null,preloadPagesCount:null,viewerLayout:1,changedUrlHash:false,hashPagePrefix:"page",pageContentType:"image",scrollbarWidth:null,password:null,useJavaScriptDocumentDescription:false,minimumImageWidth:null,fileDisplayName:null,hyperlinks:null,watermarkText:null,watermarkWidth:null,watermarkColor:null,watermarkLeft:null,watermarkTop:null,watermarkScreenWidth:null,searchText:null,htmlSearchHighlightClassName:"search_highlight_html",htmlSearchHighlightElement:"span",htmlSearchHighlightSvgElement:"tspan",currentWordCounter:0,matchedNods:null,searchMatches:null,matchedNodsCount:0,matchesCount:null,searchSeparatorsList:'\\-[\\]{}()*+?\\\\^|\\s.,:;+"/',usePngImagesForHtmlBasedEngine:false,loadAllPagesOnSearch:false,serverPages:null,convertWordDocumentsCompletely:false,ignoreDocumentAbsence:false,tabs:null,useTabsForPages:null,tabPanelHeight:30,supportPageRotation:false,fileType:null,activeTab:null,autoHeight:null,isHtmlDocument:null,rotatedWidth:null,alwaysShowLoadingSpinner:null,supportListOfContentControls:false,supportListOfBookmarks:false,isDocumentLoaded:false,_isTextPositionsCalculationFinished:true,initStorageOnMouseStart:false,options:{showHyperlinks:true},_create:function(a){this._model=new docViewerModel(a);this._init(a)},_init:function(b){var e=this;this.initCustomBindings();if(this.viewerLeft!=0){this.viewerWidth-=this.viewerLeft;this.documentSpace.css("width",this.viewerWidth+"px")}var c=852,d=1100;this.pageImageWidth=c;this.pages=ko.observableArray([]);this.scale=ko.observable(this.initialZoom/100);this.inprogress=ko.observable(false),this.pageLeft=ko.observable(0);this.pageInd=ko.observable(1);this.pageWidth=ko.observable(c);this.pageHeight=ko.observable(d);this.pageCount=ko.observable(0);this.docType=ko.observable(-1);this.documentName=ko.observable("");this.password=ko.observable("");this.preloadPagesCount=b.preloadPagesCount;this.browserIsChrome=ko.observable(false);this.hyperlinks=ko.observableArray();this.useTabsForPages=ko.observable(null);this.tabs=ko.observableArray([]);this.activeTab=ko.observable(0);this.autoHeight=ko.observable(false);this.isHtmlDocument=ko.observable(false);this.alwaysShowLoadingSpinner=ko.observable(false);this.rotatedWidth=ko.computed(function(){if(this.useTabsForPages()){var a;a=this.pageWidth();return this.autoHeight()?"auto":a/this.zoom()*100+"px"}else return"auto"},this);this.layout=ko.observable(this.viewerLayout);this.firstVisiblePageForVirtualMode=ko.observable(0).extend({rateLimit:{method:"notifyWhenChangesStop",timeout:400}});this.lastVisiblePageForVirtualMode=ko.observable(0).extend({rateLimit:{method:"notifyWhenChangesStop",timeout:400}});this.documentHeight=ko.observable(0);if(this.pageContentType=="html"){this.imageHorizontalMargin=0;this.calculatePointToPixelRatio()}if(!this.docViewerId)this.docViewerId=this.documentSpace.attr("id");this.pagePrefix=this.docViewerId+"-page-";if(b.fit90PercentWidth)this.pageImageWidth=this.documentSpace.width()*.9-2*this.imageHorizontalMargin;if(this.pageContentType=="image")this.initialWidth=this.pageImageWidth;if(this.zoomToFitWidth)this.initialWidth=this.pageImageWidth=this.getFitWidth();this.zoom=ko.observable(this.initialZoom);this.documentHeight=ko.observable(0);this.options.showHyperlinks=b.showHyperlinks!=false&&this.use_pdf!="false";this.options.highlightColor=b.highlightColor;this.matchedNods=[];this.searchMatches=[];this.serverPages=[{w:this.initialWidth,h:100}];var a;if(this.pages().length==0){a={number:1,visible:ko.observable(false),url:ko.observable(this.emptyImageUrl),htmlContent:ko.observable(""),searchText:ko.observable(null)};if(this.supportPageRotation)a.rotation=ko.observable(0);if(this.variableHeightPageSupport){a.prop=ko.observable(1);a.heightRatio=ko.observable(1)}if(this.useVirtualScrolling){a.left=0;a.top=ko.observable(0)}this.pages.push(a)}this.pagesContainerElement=this.documentSpace.find(".pages_container");this.contentControlsFromHtml=[];if(b.fileId)this.loadDocument();else a.visible(true)},loadDocument:function(a){this.inprogress(true);this.documentSpace.trigger("onDocumentloadingStarted");var c=function(b){this._onDocumentLoadFailed(b,a||this.fileId)},d=1;if(this.pageContentType=="image"){var b;if(this.shouldMinimumWidthBeUsed(this.pageImageWidth*this.initialZoom/100,false))b=this.minimumImageWidth;else b=Math.round(this.pageImageWidth*this.initialZoom/100);this._model.loadDocument(a||this.fileId,d,b,this.password(),this.fileDisplayName,this.watermarkText,this.watermarkColor,this.watermarkPosition,this.watermarkWidth,this.ignoreDocumentAbsence,this.supportPageRotation,this.supportListOfContentControls,this.supportListOfBookmarks,this.instanceIdToken,function(b){if(typeof a!=="undefined")this.fileId=a;this.pageWidth(this.pageImageWidth*(this.initialZoom/100));this.zoom(this.initialZoom);this.docWasLoadedInViewer&&this.setPageNumerInUrlHash(1);this._onDocumentLoadedBeforePdf2Xml(b)}.bind(this),c.bind(this),this.locale,this.passwordForOpening)}else this.pageContentType=="html"&&this._model.loadDocumentAsHtml(a||this.fileId,d,this.fileDisplayName,this.usePngImagesForHtmlBasedEngine,this.convertWordDocumentsCompletely,this.watermarkText,this.watermarkColor,this.watermarkPosition,this.watermarkWidth,this.ignoreDocumentAbsence,this.supportPageRotation,this.supportListOfContentControls,this.supportListOfBookmarks,this.embedImagesIntoHtmlForWordFiles,this.instanceIdToken,this.saveFontsInAllFormats,function(b){if(typeof a!=="undefined")this.fileId=a;this.pageWidth(this.pageImageWidth*(this.initialZoom/100));this._onDocumentLoadedBeforePdf2Xml(b)}.bind(this),c.bind(this),this.locale,this.passwordForOpening);typeof viewModelPathOnlineDoc!=="undefined"&&viewModelPathOnlineDoc.pathOnlineDoc("")},getDocumentPageHtml:function(b,c){var a;if(this.useTabsForPages())a=this.tabs()[b];else a=this.pages()[b];if(!a.visible()&&!a.startedDownloadingPage){var d=this.preloadedPages&&this.preloadedPages.html[b];if(d){a.htmlContent(d);var e=this.preloadedPages.css[b];this.setPageHtml(a,b,d,e);c&&c.call();return}a.startedDownloadingPage=true;this._model.getDocumentPageHtml(this.fileId,b,this.usePngImagesForHtmlBasedEngine,this.embedImagesIntoHtmlForWordFiles,this.instanceIdToken,this.saveFontsInAllFormats,function(d){this.setPageHtml(a,b,d.pageHtml,d.pageCss);c&&c.call()}.bind(this),function(b){a.startedDownloadingPage=false;this._onError(b)}.bind(this),this.locale)}},setPageHtml:function(b,i,c,j){var d=j;if(!this.pageCssElement)this.pageCssElement=a([]);if(this.browserIsIE9OrLess){var h=this.pageCssElement.filter("style:first");d=h.html();h.remove();d+=j}var g=a("<style type='text/css'>"+d+"</style>");this.pageCssElement=this.pageCssElement.add(g);g.appendTo("head");var f=this.useTabsForPages();if(f||f===null)c=c.replace(/^[\r\n\s]+|[\r\n\s]+$/g,"");b.htmlContent(c);var e={text:this.searchText,isCaseSensitive:false,searchForSeparateWords:this.searchForSeparateWords,treatPhrasesInDoubleQuotesAsExact:this.treatPhrasesInDoubleQuotesAsExact,pageNumber:i};if(this.useVirtualScrolling){b.parsedHtmlElement=a(c);b.currentValue=c;this.parseSearchParameters(b.parsedHtmlElement.not("style")[0],e)}b.searchText(e);b.visible(true);b.startedDownloadingPage=false;this.markContentControls(i)},addPageCss:function(e){var b=e;if(!this.pageCssElement)this.pageCssElement=a([]);if(this.browserIsIE9OrLess){var d=this.pageCssElement.filter("style:first");b=d.html();d.remove();b+=e}var c=a("<style type='text/css'>"+b+"</style>");this.pageCssElement=this.pageCssElement.add(c);c.appendTo("head")},retrieveImageUrls:function(d){var a,c,b;if(this.shouldMinimumWidthBeUsed(this.pageWidth(),true))b=this.minimumImageWidth;else b=this.pageWidth();c=Math.floor(b)+"x";this._model.retrieveImageUrls(this.fileId,this._sessionToken,d,this._mode=="webComponent"?Math.floor(b):c,this.watermarkText,this.watermarkColor,this.watermarkPosition,this.watermarkWidth,this.ignoreDocumentAbsence,this.useHtmlBasedEngine,this.supportPageRotation,this.instanceIdToken,function(b){var c;if(b.imageUrls&&typeof b.image_urls=="undefined")c=b.imageUrls;else c=b.image_urls;for(a=0;a<d;a++){this.pages()[a].url(c[a]);this.loadImagesForVisiblePages()}}.bind(this),function(a){this._onError(a)}.bind(this),this.locale)},_onError:function(c,b){this.inprogress(false);var a=window.jerror||window.jGDError&&window.jGDError[this.instanceId];a&&a(c.Reason||"The document couldn't be loaded...",b)},_onDocumentLoadFailed:function(b,c){this.inprogress(false);if(b.code=="Unauthorized")a(this).trigger("onDocumentPasswordRequired");else{this._onError(b,c);this.documentSpace.trigger("documentLoadFailed.groupdocs")}},_onDocumentLoadedBeforePdf2Xml:function(a){var d=this;function c(){d._onDocumentLoaded(a)}if(a.path&&typeof a.guid=="undefined")a.guid=a.path;var b={userId:this.userId,privateKey:this.userKey,fileId:this.fileId,guid:a.guid,documentDescription:a.documentDescription,callback:c,setTextPositionsCalculationFinishedCallback:this._setTextPositionsCalculationFinished,viewerThis:this};if(this.useJavaScriptDocumentDescription){b.synchronousWork=this.textSelectionSynchronousCalculation;b.descForHtmlBasedEngine=this.pageContentType=="html"||this.use_pdf=="false";this._pdf2XmlWrapper=new jGroupdocs.Pdf2JavaScriptWrapper(b);this._onDocumentLoaded(a)}else if(this.use_pdf=="false")this._onDocumentLoaded(a);else this._pdf2XmlWrapper=new jSaaspose.Pdf2XmlWrapper(b)},_onDocumentLoaded:function(c){this.isDocumentLoaded=true;if(this.useJavaScriptDocumentDescription)c.page_count=this._pdf2XmlWrapper.getPageCount();else if(typeof c.page_count=="undefined"&&c.documentDescription){var y=JSON.parse(c.documentDescription);if(y.pages&&typeof y.pages.length!="undefined")c.page_count=y.pages.length}if(c.docType&&typeof c.doc_type=="undefined")c.doc_type=c.docType;if(c.imageUrls&&typeof c.image_urls=="undefined")c.image_urls=c.imageUrls;if(c.path&&typeof c.guid=="undefined")c.guid=c.path;if(!c.page_size)c.page_size={};a(this).trigger("onDocumentLoaded",c);var e=this;this._sessionToken=c.token;this.docGuid=c.guid;this.pageCount(c.page_count);this.documentName(c.name);this.docType(c.doc_type);this.password(c.password);this.matchesCount=0;a(this).trigger("getPagesCount",c.page_count);if(this.variableHeightPageSupport)c.documentDescription=this._pdf2XmlWrapper.documentDescription;var g=null,i=null,d,h,A,s;if(this.supportListOfContentControls)this.contentControls=this._pdf2XmlWrapper.getContentControls();if(this.supportListOfBookmarks)this.bookmarks=this._pdf2XmlWrapper.getBookmarks();if(this.pageContentType=="image"){if(this.use_pdf!="false"||this.variableHeightPageSupport){i=this._pdf2XmlWrapper.getPageSize();if(this.variableHeightPageSupport){c.page_size.Width=i.width;c.page_size.Height=i.height}this.scale(this.pageImageWidth*(this.initialZoom/100)/i.width);this.unscaledPageHeight=Number(i.height);this.unscaledPageWidth=Number(i.width)}this.heightWidthRatio=parseFloat(c.page_size.Height/c.page_size.Width);this.pageHeight(Math.round(this.pageImageWidth*this.heightWidthRatio*(this.initialZoom/100)));a(this).trigger("_onProcessPages",c)}else if(this.pageContentType=="html"){this.watermarkScreenWidth=null;this.zoom(100);this.fileType=c.fileType;this.urlForResourcesInHtml=c.urlForResourcesInHtml;A=this.fileType=="Txt"||this.fileType=="Xml";this.isHtmlDocument(this.fileType=="Html"||this.fileType=="Htm"||A);var n=c.doc_type=="Cells"||this.isHtmlDocument();this.useTabsForPages(n);n|=c.doc_type=="Image";this.documentSpace.trigger("isDocumentSinglePaged.groupdocs",n);this.alwaysShowLoadingSpinner(!n);var I=a.browser.webkit&&!!window.chrome,R=window.chrome,S=window.navigator.vendor,T=window.navigator.userAgent.indexOf("OPR")>-1;if(!!R&&S==="Google Inc."&&T==false)I=true;this.browserIsChrome(I);var q=c.pageCss[0];if(!q)q="";this.pageCssElement&&this.pageCssElement.remove();this.urlForImagesInHtml=c.urlForImagesInHtml;this.urlForFontsInHtml=c.urlForFontsInHtml;this.pageCssElement=a([]);this.preloadedPages={html:c.pageHtml,css:c.pageCss};var p=c.pageHtml[0],j=this.pages()[0];g=this._pdf2XmlWrapper.documentDescription.pages;this.autoHeight(this.useTabsForPages());var m;if(this.useTabsForPages()){this.pageCount(1);if(this.isHtmlDocument()){var B;if(A)B="<div class='text_document_wrapper'>"+p+"</div>";else{var C=this.getHtmlElementContents(p,"head");if(C){var w=this.getHtmlElements(C,"style"),z=this.getHtmlElementAttributess(C,"link");if(z!=null){this.linkElementsToLoad=0;for(d=0;d<z.length;d++){m=a(z[d]);var W=m.attr("rel");if(W=="stylesheet"){this.linkElementsToLoad++;var X=m.attr("href");a.get(X,function(c){var b=a("<style type='text/css'>"+c+"</style>");e.pageCssElement=e.pageCssElement.add(b);b.prependTo("head");e.linkElementsToLoad--;if(e.linkElementsToLoad==0){e.autoHeight(true);e._calculatePageSizeFromDOM();e.adjustInitialZoom()}}).fail(function(){e.linkElementsToLoad--;if(e.linkElementsToLoad==0){e.autoHeight(true);e._calculatePageSizeFromDOM();e.adjustInitialZoom()}})}}}if(w)for(d=0;d<w.length;d++){var V=w[d];q+=V}}B=this.getPageBodyContentsWithReplace(p)}var x=a(B);x.find("script").remove();x.addClass("html_document_wrapper");p=x[0].outerHTML;var Q=".grpdx .ie .doc-page .html_page_contents > div {font-size:1em;}";q+=Q}}else{i=this._pdf2XmlWrapper.getPageSize();j.prop(g[0].h/g[0].w);s=this.getScaleRatioForPage(i.width,i.height,g[0].w,g[0].h);j.heightRatio(s);this.documentSpace.css("background-color","inherit")}m=a("<style>"+q+"</style>");this.pageCssElement=this.pageCssElement.add(m);m.appendTo("head");var M=c.sharedCss;if(M){var K=a("<style>"+M+"</style>");this.pageCssElement=this.pageCssElement.add(K);K.appendTo("head")}this.calculatePointToPixelRatio();var P=this.documentSpace.find(".html_page_contents:first");j.htmlContent(p);j.visible(true);this.clearContentControls();this.markContentControls(0);this.tabs.removeAll();if(this.useTabsForPages()){var E=this._pdf2XmlWrapper.documentDescription.sheets;if(E)for(d=0;d<E.length;d++)this.tabs.push({name:E[d].name,visible:ko.observable(false),htmlContent:ko.observable(""),searchText:ko.observable(null)});this.activeTab(0);this.documentSpace.css("background-color","white")}if(this.useTabsForPages()&&this.tabs().length>0)this.documentSpace.addClass("doc_viewer_tabs");else this.documentSpace.removeClass("doc_viewer_tabs");var k=P.children("div,table,img"),l;if(this.useTabsForPages()){l=k.width();var H=k.height();j.prop(H/l);i={width:l,height:H};j.heightRatio(1)}if(this.supportPageRotation){if(g)h=g[0].rotation;else h=0;if(typeof h=="undefined")h=0;this.applyPageRotationInBrowser(0,j,h)}this.imageHorizontalMargin=7;c.page_size.Width=i.width;c.page_size.Height=i.height;var N=i.width,J=false,G=k.children();if(G.length==1&&G.filter("img").length==1)J=true;var u=null;if(!J&&!this.useTabsForPages()){u=k.css("width");k.css("width",N+"pt")}if(this.isHtmlDocument())l=this.getFitWidth();else l=k.width();this.heightWidthRatio=parseFloat(c.page_size.Height/c.page_size.Width);(!this.useTabsForPages()||!this.supportPageRotation||j.rotation%180==0)&&this.pageWidth(l);u!==null&&typeof u!="undefined"&&k.css("width",u);this.pageHeight(Math.round(this.pageWidth()*this.heightWidthRatio));this.initialWidth=this.pageWidth()}var t=this.pageCount();if(!c.lic&&t>3)t=3;var o=[],f;if(this.pageContentType=="image"){var D,F;if(this.variableHeightPageSupport){this.serverPages=g=this._pdf2XmlWrapper.documentDescription.pages;F=this._pdf2XmlWrapper.getPageCount()}for(d=0;d<t;d++){if(d<c.image_urls.length)D=c.image_urls[d];else D="";f={number:d+1,visible:ko.observable(false),url:ko.observable(D)};if(this.variableHeightPageSupport)if(d<F&&g)f.prop=ko.observable(g[d].h/g[d].w);else f.prop=ko.observable(this.pageHeight()/this.pageWidth());if(this.supportPageRotation){h=this.serverPages[d].rotation;if(typeof h=="undefined")h=0;f.rotation=ko.observable(h);this.applyPageRotationInBrowser(d,f,h)}if(this.useVirtualScrolling){f.left=0;f.top=ko.observable(0)}o.push(f)}}else if(this.pageContentType=="html"){this.serverPages=g=this._pdf2XmlWrapper.documentDescription.pages;pageWidth=this.pageWidth();f=this.pages()[0];o.push(f);var L;for(d=1;d<t;d++){s=this.getScaleRatioForPage(i.width,i.height,g[d].w,g[d].h);L=g[d].h/g[d].w;f={number:d+1,visible:ko.observable(false),htmlContent:ko.observable(""),prop:ko.observable(L),heightRatio:ko.observable(s),searchText:ko.observable(null)};if(this.supportPageRotation){h=this.serverPages[d].rotation;if(typeof h=="undefined")h=0;f.rotation=ko.observable(h);this.applyPageRotationInBrowser(d,f,h)}if(this.useVirtualScrolling){f.left=0;f.top=ko.observable(0)}o.push(f)}if(n)c.page_count=0;this.documentSpace.trigger("_onProcessPages",[c,o,this.getDocumentPageHtml,this,this.pointToPixelRatio,this.docViewerId])}this.pages(o);this.calculatePagePositionsForVirtualMode();this._firstPage=this.documentSpace.find("#"+this.pagePrefix+"1");if(this.pages().length>0&&this._firstPage.length==0&&!this.useVirtualScrolling)return;a(this).trigger("onProcessPages",[this.docGuid]);this.inprogress(false);this.pageContentType=="image"&&this.recalculatePageLeft();var v=Math.floor(this.pagesContainerElement.width()/this.pageWidth());if(v==0)v=1;if(this.layout()==this.Layouts.OnePageInRow)v=1;if(this._pdf2XmlWrapper&&this._pdf2XmlWrapper._setTextPositionsCalculationFinished)this._isTextPositionsCalculationFinished=false;var U=this.scale();this._dvselectable=this.pagesContainerElement.dvselectable({txtarea:this.selectionContent,pdf2XmlWrapper:this._pdf2XmlWrapper,startNumbers:this.getVisiblePagesNumbers(),pagesCount:this.pageCount(),proportion:U,pageHeight:this.getPageHeight(),horizontalPageCount:v,docSpace:this.documentSpace,pagePrefix:this.pagePrefix,searchPartialWords:this.searchPartialWords,storeAnnotationCoordinatesRelativeToPages:this.storeAnnotationCoordinatesRelativeToPages,initializeStorageOnly:this.pageContentType=="html",preventTouchEventsBubbling:this.preventTouchEventsBubbling,highlightColor:this.options.highlightColor,useVirtualScrolling:this.useVirtualScrolling,pageLocations:this.useVirtualScrolling?this.pages():null,initStorageOnMouseStart:this.initStorageOnMouseStart});this._dvselectable.dvselectable("setVisiblePagesNumbers",this.getVisiblePagesNumbers());if(!this.docWasLoadedInViewer&&(this.usePageNumberInUrlHash===b||this.usePageNumberInUrlHash==true)){var O=location.pathname;location.hash.substring(1,this.hashPagePrefix.length+1)!=this.hashPagePrefix&&this.setPage(1);Sammy(function(){this.get(/\#page(.*)/i,b);this.get(O,a);function a(){e.pageInd()!=1&&e.setPage(1)}function b(){if(!e.changedUrlHash)if(!(this.params.splat.length==0||this.params.splat[0].length==0)){var b=this.params.splat[0],a=Number(b);if(isNaN(a))a=1;if(a>e.pageCount())a=e.pageCount();if(a<1)a=1;e.setPage(a)}}}).run()}else this.setPage(1);!this.zoomToFitHeight&&this.loadImagesForVisiblePages(true);this.adjustInitialZoom();this.docWasLoadedInViewer=true;this.pageContentType=="image"&&this._mode!="webComponent"&&this._mode!="annotatedDocument"&&this._loadHyperlinks();if(this.preloadPagesOnBrowserSide){var r=this.preloadPagesCount;if(r===null||r>this.pageCount())r=this.pageCount();this.loadImagesForPages(1,r)}a(this).trigger("onScrollDocView",{pi:1,direction:"up",position:0});a(this).trigger("onDocumentLoadComplete",[c,this._pdf2XmlWrapper]);this._isTextPositionsCalculationFinished&&this.raiseDocumentLoadCompletedEvent()},_onDocumentHyperlinksLoaded:function(b){if(!b||!b.links){this.hyperlinks.removeAll();return}var d=[],e=this,c=this.getSelectableInstance();a.each(b.links,function(){var a={url:this.Url,pageNumber:this.PageNumber,targetPage:this.TargetPage,rect:new jSaaspose.Rect(this.Bounds.X,this.Bounds.Y,this.Bounds.X+this.Bounds.Width,this.Bounds.Y+this.Bounds.Height)};a.frame=ko.observable(c!=null?c.convertPageAndRectToScreenCoordinates(a.pageNumber,a.rect):a.rect);d.push(a)});this.hyperlinks(d)},_loadHyperlinks:function(){this.options.showHyperlinks==true&&this._model.loadHyperlinks(this.fileId,this._onDocumentHyperlinksLoaded.bind(this),function(){})},_refreshHyperlinkFrames:function(){var b=this.getSelectableInstance();a.each(this.hyperlinks(),function(){this.frame(b!=null?b.convertPageAndRectToScreenCoordinates(this.pageNumber,this.rect):this.rect)})},setPageWidth:function(a){this.pageImageWidth=a},setContainerWidth:function(a){this.viewerWidth=a},getFitWidth:function(){var b;if(this.viewerWidth)b=this.viewerWidth;else b=this.documentSpace.width();var d=this.getScrollbarWidth(),a=b-d-2*(this.imageHorizontalMargin+1);if(!this.useTabsForPages()){var c=this.layout();if(c==this.Layouts.TwoPagesInRow||c==this.Layouts.CoverThenTwoPagesInRow)a=a/2}return a},getFitWidthZoom:function(){return this.getFitWidth()/this.initialWidth*100},setContainerHeight:function(a){this.viewerHeight=a},getViewerHeight:function(){var a;if(this.viewerHeight)a=this.viewerHeight;else a=this.documentSpace.parent().height();return a},getFitHeightZoom:function(){var a=this.getViewerHeight();return(a-(this.imageVerticalMargin+2))/Math.round(this.initialWidth*this.heightWidthRatio)*100},getScrollbarWidth:function(){if(this.scrollbarWidth==null){var c=a("<div/>").css("width","100px").css("height","100px").css("overflow","scroll").css("position","absolute").css("top","-9999px"),b=c[0];document.body.appendChild(b);this.scrollbarWidth=b.offsetWidth-b.clientWidth;document.body.removeChild(b)}return this.scrollbarWidth},getPageHeight:function(){return this.unscaledPageHeight*this.scale()},getSelectable:function(){return this._dvselectable},_onPropertiesLoaded:function(b){a(this).trigger("onDocumentLoaded",{fileId:this.fileId,response:b})},getFileId:function(){return this.fileId},ScrollDocView:function(w,v){var t=this.isSetCalled;this.isSetCalled=false;if(t)return;if(this.useTabsForPages())return;var b=null,u=this.documentSpace.height(),d=a(v.target).scrollTop();a(this).trigger("onBeforeScrollDocView",{position:d});if(this.variableHeightPageSupport){var k=this.getSelectableInstance();if(k==null)return null;k.initStorage();var s=k.pageLocations,e,p,q=this.pages(),i;i=this.getVisiblePagesNumbers();for(var r=this.documentSpace.height(),n=null,g=null,o,l,m,h,c=i.start-1;c<=i.end-1;c++){if(this.useVirtualScrolling)e=q[c].top();else e=s[c].y;pageHeight=q[c].prop()*this.pageWidth();p=Math.floor(e+pageHeight);o=Math.max(e,d);l=Math.min(p,d+r);m=l-o;h=m/pageHeight;if(g==null||h>g){g=h;n=c}}b=n+1}else if(this._firstPage!=null){b=(d+u/2)/this._firstPage.outerHeight(true);var f=Math.floor(this.pagesContainerElement.width()/this._firstPage.width());if(f==0)f=1;if(this.layout()==this.Layouts.OnePageInRow)f=1;b=b>>0;var j=this.pageCount();if(b!=j)b=b+1;b=(b-1)*f+1;if(b>j)b=j}if(b!==null){this.pageInd(b);this.setPageNumerInUrlHash(b);a(this).trigger("onScrollDocView",{pi:b,position:d});this.documentSpace.trigger("documentScrolledToPage.groupdocs",[b])}},ScrollDocViewEnd:function(d,b){if(this.useTabsForPages())return;this.isSetCalled=false;this.scrollPosition=[a(b.target).scrollLeft(),a(b.target).scrollTop()];var c=this.loadImagesForVisiblePages();this._dvselectable&&a(this._dvselectable).dvselectable("setVisiblePagesNumbers",c);a(this).trigger("onDocumentPageSet",[this.pageInd()]);this.documentSpace.trigger("documentScrolledToPage.groupdocs",[this.pageInd()])},getVisiblePagesNumbers:function(){if(!this.isDocumentLoaded)return null;if(this.useTabsForPages())return{start:1,end:1};var f=null,g=null,a=this.documentSpace.scrollTop(),e,l=null,h=this.documentSpace.height();if(this.variableHeightPageSupport){var n=this.getSelectableInstance();if(n==null&&!this.useVirtualScrolling)return null;var k=this.pages(),j,m;if(this.useVirtualScrolling)m=k.length;else{j=n.pageLocations;if(j.length!=k.length)return null;m=j.length}for(var d,i,b=0;b<m;b++){if(this.useVirtualScrolling)d=k[b].top();else d=j[b].y;e=k[b].prop()*this.pageWidth();i=d+e;if(d>=a&&d<=a+h||i>=a&&i<=a+h||d<=a&&i>=a+h)if(f===null)f=b+1;else g=b+1}if(g===null)g=f}else if(this._firstPage!=null){e=this._firstPage.outerHeight(true);var p=this._firstPage.outerWidth(true),q=this.pagesContainerElement.width();l=Math.floor(a/e)+1;var o=Math.floor((a+h)/e)+1,c=Math.floor(q/p);if(c==0)c=1;if(this.layout()==this.Layouts.OnePageInRow)c=1;f=l!=1?(l-1)*c+1:1;g=o*c<=this.pageCount()?o*c:this.pageCount()}return{start:f,end:g}},loadImagesForVisiblePages:function(d){var a=this.getVisiblePagesNumbers();if(a!=null){var b=a.start,c=a.end;if(b!==null&&c!==null){this.loadImagesForPages(b,c,d);if(this.useVirtualScrolling){this.firstVisiblePageForVirtualMode(a.start-1);this.lastVisiblePageForVirtualMode(a.end-1)}}}return a},loadImagesForPages:function(h,e,g){var d=this.pages(),f="",b,c;if(d.length<e)e=d.length;for(var a=h;a<=e;a++){b=d[a-1];c=b.visible();c&&this.markContentControls(a-1);if(this.pageContentType=="image"){this.triggerImageLoadedEvent(a);this.supportPageRotation&&g&&this.addSuffixToImageUrl(b)}else if(this.pageContentType=="html")!c&&this.getDocumentPageHtml(a-1);b.visible(true)}this.pageContentType=="html"&&f!=""&&this.addPageCss(f)},setPage:function(j){this.isSetCalled=true;var b=Number(j);if(isNaN(b)||b<1)b=1;this.pageInd(b);var c;if(this.variableHeightPageSupport)if(this.useVirtualScrolling)c=this.pages()[b-1].top();else{var d=this.getSelectableInstance();if(d!=null)if(d.pageLocations&&d.pageLocations.length>0){var h=d.pageLocations[b-1].y;c=h}}else{var e=Math.floor(this.pagesContainerElement.width()/this._firstPage.width());if(e==0)e=1;if(this.layout()==this.Layouts.OnePageInRow)e=1;var i=Math.ceil(b/e)-1;c=i*this._firstPage.outerHeight(true)}var g=this.documentSpace.scrollTop();this.documentSpace.scrollTop(c);if(this.documentSpace.scrollTop()==g)this.isSetCalled=false;a(this).trigger("onDocViewScrollPositionSet",{position:c});var f=this.pages()[b-1];if(this.pageContentType=="image"){this.triggerImageLoadedEvent(b);f.visible(true)}else if(this.pageContentType=="html")!f.visible()&&this.getDocumentPageHtml(b-1);this.setPageNumerInUrlHash(b);a(this).trigger("onDocumentPageSet",[b]);this.documentSpace.trigger("documentPageSet.groupdocs",b)},triggerImageLoadedEvent:function(b){if(a.browser.msie)!this.pages()[b-1].visible()&&a("img#img-"+b).load(function(){a(this).trigger("onPageImageLoaded")})},setZoom:function(a){this.zoom(a);this.loadPagesZoomed();this.clearContentControls();if(this.pageContentType=="image"){if(this._pdf2XmlWrapper){var b=this._pdf2XmlWrapper.getPageSize();this.scale(this.pageImageWidth/b.width*a/100)}this._dvselectable.dvselectable("changeSelectedRowsStyle",this.scale());this.reInitSelectable();if(this.useVirtualScrolling){this.getSelectableInstance().recalculateSearchPositions(this.scale());this.highlightSearch()}this.recalculatePageLeft();this.setPage(this.pageInd());this.shouldMinimumWidthBeUsed(this.pageWidth(),true)&&this.loadImagesForVisiblePages();this.options.showHyperlinks&&this._refreshHyperlinkFrames()}else if(this.pageContentType=="html"){this.reInitSelectable();this.setPage(this.pageInd());this.loadImagesForVisiblePages();this.reflowPagesInChrome(true)}},loadPagesZoomed:function(){if(this.useTabsForPages()){this._calculatePageSizeFromDOM();return}var a=Math.round(this.initialWidth*this.zoom()/100),b=Math.round(a*this.heightWidthRatio);if(a!=this.pageWidth()||b!=this.pageHeight()){this.pagesDimension=Math.floor(a)+"x";this.pageWidth(a);this.pageHeight(b);!this.useTabsForPages()&&this.calculatePagePositionsForVirtualMode();if(this.pageContentType=="image"){var c=this.pageCount();!this.shouldMinimumWidthBeUsed(a,true)&&this.retrieveImageUrls(c)}}},performSearch:function(f,h,d,c,j){if(this.pageContentType=="image"){var i=this.getSelectableInstance();if(i!=null){var l=i.performSearch(f,this.scale(),h,d,c,j);a(this).trigger("onSearchPerformed",[l])}}else{this.searchText=f;this.searchForSeparateWords=d;this.treatPhrasesInDoubleQuotesAsExact=c;var e=this.pages(),g;this.loadAllPagesOnSearch&&this.loadImagesForPages(1,e.length);for(var b=0;b<e.length;b++){g=e[b];if(g.visible()){var k={text:f,isCaseSensitive:h,searchForSeparateWords:d,treatPhrasesInDoubleQuotesAsExact:c,pageNumber:b};g.searchText(k)}}}},searchHtmlElement:function(a,s,r,j,z,E,n,p,D){s=s||this.htmlSearchHighlightElement;var o,f,F=0,b=null,e=null,L;if(a.nodeType===3){if(j){o=j.length;var q=a.data.replace(/[\r\n\s]+$/g,""),G="["+this.searchSeparatorsList+"]",x,y,M=/[\-[\]{}()*+?\\^|\s.,:;+"]+$/g,J,l,g,i,m,d,k=-1,K=0,c=0;q=q.replace(M,"");if(q.length==0)return 0;if(E&&!p){for(var h=[],t=0;t<j.length;t++){J=j[t];l=z[t];f=l;i=f.length;e=a.data;if(!n){f=f.toLocaleLowerCase();e=e.toLocaleLowerCase()}c=0;do{g=e.indexOf(f,c);if(g!=-1){h.push({index:g,length:i});c=g+i}}while(g!=-1)}h.sort(function(a,b){return b.index-a.index});var H=[];h=h.filter(function(a,b){return!h.some(function(c,e){var d=e!=b&&(a.index>=c.index&&a.index<c.index+c.length)||a.index+a.length>c.index&&a.index+a.length<c.index+c.length;if(d){if(H.indexOf(a)!=-1)return false;H.push(c)}return d})});var I=0;for(d=0;d<h.length;d++){m="search_highlight"+this.matchesCount.toString();this.matchesCount++;I+=this.highlightOneNode(a,h[d].index,h[d].length,m,r,D)}return I}var B,C,w;do{J=j[this.currentWordCounter];l=z[this.currentWordCounter];B=this.currentWordCounter==0;C=this.currentWordCounter==o-1;if(B&&!p)x="";else x="(?:"+G+"|^)+";if(C&&!p)y="";else y="(?:"+G+"|$)+";f=x+"("+l+y+")";e=a.data;e=e.substr(c,e.length-c);if(this.matchedNodsCount>0&&k==-1||k!=-1)f="^"+f;L=new RegExp(f,n?"":"i");w=false;b=e.match(L);if(b){if(k==-1)this.matchedNodsCount++;F++;this.matchedNods.push(a);g=c+b.index;i=b[0].length;if(B){g=c+e.indexOf(b[1],b.index);i=b[1].length}if(C&&!this.useAccentInsensitiveSearch){var u=j[this.currentWordCounter],A=e;if(!n){u=u.toLowerCase();A=A.toLowerCase()}var O=c+A.indexOf(u,b.index);i=u.length+O-g}this.searchMatches.push({index:g,length:i});k=c+b.index;K=b[0].length;c=k+K;this.currentWordCounter++;if(this.currentWordCounter>=o){m="search_highlight"+this.matchesCount.toString();for(d=o-1;d>=0;d--)this.highlightOneNode(this.matchedNods[d],this.searchMatches[d].index,this.searchMatches[d].length,m,r,D);this.currentWordCounter=0;this.matchedNods=[];this.searchMatches=[];this.matchedNodsCount=0;this.matchesCount++;return F}}else{this.matchedNods=[];this.searchMatches=[];if(this.currentWordCounter>0){k=-1;this.matchedNodsCount=0;w=true}this.currentWordCounter=0}}while(b&&c<q.length||w);if(!b)this.matchedNodsCount=0;return 0}}else if(a.nodeType===1&&a.childNodes&&!/(script|style)/i.test(a.tagName)&&!(a.tagName===s.toUpperCase()&&a.className===r))for(var N=0,v=N;v<a.childNodes.length;v++)v+=this.searchHtmlElement(a.childNodes[v],s,r,j,z,E,n,p,D);return 0},highlightOneNode:function(f,j,i,g,l,m){var o=false,k=a(f),b,d;if(k.is("tspan")||k.parent().is("tspan")){o=true;d=this.htmlSearchHighlightSvgElement;var p="http://www.w3.org/2000/svg";b=document.createElementNS(p,d);b.setAttribute("class",l||this.htmlSearchHighlightClassName)}else{d=this.htmlSearchHighlightElement;b=document.createElement(d);b.className=l||this.htmlSearchHighlightClassName}var h=a(b);g&&h.attr("name",g);h.attr("data-page-num",m.toString());var e=0,c;if(j==0)c=f;else{c=f.splitText(j);e++}if(c.textContent.length>i){e++;c.splitText(i)}var n=c.cloneNode(true);b.appendChild(n);c.parentNode.replaceChild(b,c);return e},removeSearchHighlight:function(d){var b=this.htmlSearchHighlightElement+"."+this.htmlSearchHighlightClassName,c=this.htmlSearchHighlightSvgElement+"."+this.htmlSearchHighlightClassName;a(d).find(b+","+c).each(function(){var a=this.parentNode;a.replaceChild(this.firstChild,this);a.normalize()})},getWords:function(f){var d="[^"+this.searchSeparatorsList+"]+",e=new RegExp(d,"g"),c=f.match(e),b;if(c==null)b=null;else b=a.map(c,function(a){if(a!="")return a});return b},selectTextInRect:function(g,d,e,b,f,c){return this._dvselectable?a(this._dvselectable).dvselectable("highlightPredefinedArea",g,d,e,b,f,c):null},deselectTextInRect:function(e,c,d,b){this._dvselectable&&a(this._dvselectable).dvselectable("unhighlightPredefinedArea",e,c,d,b)},recalculatePageLeft:function(){if(this._firstPage!=null&&this.pagesContainerElement!=null){var a=this._firstPage.offset().left-this.pagesContainerElement.offset().left;this.pageLeft(a)}},reInitSelectable:function(){var a=this.getVisiblePagesNumbers();this._dvselectable!=null&&this._dvselectable.dvselectable("reInitPages",this.scale(),a,this.scrollPosition,this.getPageHeight(),this.pages())},reInitCanvasOffset:function(){var a=this.getSelectableInstance();a.initCanvasOffset()},openCurrentPage:function(){this.setPage(this.pageInd())},setPageNumerInUrlHash:function(a){if(this.usePageNumberInUrlHash===b||this.usePageNumberInUrlHash==true)if(location.hash!=""||a>1){this.changedUrlHash=true;location.hash=this.hashPagePrefix+a.toString();this.changedUrlHash=false}},isScrollViewerVisible:function(){return this.documentSpace.is(":visible")},getSelectableInstance:function(){if(this._dvselectable==null)return null;var a=this._dvselectable.data("ui-dvselectable");if(!a)a=this._dvselectable.data("dvselectable");return a},shouldMinimumWidthBeUsed:function(d,b){var a=null;if(this.use_pdf!="false"&&b){var c=this._pdf2XmlWrapper.getPageSize();a=c.width}return this.minimumImageWidth!=null&&(d<=this.minimumImageWidth||a!==null&&a<this.minimumImageWidth)},resizeViewerElement:function(a){var c=this.documentSpace.parent(),b=c.width();if(typeof a=="undefined")a=0;else this.viewerLeft=a;this.documentSpace.width(b-a);this.reInitSelectable();this.loadImagesForVisiblePages()},onPageReordered:function(b,a){this._model.reorderPage(this.fileId,b,a,this.instanceIdToken,function(){if(this.pageContentType=="image")for(var d=this.pages(),e,g=Math.min(b,a),f=Math.max(b,a),c=g;c<=f;c++){e=d[c].url();d[c].url(e+"#0");d[c].visible(true)}this._pdf2XmlWrapper&&this._pdf2XmlWrapper.reorderPage(b,a);this.reInitSelectable();this.loadImagesForVisiblePages()}.bind(this),function(a){this._onError(a)}.bind(this))},rotatePage:function(b){var a=this.pageInd()-1;this._model.rotatePage(this.fileId,a,b,this.instanceIdToken,function(b){var c=this.pages()[a];this.applyPageRotationInBrowser(a,c,b.resultAngle);this.reflowPagesInChrome();this.setPage(a+1);this.loadImagesForVisiblePages(true)}.bind(this),function(a){this._onError(a)}.bind(this))},applyPageRotationInBrowser:function(l,a,g){if(!this.supportPageRotation)return;var j=a.rotation();if(j==0&&g==0)return;if(this.pageContentType=="image"&&j!=g){a.visible(false);this.addSuffixToImageUrl(a);a.visible(true)}a.rotation(g);var n=a.rotation()%180,i=this._pdf2XmlWrapper.documentDescription.pages,d,e,b,c,h;if(this.useTabsForPages()){var o=this.documentSpace.find(".html_page_contents:first"),k=o.children("div,table");b=k.width();c=k.height();this.initialWidth=b;if(n>0)h=b;else h=c;this.pageWidth(b*this.zoom()/100);return}else if(i){d=this.getPageSize();e=i[l];e.rotation=g;b=e.w;c=e.h;h=d.height}else return;var f;if(n>0){a.prop(b/c);if(this.pageContentType=="html"){f=this.getScaleRatioForPage(d.width,d.height,c,b);a.heightRatio(f)}}else{a.prop(c/b);if(this.pageContentType=="html"){f=this.getScaleRatioForPage(d.width,d.height,b,c);a.heightRatio(f)}}this.calculatePagePositionsForVirtualMode();this.reInitSelectable();var m=this.getSelectableInstance();m!=null&&m.clearSelectionOnPage(l);this.loadImagesForVisiblePages(true)},_calculatePageSizeFromDOM:function(){var f=this.documentSpace.find(".html_page_contents:first"),e=f.children("div,table,img");if(this.autoHeight()){var h=e.width();this.initialWidth=h}this.pageWidth(this.initialWidth*this.zoom()/100);var a=e[0].getBoundingClientRect(),g=0;this.autoHeight(true);var d=this.pages()[0],c,b;if(typeof a.width=="undefined")c=a.right-a.left;else c=a.width;if(typeof a.height=="undefined")b=a.bottom-a.top;else b=a.height;if(d&&d.rotation&&d.rotation()%180>0){var i=c;c=b;b=i}b+=g;d.prop(b/c);this.autoHeight(false)},reflowPagesInChrome:function(c){if(this.browserIsChrome()&&this.watermarkText&&!this.useVirtualScrolling){var d=this,b=function(){d.pagesContainerElement.children().each(function(){a(this).css("top",0).css("left",0)})};if(c)window.setTimeout(b,10);else b()}},getHtmlElements:function(d,a){var c=new RegExp("<"+a+"[^>]*>(?:.|\\r?\\n)*?<\\/"+a+">","gi"),b=d.match(c);return b},getHtmlElementContents:function(e,b){var d=new RegExp("<"+b+"[^>]*>((?:.|\\r?\\n)*?)<\\/"+b+">","i"),c=e.match(d),a=null;if(c)a=c[1];return a},getHtmlElementAttributess:function(c,d){var b=new RegExp("<"+d+"[^>]*/?>","gi"),a=c.match(b);return a},getPageBodyContents:function(b){return b.match(/<body[^>]*>((?:.|\r?\n)*?)<\/body>/)[1]},getPageBodyContentsWithReplace:function(a){var c="<body",e=a.indexOf(c),b=e+c.length,f=a.indexOf("/body>"),d="<div"+a.substr(b,f-b)+"/div>";return d},isPageVisible:function(a){return this.pages()[a].visible()},getPageLocations:function(){return this.getSelectableInstance().pageLocations},getPageSize:function(){return this._pdf2XmlWrapper.getPageSize()},fixImageReferencesInHtml:function(b){return this.getPageBodyContents(b)},calculatePointToPixelRatio:function(){var c=100,b=a("<div/>").css("width",c+"pt").css("height","0");b.appendTo(this.documentSpace);var d=b.width();this.pointToPixelRatio=d/c;b.remove()},activateTab:function(b){var d=this.tabs()[b],a=this;function c(){var h=a.pages(),c=h[0];c.htmlContent(d.htmlContent());var g=a.documentSpace.find(".html_page_contents:first"),f=g.children("div,table"),e=f.width();a.initialWidth=e;c.prop(f.height()/e);a.pageWidth(e*a.zoom()/100);a.activeTab(b);a.supportPageRotation&&a.applyPageRotationInBrowser(0,c,c.rotation())}if(d.visible())c();else this.getDocumentPageHtml(b,function(){c()})},adjustInitialZoom:function(){var a=false;if(this.zoomToFitHeight){a=true;this.setZoom(this.getFitHeightZoom())}else if(this.pageContentType=="html"&&this.zoomToFitWidth){var c=this.getFitWidth(),b=this.pageWidth();if(!this.onlyShrinkLargePages||b>c){var d=c/b*100;a=true;this.setZoom(d)}}!a&&this.useTabsForPages()&&this._calculatePageSizeFromDOM()},intToColor:function(a){if(a===null)a=4294901760;else a>>>=0;var c=a&255,d=(a&65280)>>>8,e=(a&16711680)>>>16,b=((a&4278190080)>>>24)/255;return"rgba("+[e,d,c,b].join(",")+")"},watermarkTransform:function(v,D){var m=0;if(v.rotation)m=v.rotation();var B=v.prop(),f="Top",s="Bottom",h="Diagonal",u="Left",o="Center",t="Right",b="",g=o;if(this.watermarkPosition.indexOf(f)==0)b=f;else if(this.watermarkPosition.indexOf(s)==0)b=s;else if(this.watermarkPosition.indexOf(h)==0){b=h;g=o}if(b!=h)if(this.watermarkPosition.indexOf(u)!=-1)g=u;else if(this.watermarkPosition.indexOf(o)!=-1)g=o;else if(this.watermarkPosition.indexOf(t)!=-1)g=t;var p="translate",E=10,n=100,c=n*B,z;if(this.watermarkScreenWidth==null){var C=D.getBBox();this.watermarkScreenWidth=C.width}z=this.watermarkScreenWidth;var a;if(this.watermarkWidth==0)a=1;else a=this.watermarkWidth/100;var y=n;if(b==h&&c<n)y=c;var x=y*a,A=y/z;if(m%180!=0&&b!=h){x=c*a;A=c/z}a*=A;var e=n/2,d=c/2,i=0;switch(g){case o:i=(n-x)/2;break;case u:i=0;break;case t:i=n-x}var r;if(b===s)r=c-c*a-8;else if(b===h)r=c-c*a;else r=0;p+="("+i+","+r+")scale("+a+")";if(b==h)p+="translate(0,"+-d/a+") rotate("+(-50+m)+","+(e-i)/a+","+c+") ";if(!v.rotation||b==h)return p;var l=0,k=0,w=0,q,j=0;if(g==o){q=(e-i)/a;if(b==f)j=0;else j=c}else if(g==u){q=e/a;if(m%180!=0)w=(e-d)/a;if(b==f)j=0;else j=c}else if(g==t){q=-(i-e)/a;if(m%180!=0)w=-(e-d)/a;if(b==f)j=0;else j=c}switch(m){case 90:if(b==f){l=d/a;k=-e/a}else{l=-d/a;k=e/a}break;case 180:if(b==f){l=d/a;k=-d/a}else{l=-d/a;k=d/a}break;case 270:if(b==f){l=d/a;k=-e/a}else{l=-d/a;k=e/a}}if(b==f||b==s)p+="translate(0,"+l+") rotate("+m+","+q+","+j+") translate("+w+","+k+")";return p},addSuffixToImageUrl:function(d){var a=d.url(),c="?",b=a.indexOf("dummy=");if(b!=-1)a=a.substring(0,b-1);var e=a.indexOf("?");if(e!=-1)c="&";d.url(a+c+"dummy="+(new Date).getTime())},isRTL:function(d){return false;var b="A-Za-zÀ-ÖØ-öø-ʸ̀-֐ࠀ-῿Ⰰ-﬜﷾-﹯﻽-",c="֑-߿יִ-﷽ﹰ-ﻼ",a=new RegExp("^[^"+b+"]*["+c+"]");return a.test(d)},setLoadingState:function(a){this.inprogress(a)},getScaleRatioForPage:function(c,f,e){var a,d;if(c===b)a=1;else a=c/e;d=a;return d},pageElementStyle:function(b){var a={},c=this.pages();if(this.useVirtualScrolling){var d=this.firstVisiblePageForVirtualMode();b+=d;if(d<c.length)a.top=c[d].top()+"px"}else a.top="";if(this.layout()==this.Layouts.OnePageInRow){a.display="block";a.marginLeft="auto";a.marginRight="auto"}else{a.display="";a.marginLeft="";a.marginRight=""}var e=this.pageWidth();if(this.options.useEmScaling){a.width=this.serverPages[b].w*this.pointToPixelRatio/16+"em";a.height=this.serverPages[b].h*this.pointToPixelRatio/16+"em"}else{a.width=e+(this.useHtmlBasedEngine?this.imageHorizontalMargin:0)+"px";if(this.autoHeight()){a.width="auto";a.height="auto";a.overflow="visible"}else{if(b<c.length)a.height=e*c[b].prop()+"px";a.overflow="hidden"}}return a},setLayout:function(a){this.layout(a);this.calculatePagePositionsForVirtualMode();this.loadImagesForVisiblePages();this.documentSpace.trigger("layoutChanged.groupdocs")},calculatePagePositionsForVirtualMode:function(){if(this.useVirtualScrolling){var j=15,p=2*7,n=this.pages(),o=this.pageWidth(),l=0,e,m,g,h=0,i=0,d=0,a,c=this.layout();switch(c){case this.Layouts.ScrollMode:a=Math.floor(this.pagesContainerElement.width()/this.pageWidth());if(a==0)a=1;break;case this.Layouts.OnePageInRow:a=1;break;case this.Layouts.TwoPagesInRow:case this.Layouts.CoverThenTwoPagesInRow:a=2}for(var f,k,b=0;b<n.length;b++){e=n[b];m=e.prop();g=o*m;e.left=h;e.top(i);f=c!=this.Layouts.CoverThenTwoPagesInRow&&b%a==0||c==this.Layouts.CoverThenTwoPagesInRow&&(b==0||b%a==1);k=c==this.Layouts.OnePageInRow||c==this.Layouts.TwoPagesInRow&&b%a==1||c==this.Layouts.CoverThenTwoPagesInRow&&(b==0||b%a==0)||c==this.Layouts.ScrollMode&&b%a==a-1;if(f||!f&&g>d)d=g;l=i+d+j;if(k){i+=d+j;h=0}else h+=o+p}this.documentHeight(l)}},triggerEvent:function(b,a){this.documentSpace.trigger(b,a)},clearContentControls:function(){if(!this.supportListOfContentControls||!this.contentControlsFromHtml)return;for(var a,b=0;b<this.contentControlsFromHtml.length;b++){a=this.contentControlsFromHtml[b];typeof a!="undefined"&&a.visualWrapper&&a.visualWrapper.remove()}this.contentControlsFromHtml.length=0},markContentControls:function(f){if(!this.supportListOfContentControls||!this.contentControls)return;for(var e,b=0;b<this.contentControlsFromHtml.length;b++){e=this.contentControlsFromHtml[b];if(typeof e!="undefined"&&e.pageNumber==f)return}var h="2D5FABC2",j="start",n="end",m="=",g=this.documentSpace;if(typeof f!="undefined")g=this.documentSpace.find("#"+this.pagePrefix+(f+1).toString());g.find(".content_control_visual_wrapper").remove();var l=g.find("a[name^='"+h+"']"),c=[],i=0,d,k=this;l.each(function(){var e=a(this),b=e.attr("name"),r=new RegExp("("+j+")|("+n+")"),i=b.search(r),p=b.substring(h.length+1,i);d=parseInt(p);if(f>=k.contentControls[d].startPage&&f<=k.contentControls[d].endPage)if(b.indexOf(j)==i){var o=b.indexOf(m,i)+1,q=b.substring(o,b.length),l=b[i+j.length]=="1",g=e;if(typeof c[d]=="undefined"){if(l||g.parent().children(":not([name^='"+h+"'])").length==0)g=g.parent();c[d]={title:q,number:d}}c[d].startElement=g;c[d].moveUpInDom=l}else{if(e.parent().children(":not([name^='"+h+"'])").length==0)e=e.parent();if(typeof c[d]=="undefined")c[d]={endElement:e,number:d};c[d].endElement=e}});for(b=0;b<this.contentControls.length;b++)if(f>=this.contentControls[b].startPage&&f<=this.contentControls[b].endPage)if(!c[b])c[b]={number:b,title:this.contentControls[b].title};for(b=0;b<c.length;b++){e=c[b];if(e){if(!e.startElement)e.startElement=g.children(".html_page_contents").children(".pageWordToHtml").children(":first");if(!e.endElement)e.endElement=g.children(".html_page_contents").children(".pageWordToHtml").children(":last");e.title=this.contentControls[b].title;e.pageNumber=f;i++;(function(a){window.setTimeout(function(){i--;k.createContentControlWrappers(g,c,a,h,i)},2e3)})(b)}}},createContentControlWrappers:function(o,e,s,v,x){var b=e[s],p=b.startElement,r=b.endElement,z=p.offset().top;z-=this.pagesContainerElement.offset().top;var c=a("<div/>").appendTo(o);b.visualWrapper=c;c.addClass("content_control_visual_wrapper");var d=p.nextUntil(r,":not([name^='"+v+"'])").add(r);if(b.moveUpInDom)d=d.add(p);var w=d.find("*");d=d.add(w);var h=null,l=null,i=null,k=null,f,n,g,m,q=this.zoom()/100;d.each(function(){var b=a(this);if(b.width()==0||b.height()==0)return;f=b.offset().left;if(h===null||f<h)h=f;n=b.width()*q;if(l===null||f+n>l)l=f+n;g=b.offset().top;if(i===null||g<i)i=g;m=b.height()*q;if(k===null||g+m>k)k=g+m});var t=o.offset().left,u=o.offset().top;c.css("left",h-t+"px");c.css("width",l-h+"px");c.css("top",i-u+"px");c.css("height",k-i+"px");c.attr("data-title",b.title);if(x==0){e.sort(function(a,b){return a.visualWrapper&&b.visualWrapper?b.visualWrapper.width()*b.visualWrapper.height()-a.visualWrapper.width()*a.visualWrapper.height():0});for(var y=1,j=0;j<e.length;j++){b=e[j];if(typeof b!="undefined"&&b.visualWrapper){b.visualWrapper.css("z-index",j+y);if(this.contentControlToBeOpened!==null&&this.contentControlToBeOpened==b.number){this.visuallySelectContentControl(b);this.contentControlToBeOpened=null}}this.contentControlsFromHtml.push(e[j])}}},getContentControlDescriptions:function(){return this.contentControls},navigateToContentControl:function(a){a=parseInt(a);var d=this.contentControls[a].startPage,e=false;if(this.pages()[d].visible())for(var b,c=0;c<this.contentControlsFromHtml.length;c++){b=this.contentControlsFromHtml[c];if(typeof b!="undefined"&&b.number==a){this.visuallySelectContentControl(b);e=true;break}}if(!e){this.contentControlToBeOpened=a;this.setPage(d+1)}},visuallySelectContentControl:function(b){var d=20;this.documentSpace[0].scrollTop=b.visualWrapper.offset().top-this.pagesContainerElement.offset().top-d;var c="hover",a=this.documentSpace.find(".doc-page .content_control_visual_wrapper");a.removeClass(c);a.unbind("mouseleave");b.visualWrapper.addClass(c);a.bind("mouseleave",function(){b.visualWrapper.removeClass(c);a.unbind("mouseleave")});this.documentSpace.trigger("ScrollDocView",[null,{target:this.documentSpace[0]}]);this.documentSpace.trigger("ScrollDocViewEnd",[null,{target:this.documentSpace[0]}])},initCustomBindings:function(){if(!ko.bindingHandlers.searchText)ko.bindingHandlers.searchText={update:function(e,c,h,g,a){var d=a.$root,b=a.$data;if(!b.searched){var f=ko.utils.unwrapObservable(c());d.parseSearchParameters(e,f)}b.searched=false}};if(!ko.bindingHandlers.parsedHtml)ko.bindingHandlers.parsedHtml={init:function(h,g,e){var d=g(),f=a(h),c=f.html();if(ko.isWriteableObservable(d))d(c);else{var b=e();b._ko_property_writers&&b._ko_property_writers.parsedHtml&&b._ko_property_writers.parsedHtml(c)}},update:function(h,f,i,j,e){var c=ko.unwrap(f())||"",b=e.$data,d=a(h);d.empty();if(c){if(typeof b.currentValue=="undefined"||b.currentValue===null||b.currentValue!=c){var g=c.replace(/^[\r\n\s]+|[\r\n\s]+$/g,"");b.parsedHtmlElement=a(g);b.currentValue=c}d.append(b.parsedHtmlElement)}else{b.parsedHtmlElement=null;b.currentValue=null}}}},parseSearchParameters:function(i,d){var a=this;a.removeSearchHighlight(i);if(d){var c=d.text;if(c){var b,k=d.isCaseSensitive,h=false;if(d.treatPhrasesInDoubleQuotesAsExact){var e=c.replace(/^[\r\n\s]+|[\r\n\s]+$/g,"");if(e.length>=2&&e[0]=='"'&&e[e.length-1]=='"'){c=c.substr(1,e.length-2);c=c.replace(/^[\r\n\s]+|[\r\n\s]+$/g,"");a.currentWordCounter=0;a.matchedNods=[];a.searchMatches=[];a.matchedNodsCount=0;h=true}}var j=/[-[\]{}()*+?.,\\^$|#\s]/g;b=a.getWords(c);if(b==null)return;b=jQuery.map(b,function(a){return a.replace(j,"\\$&")});var g=b,f;if(a.useAccentInsensitiveSearch||a.useRtl){g=[];for(wordNum=0;wordNum<b.length;wordNum++){f=b[wordNum];if(a.useAccentInsensitiveSearch)f=window.jGroupdocs.stringExtensions.getAccentInsensitiveRegexFromString(f);g.push(f)}}a.searchHtmlElement(i,null,null,b,g,d.searchForSeparateWords,k,h,d.pageNumber);return}}},highlightSearch:function(){if(this.pageContentType=="image"&&this.useVirtualScrolling){var a=this.getSelectableInstance();a&&a.highlightSearch(this.firstVisiblePageForVirtualMode(),this.lastVisiblePageForVirtualMode())}},firePageImageLoadedEvent:function(a,b){this.firePageImageEvent(a,b,false)},firePageImageLoadErrorEvent:function(a,b){this.firePageImageEvent(a,b,true)},firePageImageEvent:function(a,f,d){var c=f.target;if(this.useFullSizeImages||d){var e=this.pages(),b=null;if(a<e.length)b=e[a];if(b)if(b.visible()){b.domElement=c;if(d){this.triggerEvent("pageImageLoadError.groupdocs",[a,c]);this._onError({Reason:"The page "+a+" can't be loaded"})}else this.triggerEvent("pageImageLoaded.groupdocs",[a,c])}}},raiseDocumentLoadCompletedEvent:function(){this.documentSpace.trigger("documentLoadCompleted.groupdocs")},_setTextPositionsCalculationFinished:function(a){if(!this._isTextPositionsCalculationFinished){this._isTextPositionsCalculationFinished=a;a&&this.raiseDocumentLoadCompletedEvent()}}})})(jQuery);DocViewerAdapter=function(a){$.extend(this,a);this.init()};$.extend(DocViewerAdapter.prototype,{docViewerWidget:null,docViewerViewModel:null,navigationWidget:null,navigationViewModel:null,thumbnailsWidget:null,thumbnailsViewModel:null,zoomViewModel:null,init:function(){var g=null,f=null,d=null,k=null,i=null,r=null,m=null,a=null,h=null,c=null,e=null,j=null,l=null,p=null,q="onMenuClicked";if(this.thumbnails){d=this.thumbnails.thumbnails(this.thumbnailsOptions||{baseUrl:this.baseUrl,quality:this.quality,use_pdf:this.use_pdf});c=this.thumbnails.thumbnails("getViewModel")}else{d=this.thumbnailsCreator();c=this.thumbnailsViewModelCreator()}var o=0;if(this.thumbnails)o=c.getThumbnailsPanelWidth();if(this.docSpace){var s=$.extend({userId:this.userId,userKey:this.userKey,baseUrl:this.baseUrl,fileId:this.fileId,fileVersion:this.fileVersion,quality:this.quality,use_pdf:this.use_pdf,pageImageWidth:this.pageImageWidth,_mode:this._mode,docViewerId:this.docViewerId,createHtml:this.createHtml,initialZoom:this.initialZoom,alwaysOnePageInRow:this.alwaysOnePageInRow,zoomToFitWidth:this.zoomToFitWidth,zoomToFitHeight:this.zoomToFitHeight,viewerLeft:o,viewerWidth:this.viewerWidth,viewerHeight:this.viewerHeight,preloadPagesCount:this.preloadPagesCount,selectionContent:this.selectionContent,usePageNumberInUrlHash:this.usePageNumberInUrlHash,pageContentType:this.pageContentType,imageHorizontalMargin:this.imageHorizontalMargin,imageVerticalMargin:this.imageVerticalMargin,useJavaScriptDocumentDescription:this.useJavaScriptDocumentDescription,searchPartialWords:this.searchPartialWords,variableHeightPageSupport:this.variableHeightPageSupport,textSelectionSynchronousCalculation:this.textSelectionSynchronousCalculation,minimumImageWidth:this.minimumImageWidth,fileDisplayName:this.fileDisplayName,preventTouchEventsBubbling:this.preventTouchEventsBubbling,watermarkText:this.watermarkText,instanceId:this.instanceId},this.viewerOptions);g=this.docSpace.docViewer(s);a=this.docSpace.docViewer("getViewModel")}else{g=this.docSpaceCreator();a=this.docSpaceViewModel()}var n=null,b=null;if(this.docSpacePageFlip){n=this.docSpacePageFlip.docViewerPageFlip({userId:this.userId,userKey:this.userKey,baseUrl:this.baseUrl,fileId:this.fileId,fileVersion:this.fileVersion,quality:this.quality,use_pdf:this.use_pdf,pageImageWidth:this.pageImageWidth,_mode:this._mode,docViewerId:this.docViewerId,createHtml:this.createHtml,initialZoom:this.initialZoom,alwaysOnePageInRow:this.alwaysOnePageInRow,zoomToFitWidth:this.zoomToFitWidth,zoomToFitHeight:this.zoomToFitHeight,viewerWidth:this.viewerWidth,viewerHeight:this.viewerHeight,selectionContent:this.selectionContent,minimumImageWidth:this.minimumImageWidth});b=this.docSpacePageFlip.docViewerPageFlip("getViewModel")}if(this.navigation){f=this.navigation.navigation(this.navigationOptions);h=this.navigation.navigation("getViewModel")}if(this.search){i=this.search.search($.extend(this.searchOptions,{viewerViewModel:a}));j=this.search.search("getViewModel")}if(this.zooming){k=this.zooming.zooming(this.zoomingOptions||{});e=this.zooming.zooming("getViewModel")}if(this.embedSource){r=this.embedSource.embedSource();l=this.embedSource.embedSource("getViewModel")}if(this.viewTypeMenu){m=this.viewTypeMenu;p=this.viewTypeViewModel}this.docViewerViewModel=a;this.docViewerPageFlipViewModel=b;this.navigationViewModel=h;this.thumbnailsViewModel=c;this.zoomViewModel=e;this.searchViewModel=j;this.embedSourceViewModel=l;g.bind("getPagesCount",function(b,a){f&&h.setPagesCount(a)}.bind(this));g.bind("onDocumentloadingStarted",function(){d&&c.hideThumbnails()}.bind(this));g.bind("documentLoadFailed.groupdocs",function(){d&&c.showThumbnails(true)}.bind(this));g.bind("_onProcessPages",function(i,h,g,a,e,b,f){if(d)c.onProcessPages(h,g,a,e,b,f)}.bind(this));g.bind("onScrollDocView",function(b,a){d&&c.setThumbnailsScroll(a);f&&h.setPageIndex(a.pi);i&&j.scrollPositionChanged(a.position)}.bind(this));g.bind("onDocumentPageSet",function(c,a){if(b)b.onDocumentPageSet(a);i&&j.documentPageSetHandler()});g.bind("onDocumentLoadComplete",function(g,c,d){b&&b._onDocumentLoaded(c,d);var f=c.url;$("#btnDownload,#btnDownload2").bind({click:function(){window.location.href=f;return false}});if(r){l.setGuid(c.guid);l.setFileId(a.getFileId());l.password(a.password())}if(k)if(a.isScrollViewerVisible()){e.setFitWidthZoom(a.getFitWidthZoom());e.setFitHeightZoom(a.getFitHeightZoom());e.setZoomWithoutEvent(a.zoom())}else if(b){e.setFitWidthZoom(b.getFitWidthZoom());e.setFitHeightZoom(b.getFitHeightZoom());e.setZoomWithoutEvent(b.zoom())}i&&j.documentLoaded()}.bind(this));g.bind("layoutChanged.groupdocs",function(){if(k)if(a.isScrollViewerVisible()){e.setFitWidthZoom(a.getFitWidthZoom());e.setFitHeightZoom(a.getFitHeightZoom())}});n&&n.bind("onPageTurned",function(e,b){f&&h.setPageIndex(b);d&&c.pageInd(b);a.pageInd(b);a.setPageNumerInUrlHash(b)});i&&i.bind("onPerformSearch",function(g,f,e,d,b,c){a.performSearch(f,e,d,b,c)});if(f){f.bind("onUpNavigate",function(f,e){b&&b.setPage(e);a.setPage(e);if(d){c.setPageWithoutEvent(e);c.setThumbnailsScroll({pi:e,direction:"up"})}}.bind(this));f.bind("onDownNavigate",function(f,e){b&&b.setPage(e);a.setPage(e);if(d){c.setPageWithoutEvent(e);c.setThumbnailsScroll({pi:e,direction:"down"})}}.bind(this));f.bind("onSetNavigate",function(f,e){b&&b.setPage(e.pageIndex);a.setPage(e.pageIndex);if(d){c.setPageWithoutEvent(e.pageIndex);c.setThumbnailsScroll({pi:e.pageIndex,direction:e.direction,eventAlreadyRaised:true})}}.bind(this))}if(k){k.bind("onSetZoom",function(d,c){b&&b.setZoom(c);a.setZoom(c);i&&j.resetButtons()}.bind(this));k.bind(q,function(){m&&p.showDropDownMenu(false)})}if(d){d.bind("onSetThumbnails",function(d,c){a.setPage(c);b&&b.setPage(c);f&&h.setPageIndex(c)}.bind(this));d.bind("onSetThumbnailsScroll",function(b,a){f&&h.setPageIndex(a)}.bind(this));d.bind("onResizeThumbnails",function(d,c){a.resizeViewerElement(c);b&&b.resizeViewerElement(c)});d.bind("onPageReordered",function(d,c,b){a.onPageReordered(c,b)})}m&&m.bind(q,function(){e&&e.showDropDownMenu(false)})},thumbnailsCreator:function(){},thumbnailsViewModelCreator:function(){return{"set":function(){},setThumbnailsScroll:function(){},onProcessPages:function(){},getThumbnailsPanelWidth:function(){return 0}}}});jSaaspose.Point=function(a,b){this.x=a||0;this.y=b||0};$.extend(jSaaspose.Point.prototype,{x:0,y:0,clone:function(){return new jSaaspose.Point(this.x,this.y)},round:function(){this.x=Math.round(this.x);this.y=Math.round(this.y);return this}});jSaaspose.Rect=function(b,d,c,e,a){this.set(b,d,c,e,a)};$.extend(jSaaspose.Rect.prototype,{topLeft:null,bottomRight:null,clone:function(){return new jSaaspose.Rect(this.topLeft.x,this.topLeft.y,this.bottomRight.x,this.bottomRight.y,false)},"set":function(b,d,c,e,a){if(!this.topLeft)this.topLeft=new jSaaspose.Point;if(!this.bottomRight)this.bottomRight=new jSaaspose.Point;this.topLeft.x=b;this.topLeft.y=d;this.bottomRight.x=c;this.bottomRight.y=e;return a?this.normalize():this},add:function(a){this.topLeft.x+=a.x;this.topLeft.y+=a.y;this.bottomRight.x+=a.x;this.bottomRight.y+=a.y;return this},subtract:function(a){this.topLeft.x-=a.x;this.topLeft.y-=a.y;this.bottomRight.x-=a.x;this.bottomRight.y-=a.y;return this},scale:function(a){this.topLeft.x*=a;this.topLeft.y*=a;this.bottomRight.x*=a;this.bottomRight.y*=a;return this},round:function(){this.topLeft=this.topLeft.round();this.bottomRight=this.bottomRight.round();return this},left:function(){return this.topLeft.x},top:function(){return this.topLeft.y},right:function(){return this.bottomRight.x},bottom:function(){return this.bottomRight.y},width:function(){return this.bottomRight.x-this.topLeft.x},height:function(){return this.bottomRight.y-this.topLeft.y},setLeft:function(a){this.topLeft.x=a},setTop:function(a){this.topLeft.y=a},setRight:function(a){this.bottomRight.x=a},setBottom:function(a){this.bottomRight.y=a},contains:function(a){return this.topLeft.x<=a.x&&a.x<=this.bottomRight.x&&this.topLeft.y<=a.y&&a.y<=this.bottomRight.y},includes:function(a){return this.contains(a.topLeft)&&this.contains(a.bottomRight)},intersects:function(a){return!(this.topLeft.x>a.bottomRight.x||this.bottomRight.x<a.topLeft.x||this.topLeft.y>a.bottomRight.y||this.bottomRight.y<a.topLeft.y)},normalize:function(){if(this.topLeft.x>this.bottomRight.x)this.bottomRight.x=([this.topLeft.x,this.topLeft.x=this.bottomRight.x])[0];if(this.topLeft.y>this.bottomRight.y)this.bottomRight.y=([this.topLeft.y,this.topLeft.y=this.bottomRight.y])[0];return this}});$.ctrl=function(c,b,a){$(document).keydown(function(d){if(!a)a=[];if(d.keyCode==c.charCodeAt(0)&&d.ctrlKey){b.apply(this,a);return true}})};(function(a,b){a.widget("ui.dvselectable",a.ui.mouse,{customArea:[],search:null,lasso:null,pages:[],prevProportions:1,prevCustomTemplateProportions:1,searchProportions:1,selectedRowsCoordinates:[],highlightPaneContainer:null,highlightSearchPaneContainer:null,buttonPaneContainer:null,template:"<div id={0} class='highlight selection-highlight' style='top: {1}px; height: {2}px; width: {3}px; left: {4}px;'></div>",searchTemplate:"<div id={0} class='highlight search-highlight' style='top: {1}px; height: {2}px; width: {3}px; left: {4}px;'></div>",addTemplate:"<div id={0} class='{3}' style='top: {1}px; left: {2}px;' index='{4}'></div>",cAreaPageIndex:0,cAreaFieldIndex:0,annotationContainer:"<div id={0} style='position:relative'>{1}</div>",annotationTemplate:"<div class='highlight annotation-highlight' style='top: {0}px; height: {1}px; width: {2}px; left: {3}px;'></div>",timeouts:[],flag:0,options:{appendTo:"body",txtarea:"",pdf2XmlWrapper:null,startNumbers:null,pagesCount:0,proportion:1,cancel:":input,option,.comment",bookLayout:false,docSpace:"",highlightColor:null},_initialized:false,_textSelectionByCharModeEnabled:false,_canvasOffset:null,_canvasScroll:null,_mouseStartPos:null,_selectionInfo:{position:-1,length:0},_enabled:true,SelectionModes:{SelectText:0,SelectRectangle:1,SelectTextToStrikeout:2,ClickPoint:3,TrackMouseMovement:4,DoNothing:5},_mode:null,_lassoCssElement:null,rightMargin:35,parentElement:null,_viewModel:null,selectionCounter:0,_create:function(){this._initialized=false;this.initCanvasOffset();if(!this.options.initializeStorageOnly){this.dragged=false;if(this.options.preventTouchEventsBubbling){function b(a){a.preventBubble()}this.element.bind({touchstart:b,touchmove:b,touchend:b})}this._mouseInit();this.helper=a("<div class='ui-selectable-helper'></div>");this.createEventHandlers();this.setMode(this.SelectionModes.SelectText);this.pagePrefix=this.options.pagePrefix}},createEventHandlers:function(){var b=this;a.ctrl("C",function(){var c=a(document.activeElement),e=c.attr("id"),d=c.attr("name");if((e!==b.options.txtarea.attr("id")||d!==b.options.txtarea.attr("name"))&&(c.is("input")||c.is("textarea")))return;b.options.txtarea.focus().select()});a(b.element).bind({click:function(a){return b.mouseClickHandler(a)}})},_init:function(){this._initialized=false;if(this.options.pdf2XmlWrapper==null)return;this.initStorage();this.search=[];if(this.options.initStorageOnMouseStart)this._initialized=false},destroy:function(){this._mouseDestroy();return this},initStorage:function(){if(this._initialized)return;this._initialized=true;var c;if(this.options.useVirtualScrolling)this.pageLocations=a.map(this.options.pageLocations,function(a){return new jSaaspose.Point(a.left,a.top())});else this.pageLocations=this._getPageLocations();c=this.pageLocations;if(this.options.pdf2XmlWrapper!=null)if(this.options.bookLayout)this.pages=this.options.pdf2XmlWrapper.getPages(this.options.proportion,c,this.options.startNumbers.start-1,this.options.startNumbers.end-1,this.options.useVirtualScrolling,!this.options.bookLayout);else this.pages=this.options.pdf2XmlWrapper.getPages(this.options.proportion,c,0,this.options.pagesCount-1,b,true)},initCanvasOffset:function(){this.parentElement=this.options.docSpace.parent();var b=this.element.parent().offset(),c=b.left,a=b.top;if(this.options.bookLayout)a=this.parentElement.offset().top;this._canvasOffset=new jSaaspose.Point(c,a)},getPages:function(){this.initStorage();return this.pages},_getPageLocations:function(){var b=this,d=this.options.docSpace.attr("id"),e=".page-image",c=this.element.find(e);if(this.options.bookLayout)c=c.filter("[id='"+d+"-img-"+this.options.startNumbers.start.toString()+"'],[id='"+d+"-img-"+this.options.startNumbers.end.toString()+"']");this._canvasScroll=this.getCanvasScroll();return a.map(c,function(d){var c=a(d),e=c.offset().left-b._canvasOffset.x+b._canvasScroll.x,f=b.options.bookLayout?0:c.offset().top-b.element.offset().top;return new jSaaspose.Point(e,f)})},getCanvasScroll:function(){return this.options.bookLayout?new jSaaspose.Point(this.parentElement.scrollLeft(),this.parentElement.scrollTop()):new jSaaspose.Point(this.element.parent().scrollLeft(),this.element.parent().scrollTop())},clearSelection:function(){this.element.find(".selection-highlight:not(.static)").remove()},clearSelectionOnPage:function(a){this.element.find("#"+this.pagePrefix+(a+1)+" > .highlight-pane > .selection-highlight:not(.static)").remove()},_mouseCapture:function(a){var b=null;this._canvasScroll=this.getCanvasScroll();this._mouseStartPos=new jSaaspose.Point(a.pageX-this._canvasOffset.x+this._canvasScroll.x,a.pageY-this._canvasOffset.y+this._canvasScroll.y);return this._mode!=this.SelectionModes.DoNothing&&this._findPageAt(this._mouseStartPos)!=null},_mouseStart:function(){this.options.docSpace.focus();this.initStorage();this.clearSelection();if(this._mode==this.SelectionModes.DoNothing)return false;this.selectionCounter++;this._canvasScroll=this.getCanvasScroll();if(this.options.bookLayout)this._canvasScroll.y+=this.parentElement.parent().scrollTop();if(this.checkMouseIsInEdgeInBookMode(this._mouseStartPos.x,this._mouseStartPos.y))return false;if(this._mode==this.SelectionModes.TrackMouseMovement){var a=this._mouseStartPos.y,c=this.findPageAtVerticalPosition(a),b=parseInt(c.pageId)-1;this.element.trigger("onMouseMoveStarted",[b,{left:this._mouseStartPos.x,top:a}])}else{this.element.append(this.helper);this.helper.css({left:this._mouseStartPos.x,top:this._mouseStartPos.y,width:0,height:0})}this.options.txtarea.val("");this.lasso=new jSaaspose.Rect},_mouseDrag:function(h){if(this._mode==this.SelectionModes.DoNothing||this.checkMouseIsInEdgeInBookMode(this._mouseStartPos.x,this._mouseStartPos.y))return false;var a=this._mouseStartPos.x,c=this._mouseStartPos.y,d=h.pageX-this._canvasOffset.x+this._canvasScroll.x,e=h.pageY-this._canvasOffset.y+this._canvasScroll.y,f=d,g=e;if(this._findPageAt(new jSaaspose.Point(f,g))!=this._findPageAt(new jSaaspose.Point(a,c)))return false;if(!this._findPageAt(new jSaaspose.Point(f,g)))return false;this.dragged=true;if(a>d){var i=d;d=a;a=i}if(c>e){var i=e;e=c;c=i}this.lasso.set(a,c,d,e);this._mode!=this.SelectionModes.ClickPoint&&this._mode!=this.SelectionModes.TrackMouseMovement&&this.helper.css({left:a,top:c,width:this.lasso.width(),height:this.lasso.height()});this.findSelectedPages(false,null,b,this.options.highlightColor);this.element.trigger("onMouseDrag",[{left:f,top:g}]);return false},_mouseStop:function(u){if(this._mode==this.SelectionModes.DoNothing)return false;this.helper.remove();var r=this._findPageAt(this.lasso.topLeft)||this.pages[0];if(typeof r==="undefined")return false;var k,e=parseInt(r.pageId)-1,h=null;if(e<0)return false;if(this._mode==this.SelectionModes.SelectText||this._mode==this.SelectionModes.SelectTextToStrikeout){if(!this.dragged)return false;var w=this;this.dragged=false;var b=w._getDocumentHighlightRects();if(!b||b.length==0)return false;var o="",c=this.options.storeAnnotationCoordinatesRelativeToPages?this.convertRectToRelativeToPageUnscaledCoordinates(this.lasso):this.convertRectToAbsoluteCoordinates(this.lasso),g=c.top(),f=c.bottom();c=b[0].originalRect;var n=c.left(),m=c.right(),j=c.top(),i=c.bottom(),p=b[0].position,s=b[b.length-1].position+b[b.length-1].length-p;h=[];for(var d=0;d<b.length;d++){o+=b[d].text;o+=d>0&&(b[d-1].page!=b[d].page||b[d-1].row!=b[d].row)?"\r\n":" ";c=b[d].originalRect;h.push(c);n=Math.min(n,c.left());m=Math.max(m,c.right());j=Math.min(j,c.top());i=Math.max(i,c.bottom())}var v=this.options.proportion;if(this.options.storeAnnotationCoordinatesRelativeToPages){g=Math.min(j,g);f=Math.max(i,f)}else{k=e*this.options.pageHeight;k/=v;g=Math.max(k+j,g);f=Math.min(k+i,f)}var t=new jSaaspose.Rect(n,g,m,f),q=t.clone();this.options.txtarea.val(a.trim(o))}switch(this._mode){case this.SelectionModes.SelectText:this.element.trigger("onTextSelected",[e,q,p,s,this.selectionCounter,h]);break;case this.SelectionModes.SelectTextToStrikeout:this.element.trigger("onTextToStrikeoutSelected",[e,q,p,s,this.selectionCounter,h]);break;case this.SelectionModes.SelectRectangle:var l;if(this.options.storeAnnotationCoordinatesRelativeToPages)l=this.convertRectToRelativeToPageUnscaledCoordinates(this.lasso,this._mouseStartPos);else l=this.convertRectToAbsoluteCoordinates(this.lasso,this._mouseStartPos);this.element.trigger("onRectangleSelected",[e,l]);break;case this.SelectionModes.ClickPoint:this.mouseClickHandler(u);break;case this.SelectionModes.TrackMouseMovement:a(this.element).trigger("onMouseMoveStopped",[])}return false},mouseClickHandler:function(c){if(c.toElement==b)c.toElement=c.target;c.target.className!="doc_text_area_text mousetrap"&&this.options.docSpace.focus();if(this._mode==this.SelectionModes.SelectText){var e=false;c&&c.originalEvent&&c.originalEvent.path&&a.each(c.originalEvent.path,function(b,a){if(a.className=="widget-tooltip")e=true});if(e){this.destroy();this._enabled=false}else if(this._enabled==false){this.destroy();a(this.element).unbind();this._enabled=true;this._create()}}if(this._mode==this.SelectionModes.ClickPoint){this.initStorage();this._canvasScroll=this.getCanvasScroll();var f=c.pageX-this._canvasOffset.x+this._canvasScroll.x,g=c.pageY-this._canvasOffset.y+this._canvasScroll.y,d=new jSaaspose.Rect(f,g,f,g),h=this._findPageAt(d.topLeft);if(!h)return true;var i=parseInt(h.pageId)-1;if(this.options.storeAnnotationCoordinatesRelativeToPages)d=this.convertRectToRelativeToPageUnscaledCoordinates(d);else d=this.convertRectToAbsoluteCoordinates(d);this.element.trigger("onPointClicked",[i,d]);return false}return true},checkMouseIsInEdgeInBookMode:function(c,d){var f=this.element.width(),e=this.element.height(),b=100,a=100;return this.options.bookLayout&&(c>f-b&&d<a||c>f-b&&d>e-a||c<b&&d<a||c<b&&d>e-a)?true:false},convertRectToAbsoluteCoordinates:function(g,d){this.initStorage();var a=g.clone(),e=this.options.proportion,b=null;if(d)b=this._findPageNearby(d);else b=this._findPageNearby(a.topLeft);a.subtract(b.rect.topLeft);var f=parseInt(b.pageId)-1,c=f*this.options.pageHeight;c/=e;a.scale(1/e);a.add(new jSaaspose.Point(0,c));return a},convertRectToScreenCoordinates:function(d){this.initStorage();var a=d.clone().scale(this.options.proportion);a.top()<0&&a.setTop(0);var b=this.options.pageHeight,c=Math.floor(a.top()/b);a.subtract(new jSaaspose.Point(0,c*b));this.pages.length!=0&&a.add(this.pages[c].rect.topLeft);return a},convertRectToRelativeToPageUnscaledCoordinates:function(e,c){this.initStorage();var a=e.clone(),d=this.options.proportion,b=null;if(c)b=this._findPageNearby(c);else b=this._findPageNearby(a.topLeft);a.subtract(b.rect.topLeft);a.scale(1/d);return a},convertPageAndRectToScreenCoordinates:function(b,c){this.initStorage();var a=c.clone().scale(this.options.proportion);a.top()<0&&a.setTop(0);this.pages.length!=0&&a.add(this.pages[b].rect.topLeft);return a},highlightPredefinedArea:function(c,e,g,a,h,d){this.initStorage();this.dragged=true;if(this.options.storeAnnotationCoordinatesRelativeToPages)this.lasso=this.convertPageAndRectToScreenCoordinates(g,c);else this.lasso=this.convertRectToScreenCoordinates(c);this.selectionCounter++;var b=this._findPageAt(this.lasso.topLeft)||this.pages[0],f=this.options.startNumbers;this.options.startNumbers={start:parseInt(b.pageId),end:parseInt(b.pageId)};this.findSelectedPages(true,e,a,h||this.options.highlightColor,d);this.options.startNumbers=f;this.dragged=false;return typeof a=="undefined"?this.selectionCounter:a},unhighlightPredefinedArea:function(f,g,h,d){if(this.options.storeAnnotationCoordinatesRelativeToPages)this.lasso=this.convertPageAndRectToScreenCoordinates(h,f);else this.lasso=this.convertRectToScreenCoordinates(f);var b=this._getDocumentHighlightRects();if(!b||b.length==0)return;if(typeof d=="undefined")d="";for(var c=0;c<b.length;c++){var i=b[c].page+1,j=b[c].row+1,e="#"+this.pagePrefix+i+"-highlight-"+j+"-"+d;if(g)e+=".static";else e+=":not(.static)";a(e).remove()}},setVisiblePagesNumbers:function(a){this.options.startNumbers=a},handleDoubleClick:function(a){this.lasso=new jSaaspose.Rect(a.pageX,a.pageY,a.pageX,a.pageY);this.initStorage();this.findSelectedPages()},initHighlightSearchPaneContainer:function(){for(var a=this._getElementsByClassName("search-pane",document.getElementById(this.options.docSpace.attr("id")+"-pages-container")),c=a.length,b=c;b--;)if(a[b].children.length!=0)a[b].innerHTML="";this.highlightSearchPaneContainer=a},initButtonPaneContainer:function(){for(var a=this._getElementsByClassName("button-pane",document.getElementById(this.options.docSpace.attr("id")+"-pages-container")),c=a.length,b=c;b--;)if(a[b].children.length!=0)a[b].innerHTML="";this.buttonPaneContainer=a},reInitPages:function(b,a,d,c){this._initialized=false;this.options.startNumbers=a;this.options.proportion=b;this.options.pageHeight=c;this.initCanvasOffset();this.initStorage()},changeSelectedRowsStyle:function(b){this.changeCustomAreasStyle(b);this.changeSearchStyle(b);var d=this.element.find(".highlight-pane .highlight"),c=b/this.options.proportion;this.options.proportion=b;a.each(d,function(){var b=a(this).position();a(this).css({top:b.top*c,left:b.left*c,width:a(this).width()*c,height:a(this).height()*c})})},performSearch:function(jb,xb,I,C,eb,E){var f,gb=false;if(I)f=jb;else f=jb.toLowerCase();if(C&&eb){var z=f.replace(/^[\r\n\s]+|[\r\n\s]+$/g,"");if(z.length>=2&&z[0]=='"'&&z[z.length-1]=='"'){C=false;f=z.substr(1,z.length-2);f=f.replace(/^[\r\n\s]+|[\r\n\s]+$/g,"");gb=true}}this.search.length=0;this.initHighlightSearchPaneContainer();if(f=="")return-1;this.searchProportions=xb;var O=this.pages,yb=O.length,o=[],G=[],l=[],u,Ab,sb,tb,e,ob=0,B,R,k,p;if(E)R=new RegExp(window.jGroupdocs.stringExtensions.getAccentInsensitiveRegexFromString(f));var b;if(C){l=this.getWords(f);if(E){for(var hb=[],cb=0;cb<words.length;cb++)hb.push(new RegExp(window.jGroupdocs.stringExtensions.getAccentInsensitiveRegexFromString(l[cb])));l=hb}u=l.length}var X;if(this.options.searchPartialWords)X=this.options.proportion*this.options.pdf2XmlWrapper.getPageSize().width;for(var q=0;q<yb;q++){var db=O[q].rows,M=db.length,zb=q+1,c,D,W=[],y="",S=0,w=null;if(!C&&this.options.searchPartialWords)for(var N=0;N<M;N++){k=db[N];W.push(y.length);if(I)p=k.text;else p=k.text.toLowerCase();y+=a.trim(p);if(N<M-1)y+=" "}for(var r=0;r<M;r++){var d=0,i=0;k=db[r];if(I)p=k.text;else p=k.text.toLowerCase();if(C){if(u==0)break;c=k.words;D=c.length;for(var J,v=0;v<D;v++)for(J=0;J<u;J++){var L=a.trim(l[J]),bb=c[v].text;if(!I){L=L.toLowerCase();bb=bb.toLowerCase()}B=bb.indexOf(L);if(B!=-1){for(var g=this.options.pdf2XmlWrapper.getRowCharacterCoordinates(q,r),n=c[v].originalRect.left(),F=0,m=0;m<g.length;m++){var V=g[m];if(Math.round(V)>=Math.round(n)){F=m;break}}var x=F+B;if(x<g.length)d=g[x];else d=n;if(d<n||d>ab)d=n;s=x+L.length;if(s>=g.length)i=k.originalRect.right();else i=g[s];b=c[v].rect.clone();b.subtract(c[v].pageLocation);var P=X/O[q].originalWidth,rb=d*P,qb=i*P;b.setLeft(rb);b.setRight(qb);o.push(b);b=c[v].originalRect.clone();b.setLeft(d);b.setRight(i);G.push(b)}}}else{if(this.options.searchPartialWords){var H=W[r],U;if(r<M-1)U=W[r+1];else U=y.length}var h,j;if(E){j=w?w:R;h=y.search(j,H)}else{j=w?w:f;h=y.indexOf(j,H)}if(h<H||h>=U)h=-1;else h-=H;while(h!=-1){c=k.words;if(this.options.searchPartialWords){var nb=/\s/g,Y=p.substring(0,h),Q=p.length-h,A=j.substr(0,Q);S=j.length-Q;if(S>0)w=j.substr(Q+1);else w=null;var pb=Y.match(nb),mb=A.match(nb),t=0,kb=0;if(pb)t=pb.length;if(mb)kb=mb.length;var K=t+kb,g=this.options.pdf2XmlWrapper.getRowCharacterCoordinates(q,r),n=c[t].originalRect.left(),wb=c[K].originalRect.left(),ab=c[K].originalRect.right(),ub=k.originalRect.right();B=Y.length-Y.lastIndexOf(" ")-1;for(var F=0,ib=0,fb=false,m=0;m<g.length;m++){var V=g[m];if(!fb&&Math.round(V)>=Math.round(n)){F=m;fb=true}if(Math.round(V)>=Math.round(wb)){ib=m;break}}var x=F+B;if(x<g.length)d=g[x];else d=n;if(d<n||d>ab)d=n;var vb=A.lastIndexOf(" "),T=A.substring(vb+1,A.length),s;if(t==K)s=x+A.length;else s=ib+T.length;var lb=true;if(s<g.length){var Z=c[K].text.toLowerCase();if(Z.substring(Z.length-T.length,Z.length)==T)i=ab;else{i=g[s];lb=false}}else i=ub;if(i<d)i=ub;if(!eb||!gb||lb){b=c[t].rect.clone();b.subtract(c[t].pageLocation);var P=X/O[q].originalWidth,rb=d*P,qb=i*P;b.setLeft(rb);b.setRight(qb);o.push(b);b=c[t].originalRect.clone();b.setLeft(d);b.setRight(i);G.push(b)}if(S<=0)if(E)j=R;else j=f;h=p.indexOf(j,h+f.length)}else{l=this.getWords(f);u=l.length;if(u==0)break;D=c.length;if(u==1){for(e=0;e<D;e++)if(c[e].text.toLowerCase()==a.trim(l[0].toLowerCase())){b=c[e].rect.clone();b.subtract(c[e].pageLocation);o.push(b)}}else{sb=0;tb=u-1;for(e=0;e<D;e++)if(c[e].text.toLowerCase()==a.trim(l[sb].toLowerCase())){b=c[e].rect.clone();b.subtract(c[e].pageLocation);b.setRight(b.left()+c[e+tb].rect.right()-c[e].rect.left());o.push(b)}}h=-1}}}}if(o.length>0){this.search.push({PageId:zb,pageWords:o.slice(0),pageWordsUnscaled:G.slice(0)});ob+=o.length;o.length=0;G.length=0}}this.highlightSearch(null,null);return ob},getWords:function(b){return a.map(b.split(" "),function(a){if(a!="")return a})},highlightSearch:function(g,h){if(!this.search)return;var f=this.search;this.initHighlightSearchPaneContainer();for(var e=0;e<f.length;e++){var d=f[e].PageId;if(g===null||h===null||d-1>=g&&d-1<=h)for(var c=f[e].pageWords,b=0;b<c.length;b++){var i=window.jGroupdocs.stringExtensions.format(this.searchTemplate,this.pagePrefix+d+"-search-highlight-"+b,c[b].top(),c[b].height(),c[b].width(),c[b].left());a("#"+this.pagePrefix+d+" div.search-pane").append(i)}}},changeSearchStyle:function(d){if(this.options.useVirtualScrolling||this.search.length==0)return;this.initHighlightSearchPaneContainer();for(var f=this.search,i=0,m=f.length,c=this.searchProportions,l=this.highlightSearchPaneContainer,e=0;e<m;e++){for(var h="",g=f[e].PageId,b=f[e].pageWords,k=b.length,a=0;a<k;a++){var q=Math.round(Math.round(b[a].width()/c)*d),n=Math.round(Math.round(b[a].height()/c)*d),p=Math.round(Math.round(b[a].top()/c)*d),o=Math.round((b[a].left()-i)/c*d+i),j=window.jGroupdocs.stringExtensions.format(this.searchTemplate,this.pagePrefix+g+"-search-highlight-"+a,p,n,q,o);h+=j}l[g-1].innerHTML=h}},recalculateSearchPositions:function(c){if(!this.options.useVirtualScrolling||this.search.length==0)return;this.initHighlightSearchPaneContainer();for(var h=this.search,l=h.length,d=0;d<l;d++)for(var g=h[d],b=g.pageWordsUnscaled,k=b.length,j,i,f,e,a=0;a<k;a++){e=Math.round(b[a].left()*c);j=Math.round(b[a].width()*c);f=Math.round(b[a].top()*c);i=Math.round(b[a].height()*c);g.pageWords[a].set(e,f,e+j,f+i)}},clearAllTimeOuts:function(){var a=this.timeouts,b=a.length;if(b>0){for(var c=b;c--;)clearTimeout(a[c]);a=[]}},_getElementsByClassName:function(e,b){if(!b)b=document.getElementsByTagName("body")[0];for(var d=[],f=new RegExp("\\b"+e+"\\b"),c=b.getElementsByTagName("*"),a=0,g=c.length;a<g;a++)f.test(c[a].className)&&d.push(c[a]);return d},highlightTemplateAreas:function(c,b){this.customArea=a.extend(true,[],c);this.changeCustomAreasStyle(b)},changeCustomAreasStyle:function(d){if(typeof this.customArea==="undefined")return;if(this.customArea.length==0)return;var f=this,e=this.customArea,g=31,h=e.length;a("#"+this.options.docSpace.attr("id")+"-pages-container .custom-pane").html("");var b=0,c="";(function i(){for(var k=e[b].fields,s=k.length,l=e[b].PageId,j=0;j<s;j++){var o=Math.round(Math.round(k[j].Width)*d),t=Math.round(Math.round(k[j].Height)*d),n=Math.round(Math.round(k[j].Y)*d),m=Math.round((k[j].X-g)*d+g),q=f.cAreaPageIndex==b&&f.cAreaFieldIndex==j?"border-color:blue":"";c+="<div id="+this.pagePrefix+b+"-custom-highlight-"+j+" index="+b+"/"+j+" class='input-overlay1' style='position:absolute; cursor:pointer; padding: 0px; top: "+n+"px; height: "+t+"px; width: "+o+"px; left: "+m+"px;"+q+"'></div>";var p=window.jGroupdocs.stringExtensions.format(f.addTemplate,this.pagePrefix+b+"-custom-check-"+j,n-5,m+o-8,k[j].iconType==1?"selection-check":"selection-del",b+"/"+j);c+=p}++b;var r=b<h?e[b].PageId:-1;if(c!=""&&r!=l){a("#"+this.pagePrefix+l+" .custom-pane").html(c);f.bindCustomHandler(l);c=""}b<h&&setTimeout(i,0)})()},bindCustomHandler:function(b){var c=this;a("#"+this.pagePrefix+b+" div.input-overlay1, #"+this.pagePrefix+b+" div.selection-check, #"+this.pagePrefix+b+" div.selection-del").bind({click:function(){var f=a(this).attr("index"),g=a("#doc-space").docAssemblyViewer("getViewModel");if(typeof f!=="undefined"){var d=f.split("/"),e=d[0],b=d[1];c.cAreaPageIndex=e;c.cAreaFieldIndex=b;g.moveTo({groupIndex:parseInt(e),fieldIndex:parseInt(b)});return false}}});a("#"+this.pagePrefix+b+" div.input-overlay1").bind({mouseover:function(g){var c=a(this).attr("index"),d=a("#doc-space").docAssemblyViewer("getViewModel");if(typeof c!=="undefined"){var b=c.split("/"),f=b[0],e=b[1];d.mouseover(g,{groupIndex:parseInt(f),fieldIndex:parseInt(e)})}},mouseout:function(g){var c=a(this).attr("index"),d=a("#doc-space").docAssemblyViewer("getViewModel");if(typeof c!=="undefined"){var b=c.split("/"),f=b[0],e=b[1];d.mouseout(g,{groupIndex:parseInt(f),fieldIndex:parseInt(e)})}}})},setCustomAreaIndex:function(a){var c=a.pageIndex,b=a.fieldIndex;this.cAreaPageIndex=c;this.cAreaFieldIndex=b},changeTemplateAreaIcon:function(b){var d=this.customArea,f=d[b.pageIndex].fields,c=this.pagePrefix+"{0}-custom-check-{1}",e=window.jGroupdocs.stringExtensions.format(c,b.pageIndex,b.fieldIndex);a("#"+e).attr("class",b.iconType==1?"selection-check":"selection-del");f[b.fieldIndex].iconType=b.iconType},findSelectedPages:function(r,m,f,o,j){if(this._mode!=this.SelectionModes.SelectText&&this._mode!=this.SelectionModes.SelectTextToStrikeout)return;if(typeof f=="undefined")f=this.selectionCounter;var c=this._getDocumentHighlightRects(f);if(!c||c.length==0)return;for(var g=null,l=null,s="<div id='{0}' class='highlight selection-highlight' style='top: {1}px; height: {2}px;'></div>",e=0;e<c.length;e++){var d=c[e].bounds,h=c[e].page+1,t=c[e].row+1;if(g==null||l!=null&&l!=h){g=this.element.find("#"+this.pagePrefix+h+" div.highlight-pane");l=h}var n=this.pagePrefix+h+"-highlight-"+t+"-"+f,b=g.find("#"+n);if(b.length==0){var p=a(window.jGroupdocs.stringExtensions.format(s,n,d.top()+2,d.height()));g.append(p);b=p}if(m){var i=a._data(b.get(0),"events");(!i||!i.click)&&b.click(m)}if(j){var i=a._data(b.get(0),"events");(!i||!i.mouseover)&&b.hover(j.mouseenter,j.mouseleave)}if(r){b.addClass("static");o&&b.css("background-color",o)}b.css({left:d.left()-1,width:d.width(),height:d.height()});if(!this.options.bookLayout){var u=this.pages[c[e].page],k=u.rotation;if(typeof k=="undefined")k=0;var q=k%180>0;q&&b.css({top:d.top()})}}},_getDocumentHighlightRects:function(f){var b=this.pages;if(b.length==0)return null;for(var e=this,g=e.lasso,c=[],a=0;a<b.length;a++)if(b[a]&&g.intersects(b[a].rect)){var d=e._getPageHighlightRects(a,f);if(d&&d.length)c=c.concat(d)}return c},_getPageHighlightRects:function(g,i){for(var e=this.lasso,d=this.pages[g].rows,h=[],b=0;b<d.length;b++){if(!e.intersects(d[b].rect)){this.dragged&&a("#"+this.pagePrefix+(g+(this.options.bookLayout?this.options.startNumbers.start:1))+"-highlight-"+(b+1)+"-"+i+":not(.static)").remove();continue}var c=d[b].rect;if(e.left()<c.left()&&e.bottom()>c.bottom()||e.right()>c.right()&&e.top()<c.top()||e.bottom()>c.bottom()&&e.top()<c.top()){var k=new jSaaspose.Rect(c.left(),c.top()+1,c.right(),c.bottom()-1);k.subtract(d[b].pageLocation);var f={bounds:k,originalRect:d[b].originalRect,text:"",page:g+(this.options.bookLayout?this.options.startNumbers.start-1:0),row:b,position:-1,length:0};h.push(f);if(!this.dragged){var j=d[b].words[d[b].words.length-1];f.text=d[b].text;f.position=d[b].words[0].position;f.length=j.position+j.text.length-f.position}}else{var f=this._getRowHighlightRect(g,b);if(f!=null)h.push(f);else this.dragged&&a("#"+this.pagePrefix+(g+(this.options.bookLayout?this.options.startNumbers.start:1))+"-highlight-"+(b+1)+"-"+i+":not(.static)").remove()}}return h},_getRowHighlightRect:function(w,x){var e=this.lasso,p=Math.min(e.top(),e.bottom()),l=Math.max(e.top(),e.bottom()),u=this.pages[w],k=u.rotation;if(typeof k=="undefined")k=0;for(var A=k%180>0,f=u.rows[x],r=f.rect.top(),o=f.rect.bottom(),c=this._textSelectionByCharModeEnabled&&f.chars?f.chars:f.words,B=r<p&&p<o&&l>=o&&!A,g=p<=r&&r<l&&l<o,n=g?-1:1,b=g?c.length-1:0;b<c.length&&b>=0&&!e.intersects(c[b].rect);b+=n)c[b].shown=false;if(b==c.length||b<0)return null;for(var a=c[b],s=0,q=0,t=a.rect.left(),v=a.rect.top(),j=a.originalRect.left(),m=a.originalRect.top(),i=0,h=0,d={bounds:null,text:"",page:w+(this.options.bookLayout?this.options.startNumbers.start-1:0),row:x,position:a.position,length:a.text.length};b<c.length&&b>=0&&(g||B||e.intersects(c[b].rect));b+=n){a=c[b];a.shown=true;if(!this.dragged)if(!this._textSelectionByCharModeEnabled)if(g)d.text=a.text+" "+d.text;else d.text+=a.text+" ";else if(this._textSelectionByCharModeEnabled){d.text+=a.text;if(a.isLastWordChar)d.text+=" "}t=Math.min(t,a.rect.left());v=Math.min(v,a.rect.top());s=Math.max(s,a.rect.right());q=Math.max(q,a.rect.bottom());j=Math.min(j,a.originalRect.left());m=Math.min(m,a.originalRect.top());i=Math.max(i,a.originalRect.right());h=Math.max(h,a.originalRect.bottom())}for(;b<c.length&&b>=0;b+=n)c[b].shown=false;var y=new jSaaspose.Rect(t,v+1,s,q-1);y.subtract(u.rect.topLeft);d.bounds=y;var z=new jSaaspose.Rect(j,m+1,i,h-1);d.originalRect=z;d.length=a.position+a.text.length;return d},_findPageAt:function(b){if(this.pages!=null)for(var a=0;a<this.pages.length;a++)if(this.pages[a].rect.contains(b))return this.pages[a];return null},_findPageNearby:function(b){for(var d=0,e=0,c=null,h=false,f=false,a=0;a<this.pages.length;a++)if(this.pages[a].rect.contains(b))return this.pages[a];else if(b.y>=this.pages[a].rect.top()&&b.y<=this.pages[a].rect.bottom()){var g=Math.abs(b.x-this.pages[a].rect.left());if(!h||g<d){d=g;h=true;c=a}}else if(b.x>=this.pages[a].rect.left()&&b.x<=this.pages[a].rect.right()){var i=Math.abs(b.y-this.pages[a].rect.top());if(!f||i<e){e=i;f=true;c=a}}return this.pages[c]},findPageAtVerticalPosition:function(b){for(var a=0;a<this.pages.length;a++)if(b>=this.pages[a].rect.top()&&b<=this.pages[a].rect.bottom()||b>=this.pages[a].rect.bottom()&&a+1>=this.pages.length||b>=this.pages[a].rect.bottom()&&b<=this.pages[a+1].rect.top())return this.pages[a];return null},setTextSelectionMode:function(a){this._textSelectionByCharModeEnabled=a},setMode:function(b){this._mode=b;if(b==this.SelectionModes.SelectText||b==this.SelectionModes.SelectTextToStrikeout){if(this._lassoCssElement==null)this._lassoCssElement=a('<style type="text/css">.ui-selectable-helper { visibility: hidden; }</style>').appendTo("head")}else if(this._lassoCssElement){this._lassoCssElement.remove();this._lassoCssElement=null}},getMode:function(){return this._mode},getRowsFromRect:function(f){this.initStorage();var c=null;this.lasso=f.clone();this.lasso=new jSaaspose.Rect(Math.round(this.lasso.left()),Math.round(this.lasso.top())+.001,Math.round(this.lasso.right()),Math.round(this.lasso.bottom())-.001);for(var a=this._getDocumentHighlightRects(),b=0;b<a.length;b++){c=a[b].bounds;var d=this.pages[a[b].page].rect.topLeft.x-this.pages[0].rect.topLeft.x,e=this.pages[a[b].page].rect.topLeft.y;c.add(new jSaaspose.Point(d,e))}return a}})})(jQuery);if(!window.jGroupdocs)window.jGroupdocs={};window.jGroupdocs.Pdf2JavaScriptWrapper=function(a){this.options=$.extend(true,{},this.options,a);this.init()};$.extend(window.jGroupdocs.Pdf2JavaScriptWrapper.prototype,{documentDescription:null,_portalService:Container.Resolve("PortalService"),proportion:1,options:{userId:0,privateKey:"",guid:""},init:function(){this.documentDescription=JSON.parse(this.options.documentDescription)},getPageCount:function(){return this.documentDescription.pages?this.documentDescription.pages.length:typeof this.documentDescription.pageCount!="undefined"?this.documentDescription.pageCount:0},getPageSize:function(){var b=this.documentDescription.widthForMaxHeight,a=this.documentDescription.maxPageHeight;if(typeof b==="undefined"||typeof a==="undefined")if(this.documentDescription.pages){var c=this.documentDescription.pages[0];b=c.w;a=c.h}else b=a=null;return{width:b,height:a}},getContentControls:function(){return this.documentDescription.contentControls},getBookmarks:function(){return this.documentDescription.bookmarks},getPages:function(c,a,e,g,l,j){if(!this.documentDescription.pages)return null;var h=[],n=0;this.proportion=c;var b=this.documentDescription.pages.length;if(b>0&&a.length<b&&a.length<g-e+1)return null;var f=100,k=Math.ceil(b/f),m=c*this.documentDescription.widthForMaxHeight,o=0,d=function(v,i,g,p,s,x){for(var r=false,e=i*f;e<b&&e<(i+1)*f;e++){var h=this.documentDescription.pages[e],c;if(typeof p!=="undefined"){if(e<p)continue;if(e>s){r=true;break}c=a[e-p]}else c=a[e];var u=h.number;g=m/h.w;var l=h.rotation;if(typeof l=="undefined")l=0;var o=h.w,q=h.h;if(l%180!=0)g*=o/q;var y=this.getRows(h,u,g,n,c),w=c.x+o*g,t=c.y+q*g;switch(l){case 90:case 270:w=c.x+q*g;t=c.y+o*g}v.push({pageId:u,rows:y,rect:new jSaaspose.Rect(c.x,c.y,w,t),originalWidth:o,rotation:h.rotation})}if(x)return r;i++;if(i<k&&!r)window.setTimeout(function(){d(v,i,g,p,s)},10);else j&&this._setTextPositionsCalculationFinished(true)}.bind(this);if(l||this.options.synchronousWork){for(var i=0;i<k;i++)if(d(h,i,c,e,g,true))break;j&&this._setTextPositionsCalculationFinished(true)}else window.setTimeout(function(){d(h,o,c,e,g)},10);return h},getRows:function(c,o,b,l,d){var f=c.rotation,h=c.w,g=c.h,q=[];if(c.rows)for(var k=0;k<c.rows.length;k++){var a=c.rows[k],t=this.getWords(a,o,b,l,d,f,h,g),s=this.getChars(a,o,b,l,d,f,h,g),e=this.getRotatedtextCoordinates(f,h,g,a.l,a.t,a.w,a.h),i=e.left,j=e.top,n=e.width,m=e.height,u=i*b,v=j*b,p=u+d.x,r=v+d.y,x=n*b,w=m*b;q.push({text:a.s,words:t,chars:s,pageLocation:d,originalRect:new jSaaspose.Rect(i,j,i+n,j+m),rect:new jSaaspose.Rect(p,r,p+x,r+w)})}return q},getWords:function(d,x,c,w,h,o,q,p){var k=[],f=[],l=[],v=d.s.split(" ");f=$.map(d.c,function(a,b){if(b%2==0)return a;else l.push(a)});for(var a=0;a<f.length;a++){var b=this.getRotatedtextCoordinates(o,q,p,f[a],d.t,l[a],d.h),e=b.left,g=b.top,j=b.width,i=b.height,r=Math.round(e*c),s=Math.round(g*c),m=r+h.x,n=s+h.y,u=Math.round(j*c),t=Math.round(i*c);k.push({text:v[a],pageLocation:h,originalRect:new jSaaspose.Rect(e,g,e+j,g+i),rect:new jSaaspose.Rect(m,n,m+u,n+t)})}return k},getChars:function(a,A,f,z,k,r,t,s){var o=[],i=[],h=[],d=[],u=a.s.replace(/\s+/g,"");if(a.ch){for(var m=1,b=0;b<a.ch.length;b++){if(a.s.charAt(b+m)==" "){m++;d.push(true)}else b!=a.ch.length-1&&d.push(false);i.push(a.ch[b]);if(b<a.ch.length-1)h.push(a.ch[b+1]-a.ch[b]);else if(b==a.ch.length-1){d.push(true);h.push(a.w-a.ch[b])}}for(var c=0;c<i.length;c++){var e=this.getRotatedtextCoordinates(r,t,s,i[c],a.t,h[c],a.h),g=e.left,j=e.top,n=e.width,l=e.height,v=Math.round(g*f),w=Math.round(j*f),p=v+k.x,q=w+k.y,y=Math.round(n*f),x=Math.round(l*f);o.push({text:u.charAt(c),isLastWordChar:d[c],pageLocation:k,originalRect:new jSaaspose.Rect(g,j,g+n,j+l),rect:new jSaaspose.Rect(p,q,p+y,q+x)})}}return o},getRowCharacterCoordinates:function(b,c){return this.documentDescription.pages[b].rows[c].ch},reorderPage:function(b,c){var a=this.documentDescription.pages,d=a[b];a.splice(b,1);a.splice(c,0,d)},getRotatedtextCoordinates:function(k,j,i,g,h,b,a){var e=g,f=h,d=b,c=a;switch(k){case 90:e=i-h-a;f=g;d=a;c=b;break;case 180:e=j-g-b;f=i-h-a;d=b;c=a;break;case 270:e=h;f=j-g-b;d=a;c=b}return{left:e,top:f,width:d,height:c}},_setTextPositionsCalculationFinished:function(b){var a=this.options.setTextPositionsCalculationFinishedCallback;a&&a.call(this.options.viewerThis,b)}});(function(a){a.widget("ui.navigation",{_viewModel:null,_pageCount:0,_create:function(){if(this.options.createHtml)this._createHtml();else this.options.createEmbeddedHtml&&this._createEmbeddedHtml();this._viewModel=this.getViewModel();ko.applyBindings(this._viewModel,this.element.get(0))},_createViewModel:function(){var a={pageInd:ko.observable(1),pageCount:ko.observable(0)};a.up=function(){this.up()}.bind(this);a.down=function(){this.down()}.bind(this);a.selectPage=function(a){this.set(a)}.bind(this);a.onKeyPress=function(b,a){this.onKeyPress(a);return true}.bind(this);a.setPageIndex=function(a){this.setPageIndex(a)}.bind(this);a.openFirstPage=function(){this.set(1)}.bind(this);a.openLastPage=function(){this.set(this._viewModel.pageCount())}.bind(this);a.setPagesCount=function(a){this.setPagesCount(a)}.bind(this);return a},getViewModel:function(){if(!this._viewModel)this._viewModel=this._createViewModel();return this._viewModel},up:function(){var c=this._viewModel.pageInd(),d=this._viewModel.pageCount(),b;if(c<=0)b=1;else if(c>d)b=d;else b=c!=1?c-1:1;this._viewModel.pageInd(b);a(this.element).trigger("onUpNavigate",b)},down:function(){var b=this._viewModel.pageInd(),d=this._viewModel.pageCount(),c;if(b<=0)c=1;else if(b>d)c=d;else c=b!=d?parseInt(b)+1:b;this._viewModel.pageInd(c);a(this.element).trigger("onDownNavigate",c)},"set":function(e){var d=this._viewModel.pageInd(),b=this.setPageIndex(e),c="up";if(d>b)c="down";a(this.element).trigger("onSetNavigate",{pageIndex:b,direction:c})},setPageIndex:function(c){var a=Number(c),b=this._viewModel.pageCount();if(isNaN(a))a=1;else if(a<=0)a=1;else if(a>b)a=b;this._viewModel.pageInd(a);return a},openFirstPage:function(){this.selectPage(1)},openLastPage:function(){this.selectPage(this.pageCount())},onKeyPress:function(a){a.keyCode==13&&this.set(this._viewModel.pageInd())},setPagesCount:function(a){this._pageCount=a;this._viewModel.pageCount(a)},_createHtml:function(){var b=this.element;b.addClass("left");a('<span class="new_head_tools_btn h_t_i_nav1" data-bind="click: function() { selectPage(1); }, css: {disabled: pageInd() <= 1}" data-tooltip="First Page" data-localize-tooltip="FirstPage"></span><span class="new_head_tools_btn h_t_i_nav2" data-bind="click: up, css: {disabled: pageInd() <= 1}" data-tooltip="Previous Page" data-localize-tooltip="PreviousPage"></span><input class="new_head_input" type="text" style="width: 17px;" data-bind="value: pageInd, valueUpdate: [\'afterkeydown\'], event: { keyup: onKeyPress }" /><p class="new_head_of" data-localize="Of">of</p><p class="new_head_of" data-bind="text: pageCount()"></p><span class="new_head_tools_btn h_t_i_nav3" data-bind="click: down, css: {disabled: pageInd() >= pageCount()}" data-tooltip="Next Page" data-localize-tooltip="NextPage"></span><span class="new_head_tools_btn h_t_i_nav4" data-bind="click: function() { selectPage(this.pageCount()); }, css: {disabled: pageInd() >= pageCount()}" data-tooltip="Last Page" data-localize-tooltip="LastPage"></span>').appendTo(b);b.trigger("onHtmlCreated")},_createEmbeddedHtml:function(){var b=this.element;b.addClass("left");a('<span class="embed_viewer_icons icon1" data-bind="click: function() { selectPage(1); }"></span><span class="embed_viewer_icons icon2" data-bind="click: up"></span><p>Page</p><input type="text" name="textfield" class="page_nmbr" data-bind="value: pageInd, valueUpdate: [\'afterkeydown\'],  event: { keyup: onKeyPress }"/><p>of <span data-bind="text: pageCount()" ></span></p><span class="embed_viewer_icons icon3" data-bind="click: down"></span><span class="embed_viewer_icons icon4" data-bind="click: function() { selectPage(this.pageCount()); }"></span>').appendTo(b);b.trigger("onHtmlCreated")}})})(jQuery);(function(a){a.widget("ui.thumbnails",{_viewModel:null,_pageCount:0,_sessionToken:"",_docGuid:"",_docVersion:1,_pagesWidth:"150",_heightWidthRatio:0,_thumbsSelected:0,_thumbnailWidth:150,_portalService:Container.Resolve("PortalService"),options:{quality:null,use_pdf:"false",baseUrl:null,userId:0,userKey:null,supportPageRotation:false},_create:function(){this.useHtmlThumbnails=this.options.useHtmlThumbnails;this.useHtmlBasedEngine=this.options.useHtmlBasedEngine;this.emptyImageUrl="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNgYAAAAAMAASsJTYQAAAAASUVORK5CYII=";if(this.options.supportPageReordering){var b=this;ko.bindingHandlers.sortableArray={init:function(e,d){var c=d();a(e).sortable({axis:"y",update:function(h,e){var f=e.item[0],d=ko.dataFor(f),g=c.indexOf(d),a=ko.utils.arrayIndexOf(e.item.parent().children(),f);e.item.remove();if(a>=0){c.remove(d);c.splice(a,0,d)}b.rootElement.trigger("onPageReordered",[g,a])}})}}}this.options.createHtml&&this._createHtml();if(this.options.thumbnailWidth)this._thumbnailWidth=this.options.thumbnailWidth;this._viewModel=this.getViewModel();ko.applyBindings(this._viewModel,this.element.get(0));this.options.useInnerThumbnails&&ko.applyBindings(this._viewModel,this.toggleThuumbnailsButton[0])},_createViewModel:function(){var a={thumbnails:ko.observableArray([]),pageInd:ko.observable(1),pageCount:ko.observable(0),busy:ko.observable(true)};a._thumbnailHeight=ko.observable(201);a.useInnerThumbnails=this.options.useInnerThumbnails;a.openThumbnails=ko.observable(this.options.openThumbnails);a.element=this.element;a.rootElement=this.rootElement;a.thumbnailPanelElement=this.thumbnailPanelElement;a.emptyImageUrl=this.emptyImageUrl;if(this.useHtmlThumbnails)a.scale=ko.observable(0);a.scrollThumbnailsPanel=function(a){this._onScrollLeftPanel(a)}.bind(this);a.selectPage=function(a){this.set(a)}.bind(this);a.showThumbnails=function(c){for(var b,a=0;a<this.thumbnails().length;a++){b=this.thumbnails()[a];b.visible(c)}};a.hideThumbnails=function(){this.showThumbnails(false)};a.onProcessPages=function(f,e,a,c,b,d){this.onProcessPages(f,e,a,c,b,d)}.bind(this);a.setThumbnailsScroll=function(a){this.setThumbnailsScroll(a)}.bind(this);a.set=function(a){this.set(a)}.bind(this);a.setPageWithoutEvent=function(a){this.setPageWithoutEvent(a)}.bind(this);a.getThumbnailsPanelWidth=function(){var a=0;if(this.useInnerThumbnails)a=this.element.parent().width();return a};a.toggleThumbnails=function(){this.openThumbnails(!this.openThumbnails());this.rootElement.trigger("onResizeThumbnails",this.thumbnailPanelElement.width())};return a},getViewModel:function(){if(!this._viewModel)this._viewModel=this._createViewModel();return this._viewModel},onProcessPages:function(a,D,v,x,o,y){this._sessionToken=a.token;this._docGuid=a.guid;this._docVersion=a.version;this._viewModel.pageCount(a.page_count);!a.lic&&this._viewModel.pageCount()>3&&this._viewModel.pageCount(3);this._heightWidthRatio=parseFloat(a.page_size.Height/a.page_size.Width);var E=this._thumbnailWidth,h=false,f=null,k,p,e=null,z;if(a.documentDescription&&a.documentDescription.pages){h=true;f=a.documentDescription.pages;k=a.documentDescription.maxPageHeight;p=a.documentDescription.widthForMaxHeight;e=k/p*this._thumbnailWidth;z=e/k/o;if(this.useHtmlThumbnails){this.getDocumentPageHtmlCallback=v;this.viewerViewModel=x;this._viewModel.docViewerId=y;var w=this.element.width()}}for(var n=[],b,j,g,c,i,r=47,A=this._viewModel.pageCount(),u,s,t,q,d=0;d<A;d++){b={number:d+1,busy:ko.observable(true),visible:ko.observable(false),url:ko.observable(this.emptyImageUrl)};if(h){if(d<f.length){u=f[d].w;s=f[d].h;var m=s/u,l=f[d].rotation;if(typeof l=="undefined")l=0;if(l%180!=0)m=1/m;g=this._thumbnailWidth;c=this._thumbnailWidth*m;if(c>e){t=e/c;c=e;g=this._thumbnailWidth*t}}else{g=this._thumbnailWidth;c=215}b.width=ko.observable(g);b.height=ko.observable(c);j=0;i="";if(c<r){j=((r-c)/2).toString();i="white"}b.verticalPadding=ko.observable(j);b.backgroundColor=ko.observable(i);b.wrapperHeight=e;b.scale=ko.observable(c/f[d].h/o);q=(w-g)/2;b.thumbLeftCoord=ko.observable(q);if(this.useHtmlThumbnails)b.htmlContent=D[d].htmlContent}n.push(b)}this._viewModel.thumbnails(n);var C=parseInt(this._heightWidthRatio*E),B="";if(!h)B=".grpdx .thumbnailsContainer .thumb-page{min-height:"+C.toString()+"px}";this.loadThumbnails()},loadThumbnails:function(){var a=Math.ceil(this.element.height()/parseInt(this._heightWidthRatio*150));this._countToShowOnThumbDiv=a;this._thumbsCountToShow=Number(a)+Math.ceil(Number(Number(a)/2));this._thumbsSelected=this._thumbsCountToShow;this.retrieveImageUrls(this._viewModel.pageCount())},retrieveImageUrls:function(a){this._portalService.getImageUrlsAsync(this.options.userId,this.options.userKey,this._docGuid,this.options._mode=="webComponent"?this._thumbnailWidth:this._thumbnailWidth.toString()+"x",this._sessionToken,0,a,this.options.quality,this.options.use_pdf,this._docVersion,null,null,null,null,this.options.ignoreDocumentAbsence,this.options.useHtmlBasedEngine,this.options.supportPageRotation,function(b){b=b.data;var d;if(b.imageUrls&&typeof b.image_urls=="undefined")d=b.imageUrls;else d=b.image_urls;for(var c=0;c<a;c++)this._viewModel.thumbnails()[c].url(d[c]);this._onScrollLeftPanel()}.bind(this),function(){for(var b=0;b<a;b++)this.makeThumbnailNotBusy(b)}.bind(this),this.options.instanceIdToken,this.options.locale)},makeThumbnailNotBusy:function(b){var a=this._viewModel.thumbnails()[b];a.busy(false)},_onScrollLeftPanel:function(){for(var e=this._viewModel.pageCount(),j=this._thumbnailWidth,b=this.element,d=b.find(".thumb-page:first").outerHeight(false),f=b.scrollTop(),i=b.height(),g=Math.floor(f/d),c=Math.floor((f+i)/d)+1,h=c<e-2?c+2:e,a=g;a<h;a++){this.useHtmlThumbnails&&this.getDocumentPageHtmlCallback.call(this.viewerViewModel,a);this._viewModel.thumbnails()[a].visible(true)}this._thumbsSelected=c},setThumbnailsScroll:function(f){var d=f.pi;if(this._viewModel.pageInd()!=d){this._viewModel.pageInd(d);!f.eventAlreadyRaised&&this.element.trigger("onSetThumbnailsScroll",d)}var e=this.element.offset().top,c=this.element.children("ul").children("li:nth-child("+this._viewModel.pageInd()+")");if(c.length==0)return;var b=c.offset().top,h=b-a(window).height(),i=b+c.height()-e,g=this.element.scrollTop(),j=b-e;(h>0||i<0)&&this.element.scrollTop(g+j)},"set":function(b){this._viewModel.pageInd(b);a(this.element).trigger("onSetThumbnails",b)},setPageWithoutEvent:function(a){this._viewModel.pageInd(a)},setPagesCount:function(a){this._pageCount=a;this._viewModel.pageCount(a)},_createHtml:function(){var c=this.element,b;if(this.options.supportPageReordering)b="foreach: thumbnails, sortableArray: thumbnails";else b="foreach: thumbnails";this.element=a('<div class="thumbnailsContainer" data-bind="event: { scroll: function(e) { scrollThumbnailsPanel(e); } }, visible:!useInnerThumbnails || openThumbnails">    <ul class="vertical-list2 ui-selectable" data-bind="'+b+'">        <li class="thumb-page ui-selectee" data-bind="style: {height: $data.wrapperHeight + \'px\'}, css: { \'ui-selected\': ($index() + 1) == $root.pageInd() }, click: function() { $root.selectPage($index() + 1); }">'+(this.useHtmlThumbnails?"        <div class=\"thumbnail_wrapper\" data-bind=\"style: {width:$data.width() + 'px',height: $data.height() + 2 * $data.verticalPadding() + 'px'}\">           <div class=\"html_page_contents\"                 data-bind=\"html: htmlContent,                         visible: visible(),                        attr: {id: $root.docViewerId + 'pageHtml-' + ($index() + 1) },                        style: { padding: $data.verticalPadding() + 'px 0',                                    MozTransform: 'scale(' + $data.scale() + ')',                                     '-webkit-transform': 'scale(' + $data.scale() + ')',                                    '-ms-transform': 'scale(' + $data.scale() + ')' }\">            </div>           <div class=\"html_page_contents mouse_intercept_overlay\">            </div>":'                <div class="thumbnail_wrapper" data-bind="style: {height: $data.height() + 2 * $data.verticalPadding() + \'px\'}">                    <img class="ui-selectee thumb_image" src="'+this.emptyImageUrl+"\" data-bind=\"attr: {src: visible() ? url() : $root.emptyImageUrl}, style: {width: (visible() ? $data.width() : 0) + 'px', height: (visible() ? $data.height() : 0) + 'px', padding: $data.verticalPadding() + 'px 0', backgroundColor: $data.backgroundColor()}\" />")+'                </div>                <span class="progresspin thumb_progress"></span>        </li>    </ul></div>');if(this.options.useInnerThumbnails){this.thumbnailPanelElement=a('<div class="thumbnail_panel"></div>');this.element.appendTo(this.thumbnailPanelElement);this.toggleThuumbnailsButton=a('<div class="thumbnail_stripe">   <a class="thumbnail_open" data-bind="click:function(){toggleThumbnails();}"></a></div>');this.toggleThuumbnailsButton.appendTo(this.thumbnailPanelElement);this.thumbnailPanelElement.prependTo(c)}else this.element.appendTo(c);this.rootElement=c}})})(jQuery);(function(a){fileOpenDialogViewModel=function(a,c,b){this.fileOpenDialog=a;this.fileUploader=c;this.fileExplorer=b;this._init()};a.extend(fileOpenDialogViewModel.prototype,{_explorerViewModel:null,_uploaderElements:[],_init:function(){this.fileExplorer.bind("onPathChanged",this._onExplorerPathChanged.bind(this));this.fileExplorer.bind("onNodeSelected",this._onExplorerNodeSelected.bind(this));this._explorerViewModel=a(this.fileExplorer).explorer("getViewModel");this.fileUploader.bind("onStart",this._onFileUploaderStart.bind(this));this.fileUploader.bind("onProgress",this._onFileUploaderProgress.bind(this));this.fileUploader.bind("onComplete",this._onFileUploaderComplete.bind(this))},_onExplorerPathChanged:function(){},_onExplorerNodeSelected:function(c,b){b.id>0&&b.type==="file"&&a(this.fileOpenDialog.fileExplorer).trigger("fileSelected",b)},_onFileUploaderStart:function(d,c,a,b){this._explorerViewModel.busy(true);this._uploaderElements[c]=this._explorerViewModel.createFile(a,b)},_onFileUploaderProgress:function(f,e,d,c,b){b>0&&a(this.fileOpenDialog.explorerProgressPercentage).text(Math.round(c/b*100)+" %")},_onFileUploaderComplete:function(f,b,d){var c=this._uploaderElements,e=this._explorerViewModel;a(this.fileOpenDialog.explorerProgressPercentage).text("100 %");e.busy(false);if(b&&d){c[b].id=d.id;c[b].guid=d.guid;c[b].url=d.url;c[b].Name=d.name;c[b].docType(d.docType);c[b].sizeInKb(Math.round(d.size/1024));c[b].version=d.version;c[b].path=e.path()+"/"+d.name;c[b].name(d.name);c[b].uploading(false);c[b].open()}else e._removeEntity(c[b])}})})(jQuery);(function(a){a.widget("ui.fileOpenDialog",{_viewModel:null,options:{autoOpen:true,url:"",uploadWebFiles:false,fileTypes:"doc,docx,docm,dot,dotx,dotm,rtf,odt,ott,pdf",resourcePrefix:""},_create:function(){var b=this,k=b.options,g=this.element;g.addClass("modal fade modal2 modal800px");var e=(b.wrapper=a("<div></div>")).addClass("modal_inner_wrapper").prependTo(g);this._buildDialogHeader(e);var i=(b.content=a("<div></div>")).addClass("modal_content").appendTo(e),h=(b.inputWrapLeft=a("<div></div>")).addClass("modal_input_wrap_left").appendTo(i),f=(b.fileExplorer=a("<div></div>")).addClass("file_browser_content").appendTo(h);this._buildFileUploader(f,b);var c=(b.filesArea=a("<div></div>")).attr("data-bind","fileDnD: {}").css({position:"relative"}).appendTo(f),j=a("<div></div>").css({position:"relative"}).appendTo(c),d=a("<div></div>").addClass("file_browser_sort").appendTo(c);this._buildExplorerHeaders(d,"file_browser_sort_filename","Name","File Name","FileName");this._buildExplorerHeaders(d,"file_browser_sort_size","Size","Size","Size");this._buildExplorerHeaders(d,"file_browser_sort_modified","ModifiedOn","Modified","Modified");this._buildFoldersList(c);this._buildFilesList(c);this._buildFooter(e);this.element.trigger("onHtmlCreated");this._viewModel=this.getViewModel()},_init:function(){},_buildDialogHeader:function(b){var e=a("<div></div>").addClass("popclose").attr("data-dismiss","modal").appendTo(b),c=a("<div></div>").addClass("modal_header").appendTo(b),d=a("<h3></h3>").text("Open File").attr("data-localize","OpenFile").appendTo(c)},_buildFileUploader:function(d,c){var b=(c.fileUploader=a("<div></div>")).addClass("file_browser_toolbar").css({position:"relative",display:"inline-block",overflow:"hidden"}).appendTo(d),g=a("<!-- ko with: isNotRootFolder -->").appendTo(b),e=a("<a></a>").addClass("small_button file_browser_upload_btn").attr("data-localize","ParentFolder").attr("data-bind","click: function () { $parent.openParentFolder();}").text("Parent folder").appendTo(b),h=a("<!-- /ko -->").appendTo(b);if(c.options.uploadWebFiles)var f=(c.openFromUrlButton=a("<a></a>")).addClass("small_button").text("Open From URL").appendTo(b)},_buildExplorerProgress:function(d){var c=a("<div></div>").attr("data-bind","visible: busy()").addClass("explorer-progress").appendTo(d),b=a("<div></div>").css({position:"relative",top:"50px",left:"50%",width:"96px",height:"56px"}).appendTo(c),f=a("<img/>").attr("src",this.options.resourcePrefix+"/Images/uploading.gif").attr("alt","").css({width:"16px",height:"16px"}).appendTo(b),g=a("<br/>").appendTo(b),e=(self.explorerProgressPercentage=a("<span></span>")).attr("id","explorer-progress-percentage").appendTo(b)},_buildExplorerHeaders:function(g,e,b,f,d){var c=a("<a></a>").attr("href","#").attr("data-bind",'click: function() { setOrder("'+b+'");}').addClass(e).appendTo(g),i=a("<h4></h4>").text(f).attr("data-localize",d).appendTo(c),h=a("<span></span>").addClass("smallarrow").attr("data-bind","visible: orderBy() === '"+b+"', css: {up: orderAsc(), down: !orderAsc()}").appendTo(c)},_buildFoldersList:function(e){var d=a("<ul></ul>").addClass("file_browser_folder_list").attr("data-bind","foreach: folders").appendTo(e),c=a("<li></li>").attr("data-bind","attr: { id: 'explorer-entity-' + id }, click: open").appendTo(d),b=a("<div></div>").addClass("file_browser_listbox folderlist").appendTo(c),f=a("<span></span>").addClass("listicons licon_folder").appendTo(b),g=a("<p></p>").addClass("listname_file_browser foldername").attr("data-bind","text: name()").appendTo(b)},_buildFilesList:function(e){var d=a("<ul></ul>").addClass("file_browser_file_list").attr("data-bind","foreach: files").appendTo(e),c=a("<li></li>").attr("data-bind","attr: { id: 'explorer-entity-' + id }, click: open").appendTo(d),b=a("<div></div>").addClass("file_browser_listbox filelist").appendTo(c),f=a("<span></span>").addClass("listicons").attr("data-bind","css: { 'licon_unkwn': (docType() != 'words' && docType() != 'pdf' &&  docType() != 'slides' &&docType() != 'cells' && docType() != 'image' && docType() != 'email' && docType() != 'diagram' && docType() != 'project' && docType() != 'taggedimage'), 'licon_word': docType() == 'words', 'licon_pdf': docType() == 'pdf', 'licon_ppt': docType() == 'slides', 'licon_xls': docType() == 'cells', 'licon_bmp': (docType() == 'image' || docType() == 'taggedimage'), 'licon_outlook': docType() == 'email', 'licon_visio': docType() == 'diagram', 'licon_mpp': docType() == 'project' }").appendTo(b),g=a("<p></p>").addClass("listname_file_browser filenameellipses").attr("data-bind","text: name(), ellipsis: true").appendTo(b),h=a("<p></p>").addClass("listfilesize listsmalltext").attr("data-bind","text: (sizeInKb() + 'Kb')").appendTo(b);a("<p></p>").addClass("listfilesize listsmalltext").attr("data-bind","text: modifiedOn()").appendTo(b)},_buildFooter:function(c){var b=(self.footer=a("<div></div>")).addClass("modal_footer").appendTo(c),d=a("<div></div>").addClass("modal_btn_wrapper").appendTo(b)},_createViewModel:function(){var f=this.options.hostUrl,c=this.options.userId,b=this.options.userKey,d=a(this.fileExplorer).explorer({userId:c,privateKey:b,pageSize:30,fileTypes:this.options.fileTypes,urlHashEnabled:this.options.urlHashEnabled,instanceIdToken:this.options.instanceIdToken}),e=a(this.fileUploader).uploader({url:f,userId:c,key:b,proxy:"Uploader.aspx",fld:"",multiple:true,addFileBtn:a(this.uploadButton)});return new fileOpenDialogViewModel(this,e,d)},getViewModel:function(){if(!this._viewModel)this._viewModel=this._createViewModel();return this._viewModel},destroy:function(){a.Widget.prototype.destroy.call(this)}})})(jQuery);(function(a,b){a.widget("ui.explorer",{_viewModel:null,_init:function(){var b=this;this._viewModel=this.getViewModel();this._viewModel.path.subscribe(function(b){a(this.element).trigger("onPathChanged",[b])}.bind(this));a(this._viewModel).bind("onNodeSelected",function(d,c,b){a(this.element).trigger("onNodeSelected",[c,b])}.bind(this));ko.applyBindings(this._viewModel,this.element.get(0))},_createViewModel:function(){return new explorerViewModel(this._getViewModelOptions())},_getViewModelOptions:function(){return{userId:this.options.userId,userKey:this.options.privateKey,pageSize:this.options.pageSize,fileTypes:this.options.fileTypes,startupPath:this.options.startupPath,view:this.options.view,urlHashEnabled:this.options.urlHashEnabled,instanceIdToken:this.options.instanceIdToken}},getViewModel:function(){if(!this._viewModel)this._viewModel=this._createViewModel();return this._viewModel},setFilter:function(a){this._viewModel.setFilter(a)},setOrder:function(a){this._viewModel.setFilter(a)}});explorerModel=function(b){a.extend(this.options,b);this._init()};a.extend(explorerModel.prototype,{_portalService:Container.Resolve("PortalService"),_path:"",_entitiesLoaded:0,_entitiesTotal:0,_filter:{name:"",types:null},_order:{by:ko.observable("Name"),asc:ko.observable(true)},options:{userId:"",userKey:"",pageSize:30,extended:false},_init:function(){},_loadPage:function(b,c,d,a){this._portalService.loadFileBrowserTreeData(this.options.userId,this.options.userKey,c,b?b:0,this.options.pageSize,this._order.by(),this._order.asc(),this._filter.name,this._filter.types,this.options.extended,function(b){if(b.textStatus==="success"){this._entitiesLoaded+=b.data.nodes.length;this._entitiesTotal=b.data.count;d.apply(this,[c,b.data.nodes])}else a.apply(this,[])}.bind(this),function(b){a.apply(this,[b])}.bind(this),false,this.options.instanceIdToken)},openFolder:function(c,b,a){this._path=c||"";this._entitiesLoaded=0;this._entitiesTotal=0;this._loadPage(0,this._path,b,a)},loadMore:function(b,a){if(this._entitiesLoaded>this._entitiesTotal)return false;var c=Math.ceil(this._entitiesLoaded/this.options.pageSize);this._loadPage(c,this._path,b,a);return true},createFolder:function(a,c,b){this._portalService.createFolderAsync(this.options.userId,this.options.userKey,a,function(d){if(d.data>0)c.apply(this,[a,d.data]);else b.apply(this,[a,null,d.data])}.bind(this),function(c){b.apply(this,[c,a])}.bind(this)).Subscribe()},setFilter:function(a){this._filter.name=a.name;this._filter.types=a.types},setOrder:function(a){if(this._order.by()==a){var b=!this._order.asc();this._order.asc(b)}else{this._order.asc(true);this._order.by(a)}}});explorerViewModel=function(a){this._init(a)};a.extend(explorerViewModel.prototype,{_model:null,_filtering:false,_ordering:false,_userId:null,_userKey:null,urlHashEnabled:true,busy:ko.observable(false),path:ko.observable(""),entities:ko.observableArray(),files:ko.observableArray(),folders:ko.observableArray(),changedUrlHash:false,view:ko.observable("listing"),_init:function(a){this._model=this._createModel(a);this._userId=a.userId;this._userKey=a.userKey;if(typeof a.urlHashEnabled!="undefined")this.urlHashEnabled=a.urlHashEnabled;this.busy=ko.observable(false);this.path=ko.observable("");this.entities=ko.observableArray();this.files=ko.observableArray();this.folders=ko.observableArray();this.isNotRootFolder=ko.computed({read:function(){return!(this.path()==="")},owner:this});!a.skipStartupPathLoad&&this.openFolder(a.startupPath)},_createModel:function(a){return new explorerModel(a)},_addRoot:function(){var a=this._createEntity("Home","folder");a.path="";this.entities.push(a);return a},_onEntitiesLoaded:function(c,e){var b=this;if(b._filtering||b._ordering||c!=b.path()){b.entities.removeAll();b.files.removeAll();b.folders.removeAll()}var d=1;a.each(e,function(){if(!this.extended){var a=this;if(typeof a.id=="undefined"){a.id=d;d++}b._extendEntity(a);b.entities.push(a)}if(this.type=="file")b.files.push(this);else b.folders.push(this)});b._filtering=false;b._ordering=false;b.path(c);if(this.urlHashEnabled){this.changedUrlHash=true;location.hash=b.view()+"#"+c;this.changedUrlHash=false}b.busy(false)},_onNetworkError:function(a){this.busy(false);jerror(a.Reason||a)},_extendEntity:function(b){var c=this,d=b.supportedTypes?a.map(b.supportedTypes,function(a){return a.toUpperCase()}):[];a.extend(b,{extended:true,name:ko.observable(b.name),uploading:ko.observable(false),isNewVersion:false,processingOnServer:false,sizeInKb:ko.observable(Math.round(b.size/1024)),docType:ko.observable(b&&b.docType?b.docType.toLowerCase():""),modifiedOn:function(){return isNaN(b.modifyTime)||b.modifyTime<0?"---":(new Date(b.modifyTime)).format("mmm dd, yyyy")},percentCompleted:ko.observable(0),uploadSpeed:ko.observable(0),remainingTime:ko.observable(0),supportedTypes:ko.observableArray(d),thumbnail:ko.observable(b.thumbnail),selected:ko.observable(false),isVisible:ko.observable(true),viewJobId:ko.observable(null),viewJobPoller:null});b.statusText=ko.computed(function(){return this.viewJobId()&&this.viewJobId()>0?"Server-side processing ...":"Time remaining: "+this.remainingTime()+" secs @ "+this.uploadSpeed()+" kb/Sec."},b);b.open=function(d){if(b.type==="file")a(c).trigger("onNodeSelected",[b,d]);else c.openFolder(b.path)};b.viewJobId.subscribe(function(a){if(a&&a>0){b.processingOnServer=true;this.viewJobPoller=new jobPoller({userId:c._userId,userKey:c._userKey,jobId:a,completed:function(){b.uploading(false);b.processingOnServer=false;b.viewJobPoller=null},failed:function(){b.uploading(false);b.processingOnServer=false;b.viewJobPoller=null},timedout:function(){b.uploading(false);b.processingOnServer=false;b.viewJobPoller=null}});this.viewJobPoller.start()}})},_findEntity:function(c,d){for(var b=0;b<this.entities().length;b++){var a=this.entities()[b];if(a.name().toLowerCase()==c.toLowerCase()&&a.type==d)return a}return null},_findEntityAt:function(c,d){for(var b=0;b<this.entities().length;b++){var a=this.entities()[b];if(a.path().toLowerCase()==c.toLowerCase()&&a.type==d)return a}return null},_createEntity:function(c,f,e,d){var a={id:0,path:(this.path().trim("/")+"/"+(d?d:c)).trim("/"),name:c,type:f,docType:"undefined",time:(new Date).getTime(),modifyTime:(new Date).getTime(),url:b,isKnown:false,fileCount:0,folderCount:0,supportedTypes:[],selected:false,size:e};this._extendEntity(a);return a},_getPathLevel:function(a){return a&&a.length>0?a.length-a.replace(/\/+/g,"").length+1:0},getSelectedEntities:function(){return a.map(this.entities(),function(a){if(a.id&&a.selected())return a})},openFolder:function(a){if(this.busy())return;this.busy(true);this._model.openFolder(a,this._onEntitiesLoaded.bind(this),this._onNetworkError.bind(this))},openParentFolder:function(){var b=this.path().lastIndexOf("/"),a=this.path().substr(0,b>0?b:0);a!=this.path()&&this.openFolder(a)},loadMore:function(){!this.busy()&&this.busy(this._model.loadMore(this._onEntitiesLoaded.bind(this),this._onNetworkError.bind(this)));return this.busy()},createFile:function(c,d){var b=this._findEntity(c,"file");if(b){b.uploading(true);b.isNewVersion=true;return b}var e=this,a=this._createEntity(c,"file",d);a.uploading(true);a.isNewVersion=false;this.entities.push(a);this.files.unshift(a);return a},entityExists:function(a,b){return this._findEntity(a,b)!=null},setFilter:function(a){this._filtering=true;this._model.setFilter(a);this.openFolder(this.path())},setOrder:function(a){this._ordering=true;this._model.setOrder(a);this.openFolder(this.path())},orderBy:function(){return this._model._order.by()},orderAsc:function(){return this._model._order.asc()},findEntity:function(a,b){return this._findEntity(a,b)},isNullOrWhiteSpace:function(a){return a===null||a=="undefined"||a.match(/^ *$/)!==null}})})(jQuery);var OverrideMode={Override:0,Rename:1,Break:2,Skip:3};(function(a,b){a.widget("ui.uploader",{_appender:null,_handler:null,options:{multiple:true,userId:b,key:"",url:"",proxy:"",fld:"documents",formats:"",onComplete:null,onStart:null,addFileBtn:null,skipErrors:false,delayedStart:false,isForUserStorage:false,overrideMode:OverrideMode.Override},_initHandler:function(){if(this._handler==null){var b=Container.Resolve("HttpProvider").buildUrl(this.options.url,this.options.proxy,{user_id:this.options.userId,fld:this.options.fld});this._handler=a.handlerFactory.get({multiple:this.options.multiple,baseServerHost:this.options.url,isForUserStorage:this.options.isForUserStorage,folder:this.options.fld,action:this.options.key?Container.Resolve("HttpProvider").signUrl(b,this.options.key):b,skipErrors:this.options.skipErrors,overrideMode:this.options.overrideMode});a(this._handler).hitch("onComplete",this._onComplete,this);a(this._handler).hitch("onProgress",this._onProgress,this);a(this._handler).hitch("onStart",this._onStart,this)}},_initAppender:function(){if(this._appender==null){var b=this;this._appender=new FileAppender({container:this.element,multiple:!this._handler.sync,_addFileBtn:this.options.addFileBtn,onAddItemAction:function(c){if(b.options.delayedStart)a(b.element).trigger("onFileSelected",[a.fileInputUtils.getName(c),c]);else b._uploadFile(c)}})}},_create:function(){this._initHandler();this._initAppender()},_onCancel:function(b){var a=b.data;this._handler.cancel(a)},_onComplete:function(d,c,b){if(this.options.onComplete)this.options.onComplete.apply(this,[c,b]);else a(this.element).trigger("onComplete",[c,b])},_beforeStart:function(a){return this.options.beforeStart?this.options.beforeStart(a):true},_onStart:function(e,d,b,c){if(this.options.onStart)this.options.onStart.apply(this,[d,b,c]);else a(this.element).trigger("onStart",[d,b,c])},_onProgress:function(h,g,d,e,f,b,c){if(this.options.onProgress)this.options.onProgress.apply(this,[g,d,e,f,b,c]);else a(this.element).trigger("onProgress",[g,d,e,f,b,c])},_uploadFile:function(f,c){var b=this._handler.add(f,jSaaspose.utils.getSequenceNumber()),e=this._handler.getPath(b);if(typeof c!=="undefined")this._handler.overrideMode=c;if(!this._beforeStart(e)){this._handler.cancel(b);return}var d=this._addFileItem(b,e);if(this.options.formats==""||this.options.formats.indexOf(d.ext.toLowerCase())!=-1){a(this.element).trigger("onAdded",[d,null]);this._handler.upload(b)}else a(this.element).trigger("onAdded",[null,"Not allowed format"]);return b},upload:function(){throw new("not implemented");},uploadFile:function(b,a){return this._uploadFile(b,a)},cancelUploadFile:function(a){this._handler.cancel(a)},_addFileItem:function(c,a){return{id:c,name:a,ext:this._getExt(a)}},_getExt:function(a){return Container.Resolve("PathProvider").getExt(a).toUpperCase()},_setOption:function(b,c){a.Widget.prototype._setOption.call(this,b,c);if(b==="fld"){this._handler=null;this._initHandler()}}});UploadHandlerBasic=function(b){a.extend(this,b)};a.extend(UploadHandlerBasic.prototype,{action:"",_inputs:{},sync:true,skipErrors:false,getPath:function(b){return a.fileInputUtils.getPath(this._inputs[b])},getSize:function(c){var b=this._inputs[c];return a.fileInputUtils.getSize(b)},add:function(b,c){this._inputs[c]=b;a(b).detach();return c},upload:function(a){this._upload(a)},cancel:function(a){this._cancel(a)},_parseResponse:function(a){try{var b=eval("("+a+")")}catch(c){throw"Error in file processing at server side:"+a;}return b},_upload:function(){},_cancel:function(){}});IFrameHandler=function(){UploadHandlerBasic.apply(this,arguments)};a.extend(IFrameHandler.prototype,UploadHandlerBasic.prototype,{_upload:function(c){var e=this._inputs[c],f=Container.Resolve("PathProvider").getName(this.getPath(c));a(e).attr("name",f);var d=this._createForm(c),b=this._createIFrame(c);d.append(e);var g=b.get(0).document?b.get(0).document:b.get(0).contentDocument?b.get(0).contentDocument:b.get(0).contentWindow.document;g.body.appendChild(d.get(0));b.hitch("load",function(){var d=this._getIframeContentJSON(b[0]);a(this).trigger("onComplete",[c,d.success?d.parsed:null]);delete this._inputs[c];setTimeout(function(){b.remove()},1)},this);a(this).trigger("onStart",[c,f]);d.submit();d.remove()},_createForm:function(c){var b=a('<form method="post" enctype="multipart/form-data" style="display:none"></form>');b.attr("id","form"+c);b.attr("target","iframe"+c);b.attr("action",this.isForUserStorage?this._buildUriForIframeAction():this.action);return b},_buildUriForIframeAction:function(){var b="";a.ajax({url:this.baseServerHost+"getFileUploadUrl",data:"path="+this.folder+"&forIframe=true",async:false,success:function(a){b=a}});return b},_createIFrame:function(c){var b=a('<iframe src="javascript:false;" name="iframe'+c+'" style="display:none" />').appendTo("body");b.attr("id","iframe"+c);return b},_cancel:function(b){a("iframe"+b).remove();delete this._inputs[b]},_getIframeContentJSON:function(a){try{if(!a.parentNode)return;if(a.contentDocument&&a.contentDocument.body&&a.contentDocument.body.innerHTML=="false")return;var e=a.contentDocument?a.contentDocument:a.contentWindow.document,c=e.body.innerHTML.replace(/^<[^>]+>|<[^>]+>$/g,""),d=this.isForUserStorage?this._correctDataFromIframe(this._parseResponse(c)):this._parseResponse(c);return{success:true,parsed:d}}catch(f){}return{success:false,parsed:b}},_correctDataFromIframe:function(c){var b={};b.code=c.status;b.error=c.error_message;b.id=c.result.upload_Request_Results[0].id;b.fileType=c.result.upload_Request_Results[0].file_type;b.docType=c.result.upload_Request_Results[0].type.toLowerCase();b.guid=c.result.upload_Request_Results[0].guid;b.thumbnail=c.result.upload_Request_Results[0].thumbnail;b.upload_time=c.result.upload_Request_Results[0].upload_time;b.viewJobId=c.result.upload_Request_Results[0].view_job_id;b.size=c.result.upload_Request_Results[0].size;b.name=c.result.upload_Request_Results[0].adj_name;b.version=c.result.upload_Request_Results[0].version;b.url=c.result.upload_Request_Results[0].url;b.field_count=0;b.supportedTypes={};a.ajax({type:"POST",url:this.baseServerHost+"getJsonFileInfo",data:{fileType:c.result.upload_Request_Results[0].file_type},async:false,success:function(a){b.supportedTypes=a}});return b}});AjaxHandler=function(){UploadHandlerBasic.apply(this,arguments);this.sync=false;this._xhrs={}};a.extend(AjaxHandler.prototype,UploadHandlerBasic.prototype,{updateProgress:function(a){if(a.lengthComputable)var b=a.loaded/a.total},_upload:function(d){var i=this._inputs[d],c=this,e=UploadHandlerBasic.prototype.getPath.apply(this,[d]),f=UploadHandlerBasic.prototype.getSize.apply(this,[d]),b=c._xhrs[d]=new XMLHttpRequest,g=(new Date).getTime();b.upload.onprogress=function(b){if(b.lengthComputable){var f=(new Date).getTime()-g,h=b.loaded/f,i=(b.total-b.loaded)*f/b.loaded;a(c).trigger("onProgress",[d,e,b.loaded,b.total,h,i])}};var h=this.isForUserStorage;b.onreadystatechange=function(){if(b.readyState==4){if(b.status==0&&b.canceled){a(c).trigger("onComplete",[d,"canceled"]);return}if(b.status==0){a(c).trigger("onComplete",[d,null]);return}var k=(new Date).getTime()-g,j=f/k;a(c).trigger("onProgress",[d,e,f,f,j,0]);var i=null;if(b.status==200)try{if(h)i=c._correctData(c._parseResponse(b.responseText));else i=c._parseResponse(b.responseText);if(i.code=="Unauthorized"){window.location=Container.Resolve("HttpProvider").buildUrl("/","sign-in",{returnUrl:window.location.href});return}if(!c.skipErrors){if(i.code=="Forbidden")throw i;if(i.code=="QuotaExceeded")throw i;if(i.code=="StorageLimitExceeded")throw i;}}catch(l){jerror(i.error);i=null}a(c).trigger("onComplete",[d,i]);delete c._inputs[d];delete c._xhrs[d]}};if(this.overrideMode==OverrideMode.Rename)a(this).trigger("onStart",[d,e+" (new copy)",f]);else a(this).trigger("onStart",[d,e,f]);if(this.isForUserStorage){b.open("POST",c._buildUriForUserStorage(e),true);this.overrideMode=OverrideMode.Override}else b.open("POST",c._buildUri(e),true);b.setRequestHeader("X-Requested-With","XMLHttpRequest");b.setRequestHeader("X-File-Name",encodeURIComponent(e));b.setRequestHeader("Content-Type","application/octet-stream");b.send(i)},_correctData:function(c){var b={};b.id=c.result.id;b.code=c.result.status;b.fileType=c.result.file_type;b.docType=c.result.type.toLowerCase();b.guid=c.result.guid;b.thumbnail=c.result.thumbnail;b.upload_time=c.result.upload_time;b.viewJobId=c.result.view_job_id;b.size=c.result.size;b.name=c.result.adj_name;b.version=c.result.version;b.url=c.result.url;b.error=c.result.error_message;b.field_count=0;b.supportedTypes={};a.ajax({type:"POST",url:this.baseServerHost+"getJsonFileInfo",data:{fileType:c.result.file_type},async:false,success:function(a){b.supportedTypes=a}});return b},_buildUri:function(b){return this.action+"&"+a.param({fileName:b,multiple:true})},_buildUriForUserStorage:function(c){var b="";a.ajax({url:this.baseServerHost+"getFileUploadUrl",data:"path="+this.folder+"&filename="+encodeURIComponent(c)+"&overrideMode="+this.overrideMode,async:false,success:function(a){b=a}});return b},_cancel:function(a){if(this._inputs[a])delete this._inputs[a];if(this._xhrs[a]){this._xhrs[a].canceled=true;this._xhrs[a].abort();delete this._xhrs[a]}}});HandleFactory=function(){};a.extend(HandleFactory.prototype,{"get":function(a){return a.multiple&&this._isXHRSupported()?new AjaxHandler(a):new IFrameHandler(a)},_isXHRSupported:function(){var b=a('<input type="file" />');return"multiple"in b[0]&&typeof File!="undefined"&&typeof(new XMLHttpRequest).upload!="undefined"}});ItemAppender=function(b){a.extend(this,b);this._init();this._subscribe()};a.extend(ItemAppender.prototype,{container:null,template:"",onAddItemAction:null,multiple:false,_addFileBtn:null,_input:null,_init:function(){this._input=a("#input",this.container);if(this._addFileBtn==null)this._addFileBtn=a("#button",this.container)},_subscribe:function(){}});FileAppender=function(){ItemAppender.apply(this,arguments)};a.extend(FileAppender.prototype,ItemAppender.prototype,{_init:function(){ItemAppender.prototype._init.apply(this);this._input=this._createInput().prependTo(this._addFileBtn)},_createInput:function(){var b=a('<input type="file" class="file-input"></input>');this.multiple&&b.attr("multiple","multiple");return b},_subscribe:function(){this._input.hitch("change",this._onChange,this)},_onChange:function(b){var c=this;if(this.multiple){a.each(b.target.files,function(){c.onAddItemAction(this)});a(b.target).remove()}else this.onAddItemAction(b.target);this._input=this._createInput().prependTo(this._addFileBtn);this._subscribe()}});InputTypeFile=function(b){a.extend(this,b);this._init();this._subscribe()};a.extend(InputTypeFile.prototype,{onFileSelected:null,name:null,element:null,_input:null,_init:function(){this._input=this._createInput().prependTo(this.element)},_createInput:function(){var b=a('<input type="file" class="file-input"></input>');b.attr("name",this.name);return b},_subscribe:function(){this._input.hitch("change",this._onChange,this)},_onChange:function(a){var b=this;this.onFileSelected(a.target)}});IFrame=function(b){a.extend(this,b);this._init()};a.extend(IFrame.prototype,{values:null,elements:null,action:null,onComplete:null,_init:function(){var c=this._createForm(),b=this._createIFrame();a.each(this.values,function(){var b=a('<input type="hidden" value="'+this.value+'" name="'+this.name+'"></input>');c.append(b)});a.each(this.elements,function(){c.append(this)});var d=b.get(0).document?b.get(0).document:b.get(0).contentDocument?b.get(0).contentDocument:b.get(0).contentWindow.document;d.body.appendChild(c.get(0));b.hitch("load",function(){var a=this._getIframeContentJSON(b[0]);if(this.onComplete)this.onComplete(a.parsed);setTimeout(function(){b.remove()},1)},this);c.submit();c.remove()},_createForm:function(){var b=a('<form method="post" enctype="multipart/form-data" style="display:none"></form>');b.attr("action",_buildUriForIframeAction());b.attr("target","iframe");return b},_buildUriForIframeAction:function(){var b="";a.ajax({url:"getFileUploadUrl",data:"path="+this.folder+"&forIframe=true",async:false,success:function(a){b=a}});return b},_createIFrame:function(){return a('<iframe src="javascript:false;" name="iframe" style="display:none" />').appendTo("body")},_getIframeContentJSON:function(a){try{if(!a.parentNode)return;if(a.contentDocument&&a.contentDocument.body&&a.contentDocument.body.innerHTML=="false")return;var d=a.contentDocument?a.contentDocument:a.contentWindow.document,c=this._parseResponse(d.body.innerHTML);return{success:true,parsed:c}}catch(e){jerror()}return{success:false,parsed:b}},_parseResponse:function(a){try{var b=eval("("+a+")")}catch(c){throw"Error in file processing at server side:"+a;}return b}});FileInputUntils=function(){};a.extend(FileInputUntils.prototype,{getPath:function(a){var b=a.fullPath;if(b){b=b.trimStart("/");return b.replace(/\//g,"\\")}return a.fileName||a.name||a.value},getName:function(a){return Container.Resolve("PathProvider").getName(this.getPath(a))},getSize:function(a){return a.fileSize!=null?a.fileSize:a.size}});a.handlerFactory=new HandleFactory;a.fileInputUtils=new FileInputUntils})(jQuery);(function(a){a.widget("ui.zooming",{options:{zoomValues:[5,15,25,50,75,100,125,150,175,200,300,400,600]},_viewModel:null,_create:function(){this.options.createHtml&&this._createHtml();this._viewModel=this.getViewModel();ko.applyBindings(this._viewModel,this.element.get(0));a(this._viewModel).bind("onSetZoom",function(c,b){a(this.element).trigger("onSetZoom",[b])}.bind(this));a(this._viewModel).bind("zoomSet.groupdocs",function(b,a){this.element.trigger("zoomSet.groupdocs",[a])}.bind(this))},getViewModel:function(){if(this._viewModel)return this._viewModel;var b=a.extend({element:this.element},this.options),c=new zoomingViewModel(b);return c},_createHtml:function(){var b=this.element;this.element=a('<div class="left">    <a class="new_head_tools_btn h_t_i_zoomin" href="#" data-bind="click: zoomIn" data-tooltip="Zoom In" data-localize-tooltip="ZoomIn"> </a>    <a class="new_head_tools_btn h_t_i_zoomout" href="#" data-bind="click: zoomOut" data-tooltip="Zoom Out" data-localize-tooltip="ZoomOut"> </a>    <div class="new_head_tools_dropdown_wrapper">        <a class="new_head_tools_btn head_tool_dropdown_btn h_t_i_zoom" href="#" data-bind="click: toggleDropDownMenu" data-tooltip="Zoom Level" data-localize-tooltip="ZoomLevel">        </a>        <ul class="dropdown-menu head_tool_dropdown" style="display: none;" data-bind="style: {display: (dropDownMenuIsVisible() ? \'block\' : \'none\')}, foreach: zooms">            <li>                <a href="#" data-bind="text: name, event: { mousedown: function(item, e) { $parent.setZoom(item, e); } }, attr: {\'data-localize\': $data.localizationKey }"></a>            </li>        </ul>    </div></div>').appendTo(b);b.trigger("onHtmlCreated")}});zoomingModel=function(){};zoomingViewModel=function(b){a.extend(this,b);this._init(b)};a.extend(zoomingViewModel.prototype,{_model:null,zooms:null,_currentZoom:null,_currentZoomIndex:0,dropDownMenuIsVisible:null,dropDownMenuClicked:false,_init:function(c){this._currentZoom=ko.observable(100);this.zooms=ko.observableArray([]);this.dropDownMenuIsVisible=ko.observable(false);for(var a,b=c.zoomValues.length-1;b>=0;b--){a=c.zoomValues[b];this.zooms.push({name:a.toString()+"%",value:a});if(a==this._currentZoom())this._currentZoomIndex=this.zooms().length-1}this.setFitWidthZoom(100);this.setFitHeightZoom(100)},setFitWidthZoom:function(b){for(var d={name:"Fit Width",value:b,localizationKey:"FitWidth",fitWidth:true},c=false,a=0;a<this.zooms().length;a++)if(this.zooms()[a].fitWidth){this.zooms()[a].value=b;c=true;break}!c&&this.zooms.push(d)},setFitHeightZoom:function(b){for(var d={name:"Fit Height",value:b,localizationKey:"FitHeight",fitHeight:true},c=false,a=0;a<this.zooms().length;a++)if(this.zooms()[a].fitHeight){this.zooms()[a].value=b;c=true;break}!c&&this.zooms.push(d)},getZoom:function(){return this._currentZoom()},getFitWidthZoomValue:function(){for(var a,b=0;b<this.zooms().length;b++){a=this.zooms()[b];if(a.fitWidth)return a.value}},getFitHeightZoomValue:function(){for(var a,b=0;b<this.zooms().length;b++){a=this.zooms()[b];if(a.fitHeight)return a.value}},setZoom:function(d){var b=d.value,c=this._indexOfZoom(b);this._currentZoom(b);if(c>=0)this._currentZoomIndex=c;else this._currentZoomIndex=this._indexOfNearestZoom(b,false);a(this).trigger("onSetZoom",b);a(this).trigger("zoomSet.groupdocs",b)},setZoomWithoutEvent:function(b){var a=this._indexOfZoom(b);if(a>=0){this._currentZoom(b);this._currentZoomIndex=a}},zoomIn:function(){var c=false,b=this._currentZoomIndex;if(this._isFitToBounds()){b=this._indexOfNearestZoom(this.zooms()[this._currentZoomIndex].value,true);c=b>=0}else if(this._currentZoomIndex>0){b=this._currentZoomIndex-1;c=true}if(c){this._currentZoomIndex=b;this._currentZoom(this.zooms()[this._currentZoomIndex].value);a(this).trigger("onSetZoom",this._currentZoom());a(this).trigger("zoomSet.groupdocs",this._currentZoom())}},zoomOut:function(){var c=false,b=this._currentZoomIndex;if(this._isFitToBounds()){b=this._indexOfNearestZoom(this.zooms()[this._currentZoomIndex].value,false);c=b>=0}else if(this._currentZoomIndex<this.zooms().length-1&&!(this.zooms()[this._currentZoomIndex+1].fitWidth||this.zooms()[this._currentZoomIndex+1].fitHeight)){b=this._currentZoomIndex+1;c=true}if(c){this._currentZoomIndex=b;this._currentZoom(this.zooms()[this._currentZoomIndex].value);a(this).trigger("onSetZoom",this._currentZoom());a(this).trigger("zoomSet.groupdocs",this._currentZoom())}},_indexOfZoom:function(a){for(i=0;i<this.zooms().length;i++)if(this.zooms()[i].value==a)return i;return-1},_indexOfNearestZoom:function(g,j){var h=this.zooms().length-1,e=null,c=null,f=null,d=null,a,b;for(i=h;i>=0;i--){b=this.zooms()[i];a=b.value;if(!b.fitWidth&&!b.fitHeight)if(a>g&&(e===null||a<e)){e=a;c=i}else if(a<g&&(f===null||a>f)){f=a;d=i}}return j?c===null?-1:c:d===null?-1:d},_isFitToBounds:function(){return this.zooms()[this._currentZoomIndex].fitWidth||this.zooms()[this._currentZoomIndex].fitHeight},showDropDownMenu:function(a){this.dropDownMenuIsVisible(a)},toggleDropDownMenu:function(b,a){this.dropDownMenuIsVisible(!this.dropDownMenuIsVisible());this.dropDownMenuClicked=true;this.element.trigger("onMenuClicked");a.stopPropagation()}})})(jQuery);(function(a){a.widget("ui.docViewerPageFlip",{_viewModel:null,options:{fileId:0,fileVersion:1,userId:0,userKey:null,baseUrl:null,_mode:"full",_docGuid:"",quality:null,use_pdf:"true"},_create:function(){a.extend(this.options,{emptyImageUrl:"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNgYAAAAAMAASsJTYQAAAAASUVORK5CYII="});this.options.createHtml&&this._createHtml();this.options.documentSpace=this.element;this._viewModel=this.getViewModel();ko.applyBindings(this._viewModel,this.element.get(0))},_init:function(){a(this._viewModel).bind("getPagesCount",function(c,b){a(this.element).trigger("getPagesCount",[b])}.bind(this));a(this._viewModel).bind("onDocumentLoaded",function(){a(this.element).trigger("onDocumentLoaded")}.bind(this));a(this._viewModel).bind("_onProcessPages",function(c,b){a(this.element).trigger("_onProcessPages",[b])}.bind(this));a(this._viewModel).bind("onProcessPages",function(c,b){a(this.element).trigger("onProcessPages",[b])}.bind(this));a(this._viewModel).bind("onScrollDocView",function(c,b){a(this.element).trigger("onScrollDocView",[b])}.bind(this));a(this._viewModel).bind("onDocumentLoadComplete",function(c,b){a(this.element).trigger("onDocumentLoadComplete",[b])}.bind(this));a(this._viewModel).bind("onSearchPerformed",function(c,b){a(this.element).trigger("onSearchPerformed",[b])}.bind(this));a(this._viewModel).bind("onPageTurned",function(c,b){a(this.element).trigger("onPageTurned",[b])}.bind(this))},getViewModel:function(){if(this._viewModel==null)this._viewModel=this._createViewModel();return this._viewModel},_createViewModel:function(){return new docViewerPageFlipViewModel(this.options)},applyBindings:function(){ko.applyBindings(this._viewModel,this.element.get(0))},_createHtml:function(){var c='<div id="'+this.options.docViewerId+'_page_flip" class="doc_viewer_flip" data-bind="event: { scroll: function(item, e) { this.ScrollDocView(item, e); }, scrollstop: function(item, e) { this.ScrollDocViewEnd(item, e); } }">    <a class="page_prev" href="#" style="height: 100%" data-bind="click: previousBroadside"></a>    <a class="page_next" href="#" style="height: 100%" data-bind="click: nextBroadside"></a>    <div class="bookCovers" style="display: none">        <div class="hard hard_ie9 page">            <a class="page_next2 first_page_link" href="#">                <h1 class="ellipses" data-bind="text: documentName(), ellipsis: true" style="max-width: 700px;"></h1>            </a>        </div>        <div class="hard hard_ie9 page"></div>    </div>    <div style="overflow: hidden;">        <div class="pages_container_flip page_flip_layout">            <!-- ko foreach: pages -->                <div class="doc-page" data-bind="attr: {id: $root.pagePrefix + number}, style: { width: $root.pageWidth() + \'px\', height: $root.pageHeight() + \'px\' }">                     <div>                        <div class="button-pane"></div>                        <div class="highlight-pane"></div>                        <div class="custom-pane"></div>                        <div class="search-pane"></div>                        <img class="page-image page_image_flip" src="'+this.options.emptyImageUrl+"\" data-bind=\"attr: { id: $root.docViewerId +  '_page_flip-img-' + number, src: (visible() ? url : $root.emptyImageUrl) },                                                                         style: { width: $root.pageWidth() + 'px', height: $root.pageHeight() + 'px' }\"/>                    </div>                </div>            <!-- /ko -->        </div>    </div></div>",b=this.element;this.element=a(c).appendTo(b);b.trigger("onHtmlCreated")}});var b=function(b){a.extend(this,b);this._init()};a.extend(b.prototype,{_init:function(){this._portalService=Container.Resolve("PortalService")},loadDocument:function(c,e,d,b,a){switch(this._mode){case"embed":this._portalService.viewEmbedDocumentAllAsync(this.userId,this.userKey,c,d,this.quality,this.use_pdf,-1,null,function(c){if(c.data!=null&&typeof c.data.guid!=="undefined")b.apply(this,[c.data]);else a.apply(this,[{}])},function(b){a.apply(this,[b])});break;case"embedlite":this._portalService.viewDocumentAllAsync(this.userId,this.userKey,c,null,null,null,null,this.quality,this.use_pdf,function(c){if(typeof c.data.guid!=="undefined")b.apply(this,[c.data]);else a.apply(this)},function(b){a.apply(this,[b])},false);break;default:this._portalService.viewDocumentAllAsync(this.userId,this.userKey,c,null,e,d,null,this.quality,this.use_pdf,function(c){if(c.data&&typeof c.data.guid!=="undefined")b.apply(this,[c.data]);else a.apply(this)},function(b){a.apply(this,[b])},false)}},loadProperties:function(b,a){this._portalService.getDocInfoAsync(this.userId,this.userKey,b,function(b){a.apply(this,[b.data])})},retrieveImageUrls:function(e,c,a,f,d,b){this._portalService.getImageUrlsAsync(this.userId,this.userKey,e,a,f,0,c,this.quality==null?"":this.quality,this.use_pdf,this.fileVersion,function(a){d.apply(this,[a.data])},function(a){b.apply(this,[a])})}});window.docViewerPageFlipViewModel=function(b){a.extend(this,b);this._create(b)};a.extend(window.docViewerPageFlipViewModel.prototype,{_model:null,pagesDimension:null,pageImageWidth:568,imageHorizontalMargin:34,initialZoom:100,zoom:null,scale:null,docWasLoadedInViewer:false,scrollPosition:[0,0],inprogress:null,pages:null,pageInd:null,pageWidth:null,pageHeight:null,pageCount:null,docType:null,fileId:null,_dvselectable:null,_thumbnailHeight:140,_firstPage:null,imageUrls:[],pagePrefix:"page-flip-",documentName:null,fit90PercentWidth:false,_pageBounds:null,changedUrlHash:false,bookWidth:0,pagingBarWidth:30,turnPageWithoutEvent:false,minimumImageWidth:null,_create:function(a){this._model=new b(a);this._init(a)},_init:function(a){this.pages=ko.observableArray([]);this.scale=ko.observable(this.initialZoom/100);this.zoom=ko.observable(this.initialZoom);this.inprogress=ko.observable(false),this.pageLeft=ko.observable(0);this.pageInd=ko.observable(1);this.pageWidth=ko.observable(0);this.pageHeight=ko.observable(0);this.pageCount=ko.observable(0);this.docType=ko.observable(-1);this.documentName=ko.observable("");if(!this.docViewerId)this.docViewerId=this.documentSpace.attr("id");this.pagePrefix=this.docViewerId+"-page-flip-";if(a.fit90PercentWidth)this.pageImageWidth=this.documentSpace.width()*.9-2*this.imageHorizontalMargin;this.pagesDimension=Math.floor(this.pageImageWidth).toString()+"x";this.pages().length==0&&this.pages.push({number:1,visible:ko.observable(false),url:ko.observable(this.emptyImageUrl)})},loadDocument:function(a){this.inprogress(true);if(typeof a!=="undefined")this.fileId=a;this.docWasLoadedInViewer=false;var b=1;this._model.loadDocument(this.fileId,b,this.pageImageWidth,function(a){this._onDocumentLoaded(a)}.bind(this),function(a){this._onError(a)}.bind(this));typeof viewModelPathOnlineDoc!=="undefined"&&viewModelPathOnlineDoc.pathOnlineDoc("")},retrieveImageUrls:function(d){var a,c,b;if(this.shouldMinimumWidthBeUsed(this.pageWidth(),true))b=this.minimumImageWidth;else b=this.pageWidth();c=Math.floor(b)+"x";this._model.retrieveImageUrls(this.fileId,d,this._mode=="webComponent"?Math.floor(b):c,this.token,function(e){var b;for(a=0;a<d;a++){this.pages()[a].url(e.image_urls[a]);b=a+1;var c=this.setImageElementSize(b,this.pageWidth(),this.pageHeight());c.attr("src",this.pages()[b-1].url())}this.loadImagesForVisiblePages()}.bind(this),function(a){this._onError(a)}.bind(this))},_onError:function(a){this.inprogress(false);jerror(a.Reason||"The document couldn't be loaded...")},_onDocumentLoaded:function(c,k){a(this).trigger("onDocumentLoaded");this.fileId=c.guid;this.docGuid=c.guid;this.documentName(c.name);this.docType(c.doc_type);this.pageCount(c.page_count);this.token=c.token;a(this).trigger("getPagesCount",c.page_count);a(this).trigger("_onProcessPages",c);var h=null;if(this.use_pdf!="false"){this._pdf2XmlWrapper=k;h=this._pdf2XmlWrapper.getPageSize()}this.pagesContainerElement=this.documentSpace.find("div.pages_container_flip");this.heightWidthRatio=parseFloat(c.page_size.Height/c.page_size.Width);var e;if(this.viewerWidth)e=this.viewerWidth;else e=this.documentSpace.parent().width();this.pageWidth((e-this.pagingBarWidth*2)/2);this.pageHeight(Math.round(this.pageWidth()*this.heightWidthRatio));if(this._dvselectable){var f=this._dvselectable.data("ui-dvselectable");if(!f)f=this._dvselectable.data("dvselectable");f.destroy()}this.pagesContainerElement.turn("is")&&this.pagesContainerElement.turn("destroy");this.pagesContainerElement.height(this.pageHeight());this.inprogress(false);for(var g=this.pageCount(),j=[],d=1;d<=g;d++)j.push({number:d,visible:ko.observable(false),url:ko.observable(this.emptyImageUrl)});this.pages(j);this._firstPage=this.pagesContainerElement.find("#"+this.pagePrefix+"1");a(this).trigger("onProcessPages",[this.docGuid]);for(d=0;d<c.image_urls.length&&d<this.pages().length;d++)this.pages()[d].url(c.image_urls[d]);!this.zoomToFitHeight&&this.loadImagesForVisiblePages();this.initialWidth=this.pageWidth();h!=null&&this.scale(this.initialWidth/h.width);var i=Math.floor(this.pagesContainerElement.width()/this._firstPage.width());if(i==0)i=1;this._dvselectable=this.pagesContainerElement.dvselectable({txtarea:this.selectionContent,pdf2XmlWrapper:this._pdf2XmlWrapper,startNumbers:this.getVisiblePagesNumbers(),pagesCount:this.pageCount(),proportion:this.scale(),disabled:this.use_pdf=="true"?false:true,pageHeight:this.getPageHeight(),horizontalPageCount:i,docSpace:this.documentSpace,bookLayout:true,pagePrefix:this.pagePrefix});this._dvselectable.dvselectable("setVisiblePagesNumbers",this.getVisiblePagesNumbers());this.docWasLoadedInViewer=true;this.documentSpace.find("div.bookCovers > div:first").clone().prependTo(this.pagesContainerElement);this.documentSpace.find("div.bookCovers > div:last").clone().appendTo(this.pagesContainerElement);this.setPage(1,true,true);var b=this;this.pagesContainerElement.turn({elevation:50,acceleration:true,gradients:true,autoCenter:true,duration:1e3,width:e-this.pagingBarWidth*2,height:this.pageHeight()});this.pagesContainerElement.bind("turning",function(d,c){var f=a(this),e=f.turn("pages");if(c>e){d.preventDefault();return}c=c-1;b.setImageElementSize(c-1,b.pageWidth(),b.pageHeight());b.setPage(c-1,true);b.setImageElementSize(c,b.pageWidth(),b.pageHeight());b.setPage(c,true,true);b.setImageElementSize(c+1,b.pageWidth(),b.pageHeight());b.setPage(c+1,true);b.setImageElementSize(c+2,b.pageWidth(),b.pageHeight());b.setPage(c+2,true)});this.pagesContainerElement.bind("turned",function(h,c){c=c-1;b.setImageElementSize(c-1,b.pageWidth(),b.pageHeight());b.setPage(c-1,true);b.setImageElementSize(c,b.pageWidth(),b.pageHeight());b.setPage(c,true);b.setImageElementSize(c+1,b.pageWidth(),b.pageHeight());b.setPage(c+1,true);b.setImageElementSize(c+2,b.pageWidth(),b.pageHeight());b.setPage(c+2,true);if(b._dvselectable){var e=b.getVisiblePagesNumbers(),d=2;if(c==g)d=1;b._dvselectable.dvselectable("reInitPages",b.scale(),e,b.scrollPosition,b.getPageHeight(),d)}var f=a(this);f.turn("center");!b.turnPageWithoutEvent&&c>0&&c<=g&&a(this).trigger("onPageTurned",c);b.turnPageWithoutEvent=false});this.documentSpace.width(this.pagesContainerElement.width());this.zoomToFitHeight&&this.setZoom(this.getFitHeightZoom());a(this).trigger("onDocumentLoadComplete",[c])},setDimension:function(a){this.pagesDimension=a+"x"},setPageWidth:function(a){this.pageImageWidth=a},getFitWidthZoom:function(){var a;if(this.viewerWidth)a=this.viewerWidth;else a=this.documentSpace.parent().width();return a/((this.initialWidth+this.pagingBarWidth)*2)*100},getFitHeightZoom:function(){var a;if(this.viewerHeight)a=this.viewerHeight;else a=this.documentSpace.parent().height();return a/Math.round(this.initialWidth*this.heightWidthRatio)*100},getPageHeight:function(){return this.unscaledPageHeight*this.scale()},getSelectable:function(){return this._dvselectable},_onPropertiesLoaded:function(b){a(this).trigger("onDocumentLoaded",{fileId:this.fileId,response:b})},getFileId:function(){return this.fileId},ScrollDocView:function(){return},ScrollDocViewEnd:function(){return},getVisiblePagesNumbers:function(){var c,b,a=this.pageInd();if(a%2==1){c=a;b=a+1}else{c=a-1;b=a}var d=this.pageCount();if(b>d)b=d;return{start:c,end:b}},loadImagesForVisiblePages:function(){for(var a=this.getVisiblePagesNumbers(),c=a.start,d=a.end,b=c;b<=d;b++)this.pages()[b-1].visible(true);return a},setPage:function(i,g,h){var e=this.pageCount(),b=Number(i);if(b>e)b=e;if(isNaN(b)||b<1)b=1;var c;if(this.pageInd()<b)c="up";else c="down";this.pages()[b-1].visible(true);if(this.pagesContainerElement){var d=this.pagesContainerElement.find("#"+this.pagePrefix+b.toString()+" img.page-image"),f=this.pages()[b-1].url();d.attr("src")!=f&&d.attr("src",f);if(!g&&this.documentSpace.is(":visible")){this.turnPageWithoutEvent=true;this.pagesContainerElement.turn("page",b+1)}if(h){this.pageInd(b);a(this).trigger("onScrollDocView",{pi:b,direction:c})}}},setImageElementSize:function(d,c,b){var a=this.pagesContainerElement.find("#"+this.pagePrefix+d.toString()+" img.page-image");a.width()!=c&&a.width(c);a.height()!=b&&a.height(b);return a},previousBroadside:function(){var e=this.pagesContainerElement.turn("page"),c=e-1,d=this.pageCount(),b;if(c==0||c>d)b=c-2;else b=this.pageInd()-2;if(b<1)b=1;this.setPage(b,true);this.turnPageWithoutEvent=true;this.pagesContainerElement.turn("previous");this.pageInd(b);b>0&&b<=d&&a(this).trigger("onPageTurned",b)},nextBroadside:function(){var e=this.pagesContainerElement.turn("page"),d=e-1,c=this.pageCount(),b;if(d==0||d>c)b=d+2;else b=this.pageInd()+2;if(b>c)b=c;this.setPage(b,true);this.turnPageWithoutEvent=true;this.pagesContainerElement.turn("next");this.pageInd(b);b>0&&b<=c&&a(this).trigger("onPageTurned",b)},setZoom:function(c){this.zoom(c);if(this.isPageFlipViewerVisible()){this.loadPagesZoomed();if(this._pdf2XmlWrapper){var e=this._pdf2XmlWrapper.getPageSize();this.scale(this.initialWidth/e.width*c/100)}this.pagesContainerElement.width(this.pageWidth()*2);this.pagesContainerElement.height(this.pageHeight());this.documentSpace.width(this.pageWidth()*2);this.pagesContainerElement.turn("size",this.pagesContainerElement.width(),this.pagesContainerElement.height());var b=this.pagesContainerElement.find("img.page_image_flip");b.width(this.pageWidth());b.height(this.pageHeight());this.resizeViewerElement(this.viewerLeft);this._dvselectable.dvselectable("changeSelectedRowsStyle",this.scale());var d=this.getVisiblePagesNumbers(),a=Math.floor(this.pagesContainerElement.width()/this._firstPage.width());if(a==0)a=1;this._dvselectable.dvselectable("reInitPages",this.scale(),d,this.scrollPosition,this.pageWidth()*this.heightWidthRatio,a)}},loadPagesZoomed:function(){var a=this.initialWidth*this.zoom()/100>>0,b=a*this.heightWidthRatio>>0;this.pagesDimension=a+"x";this.pageWidth(a);this.pageHeight(b);var c=this.pageCount();this.setPage(this.pageInd());!this.shouldMinimumWidthBeUsed(a,true)&&this.retrieveImageUrls(c)},performSearch:function(c){var b=this._dvselectable.dvselectable("performSearch",c,this.zoom()/100);a(this).trigger("onSearchPerformed",[b])},selectTextInRect:function(b){this._dvselectable&&a(this._dvselectable).dvselectable("highlightPredefinedArea",b)},deselectTextInRect:function(c,b){this._dvselectable&&a(this._dvselectable).dvselectable("unhighlightPredefinedArea",c,b)},reInitSelectable:function(){var a=this.getVisiblePagesNumbers();this._dvselectable!=null&&this._dvselectable.dvselectable("reInitPages",this.scale(),a,this.scrollPosition,this.getPageHeight())},onDocumentPageSet:function(a){this.pageInd(a);this.isPageFlipViewerVisible()&&this.openCurrentPage()},openCurrentPage:function(){this.pagesContainerElement&&this.setPage(this.pageInd())},isPageFlipViewerVisible:function(){return this.documentSpace.is(":visible")},shouldMinimumWidthBeUsed:function(d,b){var a=null;if(this.use_pdf!="false"&&b){var c=this._pdf2XmlWrapper.getPageSize();a=c.width}return this.minimumImageWidth!=null&&(d<=this.minimumImageWidth||a!==null&&a<this.minimumImageWidth)},resizeViewerElement:function(a){var b=this.documentSpace.parent(),e=b.width(),d=b.parent(),c=d.width();if(typeof a=="undefined")a=0;else this.viewerLeft=a;b.width(c-a);this.reInitSelectable();this.loadImagesForVisiblePages()}})})(jQuery);(function(a,b){a.widget("ui.search",{_viewModel:null,options:{isCaseSensitive:false,searchForSeparateWords:false},_create:function(){a.extend(this.options,{element:this.element});this.options.createHtml&&this._createHtml();this._viewModel=this.getViewModel();ko.applyBindings(this._viewModel,this.element.get(0))},_init:function(){},getViewModel:function(){if(this._viewModel==null)this._viewModel=this._createViewModel();return this._viewModel},_createViewModel:function(){return new c(this.options)},applyBindings:function(){ko.applyBindings(this._viewModel,this.element.get(0))},_createHtml:function(){var c='<input type="text" placeholder="Search" class="input_search" data-localize-ph="Search" data-bind="visible: visible, attr: {dir: useRtl ? \'rtl\' : \'ltr\'}, value: searchValue, valueUpdate: [\'afterkeydown\', \'propertychange\', \'input\'], event: { keypress: keyPressed, keydown: keyDown }"><span class="input_search_clear" data-bind="visible: visible, click: function(){$root.clearValue();}, clickBubble: false"></span><span class="new_head_tools_btn h_t_i_nav2" data-bind="visible: visible, click: findPreviousFromUI, css:{disabled:!previousEnabled()}" data-tooltip="Search Backward" data-localize-tooltip="SearchBackward"></span><span class="new_head_tools_btn h_t_i_nav3" data-bind="visible: visible, click: findNextFromUI, css:{disabled:!nextEnabled()}" data-tooltip="Search Forward" data-localize-tooltip="SearchForward"></span>',b=this.element;a(c).appendTo(b);b.trigger("onHtmlCreated")}});var d=function(b){a.extend(this,b);this._init()};a.extend(d.prototype,{_init:function(){}});var c=function(b){a.extend(this,b);this._create(b)};a.extend(c.prototype,{searchValue:null,previousEnabled:null,nextEnabled:null,minAreaTopRelativeToBeginning:null,maxAreaTopRelativeToBeginning:null,searched:false,viewerIsScrolled:false,searchForward:false,closestArea:null,newHighlightedAreaFirstWordLeftRelative:0,newHighlightedAreaLastWordLeftRelative:0,highlightAreas:null,sible:null,useHtmlBasedEngine:false,useCaseSensitiveSearch:false,useAccentInsensitiveSearch:false,viewerViewModel:null,pageNumberAttribute:"data-page-num",useRtl:false,searchPageAfterScrollingToIt:null,hitsOnAllPagesAreFound:false,_create:function(a){this._model=new d(a);this._init(a)},_init:function(){this.searchValue=ko.observable("");this.previousEnabled=ko.observable(true);this.nextEnabled=ko.observable(true);this.visible=ko.observable(this.searchIsVisible)},triggerSearchEvent:function(e,d,b,c){var a=this.searchValue();!this.searched&&this.element.trigger("onPerformSearch",[a,e,d,b,c]);if(a==="")this.searched=false;else this.searched=true;return false},findClosestArea:function(e,I,H,G,bb,y){var W=this.searched;this.triggerSearchEvent(I,H,G,bb);var t=false,z=null,ab=null,Y=null,s="current_search_highlight",j=null,hb,J,x,v,l,r;J=this.viewerViewModel.getVisiblePagesNumbers();x=J.start-1;v=J.end-1;if(this.useHtmlBasedEngine){if(this.useVirtualScrolling&&this.isWaitingForPageOpening&&y===b)return;this.isWaitingForPageOpening=false;if(this.highlightAreas==null||!this.hitsOnAllPagesAreFound||!W){this.highlightAreas=this.viewerElement.find(".search_highlight_html");this.hitsOnAllPagesAreFound=true;r=this.viewerViewModel.pageCount();for(var N=0;N<r;N++)if(!this.viewerViewModel.isPageVisible(N)){this.hitsOnAllPagesAreFound=false;break}this.hitsOnAllPagesAreFound&&this.sortHighlightedAreas(this.highlightAreas)}if(this.useVirtualScrolling&&y!==b)this.highlightAreas=this.highlightAreas.filter("[data-page-num="+y+"]")}else if(this.highlightAreas==null||!W){this.highlightAreas=this.viewerElement.find(".search-pane > .search-highlight");this.sortHighlightedAreas(this.highlightAreas)}var Q=this.highlightAreas;this.currentHighlightArea=this.highlightAreas.filter("."+s+",tspan[class*='"+s+"']");var d=null;if(this.currentHighlightArea.length>0){if(this.currentHighlightArea.is("[name*='search_highlight']")){j=this.currentHighlightArea.attr("name");this.currentHighlightArea=Q.filter("[name='"+j+"']");this.sortHighlightedAreas(this.currentHighlightArea)}t=true;z=this.currentHighlightArea.offset().left;ab=this.currentHighlightArea.offset().top;Y=this.currentHighlightArea.height()}if(!this.pagesContainerElement)this.pagesContainerElement=this.viewerElement.find(".pages_container");var o=this.pagesContainerElement.offset().top,u=this.pagesContainerElement.offset().left,p,eb=this.viewerElement.scrollTop(),R=this.getScrollTop(eb);if(!R.isCurrentlyHighlightedAreaVisible)t=false;p=Math.floor(R.scrollTop);var D=0,A=null,F,g,f=0,m=0,n=0;this.minAreaTopRelativeToBeginning=null;this.maxAreaTopRelativeToBeginning=null;this.minAreaLeftRelativeToBeginning=null;this.maxAreaLeftRelativeToBeginning=null;var M,L,B,K=true,c=this;if(this.useVirtualScrolling&&y!==b){this.sortHighlightedAreas(this.highlightAreas);if(e)d=this.highlightAreas.first();else d=this.highlightAreas.last();m=d.offset().top-o;d=d.get(0)}else{var h;this.highlightAreas.each(function(k){if(t&&(!c.useHtmlBasedEngine||c.hitsOnAllPagesAreFound))if(this===c.currentHighlightArea.get(0)){var b;if(e){b=k+1;if(j!==null)for(;b<c.highlightAreas.length;b++)if(j!=a(c.highlightAreas.get(b)).attr("name"))break}else{b=k-1;if(j!==null)for(;b>=0;b--)if(j!=a(c.highlightAreas.get(b)).attr("name"))break}if(b>=c.highlightAreas.length)d=c.highlightAreas.slice(k,b);else if(b<0)d=c.highlightAreas.slice(0,k+1);else d=c.highlightAreas.get(b);h=a(d);F=h.offset().top;f=Math.floor(F-o);g=h.offset().left;n=g-u;m=f;var l=a(c.highlightAreas.get(0)).offset(),q=a(c.highlightAreas.get(c.highlightAreas.length-1)).offset();c.minAreaTopRelativeToBeginning=l.top-o;c.maxAreaTopRelativeToBeginning=q.top-o;c.minAreaLeftRelativeToBeginning=l.left-u;c.maxAreaLeftRelativeToBeginning=q.left-u;return false}else return true;h=a(this);if(c.useHtmlBasedEngine&&t&&j==h.attr("name"))return;F=h.offset().top;f=Math.floor(F-o);g=h.offset().left;n=g-u;if(c.minAreaTopRelativeToBeginning==null||f==c.minAreaTopRelativeToBeginning&&n<c.minAreaLeftRelativeToBeginning)c.minAreaLeftRelativeToBeginning=n;if(c.maxAreaTopRelativeToBeginning==null||f==c.maxAreaTopRelativeToBeginning&&n>c.maxAreaLeftRelativeToBeginning)c.maxAreaLeftRelativeToBeginning=n;if(c.minAreaTopRelativeToBeginning==null||f<c.minAreaTopRelativeToBeginning){c.minAreaTopRelativeToBeginning=f;c.minAreaLeftRelativeToBeginning=n}if(c.maxAreaTopRelativeToBeginning==null||f>c.maxAreaTopRelativeToBeginning){c.maxAreaTopRelativeToBeginning=f;c.maxAreaLeftRelativeToBeginning=n}if(t){var r=Math.abs(f-p);if(r<1){B=Math.abs(g-z);if(B>=1&&(e&&g>z||!e&&g<z)&&(B<A||A===null)){d=h;A=B;m=f;K=false}}}if(A===null&&(e&&f>p||!e&&f<p)){var i=Math.abs(f-p);if(i>=1)if(i<D&&D-i>=1||K){d=h;D=i;m=f;K=false;if(e)M=g;else L=g}else if(Math.abs(i-D)<1){if(e&&g<M){M=g;d=h;m=f}if(!e&&g>L){L=g;d=h;m=f}}}})}var k,i;if(this.useHtmlBasedEngine&&this.useVirtualScrolling&&!d&&y===b){var S=this.viewerViewModel.pages(),T;if(e){l=this.viewerViewModel.lastVisiblePageForVirtualMode()+1;k=1}else{l=this.viewerViewModel.firstVisiblePageForVirtualMode()-1;k=-1}for(var w=l;e&&w<S.length||!e&&w>=0;w+=k){var X=S[w];if(X.parsedHtmlElement){T=X.parsedHtmlElement.find(".search_highlight_html");if(T.length>0){this.searchPageAfterScrollingToIt={searchForward:e,pageNumber:w};this.viewerViewModel.setPage(w+1);return}}}}var O=null,P=null;if(d){var C=a(d),q=parseInt(C.attr(this.pageNumberAttribute));r=q;if(q>v){l=v;k=1}else{l=x;k=-1}var U=true;if(this.useHtmlBasedEngine&&q!==null&&!(q>=x&&q<=v))for(i=l;i!=r;i+=k)if(!this.viewerViewModel.isPageVisible(i)){this.loadPagesOnOneLevel(i,e,I,H,G);U=false;break}if(U){if(C.is("[name*='search_highlight']")){j=C.attr("name");d=Q.filter("[name='"+j+"']")}else d=C;this.sortHighlightedAreas(d);var cb=e?d.length-1:0,db=a(d[cb]).offset().top,Z=db-o;O=a(d[0]).offset().left;this.newHighlightedAreaFirstWordLeftRelative=O-u;P=a(d[d.length-1]).offset().left;this.newHighlightedAreaLastWordLeftRelative=P-u;p=Z;m=a(d[0]).offset().top-o;this.viewerElement[0].scrollTop=m;this.viewerIsScrolled=true;this.viewerElement.trigger("ScrollDocView",[null,{target:this.viewerElement[0]}]);this.viewerElement.trigger("ScrollDocViewEnd",[null,{target:this.viewerElement[0]}]);this.viewerIsScrolled=false;o=this.pagesContainerElement.offset().top;var E,V;if(this.currentHighlightArea.is("tspan")){E=this.currentHighlightArea.attr("class");V=E.replace(new RegExp("\\b"+s+"\\b"),"");this.currentHighlightArea.attr("class",V)}else this.currentHighlightArea.removeClass(s);if(d.is("tspan")){E=d.attr("class");d.attr("class",E+" "+s)}else d.addClass(s)}}else{if(e){k=1;l=v;r=this.viewerViewModel.pageCount()}else{k=-1;l=x;r=-1}if(this.useHtmlBasedEngine&&!(q>=x&&q<=v))for(i=l;i!=r;i+=k)if(!this.viewerViewModel.isPageVisible(i)){this.loadPagesOnOneLevel(i,e,I,H,G);break}}this.searchForward=e;if(!d&&t)d=this.currentHighlightArea;this.closestArea=d;var fb=this.isPreviousEnabled(p);this.previousEnabled(fb);var gb=this.isNextEnabled(p);this.nextEnabled(gb)},isPreviousEnabled:function(c){if(this.useHtmlBasedEngine&&!this.hitsOnAllPagesAreFound)return true;var a=this.getScrollTop(c).scrollTop,b=this.minAreaTopRelativeToBeginning!=null&&(Math.floor(a)>Math.ceil(this.minAreaTopRelativeToBeginning)||Math.abs(a-this.minAreaTopRelativeToBeginning)<1&&this.newHighlightedAreaFirstWordLeftRelative!==null&&this.newHighlightedAreaFirstWordLeftRelative>this.minAreaLeftRelativeToBeginning);return!this.searched||b},isNextEnabled:function(c){if(this.useHtmlBasedEngine&&!this.hitsOnAllPagesAreFound)return true;var a=this.getScrollTop(c).scrollTop,b=this.maxAreaTopRelativeToBeginning!=null&&(Math.ceil(a)<Math.floor(this.maxAreaTopRelativeToBeginning)||Math.abs(a-this.maxAreaTopRelativeToBeginning)<1&&this.newHighlightedAreaLastWordLeftRelative!==null&&this.newHighlightedAreaLastWordLeftRelative<this.maxAreaLeftRelativeToBeginning);return!this.searched||b},findPreviousFromUI:function(){this.findPrevious(this.isCaseSensitive,this.searchForSeparateWords,this.treatPhrasesInDoubleQuotesAsExactPhrases,this.useAccentInsensitiveSearch)},findNextFromUI:function(){this.findNext(this.isCaseSensitive,this.searchForSeparateWords,this.treatPhrasesInDoubleQuotesAsExactPhrases,this.useAccentInsensitiveSearch)},findPrevious:function(d,c,a,b){this.searchValue()!=""&&this.findClosestArea(false,d,c,a,b)},findNext:function(d,c,a,b){this.searchValue()!=""&&this.findClosestArea(true,d,c,a,b)},clearValue:function(){this.searchValue("");this.resetButtons();this.triggerSearchEvent()},resetButtons:function(){this.previousEnabled(true);this.nextEnabled(true);this.searched=false;this.highlightAreas=null},keyDown:function(b,a){(a.keyCode==8||a.keyCode==46)&&b.keyHandler(a.keyCode);return true},keyPressed:function(b,a){var c=a.which?a.which:a.keyCode;return b.keyHandler(c)},keyHandler:function(a){if(a===13){this.findNextFromUI();return false}this.previousEnabled(true);this.nextEnabled(true);this.searched=false;return true},scrollPositionChanged:function(a){if(this.searched&&!this.viewerIsScrolled){this.previousEnabled(this.isPreviousEnabled(a));this.nextEnabled(this.isNextEnabled(a))}},showControls:function(){this.visible(this.searchIsVisible)},hideControls:function(){this.visible(false)},documentLoaded:function(){this.resetButtons();this.searched&&this.element.trigger("onPerformSearch","")},loadPagesOnOneLevel:function(b,m,l,k,j){for(var i=this,d=[],c=this.viewerViewModel.getPageLocations(),f=this.viewerViewModel.pageWidth(),e=this.viewerViewModel.pages(),g=c[b].y+f*e[b].prop,a=b+1;a<c.length;a++)if(Math.abs(c[a].y+f*e[a].prop-g)<2)d.push(a);else break;for(a=b-1;a>=0;a--)if(Math.abs(c[a].y+f*e[a].prop-g)<2)d.push(a);else break;function h(){if(d.length==0)i.findClosestArea(m,l,k,j);else i.viewerViewModel.getDocumentPageHtml(d.pop(),h)}this.viewerViewModel.getDocumentPageHtml(b,h)},getScrollTop:function(e){var h=this.closestArea!=null,b,c,g;if(!this.pagesContainerElement)this.pagesContainerElement=this.viewerElement.find(".pages_container");var k=this.pagesContainerElement.offset().top,i=this.viewerElement.height(),l=e,j=e+i,d,f=false;if(h){b=null;c=null;this.closestArea.each(function(){var h=a(this),e=h.offset().top;if(b===null||e<b)b=e;var d=this.getBoundingClientRect(),f;if(typeof d.height=="undefined")f=d.bottom-d.top;else f=d.height;var g=e+f;if(c===null||g>c)c=g});g=c-b;d=b-k;if(Math.ceil(d)+g>=l&&Math.floor(d)<=j){e=d;f=true}}return{scrollTop:e,isCurrentlyHighlightedAreaVisible:f}},documentPageSetHandler:function(){if(this.useVirtualScrolling&&this.searchPageAfterScrollingToIt){var a=this,c=this.searchPageAfterScrollingToIt.searchForward,d=this.searchPageAfterScrollingToIt.pageNumber;this.searchPageAfterScrollingToIt=null;this.isWaitingForPageOpening=true;window.setTimeout(function(){a.findClosestArea(c,a.isCaseSensitive,a.searchForSeparateWords,a.treatPhrasesInDoubleQuotesAsExactPhrases,a.useAccentInsensitiveSearch,d)},1e3)}else{if(!this.pagesContainerElement)this.pagesContainerElement=this.viewerElement.find(".pages_container");var b=this.viewerElement.scrollTop();this.scrollPositionChanged(b)}},sortHighlightedAreas:function(b){b.sort(function(e,f){var c=a(f),b=a(e),d=Math.floor(b.offset().top)-Math.floor(c.offset().top);return Math.abs(d)>=1?d:b.offset().left-c.offset().left})}})})(jQuery);(function(a,b){var d=/[<>&\r\n"']/gm,c={"<":"lt;",">":"gt;","&":"amp;","\r":"#13;","\n":"#10;",'"':"quot;","'":"apos;"};a.extend({fileDownload:function(f,x){var e=a.extend({preparingMessageHtml:null,failMessageHtml:null,androidPostUnsupportedMessageHtml:"Unfortunately your Android browser doesn't support this type of file download. Please try again with a different browser.",dialogOptions:{modal:true},prepareCallback:function(){},successCallback:function(){},failCallback:function(){},httpMethod:"GET",data:null,checkInterval:100,cookieName:"fileDownload",cookieValue:"true",cookiePath:"/",popupWindowTitle:"Initiating file download...",encodeHTMLEntities:true,containerElement:a("body")},x),n=new a.Deferred,m=(navigator.userAgent||navigator.vendor||b.opera).toLowerCase(),p,l,q;if(/ip(ad|hone|od)/.test(m))p=true;else if(m.indexOf("android")!==-1)l=true;else q=/avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|playbook|silk|iemobile|iris|kindle|lge |maemo|midp|mmp|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i.test(m)||/1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq|iris|ja(t|v)a|jbro|jemu|jigs|kddi|keji|kgt( |\/)|klon|kpt |kwc\-|kyo(c|k)|le(no|xi)|lg( g|\/(k|l|u)|50|54|e\-|e\/|\-[a-w])|libw|lynx|m1\-w|m3ga|m50\/|ma(te|ui|xo)|mc(01|21|ca)|m\-cr|me(di|rc|ri)|mi(o8|oa|ts)|mmef|mo(01|02|bi|de|do|t(\-| |o|v)|zz)|mt(50|p1|v )|mwbp|mywa|n10[0-2]|n20[2-3]|n30(0|2)|n50(0|2|5)|n7(0(0|1)|10)|ne((c|m)\-|on|tf|wf|wg|wt)|nok(6|i)|nzph|o2im|op(ti|wv)|oran|owg1|p800|pan(a|d|t)|pdxg|pg(13|\-([1-8]|c))|phil|pire|pl(ay|uc)|pn\-2|po(ck|rt|se)|prox|psio|pt\-g|qa\-a|qc(07|12|21|32|60|\-[2-7]|i\-)|qtek|r380|r600|raks|rim9|ro(ve|zo)|s55\/|sa(ge|ma|mm|ms|ny|va)|sc(01|h\-|oo|p\-)|sdk\/|se(c(\-|0|1)|47|mc|nd|ri)|sgh\-|shar|sie(\-|m)|sk\-0|sl(45|id)|sm(al|ar|b3|it|t5)|so(ft|ny)|sp(01|h\-|v\-|v )|sy(01|mb)|t2(18|50)|t6(00|10|18)|ta(gt|lk)|tcl\-|tdg\-|tel(i|m)|tim\-|t\-mo|to(pl|sh)|ts(70|m\-|m3|m5)|tx\-9|up(\.b|g1|si)|utst|v400|v750|veri|vi(rg|te)|vk(40|5[0-3]|\-v)|vm40|voda|vulc|vx(52|53|60|61|70|80|81|83|85|98)|w3c(\-| )|webc|whit|wi(g |nc|nw)|wmlb|wonu|x700|xda(\-|2|g)|yas\-|your|zeto|zte\-/i.test(m.substr(0,4));var w=e.httpMethod.toUpperCase();if(l&&w!=="GET"){if(a().dialog)a("<div>").html(e.androidPostUnsupportedMessageHtml).dialog(e.dialogOptions);else //alert(e.androidPostUnsupportedMessageHtml);return n.reject()}var j=null,k={onPrepare:function(b){if(e.preparingMessageHtml)j=a("<div>").html(e.preparingMessageHtml).dialog(e.dialogOptions);else e.prepareCallback&&e.prepareCallback(b)},onSuccess:function(a){j&&j.dialog("close");e.successCallback(a);n.resolve(a)},onFail:function(b,c){j&&j.dialog("close");e.failMessageHtml&&a("<div>").html(e.failMessageHtml).dialog(e.dialogOptions);e.failCallback(b,c);n.reject(b,c)}};k.onPrepare(f);if(e.data!==null&&typeof e.data!=="string")e.data=a.param(e.data);var h,g,o,i;if(w==="GET"){if(e.data!==null){var y=f.indexOf("?");if(y!==-1){if(f.substring(f.length-1)!=="&")f=f+"&"}else f=f+"?";f=f+e.data}if(p||l){g=b.open(f);g.document.title=e.popupWindowTitle;b.focus()}else if(q)b.location(f);else{h=e.containerElement.find("iframe[name='jqueryFileDownloadJS']");h.length!=0&&h.remove();h=a("<iframe name='jqueryFileDownloadJS'>").hide().prop("src",f).appendTo(e.containerElement)}}else{var r="";e.data!==null&&a.each(e.data.replace(/\+/g," ").split("&"),function(){var a=this.split("="),b=e.encodeHTMLEntities?t(decodeURIComponent(a[0])):decodeURIComponent(a[0]);if(b){var c=e.encodeHTMLEntities?t(decodeURIComponent(a[1])):decodeURIComponent(a[1]);r+='<input type="hidden" name="'+b+'" value="'+c+'" />'}});if(q){i=a("<form>").appendTo("body");i.hide().prop("method",e.httpMethod).prop("action",f).html(r)}else{if(p){g=b.open("about:blank");g.document.title=e.popupWindowTitle;o=g.document;b.focus()}else{h=a("<iframe style='display: none' src='about:blank'></iframe>").appendTo("body");o=v(h)}o.write("<html><head></head><body><form method='"+e.httpMethod+"' action='"+f+"'>"+r+"</form>"+e.popupWindowTitle+"</body></html>");i=a(o).find("form")}i.submit()}setTimeout(u,e.checkInterval);function u(){if(document.cookie.indexOf(e.cookieName+"="+e.cookieValue)!=-1){k.onSuccess(f);document.cookie=e.cookieName+"=; expires="+(new Date(1e3)).toUTCString()+"; path="+e.cookiePath;s(false);return}if(g||h)try{var b=g?g.document:v(h);if(b&&b.body!=null&&b.body.innerHTML.length){var d=true;if(i&&i.length){var c=a(b.body).contents().first();if(c.length&&c[0]===i[0])d=false}if(d){k.onFail(b.body.innerHTML,f);s(true);return}}}catch(j){k.onFail(j.message,f);s(true);return}setTimeout(u,e.checkInterval)}function v(b){var a=b[0].contentWindow||b[0].contentDocument;if(a&&a.document)a=a.document;return a}function s(a){setTimeout(function(){if(g){l&&g.close();if(p){g.focus();a&&g.close()}}},0)}function t(a){return a.replace(d,function(a){return"&"+c[a]})}return n.promise()}})})(jQuery,this);