egroupware/collabeditor/js/webodf/collab/webodf.js

652 lines
347 KiB
JavaScript

/*
This is a generated file. DO NOT EDIT.
Copyright (C) 2010-2015 KO GmbH <copyright@kogmbh.com>
@licstart
The code in this file is free software: you can redistribute it and/or modify it
under the terms of the GNU Affero General Public License (GNU AGPL)
as published by the Free Software Foundation, either version 3 of
the License, or (at your option) any later version.
The code in this file is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with WebODF. If not, see <http://www.gnu.org/licenses/>.
As additional permission under GNU AGPL version 3 section 7, you
may distribute UNMODIFIED VERSIONS OF THIS file without the copy of the GNU AGPL normally
required by section 4, provided you include this license notice and a URL
through which recipients can access the Corresponding Source.
As a special exception to the AGPL, any HTML file which merely makes function
calls to this code, and for that purpose includes it in unmodified form by reference or in-line shall be
deemed a separate work for copyright law purposes. In addition, the copyright
holders of this code give you permission to combine this code with free
software libraries that are released under the GNU LGPL. You may copy and
distribute such a system following the terms of the GNU AGPL for this code
and the LGPL for the libraries. If you modify this code, you may extend this
exception to your version of the code, but you are not obligated to do so.
If you do not wish to do so, delete this exception statement from your
version.
This license applies to this entire compilation.
@licend
@source: http://www.webodf.org/
@source: https://github.com/kogmbh/WebODF/
*/
var webodf_version="0.5.8.preview1";function Runtime(){}Runtime.prototype.getVariable=function(f){};Runtime.prototype.toJson=function(f){};Runtime.prototype.fromJson=function(f){};Runtime.prototype.byteArrayFromString=function(f,k){};Runtime.prototype.byteArrayToString=function(f,k){};Runtime.prototype.read=function(f,k,a,e){};Runtime.prototype.readFile=function(f,k,a){};Runtime.prototype.readFileSync=function(f,k){};Runtime.prototype.loadXML=function(f,k){};Runtime.prototype.writeFile=function(f,k,a){};
Runtime.prototype.deleteFile=function(f,k){};Runtime.prototype.log=function(f,k){};Runtime.prototype.setTimeout=function(f,k){};Runtime.prototype.clearTimeout=function(f){};Runtime.prototype.libraryPaths=function(){};Runtime.prototype.currentDirectory=function(){};Runtime.prototype.setCurrentDirectory=function(f){};Runtime.prototype.type=function(){};Runtime.prototype.getDOMImplementation=function(){};Runtime.prototype.parseXML=function(f){};Runtime.prototype.exit=function(f){};
Runtime.prototype.getWindow=function(){};Runtime.prototype.requestAnimationFrame=function(f){};Runtime.prototype.cancelAnimationFrame=function(f){};Runtime.prototype.assert=function(f,k){};var IS_COMPILED_CODE=!0;
Runtime.byteArrayToString=function(f,k){function a(a){var e="",c,q=a.length;for(c=0;c<q;c+=1)e+=String.fromCharCode(a[c]&255);return e}function e(a){var e="",c,q=a.length,g=[],h,d,b,r;for(c=3<=q&&239===a[0]&&187===a[1]&&191===a[2]?3:0;c<q;c+=1)h=a[c],128>h?g.push(h):(c+=1,d=a[c],194<=h&&224>h?g.push((h&31)<<6|d&63):(c+=1,b=a[c],224<=h&&240>h?g.push((h&15)<<12|(d&63)<<6|b&63):(c+=1,r=a[c],240<=h&&245>h&&(h=(h&7)<<18|(d&63)<<12|(b&63)<<6|r&63,h-=65536,g.push((h>>10)+55296,(h&1023)+56320))))),1E3<=g.length&&
(e+=String.fromCharCode.apply(null,g),g.length=0);return e+String.fromCharCode.apply(null,g)}var c;"utf8"===k?c=e(f):("binary"!==k&&this.log("Unsupported encoding: "+k),c=a(f));return c};Runtime.getVariable=function(f){try{return eval(f)}catch(k){}};Runtime.toJson=function(f){return JSON.stringify(f)};Runtime.fromJson=function(f){return JSON.parse(f)};Runtime.getFunctionName=function(f){return void 0===f.name?(f=/function\s+(\w+)/.exec(f))&&f[1]:f.name};
Runtime.assert=function(f,k){if(!f)throw this.log("alert","ASSERTION FAILED:\n"+k),Error(k);};
function BrowserRuntime(){function f(a){var g=a.length,h,d,b=0;for(h=0;h<g;h+=1)d=a.charCodeAt(h),b+=1+(128<d)+(2048<d),55040<d&&57344>d&&(b+=1,h+=1);return b}function k(a,g,h){var d=a.length,b,r;g=new Uint8Array(new ArrayBuffer(g));h?(g[0]=239,g[1]=187,g[2]=191,r=3):r=0;for(h=0;h<d;h+=1)b=a.charCodeAt(h),128>b?(g[r]=b,r+=1):2048>b?(g[r]=192|b>>>6,g[r+1]=128|b&63,r+=2):55040>=b||57344<=b?(g[r]=224|b>>>12&15,g[r+1]=128|b>>>6&63,g[r+2]=128|b&63,r+=3):(h+=1,b=(b-55296<<10|a.charCodeAt(h)-56320)+65536,
g[r]=240|b>>>18&7,g[r+1]=128|b>>>12&63,g[r+2]=128|b>>>6&63,g[r+3]=128|b&63,r+=4);return g}function a(a){var g=a.length,h=new Uint8Array(new ArrayBuffer(g)),d;for(d=0;d<g;d+=1)h[d]=a.charCodeAt(d)&255;return h}function e(a,g){var h;void 0!==g?h=a:g=a;console.log(g);p.enableAlerts&&"alert"===h&&alert(g)}function c(e,g,h){if(0!==h.status||h.responseText)if(200===h.status||0===h.status){if(h.response&&"string"!==typeof h.response)"binary"===g?(h=h.response,h=new Uint8Array(h)):h=String(h.response);else if("binary"===
g)if(null!==h.responseBody&&"undefined"!==String(typeof VBArray)){h=(new VBArray(h.responseBody)).toArray();var d=h.length;g=new Uint8Array(new ArrayBuffer(d));for(e=0;e<d;e+=1)g[e]=h[e];h=g}else{(e=h.getResponseHeader("Content-Length"))&&(e=parseInt(e,10));if(e&&e!==h.responseText.length)a:{d=h.responseText;g=!1;var b=f(d);if("number"===typeof e){if(e!==b&&e!==b+3){d=void 0;break a}g=b+3===e;b=e}d=k(d,b,g)}void 0===d&&(d=a(h.responseText));h=d}else h=h.responseText;h={err:null,data:h}}else h={err:h.responseText||
h.statusText,data:null};else h={err:"File "+e+" is empty.",data:null};return h}function m(a,g,h){var d=new XMLHttpRequest;d.open("GET",a,h);d.overrideMimeType&&("binary"!==g?d.overrideMimeType("text/plain; charset="+g):d.overrideMimeType("text/plain; charset=x-user-defined"));return d}function n(a,g,h){var d=m(a,g,!0);d.onreadystatechange=function(){var b;4===d.readyState&&(b=c(a,g,d),h(b.err,b.data))};try{d.send(null)}catch(b){h(b.message,null)}}var p=this;this.byteArrayFromString=function(e,g){var h;
"utf8"===g?h=k(e,f(e),!1):("binary"!==g&&p.log("unknown encoding: "+g),h=a(e));return h};this.byteArrayToString=Runtime.byteArrayToString;this.getVariable=Runtime.getVariable;this.fromJson=Runtime.fromJson;this.toJson=Runtime.toJson;this.readFile=n;this.read=function(a,g,h,d){n(a,"binary",function(b,r){var l=null;if(r){if("string"===typeof r)throw"This should not happen.";l=r.subarray(g,g+h)}d(b,l)})};this.readFileSync=function(a,g){var h=m(a,g,!1),d;try{h.send(null);d=c(a,g,h);if(d.err)throw d.err;
if(null===d.data)throw"No data read from "+a+".";}catch(b){throw b;}return d.data};this.writeFile=function(a,g,h){var d=new XMLHttpRequest,b;d.open("PUT",a,!0);d.onreadystatechange=function(){4===d.readyState&&(0!==d.status||d.responseText?200<=d.status&&300>d.status||0===d.status?h(null):h("Status "+String(d.status)+": "+d.responseText||d.statusText):h("File "+a+" is empty."))};b=g.buffer&&!d.sendAsBinary?g.buffer:p.byteArrayToString(g,"binary");try{d.sendAsBinary?d.sendAsBinary(b):d.send(b)}catch(r){p.log("HUH? "+
r+" "+g),h(r.message)}};this.deleteFile=function(a,g){var h=new XMLHttpRequest;h.open("DELETE",a,!0);h.onreadystatechange=function(){4===h.readyState&&(200>h.status&&300<=h.status?g(h.responseText):g(null))};h.send(null)};this.loadXML=function(a,g){var h=new XMLHttpRequest;h.open("GET",a,!0);h.overrideMimeType&&h.overrideMimeType("text/xml");h.onreadystatechange=function(){4===h.readyState&&(0!==h.status||h.responseText?200===h.status||0===h.status?g(null,h.responseXML):g(h.responseText,null):g("File "+
a+" is empty.",null))};try{h.send(null)}catch(d){g(d.message,null)}};this.log=e;this.enableAlerts=!0;this.assert=Runtime.assert;this.setTimeout=function(a,g){return setTimeout(function(){a()},g)};this.clearTimeout=function(a){clearTimeout(a)};this.libraryPaths=function(){return["lib"]};this.setCurrentDirectory=function(){};this.currentDirectory=function(){return""};this.type=function(){return"BrowserRuntime"};this.getDOMImplementation=function(){return window.document.implementation};this.parseXML=
function(a){return(new DOMParser).parseFromString(a,"text/xml")};this.exit=function(a){e("Calling exit with code "+String(a)+", but exit() is not implemented.")};this.getWindow=function(){return window};this.requestAnimationFrame=function(a){var g=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.msRequestAnimationFrame,h=0;if(g)g.bind(window),h=g(a);else return setTimeout(a,15);return h};this.cancelAnimationFrame=function(a){var g=window.cancelAnimationFrame||
window.webkitCancelAnimationFrame||window.mozCancelAnimationFrame||window.msCancelAnimationFrame;g?(g.bind(window),g(a)):clearTimeout(a)}}
function NodeJSRuntime(){function f(a){var g=a.length,h,d=new Uint8Array(new ArrayBuffer(g));for(h=0;h<g;h+=1)d[h]=a[h];return d}function k(a,g,h){function d(d,r){if(d)return h(d,null);if(!r)return h("No data for "+a+".",null);if("string"===typeof r)return h(d,r);h(d,f(r))}a=c.resolve(m,a);"binary"!==g?e.readFile(a,g,d):e.readFile(a,null,d)}var a=this,e=webodfModule.require("fs"),c=webodfModule.require("path"),m="",n,p;this.byteArrayFromString=function(a,g){var h=new Buffer(a,g),d,b=h.length,r=new Uint8Array(new ArrayBuffer(b));
for(d=0;d<b;d+=1)r[d]=h[d];return r};this.byteArrayToString=Runtime.byteArrayToString;this.getVariable=Runtime.getVariable;this.fromJson=Runtime.fromJson;this.toJson=Runtime.toJson;this.readFile=k;this.loadXML=function(e,g){k(e,"utf-8",function(h,d){if(h)return g(h,null);if(!d)return g("No data for "+e+".",null);g(null,a.parseXML(d))})};this.writeFile=function(a,g,h){g=new Buffer(g);a=c.resolve(m,a);e.writeFile(a,g,"binary",function(d){h(d||null)})};this.deleteFile=function(a,g){a=c.resolve(m,a);
e.unlink(a,g)};this.read=function(a,g,h,d){a=c.resolve(m,a);e.open(a,"r+",666,function(b,r){if(b)d(b,null);else{var l=new Buffer(h);e.read(r,l,0,h,g,function(b){e.close(r);d(b,f(l))})}})};this.readFileSync=function(a,g){var h;h=e.readFileSync(a,"binary"===g?null:g);if(null===h)throw"File "+a+" could not be read.";"binary"===g&&(h=f(h));return h};this.log=function(a,e){var h;void 0!==e?h=a:e=a;"alert"===h&&process.stderr.write("\n!!!!! ALERT !!!!!\n");process.stderr.write(e+"\n");"alert"===h&&process.stderr.write("!!!!! ALERT !!!!!\n")};
this.assert=Runtime.assert;this.setTimeout=function(a,e){return setTimeout(function(){a()},e)};this.clearTimeout=function(a){clearTimeout(a)};this.libraryPaths=function(){return[__dirname]};this.setCurrentDirectory=function(a){m=a};this.currentDirectory=function(){return m};this.type=function(){return"NodeJSRuntime"};this.getDOMImplementation=function(){return p};this.parseXML=function(a){return n.parseFromString(a,"text/xml")};this.exit=process.exit;this.getWindow=function(){return null};this.requestAnimationFrame=
function(a){return setTimeout(a,15)};this.cancelAnimationFrame=function(a){clearTimeout(a)};n=new (webodfModule.require("xmldom").DOMParser);p=a.parseXML("<a/>").implementation}
function RhinoRuntime(){var f=this,k={},a=k.javax.xml.parsers.DocumentBuilderFactory.newInstance(),e,c,m="";a.setValidating(!1);a.setNamespaceAware(!0);a.setExpandEntityReferences(!1);a.setSchema(null);c=k.org.xml.sax.EntityResolver({resolveEntity:function(a,e){var c=new k.java.io.FileReader(e);return new k.org.xml.sax.InputSource(c)}});e=a.newDocumentBuilder();e.setEntityResolver(c);this.byteArrayFromString=function(a,e){var c,g=a.length,h=new Uint8Array(new ArrayBuffer(g));for(c=0;c<g;c+=1)h[c]=
a.charCodeAt(c)&255;return h};this.byteArrayToString=Runtime.byteArrayToString;this.getVariable=Runtime.getVariable;this.fromJson=Runtime.fromJson;this.toJson=Runtime.toJson;this.loadXML=function(a,c){var m=new k.java.io.File(a),g=null;try{g=e.parse(m)}catch(h){return print(h),c(h,null)}c(null,g)};this.readFile=function(a,e,c){m&&(a=m+"/"+a);var g=new k.java.io.File(a),h="binary"===e?"latin1":e;g.isFile()?((a=readFile(a,h))&&"binary"===e&&(a=f.byteArrayFromString(a,"binary")),c(null,a)):c(a+" is not a file.",
null)};this.writeFile=function(a,e,c){m&&(a=m+"/"+a);a=new k.java.io.FileOutputStream(a);var g,h=e.length;for(g=0;g<h;g+=1)a.write(e[g]);a.close();c(null)};this.deleteFile=function(a,e){m&&(a=m+"/"+a);var c=new k.java.io.File(a),g=a+Math.random(),g=new k.java.io.File(g);c.rename(g)?(g.deleteOnExit(),e(null)):e("Could not delete "+a)};this.read=function(a,e,c,g){m&&(a=m+"/"+a);var h;h=a;var d="binary";(new k.java.io.File(h)).isFile()?("binary"===d&&(d="latin1"),h=readFile(h,d)):h=null;h?g(null,this.byteArrayFromString(h.substring(e,
e+c),"binary")):g("Cannot read "+a,null)};this.readFileSync=function(a,e){if(!e)return"";var c=readFile(a,e);if(null===c)throw"File could not be read.";return c};this.log=function(a,e){var c;void 0!==e?c=a:e=a;"alert"===c&&print("\n!!!!! ALERT !!!!!");print(e);"alert"===c&&print("!!!!! ALERT !!!!!")};this.assert=Runtime.assert;this.setTimeout=function(a){a();return 0};this.clearTimeout=function(){};this.libraryPaths=function(){return["lib"]};this.setCurrentDirectory=function(a){m=a};this.currentDirectory=
function(){return m};this.type=function(){return"RhinoRuntime"};this.getDOMImplementation=function(){return e.getDOMImplementation()};this.parseXML=function(a){a=new k.java.io.StringReader(a);a=new k.org.xml.sax.InputSource(a);return e.parse(a)};this.exit=quit;this.getWindow=function(){return null};this.requestAnimationFrame=function(a){a();return 0};this.cancelAnimationFrame=function(){}}
Runtime.create=function(){return"undefined"!==String(typeof window)?new BrowserRuntime:"undefined"!==String(typeof require)?new NodeJSRuntime:new RhinoRuntime};var runtime=Runtime.create(),core={},gui={},xmldom={},odf={},ops={},webodf={};(function(){webodf.Version="undefined"!==String(typeof webodf_version)?webodf_version:"From Source"})();
(function(){function f(a,e,g){var h=a+"/manifest.json",d,b;runtime.log("Loading manifest: "+h);try{d=runtime.readFileSync(h,"utf-8")}catch(r){if(g)runtime.log("No loadable manifest found.");else throw console.log(String(r)),r;return}g=JSON.parse(d);for(b in g)g.hasOwnProperty(b)&&(e[b]={dir:a,deps:g[b]})}function k(a,e,g){function h(l){if(!r[l]&&!g(l)){if(b[l])throw"Circular dependency detected for "+l+".";b[l]=!0;if(!e[l])throw"Missing dependency information for class "+l+".";var a=e[l],c=a.deps,
m,p=c.length;for(m=0;m<p;m+=1)h(c[m]);b[l]=!1;r[l]=!0;d.push(a.dir+"/"+l.replace(".","/")+".js")}}var d=[],b={},r={};a.forEach(h);return d}function a(a,e){return e+("\n//# sourceURL="+a)}function e(e){var c,g;for(c=0;c<e.length;c+=1)g=runtime.readFileSync(e[c],"utf-8"),g=a(e[c],g),eval(g)}function c(a){a=a.split(".");var e,c=n,h=a.length;for(e=0;e<h;e+=1){if(!c.hasOwnProperty(a[e]))return!1;c=c[a[e]]}return!0}var m,n={core:core,gui:gui,xmldom:xmldom,odf:odf,ops:ops};runtime.loadClasses=function(a,
n){if(IS_COMPILED_CODE||0===a.length)return n&&n();var g;if(!(g=m)){g=[];var h=runtime.libraryPaths(),d;runtime.currentDirectory()&&-1===h.indexOf(runtime.currentDirectory())&&f(runtime.currentDirectory(),g,!0);for(d=0;d<h.length;d+=1)f(h[d],g)}m=g;a=k(a,m,c);if(0===a.length)return n&&n();if("BrowserRuntime"===runtime.type()&&n){g=a;h=document.currentScript||document.documentElement.lastChild;d=document.createDocumentFragment();var b,r;for(r=0;r<g.length;r+=1)b=document.createElement("script"),b.type=
"text/javascript",b.charset="utf-8",b.async=!1,b.setAttribute("src",g[r]),d.appendChild(b);n&&(b.onload=n);h.parentNode.insertBefore(d,h)}else e(a),n&&n()};runtime.loadClass=function(a,e){runtime.loadClasses([a],e)}})();(function(){var f=function(f){return f};runtime.getTranslator=function(){return f};runtime.setTranslator=function(k){f=k};runtime.tr=function(k){var a=f(k);return a&&"string"===String(typeof a)?a:k}})();
(function(f){function k(a){if(a.length){var e=a[0];runtime.readFile(e,"utf8",function(c,m){function n(){var a;(a=eval(f))&&runtime.exit(a)}var p="",p=e.lastIndexOf("/"),f=m,p=-1!==p?e.substring(0,p):".";runtime.setCurrentDirectory(p);c?(runtime.log(c),runtime.exit(1)):null===f?(runtime.log("No code found for "+e),runtime.exit(1)):n.apply(null,a)})}}f=f?Array.prototype.slice.call(f):[];"NodeJSRuntime"===runtime.type()?k(process.argv.slice(2)):"RhinoRuntime"===runtime.type()?k(f):k(f.slice(1))})("undefined"!==
String(typeof arguments)&&arguments);(function(){core.Async=function(){return{forEach:function(f,k,a){function e(e){n!==m&&(e?(n=m,a(e)):(n+=1,n===m&&a(null)))}var c,m=f.length,n=0;for(c=0;c<m;c+=1)k(f[c],e)},destroyAll:function(f,k){function a(e,c){if(c)k(c);else if(e<f.length)f[e](function(c){a(e+1,c)});else k()}a(0,void 0)}}}()})();function makeBase64(){function f(d){var b,l=d.length,r=new Uint8Array(new ArrayBuffer(l));for(b=0;b<l;b+=1)r[b]=d.charCodeAt(b)&255;return r}function k(d){var b,l="",r,a=d.length-2;for(r=0;r<a;r+=3)b=d[r]<<16|d[r+1]<<8|d[r+2],l+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[b>>>18],l+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[b>>>12&63],l+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[b>>>6&63],l+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[b&
63];r===a+1?(b=d[r]<<4,l+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[b>>>6],l+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[b&63],l+="=="):r===a&&(b=d[r]<<10|d[r+1]<<2,l+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[b>>>12],l+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[b>>>6&63],l+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[b&63],l+="=");return l}function a(d){d=d.replace(/[^A-Za-z0-9+\/]+/g,
"");var b=d.length,r=new Uint8Array(new ArrayBuffer(3*b)),a=d.length%4,e=0,c,B;for(c=0;c<b;c+=4)B=(l[d.charAt(c)]||0)<<18|(l[d.charAt(c+1)]||0)<<12|(l[d.charAt(c+2)]||0)<<6|(l[d.charAt(c+3)]||0),r[e]=B>>16,r[e+1]=B>>8&255,r[e+2]=B&255,e+=3;b=3*b-[0,0,2,1][a];return r.subarray(0,b)}function e(d){var b,l,r=d.length,a=0,e=new Uint8Array(new ArrayBuffer(3*r));for(b=0;b<r;b+=1)l=d[b],128>l?e[a++]=l:(2048>l?e[a++]=192|l>>>6:(e[a++]=224|l>>>12&15,e[a++]=128|l>>>6&63),e[a++]=128|l&63);return e.subarray(0,
a)}function c(d){var b,l,r,a,e=d.length,B=new Uint8Array(new ArrayBuffer(e)),c=0;for(b=0;b<e;b+=1)l=d[b],128>l?B[c++]=l:(b+=1,r=d[b],224>l?B[c++]=(l&31)<<6|r&63:(b+=1,a=d[b],B[c++]=(l&15)<<12|(r&63)<<6|a&63));return B.subarray(0,c)}function m(b){return k(f(b))}function n(b){return String.fromCharCode.apply(String,a(b))}function p(b){return c(f(b))}function q(b){b=c(b);for(var d="",l=0;l<b.length;)d+=String.fromCharCode.apply(String,b.subarray(l,l+45E3)),l+=45E3;return d}function g(b,d,l){var r,a,
e,B="";for(e=d;e<l;e+=1)d=b.charCodeAt(e)&255,128>d?B+=String.fromCharCode(d):(e+=1,r=b.charCodeAt(e)&255,224>d?B+=String.fromCharCode((d&31)<<6|r&63):(e+=1,a=b.charCodeAt(e)&255,B+=String.fromCharCode((d&15)<<12|(r&63)<<6|a&63)));return B}function h(b,d){function l(){var e=a+1E5;e>b.length&&(e=b.length);r+=g(b,a,e);a=e;e=a===b.length;d(r,e)&&!e&&runtime.setTimeout(l,0)}var r="",a=0;1E5>b.length?d(g(b,0,b.length),!0):("string"!==typeof b&&(b=b.slice()),l())}function d(b){return e(f(b))}function b(b){return String.fromCharCode.apply(String,
e(b))}function r(b){return String.fromCharCode.apply(String,e(f(b)))}var l=function(b){var d={},l,r;l=0;for(r=b.length;l<r;l+=1)d[b.charAt(l)]=l;return d}("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),y,t,z=runtime.getWindow(),w,s;z&&z.btoa?(w=z.btoa,y=function(b){return w(r(b))}):(w=m,y=function(b){return k(d(b))});z&&z.atob?(s=z.atob,t=function(b){b=s(b);return g(b,0,b.length)}):(s=n,t=function(b){return q(a(b))});core.Base64=function(){this.convertByteArrayToBase64=this.convertUTF8ArrayToBase64=
k;this.convertBase64ToByteArray=this.convertBase64ToUTF8Array=a;this.convertUTF16ArrayToByteArray=this.convertUTF16ArrayToUTF8Array=e;this.convertByteArrayToUTF16Array=this.convertUTF8ArrayToUTF16Array=c;this.convertUTF8StringToBase64=m;this.convertBase64ToUTF8String=n;this.convertUTF8StringToUTF16Array=p;this.convertByteArrayToUTF16String=this.convertUTF8ArrayToUTF16String=q;this.convertUTF8StringToUTF16String=h;this.convertUTF16StringToByteArray=this.convertUTF16StringToUTF8Array=d;this.convertUTF16ArrayToUTF8String=
b;this.convertUTF16StringToUTF8String=r;this.convertUTF16StringToBase64=y;this.convertBase64ToUTF16String=t;this.fromBase64=n;this.toBase64=m;this.atob=s;this.btoa=w;this.utob=r;this.btou=h;this.encode=y;this.encodeURI=function(b){return y(b).replace(/[+\/]/g,function(b){return"+"===b?"-":"_"}).replace(/\\=+$/,"")};this.decode=function(b){return t(b.replace(/[\-_]/g,function(b){return"-"===b?"+":"/"}))};return this};return core.Base64}core.Base64=makeBase64();core.ByteArray=function(f){this.pos=0;this.data=f;this.readUInt32LE=function(){this.pos+=4;var f=this.data,a=this.pos;return f[--a]<<24|f[--a]<<16|f[--a]<<8|f[--a]};this.readUInt16LE=function(){this.pos+=2;var f=this.data,a=this.pos;return f[--a]<<8|f[--a]}};core.ByteArrayWriter=function(f){function k(a){a>c-e&&(c=Math.max(2*c,e+a),a=new Uint8Array(new ArrayBuffer(c)),a.set(m),m=a)}var a=this,e=0,c=1024,m=new Uint8Array(new ArrayBuffer(c));this.appendByteArrayWriter=function(e){a.appendByteArray(e.getByteArray())};this.appendByteArray=function(a){var c=a.length;k(c);m.set(a,e);e+=c};this.appendArray=function(a){var c=a.length;k(c);m.set(a,e);e+=c};this.appendUInt16LE=function(e){a.appendArray([e&255,e>>8&255])};this.appendUInt32LE=function(e){a.appendArray([e&
255,e>>8&255,e>>16&255,e>>24&255])};this.appendString=function(e){a.appendByteArray(runtime.byteArrayFromString(e,f))};this.getLength=function(){return e};this.getByteArray=function(){var a=new Uint8Array(new ArrayBuffer(e));a.set(m.subarray(0,e));return a}};core.CSSUnits=function(){var f=this,k={"in":1,cm:2.54,mm:25.4,pt:72,pc:12,px:96};this.convert=function(a,e,c){return a*k[c]/k[e]};this.convertMeasure=function(a,e){var c,m;a&&e&&(c=parseFloat(a),m=a.replace(c.toString(),""),c=f.convert(c,m,e));return c};this.getUnits=function(a){return a.substr(a.length-2,a.length)}};(function(){function f(){var e,c,m,f,p,k,g,h,d;void 0===a&&(c=(e=runtime.getWindow())&&e.document,k=c.documentElement,g=c.body,a={rangeBCRIgnoresElementBCR:!1,unscaledRangeClientRects:!1,elementBCRIgnoresBodyScroll:!1},c&&(f=c.createElement("div"),f.style.position="absolute",f.style.left="-99999px",f.style.transform="scale(2)",f.style["-webkit-transform"]="scale(2)",p=c.createElement("div"),f.appendChild(p),g.appendChild(f),e=c.createRange(),e.selectNode(p),a.rangeBCRIgnoresElementBCR=0===e.getClientRects().length,
p.appendChild(c.createTextNode("Rect transform test")),c=p.getBoundingClientRect(),m=e.getBoundingClientRect(),a.unscaledRangeClientRects=2<Math.abs(c.height-m.height),f.style.transform="",f.style["-webkit-transform"]="",c=k.style.overflow,m=g.style.overflow,h=g.style.height,d=g.scrollTop,k.style.overflow="visible",g.style.overflow="visible",g.style.height="200%",g.scrollTop=g.scrollHeight,a.elementBCRIgnoresBodyScroll=e.getBoundingClientRect().top!==p.getBoundingClientRect().top,g.scrollTop=d,g.style.height=
h,g.style.overflow=m,k.style.overflow=c,e.detach(),g.removeChild(f),e=Object.keys(a).map(function(b){return b+":"+String(a[b])}).join(", "),runtime.log("Detected browser quirks - "+e)));return a}function k(a,c,m){for(a=a?a.firstElementChild:null;a;){if(a.localName===m&&a.namespaceURI===c)return a;a=a.nextElementSibling}return null}var a;core.DomUtilsImpl=function(){function a(b,d){for(var e=0,c;b.parentNode!==d;)runtime.assert(null!==b.parentNode,"parent is null"),b=b.parentNode;for(c=d.firstChild;c!==
b;)e+=1,c=c.nextSibling;return e}function c(b,d){return 0>=b.compareBoundaryPoints(Range.START_TO_START,d)&&0<=b.compareBoundaryPoints(Range.END_TO_END,d)}function m(b,d){return 0>=b.compareBoundaryPoints(Range.END_TO_START,d)&&0<=b.compareBoundaryPoints(Range.START_TO_END,d)}function n(b,d){var a=null;b.nodeType===Node.TEXT_NODE&&(0===b.length?(b.parentNode.removeChild(b),d.nodeType===Node.TEXT_NODE&&(a=d)):(d.nodeType===Node.TEXT_NODE&&(b.appendData(d.data),d.parentNode.removeChild(d)),a=b));return a}
function p(b){for(var d=b.parentNode;b.firstChild;)d.insertBefore(b.firstChild,b);d.removeChild(b);return d}function q(b,d){var a=b.parentNode,e=b.firstChild,c=d(b),h;if(c===NodeFilter.FILTER_SKIP)return a;for(;e;)h=e.nextSibling,q(e,d),e=h;a&&c===NodeFilter.FILTER_REJECT&&p(b);return a}function g(b,d){return b===d||Boolean(b.compareDocumentPosition(d)&Node.DOCUMENT_POSITION_CONTAINED_BY)}function h(b,d){return f().unscaledRangeClientRects?b:b/d}function d(b,l,a){Object.keys(l).forEach(function(e){var c=
e.split(":"),h=c[1],g=a(c[0]),c=l[e],m=typeof c;"object"===m?Object.keys(c).length&&(e=g?b.getElementsByTagNameNS(g,h)[0]||b.ownerDocument.createElementNS(g,e):b.getElementsByTagName(h)[0]||b.ownerDocument.createElement(e),b.appendChild(e),d(e,c,a)):g&&(runtime.assert("number"===m||"string"===m,"attempting to map unsupported type '"+m+"' (key: "+e+")"),b.setAttributeNS(g,e,String(c)))})}var b=null;this.splitBoundaries=function(b){var d,c=[],h,g,m;if(b.startContainer.nodeType===Node.TEXT_NODE||b.endContainer.nodeType===
Node.TEXT_NODE){h=b.endContainer;g=b.endContainer.nodeType!==Node.TEXT_NODE?b.endOffset===b.endContainer.childNodes.length:!1;m=b.endOffset;d=b.endContainer;if(m<d.childNodes.length)for(d=d.childNodes.item(m),m=0;d.firstChild;)d=d.firstChild;else for(;d.lastChild;)d=d.lastChild,m=d.nodeType===Node.TEXT_NODE?d.textContent.length:d.childNodes.length;d===h&&(h=null);b.setEnd(d,m);m=b.endContainer;0!==b.endOffset&&m.nodeType===Node.TEXT_NODE&&(d=m,b.endOffset!==d.length&&(c.push(d.splitText(b.endOffset)),
c.push(d)));m=b.startContainer;0!==b.startOffset&&m.nodeType===Node.TEXT_NODE&&(d=m,b.startOffset!==d.length&&(m=d.splitText(b.startOffset),c.push(d),c.push(m),b.setStart(m,0)));if(null!==h){for(m=b.endContainer;m.parentNode&&m.parentNode!==h;)m=m.parentNode;g=g?h.childNodes.length:a(m,h);b.setEnd(h,g)}}return c};this.containsRange=c;this.rangesIntersect=m;this.rangeIntersection=function(b,d){var a;m(b,d)&&(a=b.cloneRange(),-1===b.compareBoundaryPoints(Range.START_TO_START,d)&&a.setStart(d.startContainer,
d.startOffset),1===b.compareBoundaryPoints(Range.END_TO_END,d)&&a.setEnd(d.endContainer,d.endOffset));return a};this.getNodesInRange=function(b,d,a){var e=[],c=b.commonAncestorContainer,c=c.nodeType===Node.TEXT_NODE?c.parentNode:c;a=b.startContainer.ownerDocument.createTreeWalker(c,a,d,!1);var h,g;b.endContainer.childNodes[b.endOffset-1]?(h=b.endContainer.childNodes[b.endOffset-1],g=Node.DOCUMENT_POSITION_PRECEDING|Node.DOCUMENT_POSITION_CONTAINED_BY):(h=b.endContainer,g=Node.DOCUMENT_POSITION_PRECEDING);
b.startContainer.childNodes[b.startOffset]?(b=b.startContainer.childNodes[b.startOffset],a.currentNode=b):b.startOffset===(b.startContainer.nodeType===Node.TEXT_NODE?b.startContainer.length:b.startContainer.childNodes.length)?(b=b.startContainer,a.currentNode=b,a.lastChild(),b=a.nextNode()):(b=b.startContainer,a.currentNode=b);if(b){b=a.currentNode;if(b!==c)for(b=b.parentNode;b&&b!==c;)d(b)===NodeFilter.FILTER_REJECT&&(a.currentNode=b),b=b.parentNode;b=a.currentNode;switch(d(b)){case NodeFilter.FILTER_REJECT:for(b=
a.nextSibling();!b&&a.parentNode();)b=a.nextSibling();break;case NodeFilter.FILTER_SKIP:b=a.nextNode()}for(;b;){d=h.compareDocumentPosition(b);if(0!==d&&0===(d&g))break;e.push(b);b=a.nextNode()}}return e};this.normalizeTextNodes=function(b){b&&b.nextSibling&&(b=n(b,b.nextSibling));b&&b.previousSibling&&n(b.previousSibling,b)};this.rangeContainsNode=function(b,d){var a=d.ownerDocument.createRange(),e=d.ownerDocument.createRange(),h;a.setStart(b.startContainer,b.startOffset);a.setEnd(b.endContainer,
b.endOffset);e.selectNodeContents(d);h=c(a,e);a.detach();e.detach();return h};this.mergeIntoParent=p;this.removeUnwantedNodes=q;this.removeAllChildNodes=function(b){for(;b.firstChild;)b.removeChild(b.firstChild)};this.getElementsByTagNameNS=function(b,d,a){var e=[];b=b.getElementsByTagNameNS(d,a);e.length=a=b.length;for(d=0;d<a;d+=1)e[d]=b.item(d);return e};this.getElementsByTagName=function(b,d){var a=[],e,c,h;e=b.getElementsByTagName(d);a.length=h=e.length;for(c=0;c<h;c+=1)a[c]=e.item(c);return a};
this.containsNode=function(b,d){return b===d||b.contains(d)};this.comparePoints=function(b,d,c,h){if(b===c)return h-d;var g=b.compareDocumentPosition(c);2===g?g=-1:4===g?g=1:10===g?(d=a(b,c),g=d<h?1:-1):(h=a(c,b),g=h<d?-1:1);return g};this.adaptRangeDifferenceToZoomLevel=h;this.translateRect=function(b,d,a){return{top:h(b.top-d.top,a),left:h(b.left-d.left,a),bottom:h(b.bottom-d.top,a),right:h(b.right-d.left,a),width:h(b.width,a),height:h(b.height,a)}};this.getBoundingClientRect=function(d){var a=
d.ownerDocument,e=f(),c=a.body;if((!1===e.unscaledRangeClientRects||e.rangeBCRIgnoresElementBCR)&&d.nodeType===Node.ELEMENT_NODE)return d=d.getBoundingClientRect(),e.elementBCRIgnoresBodyScroll?{left:d.left+c.scrollLeft,right:d.right+c.scrollLeft,top:d.top+c.scrollTop,bottom:d.bottom+c.scrollTop,width:d.width,height:d.height}:d;var h;b?h=b:b=h=a.createRange();e=h;e.selectNode(d);return e.getBoundingClientRect()};this.mapKeyValObjOntoNode=function(b,d,a){Object.keys(d).forEach(function(e){var c=e.split(":"),
h=c[1],c=a(c[0]),g=d[e];c?(h=b.getElementsByTagNameNS(c,h)[0],h||(h=b.ownerDocument.createElementNS(c,e),b.appendChild(h)),h.textContent=g):runtime.log("Key ignored: "+e)})};this.removeKeyElementsFromNode=function(b,d,a){d.forEach(function(d){var l=d.split(":"),e=l[1];(l=a(l[0]))?(e=b.getElementsByTagNameNS(l,e)[0])?e.parentNode.removeChild(e):runtime.log("Element for "+d+" not found."):runtime.log("Property Name ignored: "+d)})};this.getKeyValRepresentationOfNode=function(b,d){for(var a={},e=b.firstElementChild,
c;e;){if(c=d(e.namespaceURI))a[c+":"+e.localName]=e.textContent;e=e.nextElementSibling}return a};this.mapObjOntoNode=d;this.cloneEvent=function(b){var d=Object.create(null);Object.keys(b).forEach(function(a){d[a]=b[a]});d.prototype=b.constructor.prototype;return d};this.getDirectChild=k;(function(b){var d,a;a=runtime.getWindow();null!==a&&(d=a.navigator.appVersion.toLowerCase(),a=-1===d.indexOf("chrome")&&(-1!==d.indexOf("applewebkit")||-1!==d.indexOf("safari")),d=-1!==d.indexOf("msie")||-1!==d.indexOf("trident"),
a||d)&&(b.containsNode=g)})(this)};core.DomUtils=new core.DomUtilsImpl})();core.Cursor=function(f,k){function a(d){d.parentNode&&(p.push(d.previousSibling),p.push(d.nextSibling),d.parentNode.removeChild(d))}function e(d,b,a){if(b.nodeType===Node.TEXT_NODE){runtime.assert(Boolean(b),"putCursorIntoTextNode: invalid container");var l=b.parentNode;runtime.assert(Boolean(l),"putCursorIntoTextNode: container without parent");runtime.assert(0<=a&&a<=b.length,"putCursorIntoTextNode: offset is out of bounds");0===a?l.insertBefore(d,b):(a!==b.length&&b.splitText(a),l.insertBefore(d,
b.nextSibling))}else b.nodeType===Node.ELEMENT_NODE&&b.insertBefore(d,b.childNodes.item(a));p.push(d.previousSibling);p.push(d.nextSibling)}var c=f.createElementNS("urn:webodf:names:cursor","cursor"),m=f.createElementNS("urn:webodf:names:cursor","anchor"),n,p=[],q=f.createRange(),g,h=core.DomUtils;this.getNode=function(){return c};this.getAnchorNode=function(){return m.parentNode?m:c};this.getSelectedRange=function(){g?(q.setStartBefore(c),q.collapse(!0)):(q.setStartAfter(n?m:c),q.setEndBefore(n?
c:m));return q};this.setSelectedRange=function(d,b){q&&q!==d&&q.detach();q=d;n=!1!==b;(g=d.collapsed)?(a(m),a(c),e(c,d.startContainer,d.startOffset)):(a(m),a(c),e(n?c:m,d.endContainer,d.endOffset),e(n?m:c,d.startContainer,d.startOffset));p.forEach(h.normalizeTextNodes);p.length=0};this.hasForwardSelection=function(){return n};this.remove=function(){a(c);p.forEach(h.normalizeTextNodes);p.length=0};c.setAttributeNS("urn:webodf:names:cursor","memberId",k);m.setAttributeNS("urn:webodf:names:cursor","memberId",
k)};core.Destroyable=function(){};core.Destroyable.prototype.destroy=function(f){};core.EventSource=function(){};core.EventSource.prototype.subscribe=function(f,k){};core.EventSource.prototype.unsubscribe=function(f,k){};core.EventNotifier=function(f){function k(e){runtime.assert(!a.hasOwnProperty(e),'Duplicated event ids: "'+e+'" registered more than once.');a[e]=[]}var a={};this.emit=function(e,c){var m,f;runtime.assert(a.hasOwnProperty(e),'unknown event fired "'+e+'"');f=a[e];for(m=0;m<f.length;m+=1)f[m](c)};this.subscribe=function(e,c){runtime.assert(a.hasOwnProperty(e),'tried to subscribe to unknown event "'+e+'"');a[e].push(c)};this.unsubscribe=function(e,c){var m;runtime.assert(a.hasOwnProperty(e),'tried to unsubscribe from unknown event "'+
e+'"');m=a[e].indexOf(c);runtime.assert(-1!==m,'tried to unsubscribe unknown callback from event "'+e+'"');-1!==m&&a[e].splice(m,1)};this.register=k;f&&f.forEach(k)};core.ScheduledTask=function(f,k,a){function e(){n&&(a(m),n=!1)}function c(){e();f.apply(void 0,p);p=null}var m,n=!1,p=[],q=!1;this.trigger=function(){runtime.assert(!1===q,"Can't trigger destroyed ScheduledTask instance");p=Array.prototype.slice.call(arguments);n||(n=!0,m=k(c))};this.triggerImmediate=function(){runtime.assert(!1===q,"Can't trigger destroyed ScheduledTask instance");p=Array.prototype.slice.call(arguments);c()};this.processRequests=function(){n&&c()};this.cancel=e;this.restart=function(){runtime.assert(!1===
q,"Can't trigger destroyed ScheduledTask instance");e();n=!0;m=k(c)};this.destroy=function(a){e();q=!0;a()}};(function(){var f;core.Task={};core.Task.SUPPRESS_MANUAL_PROCESSING=!1;core.Task.processTasks=function(){core.Task.SUPPRESS_MANUAL_PROCESSING||f.performRedraw()};core.Task.createRedrawTask=function(k){return new core.ScheduledTask(k,f.requestRedrawTask,f.cancelRedrawTask)};core.Task.createTimeoutTask=function(f,a){return new core.ScheduledTask(f,function(e){return runtime.setTimeout(e,a)},runtime.clearTimeout)};f=new function(){var f={};this.requestRedrawTask=function(a){var e=runtime.requestAnimationFrame(function(){a();
delete f[e]});f[e]=a;return e};this.performRedraw=function(){Object.keys(f).forEach(function(a){f[a]();runtime.cancelAnimationFrame(parseInt(a,10))});f={}};this.cancelRedrawTask=function(a){runtime.cancelAnimationFrame(a);delete f[a]}}})();core.EventSubscriptions=function(){function f(e,c,m){e.subscribe(c,m);a.push({eventSource:e,eventid:c,callback:m})}function k(){var m=[];a.forEach(function(a){a.eventSource.unsubscribe(a.eventid,a.callback)});a.length=0;Object.keys(c).forEach(function(a){c[a].forEach(function(a){m.push(a.task.destroy)});delete c[a]});core.Async.destroyAll(m,function(){});e=new core.EventNotifier}var a=[],e=new core.EventNotifier,c={},m=0;this.addSubscription=f;this.addFrameSubscription=function(a,p,k){var g,h,d,b;
c.hasOwnProperty(p)||(c[p]=[]);d=c[p];for(b=0;b<d.length;b+=1)if(d[b].eventSource===a){g=d[b];break}g||(h="s"+m,m+=1,e.register(h),g={frameEventId:h,eventSource:a,task:core.Task.createRedrawTask(function(){e.emit(h,void 0)})},d.push(g),f(a,p,g.task.trigger));e.subscribe(g.frameEventId,k)};this.unsubscribeAll=k;this.destroy=function(a){k();a()}};core.LazyProperty=function(f){var k,a=!1;this.value=function(){a||(k=f(),a=!0);return k};this.reset=function(){a=!1}};core.LoopWatchDog=function(f,k){var a=Date.now(),e=0;this.check=function(){var c;if(f&&(c=Date.now(),c-a>f))throw runtime.log("alert","watchdog timeout"),"timeout!";if(0<k&&(e+=1,e>k))throw runtime.log("alert","watchdog loop overflow"),"loop overflow";}};core.NodeFilterChain=function(f){var k=NodeFilter.FILTER_REJECT,a=NodeFilter.FILTER_ACCEPT;this.acceptNode=function(e){var c;for(c=0;c<f.length;c+=1)if(f[c].acceptNode(e)===k)return k;return a}};core.PositionIterator=function(f,k,a,e){function c(){this.acceptNode=function(b){return!b||b.nodeType===r&&0===b.length?t:y}}function m(b){this.acceptNode=function(d){return!d||d.nodeType===r&&0===d.length?t:b.acceptNode(d)}}function n(){var b=h.currentNode,a=b.nodeType;d=a===r?b.length-1:a===l?1:0}function p(){if(null===h.previousSibling()){if(!h.parentNode()||h.currentNode===f)return h.firstChild(),!1;d=0}else n();return!0}function q(){var a=h.currentNode,l;l=b(a);if(a!==f)for(a=a.parentNode;a&&
a!==f;)b(a)===t&&(h.currentNode=a,l=t),a=a.parentNode;l===t?(d=h.currentNode.nodeType===r?a.length:1,a=g.nextPosition()):a=l===y?!0:g.nextPosition();a&&runtime.assert(b(h.currentNode)===y,"moveToAcceptedNode did not result in walker being on an accepted node");return a}var g=this,h,d,b,r=Node.TEXT_NODE,l=Node.ELEMENT_NODE,y=NodeFilter.FILTER_ACCEPT,t=NodeFilter.FILTER_REJECT;this.nextPosition=function(){var b=h.currentNode,a=b.nodeType;if(b===f)return!1;if(0===d&&a===l)null===h.firstChild()&&(d=1);
else if(a===r&&d+1<b.length)d+=1;else if(null!==h.nextSibling())d=0;else if(h.parentNode())d=1;else return!1;return!0};this.previousPosition=function(){var b=!0,a=h.currentNode;0===d?b=p():a.nodeType===r?d-=1:null!==h.lastChild()?n():a===f?b=!1:d=0;return b};this.previousNode=p;this.container=function(){var b=h.currentNode,a=b.nodeType;0===d&&a!==r&&(b=b.parentNode);return b};this.rightNode=function(){var a=h.currentNode,e=a.nodeType;if(e===r&&d===a.length)for(a=a.nextSibling;a&&b(a)!==y;)a=a.nextSibling;
else e===l&&1===d&&(a=null);return a};this.leftNode=function(){var a=h.currentNode;if(0===d)for(a=a.previousSibling;a&&b(a)!==y;)a=a.previousSibling;else if(a.nodeType===l)for(a=a.lastChild;a&&b(a)!==y;)a=a.previousSibling;return a};this.getCurrentNode=function(){return h.currentNode};this.unfilteredDomOffset=function(){if(h.currentNode.nodeType===r)return d;for(var b=0,a=h.currentNode,a=1===d?a.lastChild:a.previousSibling;a;)b+=1,a=a.previousSibling;return b};this.getPreviousSibling=function(){var b=
h.currentNode,d=h.previousSibling();h.currentNode=b;return d};this.getNextSibling=function(){var b=h.currentNode,d=h.nextSibling();h.currentNode=b;return d};this.setPositionBeforeElement=function(b){runtime.assert(Boolean(b),"setPositionBeforeElement called without element");h.currentNode=b;d=0;return q()};this.setUnfilteredPosition=function(b,a){runtime.assert(Boolean(b),"PositionIterator.setUnfilteredPosition called without container");h.currentNode=b;b.nodeType===r?(d=a,runtime.assert(a<=b.length,
"Error in setPosition: "+a+" > "+b.length),runtime.assert(0<=a,"Error in setPosition: "+a+" < 0"),a===b.length&&(h.nextSibling()?d=0:h.parentNode()?d=1:runtime.assert(!1,"Error in setUnfilteredPosition: position not valid."))):a<b.childNodes.length?(h.currentNode=b.childNodes.item(a),d=0):d=1;return q()};this.moveToEnd=function(){h.currentNode=f;d=1};this.moveToEndOfNode=function(b){b.nodeType===r?g.setUnfilteredPosition(b,b.length):(h.currentNode=b,d=1)};this.isBeforeNode=function(){return 0===d};
this.getNodeFilter=function(){return b};b=(a?new m(a):new c).acceptNode;b.acceptNode=b;k=k||NodeFilter.SHOW_ALL;runtime.assert(f.nodeType!==Node.TEXT_NODE,"Internet Explorer doesn't allow tree walker roots to be text nodes");h=f.ownerDocument.createTreeWalker(f,k,b,e);d=0;null===h.firstChild()&&(d=1)};core.PositionFilter=function(){};core.PositionFilter.FilterResult={FILTER_ACCEPT:1,FILTER_REJECT:2,FILTER_SKIP:3};core.PositionFilter.prototype.acceptPosition=function(f){};core.PositionFilterChain=function(){var f=[],k=core.PositionFilter.FilterResult.FILTER_ACCEPT,a=core.PositionFilter.FilterResult.FILTER_REJECT;this.acceptPosition=function(e){var c;for(c=0;c<f.length;c+=1)if(f[c].acceptPosition(e)===a)return a;return k};this.addFilter=function(a){f.push(a)}};(function(){core.RawInflate=function(){var f;(function(k){f=k()})(function(){return function a(e,c,m){function f(p,g){if(!c[p]){if(!e[p])throw Error("Cannot find module '"+p+"'");var h=c[p]={exports:{}};e[p][0].call(h.exports,function(d){var b=e[p][1][d];return f(b?b:d)},h,h.exports,a,e,c,m)}return c[p].exports}for(var p=0;p<m.length;p++)f(m[p]);return f}({1:[function(a,e,c){function m(b,d){var a=new r(d);a.push(b,!0);if(a.err)throw a.msg;return a.result}var f=a("./zlib/inflate.js"),p=a("./utils/common"),
q=a("./utils/strings"),g=a("./zlib/constants"),h=a("./zlib/messages"),d=a("./zlib/zstream"),b=a("./zlib/gzheader"),r=function(a){var e=this.options=p.assign({chunkSize:16384,windowBits:0,to:""},a||{});e.raw&&0<=e.windowBits&&16>e.windowBits&&(e.windowBits=-e.windowBits,0===e.windowBits&&(e.windowBits=-15));!(0<=e.windowBits&&16>e.windowBits)||a&&a.windowBits||(e.windowBits+=32);15<e.windowBits&&48>e.windowBits&&0===(e.windowBits&15)&&(e.windowBits|=15);this.err=0;this.msg="";this.ended=!1;this.chunks=
[];this.strm=new d;this.strm.avail_out=0;a=f.inflateInit2(this.strm,e.windowBits);if(a!==g.Z_OK)throw Error(h[a]);this.header=new b;f.inflateGetHeader(this.strm,this.header)};r.prototype.push=function(b,d){var a=this.strm,e=this.options.chunkSize,c,r,h,m,C;if(this.ended)return!1;r=d===~~d?d:!0===d?g.Z_FINISH:g.Z_NO_FLUSH;a.input="string"===typeof b?q.binstring2buf(b):b;a.next_in=0;a.avail_in=a.input.length;do{0===a.avail_out&&(a.output=new p.Buf8(e),a.next_out=0,a.avail_out=e);c=f.inflate(a,g.Z_NO_FLUSH);
if(c!==g.Z_STREAM_END&&c!==g.Z_OK)return this.onEnd(c),this.ended=!0,!1;if(a.next_out&&(0===a.avail_out||c===g.Z_STREAM_END||0===a.avail_in&&r===g.Z_FINISH))if("string"===this.options.to)h=q.utf8border(a.output,a.next_out),m=a.next_out-h,C=q.buf2string(a.output,h),a.next_out=m,a.avail_out=e-m,m&&p.arraySet(a.output,a.output,h,m,0),this.onData(C);else this.onData(p.shrinkBuf(a.output,a.next_out))}while((0<a.avail_in||0===a.avail_out)&&c!==g.Z_STREAM_END);c===g.Z_STREAM_END&&(r=g.Z_FINISH);return r===
g.Z_FINISH?(c=f.inflateEnd(this.strm),this.onEnd(c),this.ended=!0,c===g.Z_OK):!0};r.prototype.onData=function(b){this.chunks.push(b)};r.prototype.onEnd=function(b){b===g.Z_OK&&(this.result="string"===this.options.to?this.chunks.join(""):p.flattenChunks(this.chunks));this.chunks=[];this.err=b;this.msg=this.strm.msg};c.Inflate=r;c.inflate=m;c.inflateRaw=function(b,d){d=d||{};d.raw=!0;return m(b,d)};c.ungzip=m},{"./utils/common":2,"./utils/strings":3,"./zlib/constants":5,"./zlib/gzheader":7,"./zlib/inflate.js":9,
"./zlib/messages":11,"./zlib/zstream":12}],2:[function(a,e,c){a="undefined"!==typeof Uint8Array&&"undefined"!==typeof Uint16Array&&"undefined"!==typeof Int32Array;c.assign=function(a){for(var e=Array.prototype.slice.call(arguments,1);e.length;){var c=e.shift();if(c){if("object"!==typeof c)throw new TypeError(c+"must be non-object");for(var h in c)c.hasOwnProperty(h)&&(a[h]=c[h])}}return a};c.shrinkBuf=function(a,e){if(a.length===e)return a;if(a.subarray)return a.subarray(0,e);a.length=e;return a};
var m={arraySet:function(a,e,c,h,d){if(e.subarray&&a.subarray)a.set(e.subarray(c,c+h),d);else for(var b=0;b<h;b++)a[d+b]=e[c+b]},flattenChunks:function(a){var e,c,h,d,b;e=h=0;for(c=a.length;e<c;e++)h+=a[e].length;b=new Uint8Array(h);e=h=0;for(c=a.length;e<c;e++)d=a[e],b.set(d,h),h+=d.length;return b}},f={arraySet:function(a,e,c,h,d){for(var b=0;b<h;b++)a[d+b]=e[c+b]},flattenChunks:function(a){return[].concat.apply([],a)}};c.setTyped=function(a){a?(c.Buf8=Uint8Array,c.Buf16=Uint16Array,c.Buf32=Int32Array,
c.assign(c,m)):(c.Buf8=Array,c.Buf16=Array,c.Buf32=Array,c.assign(c,f))};c.setTyped(a)},{}],3:[function(a,e,c){function m(b,d){if(65537>d&&(b.subarray&&q||!b.subarray&&p))return String.fromCharCode.apply(null,f.shrinkBuf(b,d));for(var a="",e=0;e<d;e++)a+=String.fromCharCode(b[e]);return a}var f=a("./common"),p=!0,q=!0;try{String.fromCharCode.apply(null,[0])}catch(g){p=!1}try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(h){q=!1}var d=new f.Buf8(256);for(a=0;256>a;a++)d[a]=252<=a?6:248<=
a?5:240<=a?4:224<=a?3:192<=a?2:1;d[254]=d[254]=1;c.string2buf=function(b){var d,a,e,c,h,g=b.length,m=0;for(c=0;c<g;c++)a=b.charCodeAt(c),55296===(a&64512)&&c+1<g&&(e=b.charCodeAt(c+1),56320===(e&64512)&&(a=65536+(a-55296<<10)+(e-56320),c++)),m+=128>a?1:2048>a?2:65536>a?3:4;d=new f.Buf8(m);for(c=h=0;h<m;c++)a=b.charCodeAt(c),55296===(a&64512)&&c+1<g&&(e=b.charCodeAt(c+1),56320===(e&64512)&&(a=65536+(a-55296<<10)+(e-56320),c++)),128>a?d[h++]=a:(2048>a?d[h++]=192|a>>>6:(65536>a?d[h++]=224|a>>>12:(d[h++]=
240|a>>>18,d[h++]=128|a>>>12&63),d[h++]=128|a>>>6&63),d[h++]=128|a&63);return d};c.buf2binstring=function(b){return m(b,b.length)};c.binstring2buf=function(b){for(var d=new f.Buf8(b.length),a=0,e=d.length;a<e;a++)d[a]=b.charCodeAt(a);return d};c.buf2string=function(b,a){var e,c,h,g,f=a||b.length,p=Array(2*f);for(e=c=0;e<f;)if(h=b[e++],128>h)p[c++]=h;else if(g=d[h],4<g)p[c++]=65533,e+=g-1;else{for(h&=2===g?31:3===g?15:7;1<g&&e<f;)h=h<<6|b[e++]&63,g--;1<g?p[c++]=65533:65536>h?p[c++]=h:(h-=65536,p[c++]=
55296|h>>10&1023,p[c++]=56320|h&1023)}return m(p,c)};c.utf8border=function(b,a){var e;a=a||b.length;a>b.length&&(a=b.length);for(e=a-1;0<=e&&128===(b[e]&192);)e--;return 0>e||0===e?a:e+d[b[e]]>a?e:a}},{"./common":2}],4:[function(a,e,c){e.exports=function(a,e,c,f){var g=a&65535|0;a=a>>>16&65535|0;for(var h=0;0!==c;){h=2E3<c?2E3:c;c-=h;do g=g+e[f++]|0,a=a+g|0;while(--h);g%=65521;a%=65521}return g|a<<16|0}},{}],5:[function(a,e,c){e.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,
Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}},{}],6:[function(a,e,c){var m=function(){for(var a,e=[],c=0;256>c;c++){a=c;for(var g=0;8>g;g++)a=a&1?3988292384^a>>>1:a>>>1;e[c]=a}return e}();e.exports=function(a,e,c,g){c=g+c;for(a^=
-1;g<c;g++)a=a>>>8^m[(a^e[g])&255];return a^-1}},{}],7:[function(a,e,c){e.exports=function(){this.os=this.xflags=this.time=this.text=0;this.extra=null;this.extra_len=0;this.comment=this.name="";this.hcrc=0;this.done=!1}},{}],8:[function(a,e,c){e.exports=function(a,e){var c,f,g,h,d,b,r,l,y,t,z,w,s,x,u,C,H,D,G,B,J,P,Q,A;c=a.state;f=a.next_in;Q=a.input;g=f+(a.avail_in-5);h=a.next_out;A=a.output;d=h-(e-a.avail_out);b=h+(a.avail_out-257);r=c.dmax;l=c.wsize;y=c.whave;t=c.wnext;z=c.window;w=c.hold;s=c.bits;
x=c.lencode;u=c.distcode;C=(1<<c.lenbits)-1;H=(1<<c.distbits)-1;a:do b:for(15>s&&(w+=Q[f++]<<s,s+=8,w+=Q[f++]<<s,s+=8),D=x[w&C];;){G=D>>>24;w>>>=G;s-=G;G=D>>>16&255;if(0===G)A[h++]=D&65535;else if(G&16){B=D&65535;if(G&=15)s<G&&(w+=Q[f++]<<s,s+=8),B+=w&(1<<G)-1,w>>>=G,s-=G;15>s&&(w+=Q[f++]<<s,s+=8,w+=Q[f++]<<s,s+=8);D=u[w&H];c:for(;;){G=D>>>24;w>>>=G;s-=G;G=D>>>16&255;if(G&16){D&=65535;G&=15;s<G&&(w+=Q[f++]<<s,s+=8,s<G&&(w+=Q[f++]<<s,s+=8));D+=w&(1<<G)-1;if(D>r){a.msg="invalid distance too far back";
c.mode=30;break a}w>>>=G;s-=G;G=h-d;if(D>G){G=D-G;if(G>y&&c.sane){a.msg="invalid distance too far back";c.mode=30;break a}J=0;P=z;if(0===t){if(J+=l-G,G<B){B-=G;do A[h++]=z[J++];while(--G);J=h-D;P=A}}else if(t<G){if(J+=l+t-G,G-=t,G<B){B-=G;do A[h++]=z[J++];while(--G);J=0;if(t<B){G=t;B-=G;do A[h++]=z[J++];while(--G);J=h-D;P=A}}}else if(J+=t-G,G<B){B-=G;do A[h++]=z[J++];while(--G);J=h-D;P=A}for(;2<B;)A[h++]=P[J++],A[h++]=P[J++],A[h++]=P[J++],B-=3;B&&(A[h++]=P[J++],1<B&&(A[h++]=P[J++]))}else{J=h-D;do A[h++]=
A[J++],A[h++]=A[J++],A[h++]=A[J++],B-=3;while(2<B);B&&(A[h++]=A[J++],1<B&&(A[h++]=A[J++]))}}else if(0===(G&64)){D=u[(D&65535)+(w&(1<<G)-1)];continue c}else{a.msg="invalid distance code";c.mode=30;break a}break}}else if(0===(G&64)){D=x[(D&65535)+(w&(1<<G)-1)];continue b}else{G&32?c.mode=12:(a.msg="invalid literal/length code",c.mode=30);break a}break}while(f<g&&h<b);B=s>>3;f-=B;s-=B<<3;a.next_in=f;a.next_out=h;a.avail_in=f<g?5+(g-f):5-(f-g);a.avail_out=h<b?257+(b-h):257-(h-b);c.hold=w&(1<<s)-1;c.bits=
s}},{}],9:[function(a,e,c){function f(b){return(b>>>24&255)+(b>>>8&65280)+((b&65280)<<8)+((b&255)<<24)}function n(){this.mode=0;this.last=!1;this.wrap=0;this.havedict=!1;this.total=this.check=this.dmax=this.flags=0;this.head=null;this.wnext=this.whave=this.wsize=this.wbits=0;this.window=null;this.extra=this.offset=this.length=this.bits=this.hold=0;this.distcode=this.lencode=null;this.have=this.ndist=this.nlen=this.ncode=this.distbits=this.lenbits=0;this.next=null;this.lens=new d.Buf16(320);this.work=
new d.Buf16(288);this.distdyn=this.lendyn=null;this.was=this.back=this.sane=0}function p(b){var a;if(!b||!b.state)return z;a=b.state;b.total_in=b.total_out=a.total=0;b.msg="";a.wrap&&(b.adler=a.wrap&1);a.mode=w;a.last=0;a.havedict=0;a.dmax=32768;a.head=null;a.hold=0;a.bits=0;a.lencode=a.lendyn=new d.Buf32(s);a.distcode=a.distdyn=new d.Buf32(x);a.sane=1;a.back=-1;return t}function q(b){var d;if(!b||!b.state)return z;d=b.state;d.wsize=0;d.whave=0;d.wnext=0;return p(b)}function g(b,d){var a,e;if(!b||
!b.state)return z;e=b.state;0>d?(a=0,d=-d):(a=(d>>4)+1,48>d&&(d&=15));if(d&&(8>d||15<d))return z;null!==e.window&&e.wbits!==d&&(e.window=null);e.wrap=a;e.wbits=d;return q(b)}function h(b,d){var a;if(!b)return z;a=new n;b.state=a;a.window=null;a=g(b,d);a!==t&&(b.state=null);return a}var d=a("../utils/common"),b=a("./adler32"),r=a("./crc32"),l=a("./inffast"),y=a("./inftrees"),t=0,z=-2,w=1,s=852,x=592,u=!0,C,H;c.inflateReset=q;c.inflateReset2=g;c.inflateResetKeep=p;c.inflateInit=function(b){return h(b,
15)};c.inflateInit2=h;c.inflate=function(a,e){var c,h,g,p,A,n,q,v,s,x,T,F,N,Z;F=0;var E,V,$,ca,U,W=new d.Buf8(4),O=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!a||!a.state||!a.output||!a.input&&0!==a.avail_in)return z;c=a.state;12===c.mode&&(c.mode=13);A=a.next_out;g=a.output;q=a.avail_out;p=a.next_in;h=a.input;n=a.avail_in;v=c.hold;s=c.bits;x=n;T=q;U=t;a:for(;;)switch(c.mode){case w:if(0===c.wrap){c.mode=13;break}for(;16>s;){if(0===n)break a;n--;v+=h[p++]<<s;s+=8}if(c.wrap&2&&35615===v){c.check=
0;W[0]=v&255;W[1]=v>>>8&255;c.check=r(c.check,W,2,0);s=v=0;c.mode=2;break}c.flags=0;c.head&&(c.head.done=!1);if(!(c.wrap&1)||(((v&255)<<8)+(v>>8))%31){a.msg="incorrect header check";c.mode=30;break}if(8!==(v&15)){a.msg="unknown compression method";c.mode=30;break}v>>>=4;s-=4;N=(v&15)+8;if(0===c.wbits)c.wbits=N;else if(N>c.wbits){a.msg="invalid window size";c.mode=30;break}c.dmax=1<<N;a.adler=c.check=1;c.mode=v&512?10:12;s=v=0;break;case 2:for(;16>s;){if(0===n)break a;n--;v+=h[p++]<<s;s+=8}c.flags=
v;if(8!==(c.flags&255)){a.msg="unknown compression method";c.mode=30;break}if(c.flags&57344){a.msg="unknown header flags set";c.mode=30;break}c.head&&(c.head.text=v>>8&1);c.flags&512&&(W[0]=v&255,W[1]=v>>>8&255,c.check=r(c.check,W,2,0));s=v=0;c.mode=3;case 3:for(;32>s;){if(0===n)break a;n--;v+=h[p++]<<s;s+=8}c.head&&(c.head.time=v);c.flags&512&&(W[0]=v&255,W[1]=v>>>8&255,W[2]=v>>>16&255,W[3]=v>>>24&255,c.check=r(c.check,W,4,0));s=v=0;c.mode=4;case 4:for(;16>s;){if(0===n)break a;n--;v+=h[p++]<<s;s+=
8}c.head&&(c.head.xflags=v&255,c.head.os=v>>8);c.flags&512&&(W[0]=v&255,W[1]=v>>>8&255,c.check=r(c.check,W,2,0));s=v=0;c.mode=5;case 5:if(c.flags&1024){for(;16>s;){if(0===n)break a;n--;v+=h[p++]<<s;s+=8}c.length=v;c.head&&(c.head.extra_len=v);c.flags&512&&(W[0]=v&255,W[1]=v>>>8&255,c.check=r(c.check,W,2,0));s=v=0}else c.head&&(c.head.extra=null);c.mode=6;case 6:if(c.flags&1024&&(F=c.length,F>n&&(F=n),F&&(c.head&&(N=c.head.extra_len-c.length,c.head.extra||(c.head.extra=Array(c.head.extra_len)),d.arraySet(c.head.extra,
h,p,F,N)),c.flags&512&&(c.check=r(c.check,h,F,p)),n-=F,p+=F,c.length-=F),c.length))break a;c.length=0;c.mode=7;case 7:if(c.flags&2048){if(0===n)break a;F=0;do N=h[p+F++],c.head&&N&&65536>c.length&&(c.head.name+=String.fromCharCode(N));while(N&&F<n);c.flags&512&&(c.check=r(c.check,h,F,p));n-=F;p+=F;if(N)break a}else c.head&&(c.head.name=null);c.length=0;c.mode=8;case 8:if(c.flags&4096){if(0===n)break a;F=0;do N=h[p+F++],c.head&&N&&65536>c.length&&(c.head.comment+=String.fromCharCode(N));while(N&&F<
n);c.flags&512&&(c.check=r(c.check,h,F,p));n-=F;p+=F;if(N)break a}else c.head&&(c.head.comment=null);c.mode=9;case 9:if(c.flags&512){for(;16>s;){if(0===n)break a;n--;v+=h[p++]<<s;s+=8}if(v!==(c.check&65535)){a.msg="header crc mismatch";c.mode=30;break}s=v=0}c.head&&(c.head.hcrc=c.flags>>9&1,c.head.done=!0);a.adler=c.check=0;c.mode=12;break;case 10:for(;32>s;){if(0===n)break a;n--;v+=h[p++]<<s;s+=8}a.adler=c.check=f(v);s=v=0;c.mode=11;case 11:if(0===c.havedict)return a.next_out=A,a.avail_out=q,a.next_in=
p,a.avail_in=n,c.hold=v,c.bits=s,2;a.adler=c.check=1;c.mode=12;case 12:if(5===e||6===e)break a;case 13:if(c.last){v>>>=s&7;s-=s&7;c.mode=27;break}for(;3>s;){if(0===n)break a;n--;v+=h[p++]<<s;s+=8}c.last=v&1;v>>>=1;s-=1;switch(v&3){case 0:c.mode=14;break;case 1:F=c;if(u){N=void 0;C=new d.Buf32(512);H=new d.Buf32(32);for(N=0;144>N;)F.lens[N++]=8;for(;256>N;)F.lens[N++]=9;for(;280>N;)F.lens[N++]=7;for(;288>N;)F.lens[N++]=8;y(1,F.lens,0,288,C,0,F.work,{bits:9});for(N=0;32>N;)F.lens[N++]=5;y(2,F.lens,
0,32,H,0,F.work,{bits:5});u=!1}F.lencode=C;F.lenbits=9;F.distcode=H;F.distbits=5;c.mode=20;if(6===e){v>>>=2;s-=2;break a}break;case 2:c.mode=17;break;case 3:a.msg="invalid block type",c.mode=30}v>>>=2;s-=2;break;case 14:v>>>=s&7;for(s-=s&7;32>s;){if(0===n)break a;n--;v+=h[p++]<<s;s+=8}if((v&65535)!==(v>>>16^65535)){a.msg="invalid stored block lengths";c.mode=30;break}c.length=v&65535;s=v=0;c.mode=15;if(6===e)break a;case 15:c.mode=16;case 16:if(F=c.length){F>n&&(F=n);F>q&&(F=q);if(0===F)break a;d.arraySet(g,
h,p,F,A);n-=F;p+=F;q-=F;A+=F;c.length-=F;break}c.mode=12;break;case 17:for(;14>s;){if(0===n)break a;n--;v+=h[p++]<<s;s+=8}c.nlen=(v&31)+257;v>>>=5;s-=5;c.ndist=(v&31)+1;v>>>=5;s-=5;c.ncode=(v&15)+4;v>>>=4;s-=4;if(286<c.nlen||30<c.ndist){a.msg="too many length or distance symbols";c.mode=30;break}c.have=0;c.mode=18;case 18:for(;c.have<c.ncode;){for(;3>s;){if(0===n)break a;n--;v+=h[p++]<<s;s+=8}c.lens[O[c.have++]]=v&7;v>>>=3;s-=3}for(;19>c.have;)c.lens[O[c.have++]]=0;c.lencode=c.lendyn;c.lenbits=7;
F={bits:c.lenbits};U=y(0,c.lens,0,19,c.lencode,0,c.work,F);c.lenbits=F.bits;if(U){a.msg="invalid code lengths set";c.mode=30;break}c.have=0;c.mode=19;case 19:for(;c.have<c.nlen+c.ndist;){for(;;){F=c.lencode[v&(1<<c.lenbits)-1];E=F>>>24;V=F>>>16&255;$=F&65535;if(E<=s)break;if(0===n)break a;n--;v+=h[p++]<<s;s+=8}if(16>$)v>>>=E,s-=E,c.lens[c.have++]=$;else{if(16===$){for(F=E+2;s<F;){if(0===n)break a;n--;v+=h[p++]<<s;s+=8}v>>>=E;s-=E;if(0===c.have){a.msg="invalid bit length repeat";c.mode=30;break}N=
c.lens[c.have-1];F=3+(v&3);v>>>=2;s-=2}else if(17===$){for(F=E+3;s<F;){if(0===n)break a;n--;v+=h[p++]<<s;s+=8}v>>>=E;s-=E;N=0;F=3+(v&7);v>>>=3;s-=3}else{for(F=E+7;s<F;){if(0===n)break a;n--;v+=h[p++]<<s;s+=8}v>>>=E;s-=E;N=0;F=11+(v&127);v>>>=7;s-=7}if(c.have+F>c.nlen+c.ndist){a.msg="invalid bit length repeat";c.mode=30;break}for(;F--;)c.lens[c.have++]=N}}if(30===c.mode)break;if(0===c.lens[256]){a.msg="invalid code -- missing end-of-block";c.mode=30;break}c.lenbits=9;F={bits:c.lenbits};U=y(1,c.lens,
0,c.nlen,c.lencode,0,c.work,F);c.lenbits=F.bits;if(U){a.msg="invalid literal/lengths set";c.mode=30;break}c.distbits=6;c.distcode=c.distdyn;F={bits:c.distbits};U=y(2,c.lens,c.nlen,c.ndist,c.distcode,0,c.work,F);c.distbits=F.bits;if(U){a.msg="invalid distances set";c.mode=30;break}c.mode=20;if(6===e)break a;case 20:c.mode=21;case 21:if(6<=n&&258<=q){a.next_out=A;a.avail_out=q;a.next_in=p;a.avail_in=n;c.hold=v;c.bits=s;l(a,T);A=a.next_out;g=a.output;q=a.avail_out;p=a.next_in;h=a.input;n=a.avail_in;
v=c.hold;s=c.bits;12===c.mode&&(c.back=-1);break}for(c.back=0;;){F=c.lencode[v&(1<<c.lenbits)-1];E=F>>>24;V=F>>>16&255;$=F&65535;if(E<=s)break;if(0===n)break a;n--;v+=h[p++]<<s;s+=8}if(V&&0===(V&240)){N=E;Z=V;for(ca=$;;){F=c.lencode[ca+((v&(1<<N+Z)-1)>>N)];E=F>>>24;V=F>>>16&255;$=F&65535;if(N+E<=s)break;if(0===n)break a;n--;v+=h[p++]<<s;s+=8}v>>>=N;s-=N;c.back+=N}v>>>=E;s-=E;c.back+=E;c.length=$;if(0===V){c.mode=26;break}if(V&32){c.back=-1;c.mode=12;break}if(V&64){a.msg="invalid literal/length code";
c.mode=30;break}c.extra=V&15;c.mode=22;case 22:if(c.extra){for(F=c.extra;s<F;){if(0===n)break a;n--;v+=h[p++]<<s;s+=8}c.length+=v&(1<<c.extra)-1;v>>>=c.extra;s-=c.extra;c.back+=c.extra}c.was=c.length;c.mode=23;case 23:for(;;){F=c.distcode[v&(1<<c.distbits)-1];E=F>>>24;V=F>>>16&255;$=F&65535;if(E<=s)break;if(0===n)break a;n--;v+=h[p++]<<s;s+=8}if(0===(V&240)){N=E;Z=V;for(ca=$;;){F=c.distcode[ca+((v&(1<<N+Z)-1)>>N)];E=F>>>24;V=F>>>16&255;$=F&65535;if(N+E<=s)break;if(0===n)break a;n--;v+=h[p++]<<s;s+=
8}v>>>=N;s-=N;c.back+=N}v>>>=E;s-=E;c.back+=E;if(V&64){a.msg="invalid distance code";c.mode=30;break}c.offset=$;c.extra=V&15;c.mode=24;case 24:if(c.extra){for(F=c.extra;s<F;){if(0===n)break a;n--;v+=h[p++]<<s;s+=8}c.offset+=v&(1<<c.extra)-1;v>>>=c.extra;s-=c.extra;c.back+=c.extra}if(c.offset>c.dmax){a.msg="invalid distance too far back";c.mode=30;break}c.mode=25;case 25:if(0===q)break a;F=T-q;if(c.offset>F){F=c.offset-F;if(F>c.whave&&c.sane){a.msg="invalid distance too far back";c.mode=30;break}F>
c.wnext?(F-=c.wnext,N=c.wsize-F):N=c.wnext-F;F>c.length&&(F=c.length);Z=c.window}else Z=g,N=A-c.offset,F=c.length;F>q&&(F=q);q-=F;c.length-=F;do g[A++]=Z[N++];while(--F);0===c.length&&(c.mode=21);break;case 26:if(0===q)break a;g[A++]=c.length;q--;c.mode=21;break;case 27:if(c.wrap){for(;32>s;){if(0===n)break a;n--;v|=h[p++]<<s;s+=8}T-=q;a.total_out+=T;c.total+=T;T&&(a.adler=c.check=c.flags?r(c.check,g,T,A-T):b(c.check,g,T,A-T));T=q;if((c.flags?v:f(v))!==c.check){a.msg="incorrect data check";c.mode=
30;break}s=v=0}c.mode=28;case 28:if(c.wrap&&c.flags){for(;32>s;){if(0===n)break a;n--;v+=h[p++]<<s;s+=8}if(v!==(c.total&4294967295)){a.msg="incorrect length check";c.mode=30;break}s=v=0}c.mode=29;case 29:U=1;break a;case 30:U=-3;break a;case 31:return-4;default:return z}a.next_out=A;a.avail_out=q;a.next_in=p;a.avail_in=n;c.hold=v;c.bits=s;if(c.wsize||T!==a.avail_out&&30>c.mode&&(27>c.mode||4!==e))h=a.output,p=a.next_out,A=T-a.avail_out,q=a.state,null===q.window&&(q.wsize=1<<q.wbits,q.wnext=0,q.whave=
0,q.window=new d.Buf8(q.wsize)),A>=q.wsize?(d.arraySet(q.window,h,p-q.wsize,q.wsize,0),q.wnext=0,q.whave=q.wsize):(n=q.wsize-q.wnext,n>A&&(n=A),d.arraySet(q.window,h,p-A,n,q.wnext),(A-=n)?(d.arraySet(q.window,h,p-A,A,0),q.wnext=A,q.whave=q.wsize):(q.wnext+=n,q.wnext===q.wsize&&(q.wnext=0),q.whave<q.wsize&&(q.whave+=n)));x-=a.avail_in;T-=a.avail_out;a.total_in+=x;a.total_out+=T;c.total+=T;c.wrap&&T&&(a.adler=c.check=c.flags?r(c.check,g,T,a.next_out-T):b(c.check,g,T,a.next_out-T));a.data_type=c.bits+
(c.last?64:0)+(12===c.mode?128:0)+(20===c.mode||15===c.mode?256:0);(0===x&&0===T||4===e)&&U===t&&(U=-5);return U};c.inflateEnd=function(b){if(!b||!b.state)return z;var d=b.state;d.window&&(d.window=null);b.state=null;return t};c.inflateGetHeader=function(b,d){var a;if(!b||!b.state)return z;a=b.state;if(0===(a.wrap&2))return z;a.head=d;d.done=!1;return t};c.inflateInfo="pako inflate (from Nodeca project)"},{"../utils/common":2,"./adler32":4,"./crc32":6,"./inffast":8,"./inftrees":10}],10:[function(a,
e,c){var f=a("../utils/common"),n=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],p=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],q=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],g=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64];e.exports=function(a,d,b,c,e,y,t,z){for(var w=z.bits,s=0,x=
0,u=0,C=0,H=0,D=0,G=0,B=0,J=0,P=0,Q,A,Y=null,S=0,v,I=new f.Buf16(16),D=new f.Buf16(16),ba=null,T=0,F,N,Z,s=0;15>=s;s++)I[s]=0;for(x=0;x<c;x++)I[d[b+x]]++;H=w;for(C=15;1<=C&&0===I[C];C--);H>C&&(H=C);if(0===C)return e[y++]=20971520,e[y++]=20971520,z.bits=1,0;for(u=1;u<C&&0===I[u];u++);H<u&&(H=u);for(s=B=1;15>=s;s++)if(B<<=1,B-=I[s],0>B)return-1;if(0<B&&(0===a||1!==C))return-1;D[1]=0;for(s=1;15>s;s++)D[s+1]=D[s]+I[s];for(x=0;x<c;x++)0!==d[b+x]&&(t[D[d[b+x]]++]=x);switch(a){case 0:Y=ba=t;v=19;break;case 1:Y=
n;S-=257;ba=p;T-=257;v=256;break;default:Y=q,ba=g,v=-1}x=P=0;s=u;w=y;D=H;G=0;A=-1;J=1<<H;c=J-1;if(1===a&&852<J||2===a&&592<J)return 1;for(var E=0;;){E++;F=s-G;t[x]<v?(N=0,Z=t[x]):t[x]>v?(N=ba[T+t[x]],Z=Y[S+t[x]]):(N=96,Z=0);B=1<<s-G;u=Q=1<<D;do Q-=B,e[w+(P>>G)+Q]=F<<24|N<<16|Z|0;while(0!==Q);for(B=1<<s-1;P&B;)B>>=1;0!==B?(P&=B-1,P+=B):P=0;x++;if(0===--I[s]){if(s===C)break;s=d[b+t[x]]}if(s>H&&(P&c)!==A){0===G&&(G=H);w+=u;D=s-G;for(B=1<<D;D+G<C;){B-=I[D+G];if(0>=B)break;D++;B<<=1}J+=1<<D;if(1===a&&
852<J||2===a&&592<J)return 1;A=P&c;e[A]=H<<24|D<<16|w-y|0}}0!==P&&(e[w+P]=s-G<<24|4194304);z.bits=H;return 0}},{"../utils/common":2}],11:[function(a,e,c){e.exports={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}},{}],12:[function(a,e,c){e.exports=function(){this.input=null;this.total_in=this.avail_in=this.next_in=0;this.output=null;this.total_out=this.avail_out=this.next_out=
0;this.msg="";this.state=null;this.data_type=2;this.adler=0}},{}]},{},[1])(1)});return{inflate:function(k,a){return f.inflateRaw(k)}}}()})();core.StepDirection={PREVIOUS:1,NEXT:2};core.StepIterator=function(f,k){function a(){d=null;r=b=void 0}function e(){void 0===r&&(r=f.acceptPosition(k)===g);return r}function c(b,d){a();return k.setUnfilteredPosition(b,d)}function m(){d||(d=k.container());return d}function n(){void 0===b&&(b=k.unfilteredDomOffset());return b}function p(){for(a();k.nextPosition();)if(a(),e())return!0;return!1}function q(){for(a();k.previousPosition();)if(a(),e())return!0;return!1}var g=core.PositionFilter.FilterResult.FILTER_ACCEPT,h=core.StepDirection.NEXT,
d,b,r;this.isStep=e;this.setPosition=c;this.container=m;this.offset=n;this.nextStep=p;this.previousStep=q;this.advanceStep=function(b){return b===h?p():q()};this.roundToClosestStep=function(){var b,d,a=e();a||(b=m(),d=n(),a=q(),a||(c(b,d),a=p()));return a};this.roundToPreviousStep=function(){var b=e();b||(b=q());return b};this.roundToNextStep=function(){var b=e();b||(b=p());return b};this.leftNode=function(){return k.leftNode()};this.snapshot=function(){return new core.StepIterator.StepSnapshot(m(),
n())};this.restore=function(b){c(b.container,b.offset)}};core.StepIterator.StepSnapshot=function(f,k){this.container=f;this.offset=k};core.Utils=function(){function f(k,a){if(a&&Array.isArray(a)){k=k||[];if(!Array.isArray(k))throw"Destination is not an array.";k=k.concat(a.map(function(a){return f(null,a)}))}else if(a&&"object"===typeof a){k=k||{};if("object"!==typeof k)throw"Destination is not an object.";Object.keys(a).forEach(function(e){k[e]=f(k[e],a[e])})}else k=a;return k}this.hashString=function(f){var a=0,e,c;e=0;for(c=f.length;e<c;e+=1)a=(a<<5)-a+f.charCodeAt(e),a|=0;return a};this.mergeObjects=function(k,a){Object.keys(a).forEach(function(e){k[e]=
f(k[e],a[e])});return k}};core.Zip=function(f,k){function a(b,a,d){y?d(null,y.subarray(b,b+a)):d("File data not loaded",null)}function e(b){var a=[0,1996959894,3993919788,2567524794,124634137,1886057615,3915621685,2657392035,249268274,2044508324,3772115230,2547177864,162941995,2125561021,3887607047,2428444049,498536548,1789927666,4089016648,2227061214,450548861,1843258603,4107580753,2211677639,325883990,1684777152,4251122042,2321926636,335633487,1661365465,4195302755,2366115317,997073096,1281953886,3579855332,2724688242,1006888145,
1258607687,3524101629,2768942443,901097722,1119000684,3686517206,2898065728,853044451,1172266101,3705015759,2882616665,651767980,1373503546,3369554304,3218104598,565507253,1454621731,3485111705,3099436303,671266974,1594198024,3322730930,2970347812,795835527,1483230225,3244367275,3060149565,1994146192,31158534,2563907772,4023717930,1907459465,112637215,2680153253,3904427059,2013776290,251722036,2517215374,3775830040,2137656763,141376813,2439277719,3865271297,1802195444,476864866,2238001368,4066508878,
1812370925,453092731,2181625025,4111451223,1706088902,314042704,2344532202,4240017532,1658658271,366619977,2362670323,4224994405,1303535960,984961486,2747007092,3569037538,1256170817,1037604311,2765210733,3554079995,1131014506,879679996,2909243462,3663771856,1141124467,855842277,2852801631,3708648649,1342533948,654459306,3188396048,3373015174,1466479909,544179635,3110523913,3462522015,1591671054,702138776,2966460450,3352799412,1504918807,783551873,3082640443,3233442989,3988292384,2596254646,62317068,
1957810842,3939845945,2647816111,81470997,1943803523,3814918930,2489596804,225274430,2053790376,3826175755,2466906013,167816743,2097651377,4027552580,2265490386,503444072,1762050814,4150417245,2154129355,426522225,1852507879,4275313526,2312317920,282753626,1742555852,4189708143,2394877945,397917763,1622183637,3604390888,2714866558,953729732,1340076626,3518719985,2797360999,1068828381,1219638859,3624741850,2936675148,906185462,1090812512,3747672003,2825379669,829329135,1181335161,3412177804,3160834842,
628085408,1382605366,3423369109,3138078467,570562233,1426400815,3317316542,2998733608,733239954,1555261956,3268935591,3050360625,752459403,1541320221,2607071920,3965973030,1969922972,40735498,2617837225,3943577151,1913087877,83908371,2512341634,3803740692,2075208622,213261112,2463272603,3855990285,2094854071,198958881,2262029012,4057260610,1759359992,534414190,2176718541,4139329115,1873836001,414664567,2282248934,4279200368,1711684554,285281116,2405801727,4167216745,1634467795,376229701,2685067896,
3608007406,1308918612,956543938,2808555105,3495958263,1231636301,1047427035,2932959818,3654703836,1088359270,936918E3,2847714899,3736837829,1202900863,817233897,3183342108,3401237130,1404277552,615818150,3134207493,3453421203,1423857449,601450431,3009837614,3294710456,1567103746,711928724,3020668471,3272380065,1510334235,755167117],d,c,e=b.length,h=0,h=0;d=-1;for(c=0;c<e;c+=1)h=(d^b[c])&255,h=a[h],d=d>>>8^h;return d^-1}function c(b){return new Date((b>>25&127)+1980,(b>>21&15)-1,b>>16&31,b>>11&15,
b>>5&63,(b&31)<<1)}function m(b){var d=b.getFullYear();return 1980>d?0:d-1980<<25|b.getMonth()+1<<21|b.getDate()<<16|b.getHours()<<11|b.getMinutes()<<5|b.getSeconds()>>1}function n(b,d){var e,h,l,g,r,f,m,n=this;this.load=function(d){if(null!==n.data)d(null,n.data);else{var c=r+34+h+l+256;c+m>t&&(c=t-m);a(m,c,function(a,c){if(a||null===c)d(a,c);else a:{var e=c,h=new core.ByteArray(e),l=h.readUInt32LE(),m;if(67324752!==l)d("File entry signature is wrong."+l.toString()+" "+e.length.toString(),null);
else{h.pos+=22;l=h.readUInt16LE();m=h.readUInt16LE();h.pos+=l+m;if(g){e=e.subarray(h.pos,h.pos+r);if(r!==e.length){d("The amount of compressed bytes read was "+e.length.toString()+" instead of "+r.toString()+" for "+n.filename+" in "+b+".",null);break a}e=w(e,f)}else e=e.subarray(h.pos,h.pos+f);f!==e.length?d("The amount of bytes read was "+e.length.toString()+" instead of "+f.toString()+" for "+n.filename+" in "+b+".",null):(n.data=e,d(null,e))}}})}};this.set=function(b,d,a,c){n.filename=b;n.data=
d;n.compressed=a;n.date=c};this.error=null;d&&(e=d.readUInt32LE(),33639248!==e?this.error="Central directory entry has wrong signature at position "+(d.pos-4).toString()+' for file "'+b+'": '+d.data.length.toString():(d.pos+=6,g=d.readUInt16LE(),this.date=c(d.readUInt32LE()),d.readUInt32LE(),r=d.readUInt32LE(),f=d.readUInt32LE(),h=d.readUInt16LE(),l=d.readUInt16LE(),e=d.readUInt16LE(),d.pos+=8,m=d.readUInt32LE(),this.filename=runtime.byteArrayToString(d.data.subarray(d.pos,d.pos+h),"utf8"),this.data=
null,d.pos+=h+l+e))}function p(b,d){if(22!==b.length)d("Central directory length should be 22.",s);else{var c=new core.ByteArray(b),e;e=c.readUInt32LE();101010256!==e?d("Central directory signature is wrong: "+e.toString(),s):(e=c.readUInt16LE(),0!==e?d("Zip files with non-zero disk numbers are not supported.",s):(e=c.readUInt16LE(),0!==e?d("Zip files with non-zero disk numbers are not supported.",s):(e=c.readUInt16LE(),z=c.readUInt16LE(),e!==z?d("Number of entries is inconsistent.",s):(e=c.readUInt32LE(),
c=c.readUInt16LE(),c=t-22-e,a(c,t-c,function(b,a){if(b||null===a)d(b,s);else a:{var c=new core.ByteArray(a),e,h;l=[];for(e=0;e<z;e+=1){h=new n(f,c);if(h.error){d(h.error,s);break a}l[l.length]=h}d(null,s)}})))))}}function q(b,d){var a=null,c,e;for(e=0;e<l.length;e+=1)if(c=l[e],c.filename===b){a=c;break}a?a.data?d(null,a.data):a.load(d):d(b+" not found.",null)}function g(b){var d=new core.ByteArrayWriter("utf8"),a=0;d.appendArray([80,75,3,4,20,0,0,0,0,0]);b.data&&(a=b.data.length);d.appendUInt32LE(m(b.date));
d.appendUInt32LE(b.data?e(b.data):0);d.appendUInt32LE(a);d.appendUInt32LE(a);d.appendUInt16LE(b.filename.length);d.appendUInt16LE(0);d.appendString(b.filename);b.data&&d.appendByteArray(b.data);return d}function h(b,d){var a=new core.ByteArrayWriter("utf8"),c=0;a.appendArray([80,75,1,2,20,0,20,0,0,0,0,0]);b.data&&(c=b.data.length);a.appendUInt32LE(m(b.date));a.appendUInt32LE(b.data?e(b.data):0);a.appendUInt32LE(c);a.appendUInt32LE(c);a.appendUInt16LE(b.filename.length);a.appendArray([0,0,0,0,0,0,
0,0,0,0,0,0]);a.appendUInt32LE(d);a.appendString(b.filename);return a}function d(b,a){if(b===l.length)a(null);else{var c=l[b];null!==c.data?d(b+1,a):c.load(function(c){c?a(c):d(b+1,a)})}}function b(b,a){d(0,function(d){if(d)a(d);else{var c,e,r=new core.ByteArrayWriter("utf8"),f=[0];for(c=0;c<l.length;c+=1)r.appendByteArrayWriter(g(l[c])),f.push(r.getLength());d=r.getLength();for(c=0;c<l.length;c+=1)e=l[c],r.appendByteArrayWriter(h(e,f[c]));c=r.getLength()-d;r.appendArray([80,75,5,6,0,0,0,0]);r.appendUInt16LE(l.length);
r.appendUInt16LE(l.length);r.appendUInt32LE(c);r.appendUInt32LE(d);r.appendArray([0,0]);b(r.getByteArray())}})}function r(d,a){b(function(b){runtime.writeFile(d,b,function(d){d||(y=b,t=y.length);a(d)})},a)}var l,y,t,z,w=core.RawInflate.inflate,s=this,x=new core.Base64;this.load=q;this.save=function(b,d,a,c){var e,h;for(e=0;e<l.length;e+=1)if(h=l[e],h.filename===b){h.set(b,d,a,c);return}h=new n(f);h.set(b,d,a,c);l.push(h)};this.remove=function(b){var d,a;for(d=0;d<l.length;d+=1)if(a=l[d],a.filename===
b)return l.splice(d,1),!0;return!1};this.write=function(b){r(f,b)};this.writeAs=r;this.createByteArray=b;this.loadContentXmlAsFragments=function(b,d){s.loadAsString(b,function(b,a){if(b)return d.rootElementReady(b);d.rootElementReady(null,a,!0)})};this.loadAsString=function(b,d){q(b,function(b,a){if(b||null===a)return d(b,null);var c=runtime.byteArrayToString(a,"utf8");d(null,c)})};this.loadAsDOM=function(b,d){s.loadAsString(b,function(b,a){if(b||null===a)d(b,null);else{var c=(new DOMParser).parseFromString(a,
"text/xml");d(null,c)}})};this.loadAsDataURL=function(b,d,a){q(b,function(b,c){if(b||!c)return a(b,null);var e=0,h;d||(d=80===c[1]&&78===c[2]&&71===c[3]?"image/png":255===c[0]&&216===c[1]&&255===c[2]?"image/jpeg":71===c[0]&&73===c[1]&&70===c[2]?"image/gif":"");for(h="data:"+d+";base64,";e<c.length;)h+=x.convertUTF8ArrayToBase64(c.subarray(e,Math.min(e+45E3,c.length))),e+=45E3;a(null,h)})};this.getEntries=function(){return l.slice()};t=-1;null===k?l=[]:runtime.readFile(f,"binary",function(b,d){"string"===
typeof d&&(b="file was read as a string. Should be Uint8Array.");b||!d||0===d.length?k("File '"+f+"' cannot be read. Err: "+(b||"[none]"),s):(y=d,t=y.length,a(t-22,22,function(b,d){b||null===d?k(b,s):p(d,k)}))})};core.SimpleClientRect=null;gui.CommonConstraints={EDIT:{ANNOTATIONS:{ONLY_DELETE_OWN:"onlyDeleteOwn"},REVIEW_MODE:"reviewMode"}};gui.SessionConstraints=function(){function f(e){k.hasOwnProperty(e)||(k[e]=!1,a.register(e))}var k={},a=new core.EventNotifier;this.registerConstraint=f;this.subscribe=function(e,c){f(e);a.subscribe(e,c)};this.unsubscribe=function(e,c){a.unsubscribe(e,c)};this.setState=function(e,c){runtime.assert(!0===k.hasOwnProperty(e),"No such constraint");k[e]!==c&&(k[e]=c,a.emit(e,c))};this.getState=function(a){runtime.assert(!0===k.hasOwnProperty(a),"No such constraint");return k[a]}};gui.BlacklistNamespaceNodeFilter=function(f){var k={},a=NodeFilter.FILTER_REJECT,e=NodeFilter.FILTER_ACCEPT;this.acceptNode=function(c){return!c||k.hasOwnProperty(c.namespaceURI)?a:e};(function(){f.forEach(function(a){k[a]=!0})})()};odf.Namespaces={namespaceMap:{config:"urn:oasis:names:tc:opendocument:xmlns:config:1.0",db:"urn:oasis:names:tc:opendocument:xmlns:database:1.0",dc:"http://purl.org/dc/elements/1.1/",dr3d:"urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0",draw:"urn:oasis:names:tc:opendocument:xmlns:drawing:1.0",chart:"urn:oasis:names:tc:opendocument:xmlns:chart:1.0",fo:"urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0",form:"urn:oasis:names:tc:opendocument:xmlns:form:1.0",math:"http://www.w3.org/1998/Math/MathML",
meta:"urn:oasis:names:tc:opendocument:xmlns:meta:1.0",number:"urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0",office:"urn:oasis:names:tc:opendocument:xmlns:office:1.0",presentation:"urn:oasis:names:tc:opendocument:xmlns:presentation:1.0",style:"urn:oasis:names:tc:opendocument:xmlns:style:1.0",svg:"urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0",table:"urn:oasis:names:tc:opendocument:xmlns:table:1.0",text:"urn:oasis:names:tc:opendocument:xmlns:text:1.0",xforms:"http://www.w3.org/2002/xforms",
xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace"},prefixMap:{},configns:"urn:oasis:names:tc:opendocument:xmlns:config:1.0",dbns:"urn:oasis:names:tc:opendocument:xmlns:database:1.0",dcns:"http://purl.org/dc/elements/1.1/",dr3dns:"urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0",drawns:"urn:oasis:names:tc:opendocument:xmlns:drawing:1.0",chartns:"urn:oasis:names:tc:opendocument:xmlns:chart:1.0",fons:"urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0",formns:"urn:oasis:names:tc:opendocument:xmlns:form:1.0",
mathns:"http://www.w3.org/1998/Math/MathML",metans:"urn:oasis:names:tc:opendocument:xmlns:meta:1.0",numberns:"urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0",officens:"urn:oasis:names:tc:opendocument:xmlns:office:1.0",presentationns:"urn:oasis:names:tc:opendocument:xmlns:presentation:1.0",stylens:"urn:oasis:names:tc:opendocument:xmlns:style:1.0",svgns:"urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0",tablens:"urn:oasis:names:tc:opendocument:xmlns:table:1.0",textns:"urn:oasis:names:tc:opendocument:xmlns:text:1.0",
xformsns:"http://www.w3.org/2002/xforms",xlinkns:"http://www.w3.org/1999/xlink",xmlns:"http://www.w3.org/XML/1998/namespace"};(function(){var f=odf.Namespaces.namespaceMap,k=odf.Namespaces.prefixMap,a;for(a in f)f.hasOwnProperty(a)&&(k[f[a]]=a)})();odf.Namespaces.forEachPrefix=function(f){var k=odf.Namespaces.namespaceMap,a;for(a in k)k.hasOwnProperty(a)&&f(a,k[a])};
odf.Namespaces.lookupNamespaceURI=function(f){var k=null;odf.Namespaces.namespaceMap.hasOwnProperty(f)&&(k=odf.Namespaces.namespaceMap[f]);return k};odf.Namespaces.lookupPrefix=function(f){var k=odf.Namespaces.prefixMap;return k.hasOwnProperty(f)?k[f]:null};odf.Namespaces.lookupNamespaceURI.lookupNamespaceURI=odf.Namespaces.lookupNamespaceURI;(function(){odf.OdfSchemaImpl=function(){var f=[["config:config-item","uncategorized"],["form:item","object"],["form:option","uncategorized"],["math:math","field"],["meta:user-defined","uncategorized"],["number:currency-symbol","uncategorized"],["number:embedded-text","uncategorized"],["number:text","uncategorized"],["presentation:date-time-decl","uncategorized"],["presentation:footer-decl","uncategorized"],["presentation:header-decl","uncategorized"],["svg:desc","text"],["svg:title","text"],["table:desc",
"uncategorized"],["table:title","uncategorized"],["text:a","text"],["text:author-initials","field"],["text:author-name","field"],["text:bibliography-mark","field"],["text:bookmark-ref","field"],["text:chapter","field"],["text:character-count","field"],["text:conditional-text","field"],["text:creation-date","field"],["text:creation-time","field"],["text:creator","field"],["text:database-display","field"],["text:database-name","field"],["text:database-row-number","field"],["text:date","field"],["text:dde-connection",
"field"],["text:description","field"],["text:editing-cycles","field"],["text:editing-duration","field"],["text:execute-macro","uncategorized"],["text:expression","uncategorized"],["text:file-name","field"],["text:h","text"],["text:hidden-paragraph","text"],["text:hidden-text","text"],["text:image-count","field"],["text:index-entry-span","uncategorized"],["text:index-title-template","uncategorized"],["text:initial-creator","field"],["text:keywords","field"],["text:linenumbering-separator","style"],
["text:measure","uncategorized"],["text:meta","uncategorized"],["text:meta-field","uncategorized"],["text:modification-date","field"],["text:modification-time","field"],["text:note-citation","field"],["text:note-continuation-notice-backward","style"],["text:note-continuation-notice-forward","style"],["text:note-ref","field"],["text:object-count","field"],["text:p","text"],["text:page-continuation","uncategorized"],["text:page-count","field"],["text:page-number","field"],["text:page-variable-get",
"field"],["text:page-variable-set","field"],["text:paragraph-count","field"],["text:placeholder","field"],["text:print-date","field"],["text:print-time","field"],["text:printed-by","field"],["text:reference-ref","field"],["text:ruby-base","text"],["text:ruby-text","text"],["text:script","text"],["text:sender-city","field"],["text:sender-company","field"],["text:sender-country","field"],["text:sender-email","field"],["text:sender-fax","field"],["text:sender-firstname","field"],["text:sender-initials",
"field"],["text:sender-lastname","field"],["text:sender-phone-private","field"],["text:sender-phone-work","field"],["text:sender-position","field"],["text:sender-postal-code","field"],["text:sender-state-or-province","field"],["text:sender-street","field"],["text:sender-title","field"],["text:sequence","uncategorized"],["text:sequence-ref","uncategorized"],["text:sheet-name","uncategorized"],["text:span","text"],["text:subject","field"],["text:table-count","field"],["text:table-formula","deprecated"],
["text:template-name","uncategorized"],["text:text-input","field"],["text:time","field"],["text:title","field"],["text:user-defined","field"],["text:user-field-get","field"],["text:user-field-input","field"],["text:variable-get","field"],["text:variable-input","field"],["text:variable-set","field"],["text:word-count","field"],["xforms:model","uncategorized"]],k={};this.isTextContainer=function(a,e){return"text"===k[a+":"+e]};this.isField=function(a,e){return"field"===k[a+":"+e]};this.getFields=function(){return f.filter(function(a){return"field"===
a[1]}).map(function(a){return a[0]})};(function(){f.forEach(function(a){var e=a[1],c=a[0].split(":");a=c[0];var c=c[1],f=odf.Namespaces.lookupNamespaceURI(a);f?k[f+":"+c]=e:runtime.log("DEBUG: OdfSchema - unknown prefix '"+a+"'")})})()};odf.OdfSchema=new odf.OdfSchemaImpl})();odf.OdfUtilsImpl=function(){function f(b){return"image"===(b&&b.localName)&&b.namespaceURI===S}function k(b){return null!==b&&b.nodeType===Node.ELEMENT_NODE&&"frame"===b.localName&&b.namespaceURI===S&&"as-char"===b.getAttributeNS(Y,"anchor-type")}function a(b){var d;(d="annotation"===(b&&b.localName)&&b.namespaceURI===odf.Namespaces.officens)||(d="div"===(b&&b.localName)&&"annotationWrapper"===b.className);return d}function e(b){return"a"===(b&&b.localName)&&b.namespaceURI===Y}function c(b){var d=
b&&b.localName;return("p"===d||"h"===d)&&b.namespaceURI===Y}function m(b,d){for(b&&void 0!==d&&!c(b)&&b.childNodes.item(d)&&(b=b.childNodes.item(d));b&&!c(b);)b=b.parentNode;return b}function n(b,d){for(;b&&b!==d;){if(b.namespaceURI===odf.Namespaces.officens&&"annotation"===b.localName)return b;b=b.parentNode}return null}function p(b){return/^[ \t\r\n]+$/.test(b)}function q(b){if(null===b||b.nodeType!==Node.ELEMENT_NODE)return!1;var d=b.localName;return T.isTextContainer(b.namespaceURI,d)||"span"===
d&&"webodf-annotationHighlight"===b.className}function g(b){return null===b||b.nodeType!==Node.ELEMENT_NODE?!1:T.isField(b.namespaceURI,b.localName)}function h(b){var d=b&&b.localName,a=!1;d&&(b=b.namespaceURI,b===Y&&(a="s"===d||"tab"===d||"line-break"===d));return a}function d(b){return h(b)||g(b)||k(b)||a(b)}function b(b){var d=b&&b.localName,a=!1;d&&(b=b.namespaceURI,b===Y&&(a="s"===d));return a}function r(b){return-1!==ba.indexOf(b.namespaceURI)}function l(b){if(h(b)||g(b))return!1;if(q(b.parentNode)&&
b.nodeType===Node.TEXT_NODE)return 0===b.textContent.length;for(b=b.firstChild;b;){if(r(b)||!l(b))return!1;b=b.nextSibling}return!0}function y(b){for(;null!==b.firstChild&&q(b);)b=b.firstChild;return b}function t(b){for(;null!==b.lastChild&&q(b);)b=b.lastChild;return b}function z(b){for(;!c(b)&&null===b.previousSibling;)b=b.parentNode;return c(b)?null:t(b.previousSibling)}function w(b){for(;!c(b)&&null===b.nextSibling;)b=b.parentNode;return c(b)?null:y(b.nextSibling)}function s(a){for(var c=!1;a;)if(a.nodeType===
Node.TEXT_NODE)if(0===a.length)a=z(a);else return!p(a.data.substr(a.length-1,1));else d(a)?(c=!1===b(a),a=null):a=z(a);return c}function x(b){var a=!1,c;for(b=b&&y(b);b;){c=b.nodeType===Node.TEXT_NODE?b.length:0;if(0<c&&!p(b.data)){a=!0;break}if(d(b)){a=!0;break}b=w(b)}return a}function u(b,d){return p(b.data.substr(d))?!x(w(b)):!1}function C(b,a){var c=b.data,e;if(!p(c[a])||d(b.parentNode))return!1;0<a?p(c[a-1])||(e=!0):s(z(b))&&(e=!0);return!0===e?u(b,a)?!1:!0:!1}function H(b){return(b=/(-?[0-9]*[0-9][0-9]*(\.[0-9]*)?|0+\.[0-9]*[1-9][0-9]*|\.[0-9]*[1-9][0-9]*)((cm)|(mm)|(in)|(pt)|(pc)|(px)|(%))/.exec(b))?
{value:parseFloat(b[1]),unit:b[3]}:null}function D(b){return(b=H(b))&&(0>b.value||"%"===b.unit)?null:b}function G(b){return(b=H(b))&&"%"!==b.unit?null:b}function B(b){switch(b.namespaceURI){case odf.Namespaces.drawns:case odf.Namespaces.svgns:case odf.Namespaces.dr3dns:return!1;case odf.Namespaces.textns:switch(b.localName){case "note-body":case "ruby-text":return!1}break;case odf.Namespaces.officens:switch(b.localName){case "annotation":case "binary-data":case "event-listeners":return!1}break;default:switch(b.localName){case "cursor":case "editinfo":return!1}}return!0}
function J(b,d){for(;0<d.length&&!I.rangeContainsNode(b,d[0]);)d.shift();for(;0<d.length&&!I.rangeContainsNode(b,d[d.length-1]);)d.pop()}function P(b,c,e){var l;l=I.getNodesInRange(b,function(b){var c=NodeFilter.FILTER_REJECT;if(h(b.parentNode)||g(b.parentNode)||a(b))c=NodeFilter.FILTER_REJECT;else if(b.nodeType===Node.TEXT_NODE){if(e||Boolean(m(b)&&(!p(b.textContent)||C(b,0))))c=NodeFilter.FILTER_ACCEPT}else if(d(b))c=NodeFilter.FILTER_ACCEPT;else if(B(b)||q(b))c=NodeFilter.FILTER_SKIP;return c},
NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_TEXT);c||J(b,l);return l}function Q(b,d,c){for(;b;){if(c(b)){d[0]!==b&&d.unshift(b);break}if(a(b))break;b=b.parentNode}}function A(b,d){var a=b;if(d<a.childNodes.length-1)a=a.childNodes[d+1];else{for(;!a.nextSibling;)a=a.parentNode;a=a.nextSibling}for(;a.firstChild;)a=a.firstChild;return a}var Y=odf.Namespaces.textns,S=odf.Namespaces.drawns,v=odf.Namespaces.xlinkns,I=core.DomUtils,ba=[odf.Namespaces.dbns,odf.Namespaces.dcns,odf.Namespaces.dr3dns,odf.Namespaces.drawns,
odf.Namespaces.chartns,odf.Namespaces.formns,odf.Namespaces.numberns,odf.Namespaces.officens,odf.Namespaces.presentationns,odf.Namespaces.stylens,odf.Namespaces.svgns,odf.Namespaces.tablens,odf.Namespaces.textns],T=odf.OdfSchema;this.isImage=f;this.isCharacterFrame=k;this.isInlineRoot=a;this.isTextSpan=function(b){return"span"===(b&&b.localName)&&b.namespaceURI===Y};this.isHyperlink=e;this.getHyperlinkTarget=function(b){return b.getAttributeNS(v,"href")||""};this.isParagraph=c;this.getParagraphElement=
m;this.getParentAnnotation=n;this.isWithinAnnotation=function(b,d){return Boolean(n(b,d))};this.getAnnotationCreator=function(b){return b.getElementsByTagNameNS(odf.Namespaces.dcns,"creator")[0].textContent};this.isListItem=function(b){return"list-item"===(b&&b.localName)&&b.namespaceURI===Y};this.isLineBreak=function(b){return"line-break"===(b&&b.localName)&&b.namespaceURI===Y};this.isODFWhitespace=p;this.isGroupingElement=q;this.isFieldElement=g;this.isCharacterElement=h;this.isAnchoredAsCharacterElement=
d;this.isSpaceElement=b;this.isODFNode=r;this.hasNoODFContent=l;this.firstChild=y;this.lastChild=t;this.previousNode=z;this.nextNode=w;this.scanLeftForNonSpace=s;this.lookLeftForCharacter=function(b){var a,c=a=0;b.nodeType===Node.TEXT_NODE&&(c=b.length);0<c?(a=b.data,a=p(a.substr(c-1,1))?1===c?s(z(b))?2:0:p(a.substr(c-2,1))?0:2:1):d(b)&&(a=1);return a};this.lookRightForCharacter=function(b){var a=!1,c=0;b&&b.nodeType===Node.TEXT_NODE&&(c=b.length);0<c?a=!p(b.data.substr(0,1)):d(b)&&(a=!0);return a};
this.scanLeftForAnyCharacter=function(b){var a=!1,c;for(b=b&&t(b);b;){c=b.nodeType===Node.TEXT_NODE?b.length:0;if(0<c&&!p(b.data)){a=!0;break}if(d(b)){a=!0;break}b=z(b)}return a};this.scanRightForAnyCharacter=x;this.isTrailingWhitespace=u;this.isSignificantWhitespace=C;this.isDowngradableSpaceElement=function(d){return b(d)?s(z(d))&&x(w(d)):!1};this.parseLength=H;this.parseNonNegativeLength=D;this.parseFoFontSize=function(b){var d;d=(d=H(b))&&(0>=d.value||"%"===d.unit)?null:d;return d||G(b)};this.parseFoLineHeight=
function(b){return D(b)||G(b)};this.isTextContentContainingNode=B;this.getTextNodes=function(b,d){var a;a=I.getNodesInRange(b,function(b){var d=NodeFilter.FILTER_REJECT;b.nodeType===Node.TEXT_NODE?Boolean(m(b)&&(!p(b.textContent)||C(b,0)))&&(d=NodeFilter.FILTER_ACCEPT):B(b)&&(d=NodeFilter.FILTER_SKIP);return d},NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_TEXT);d||J(b,a);return a};this.getTextElements=P;this.getParagraphElements=function(b){var d;d=I.getNodesInRange(b,function(b){var d=NodeFilter.FILTER_REJECT;
if(c(b))d=NodeFilter.FILTER_ACCEPT;else if(B(b)||q(b))d=NodeFilter.FILTER_SKIP;return d},NodeFilter.SHOW_ELEMENT);Q(b.startContainer,d,c);return d};this.getImageElements=function(b){var d;d=I.getNodesInRange(b,function(b){var d=NodeFilter.FILTER_SKIP;f(b)&&(d=NodeFilter.FILTER_ACCEPT);return d},NodeFilter.SHOW_ELEMENT);Q(b.startContainer,d,f);return d};this.getHyperlinkElements=function(b){var d=[],a=b.cloneRange();b.collapsed&&b.endContainer.nodeType===Node.ELEMENT_NODE&&(b=A(b.endContainer,b.endOffset),
b.nodeType===Node.TEXT_NODE&&a.setEnd(b,1));P(a,!0,!1).forEach(function(b){for(b=b.parentNode;!c(b);){if(e(b)&&-1===d.indexOf(b)){d.push(b);break}b=b.parentNode}});a.detach();return d};this.getNormalizedFontFamilyName=function(b){/^(["'])(?:.|[\n\r])*?\1$/.test(b)||(b=b.replace(/^[ \t\r\n\f]*((?:.|[\n\r])*?)[ \t\r\n\f]*$/,"$1"),/[ \t\r\n\f]/.test(b)&&(b="'"+b.replace(/[ \t\r\n\f]+/g," ")+"'"));return b}};odf.OdfUtils=new odf.OdfUtilsImpl;gui.OdfTextBodyNodeFilter=function(){var f=odf.OdfUtils,k=Node.TEXT_NODE,a=NodeFilter.FILTER_REJECT,e=NodeFilter.FILTER_ACCEPT,c=odf.Namespaces.textns;this.acceptNode=function(m){if(m.nodeType===k){if(!f.isGroupingElement(m.parentNode))return a}else if(m.namespaceURI===c&&"tracked-changes"===m.localName)return a;return e}};xmldom.LSSerializerFilter=function(){};xmldom.LSSerializerFilter.prototype.acceptNode=function(f){};odf.OdfNodeFilter=function(){this.acceptNode=function(f){return"http://www.w3.org/1999/xhtml"===f.namespaceURI?NodeFilter.FILTER_SKIP:f.namespaceURI&&f.namespaceURI.match(/^urn:webodf:/)?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}};xmldom.XPathIterator=function(){};xmldom.XPathIterator.prototype.next=function(){};xmldom.XPathIterator.prototype.reset=function(){};
function createXPathSingleton(){function f(a,d,b){return-1!==a&&(a<d||-1===d)&&(a<b||-1===b)}function k(a){for(var d=[],b=0,c=a.length,e;b<c;){var m=a,n=c,p=d,k="",q=[],x=m.indexOf("[",b),u=m.indexOf("/",b),C=m.indexOf("=",b);f(u,x,C)?(k=m.substring(b,u),b=u+1):f(x,u,C)?(k=m.substring(b,x),b=g(m,x,q)):f(C,u,x)?(k=m.substring(b,C),b=C):(k=m.substring(b,n),b=n);p.push({location:k,predicates:q});if(b<c&&"="===a[b]){e=a.substring(b+1,c);if(2<e.length&&("'"===e[0]||'"'===e[0]))e=e.slice(1,e.length-1);
else try{e=parseInt(e,10)}catch(H){}b=c}}return{steps:d,value:e}}function a(){var a=null,d=!1;this.setNode=function(b){a=b};this.reset=function(){d=!1};this.next=function(){var b=d?null:a;d=!0;return b}}function e(a,d,b){this.reset=function(){a.reset()};this.next=function(){for(var c=a.next();c;){c.nodeType===Node.ELEMENT_NODE&&(c=c.getAttributeNodeNS(d,b));if(c)break;c=a.next()}return c}}function c(a,d){var b=a.next(),c=null;this.reset=function(){a.reset();b=a.next();c=null};this.next=function(){for(;b;){if(c)if(d&&
c.firstChild)c=c.firstChild;else{for(;!c.nextSibling&&c!==b;)c=c.parentNode;c===b?b=a.next():c=c.nextSibling}else{do(c=b.firstChild)||(b=a.next());while(b&&!c)}if(c&&c.nodeType===Node.ELEMENT_NODE)return c}return null}}function m(a,d){this.reset=function(){a.reset()};this.next=function(){for(var b=a.next();b&&!d(b);)b=a.next();return b}}function n(a,d,b){d=d.split(":",2);var c=b(d[0]),e=d[1];return new m(a,function(b){return b.localName===e&&b.namespaceURI===c})}function p(c,d,b){var e=new a,l=q(e,
d,b),g=d.value;return void 0===g?new m(c,function(b){e.setNode(b);l.reset();return null!==l.next()}):new m(c,function(b){e.setNode(b);l.reset();return(b=l.next())?b.nodeValue===g:!1})}var q,g;g=function(a,d,b){for(var c=d,e=a.length,g=0;c<e;)"]"===a[c]?(g-=1,0>=g&&b.push(k(a.substring(d,c)))):"["===a[c]&&(0>=g&&(d=c+1),g+=1),c+=1;return c};q=function(a,d,b){var g,l,f,m;for(g=0;g<d.steps.length;g+=1){f=d.steps[g];l=f.location;if(""===l)a=new c(a,!1);else if("@"===l[0]){l=l.substr(1).split(":",2);m=
b(l[0]);if(!m)throw"No namespace associated with the prefix "+l[0];a=new e(a,m,l[1])}else"."!==l&&(a=new c(a,!1),-1!==l.indexOf(":")&&(a=n(a,l,b)));for(l=0;l<f.predicates.length;l+=1)m=f.predicates[l],a=p(a,m,b)}return a};return{getODFElementsWithXPath:function(c,d,b){var e=c.ownerDocument,l=[],g=null;if(e&&"function"===typeof e.evaluate)for(b=e.evaluate(d,c,b,XPathResult.UNORDERED_NODE_ITERATOR_TYPE,null),g=b.iterateNext();null!==g;)g.nodeType===Node.ELEMENT_NODE&&l.push(g),g=b.iterateNext();else{l=
new a;l.setNode(c);c=k(d);l=q(l,c,b);c=[];for(b=l.next();b;)c.push(b),b=l.next();l=c}return l}}}xmldom.XPath=createXPathSingleton();odf.StyleInfo=function(){function f(b,d){var a,c,e,l,h,g=0;if(a=D[b.localName])if(e=a[b.namespaceURI])g=e.length;for(a=0;a<g;a+=1)c=e[a],l=c.ns,h=c.localname,(c=b.getAttributeNS(l,h))&&b.setAttributeNS(l,C[l]+h,d+c);for(e=b.firstElementChild;e;)f(e,d),e=e.nextElementSibling}function k(b,d){var a,c,e,l,h,g=0;if(a=D[b.localName])if(e=a[b.namespaceURI])g=e.length;for(a=0;a<g;a+=1)if(c=e[a],l=c.ns,h=c.localname,c=b.getAttributeNS(l,h))c=c.replace(d,""),b.setAttributeNS(l,C[l]+h,c);for(e=b.firstElementChild;e;)k(e,
d),e=e.nextElementSibling}function a(b,d){var a,c,e,l,h,g=0;if(a=D[b.localName])if(e=a[b.namespaceURI])g=e.length;for(a=0;a<g;a+=1)if(l=e[a],c=l.ns,h=l.localname,c=b.getAttributeNS(c,h))d=d||{},l=l.keyname,d.hasOwnProperty(l)?d[l][c]=1:(h={},h[c]=1,d[l]=h);return d}function e(b,d){var c,l;a(b,d);for(c=b.firstChild;c;)c.nodeType===Node.ELEMENT_NODE&&(l=c,e(l,d)),c=c.nextSibling}function c(b,d,a){this.key=b;this.name=d;this.family=a;this.requires={}}function m(b,d,a){var e=b+'"'+d,l=a[e];l||(l=a[e]=
new c(e,b,d));return l}function n(b,d,a){var c,e,l,h,g,r=0;c=b.getAttributeNS(s,"name");h=b.getAttributeNS(s,"family");c&&h&&(d=m(c,h,a));if(d){if(c=D[b.localName])if(l=c[b.namespaceURI])r=l.length;for(c=0;c<r;c+=1)if(h=l[c],e=h.ns,g=h.localname,e=b.getAttributeNS(e,g))h=h.keyname,h=m(e,h,a),d.requires[h.key]=h}for(b=b.firstElementChild;b;)n(b,d,a),b=b.nextElementSibling;return a}function p(b,d){var a=d[b.family];a||(a=d[b.family]={});a[b.name]=1;Object.keys(b.requires).forEach(function(a){p(b.requires[a],
d)})}function q(b,d){var a=n(b,null,{});Object.keys(a).forEach(function(b){b=a[b];var c=d[b.family];c&&c.hasOwnProperty(b.name)&&p(b,d)})}function g(b,d){function a(d){(d=l.getAttributeNS(s,d))&&(b[d]=!0)}var c=["font-name","font-name-asian","font-name-complex"],e,l;for(e=d&&d.firstElementChild;e;)l=e,c.forEach(a),g(b,l),e=e.nextElementSibling}function h(b,d){function a(b){var c=l.getAttributeNS(s,b);c&&d.hasOwnProperty(c)&&l.setAttributeNS(s,"style:"+b,d[c])}var c=["font-name","font-name-asian",
"font-name-complex"],e,l;for(e=b&&b.firstElementChild;e;)l=e,c.forEach(a),h(l,d),e=e.nextElementSibling}var d=odf.Namespaces.chartns,b=odf.Namespaces.dbns,r=odf.Namespaces.dr3dns,l=odf.Namespaces.drawns,y=odf.Namespaces.formns,t=odf.Namespaces.numberns,z=odf.Namespaces.officens,w=odf.Namespaces.presentationns,s=odf.Namespaces.stylens,x=odf.Namespaces.tablens,u=odf.Namespaces.textns,C={"urn:oasis:names:tc:opendocument:xmlns:chart:1.0":"chart:","urn:oasis:names:tc:opendocument:xmlns:database:1.0":"db:",
"urn:oasis:names:tc:opendocument:xmlns:dr3d:1.0":"dr3d:","urn:oasis:names:tc:opendocument:xmlns:drawing:1.0":"draw:","urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0":"fo:","urn:oasis:names:tc:opendocument:xmlns:form:1.0":"form:","urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0":"number:","urn:oasis:names:tc:opendocument:xmlns:office:1.0":"office:","urn:oasis:names:tc:opendocument:xmlns:presentation:1.0":"presentation:","urn:oasis:names:tc:opendocument:xmlns:style:1.0":"style:","urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0":"svg:",
"urn:oasis:names:tc:opendocument:xmlns:table:1.0":"table:","urn:oasis:names:tc:opendocument:xmlns:text:1.0":"chart:","http://www.w3.org/XML/1998/namespace":"xml:"},H={text:[{ens:s,en:"tab-stop",ans:s,a:"leader-text-style"},{ens:s,en:"drop-cap",ans:s,a:"style-name"},{ens:u,en:"notes-configuration",ans:u,a:"citation-body-style-name"},{ens:u,en:"notes-configuration",ans:u,a:"citation-style-name"},{ens:u,en:"a",ans:u,a:"style-name"},{ens:u,en:"alphabetical-index",ans:u,a:"style-name"},{ens:u,en:"linenumbering-configuration",
ans:u,a:"style-name"},{ens:u,en:"list-level-style-number",ans:u,a:"style-name"},{ens:u,en:"ruby-text",ans:u,a:"style-name"},{ens:u,en:"span",ans:u,a:"style-name"},{ens:u,en:"a",ans:u,a:"visited-style-name"},{ens:s,en:"text-properties",ans:s,a:"text-line-through-text-style"},{ens:u,en:"alphabetical-index-source",ans:u,a:"main-entry-style-name"},{ens:u,en:"index-entry-bibliography",ans:u,a:"style-name"},{ens:u,en:"index-entry-chapter",ans:u,a:"style-name"},{ens:u,en:"index-entry-link-end",ans:u,a:"style-name"},
{ens:u,en:"index-entry-link-start",ans:u,a:"style-name"},{ens:u,en:"index-entry-page-number",ans:u,a:"style-name"},{ens:u,en:"index-entry-span",ans:u,a:"style-name"},{ens:u,en:"index-entry-tab-stop",ans:u,a:"style-name"},{ens:u,en:"index-entry-text",ans:u,a:"style-name"},{ens:u,en:"index-title-template",ans:u,a:"style-name"},{ens:u,en:"list-level-style-bullet",ans:u,a:"style-name"},{ens:u,en:"outline-level-style",ans:u,a:"style-name"}],paragraph:[{ens:l,en:"caption",ans:l,a:"text-style-name"},{ens:l,
en:"circle",ans:l,a:"text-style-name"},{ens:l,en:"connector",ans:l,a:"text-style-name"},{ens:l,en:"control",ans:l,a:"text-style-name"},{ens:l,en:"custom-shape",ans:l,a:"text-style-name"},{ens:l,en:"ellipse",ans:l,a:"text-style-name"},{ens:l,en:"frame",ans:l,a:"text-style-name"},{ens:l,en:"line",ans:l,a:"text-style-name"},{ens:l,en:"measure",ans:l,a:"text-style-name"},{ens:l,en:"path",ans:l,a:"text-style-name"},{ens:l,en:"polygon",ans:l,a:"text-style-name"},{ens:l,en:"polyline",ans:l,a:"text-style-name"},
{ens:l,en:"rect",ans:l,a:"text-style-name"},{ens:l,en:"regular-polygon",ans:l,a:"text-style-name"},{ens:z,en:"annotation",ans:l,a:"text-style-name"},{ens:y,en:"column",ans:y,a:"text-style-name"},{ens:s,en:"style",ans:s,a:"next-style-name"},{ens:x,en:"body",ans:x,a:"paragraph-style-name"},{ens:x,en:"even-columns",ans:x,a:"paragraph-style-name"},{ens:x,en:"even-rows",ans:x,a:"paragraph-style-name"},{ens:x,en:"first-column",ans:x,a:"paragraph-style-name"},{ens:x,en:"first-row",ans:x,a:"paragraph-style-name"},
{ens:x,en:"last-column",ans:x,a:"paragraph-style-name"},{ens:x,en:"last-row",ans:x,a:"paragraph-style-name"},{ens:x,en:"odd-columns",ans:x,a:"paragraph-style-name"},{ens:x,en:"odd-rows",ans:x,a:"paragraph-style-name"},{ens:u,en:"notes-configuration",ans:u,a:"default-style-name"},{ens:u,en:"alphabetical-index-entry-template",ans:u,a:"style-name"},{ens:u,en:"bibliography-entry-template",ans:u,a:"style-name"},{ens:u,en:"h",ans:u,a:"style-name"},{ens:u,en:"illustration-index-entry-template",ans:u,a:"style-name"},
{ens:u,en:"index-source-style",ans:u,a:"style-name"},{ens:u,en:"object-index-entry-template",ans:u,a:"style-name"},{ens:u,en:"p",ans:u,a:"style-name"},{ens:u,en:"table-index-entry-template",ans:u,a:"style-name"},{ens:u,en:"table-of-content-entry-template",ans:u,a:"style-name"},{ens:u,en:"table-index-entry-template",ans:u,a:"style-name"},{ens:u,en:"user-index-entry-template",ans:u,a:"style-name"},{ens:s,en:"page-layout-properties",ans:s,a:"register-truth-ref-style-name"}],chart:[{ens:d,en:"axis",ans:d,
a:"style-name"},{ens:d,en:"chart",ans:d,a:"style-name"},{ens:d,en:"data-label",ans:d,a:"style-name"},{ens:d,en:"data-point",ans:d,a:"style-name"},{ens:d,en:"equation",ans:d,a:"style-name"},{ens:d,en:"error-indicator",ans:d,a:"style-name"},{ens:d,en:"floor",ans:d,a:"style-name"},{ens:d,en:"footer",ans:d,a:"style-name"},{ens:d,en:"grid",ans:d,a:"style-name"},{ens:d,en:"legend",ans:d,a:"style-name"},{ens:d,en:"mean-value",ans:d,a:"style-name"},{ens:d,en:"plot-area",ans:d,a:"style-name"},{ens:d,en:"regression-curve",
ans:d,a:"style-name"},{ens:d,en:"series",ans:d,a:"style-name"},{ens:d,en:"stock-gain-marker",ans:d,a:"style-name"},{ens:d,en:"stock-loss-marker",ans:d,a:"style-name"},{ens:d,en:"stock-range-line",ans:d,a:"style-name"},{ens:d,en:"subtitle",ans:d,a:"style-name"},{ens:d,en:"title",ans:d,a:"style-name"},{ens:d,en:"wall",ans:d,a:"style-name"}],section:[{ens:u,en:"alphabetical-index",ans:u,a:"style-name"},{ens:u,en:"bibliography",ans:u,a:"style-name"},{ens:u,en:"illustration-index",ans:u,a:"style-name"},
{ens:u,en:"index-title",ans:u,a:"style-name"},{ens:u,en:"object-index",ans:u,a:"style-name"},{ens:u,en:"section",ans:u,a:"style-name"},{ens:u,en:"table-of-content",ans:u,a:"style-name"},{ens:u,en:"table-index",ans:u,a:"style-name"},{ens:u,en:"user-index",ans:u,a:"style-name"}],ruby:[{ens:u,en:"ruby",ans:u,a:"style-name"}],table:[{ens:b,en:"query",ans:b,a:"style-name"},{ens:b,en:"table-representation",ans:b,a:"style-name"},{ens:x,en:"background",ans:x,a:"style-name"},{ens:x,en:"table",ans:x,a:"style-name"}],
"table-column":[{ens:b,en:"column",ans:b,a:"style-name"},{ens:x,en:"table-column",ans:x,a:"style-name"}],"table-row":[{ens:b,en:"query",ans:b,a:"default-row-style-name"},{ens:b,en:"table-representation",ans:b,a:"default-row-style-name"},{ens:x,en:"table-row",ans:x,a:"style-name"}],"table-cell":[{ens:b,en:"column",ans:b,a:"default-cell-style-name"},{ens:x,en:"table-column",ans:x,a:"default-cell-style-name"},{ens:x,en:"table-row",ans:x,a:"default-cell-style-name"},{ens:x,en:"body",ans:x,a:"style-name"},
{ens:x,en:"covered-table-cell",ans:x,a:"style-name"},{ens:x,en:"even-columns",ans:x,a:"style-name"},{ens:x,en:"covered-table-cell",ans:x,a:"style-name"},{ens:x,en:"even-columns",ans:x,a:"style-name"},{ens:x,en:"even-rows",ans:x,a:"style-name"},{ens:x,en:"first-column",ans:x,a:"style-name"},{ens:x,en:"first-row",ans:x,a:"style-name"},{ens:x,en:"last-column",ans:x,a:"style-name"},{ens:x,en:"last-row",ans:x,a:"style-name"},{ens:x,en:"odd-columns",ans:x,a:"style-name"},{ens:x,en:"odd-rows",ans:x,a:"style-name"},
{ens:x,en:"table-cell",ans:x,a:"style-name"}],graphic:[{ens:r,en:"cube",ans:l,a:"style-name"},{ens:r,en:"extrude",ans:l,a:"style-name"},{ens:r,en:"rotate",ans:l,a:"style-name"},{ens:r,en:"scene",ans:l,a:"style-name"},{ens:r,en:"sphere",ans:l,a:"style-name"},{ens:l,en:"caption",ans:l,a:"style-name"},{ens:l,en:"circle",ans:l,a:"style-name"},{ens:l,en:"connector",ans:l,a:"style-name"},{ens:l,en:"control",ans:l,a:"style-name"},{ens:l,en:"custom-shape",ans:l,a:"style-name"},{ens:l,en:"ellipse",ans:l,a:"style-name"},
{ens:l,en:"frame",ans:l,a:"style-name"},{ens:l,en:"g",ans:l,a:"style-name"},{ens:l,en:"line",ans:l,a:"style-name"},{ens:l,en:"measure",ans:l,a:"style-name"},{ens:l,en:"page-thumbnail",ans:l,a:"style-name"},{ens:l,en:"path",ans:l,a:"style-name"},{ens:l,en:"polygon",ans:l,a:"style-name"},{ens:l,en:"polyline",ans:l,a:"style-name"},{ens:l,en:"rect",ans:l,a:"style-name"},{ens:l,en:"regular-polygon",ans:l,a:"style-name"},{ens:z,en:"annotation",ans:l,a:"style-name"}],presentation:[{ens:r,en:"cube",ans:w,
a:"style-name"},{ens:r,en:"extrude",ans:w,a:"style-name"},{ens:r,en:"rotate",ans:w,a:"style-name"},{ens:r,en:"scene",ans:w,a:"style-name"},{ens:r,en:"sphere",ans:w,a:"style-name"},{ens:l,en:"caption",ans:w,a:"style-name"},{ens:l,en:"circle",ans:w,a:"style-name"},{ens:l,en:"connector",ans:w,a:"style-name"},{ens:l,en:"control",ans:w,a:"style-name"},{ens:l,en:"custom-shape",ans:w,a:"style-name"},{ens:l,en:"ellipse",ans:w,a:"style-name"},{ens:l,en:"frame",ans:w,a:"style-name"},{ens:l,en:"g",ans:w,a:"style-name"},
{ens:l,en:"line",ans:w,a:"style-name"},{ens:l,en:"measure",ans:w,a:"style-name"},{ens:l,en:"page-thumbnail",ans:w,a:"style-name"},{ens:l,en:"path",ans:w,a:"style-name"},{ens:l,en:"polygon",ans:w,a:"style-name"},{ens:l,en:"polyline",ans:w,a:"style-name"},{ens:l,en:"rect",ans:w,a:"style-name"},{ens:l,en:"regular-polygon",ans:w,a:"style-name"},{ens:z,en:"annotation",ans:w,a:"style-name"}],"drawing-page":[{ens:l,en:"page",ans:l,a:"style-name"},{ens:w,en:"notes",ans:l,a:"style-name"},{ens:s,en:"handout-master",
ans:l,a:"style-name"},{ens:s,en:"master-page",ans:l,a:"style-name"}],"list-style":[{ens:u,en:"list",ans:u,a:"style-name"},{ens:u,en:"numbered-paragraph",ans:u,a:"style-name"},{ens:u,en:"list-item",ans:u,a:"style-override"},{ens:s,en:"style",ans:s,a:"list-style-name"}],data:[{ens:s,en:"style",ans:s,a:"data-style-name"},{ens:s,en:"style",ans:s,a:"percentage-data-style-name"},{ens:w,en:"date-time-decl",ans:s,a:"data-style-name"},{ens:u,en:"creation-date",ans:s,a:"data-style-name"},{ens:u,en:"creation-time",
ans:s,a:"data-style-name"},{ens:u,en:"database-display",ans:s,a:"data-style-name"},{ens:u,en:"date",ans:s,a:"data-style-name"},{ens:u,en:"editing-duration",ans:s,a:"data-style-name"},{ens:u,en:"expression",ans:s,a:"data-style-name"},{ens:u,en:"meta-field",ans:s,a:"data-style-name"},{ens:u,en:"modification-date",ans:s,a:"data-style-name"},{ens:u,en:"modification-time",ans:s,a:"data-style-name"},{ens:u,en:"print-date",ans:s,a:"data-style-name"},{ens:u,en:"print-time",ans:s,a:"data-style-name"},{ens:u,
en:"table-formula",ans:s,a:"data-style-name"},{ens:u,en:"time",ans:s,a:"data-style-name"},{ens:u,en:"user-defined",ans:s,a:"data-style-name"},{ens:u,en:"user-field-get",ans:s,a:"data-style-name"},{ens:u,en:"user-field-input",ans:s,a:"data-style-name"},{ens:u,en:"variable-get",ans:s,a:"data-style-name"},{ens:u,en:"variable-input",ans:s,a:"data-style-name"},{ens:u,en:"variable-set",ans:s,a:"data-style-name"}],"page-layout":[{ens:w,en:"notes",ans:s,a:"page-layout-name"},{ens:s,en:"handout-master",ans:s,
a:"page-layout-name"},{ens:s,en:"master-page",ans:s,a:"page-layout-name"}]},D,G=xmldom.XPath;this.collectUsedFontFaces=g;this.changeFontFaceNames=h;this.UsedStyleList=function(b,d){var a={};this.uses=function(b){var d=b.localName,c=b.getAttributeNS(l,"name")||b.getAttributeNS(s,"name");b="style"===d?b.getAttributeNS(s,"family"):b.namespaceURI===t?"data":d;return(b=a[b])?0<b[c]:!1};e(b,a);d&&q(d,a)};this.getStyleName=function(b,d){var a,c,e=D[d.localName];if(e&&(e=e[d.namespaceURI]))for(c=0;c<e.length;c+=
1)if(e[c].keyname===b&&(e=e[c],d.hasAttributeNS(e.ns,e.localname))){a=d.getAttributeNS(e.ns,e.localname);break}return a};this.hasDerivedStyles=function(b,d,a){var c=a.getAttributeNS(s,"name");a=a.getAttributeNS(s,"family");return G.getODFElementsWithXPath(b,'//style:*[@style:parent-style-name="'+c+'"][@style:family="'+a+'"]',d).length?!0:!1};this.prefixStyleNames=function(b,d,a){var c;if(b){for(c=b.firstChild;c;){if(c.nodeType===Node.ELEMENT_NODE){var e=c,h=d,g=e.getAttributeNS(l,"name"),r=void 0;
g?r=l:(g=e.getAttributeNS(s,"name"))&&(r=s);r&&e.setAttributeNS(r,C[r]+"name",h+g)}c=c.nextSibling}f(b,d);a&&f(a,d)}};this.removePrefixFromStyleNames=function(b,d,a){var c=RegExp("^"+d);if(b){for(d=b.firstChild;d;){if(d.nodeType===Node.ELEMENT_NODE){var e=d,h=c,g=e.getAttributeNS(l,"name"),r=void 0;g?r=l:(g=e.getAttributeNS(s,"name"))&&(r=s);r&&(g=g.replace(h,""),e.setAttributeNS(r,C[r]+"name",g))}d=d.nextSibling}k(b,c);a&&k(a,c)}};this.determineStylesForNode=a;D=function(){var b,d,a,c,e,l={},h,g,
r,f;for(a in H)if(H.hasOwnProperty(a))for(c=H[a],d=c.length,b=0;b<d;b+=1)e=c[b],r=e.en,f=e.ens,l.hasOwnProperty(r)?h=l[r]:l[r]=h={},h.hasOwnProperty(f)?g=h[f]:h[f]=g=[],g.push({ns:e.ans,localname:e.a,keyname:a});return l}()};"function"!==typeof Object.create&&(Object.create=function(f){var k=function(){};k.prototype=f;return new k});
xmldom.LSSerializer=function(){function f(a){var e=a||{},f=function(a){var d={},b;for(b in a)a.hasOwnProperty(b)&&(d[a[b]]=b);return d}(a),p=[e],k=[f],g=0;this.push=function(){g+=1;e=p[g]=Object.create(e);f=k[g]=Object.create(f)};this.pop=function(){p.pop();k.pop();g-=1;e=p[g];f=k[g]};this.getLocalNamespaceDefinitions=function(){return f};this.getQName=function(a){var d=a.namespaceURI,b=0,c;if(!d)return a.localName;if(c=f[d])return c+":"+a.localName;do{c||!a.prefix?(c="ns"+b,b+=1):c=a.prefix;if(e[c]===
d)break;if(!e[c]){e[c]=d;f[d]=c;break}c=null}while(null===c);return c+":"+a.localName}}function k(a){return a.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/'/g,"&apos;").replace(/"/g,"&quot;")}function a(c,f){var n="",p=e.filter?e.filter.acceptNode(f):NodeFilter.FILTER_ACCEPT,q;if(p===NodeFilter.FILTER_ACCEPT&&f.nodeType===Node.ELEMENT_NODE){c.push();q=c.getQName(f);var g,h=f.attributes,d,b,r,l="",y;g="<"+q;d=h.length;for(b=0;b<d;b+=1)r=h.item(b),"http://www.w3.org/2000/xmlns/"!==
r.namespaceURI&&(y=e.filter?e.filter.acceptNode(r):NodeFilter.FILTER_ACCEPT,y===NodeFilter.FILTER_ACCEPT&&(y=c.getQName(r),r="string"===typeof r.value?k(r.value):r.value,l+=" "+(y+'="'+r+'"')));d=c.getLocalNamespaceDefinitions();for(b in d)d.hasOwnProperty(b)&&((h=d[b])?"xmlns"!==h&&(g+=" xmlns:"+d[b]+'="'+b+'"'):g+=' xmlns="'+b+'"');n+=g+(l+">")}if(p===NodeFilter.FILTER_ACCEPT||p===NodeFilter.FILTER_SKIP){for(p=f.firstChild;p;)n+=a(c,p),p=p.nextSibling;f.nodeValue&&(n+=k(f.nodeValue))}q&&(n+="</"+
q+">",c.pop());return n}var e=this;this.filter=null;this.writeToString=function(c,e){if(!c)return"";var n=new f(e);return a(n,c)}};(function(){function f(a){var d,b=p.length;for(d=0;d<b;d+=1)if("urn:oasis:names:tc:opendocument:xmlns:office:1.0"===a.namespaceURI&&a.localName===p[d])return d;return-1}function k(a,d){var b=new c.UsedStyleList(a,d),e=new odf.OdfNodeFilter;this.acceptNode=function(a){var c=e.acceptNode(a);c===NodeFilter.FILTER_ACCEPT&&a.parentNode===d&&a.nodeType===Node.ELEMENT_NODE&&(c=b.uses(a)?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_REJECT);return c}}function a(a,d){var b=new k(a,d);this.acceptNode=function(a){var d=
b.acceptNode(a);d!==NodeFilter.FILTER_ACCEPT||!a.parentNode||a.parentNode.namespaceURI!==odf.Namespaces.textns||"s"!==a.parentNode.localName&&"tab"!==a.parentNode.localName||(d=NodeFilter.FILTER_REJECT);return d}}function e(a,d){if(d){var b=f(d),c,e=a.firstChild;if(-1!==b){for(;e;){c=f(e);if(-1!==c&&c>b)break;e=e.nextSibling}a.insertBefore(d,e)}}}var c=new odf.StyleInfo,m=core.DomUtils,n=odf.Namespaces.stylens,p="meta settings scripts font-face-decls styles automatic-styles master-styles body".split(" "),
q=Date.now()+"_webodf_",g=new core.Base64;odf.ODFElement=function(){};odf.ODFDocumentElement=function(){};odf.ODFDocumentElement.prototype=new odf.ODFElement;odf.ODFDocumentElement.prototype.constructor=odf.ODFDocumentElement;odf.ODFDocumentElement.prototype.fontFaceDecls=null;odf.ODFDocumentElement.prototype.manifest=null;odf.ODFDocumentElement.prototype.settings=null;odf.ODFDocumentElement.namespaceURI="urn:oasis:names:tc:opendocument:xmlns:office:1.0";odf.ODFDocumentElement.localName="document";
odf.AnnotationElement=function(){};odf.OdfPart=function(a,d,b,c){var e=this;this.size=0;this.type=null;this.name=a;this.container=b;this.url=null;this.mimetype=d;this.onstatereadychange=this.document=null;this.EMPTY=0;this.LOADING=1;this.DONE=2;this.state=this.EMPTY;this.data="";this.load=function(){null!==c&&(this.mimetype=d,c.loadAsDataURL(a,d,function(b,a){b&&runtime.log(b);e.url=a;if(e.onchange)e.onchange(e);if(e.onstatereadychange)e.onstatereadychange(e)}))}};odf.OdfPart.prototype.load=function(){};
odf.OdfPart.prototype.getUrl=function(){return this.data?"data:;base64,"+g.toBase64(this.data):null};odf.OdfContainer=function d(b,f){function l(b){for(var a=b.firstChild,d;a;)d=a.nextSibling,a.nodeType===Node.ELEMENT_NODE?l(a):a.nodeType===Node.PROCESSING_INSTRUCTION_NODE&&b.removeChild(a),a=d}function p(b){var a={},d,c,e=b.ownerDocument.createNodeIterator(b,NodeFilter.SHOW_ELEMENT,null,!1);for(b=e.nextNode();b;)"urn:oasis:names:tc:opendocument:xmlns:office:1.0"===b.namespaceURI&&("annotation"===
b.localName?(d=b.getAttributeNS("urn:oasis:names:tc:opendocument:xmlns:office:1.0","name"))&&(a.hasOwnProperty(d)?runtime.log("Warning: annotation name used more than once with <office:annotation/>: '"+d+"'"):a[d]=b):"annotation-end"===b.localName&&((d=b.getAttributeNS("urn:oasis:names:tc:opendocument:xmlns:office:1.0","name"))?a.hasOwnProperty(d)?(c=a[d],c.annotationEndElement?runtime.log("Warning: annotation name used more than once with <office:annotation-end/>: '"+d+"'"):c.annotationEndElement=
b):runtime.log("Warning: annotation end without an annotation start, name: '"+d+"'"):runtime.log("Warning: annotation end without a name found"))),b=e.nextNode()}function t(b,a){for(var d=b&&b.firstChild;d;)d.nodeType===Node.ELEMENT_NODE&&d.setAttributeNS("urn:webodf:names:scope","scope",a),d=d.nextSibling}function z(b,a){for(var d=U.rootElement.meta,d=d&&d.firstChild;d&&(d.namespaceURI!==b||d.localName!==a);)d=d.nextSibling;for(d=d&&d.firstChild;d&&d.nodeType!==Node.TEXT_NODE;)d=d.nextSibling;return d?
d.data:null}function w(b){var a={},d;for(b=b.firstChild;b;)b.nodeType===Node.ELEMENT_NODE&&b.namespaceURI===n&&"font-face"===b.localName&&(d=b.getAttributeNS(n,"name"),a[d]=b),b=b.nextSibling;return a}function s(b,a){var d=null,c,e,l;if(b)for(d=b.cloneNode(!0),c=d.firstElementChild;c;)e=c.nextElementSibling,(l=c.getAttributeNS("urn:webodf:names:scope","scope"))&&l!==a&&d.removeChild(c),c=e;return d}function x(b,a){var d,e,l,g=null,f={};if(b)for(a.forEach(function(b){c.collectUsedFontFaces(f,b)}),
g=b.cloneNode(!0),d=g.firstElementChild;d;)e=d.nextElementSibling,l=d.getAttributeNS(n,"name"),f[l]||g.removeChild(d),d=e;return g}function u(b){var d=U.rootElement.ownerDocument,a;if(b){l(b.documentElement);try{a=d.importNode(b.documentElement,!0)}catch(c){}}return a}function C(b){U.state=b;if(U.onchange)U.onchange(U);if(U.onstatereadychange)U.onstatereadychange(U)}function H(b){aa=null;U.rootElement=b;b.fontFaceDecls=m.getDirectChild(b,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","font-face-decls");
b.styles=m.getDirectChild(b,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","styles");b.automaticStyles=m.getDirectChild(b,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","automatic-styles");b.masterStyles=m.getDirectChild(b,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","master-styles");b.body=m.getDirectChild(b,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","body");b.meta=m.getDirectChild(b,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","meta");b.settings=m.getDirectChild(b,"urn:oasis:names:tc:opendocument:xmlns:office:1.0",
"settings");b.scripts=m.getDirectChild(b,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","scripts");p(b)}function D(b){var a=u(b),l=U.rootElement,g;a&&"document-styles"===a.localName&&"urn:oasis:names:tc:opendocument:xmlns:office:1.0"===a.namespaceURI?(l.fontFaceDecls=m.getDirectChild(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","font-face-decls"),e(l,l.fontFaceDecls),g=m.getDirectChild(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","styles"),l.styles=g||b.createElementNS("urn:oasis:names:tc:opendocument:xmlns:office:1.0",
"styles"),e(l,l.styles),g=m.getDirectChild(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","automatic-styles"),l.automaticStyles=g||b.createElementNS("urn:oasis:names:tc:opendocument:xmlns:office:1.0","automatic-styles"),t(l.automaticStyles,"document-styles"),e(l,l.automaticStyles),a=m.getDirectChild(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","master-styles"),l.masterStyles=a||b.createElementNS("urn:oasis:names:tc:opendocument:xmlns:office:1.0","master-styles"),e(l,l.masterStyles),
c.prefixStyleNames(l.automaticStyles,q,l.masterStyles)):C(d.INVALID)}function G(b){b=u(b);var a,l,g,f;if(b&&"document-content"===b.localName&&"urn:oasis:names:tc:opendocument:xmlns:office:1.0"===b.namespaceURI){a=U.rootElement;g=m.getDirectChild(b,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","font-face-decls");if(a.fontFaceDecls&&g){f=a.fontFaceDecls;var r,p,k,q,A={};l=w(f);q=w(g);for(g=g.firstElementChild;g;){r=g.nextElementSibling;if(g.namespaceURI===n&&"font-face"===g.localName)if(p=g.getAttributeNS(n,
"name"),l.hasOwnProperty(p)){if(!g.isEqualNode(l[p])){k=p;for(var s=l,P=q,y=0,Y=void 0,Y=k=k.replace(/\d+$/,"");s.hasOwnProperty(Y)||P.hasOwnProperty(Y);)y+=1,Y=k+y;k=Y;g.setAttributeNS(n,"style:name",k);f.appendChild(g);l[k]=g;delete q[p];A[p]=k}}else f.appendChild(g),l[p]=g,delete q[p];g=r}f=A}else g&&(a.fontFaceDecls=g,e(a,g));l=m.getDirectChild(b,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","automatic-styles");t(l,"document-content");f&&c.changeFontFaceNames(l,f);if(a.automaticStyles&&l)for(f=
l.firstChild;f;)a.automaticStyles.appendChild(f),f=l.firstChild;else l&&(a.automaticStyles=l,e(a,l));b=m.getDirectChild(b,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","body");if(null===b)throw"<office:body/> tag is mising.";a.body=b;e(a,a.body)}else C(d.INVALID)}function B(b){b=u(b);var a;b&&"document-meta"===b.localName&&"urn:oasis:names:tc:opendocument:xmlns:office:1.0"===b.namespaceURI&&(a=U.rootElement,a.meta=m.getDirectChild(b,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","meta"),
e(a,a.meta))}function J(b){b=u(b);var a;b&&"document-settings"===b.localName&&"urn:oasis:names:tc:opendocument:xmlns:office:1.0"===b.namespaceURI&&(a=U.rootElement,a.settings=m.getDirectChild(b,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","settings"),e(a,a.settings))}function P(b){b=u(b);var a;if(b&&"manifest"===b.localName&&"urn:oasis:names:tc:opendocument:xmlns:manifest:1.0"===b.namespaceURI)for(a=U.rootElement,a.manifest=b,b=a.manifest.firstElementChild;b;)"file-entry"===b.localName&&"urn:oasis:names:tc:opendocument:xmlns:manifest:1.0"===
b.namespaceURI&&(O[b.getAttributeNS("urn:oasis:names:tc:opendocument:xmlns:manifest:1.0","full-path")]=b.getAttributeNS("urn:oasis:names:tc:opendocument:xmlns:manifest:1.0","media-type")),b=b.nextElementSibling}function Q(b,a,d){b=m.getElementsByTagName(b,a);var c;for(c=0;c<b.length;c+=1)a=b[c],d.hasOwnProperty(a.namespaceURI)||a.parentNode.removeChild(a)}function A(b){Q(b,"script",{"urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0":!0,"urn:oasis:names:tc:opendocument:xmlns:office:1.0":!0,"urn:oasis:names:tc:opendocument:xmlns:table:1.0":!0,
"urn:oasis:names:tc:opendocument:xmlns:text:1.0":!0,"urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0":!0});Q(b,"style",{"urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0":!0,"urn:oasis:names:tc:opendocument:xmlns:drawing:1.0":!0,"urn:oasis:names:tc:opendocument:xmlns:style:1.0":!0})}function Y(b){var a=b.firstElementChild,d=[],c,e,l,g=b.attributes,f=g.length;for(c=0;c<f;c+=1)l=g.item(c),e=l.localName.substr(0,2).toLowerCase(),null===l.namespaceURI&&"on"===e&&d.push(l);f=d.length;for(c=
0;c<f;c+=1)b.removeAttributeNode(d[c]);for(;a;)Y(a),a=a.nextElementSibling}function S(b){var a=b.shift();a?W.loadAsDOM(a.path,function(c,e){e&&(A(e),Y(e.documentElement));a.handler(e);U.state===d.INVALID?c?runtime.log("ERROR: Unable to load "+a.path+" - "+c):runtime.log("ERROR: Unable to load "+a.path):(c&&runtime.log("DEBUG: Unable to load "+a.path+" - "+c),S(b))}):(p(U.rootElement),C(d.DONE))}function v(b){var a="";odf.Namespaces.forEachPrefix(function(b,d){a+=" xmlns:"+b+'="'+d+'"'});return'<?xml version="1.0" encoding="UTF-8"?><office:'+
b+" "+a+' office:version="1.2">'}function I(){var b=new xmldom.LSSerializer,a=v("document-meta");b.filter=new odf.OdfNodeFilter;a+=b.writeToString(U.rootElement.meta,odf.Namespaces.namespaceMap);return a+"</office:document-meta>"}function ba(b,a){var d=document.createElementNS("urn:oasis:names:tc:opendocument:xmlns:manifest:1.0","manifest:file-entry");d.setAttributeNS("urn:oasis:names:tc:opendocument:xmlns:manifest:1.0","manifest:full-path",b);d.setAttributeNS("urn:oasis:names:tc:opendocument:xmlns:manifest:1.0",
"manifest:media-type",a);return d}function T(){var b=runtime.parseXML('<manifest:manifest xmlns:manifest="urn:oasis:names:tc:opendocument:xmlns:manifest:1.0" manifest:version="1.2"></manifest:manifest>'),a=b.documentElement,d=new xmldom.LSSerializer,c;for(c in O)O.hasOwnProperty(c)&&a.appendChild(ba(c,O[c]));d.filter=new odf.OdfNodeFilter;return'<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\n'+d.writeToString(b,odf.Namespaces.namespaceMap)}function F(){var b,a,d,e=odf.Namespaces.namespaceMap,
l=new xmldom.LSSerializer,g=v("document-styles");a=s(U.rootElement.automaticStyles,"document-styles");d=U.rootElement.masterStyles.cloneNode(!0);b=x(U.rootElement.fontFaceDecls,[d,U.rootElement.styles,a]);c.removePrefixFromStyleNames(a,q,d);l.filter=new k(d,a);g+=l.writeToString(b,e);g+=l.writeToString(U.rootElement.styles,e);g+=l.writeToString(a,e);g+=l.writeToString(d,e);return g+"</office:document-styles>"}function N(){var b,d,c=odf.Namespaces.namespaceMap,e=new xmldom.LSSerializer,l=v("document-content");
d=s(U.rootElement.automaticStyles,"document-content");b=x(U.rootElement.fontFaceDecls,[d]);e.filter=new a(U.rootElement.body,d);l+=e.writeToString(b,c);l+=e.writeToString(d,c);l+=e.writeToString(U.rootElement.body,c);return l+"</office:document-content>"}function Z(b,a){runtime.loadXML(b,function(b,c){if(b)a(b);else if(c){A(c);Y(c.documentElement);var e=u(c);e&&"document"===e.localName&&"urn:oasis:names:tc:opendocument:xmlns:office:1.0"===e.namespaceURI?(H(e),C(d.DONE)):C(d.INVALID)}else a("No DOM was loaded.")})}
function E(b,a){var d;d=U.rootElement;var c=d.meta;c||(d.meta=c=document.createElementNS("urn:oasis:names:tc:opendocument:xmlns:office:1.0","meta"),e(d,c));d=c;b&&m.mapKeyValObjOntoNode(d,b,odf.Namespaces.lookupNamespaceURI);a&&m.removeKeyElementsFromNode(d,a,odf.Namespaces.lookupNamespaceURI)}function V(b,a){function c(b,a){var d;a||(a=b);d=document.createElementNS("urn:oasis:names:tc:opendocument:xmlns:office:1.0",a);f[b]=d;f.appendChild(d)}var e=new core.Zip("",null),l="application/vnd.oasis.opendocument."+
b+(!0===a?"-template":""),g=runtime.byteArrayFromString(l,"utf8"),f=U.rootElement,r=document.createElementNS("urn:oasis:names:tc:opendocument:xmlns:office:1.0",b);e.save("mimetype",g,!1,new Date);c("meta");c("settings");c("scripts");c("fontFaceDecls","font-face-decls");c("styles");c("automaticStyles","automatic-styles");c("masterStyles","master-styles");c("body");f.body.appendChild(r);O["/"]=l;O["settings.xml"]="text/xml";O["meta.xml"]="text/xml";O["styles.xml"]="text/xml";O["content.xml"]="text/xml";
C(d.DONE);return e}function $(){var b,a=new Date,d="";U.rootElement.settings&&U.rootElement.settings.firstElementChild&&(b=new xmldom.LSSerializer,d=v("document-settings"),b.filter=new odf.OdfNodeFilter,d+=b.writeToString(U.rootElement.settings,odf.Namespaces.namespaceMap),d+="</office:document-settings>");(b=d)?(b=runtime.byteArrayFromString(b,"utf8"),W.save("settings.xml",b,!0,a)):W.remove("settings.xml");d=runtime.getWindow();b="WebODF/"+webodf.Version;d&&(b=b+" "+d.navigator.userAgent);E({"meta:generator":b},
null);b=runtime.byteArrayFromString(I(),"utf8");W.save("meta.xml",b,!0,a);b=runtime.byteArrayFromString(F(),"utf8");W.save("styles.xml",b,!0,a);b=runtime.byteArrayFromString(N(),"utf8");W.save("content.xml",b,!0,a);b=runtime.byteArrayFromString(T(),"utf8");W.save("META-INF/manifest.xml",b,!0,a)}function ca(b,a){$();W.writeAs(b,function(b){a(b)})}var U=this,W,O={},aa,R="";this.onstatereadychange=f;this.state=this.onchange=null;this.getMetadata=z;this.setRootElement=H;this.getContentElement=function(){var b;
aa||(b=U.rootElement.body,aa=m.getDirectChild(b,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","text")||m.getDirectChild(b,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","presentation")||m.getDirectChild(b,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","spreadsheet"));if(!aa)throw"Could not find content element in <office:body/>.";return aa};this.getDocumentType=function(){var b=U.getContentElement();return b&&b.localName};this.isTemplate=function(){return"-template"===O["/"].substr(-9)};
this.setIsTemplate=function(b){var a=O["/"],d="-template"===a.substr(-9);b!==d&&(a=b?a+"-template":a.substr(0,a.length-9),O["/"]=a,b=runtime.byteArrayFromString(a,"utf8"),W.save("mimetype",b,!1,new Date))};this.getPart=function(b){return new odf.OdfPart(b,O[b],U,W)};this.getPartData=function(b,a){W.load(b,a)};this.setMetadata=E;this.incrementEditingCycles=function(){var b=z(odf.Namespaces.metans,"editing-cycles"),b=b?parseInt(b,10):0;isNaN(b)&&(b=0);E({"meta:editing-cycles":b+1},null);return b+1};
this.createByteArray=function(b,a){$();W.createByteArray(b,a)};this.saveAs=ca;this.save=function(b){ca(R,b)};this.getUrl=function(){return R};this.setBlob=function(b,a,d){d=g.convertBase64ToByteArray(d);W.save(b,d,!1,new Date);O.hasOwnProperty(b)&&runtime.log(b+" has been overwritten.");O[b]=a};this.removeBlob=function(b){var a=W.remove(b);runtime.assert(a,"file is not found: "+b);delete O[b]};this.state=d.LOADING;this.rootElement=function(b){var a=document.createElementNS(b.namespaceURI,b.localName),
d;b=new b.Type;for(d in b)b.hasOwnProperty(d)&&(a[d]=b[d]);return a}({Type:odf.ODFDocumentElement,namespaceURI:odf.ODFDocumentElement.namespaceURI,localName:odf.ODFDocumentElement.localName});b===odf.OdfContainer.DocumentType.TEXT?W=V("text"):b===odf.OdfContainer.DocumentType.TEXT_TEMPLATE?W=V("text",!0):b===odf.OdfContainer.DocumentType.PRESENTATION?W=V("presentation"):b===odf.OdfContainer.DocumentType.PRESENTATION_TEMPLATE?W=V("presentation",!0):b===odf.OdfContainer.DocumentType.SPREADSHEET?W=V("spreadsheet"):
b===odf.OdfContainer.DocumentType.SPREADSHEET_TEMPLATE?W=V("spreadsheet",!0):(R=b,W=new core.Zip(R,function(b,a){W=a;b?Z(R,function(a){b&&(W.error=b+"\n"+a,C(d.INVALID))}):S([{path:"styles.xml",handler:D},{path:"content.xml",handler:G},{path:"meta.xml",handler:B},{path:"settings.xml",handler:J},{path:"META-INF/manifest.xml",handler:P}])}))};odf.OdfContainer.EMPTY=0;odf.OdfContainer.LOADING=1;odf.OdfContainer.DONE=2;odf.OdfContainer.INVALID=3;odf.OdfContainer.SAVING=4;odf.OdfContainer.MODIFIED=5;odf.OdfContainer.getContainer=
function(a){return new odf.OdfContainer(a,null)}})();odf.OdfContainer.DocumentType={TEXT:1,TEXT_TEMPLATE:2,PRESENTATION:3,PRESENTATION_TEMPLATE:4,SPREADSHEET:5,SPREADSHEET_TEMPLATE:6};gui.AnnotatableCanvas=function(){};gui.AnnotatableCanvas.prototype.refreshSize=function(){};gui.AnnotatableCanvas.prototype.getZoomLevel=function(){};gui.AnnotatableCanvas.prototype.getSizer=function(){};
gui.AnnotationViewManager=function(f,k,a,e){function c(b){var a=b.annotationEndElement,c=h.createRange(),e=b.getAttributeNS(odf.Namespaces.officens,"name");a&&(c.setStart(b,b.childNodes.length),c.setEnd(a,0),b=d.getTextNodes(c,!1),b.forEach(function(b){var a;a:{for(a=b.parentNode;a.namespaceURI!==odf.Namespaces.officens||"body"!==a.localName;){if(a.namespaceURI===r&&"webodf-annotationHighlight"===a.className&&a.getAttribute("annotation")===e){a=!0;break a}a=a.parentNode}a=!1}a||(a=h.createElement("span"),
a.className="webodf-annotationHighlight",a.setAttribute("annotation",e),b.parentNode.replaceChild(a,b),a.appendChild(b))}));c.detach()}function m(d){var c=f.getSizer();d?(a.style.display="inline-block",c.style.paddingRight=b.getComputedStyle(a).width):(a.style.display="none",c.style.paddingRight=0);f.refreshSize()}function n(){g.sort(function(b,a){return 0!==(b.compareDocumentPosition(a)&Node.DOCUMENT_POSITION_FOLLOWING)?-1:1})}function p(){var b;for(b=0;b<g.length;b+=1){var d=g[b],c=d.parentNode,
e=c.nextElementSibling,h=e.nextElementSibling,r=c.parentNode,m=0,m=g[g.indexOf(d)-1],n=void 0,d=f.getZoomLevel();c.style.left=(a.getBoundingClientRect().left-r.getBoundingClientRect().left)/d+"px";c.style.width=a.getBoundingClientRect().width/d+"px";e.style.width=parseFloat(c.style.left)-30+"px";m?(n=m.parentNode.getBoundingClientRect(),20>=(r.getBoundingClientRect().top-n.bottom)/d?c.style.top=Math.abs(r.getBoundingClientRect().top-n.bottom)/d+20+"px":c.style.top="0px"):c.style.top="0px";h.style.left=
e.getBoundingClientRect().width/d+"px";var e=h.style,r=h.getBoundingClientRect().left/d,m=h.getBoundingClientRect().top/d,n=c.getBoundingClientRect().left/d,p=c.getBoundingClientRect().top/d,k=0,q=0,k=n-r,k=k*k,q=p-m,q=q*q,r=Math.sqrt(k+q);e.width=r+"px";m=Math.asin((c.getBoundingClientRect().top-h.getBoundingClientRect().top)/(d*parseFloat(h.style.width)));h.style.transform="rotate("+m+"rad)";h.style.MozTransform="rotate("+m+"rad)";h.style.WebkitTransform="rotate("+m+"rad)";h.style.msTransform="rotate("+
m+"rad)"}}function q(b){var a=g.indexOf(b),d=b.parentNode.parentNode;"div"===d.localName&&(d.parentNode.insertBefore(b,d),d.parentNode.removeChild(d));b=b.getAttributeNS(odf.Namespaces.officens,"name");b=h.querySelectorAll('span.webodf-annotationHighlight[annotation="'+b+'"]');for(var c,d=0;d<b.length;d+=1){for(c=b.item(d);c.firstChild;)c.parentNode.insertBefore(c.firstChild,c);c.parentNode.removeChild(c)}-1!==a&&g.splice(a,1);0===g.length&&m(!1)}var g=[],h=k.ownerDocument,d=odf.OdfUtils,b=runtime.getWindow(),
r="http://www.w3.org/1999/xhtml";runtime.assert(Boolean(b),"Expected to be run in an environment which has a global window, like a browser.");this.rerenderAnnotations=p;this.rehighlightAnnotations=function(){g.forEach(function(b){c(b)})};this.getMinimumHeightForAnnotationPane=function(){return"none"!==a.style.display&&0<g.length?(g[g.length-1].parentNode.getBoundingClientRect().bottom-a.getBoundingClientRect().top)/f.getZoomLevel()+"px":null};this.addAnnotations=function(b){0!==b.length&&(m(!0),b.forEach(function(b){g.push(b);
var a=h.createElement("div"),l=h.createElement("div"),f=h.createElement("div"),r=h.createElement("div"),m;a.className="annotationWrapper";a.setAttribute("creator",d.getAnnotationCreator(b));b.parentNode.insertBefore(a,b);l.className="annotationNote";l.appendChild(b);e&&(m=h.createElement("div"),m.className="annotationRemoveButton",l.appendChild(m));f.className="annotationConnector horizontal";r.className="annotationConnector angular";a.appendChild(l);a.appendChild(f);a.appendChild(r);b.annotationEndElement&&
c(b)}),n(),p())};this.forgetAnnotation=q;this.forgetAnnotations=function(){for(;g.length;)q(g[0])}};gui.Viewport=function(){};gui.Viewport.prototype.scrollIntoView=function(f,k){};gui.SingleScrollViewport=function(f){this.scrollIntoView=function(k,a){var e,c,m,n;n=f.offsetHeight-f.clientHeight;m=f.offsetWidth-f.clientWidth;var p=f.getBoundingClientRect();if(k&&p){e=p.left+5;c=p.top+5;m=p.right-(m+5);n=p.bottom-(n+5);if(a||k.top<c)f.scrollTop-=c-k.top;else if(k.top>n||k.bottom>n)f.scrollTop=k.bottom-k.top<=n-c?f.scrollTop+(k.bottom-n):f.scrollTop+(k.top-c);k.left<e?f.scrollLeft-=e-k.left:k.right>m&&(f.scrollLeft=k.right-k.left<=m-e?f.scrollLeft+(k.right-m):f.scrollLeft-(e-k.left))}}};(function(){function f(a,m,n,p,k){var g,h=0,d;for(d in a)if(a.hasOwnProperty(d)){if(h===n){g=d;break}h+=1}g?m.getPartData(a[g].href,function(b,d){if(b)runtime.log(b);else if(d){var l="@font-face { font-family: "+(a[g].family||g)+"; src: url(data:application/x-font-ttf;charset=binary;base64,"+e.convertUTF8ArrayToBase64(d)+') format("truetype"); }';try{p.insertRule(l,p.cssRules.length)}catch(h){runtime.log("Problem inserting rule in CSS: "+runtime.toJson(h)+"\nRule: "+l)}}else runtime.log("missing font data for "+
a[g].href);f(a,m,n+1,p,k)}):k&&k()}var k=xmldom.XPath,a=odf.OdfUtils,e=new core.Base64;odf.FontLoader=function(){this.loadFonts=function(c,e){for(var n=c.rootElement.fontFaceDecls;e.cssRules.length;)e.deleteRule(e.cssRules.length-1);if(n){var p={},q,g,h,d;if(n)for(n=k.getODFElementsWithXPath(n,"style:font-face[svg:font-face-src]",odf.Namespaces.lookupNamespaceURI),q=0;q<n.length;q+=1)g=n[q],h=g.getAttributeNS(odf.Namespaces.stylens,"name"),d=a.getNormalizedFontFamilyName(g.getAttributeNS(odf.Namespaces.svgns,
"font-family")),g=k.getODFElementsWithXPath(g,"svg:font-face-src/svg:font-face-uri",odf.Namespaces.lookupNamespaceURI),0<g.length&&(g=g[0].getAttributeNS(odf.Namespaces.xlinkns,"href"),p[h]={href:g,family:d});f(p,c,0,e)}}}})();odf.Formatting=function(){function f(b){return(b=C[b])?x.mergeObjects({},b):{}}function k(){for(var b=d.rootElement.fontFaceDecls,a={},c,e,b=b&&b.firstElementChild;b;){if(c=b.getAttributeNS(l,"name"))if((e=b.getAttributeNS(r,"font-family"))||0<b.getElementsByTagNameNS(r,"font-face-uri").length)a[c]=e;b=b.nextElementSibling}return a}function a(b){for(var a=d.rootElement.styles.firstElementChild;a;){if(a.namespaceURI===l&&"default-style"===a.localName&&a.getAttributeNS(l,"family")===b)return a;a=a.nextElementSibling}return null}
function e(b,a,c){var e,g,h;c=c||[d.rootElement.automaticStyles,d.rootElement.styles];for(h=0;h<c.length;h+=1)for(e=c[h],e=e.firstElementChild;e;){g=e.getAttributeNS(l,"name");if(e.namespaceURI===l&&"style"===e.localName&&e.getAttributeNS(l,"family")===a&&g===b||"list-style"===a&&e.namespaceURI===y&&"list-style"===e.localName&&g===b||"data"===a&&e.namespaceURI===t&&g===b)return e;e=e.nextElementSibling}return null}function c(b){for(var a,d,c,e,g={},h=b.firstElementChild;h;){if(h.namespaceURI===l)for(c=
g[h.nodeName]={},d=h.attributes,a=0;a<d.length;a+=1)e=d.item(a),c[e.name]=e.value;h=h.nextElementSibling}d=b.attributes;for(a=0;a<d.length;a+=1)e=d.item(a),g[e.name]=e.value;return g}function m(b,g){for(var h=d.rootElement.styles,r,m={},n=b.getAttributeNS(l,"family"),p=b;p;)r=c(p),m=x.mergeObjects(r,m),p=(r=p.getAttributeNS(l,"parent-style-name"))?e(r,n,[h]):null;if(p=a(n))r=c(p),m=x.mergeObjects(r,m);!1!==g&&(r=f(n),m=x.mergeObjects(r,m));return m}function n(a,c){function e(b){Object.keys(b).forEach(function(a){Object.keys(b[a]).forEach(function(b){f+=
"|"+a+":"+b+"|"})})}for(var l=a.nodeType===Node.TEXT_NODE?a.parentNode:a,g,h=[],f="",r=!1;l&&!w.isInlineRoot(l)&&l.parentNode!==d.rootElement;)!r&&w.isGroupingElement(l)&&(r=!0),(g=b.determineStylesForNode(l))&&h.push(g),l=l.parentNode;r&&(h.forEach(e),c&&(c[f]=h));return r?h:void 0}function p(b){var a={orderedStyles:[],styleProperties:{}};b.forEach(function(b){Object.keys(b).forEach(function(c){var g=Object.keys(b[c])[0],h={name:g,family:c,displayName:void 0,isCommonStyle:!1},f;(f=e(g,c))?(c=m(f),
a.styleProperties=x.mergeObjects(c,a.styleProperties),h.displayName=f.getAttributeNS(l,"display-name")||void 0,h.isCommonStyle=f.parentNode===d.rootElement.styles):runtime.log("No style element found for '"+g+"' of family '"+c+"'");a.orderedStyles.push(h)})});return a}function q(b,a){var d={},c=[];a||(a={});b.forEach(function(b){n(b,d)});Object.keys(d).forEach(function(b){a[b]||(a[b]=p(d[b]));c.push(a[b])});return c}function g(b){for(var a=d.rootElement.masterStyles.firstElementChild;a&&(a.namespaceURI!==
l||"master-page"!==a.localName||a.getAttributeNS(l,"name")!==b);)a=a.nextElementSibling;return a}function h(b,a){var d;b&&(d=u.convertMeasure(b,"px"));void 0===d&&a&&(d=u.convertMeasure(a,"px"));return d}var d,b=new odf.StyleInfo,r=odf.Namespaces.svgns,l=odf.Namespaces.stylens,y=odf.Namespaces.textns,t=odf.Namespaces.numberns,z=odf.Namespaces.fons,w=odf.OdfUtils,s=core.DomUtils,x=new core.Utils,u=new core.CSSUnits,C={paragraph:{"style:paragraph-properties":{"fo:text-align":"left"}}};this.getSystemDefaultStyleAttributes=
f;this.setOdfContainer=function(b){d=b};this.getFontMap=k;this.getAvailableParagraphStyles=function(){for(var b=d.rootElement.styles,a,c,e=[],b=b&&b.firstElementChild;b;)"style"===b.localName&&b.namespaceURI===l&&(a=b.getAttributeNS(l,"family"),"paragraph"===a&&(a=b.getAttributeNS(l,"name"),c=b.getAttributeNS(l,"display-name")||a,a&&c&&e.push({name:a,displayName:c}))),b=b.nextElementSibling;return e};this.isStyleUsed=function(a){var c,e=d.rootElement;c=b.hasDerivedStyles(e,odf.Namespaces.lookupNamespaceURI,
a);a=(new b.UsedStyleList(e.styles)).uses(a)||(new b.UsedStyleList(e.automaticStyles)).uses(a)||(new b.UsedStyleList(e.body)).uses(a);return c||a};this.getDefaultStyleElement=a;this.getStyleElement=e;this.getStyleAttributes=c;this.getInheritedStyleAttributes=m;this.getFirstCommonParentStyleNameOrSelf=function(b){var a=d.rootElement.styles,c;if(c=e(b,"paragraph",[d.rootElement.automaticStyles]))if(b=c.getAttributeNS(l,"parent-style-name"),!b)return null;return(c=e(b,"paragraph",[a]))?b:null};this.hasParagraphStyle=
function(b){return Boolean(e(b,"paragraph"))};this.getAppliedStyles=q;this.getAppliedStylesForElement=function(b,a){return q([b],a)[0]};this.updateStyle=function(b,a){var c,e;s.mapObjOntoNode(b,a,odf.Namespaces.lookupNamespaceURI);(c=(c=a["style:text-properties"])&&c["style:font-name"])&&!k().hasOwnProperty(c)&&(e=b.ownerDocument.createElementNS(l,"style:font-face"),e.setAttributeNS(l,"style:name",c),e.setAttributeNS(r,"svg:font-family",c),d.rootElement.fontFaceDecls.appendChild(e))};this.createDerivedStyleObject=
function(b,a,l){var g=e(b,a);runtime.assert(Boolean(g),"No style element found for '"+b+"' of family '"+a+"'");b=g.parentNode===d.rootElement.styles?{"style:parent-style-name":b}:c(g);b["style:family"]=a;x.mergeObjects(b,l);return b};this.getDefaultTabStopDistance=function(){for(var b=a("paragraph"),b=b&&b.firstElementChild,d;b;)b.namespaceURI===l&&"paragraph-properties"===b.localName&&(d=b.getAttributeNS(l,"tab-stop-distance")),b=b.nextElementSibling;d||(d="1.25cm");return w.parseNonNegativeLength(d)};
this.getMasterPageElement=g;this.getContentSize=function(b,a){var c,f,r,m,n,p,k,q,y,t;a:{f=e(b,a);runtime.assert("paragraph"===a||"table"===a,"styleFamily must be either paragraph or table");if(f){if(f=f.getAttributeNS(l,"master-page-name"))(c=g(f))||runtime.log("WARN: No master page definition found for "+f);c||(c=g("Standard"));c||(c=d.rootElement.masterStyles.getElementsByTagNameNS(l,"master-page")[0])||runtime.log("WARN: Document has no master pages defined");if(c)for(f=c.getAttributeNS(l,"page-layout-name"),
r=d.rootElement.automaticStyles.getElementsByTagNameNS(l,"page-layout"),m=0;m<r.length;m+=1)if(c=r.item(m),c.getAttributeNS(l,"name")===f)break a}c=null}c||(c=s.getDirectChild(d.rootElement.styles,l,"default-page-layout"));(c=s.getDirectChild(c,l,"page-layout-properties"))?("landscape"===c.getAttributeNS(l,"print-orientation")?(f="29.7cm",r="21.001cm"):(f="21.001cm",r="29.7cm"),f=h(c.getAttributeNS(z,"page-width"),f),r=h(c.getAttributeNS(z,"page-height"),r),m=h(c.getAttributeNS(z,"margin")),void 0===
m?(m=h(c.getAttributeNS(z,"margin-left"),"2cm"),n=h(c.getAttributeNS(z,"margin-right"),"2cm"),p=h(c.getAttributeNS(z,"margin-top"),"2cm"),k=h(c.getAttributeNS(z,"margin-bottom"),"2cm")):m=n=p=k=m,q=h(c.getAttributeNS(z,"padding")),void 0===q?(q=h(c.getAttributeNS(z,"padding-left"),"0cm"),y=h(c.getAttributeNS(z,"padding-right"),"0cm"),t=h(c.getAttributeNS(z,"padding-top"),"0cm"),c=h(c.getAttributeNS(z,"padding-bottom"),"0cm")):q=y=t=c=q):(f=h("21.001cm"),r=h("29.7cm"),m=n=p=k=m=h("2cm"),q=y=t=c=q=
h("0cm"));return{width:f-m-n-q-y,height:r-p-k-t-c}}};(function(){var f=odf.Namespaces.stylens,k=odf.Namespaces.textns,a={graphic:"draw","drawing-page":"draw",paragraph:"text",presentation:"presentation",ruby:"text",section:"text",table:"table","table-cell":"table","table-column":"table","table-row":"table",text:"text",list:"text",page:"office"};odf.StyleTreeNode=function(a){this.derivedStyles={};this.element=a};odf.StyleTree=function(e,c){function m(a){var d,b,c,e={};if(!a)return e;for(a=a.firstElementChild;a;){if(b=a.namespaceURI!==f||"style"!==a.localName&&
"default-style"!==a.localName?a.namespaceURI===k&&"list-style"===a.localName?"list":a.namespaceURI!==f||"page-layout"!==a.localName&&"default-page-layout"!==a.localName?void 0:"page":a.getAttributeNS(f,"family"))(d=a.getAttributeNS(f,"name"))||(d=""),e.hasOwnProperty(b)?c=e[b]:e[b]=c={},c[d]=a;a=a.nextElementSibling}return e}function n(a,d){if(a.hasOwnProperty(d))return a[d];var b=null,c=Object.keys(a),e;for(e=0;e<c.length&&!(b=n(a[c[e]].derivedStyles,d));e+=1);return b}function p(a,d,b){var c,e,
g;if(!d.hasOwnProperty(a))return null;c=new odf.StyleTreeNode(d[a]);e=c.element.getAttributeNS(f,"parent-style-name");g=null;e&&(g=n(b,e)||p(e,d,b));g?g.derivedStyles[a]=c:b[a]=c;delete d[a];return c}function q(a,d){a&&Object.keys(a).forEach(function(b){p(b,a,d)})}var g={};this.getStyleTree=function(){return g};(function(){var h,d,b;d=m(e);b=m(c);Object.keys(a).forEach(function(a){h=g[a]={};q(d[a],h);q(b[a],h)})})()}})();(function(){function f(a,c){try{a.insertRule(c,a.cssRules.length)}catch(e){runtime.log("cannot load rule: "+c+" - "+e)}}function k(a,c){this.listCounterCount=0;this.contentRules=a;this.counterIdStack=[];this.continuedCounterIdStack=c}function a(a){function c(b,e,h,n){var p=e.namespaceURI===m&&"list"===e.localName,k=e.namespaceURI===m&&"list-item"===e.localName;if(p||k){if(p){var p=h+=1,s,x,u;n.listCounterCount+=1;k=b+"-level"+p+"-"+n.listCounterCount;e.setAttributeNS("urn:webodf:names:helper","counter-id",
k);s=n.continuedCounterIdStack.shift();s||(s=k,d+=k+" 1 ",x='text|list[webodfhelper|counter-id="'+k+'"] > text|list-item:first-child > :not(text|list):first-child:before',x+="{",x+="counter-increment: "+s+" 0;",x+="}",f(a,x));for(;n.counterIdStack.length>=p;)n.counterIdStack.pop();n.counterIdStack.push(s);u=n.contentRules[p.toString()]||"";for(x=1;x<=p;x+=1)u=u.replace(x+"webodf-listLevel",n.counterIdStack[x-1]);x='text|list[webodfhelper|counter-id="'+k+'"] > text|list-item > :not(text|list):first-child:before';
x+="{";x+=u;x+="counter-increment: "+s+";";x+="}";f(a,x)}for(e=e.firstElementChild;e;)c(b,e,h,n),e=e.nextElementSibling}else n.continuedCounterIdStack=[]}var e=0,d="",b={};this.createCounterRules=function(a,d,f){var m=d.getAttributeNS(n,"id"),p=[];f&&(f=f.getAttributeNS("urn:webodf:names:helper","counter-id"),p=b[f].slice(0));a=new k(a,p);m?m="Y"+m:(e+=1,m="X"+e);c(m,d,0,a);b[m+"-level1-1"]=a.counterIdStack};this.initialiseCreatedCounters=function(){var b;b="office|document{"+("counter-reset: "+d+
";");b+="}";f(a,b)}}var e=odf.Namespaces.fons,c=odf.Namespaces.stylens,m=odf.Namespaces.textns,n=odf.Namespaces.xmlns,p={1:"decimal",a:"lower-latin",A:"upper-latin",i:"lower-roman",I:"upper-roman"};odf.ListStyleToCss=function(){function k(a){var d=r.parseLength(a);return d?b.convert(d.value,d.unit,"px"):(runtime.log("Could not parse value '"+a+"'."),0)}function g(b){return b.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}function h(b,a){var d;b&&(d=b.getAttributeNS(m,"style-name"));return d===a}function d(b,
d,e){d=d.getElementsByTagNameNS(m,"list");b=new a(b);var f,r,k,q,u,C,H={},D;for(D=0;D<d.length;D+=1)if(f=d.item(D),C=f.getAttributeNS(m,"style-name")){k=f.getAttributeNS(m,"continue-numbering");q=f.getAttributeNS(m,"continue-list");(u=f.getAttributeNS(n,"id"))&&(H[u]=f);u=e[C].element.firstElementChild;for(var G=void 0,B={};u;){var G=(G=u.getAttributeNS(m,"level"))&&parseInt(G,10),J=B,P=u,Q="",A=void 0,Y=void 0,S=A=void 0;if("list-level-style-number"===P.localName){var v=P,Q=v.getAttributeNS(c,"num-format"),
A=v.getAttributeNS(c,"num-suffix")||"",Y=v.getAttributeNS(c,"num-prefix")||"",I="",ba=v.getAttributeNS(m,"level"),v=v.getAttributeNS(m,"display-levels");Y&&(I+='"'+g(Y)+'"\n');if(p.hasOwnProperty(Q))for(ba=ba?parseInt(ba,10):1,v=v?parseInt(v,10):1;0<v;)I+=" counter("+(ba-v+1)+"webodf-listLevel,"+p[Q]+")",1<v&&(I+='"."'),v-=1;else I=Q?I+(' "'+Q+'"'):I+' ""';Q="content:"+I+' "'+g(A)+'"'}else"list-level-style-image"===P.localName?Q="content: none":"list-level-style-bullet"===P.localName&&(Q=P.getAttributeNS(m,
"bullet-char"),Q='content: "'+g(Q)+'"');if(A=P.getElementsByTagNameNS(c,"list-level-properties")[0])Y=A.getAttributeNS(m,"list-level-position-and-space-mode"),"label-alignment"===Y&&((A=A.getElementsByTagNameNS(c,"list-level-label-alignment")[0])&&(S=A.getAttributeNS(m,"label-followed-by")),"space"===S&&(Q+=' "\\a0"'));J[G]="\n"+Q+";\n";u=u.nextElementSibling}u=B;k&&!q&&h(r,C)?b.createCounterRules(u,f,r):q&&h(H[q],C)?b.createCounterRules(u,f,H[q]):b.createCounterRules(u,f);r=f}b.initialiseCreatedCounters()}
var b=new core.CSSUnits,r=odf.OdfUtils;this.applyListStyles=function(b,a,g){var h,r;(h=a.list)&&Object.keys(h).forEach(function(a){r=h[a];for(var d=r.element.firstElementChild;d;){if(d.namespaceURI===m){for(var g=b,n=d,p='text|list[text|style-name="'+a+'"]',y=n.getAttributeNS(m,"level"),t=void 0,B=void 0,J=B=void 0,P=void 0,Q=void 0,A=t=void 0,Y=void 0,S=void 0,v=void 0,P=void 0,J=(B=n.getElementsByTagNameNS(c,"list-level-properties")[0])&&B.getAttributeNS(m,"list-level-position-and-space-mode"),
P=B&&B.getElementsByTagNameNS(c,"list-level-label-alignment")[0],t=y=y&&parseInt(y,10);1<t;)p+=" > text|list-item > text|list",t-=1;t=B&&B.getAttributeNS(e,"text-align")||"left";switch(t){case "end":t="right";break;case "start":t="left"}"label-alignment"===J?(Q=P&&P.getAttributeNS(e,"margin-left")||"0px",S=P&&P.getAttributeNS(e,"text-indent")||"0px",v=P&&P.getAttributeNS(m,"label-followed-by"),P=k(Q)):(Q=B&&B.getAttributeNS(m,"space-before")||"0px",A=B&&B.getAttributeNS(m,"min-label-width")||"0px",
Y=B&&B.getAttributeNS(m,"min-label-distance")||"0px",P=k(Q)+k(A));B=p+" > text|list-item";B+="{";B+="margin-left: "+P+"px;";B+="}";f(g,B);B=p+" > text|list-item > text|list";B+="{";B+="margin-left: "+-P+"px;";B+="}";f(g,B);B=p+" > text|list-item > :not(text|list):first-child:before";B+="{";B+="text-align: "+t+";";B+="display: inline-block;";"label-alignment"===J?(B+="margin-left: "+S+";","listtab"===v&&(B+="padding-right: 0.2cm;")):(B+="min-width: "+A+";",B+="margin-left: "+(0===parseFloat(A)?"":
"-")+A+";",B+="padding-right: "+Y+";");B+="}";f(g,B)}d=d.nextElementSibling}});d(b,g,h)}}})();odf.LazyStyleProperties=function(f,k){var a={};this.value=function(e){var c;a.hasOwnProperty(e)?c=a[e]:(c=k[e](),void 0===c&&f&&(c=f.value(e)),a[e]=c);return c};this.reset=function(e){f=e;a={}}};
odf.StyleParseUtils=function(){function f(a){var e,c;a=(a=/(-?[0-9]*[0-9][0-9]*(\.[0-9]*)?|0+\.[0-9]*[1-9][0-9]*|\.[0-9]*[1-9][0-9]*)((cm)|(mm)|(in)|(pt)|(pc)|(px))/.exec(a))?{value:parseFloat(a[1]),unit:a[3]}:null;c=a&&a.unit;"px"===c?e=a.value:"cm"===c?e=96*(a.value/2.54):"mm"===c?e=96*(a.value/25.4):"in"===c?e=96*a.value:"pt"===c?e=a.value/0.75:"pc"===c&&(e=16*a.value);return e}var k=odf.Namespaces.stylens;this.parseLength=f;this.parsePositiveLengthOrPercent=function(a,e,c){var m;a&&(m=parseFloat(a.substr(0,
a.indexOf("%"))),isNaN(m)&&(m=void 0));var n;void 0!==m?(c&&(n=c.value(e)),m=void 0===n?void 0:m*(n/100)):m=f(a);return m};this.getPropertiesElement=function(a,e,c){for(e=c?c.nextElementSibling:e.firstElementChild;null!==e&&(e.localName!==a||e.namespaceURI!==k);)e=e.nextElementSibling;return e};this.parseAttributeList=function(a){a&&(a=a.replace(/^\s*(.*?)\s*$/g,"$1"));return a&&0<a.length?a.split(/\s+/):[]}};odf.Style2CSS=function(){function f(b,a,d){var c=[];d=d.derivedStyles;var e;var g=z[b],l;void 0===g?a=null:(l=a?"["+g+'|style-name="'+a+'"]':"","presentation"===g&&(g="draw",l=a?'[presentation|style-name="'+a+'"]':""),a=g+"|"+w[b].join(l+","+g+"|")+l);null!==a&&c.push(a);for(e in d)d.hasOwnProperty(e)&&(a=f(b,e,d[e]),c=c.concat(a));return c}function k(b){var a="",d="",a=null;if("default-style"===b.localName)return null;a=b.getAttributeNS(h,"parent-style-name");d=b.getAttributeNS(h,"family");return a=
T.getODFElementsWithXPath(I,a?"//style:*[@style:name='"+a+"'][@style:family='"+d+"']":"//style:default-style[@style:family='"+d+"']",odf.Namespaces.lookupNamespaceURI)[0]}function a(b,a){var d="",c,e,g;for(c=0;c<a.length;c+=1)if(e=a[c],g=b.getAttributeNS(e[0],e[1])){g=g.trim();if(Q.hasOwnProperty(e[1])){var l=g,f=l.indexOf(" "),r=void 0;g=void 0;-1!==f?(r=l.substring(0,f),g=l.substring(f)):(r=l,g="");(r=S.parseLength(r))&&"pt"===r.unit&&0.75>r.value&&(l="0.75pt"+g);g=l}else if(A.hasOwnProperty(e[1])){var l=
b,f=e[0],r=e[1],m=S.parseLength(g),n=void 0,p=void 0,q=void 0,s=void 0,q=void 0;if(m&&"%"===m.unit){n=m.value/100;p=k(l.parentNode);for(s="0";p;){if(q=y.getDirectChild(p,h,"paragraph-properties"))if(q=S.parseLength(q.getAttributeNS(f,r))){if("%"!==q.unit){s=q.value*n+q.unit;break}n*=q.value/100}p=k(p)}g=s}}e[2]&&(d+=e[2]+":"+g+";")}return d}function e(b,a,d,c){return a+a+d+d+c+c}function c(b,a){var d=[b],e=a.derivedStyles;Object.keys(e).forEach(function(b){b=c(b,e[b]);d=d.concat(b)});return d}function m(b,
a,d,e){function g(a,d){var c=[],e;a.forEach(function(b){h.forEach(function(a){c.push('draw|page[webodfhelper|page-style-name="'+a+'"] draw|frame[presentation|class="'+b+'"]')})});0<c.length&&(e=c.join(",")+"{visibility:"+d+";}",b.insertRule(e,b.cssRules.length))}var h=c(a,e),f=[],r=[];["page-number","date-time","header","footer"].forEach(function(b){var a;a=d.getAttributeNS(l,"display-"+b);"true"===a?f.push(b):"false"===a&&r.push(b)});g(f,"visible");g(r,"hidden")}function n(d,c,A,Q){var w,z;if("page"===
c){var I=Q.element,T="",O,aa;aa=O="";A=y.getDirectChild(I,h,"page-layout-properties");var R;if(A)if(R=I.getAttributeNS(h,"name"),T+=a(A,J),(O=y.getDirectChild(A,h,"background-image"))&&(aa=O.getAttributeNS(r,"href"))&&(T=T+("background-image: url('odfkit:"+aa+"');")+a(O,x)),"presentation"===v)for(I=(I=y.getDirectChild(I.parentNode.parentNode,g,"master-styles"))&&I.firstElementChild;I;)I.namespaceURI===h&&"master-page"===I.localName&&I.getAttributeNS(h,"page-layout-name")===R&&(aa=I.getAttributeNS(h,
"name"),O='draw|page[draw|master-page-name="'+aa+'"] {'+T+"}",aa='office|body, draw|page[draw|master-page-name="'+aa+'"] {'+a(A,P)+" }",d.insertRule(O,d.cssRules.length),d.insertRule(aa,d.cssRules.length)),I=I.nextElementSibling;else"text"===v&&(O="office|text {"+T+"}",aa="office|body {width: "+A.getAttributeNS(q,"page-width")+";}",d.insertRule(O,d.cssRules.length),d.insertRule(aa,d.cssRules.length))}else{T=f(c,A,Q).join(",");R="";if(I=y.getDirectChild(Q.element,h,"text-properties")){var L=I,ea=z=
"";O="";aa=1;I=""+a(L,s);w=L.getAttributeNS(h,"text-underline-style");"solid"===w&&(z+=" underline");w=L.getAttributeNS(h,"text-line-through-style");"solid"===w&&(z+=" line-through");z.length&&(I=I+("text-decoration:"+z+";\n")+("text-decoration-line:"+z+";\n"),I+="-moz-text-decoration-line:"+z+";\n");w=L.getAttributeNS(h,"text-line-through-type");switch(w){case "double":ea+=" double";break;case "single":ea+=" single"}ea&&(I+="text-decoration-style:"+ea+";\n",I+="-moz-text-decoration-style:"+ea+";\n");
if(z=L.getAttributeNS(h,"font-name")||L.getAttributeNS(q,"font-family"))w=Y[z],I+="font-family: "+(w||z)+";";if(w=L.getAttributeNS(h,"text-position"))z=t.parseAttributeList(w),w=z[0],z=z[1],I+="vertical-align: "+w+"\n; ",z&&(aa=parseFloat(z)/100);if(L.hasAttributeNS(q,"font-size")||1!==aa){for(L=L.parentNode;L;){if(w=(w=y.getDirectChild(L,h,"text-properties"))?S.parseFoFontSize(w.getAttributeNS(q,"font-size")):null){if("%"!==w.unit){O="font-size: "+w.value*aa+w.unit+";";break}aa*=w.value/100}L=k(L)}O||
(O="font-size: "+parseFloat(ba)*aa+F.getUnits(ba)+";")}I+=O;R+=I}if(I=y.getDirectChild(Q.element,h,"paragraph-properties"))O=I,I=""+a(O,u),(aa=y.getDirectChild(O,h,"background-image"))&&(L=aa.getAttributeNS(r,"href"))&&(I=I+("background-image: url('odfkit:"+L+"');")+a(aa,x)),(O=O.getAttributeNS(q,"line-height"))&&"normal"!==O&&(O=S.parseFoLineHeight(O),I="%"!==O.unit?I+("line-height: "+O.value+O.unit+";"):I+("line-height: "+O.value/100+";")),R+=I;if(I=y.getDirectChild(Q.element,h,"graphic-properties"))L=
I,I=""+a(L,C),O=L.getAttributeNS(p,"opacity"),aa=L.getAttributeNS(p,"fill"),L=L.getAttributeNS(p,"fill-color"),"solid"===aa||"hatch"===aa?L&&"none"!==L?(O=isNaN(parseFloat(O))?1:parseFloat(O)/100,aa=L.replace(/^#?([a-f\d])([a-f\d])([a-f\d])$/i,e),(L=(aa=/^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(aa))?{r:parseInt(aa[1],16),g:parseInt(aa[2],16),b:parseInt(aa[3],16)}:null)&&(I+="background-color: rgba("+L.r+","+L.g+","+L.b+","+O+");")):I+="background: none;":"none"===aa&&(I+="background: none;"),
R+=I;if(I=y.getDirectChild(Q.element,h,"drawing-page-properties"))O=I,aa=""+a(O,C),"true"===O.getAttributeNS(l,"background-visible")&&(aa+="background: none;"),R+=aa,m(d,A,I,Q);if(I=y.getDirectChild(Q.element,h,"table-cell-properties"))A=R,R=""+a(I,H),R=A+R;if(I=y.getDirectChild(Q.element,h,"table-row-properties"))A=R,R=""+a(I,G),R=A+R;if(I=y.getDirectChild(Q.element,h,"table-column-properties"))A=R,R=""+a(I,D),R=A+R;if(I=y.getDirectChild(Q.element,h,"table-properties"))A=R,R=""+a(I,B),I=I.getAttributeNS(b,
"border-model"),"collapsing"===I?R+="border-collapse:collapse;":"separating"===I&&(R+="border-collapse:separate;"),R=A+R;0!==R.length&&d.insertRule(T+"{"+R+"}",d.cssRules.length)}for(var ga in Q.derivedStyles)Q.derivedStyles.hasOwnProperty(ga)&&n(d,c,ga,Q.derivedStyles[ga])}var p=odf.Namespaces.drawns,q=odf.Namespaces.fons,g=odf.Namespaces.officens,h=odf.Namespaces.stylens,d=odf.Namespaces.svgns,b=odf.Namespaces.tablens,r=odf.Namespaces.xlinkns,l=odf.Namespaces.presentationns,y=core.DomUtils,t=new odf.StyleParseUtils,
z={graphic:"draw","drawing-page":"draw",paragraph:"text",presentation:"presentation",ruby:"text",section:"text",table:"table","table-cell":"table","table-column":"table","table-row":"table",text:"text",list:"text",page:"office"},w={graphic:"circle connected control custom-shape ellipse frame g line measure page page-thumbnail path polygon polyline rect regular-polygon".split(" "),paragraph:"alphabetical-index-entry-template h illustration-index-entry-template index-source-style object-index-entry-template p table-index-entry-template table-of-content-entry-template user-index-entry-template".split(" "),
presentation:"caption circle connector control custom-shape ellipse frame g line measure page-thumbnail path polygon polyline rect regular-polygon".split(" "),"drawing-page":"caption circle connector control page custom-shape ellipse frame g line measure page-thumbnail path polygon polyline rect regular-polygon".split(" "),ruby:["ruby","ruby-text"],section:"alphabetical-index bibliography illustration-index index-title object-index section table-of-content table-index user-index".split(" "),table:["background",
"table"],"table-cell":"body covered-table-cell even-columns even-rows first-column first-row last-column last-row odd-columns odd-rows table-cell".split(" "),"table-column":["table-column"],"table-row":["table-row"],text:"a index-entry-chapter index-entry-link-end index-entry-link-start index-entry-page-number index-entry-span index-entry-tab-stop index-entry-text index-title-template linenumbering-configuration list-level-style-number list-level-style-bullet outline-level-style span".split(" "),
list:["list-item"]},s=[[q,"color","color"],[q,"background-color","background-color"],[q,"font-weight","font-weight"],[q,"font-style","font-style"]],x=[[h,"repeat","background-repeat"]],u=[[q,"background-color","background-color"],[q,"text-align","text-align"],[q,"text-indent","text-indent"],[q,"padding","padding"],[q,"padding-left","padding-left"],[q,"padding-right","padding-right"],[q,"padding-top","padding-top"],[q,"padding-bottom","padding-bottom"],[q,"border-left","border-left"],[q,"border-right",
"border-right"],[q,"border-top","border-top"],[q,"border-bottom","border-bottom"],[q,"margin","margin"],[q,"margin-left","margin-left"],[q,"margin-right","margin-right"],[q,"margin-top","margin-top"],[q,"margin-bottom","margin-bottom"],[q,"border","border"]],C=[[q,"background-color","background-color"],[q,"min-height","min-height"],[p,"stroke","border"],[d,"stroke-color","border-color"],[d,"stroke-width","border-width"],[q,"border","border"],[q,"border-left","border-left"],[q,"border-right","border-right"],
[q,"border-top","border-top"],[q,"border-bottom","border-bottom"]],H=[[q,"background-color","background-color"],[q,"border-left","border-left"],[q,"border-right","border-right"],[q,"border-top","border-top"],[q,"border-bottom","border-bottom"],[q,"border","border"]],D=[[h,"column-width","width"]],G=[[h,"row-height","height"],[q,"keep-together",null]],B=[[h,"width","width"],[q,"margin-left","margin-left"],[q,"margin-right","margin-right"],[q,"margin-top","margin-top"],[q,"margin-bottom","margin-bottom"]],
J=[[q,"background-color","background-color"],[q,"padding","padding"],[q,"padding-left","padding-left"],[q,"padding-right","padding-right"],[q,"padding-top","padding-top"],[q,"padding-bottom","padding-bottom"],[q,"border","border"],[q,"border-left","border-left"],[q,"border-right","border-right"],[q,"border-top","border-top"],[q,"border-bottom","border-bottom"],[q,"margin","margin"],[q,"margin-left","margin-left"],[q,"margin-right","margin-right"],[q,"margin-top","margin-top"],[q,"margin-bottom","margin-bottom"]],
P=[[q,"page-width","width"],[q,"page-height","height"]],Q={border:!0,"border-left":!0,"border-right":!0,"border-top":!0,"border-bottom":!0,"stroke-width":!0},A={margin:!0,"margin-left":!0,"margin-right":!0,"margin-top":!0,"margin-bottom":!0},Y={},S=odf.OdfUtils,v,I,ba,T=xmldom.XPath,F=new core.CSSUnits;this.style2css=function(b,a,d,c,e){function g(b,a){l="@namespace "+b+" url("+a+");";try{d.insertRule(l,d.cssRules.length)}catch(c){}}var l,h,f;for(I=a;d.cssRules.length;)d.deleteRule(d.cssRules.length-
1);odf.Namespaces.forEachPrefix(g);g("webodfhelper","urn:webodf:names:helper");Y=c;v=b;ba=runtime.getWindow().getComputedStyle(document.body,null).getPropertyValue("font-size")||"12pt";for(f in z)if(z.hasOwnProperty(f))for(h in b=e[f],b)b.hasOwnProperty(h)&&n(d,f,h,b[h])}};(function(){function f(k,a){var e=this;this.getDistance=function(a){var f=e.x-a.x;a=e.y-a.y;return Math.sqrt(f*f+a*a)};this.getCenter=function(a){return new f((e.x+a.x)/2,(e.y+a.y)/2)};e.x=k;e.y=a}gui.ZoomHelper=function(){function k(a,d,c,e){a=e?"translate3d("+a+"px, "+d+"px, 0) scale3d("+c+", "+c+", 1)":"translate("+a+"px, "+d+"px) scale("+c+")";b.style.WebkitTransform=a;b.style.MozTransform=a;b.style.msTransform=a;b.style.OTransform=a;b.style.transform=a}function a(b){b?k(-r.x,-r.y,t,!0):(k(0,
0,t,!0),k(0,0,t,!1))}function e(b){if(s&&D){var a=s.style.overflow,d=s.classList.contains("webodf-customScrollbars");b&&d||!b&&!d||(b?(s.classList.add("webodf-customScrollbars"),s.style.overflow="hidden",runtime.requestAnimationFrame(function(){s.style.overflow=a})):s.classList.remove("webodf-customScrollbars"))}}function c(){k(-r.x,-r.y,t,!0);s.scrollLeft=0;s.scrollTop=0;G=x.style.overflow;x.style.overflow="visible";e(!1)}function m(){k(0,0,t,!0);s.scrollLeft=r.x;s.scrollTop=r.y;x.style.overflow=
G||"";e(!0)}function n(a){return new f(a.pageX-b.offsetLeft,a.pageY-b.offsetTop)}function p(a){l&&(r.x-=a.x-l.x,r.y-=a.y-l.y,r=new f(Math.min(Math.max(r.x,b.offsetLeft),(b.offsetLeft+b.offsetWidth)*t-s.clientWidth),Math.min(Math.max(r.y,b.offsetTop),(b.offsetTop+b.offsetHeight)*t-s.clientHeight)));l=a}function q(b){var a=b.touches.length,d=0<a?n(b.touches[0]):null;b=1<a?n(b.touches[1]):null;d&&b?(y=d.getDistance(b),z=t,l=d.getCenter(b),c(),H=C.PINCH):d&&(l=d,H=C.SCROLL)}function g(d){var e=d.touches.length,
g=0<e?n(d.touches[0]):null,e=1<e?n(d.touches[1]):null;if(g&&e)if(d.preventDefault(),H===C.SCROLL)H=C.PINCH,c(),y=g.getDistance(e);else{d=g.getCenter(e);g=g.getDistance(e)/y;p(d);var e=t,l=Math.min(w,b.offsetParent.clientWidth/b.offsetWidth);t=z*g;t=Math.min(Math.max(t,l),w);g=t/e;r.x+=(g-1)*(d.x+r.x);r.y+=(g-1)*(d.y+r.y);a(!0)}else g&&(H===C.PINCH?(H=C.SCROLL,m()):p(g))}function h(){H===C.PINCH&&(u.emit(gui.ZoomHelper.signalZoomChanged,t),m(),a(!1));H=C.NONE}function d(){s&&(s.removeEventListener("touchstart",
q,!1),s.removeEventListener("touchmove",g,!1),s.removeEventListener("touchend",h,!1))}var b,r,l,y,t,z,w=4,s,x,u=new core.EventNotifier([gui.ZoomHelper.signalZoomChanged]),C={NONE:0,SCROLL:1,PINCH:2},H=C.NONE,D=runtime.getWindow().hasOwnProperty("ontouchstart"),G="";this.subscribe=function(b,a){u.subscribe(b,a)};this.unsubscribe=function(b,a){u.unsubscribe(b,a)};this.getZoomLevel=function(){return t};this.setZoomLevel=function(d){b&&(t=d,a(!1),u.emit(gui.ZoomHelper.signalZoomChanged,t))};this.destroy=
function(b){d();e(!1);b()};this.setZoomableElement=function(c){d();b=c;s=b.offsetParent;x=b.parentNode;a(!1);s&&(s.addEventListener("touchstart",q,!1),s.addEventListener("touchmove",g,!1),s.addEventListener("touchend",h,!1));e(!0)};z=t=1;r=new f(0,0)};gui.ZoomHelper.signalZoomChanged="zoomChanged"})();ops.Canvas=function(){};ops.Canvas.prototype.getZoomLevel=function(){};ops.Canvas.prototype.getElement=function(){};ops.Canvas.prototype.getSizer=function(){};ops.Canvas.prototype.getZoomHelper=function(){};(function(){function f(){function b(c){d=!0;runtime.setTimeout(function(){try{c()}catch(e){runtime.log(String(e)+"\n"+e.stack)}d=!1;0<a.length&&b(a.pop())},10)}var a=[],d=!1;this.clearQueue=function(){a.length=0};this.addToQueue=function(c){if(0===a.length&&!d)return b(c);a.push(c)}}function k(b){function a(){for(;0<d.cssRules.length;)d.deleteRule(0);d.insertRule("#shadowContent draw|page {display:none;}",0);d.insertRule("office|presentation draw|page {display:none;}",1);d.insertRule("#shadowContent draw|page:nth-of-type("+
c+") {display:block;}",2);d.insertRule("office|presentation draw|page:nth-of-type("+c+") {display:block;}",3)}var d=b.sheet,c=1;this.showFirstPage=function(){c=1;a()};this.showNextPage=function(){c+=1;a()};this.showPreviousPage=function(){1<c&&(c-=1,a())};this.showPage=function(b){0<b&&(c=b,a())};this.css=b;this.destroy=function(a){b.parentNode.removeChild(b);a()}}function a(b){b=b.sheet;for(var a=b.cssRules;a.length;)b.deleteRule(a.length-1)}function e(b,a,d){var c=new odf.Style2CSS,e=new odf.ListStyleToCss;
d=d.sheet;var g=(new odf.StyleTree(b.rootElement.styles,b.rootElement.automaticStyles)).getStyleTree();c.style2css(b.getDocumentType(),b.rootElement,d,a.getFontMap(),g);e.applyListStyles(d,g,b.rootElement.body)}function c(b,a){(new odf.FontLoader).loadFonts(b,a.sheet)}function m(b,a,d){var c=null;b=b.rootElement.body.getElementsByTagNameNS(G,d+"-decl");d=a.getAttributeNS(G,"use-"+d+"-name");var e;if(d&&0<b.length)for(a=0;a<b.length;a+=1)if(e=b[a],e.getAttributeNS(G,"name")===d){c=e.textContent;break}return c}
function n(b,a,d,c){var e=b.ownerDocument;a=J.getElementsByTagNameNS(b,a,d);for(b=0;b<a.length;b+=1)J.removeAllChildNodes(a[b]),c&&(d=a[b],d.appendChild(e.createTextNode(c)))}function p(b,a,d){a.setAttributeNS("urn:webodf:names:helper","styleid",b);var c,e=a.getAttributeNS(H,"anchor-type"),g=a.getAttributeNS(u,"x"),l=a.getAttributeNS(u,"y"),h=a.getAttributeNS(u,"width"),f=a.getAttributeNS(u,"height"),r=a.getAttributeNS(w,"min-height"),m=a.getAttributeNS(w,"min-width");if("as-char"===e)c="display: inline-block;";
else if(e||g||l)c="position: absolute;";else if(h||f||r||m)c="display: block;";g&&(c+="left: "+g+";");l&&(c+="top: "+l+";");h&&(c+="width: "+h+";");f&&(c+="height: "+f+";");r&&(c+="min-height: "+r+";");m&&(c+="min-width: "+m+";");c&&(c="draw|"+a.localName+'[webodfhelper|styleid="'+b+'"] {'+c+"}",d.insertRule(c,d.cssRules.length))}function q(b){for(b=b.firstChild;b;){if(b.namespaceURI===s&&"binary-data"===b.localName)return"data:image/png;base64,"+b.textContent.replace(/[\r\n\s]/g,"");b=b.nextSibling}return""}
function g(b,a,d,c){function e(a){a&&(a='draw|image[webodfhelper|styleid="'+b+'"] {'+("background-image: url("+a+");")+"}",c.insertRule(a,c.cssRules.length))}function g(b){e(b.url)}d.setAttributeNS("urn:webodf:names:helper","styleid",b);var l=d.getAttributeNS(D,"href"),h;if(l)try{h=a.getPart(l),h.onchange=g,h.load()}catch(f){runtime.log("slight problem: "+String(f))}else l=q(d),e(l)}function h(b){var a=b.ownerDocument;J.getElementsByTagNameNS(b,H,"line-break").forEach(function(b){b.hasChildNodes()||
b.appendChild(a.createElement("br"))})}function d(b){var a=b.ownerDocument;J.getElementsByTagNameNS(b,H,"s").forEach(function(b){var d,c;J.removeAllChildNodes(b);b.appendChild(a.createTextNode(" "));c=parseInt(b.getAttributeNS(H,"c"),10);if(1<c)for(b.removeAttributeNS(H,"c"),d=1;d<c;d+=1)b.parentNode.insertBefore(b.cloneNode(!0),b)})}function b(b){J.getElementsByTagNameNS(b,H,"tab").forEach(function(b){b.textContent="\t"})}function r(b,a){function d(b,c){var l=h.documentElement.namespaceURI;"video/"===
c.substr(0,6)?(e=h.createElementNS(l,"video"),e.setAttribute("controls","controls"),g=h.createElementNS(l,"source"),b&&g.setAttribute("src",b),g.setAttribute("type",c),e.appendChild(g),a.parentNode.appendChild(e)):a.innerHtml="Unrecognised Plugin"}function c(b){d(b.url,b.mimetype)}var e,g,l,h=a.ownerDocument,f;if(l=a.getAttributeNS(D,"href"))try{f=b.getPart(l),f.onchange=c,f.load()}catch(r){runtime.log("slight problem: "+String(r))}else runtime.log("using MP4 data fallback"),l=q(a),d(l,"video/mp4")}
function l(b){var a=b.getElementsByTagName("head")[0],d,c;d=b.styleSheets.length;for(c=a.firstElementChild;c&&("style"!==c.localName||!c.hasAttribute("webodfcss"));)c=c.nextElementSibling;if(c)return d=parseInt(c.getAttribute("webodfcss"),10),c.setAttribute("webodfcss",d+1),c;"string"===String(typeof webodf_css)?d=webodf_css:(c="webodf.css",runtime.currentDirectory&&(c=runtime.currentDirectory(),0<c.length&&"/"!==c.substr(-1)&&(c+="/"),c+="../webodf.css"),d=runtime.readFileSync(c,"utf-8"));c=b.createElementNS(a.namespaceURI,
"style");c.setAttribute("media","screen, print, handheld, projection");c.setAttribute("type","text/css");c.setAttribute("webodfcss","1");c.appendChild(b.createTextNode(d));a.appendChild(c);return c}function y(b){var a=parseInt(b.getAttribute("webodfcss"),10);1===a?b.parentNode.removeChild(b):b.setAttribute("count",a-1)}function t(b){var a=b.getElementsByTagName("head")[0],d=b.createElementNS(a.namespaceURI,"style"),c="";d.setAttribute("type","text/css");d.setAttribute("media","screen, print, handheld, projection");
odf.Namespaces.forEachPrefix(function(b,a){c+="@namespace "+b+" url("+a+");\n"});c+="@namespace webodfhelper url(urn:webodf:names:helper);\n";d.appendChild(b.createTextNode(c));a.appendChild(d);return d}var z=odf.Namespaces.drawns,w=odf.Namespaces.fons,s=odf.Namespaces.officens,x=odf.Namespaces.stylens,u=odf.Namespaces.svgns,C=odf.Namespaces.tablens,H=odf.Namespaces.textns,D=odf.Namespaces.xlinkns,G=odf.Namespaces.presentationns,B=xmldom.XPath,J=core.DomUtils;odf.OdfCanvas=function(q,w){function A(b,
a,d){function c(b,a,d,e){ja.addToQueue(function(){g(b,a,d,e)})}var e,l;e=a.getElementsByTagNameNS(z,"image");for(a=0;a<e.length;a+=1)l=e.item(a),c("image"+String(a),b,l,d)}function Y(b,a){function d(b,a){ja.addToQueue(function(){r(b,a)})}var c,e,g;e=a.getElementsByTagNameNS(z,"plugin");for(c=0;c<e.length;c+=1)g=e.item(c),d(b,g)}function u(){var b;b=$.firstChild;var a=fa.getZoomLevel();b&&($.style.WebkitTransformOrigin="0% 0%",$.style.MozTransformOrigin="0% 0%",$.style.msTransformOrigin="0% 0%",$.style.OTransformOrigin=
"0% 0%",$.style.transformOrigin="0% 0%",O&&((b=O.getMinimumHeightForAnnotationPane())?$.style.minHeight=b:$.style.removeProperty("min-height")),q.style.width=Math.round(a*$.offsetWidth)+"px",q.style.height=Math.round(a*$.offsetHeight)+"px",q.style.display="inline-block")}function v(a,c){var e=ea.sheet;J.removeAllChildNodes(q);$=N.createElementNS(q.namespaceURI,"div");$.style.display="inline-block";$.style.background="white";$.style.setProperty("float","left","important");$.appendChild(c);q.appendChild($);
ca=N.createElementNS(q.namespaceURI,"div");ca.id="annotationsPane";ga=N.createElementNS(q.namespaceURI,"div");ga.id="shadowContent";ga.style.position="absolute";ga.style.top=0;ga.style.left=0;a.getContentElement().appendChild(ga);var g=c.body,l,f=[],r;for(l=g.firstElementChild;l&&l!==g;)if(l.namespaceURI===z&&(f[f.length]=l),l.firstElementChild)l=l.firstElementChild;else{for(;l&&l!==g&&!l.nextElementSibling;)l=l.parentNode;l&&l.nextElementSibling&&(l=l.nextElementSibling)}for(r=0;r<f.length;r+=1)l=
f[r],p("frame"+String(r),l,e);f=B.getODFElementsWithXPath(g,".//*[*[@text:anchor-type='paragraph']]",odf.Namespaces.lookupNamespaceURI);for(l=0;l<f.length;l+=1)g=f[l],g.setAttributeNS&&g.setAttributeNS("urn:webodf:names:helper","containsparagraphanchor",!0);g=E;l=ga;var k,y,v,t,w=0,Q;r=a.rootElement.ownerDocument;if((f=c.body.firstElementChild)&&f.namespaceURI===s&&("presentation"===f.localName||"drawing"===f.localName))for(f=f.firstElementChild;f;){if(k=(k=f.getAttributeNS(z,"master-page-name"))?
g.getMasterPageElement(k):null){y=f.getAttributeNS("urn:webodf:names:helper","styleid");v=r.createElementNS(z,"draw:page");Q=k.firstElementChild;for(w=0;Q;)"true"!==Q.getAttributeNS(G,"placeholder")&&(t=Q.cloneNode(!0),v.appendChild(t)),Q=Q.nextElementSibling,w+=1;Q=t=w=void 0;for(var u=J.getElementsByTagNameNS(v,z,"frame"),w=0;w<u.length;w+=1)t=u[w],(Q=t.getAttributeNS(G,"class"))&&!/^(date-time|footer|header|page-number)$/.test(Q)&&t.parentNode.removeChild(t);t=J.getElementsByTagNameNS(v,z,"*");
for(w=0;w<t.length;w+=1)p(y+"_"+w,t[w],e);l.appendChild(v);w=String(l.getElementsByTagNameNS(z,"page").length);n(v,H,"page-number",w);n(v,G,"header",m(a,f,"header"));n(v,G,"footer",m(a,f,"footer"));p(y,v,e);v.setAttributeNS("urn:webodf:names:helper","page-style-name",f.getAttributeNS(z,"style-name"));v.setAttributeNS(z,"draw:master-page-name",k.getAttributeNS(x,"name"))}f=f.nextElementSibling}g=q.namespaceURI;f=J.getElementsByTagNameNS(c.body,C,"table-cell");for(l=0;l<f.length;l+=1)r=f[l],r.hasAttributeNS(C,
"number-columns-spanned")&&r.setAttributeNS(g,"colspan",r.getAttributeNS(C,"number-columns-spanned")),r.hasAttributeNS(C,"number-rows-spanned")&&r.setAttributeNS(g,"rowspan",r.getAttributeNS(C,"number-rows-spanned"));h(c.body);d(c.body);b(c.body);A(a,c.body,e);Y(a,c.body);$.insertBefore(ga,$.firstChild);fa.setZoomableElement($)}function D(b){U?(ca.parentNode||$.appendChild(ca),O&&O.forgetAnnotations(),O=new gui.AnnotationViewManager(F,b.body,ca,W),b=J.getElementsByTagNameNS(b.body,s,"annotation"),
O.addAnnotations(b),u()):ca.parentNode&&($.removeChild(ca),O.forgetAnnotations(),u())}function ba(b){function d(){a(R);a(L);a(ea);J.removeAllChildNodes(q);q.style.display="inline-block";var g=Z.rootElement;q.ownerDocument.importNode(g,!0);E.setOdfContainer(Z);c(Z,R);e(Z,E,L);v(Z,g);D(g);b||ja.addToQueue(function(){var b=[Z];if(da.hasOwnProperty("statereadychange")){var a=da.statereadychange,d;for(d=0;d<a.length;d+=1)a[d].apply(null,b)}})}Z.state===odf.OdfContainer.DONE?d():(runtime.log("WARNING: refreshOdf called but ODF was not DONE."),
ha=runtime.setTimeout(function qa(){Z.state===odf.OdfContainer.DONE?d():(runtime.log("will be back later..."),ha=runtime.setTimeout(qa,500))},100))}function T(b){ja.clearQueue();J.removeAllChildNodes(q);q.appendChild(q.ownerDocument.createTextNode(runtime.tr("Loading")+b+"..."));q.removeAttribute("style");Z=new odf.OdfContainer(b,function(b){Z=b;ba(!1)})}runtime.assert(null!==q&&void 0!==q,"odf.OdfCanvas constructor needs DOM element");runtime.assert(null!==q.ownerDocument&&void 0!==q.ownerDocument,
"odf.OdfCanvas constructor needs DOM");var F=this,N=q.ownerDocument,Z,E=new odf.Formatting,V,$=null,ca=null,U=!1,W=!1,O=null,aa,R,L,ea,ga,da={},ha,ma,la=!1,ia=!1,ja=new f,fa=new gui.ZoomHelper,pa=w||new gui.SingleScrollViewport(q.parentNode);this.refreshCSS=function(){la=!0;ma.trigger()};this.refreshSize=function(){ma.trigger()};this.odfContainer=function(){return Z};this.setOdfContainer=function(b,a){Z=b;ba(!0===a)};this.load=this.load=T;this.save=function(b){Z.save(b)};this.addListener=function(b,
a){switch(b){case "click":var d=q,c=b;d.addEventListener?d.addEventListener(c,a,!1):d.attachEvent?d.attachEvent("on"+c,a):d["on"+c]=a;break;default:d=da.hasOwnProperty(b)?da[b]:da[b]=[],a&&-1===d.indexOf(a)&&d.push(a)}};this.getFormatting=function(){return E};this.getAnnotationViewManager=function(){return O};this.refreshAnnotations=function(){D(Z.rootElement)};this.rerenderAnnotations=function(){O&&(ia=!0,ma.trigger())};this.getSizer=function(){return $};this.enableAnnotations=function(b,a){b!==
U&&(U=b,W=a,Z&&D(Z.rootElement))};this.addAnnotation=function(b){O&&(O.addAnnotations([b]),u())};this.forgetAnnotation=function(b){O&&(O.forgetAnnotation(b),u())};this.getZoomHelper=function(){return fa};this.setZoomLevel=function(b){fa.setZoomLevel(b)};this.getZoomLevel=function(){return fa.getZoomLevel()};this.fitToContainingElement=function(b,a){var d=fa.getZoomLevel(),c=q.offsetHeight/d,d=b/(q.offsetWidth/d);a/c<d&&(d=a/c);fa.setZoomLevel(d)};this.fitToWidth=function(b){var a=q.offsetWidth/fa.getZoomLevel();
fa.setZoomLevel(b/a)};this.fitSmart=function(b,a){var d,c;c=fa.getZoomLevel();d=q.offsetWidth/c;c=q.offsetHeight/c;d=b/d;void 0!==a&&a/c<d&&(d=a/c);fa.setZoomLevel(Math.min(1,d))};this.fitToHeight=function(b){var a=q.offsetHeight/fa.getZoomLevel();fa.setZoomLevel(b/a)};this.showFirstPage=function(){V.showFirstPage()};this.showNextPage=function(){V.showNextPage()};this.showPreviousPage=function(){V.showPreviousPage()};this.showPage=function(b){V.showPage(b);u()};this.getElement=function(){return q};
this.getViewport=function(){return pa};this.addCssForFrameWithImage=function(b){var a=b.getAttributeNS(z,"name"),d=b.firstElementChild;p(a,b,ea.sheet);d&&g(a+"img",Z,d,ea.sheet)};this.destroy=function(b){var a=N.getElementsByTagName("head")[0],d=[V.destroy,ma.destroy];runtime.clearTimeout(ha);ca&&ca.parentNode&&ca.parentNode.removeChild(ca);fa.destroy(function(){$&&(q.removeChild($),$=null)});y(aa);a.removeChild(R);a.removeChild(L);a.removeChild(ea);core.Async.destroyAll(d,b)};aa=l(N);V=new k(t(N));
R=t(N);L=t(N);ea=t(N);ma=core.Task.createRedrawTask(function(){la&&(e(Z,E,L),la=!1);ia&&(O&&O.rerenderAnnotations(),ia=!1);u()});fa.subscribe(gui.ZoomHelper.signalZoomChanged,u)}})();odf.StepUtils=function(){this.getContentBounds=function(f){var k=f.container(),a,e;runtime.assert(f.isStep(),"Step iterator must be on a step");k.nodeType===Node.TEXT_NODE&&0<f.offset()?a=f.offset():(k=f.leftNode())&&k.nodeType===Node.TEXT_NODE&&(a=k.length);k&&(k.nodeType===Node.TEXT_NODE?(runtime.assert(0<a,"Empty text node found"),e={container:k,startOffset:a-1,endOffset:a}):e={container:k,startOffset:0,endOffset:k.childNodes.length});return e}};ops.MemberProperties=function(){};
ops.Member=function(f,k){var a=new ops.MemberProperties;this.getMemberId=function(){return f};this.getProperties=function(){return a};this.setProperties=function(e){Object.keys(e).forEach(function(c){a[c]=e[c]})};this.removeProperties=function(e){Object.keys(e).forEach(function(c){"fullName"!==c&&"color"!==c&&"imageUrl"!==c&&a.hasOwnProperty(c)&&delete a[c]})};runtime.assert(Boolean(f),"No memberId was supplied!");k.fullName||(k.fullName=runtime.tr("Unknown Author"));k.color||(k.color="black");k.imageUrl||
(k.imageUrl="avatar-joe.png");a=k};ops.Document=function(){};ops.Document.prototype.getMemberIds=function(){};ops.Document.prototype.removeCursor=function(f){};ops.Document.prototype.getDocumentElement=function(){};ops.Document.prototype.getRootNode=function(){};ops.Document.prototype.getDOMDocument=function(){};ops.Document.prototype.cloneDocumentElement=function(){};ops.Document.prototype.setDocumentElement=function(f){};ops.Document.prototype.subscribe=function(f,k){};ops.Document.prototype.unsubscribe=function(f,k){};
ops.Document.prototype.getCanvas=function(){};ops.Document.prototype.createRootFilter=function(f){};ops.Document.prototype.createPositionIterator=function(f){};ops.Document.signalCursorAdded="cursor/added";ops.Document.signalCursorRemoved="cursor/removed";ops.Document.signalCursorMoved="cursor/moved";ops.Document.signalMemberAdded="member/added";ops.Document.signalMemberUpdated="member/updated";ops.Document.signalMemberRemoved="member/removed";ops.OdtCursor=function(f,k){var a=this,e={},c,m,n=new core.EventNotifier([ops.OdtCursor.signalCursorUpdated]);this.removeFromDocument=function(){m.remove()};this.subscribe=function(a,c){n.subscribe(a,c)};this.unsubscribe=function(a,c){n.unsubscribe(a,c)};this.getMemberId=function(){return f};this.getNode=function(){return m.getNode()};this.getAnchorNode=function(){return m.getAnchorNode()};this.getSelectedRange=function(){return m.getSelectedRange()};this.setSelectedRange=function(c,e){m.setSelectedRange(c,
e);n.emit(ops.OdtCursor.signalCursorUpdated,a)};this.hasForwardSelection=function(){return m.hasForwardSelection()};this.getDocument=function(){return k};this.getSelectionType=function(){return c};this.setSelectionType=function(a){e.hasOwnProperty(a)?c=a:runtime.log("Invalid selection type: "+a)};this.resetSelectionType=function(){a.setSelectionType(ops.OdtCursor.RangeSelection)};m=new core.Cursor(k.getDOMDocument(),f);e[ops.OdtCursor.RangeSelection]=!0;e[ops.OdtCursor.RegionSelection]=!0;a.resetSelectionType()};
ops.OdtCursor.RangeSelection="Range";ops.OdtCursor.RegionSelection="Region";ops.OdtCursor.signalCursorUpdated="cursorUpdated";(function(){var f=0;ops.StepsCache=function(k,a,e){function c(b,a){var d=this;this.nodeId=b;this.steps=-1;this.node=a;this.previousBookmark=this.nextBookmark=null;this.setIteratorPosition=function(b){b.setPositionBeforeElement(a);e(d.steps,b)}}function m(b,a,d){var c=this;this.nodeId=b;this.steps=a;this.node=d;this.previousBookmark=this.nextBookmark=null;this.setIteratorPosition=function(b){b.setUnfilteredPosition(d,0);e(c.steps,b)}}function n(b,a){var d="["+b.nodeId;a&&(d+=" => "+a.nodeId);return d+
"]"}function p(){for(var b=z,a,d,c,e=new core.LoopWatchDog(0,1E5),g={};b;){e.check();(a=b.previousBookmark)?runtime.assert(a.nextBookmark===b,"Broken bookmark link to previous @"+n(a,b)):(runtime.assert(b===z,"Broken bookmark link @"+n(b)),runtime.assert(void 0===w||z===z||z.steps<=w,"Base point is damaged @"+n(b)));(d=b.nextBookmark)&&runtime.assert(d.previousBookmark===b,"Broken bookmark link to next @"+n(b,d));if(void 0===w||b===z||b.steps<=w)runtime.assert(t.containsNode(k,b.node),"Disconnected node is being reported as undamaged @"+
n(b)),a&&(c=b.node.compareDocumentPosition(a.node),runtime.assert(0===c||0!==(c&x),"Bookmark order with previous does not reflect DOM order @"+n(a,b))),d&&t.containsNode(k,d.node)&&(c=b.node.compareDocumentPosition(d.node),runtime.assert(0===c||0!==(c&s),"Bookmark order with next does not reflect DOM order @"+n(b,d)));b=b.nextBookmark}Object.keys(l).forEach(function(b){var a=l[b];(void 0===w||b<=w)&&runtime.assert(a.steps<=b,"Bookmark step of "+a.steps+" exceeds cached step lookup for "+b+" @"+n(a));
runtime.assert(!1===g.hasOwnProperty(a.nodeId),"Bookmark "+n(a)+" appears twice in cached step lookup at steps "+g[a.nodeId]+" and "+b);g[a.nodeId]=b})}function q(b){var a="";b.nodeType===Node.ELEMENT_NODE&&(a=b.getAttributeNS(r,"nodeId")||"");return a}function g(b){var a=f.toString();b.setAttributeNS(r,"nodeId",a);f+=1;return a}function h(b){var d,c,e=new core.LoopWatchDog(0,1E4);void 0!==w&&b>w&&(b=w);for(d=Math.floor(b/a)*a;!c&&0<=d;)c=l[d],d-=a;for(c=c||z;c.nextBookmark&&c.nextBookmark.steps<=
b;)e.check(),c=c.nextBookmark;runtime.assert(-1===b||c.steps<=b,"Bookmark @"+n(c)+" at step "+c.steps+" exceeds requested step of "+b);return c}function d(b){b.previousBookmark&&(b.previousBookmark.nextBookmark=b.nextBookmark);b.nextBookmark&&(b.nextBookmark.previousBookmark=b.previousBookmark)}function b(b){for(var a,d=null;!d&&b&&b!==k;)(a=q(b))&&(d=y[a])&&d.node!==b&&(runtime.log("Cloned node detected. Creating new bookmark"),d=null,b.removeAttributeNS(r,"nodeId")),b=b.parentNode;return d}var r=
"urn:webodf:names:steps",l={},y={},t=core.DomUtils,z,w,s=Node.DOCUMENT_POSITION_FOLLOWING,x=Node.DOCUMENT_POSITION_PRECEDING,u;this.updateBookmark=function(b,e){var f,r=Math.ceil(b/a)*a,m,n,p;if(void 0!==w&&w<b){m=h(w);for(n=m.nextBookmark;n&&n.steps<=b;)f=n.nextBookmark,p=Math.ceil(n.steps/a)*a,l[p]===n&&delete l[p],t.containsNode(k,n.node)?n.steps=b+1:(d(n),delete y[n.nodeId]),n=f;w=b}else m=h(b);n=q(e)||g(e);f=y[n];f?f.node!==e&&(runtime.log("Cloned node detected. Creating new bookmark"),n=g(e),
f=y[n]=new c(n,e)):f=y[n]=new c(n,e);n=f;n.steps!==b&&(f=Math.ceil(n.steps/a)*a,f!==r&&l[f]===n&&delete l[f],n.steps=b);if(m!==n&&m.nextBookmark!==n){if(m.steps===n.steps)for(;0!==(n.node.compareDocumentPosition(m.node)&s)&&m!==z;)m=m.previousBookmark;m!==n&&m.nextBookmark!==n&&(d(n),f=m.nextBookmark,n.nextBookmark=m.nextBookmark,n.previousBookmark=m,m.nextBookmark=n,f&&(f.previousBookmark=n))}m=l[r];if(!m||n.steps>m.steps)l[r]=n;u()};this.setToClosestStep=function(b,a){var d;u();d=h(b);d.setIteratorPosition(a);
return d.steps};this.setToClosestDomPoint=function(a,d,c){var e,g;u();if(a===k&&0===d)e=z;else if(a===k&&d===k.childNodes.length)for(g in e=z,l)l.hasOwnProperty(g)&&(a=l[g],a.steps>e.steps&&(e=a));else if(e=b(a.childNodes.item(d)||a),!e)for(c.setUnfilteredPosition(a,d);!e&&c.previousNode();)e=b(c.getCurrentNode());e=e||z;void 0!==w&&e.steps>w&&(e=h(w));e.setIteratorPosition(c);return e.steps};this.damageCacheAfterStep=function(b){0>b&&(b=-1);void 0===w?w=b:b<w&&(w=b);u()};(function(){var b=q(k)||
g(k);z=new m(b,0,k);u=ops.StepsCache.ENABLE_CACHE_VERIFICATION?p:function(){}})()};ops.StepsCache.ENABLE_CACHE_VERIFICATION=!1;ops.StepsCache.Bookmark=function(){};ops.StepsCache.Bookmark.prototype.setIteratorPosition=function(f){}})();(function(){ops.OdtStepsTranslator=function(f,k,a,e){function c(b,a,d){var c=a.getCurrentNode();a.isBeforeNode()&&p.isParagraph(c)&&(d||(b+=1),n.updateBookmark(b,c))}function m(b,c){if(!c||a.acceptPosition(b)===g)return!0;for(;b.previousPosition();)if(a.acceptPosition(b)===g){if(c(h,b.container(),b.unfilteredDomOffset()))return!0;break}for(;b.nextPosition();)if(a.acceptPosition(b)===g){if(c(d,b.container(),b.unfilteredDomOffset()))return!0;break}return!1}var n,p=odf.OdfUtils,q=core.DomUtils,g=core.PositionFilter.FilterResult.FILTER_ACCEPT,
h=core.StepDirection.PREVIOUS,d=core.StepDirection.NEXT;this.convertStepsToDomPoint=function(b){var d,e;if(isNaN(b))throw new TypeError("Requested steps is not numeric ("+b+")");if(0>b)throw new RangeError("Requested steps is negative ("+b+")");for(d=n.setToClosestStep(b,k);d<b&&k.nextPosition();)(e=a.acceptPosition(k)===g)&&(d+=1),c(d,k,e);if(d!==b)throw new RangeError("Requested steps ("+b+") exceeds available steps ("+d+")");return{node:k.container(),offset:k.unfilteredDomOffset()}};this.convertDomPointToSteps=
function(b,d,e){var h;q.containsNode(f,b)||(d=0>q.comparePoints(f,0,b,d),b=f,d=d?0:f.childNodes.length);k.setUnfilteredPosition(b,d);m(k,e)||k.setUnfilteredPosition(b,d);e=k.container();d=k.unfilteredDomOffset();b=n.setToClosestDomPoint(e,d,k);if(0>q.comparePoints(k.container(),k.unfilteredDomOffset(),e,d))return 0<b?b-1:b;for(;(k.container()!==e||k.unfilteredDomOffset()!==d)&&k.nextPosition();)(h=a.acceptPosition(k)===g)&&(b+=1),c(b,k,h);return b+0};this.prime=function(){var b,d;for(b=n.setToClosestStep(0,
k);k.nextPosition();)(d=a.acceptPosition(k)===g)&&(b+=1),c(b,k,d)};this.handleStepsInserted=function(b){n.damageCacheAfterStep(b.position)};this.handleStepsRemoved=function(b){n.damageCacheAfterStep(b.position-1)};n=new ops.StepsCache(f,e,function(b,d){do{if(a.acceptPosition(d)===g){c(b,d,!0);break}c(b-1,d,!1)}while(d.nextPosition())})}})();ops.Operation=function(){};ops.Operation.prototype.init=function(f){};ops.Operation.prototype.execute=function(f){};ops.Operation.prototype.spec=function(){};ops.TextPositionFilter=function(){function f(a,c){for(;a&&c(a)!==m;)a=a.previousSibling;return a}function k(c,e,g,h){var d;if(e){if(a.isInlineRoot(e)&&a.isGroupingElement(g))return n;h=a.lookLeftForCharacter(e);if(1===h||2===h&&(a.scanRightForAnyCharacter(g)||a.scanRightForAnyCharacter(a.nextNode(c))))return m}else if(a.isGroupingElement(c)&&a.isInlineRoot(f(c.previousSibling,h)))return m;h=null===e&&a.isParagraph(c);d=a.lookRightForCharacter(g);if(h)return d?m:a.scanRightForAnyCharacter(g)?n:m;if(!d)return n;
e=e||a.previousNode(c);return a.scanLeftForAnyCharacter(e)?n:m}var a=odf.OdfUtils,e=Node.ELEMENT_NODE,c=Node.TEXT_NODE,m=core.PositionFilter.FilterResult.FILTER_ACCEPT,n=core.PositionFilter.FilterResult.FILTER_REJECT;this.acceptPosition=function(f){var q=f.container(),g=q.nodeType,h,d,b;if(g!==e&&g!==c)return n;if(g===c){g=f.unfilteredDomOffset();h=q.data;runtime.assert(g!==h.length,"Unexpected offset.");if(0<g){f=h[g-1];if(!a.isODFWhitespace(f))return m;if(1<g)if(f=h[g-2],!a.isODFWhitespace(f))b=
m;else{if(!a.isODFWhitespace(h.substr(0,g)))return n}else d=a.previousNode(q),a.scanLeftForNonSpace(d)&&(b=m);if(b===m)return a.isTrailingWhitespace(q,g)?n:m;f=h[g];return a.isODFWhitespace(f)?n:a.scanLeftForAnyCharacter(a.previousNode(q))?n:m}d=f.leftNode();b=q;q=q.parentNode;b=k(q,d,b,f.getNodeFilter())}else a.isGroupingElement(q)?(d=f.leftNode(),b=f.rightNode(),b=k(q,d,b,f.getNodeFilter())):b=n;return b}};ops.OdtDocument=function(f){function k(b){return new core.PositionIterator(b,B,Q,!1)}function a(){var b=f.odfContainer().getContentElement(),a=b&&b.localName;runtime.assert("text"===a,"Unsupported content element type '"+a+"' for OdtDocument");return b}function e(){return b.getDocumentElement().ownerDocument}function c(b){for(;b&&!(b.namespaceURI===odf.Namespaces.officens&&"text"===b.localName||b.namespaceURI===odf.Namespaces.officens&&"annotation"===b.localName);)b=b.parentNode;return b}function m(b){this.acceptPosition=
function(a){a=a.container();var d;d="string"===typeof b?t[b].getNode():b;return c(a)===c(d)?s:x}}function n(b,a,d,c){c=k(c);var e;1===d.length?e=d[0]:(e=new core.PositionFilterChain,d.forEach(e.addFilter));d=new core.StepIterator(e,c);d.setPosition(b,a);return d}function p(b){var d=k(a());b=H.convertStepsToDomPoint(b);d.setUnfilteredPosition(b.node,b.offset);return d}function q(b){return b===u}function g(a){var d=a.spec(),c=d.memberid,e=(new Date(d.timestamp)).toISOString(),d=f.odfContainer();a.isEdit&&
(c=b.getMember(c).getProperties().fullName,d.setMetadata({"dc:creator":c,"dc:date":e},null),c={setProperties:{"dc:creator":c,"dc:date":e},removedProperties:[]},D||(c.setProperties["meta:editing-cycles"]=d.incrementEditingCycles(),G||d.setMetadata(null,["meta:editing-duration","meta:document-statistic"])),D=a,b.emit(ops.OdtDocument.signalMetadataUpdated,c))}function h(b){var a,d=[],c,e=2;runtime.assert(b.isStep(),"positionIterator is not at a step");do{if(a=r.getContentBounds(b))if(a=a.container,l.isDowngradableSpaceElement(a)){for(c=
a.lastChild;a.firstChild;)d.push(a.firstChild),a.parentNode.insertBefore(a.firstChild,a);a.parentNode.removeChild(a);b.setPosition(c,c.nodeType===Node.TEXT_NODE?c.length:c.childNodes.length);b.roundToPreviousStep()}e-=1}while(0<e&&b.nextStep());d.forEach(y.normalizeTextNodes)}function d(b,a,d){b=b.childNodes.item(a)||b;return(b=l.getParagraphElement(b))&&y.containsNode(d,b)?b:d}var b=this,r,l=odf.OdfUtils,y=core.DomUtils,t={},z={},w=new core.EventNotifier([ops.Document.signalMemberAdded,ops.Document.signalMemberUpdated,
ops.Document.signalMemberRemoved,ops.Document.signalCursorAdded,ops.Document.signalCursorRemoved,ops.Document.signalCursorMoved,ops.OdtDocument.signalParagraphChanged,ops.OdtDocument.signalParagraphStyleModified,ops.OdtDocument.signalCommonStyleCreated,ops.OdtDocument.signalCommonStyleDeleted,ops.OdtDocument.signalTableAdded,ops.OdtDocument.signalOperationStart,ops.OdtDocument.signalOperationEnd,ops.OdtDocument.signalProcessingBatchStart,ops.OdtDocument.signalProcessingBatchEnd,ops.OdtDocument.signalUndoStackChanged,
ops.OdtDocument.signalStepsInserted,ops.OdtDocument.signalStepsRemoved,ops.OdtDocument.signalMetadataUpdated,ops.OdtDocument.signalAnnotationAdded]),s=core.PositionFilter.FilterResult.FILTER_ACCEPT,x=core.PositionFilter.FilterResult.FILTER_REJECT,u=core.StepDirection.NEXT,C,H,D,G=!1,B=NodeFilter.SHOW_ALL,J=new gui.BlacklistNamespaceNodeFilter(["urn:webodf:names:cursor","urn:webodf:names:editinfo"]),P=new gui.OdfTextBodyNodeFilter,Q=new core.NodeFilterChain([J,P]);this.createPositionIterator=k;this.getDocumentElement=
function(){return f.odfContainer().rootElement};this.cloneDocumentElement=function(){var a=b.getDocumentElement(),d=f.getAnnotationViewManager();d&&d.forgetAnnotations();a=a.cloneNode(!0);f.refreshAnnotations();b.fixCursorPositions();return a};this.setDocumentElement=function(b){var d=f.odfContainer();w.unsubscribe(ops.OdtDocument.signalStepsInserted,H.handleStepsInserted);w.unsubscribe(ops.OdtDocument.signalStepsRemoved,H.handleStepsRemoved);d.setRootElement(b);f.setOdfContainer(d,!0);f.refreshCSS();
b=a();H=new ops.OdtStepsTranslator(b,k(b),C,500);w.subscribe(ops.OdtDocument.signalStepsInserted,H.handleStepsInserted);w.subscribe(ops.OdtDocument.signalStepsRemoved,H.handleStepsRemoved)};this.getDOMDocument=e;this.getRootElement=c;this.createStepIterator=n;this.getIteratorAtPosition=p;this.convertCursorStepToDomPoint=function(b){return H.convertStepsToDomPoint(b)};this.convertDomPointToCursorStep=function(b,a,d){var c;d===u&&(c=q);return H.convertDomPointToSteps(b,a,c)};this.convertDomToCursorRange=
function(b){var a;a=H.convertDomPointToSteps(b.anchorNode,b.anchorOffset);b=b.anchorNode===b.focusNode&&b.anchorOffset===b.focusOffset?a:H.convertDomPointToSteps(b.focusNode,b.focusOffset);return{position:a,length:b-a}};this.convertCursorToDomRange=function(b,a){var d=e().createRange(),c,g;c=H.convertStepsToDomPoint(b);a?(g=H.convertStepsToDomPoint(b+a),0<a?(d.setStart(c.node,c.offset),d.setEnd(g.node,g.offset)):(d.setStart(g.node,g.offset),d.setEnd(c.node,c.offset))):d.setStart(c.node,c.offset);
return d};this.upgradeWhitespacesAtPosition=function(b){var a=p(b),a=new core.StepIterator(C,a),d,c=2;runtime.assert(a.isStep(),"positionIterator is not at a step (requested step: "+b+")");do{if(d=r.getContentBounds(a))if(b=d.container,d=d.startOffset,b.nodeType===Node.TEXT_NODE&&l.isSignificantWhitespace(b,d)){runtime.assert(" "===b.data[d],"upgradeWhitespaceToElement: textNode.data[offset] should be a literal space");var e=b.ownerDocument.createElementNS(odf.Namespaces.textns,"text:s"),g=b.parentNode,
f=b;e.appendChild(b.ownerDocument.createTextNode(" "));1===b.length?g.replaceChild(e,b):(b.deleteData(d,1),0<d&&(d<b.length&&b.splitText(d),f=b.nextSibling),g.insertBefore(e,f));b=e;a.setPosition(b,b.childNodes.length);a.roundToPreviousStep()}c-=1}while(0<c&&a.nextStep())};this.downgradeWhitespaces=h;this.downgradeWhitespacesAtPosition=function(b){b=p(b);b=new core.StepIterator(C,b);h(b)};this.getTextNodeAtStep=function(a,d){var c=p(a),g=c.container(),l,f=0,h=null;g.nodeType===Node.TEXT_NODE?(l=g,
f=c.unfilteredDomOffset(),0<l.length&&(0<f&&(l=l.splitText(f)),l.parentNode.insertBefore(e().createTextNode(""),l),l=l.previousSibling,f=0)):(l=e().createTextNode(""),f=0,g.insertBefore(l,c.rightNode()));if(d){if(t[d]&&b.getCursorPosition(d)===a){for(h=t[d].getNode();h.nextSibling&&"cursor"===h.nextSibling.localName;)h.parentNode.insertBefore(h.nextSibling,h);0<l.length&&l.nextSibling!==h&&(l=e().createTextNode(""),f=0);h.parentNode.insertBefore(l,h)}}else for(;l.nextSibling&&"cursor"===l.nextSibling.localName;)l.parentNode.insertBefore(l.nextSibling,
l);for(;l.previousSibling&&l.previousSibling.nodeType===Node.TEXT_NODE;)c=l.previousSibling,c.appendData(l.data),f=c.length,l=c,l.parentNode.removeChild(l.nextSibling);for(;l.nextSibling&&l.nextSibling.nodeType===Node.TEXT_NODE;)c=l.nextSibling,l.appendData(c.data),l.parentNode.removeChild(c);return{textNode:l,offset:f}};this.fixCursorPositions=function(){Object.keys(t).forEach(function(a){var e=t[a],g=c(e.getNode()),l=b.createRootFilter(g),f,h,m,r=!1;m=e.getSelectedRange();f=d(m.startContainer,m.startOffset,
g);h=n(m.startContainer,m.startOffset,[C,l],f);m.collapsed?g=h:(f=d(m.endContainer,m.endOffset,g),g=n(m.endContainer,m.endOffset,[C,l],f));h.isStep()&&g.isStep()?h.container()!==g.container()||h.offset()!==g.offset()||m.collapsed&&e.getAnchorNode()===e.getNode()||(r=!0,m.setStart(h.container(),h.offset()),m.collapse(!0)):(r=!0,runtime.assert(h.roundToClosestStep(),"No walkable step found for cursor owned by "+a),m.setStart(h.container(),h.offset()),runtime.assert(g.roundToClosestStep(),"No walkable step found for cursor owned by "+
a),m.setEnd(g.container(),g.offset()));r&&(e.setSelectedRange(m,e.hasForwardSelection()),b.emit(ops.Document.signalCursorMoved,e))})};this.getCursorPosition=function(b){return(b=t[b])?H.convertDomPointToSteps(b.getNode(),0):0};this.getCursorSelection=function(b){b=t[b];var a=0,d=0;b&&(a=H.convertDomPointToSteps(b.getNode(),0),d=H.convertDomPointToSteps(b.getAnchorNode(),0));return{position:d,length:a-d}};this.getPositionFilter=function(){return C};this.getOdfCanvas=function(){return f};this.getCanvas=
function(){return f};this.getRootNode=a;this.addMember=function(b){runtime.assert(void 0===z[b.getMemberId()],"This member already exists");z[b.getMemberId()]=b};this.getMember=function(b){return z.hasOwnProperty(b)?z[b]:null};this.removeMember=function(b){delete z[b]};this.getCursor=function(b){return t[b]};this.getMemberIds=function(){var b=[],a;for(a in t)t.hasOwnProperty(a)&&b.push(t[a].getMemberId());return b};this.addCursor=function(a){runtime.assert(Boolean(a),"OdtDocument::addCursor without cursor");
var d=a.getMemberId(),c=b.convertCursorToDomRange(0,0);runtime.assert("string"===typeof d,"OdtDocument::addCursor has cursor without memberid");runtime.assert(!t[d],"OdtDocument::addCursor is adding a duplicate cursor with memberid "+d);a.setSelectedRange(c,!0);t[d]=a};this.removeCursor=function(a){var d=t[a];return d?(d.removeFromDocument(),delete t[a],b.emit(ops.Document.signalCursorRemoved,a),!0):!1};this.moveCursor=function(a,d,c,e){a=t[a];d=b.convertCursorToDomRange(d,c);a&&(a.setSelectedRange(d,
0<=c),a.setSelectionType(e||ops.OdtCursor.RangeSelection))};this.getFormatting=function(){return f.getFormatting()};this.emit=function(b,a){w.emit(b,a)};this.subscribe=function(b,a){w.subscribe(b,a)};this.unsubscribe=function(b,a){w.unsubscribe(b,a)};this.createRootFilter=function(b){return new m(b)};this.close=function(b){b()};this.destroy=function(b){b()};(function(){var b=a();C=new ops.TextPositionFilter;r=new odf.StepUtils;H=new ops.OdtStepsTranslator(b,k(b),C,500);w.subscribe(ops.OdtDocument.signalStepsInserted,
H.handleStepsInserted);w.subscribe(ops.OdtDocument.signalStepsRemoved,H.handleStepsRemoved);w.subscribe(ops.OdtDocument.signalOperationEnd,g);w.subscribe(ops.OdtDocument.signalProcessingBatchEnd,core.Task.processTasks)})()};ops.OdtDocument.signalParagraphChanged="paragraph/changed";ops.OdtDocument.signalTableAdded="table/added";ops.OdtDocument.signalCommonStyleCreated="style/created";ops.OdtDocument.signalCommonStyleDeleted="style/deleted";ops.OdtDocument.signalParagraphStyleModified="paragraphstyle/modified";
ops.OdtDocument.signalOperationStart="operation/start";ops.OdtDocument.signalOperationEnd="operation/end";ops.OdtDocument.signalProcessingBatchStart="router/batchstart";ops.OdtDocument.signalProcessingBatchEnd="router/batchend";ops.OdtDocument.signalUndoStackChanged="undo/changed";ops.OdtDocument.signalStepsInserted="steps/inserted";ops.OdtDocument.signalStepsRemoved="steps/removed";ops.OdtDocument.signalMetadataUpdated="metadata/updated";ops.OdtDocument.signalAnnotationAdded="annotation/added";ops.OpAddAnnotation=function(){function f(a,c,e){var h=a.getTextNodeAtStep(e,k);h&&(a=h.textNode,e=a.parentNode,h.offset!==a.length&&a.splitText(h.offset),e.insertBefore(c,a.nextSibling),0===a.length&&e.removeChild(a))}var k,a,e,c,m,n;this.init=function(f){k=f.memberid;a=parseInt(f.timestamp,10);e=parseInt(f.position,10);c=void 0!==f.length?parseInt(f.length,10)||0:void 0;m=f.name};this.isEdit=!0;this.group=void 0;this.execute=function(p){var q=p.getCursor(k),g,h;n=p.getDOMDocument();var d=new Date(a),
b,r,l;b=n.createElementNS(odf.Namespaces.officens,"office:annotation");b.setAttributeNS(odf.Namespaces.officens,"office:name",m);g=n.createElementNS(odf.Namespaces.dcns,"dc:creator");g.setAttributeNS("urn:webodf:names:editinfo","editinfo:memberid",k);g.textContent=p.getMember(k).getProperties().fullName;h=n.createElementNS(odf.Namespaces.dcns,"dc:date");h.appendChild(n.createTextNode(d.toISOString()));d=n.createElementNS(odf.Namespaces.textns,"text:list");r=n.createElementNS(odf.Namespaces.textns,
"text:list-item");l=n.createElementNS(odf.Namespaces.textns,"text:p");r.appendChild(l);d.appendChild(r);b.appendChild(g);b.appendChild(h);b.appendChild(d);void 0!==c&&(g=n.createElementNS(odf.Namespaces.officens,"office:annotation-end"),g.setAttributeNS(odf.Namespaces.officens,"office:name",m),b.annotationEndElement=g,f(p,g,e+c));f(p,b,e);p.emit(ops.OdtDocument.signalStepsInserted,{position:e});q&&(g=n.createRange(),h=b.getElementsByTagNameNS(odf.Namespaces.textns,"p")[0],g.selectNodeContents(h),
q.setSelectedRange(g,!1),q.setSelectionType(ops.OdtCursor.RangeSelection),p.emit(ops.Document.signalCursorMoved,q));p.getOdfCanvas().addAnnotation(b);p.fixCursorPositions();p.emit(ops.OdtDocument.signalAnnotationAdded,{memberId:k,annotation:b});return!0};this.spec=function(){return{optype:"AddAnnotation",memberid:k,timestamp:a,position:e,length:c,name:m}}};ops.OpAddCursor=function(){var f,k;this.init=function(a){f=a.memberid;k=a.timestamp};this.isEdit=!1;this.group=void 0;this.execute=function(a){var e=a.getCursor(f);if(e)return!1;e=new ops.OdtCursor(f,a);a.addCursor(e);a.emit(ops.Document.signalCursorAdded,e);return!0};this.spec=function(){return{optype:"AddCursor",memberid:f,timestamp:k}}};ops.OpAddMember=function(){var f,k,a;this.init=function(e){f=e.memberid;k=parseInt(e.timestamp,10);a=e.setProperties};this.isEdit=!1;this.group=void 0;this.execute=function(e){var c;if(e.getMember(f))return!1;c=new ops.Member(f,a);e.addMember(c);e.emit(ops.Document.signalMemberAdded,c);return!0};this.spec=function(){return{optype:"AddMember",memberid:f,timestamp:k,setProperties:a}}};ops.OpAddStyle=function(){var f,k,a,e,c,m,n=odf.Namespaces.stylens;this.init=function(n){f=n.memberid;k=n.timestamp;a=n.styleName;e=n.styleFamily;c="true"===n.isAutomaticStyle||!0===n.isAutomaticStyle;m=n.setProperties};this.isEdit=!0;this.group=void 0;this.execute=function(f){var k=f.getOdfCanvas().odfContainer(),g=f.getFormatting(),h=f.getDOMDocument().createElementNS(n,"style:style");if(!h)return!1;m&&g.updateStyle(h,m);h.setAttributeNS(n,"style:family",e);h.setAttributeNS(n,"style:name",a);c?
k.rootElement.automaticStyles.appendChild(h):k.rootElement.styles.appendChild(h);f.getOdfCanvas().refreshCSS();c||f.emit(ops.OdtDocument.signalCommonStyleCreated,{name:a,family:e});return!0};this.spec=function(){return{optype:"AddStyle",memberid:f,timestamp:k,styleName:a,styleFamily:e,isAutomaticStyle:c,setProperties:m}}};odf.ObjectNameGenerator=function(f,k){function a(b,a){var d={};this.generateName=function(){var c=a(),e=0,g;do g=b+e,e+=1;while(d[g]||c[g]);d[g]=!0;return g}}function e(){var b={};[f.rootElement.automaticStyles,f.rootElement.styles].forEach(function(a){for(a=a.firstElementChild;a;)a.namespaceURI===c&&"style"===a.localName&&(b[a.getAttributeNS(c,"name")]=!0),a=a.nextElementSibling});return b}var c=odf.Namespaces.stylens,m=odf.Namespaces.drawns,n=odf.Namespaces.xlinkns,p=(new core.Utils).hashString(k),
q=null,g=null,h=null,d={},b={};this.generateStyleName=function(){null===q&&(q=new a("auto"+p+"_",function(){return e()}));return q.generateName()};this.generateFrameName=function(){var b,c,e;if(null===g){c=f.rootElement.body.getElementsByTagNameNS(m,"frame");for(b=0;b<c.length;b+=1)e=c.item(b),d[e.getAttributeNS(m,"name")]=!0;g=new a("fr"+p+"_",function(){return d})}return g.generateName()};this.generateImageName=function(){var d,c,e;if(null===h){e=f.rootElement.body.getElementsByTagNameNS(m,"image");
for(d=0;d<e.length;d+=1)c=e.item(d),c=c.getAttributeNS(n,"href"),c=c.substring(9,c.lastIndexOf(".")),b[c]=!0;h=new a("img"+p+"_",function(){return b})}return h.generateName()}};odf.TextStyleApplicator=function(f,k,a){function e(a){function c(b,a){return"object"===typeof b&&"object"===typeof a?Object.keys(b).every(function(d){return c(b[d],a[d])}):b===a}var d={};this.isStyleApplied=function(b){b=k.getAppliedStylesForElement(b,d).styleProperties;return c(a,b)}}function c(c){var e={};this.applyStyleToContainer=function(d){var b;b=d.getAttributeNS(p,"style-name");var m=d.ownerDocument;b=b||"";if(!e.hasOwnProperty(b)){var l=b,n;n=b?k.createDerivedStyleObject(b,"text",c):c;m=
m.createElementNS(q,"style:style");k.updateStyle(m,n);m.setAttributeNS(q,"style:name",f.generateStyleName());m.setAttributeNS(q,"style:family","text");m.setAttributeNS("urn:webodf:names:scope","scope","document-content");a.appendChild(m);e[l]=m}b=e[b].getAttributeNS(q,"name");d.setAttributeNS(p,"text:style-name",b)}}function m(a,c){var d=a.ownerDocument,b=a.parentNode,e,l,f,m=new core.LoopWatchDog(1E4);l=[];l.push(a);for(f=a.nextSibling;f&&n.rangeContainsNode(c,f);)m.check(),l.push(f),f=f.nextSibling;
"span"!==b.localName||b.namespaceURI!==p?(e=d.createElementNS(p,"text:span"),b.insertBefore(e,a),d=!1):(a.previousSibling&&!n.rangeContainsNode(c,b.firstChild)?(e=b.cloneNode(!1),b.parentNode.insertBefore(e,b.nextSibling)):e=b,d=!0);l.forEach(function(b){b.parentNode!==e&&e.appendChild(b)});if(f&&d)for(l=e.cloneNode(!1),e.parentNode.insertBefore(l,e.nextSibling);f;)m.check(),d=f.nextSibling,l.appendChild(f),f=d;return e}var n=core.DomUtils,p=odf.Namespaces.textns,q=odf.Namespaces.stylens;this.applyStyle=
function(a,f,d){var b={},n,l,k,p;runtime.assert(d&&d.hasOwnProperty("style:text-properties"),"applyStyle without any text properties");b["style:text-properties"]=d["style:text-properties"];k=new c(b);p=new e(b);a.forEach(function(b){n=p.isStyleApplied(b);!1===n&&(l=m(b,f),k.applyStyleToContainer(l))})}};ops.OpApplyDirectStyling=function(){function f(a,c,e){var d=a.getOdfCanvas().odfContainer(),b=p.splitBoundaries(c),f=n.getTextNodes(c,!1);(new odf.TextStyleApplicator(new odf.ObjectNameGenerator(d,k),a.getFormatting(),d.rootElement.automaticStyles)).applyStyle(f,c,e);b.forEach(p.normalizeTextNodes)}var k,a,e,c,m,n=odf.OdfUtils,p=core.DomUtils;this.init=function(f){k=f.memberid;a=f.timestamp;e=parseInt(f.position,10);c=parseInt(f.length,10);m=f.setProperties};this.isEdit=!0;this.group=void 0;this.execute=
function(p){var g=p.convertCursorToDomRange(e,c),h=n.getParagraphElements(g);f(p,g,m);g.detach();p.getOdfCanvas().refreshCSS();p.fixCursorPositions();h.forEach(function(d){p.emit(ops.OdtDocument.signalParagraphChanged,{paragraphElement:d,memberId:k,timeStamp:a})});p.getOdfCanvas().rerenderAnnotations();return!0};this.spec=function(){return{optype:"ApplyDirectStyling",memberid:k,timestamp:a,position:e,length:c,setProperties:m}}};ops.OpApplyHyperlink=function(){function f(a){for(;a;){if(p.isHyperlink(a))return!0;a=a.parentNode}return!1}var k,a,e,c,m,n=core.DomUtils,p=odf.OdfUtils;this.init=function(f){k=f.memberid;a=f.timestamp;e=f.position;c=f.length;m=f.hyperlink};this.isEdit=!0;this.group=void 0;this.execute=function(q){var g=q.getDOMDocument(),h=q.convertCursorToDomRange(e,c),d=n.splitBoundaries(h),b=[],r=p.getTextNodes(h,!1);if(0===r.length)return!1;r.forEach(function(a){var d=p.getParagraphElement(a);runtime.assert(!1===
f(a),"The given range should not contain any link.");var c=m,e=g.createElementNS(odf.Namespaces.textns,"text:a");e.setAttributeNS(odf.Namespaces.xlinkns,"xlink:type","simple");e.setAttributeNS(odf.Namespaces.xlinkns,"xlink:href",c);a.parentNode.insertBefore(e,a);e.appendChild(a);-1===b.indexOf(d)&&b.push(d)});d.forEach(n.normalizeTextNodes);h.detach();q.fixCursorPositions();q.getOdfCanvas().refreshSize();q.getOdfCanvas().rerenderAnnotations();b.forEach(function(b){q.emit(ops.OdtDocument.signalParagraphChanged,
{paragraphElement:b,memberId:k,timeStamp:a})});return!0};this.spec=function(){return{optype:"ApplyHyperlink",memberid:k,timestamp:a,position:e,length:c,hyperlink:m}}};ops.OpInsertImage=function(){var f,k,a,e,c,m,n,p,q=odf.Namespaces.drawns,g=odf.Namespaces.svgns,h=odf.Namespaces.textns,d=odf.Namespaces.xlinkns,b=odf.OdfUtils;this.init=function(b){f=b.memberid;k=b.timestamp;a=b.position;e=b.filename;c=b.frameWidth;m=b.frameHeight;n=b.frameStyleName;p=b.frameName};this.isEdit=!0;this.group=void 0;this.execute=function(r){var l=r.getOdfCanvas(),y=r.getTextNodeAtStep(a,f),t,z;if(!y)return!1;t=y.textNode;z=b.getParagraphElement(t);var y=y.offset!==t.length?t.splitText(y.offset):
t.nextSibling,w=r.getDOMDocument(),s=w.createElementNS(q,"draw:image"),w=w.createElementNS(q,"draw:frame");s.setAttributeNS(d,"xlink:href",e);s.setAttributeNS(d,"xlink:type","simple");s.setAttributeNS(d,"xlink:show","embed");s.setAttributeNS(d,"xlink:actuate","onLoad");w.setAttributeNS(q,"draw:style-name",n);w.setAttributeNS(q,"draw:name",p);w.setAttributeNS(h,"text:anchor-type","as-char");w.setAttributeNS(g,"svg:width",c);w.setAttributeNS(g,"svg:height",m);w.appendChild(s);t.parentNode.insertBefore(w,
y);r.emit(ops.OdtDocument.signalStepsInserted,{position:a});0===t.length&&t.parentNode.removeChild(t);l.addCssForFrameWithImage(w);l.refreshCSS();r.emit(ops.OdtDocument.signalParagraphChanged,{paragraphElement:z,memberId:f,timeStamp:k});l.rerenderAnnotations();return!0};this.spec=function(){return{optype:"InsertImage",memberid:f,timestamp:k,filename:e,position:a,frameWidth:c,frameHeight:m,frameStyleName:n,frameName:p}}};ops.OpInsertTable=function(){function f(a,b){var f;if(1===g.length)f=g[0];else if(3===g.length)switch(a){case 0:f=g[0];break;case e-1:f=g[2];break;default:f=g[1]}else f=g[a];if(1===f.length)return f[0];if(3===f.length)switch(b){case 0:return f[0];case c-1:return f[2];default:return f[1]}return f[b]}var k,a,e,c,m,n,p,q,g,h=odf.OdfUtils;this.init=function(d){k=d.memberid;a=d.timestamp;m=d.position;e=d.initialRows;c=d.initialColumns;n=d.tableName;p=d.tableStyleName;q=d.tableColumnStyleName;g=d.tableCellStyleMatrix};
this.isEdit=!0;this.group=void 0;this.execute=function(d){var b=d.getTextNodeAtStep(m),g=d.getRootNode();if(b){var l=d.getDOMDocument(),y=l.createElementNS("urn:oasis:names:tc:opendocument:xmlns:table:1.0","table:table"),t=l.createElementNS("urn:oasis:names:tc:opendocument:xmlns:table:1.0","table:table-column"),z,w,s,x;p&&y.setAttributeNS("urn:oasis:names:tc:opendocument:xmlns:table:1.0","table:style-name",p);n&&y.setAttributeNS("urn:oasis:names:tc:opendocument:xmlns:table:1.0","table:name",n);t.setAttributeNS("urn:oasis:names:tc:opendocument:xmlns:table:1.0",
"table:number-columns-repeated",c);q&&t.setAttributeNS("urn:oasis:names:tc:opendocument:xmlns:table:1.0","table:style-name",q);y.appendChild(t);for(s=0;s<e;s+=1){t=l.createElementNS("urn:oasis:names:tc:opendocument:xmlns:table:1.0","table:table-row");for(x=0;x<c;x+=1)z=l.createElementNS("urn:oasis:names:tc:opendocument:xmlns:table:1.0","table:table-cell"),(w=f(s,x))&&z.setAttributeNS("urn:oasis:names:tc:opendocument:xmlns:table:1.0","table:style-name",w),w=l.createElementNS("urn:oasis:names:tc:opendocument:xmlns:text:1.0",
"text:p"),z.appendChild(w),t.appendChild(z);y.appendChild(t)}b=h.getParagraphElement(b.textNode);g.insertBefore(y,b.nextSibling);d.emit(ops.OdtDocument.signalStepsInserted,{position:m});d.getOdfCanvas().refreshSize();d.emit(ops.OdtDocument.signalTableAdded,{tableElement:y,memberId:k,timeStamp:a});d.getOdfCanvas().rerenderAnnotations();return!0}return!1};this.spec=function(){return{optype:"InsertTable",memberid:k,timestamp:a,position:m,initialRows:e,initialColumns:c,tableName:n,tableStyleName:p,tableColumnStyleName:q,
tableCellStyleMatrix:g}}};ops.OpInsertText=function(){var f,k,a,e,c,m=odf.OdfUtils;this.init=function(m){f=m.memberid;k=m.timestamp;a=m.position;c=m.text;e="true"===m.moveCursor||!0===m.moveCursor};this.isEdit=!0;this.group=void 0;this.execute=function(n){var p,q,g,h=null,d=n.getDOMDocument(),b,r=0,l,y=n.getCursor(f),t;n.upgradeWhitespacesAtPosition(a);if(p=n.getTextNodeAtStep(a)){q=p.textNode;h=q.nextSibling;g=q.parentNode;b=m.getParagraphElement(q);for(t=0;t<c.length;t+=1)if("\t"===c[t]||"\t"!==c[t]&&m.isODFWhitespace(c[t])&&
(0===t||t===c.length-1||"\t"!==c[t-1]&&m.isODFWhitespace(c[t-1])))0===r?(p.offset!==q.length&&(h=q.splitText(p.offset)),0<t&&q.appendData(c.substring(0,t))):r<t&&(r=c.substring(r,t),g.insertBefore(d.createTextNode(r),h)),r=t+1,"\t"===c[t]?(l=d.createElementNS("urn:oasis:names:tc:opendocument:xmlns:text:1.0","text:tab"),l.appendChild(d.createTextNode("\t"))):(" "!==c[t]&&runtime.log("WARN: InsertText operation contains non-tab, non-space whitespace character (character code "+c.charCodeAt(t)+")"),
l=d.createElementNS("urn:oasis:names:tc:opendocument:xmlns:text:1.0","text:s"),l.appendChild(d.createTextNode(" "))),g.insertBefore(l,h);0===r?q.insertData(p.offset,c):r<c.length&&(p=c.substring(r),g.insertBefore(d.createTextNode(p),h));g=q.parentNode;h=q.nextSibling;g.removeChild(q);g.insertBefore(q,h);0===q.length&&q.parentNode.removeChild(q);n.emit(ops.OdtDocument.signalStepsInserted,{position:a});y&&e&&(n.moveCursor(f,a+c.length,0),n.emit(ops.Document.signalCursorMoved,y));n.downgradeWhitespacesAtPosition(a);
n.downgradeWhitespacesAtPosition(a+c.length);n.getOdfCanvas().refreshSize();n.emit(ops.OdtDocument.signalParagraphChanged,{paragraphElement:b,memberId:f,timeStamp:k});n.getOdfCanvas().rerenderAnnotations();return!0}return!1};this.spec=function(){return{optype:"InsertText",memberid:f,timestamp:k,position:a,text:c,moveCursor:e}}};odf.CollapsingRules=function(f){function k(a){return e.isODFNode(a)||"br"===a.localName&&e.isLineBreak(a.parentNode)||a.nodeType===Node.TEXT_NODE&&e.isODFNode(a.parentNode)?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}function a(m){var n;m.nodeType===Node.TEXT_NODE?(n=m.parentNode,n.removeChild(m)):n=c.removeUnwantedNodes(m,k);return n&&!e.isParagraph(n)&&n!==f&&e.hasNoODFContent(n)?a(n):n}var e=odf.OdfUtils,c=core.DomUtils;this.mergeChildrenIntoParent=a};ops.OpMergeParagraph=function(){function f(b){return odf.OdfUtils.isInlineRoot(b)?NodeFilter.FILTER_SKIP:h.isGroupingElement(b)&&h.hasNoODFContent(b)?NodeFilter.FILTER_REJECT:NodeFilter.FILTER_ACCEPT}function k(b){if(b.nodeType===Node.TEXT_NODE){if(0===b.length)return runtime.log("WARN: Empty text node found during merge operation"),!0;if(h.isODFWhitespace(b.data)&&!1===h.isSignificantWhitespace(b,0))return!0;b="#text"}else b=(b.prefix?b.prefix+":":"")+b.localName;runtime.log("WARN: Unexpected text element found near paragraph boundary ["+
b+"]");return!1}function a(b){b.collapsed||(d.splitBoundaries(b),b=h.getTextElements(b,!1,!0).filter(k),b.forEach(function(b){b.parentNode.removeChild(b)}))}function e(b,a,d){b=b.convertCursorStepToDomPoint(a);var c=h.getParagraphElement(b.node,b.offset);runtime.assert(Boolean(c),"Paragraph not found at step "+a);d&&d.setPosition(b.node,b.offset);return c}var c,m,n,p,q,g,h=odf.OdfUtils,d=core.DomUtils,b=odf.Namespaces.textns;this.init=function(b){c=b.memberid;m=b.timestamp;n=b.moveCursor;p=b.paragraphStyleName;
q=parseInt(b.sourceStartPosition,10);g=parseInt(b.destinationStartPosition,10)};this.isEdit=!0;this.group=void 0;this.execute=function(h){var l,k,t=h.getCursor(c);l=h.getRootNode();var z=new odf.CollapsingRules(l),w=h.createStepIterator(l,0,[h.getPositionFilter()],l),s;runtime.assert(g<q,"Destination paragraph ("+g+") must be before source paragraph ("+q+")");k=e(h,g);l=e(h,q,w);w.previousStep();runtime.assert(d.containsNode(k,w.container()),"Destination paragraph must be adjacent to the source paragraph");
s=k.ownerDocument.createRange();w.setPosition(k,k.childNodes.length);w.roundToPreviousStep();s.setStart(w.container(),w.offset());s.setEnd(k,k.childNodes.length);a(s);s=k.childNodes.length;var x=l.ownerDocument.createRange();w.setPosition(l,0);w.roundToNextStep();x.setStart(l,0);x.setEnd(w.container(),w.offset());a(x);for(x=l.firstChild;x;)"editinfo"===x.localName?l.removeChild(x):(k.appendChild(x),d.removeUnwantedNodes(x,f)),x=l.firstChild;runtime.assert(0===l.childNodes.length,"Source paragraph should be empty before it is removed");
z.mergeChildrenIntoParent(l);h.emit(ops.OdtDocument.signalStepsRemoved,{position:q-1});w.setPosition(k,s);w.roundToClosestStep();w.previousStep()||w.roundToNextStep();h.downgradeWhitespaces(w);p?k.setAttributeNS(b,"text:style-name",p):k.removeAttributeNS(b,"style-name");t&&n&&(h.moveCursor(c,q-1,0),h.emit(ops.Document.signalCursorMoved,t));h.fixCursorPositions();h.getOdfCanvas().refreshSize();h.emit(ops.OdtDocument.signalParagraphChanged,{paragraphElement:k,memberId:c,timeStamp:m});h.getOdfCanvas().rerenderAnnotations();
return!0};this.spec=function(){return{optype:"MergeParagraph",memberid:c,timestamp:m,moveCursor:n,paragraphStyleName:p,sourceStartPosition:q,destinationStartPosition:g}}};ops.OpMoveCursor=function(){var f,k,a,e,c;this.init=function(m){f=m.memberid;k=m.timestamp;a=m.position;e=m.length||0;c=m.selectionType||ops.OdtCursor.RangeSelection};this.isEdit=!1;this.group=void 0;this.execute=function(m){var n=m.getCursor(f),k;if(!n)return!1;k=m.convertCursorToDomRange(a,e);n.setSelectedRange(k,0<=e);n.setSelectionType(c);m.emit(ops.Document.signalCursorMoved,n);return!0};this.spec=function(){return{optype:"MoveCursor",memberid:f,timestamp:k,position:a,length:e,selectionType:c}}};ops.OpRemoveAnnotation=function(){var f,k,a,e,c=core.DomUtils;this.init=function(c){f=c.memberid;k=c.timestamp;a=parseInt(c.position,10);e=parseInt(c.length,10)};this.isEdit=!0;this.group=void 0;this.execute=function(e){function f(a){q.parentNode.insertBefore(a,q)}for(var k=e.getIteratorAtPosition(a).container(),q;k.namespaceURI!==odf.Namespaces.officens||"annotation"!==k.localName;)k=k.parentNode;if(null===k)return!1;q=k;k=q.annotationEndElement;e.getOdfCanvas().forgetAnnotation(q);c.getElementsByTagNameNS(q,
"urn:webodf:names:cursor","cursor").forEach(f);c.getElementsByTagNameNS(q,"urn:webodf:names:cursor","anchor").forEach(f);q.parentNode.removeChild(q);k&&k.parentNode.removeChild(k);e.emit(ops.OdtDocument.signalStepsRemoved,{position:0<a?a-1:a});e.getOdfCanvas().rerenderAnnotations();e.fixCursorPositions();return!0};this.spec=function(){return{optype:"RemoveAnnotation",memberid:f,timestamp:k,position:a,length:e}}};ops.OpRemoveBlob=function(){var f,k,a;this.init=function(e){f=e.memberid;k=e.timestamp;a=e.filename};this.isEdit=!0;this.group=void 0;this.execute=function(e){e.getOdfCanvas().odfContainer().removeBlob(a);return!0};this.spec=function(){return{optype:"RemoveBlob",memberid:f,timestamp:k,filename:a}}};ops.OpRemoveCursor=function(){var f,k;this.init=function(a){f=a.memberid;k=a.timestamp};this.isEdit=!1;this.group=void 0;this.execute=function(a){return a.removeCursor(f)?!0:!1};this.spec=function(){return{optype:"RemoveCursor",memberid:f,timestamp:k}}};ops.OpRemoveHyperlink=function(){var f,k,a,e,c=core.DomUtils,m=odf.OdfUtils;this.init=function(c){f=c.memberid;k=c.timestamp;a=c.position;e=c.length};this.isEdit=!0;this.group=void 0;this.execute=function(n){var p=n.convertCursorToDomRange(a,e),q=m.getHyperlinkElements(p);runtime.assert(1===q.length,"The given range should only contain a single link.");q=c.mergeIntoParent(q[0]);p.detach();n.fixCursorPositions();n.getOdfCanvas().refreshSize();n.getOdfCanvas().rerenderAnnotations();n.emit(ops.OdtDocument.signalParagraphChanged,
{paragraphElement:m.getParagraphElement(q),memberId:f,timeStamp:k});return!0};this.spec=function(){return{optype:"RemoveHyperlink",memberid:f,timestamp:k,position:a,length:e}}};ops.OpRemoveMember=function(){var f,k;this.init=function(a){f=a.memberid;k=parseInt(a.timestamp,10)};this.isEdit=!1;this.group=void 0;this.execute=function(a){if(!a.getMember(f))return!1;a.removeMember(f);a.emit(ops.Document.signalMemberRemoved,f);return!0};this.spec=function(){return{optype:"RemoveMember",memberid:f,timestamp:k}}};ops.OpRemoveStyle=function(){var f,k,a,e;this.init=function(c){f=c.memberid;k=c.timestamp;a=c.styleName;e=c.styleFamily};this.isEdit=!0;this.group=void 0;this.execute=function(c){var f=c.getFormatting().getStyleElement(a,e);if(!f)return!1;f.parentNode.removeChild(f);c.getOdfCanvas().refreshCSS();c.emit(ops.OdtDocument.signalCommonStyleDeleted,{name:a,family:e});return!0};this.spec=function(){return{optype:"RemoveStyle",memberid:f,timestamp:k,styleName:a,styleFamily:e}}};ops.OpRemoveText=function(){var f,k,a,e,c=odf.OdfUtils,m=core.DomUtils;this.init=function(c){runtime.assert(0<=c.length,"OpRemoveText only supports positive lengths");f=c.memberid;k=c.timestamp;a=parseInt(c.position,10);e=parseInt(c.length,10)};this.isEdit=!0;this.group=void 0;this.execute=function(n){var p,q,g,h=n.getCursor(f),d=new odf.CollapsingRules(n.getRootNode());n.upgradeWhitespacesAtPosition(a);n.upgradeWhitespacesAtPosition(a+e);p=n.convertCursorToDomRange(a,e);m.splitBoundaries(p);q=c.getTextElements(p,
!1,!0);g=c.getParagraphElement(p.startContainer,p.startOffset);runtime.assert(void 0!==g,"Attempting to remove text outside a paragraph element");p.detach();q.forEach(function(b){b.parentNode?(runtime.assert(m.containsNode(g,b),"RemoveText only supports removing elements within the same paragraph"),d.mergeChildrenIntoParent(b)):runtime.log("WARN: text element has already been removed from it's container")});n.emit(ops.OdtDocument.signalStepsRemoved,{position:a});n.downgradeWhitespacesAtPosition(a);
n.fixCursorPositions();n.getOdfCanvas().refreshSize();n.emit(ops.OdtDocument.signalParagraphChanged,{paragraphElement:g,memberId:f,timeStamp:k});h&&(h.resetSelectionType(),n.emit(ops.Document.signalCursorMoved,h));n.getOdfCanvas().rerenderAnnotations();return!0};this.spec=function(){return{optype:"RemoveText",memberid:f,timestamp:k,position:a,length:e}}};ops.OpSetBlob=function(){var f,k,a,e,c;this.init=function(m){f=m.memberid;k=m.timestamp;a=m.filename;e=m.mimetype;c=m.content};this.isEdit=!0;this.group=void 0;this.execute=function(f){f.getOdfCanvas().odfContainer().setBlob(a,e,c);return!0};this.spec=function(){return{optype:"SetBlob",memberid:f,timestamp:k,filename:a,mimetype:e,content:c}}};ops.OpSetParagraphStyle=function(){function f(a,c,e){var g=[a.getPositionFilter()],f=e.container();e=e.unfilteredDomOffset();return!1===a.createStepIterator(f,e,g,c).previousStep()}var k,a,e,c,m=odf.OdfUtils;this.init=function(f){k=f.memberid;a=f.timestamp;e=f.position;c=f.styleName};this.isEdit=!0;this.group=void 0;this.execute=function(n){var p,q;p=n.getIteratorAtPosition(e);return(q=m.getParagraphElement(p.container()))?(runtime.assert(f(n,q,p),"SetParagraphStyle position should be the first position in the paragraph"),
c?q.setAttributeNS("urn:oasis:names:tc:opendocument:xmlns:text:1.0","text:style-name",c):q.removeAttributeNS("urn:oasis:names:tc:opendocument:xmlns:text:1.0","style-name"),n.getOdfCanvas().refreshSize(),n.emit(ops.OdtDocument.signalParagraphChanged,{paragraphElement:q,timeStamp:a,memberId:k}),n.getOdfCanvas().rerenderAnnotations(),!0):!1};this.spec=function(){return{optype:"SetParagraphStyle",memberid:k,timestamp:a,position:e,styleName:c}}};ops.OpSplitParagraph=function(){var f,k,a,e,c,m,n=odf.OdfUtils,p=odf.Namespaces.textns;this.init=function(n){f=n.memberid;k=n.timestamp;e=n.position;a=n.sourceParagraphPosition;m=n.paragraphStyleName;c="true"===n.moveCursor||!0===n.moveCursor};this.isEdit=!0;this.group=void 0;this.execute=function(a){var g,h,d,b,r,l,y,t=a.getCursor(f);a.upgradeWhitespacesAtPosition(e);g=a.getTextNodeAtStep(e);if(!g)return!1;h=n.getParagraphElement(g.textNode);if(!h)return!1;d=n.isListItem(h.parentNode)?h.parentNode:
h;0===g.offset?(y=g.textNode.previousSibling,l=null):(y=g.textNode,l=g.offset>=g.textNode.length?null:g.textNode.splitText(g.offset));for(b=g.textNode;b!==d;){b=b.parentNode;r=b.cloneNode(!1);l&&r.appendChild(l);if(y)for(;y&&y.nextSibling;)r.appendChild(y.nextSibling);else for(;b.firstChild;)r.appendChild(b.firstChild);b.parentNode.insertBefore(r,b.nextSibling);y=b;l=r}n.isListItem(l)&&(l=l.childNodes.item(0));m?l.setAttributeNS(p,"text:style-name",m):l.removeAttributeNS(p,"style-name");0===g.textNode.length&&
g.textNode.parentNode.removeChild(g.textNode);a.emit(ops.OdtDocument.signalStepsInserted,{position:e});t&&c&&(a.moveCursor(f,e+1,0),a.emit(ops.Document.signalCursorMoved,t));a.fixCursorPositions();a.getOdfCanvas().refreshSize();a.emit(ops.OdtDocument.signalParagraphChanged,{paragraphElement:h,memberId:f,timeStamp:k});a.emit(ops.OdtDocument.signalParagraphChanged,{paragraphElement:l,memberId:f,timeStamp:k});a.getOdfCanvas().rerenderAnnotations();return!0};this.spec=function(){return{optype:"SplitParagraph",
memberid:f,timestamp:k,position:e,sourceParagraphPosition:a,paragraphStyleName:m,moveCursor:c}}};ops.OpUpdateMember=function(){function f(a){var c="//dc:creator[@editinfo:memberid='"+k+"']";a=xmldom.XPath.getODFElementsWithXPath(a.getRootNode(),c,function(a){return"editinfo"===a?"urn:webodf:names:editinfo":odf.Namespaces.lookupNamespaceURI(a)});for(c=0;c<a.length;c+=1)a[c].textContent=e.fullName}var k,a,e,c;this.init=function(f){k=f.memberid;a=parseInt(f.timestamp,10);e=f.setProperties;c=f.removedProperties};this.isEdit=!1;this.group=void 0;this.execute=function(a){var n=a.getMember(k);if(!n)return!1;
c&&n.removeProperties(c);e&&(n.setProperties(e),e.fullName&&f(a));a.emit(ops.Document.signalMemberUpdated,n);return!0};this.spec=function(){return{optype:"UpdateMember",memberid:k,timestamp:a,setProperties:e,removedProperties:c}}};ops.OpUpdateMetadata=function(){var f,k,a,e;this.init=function(c){f=c.memberid;k=parseInt(c.timestamp,10);a=c.setProperties;e=c.removedProperties};this.isEdit=!0;this.group=void 0;this.execute=function(c){var f=c.getOdfCanvas().odfContainer(),n=null;e&&(n=e.attributes.split(","));f.setMetadata(a,n);c.emit(ops.OdtDocument.signalMetadataUpdated,{setProperties:null!==a?a:{},removedProperties:null!==n?n:[]});return!0};this.spec=function(){return{optype:"UpdateMetadata",memberid:f,timestamp:k,setProperties:a,
removedProperties:e}}};ops.OpUpdateParagraphStyle=function(){function f(a,c){var e,f,d=c?c.split(","):[];for(e=0;e<d.length;e+=1)f=d[e].split(":"),a.removeAttributeNS(odf.Namespaces.lookupNamespaceURI(f[0]),f[1])}var k,a,e,c,m,n=odf.Namespaces.stylens;this.init=function(f){k=f.memberid;a=f.timestamp;e=f.styleName;c=f.setProperties;m=f.removedProperties};this.isEdit=!0;this.group=void 0;this.execute=function(a){var k=a.getFormatting(),g,h,d;return(g=""!==e?k.getStyleElement(e,"paragraph"):k.getDefaultStyleElement("paragraph"))?
(h=g.getElementsByTagNameNS(n,"paragraph-properties").item(0),d=g.getElementsByTagNameNS(n,"text-properties").item(0),c&&k.updateStyle(g,c),m&&(k=m["style:paragraph-properties"],h&&k&&(f(h,k.attributes),0===h.attributes.length&&g.removeChild(h)),k=m["style:text-properties"],d&&k&&(f(d,k.attributes),0===d.attributes.length&&g.removeChild(d)),f(g,m.attributes)),a.getOdfCanvas().refreshCSS(),a.emit(ops.OdtDocument.signalParagraphStyleModified,e),a.getOdfCanvas().rerenderAnnotations(),!0):!1};this.spec=
function(){return{optype:"UpdateParagraphStyle",memberid:k,timestamp:a,styleName:e,setProperties:c,removedProperties:m}}};ops.OperationFactory=function(){function f(a){return function(e){return new a}}var k;this.register=function(a,e){k[a]=e};this.create=function(a){var e=null,c=k[a.optype];c&&(e=c(a),e.init(a));return e};k={AddMember:f(ops.OpAddMember),UpdateMember:f(ops.OpUpdateMember),RemoveMember:f(ops.OpRemoveMember),AddCursor:f(ops.OpAddCursor),ApplyDirectStyling:f(ops.OpApplyDirectStyling),SetBlob:f(ops.OpSetBlob),RemoveBlob:f(ops.OpRemoveBlob),InsertImage:f(ops.OpInsertImage),InsertTable:f(ops.OpInsertTable),
InsertText:f(ops.OpInsertText),RemoveText:f(ops.OpRemoveText),MergeParagraph:f(ops.OpMergeParagraph),SplitParagraph:f(ops.OpSplitParagraph),SetParagraphStyle:f(ops.OpSetParagraphStyle),UpdateParagraphStyle:f(ops.OpUpdateParagraphStyle),AddStyle:f(ops.OpAddStyle),RemoveStyle:f(ops.OpRemoveStyle),MoveCursor:f(ops.OpMoveCursor),RemoveCursor:f(ops.OpRemoveCursor),AddAnnotation:f(ops.OpAddAnnotation),RemoveAnnotation:f(ops.OpRemoveAnnotation),UpdateMetadata:f(ops.OpUpdateMetadata),ApplyHyperlink:f(ops.OpApplyHyperlink),
RemoveHyperlink:f(ops.OpRemoveHyperlink)}};ops.OperationRouter=function(){};ops.OperationRouter.prototype.setOperationFactory=function(f){};ops.OperationRouter.prototype.setPlaybackFunction=function(f){};ops.OperationRouter.prototype.push=function(f){};ops.OperationRouter.prototype.close=function(f){};ops.OperationRouter.prototype.subscribe=function(f,k){};ops.OperationRouter.prototype.unsubscribe=function(f,k){};ops.OperationRouter.prototype.hasLocalUnsyncedOps=function(){};ops.OperationRouter.prototype.hasSessionHostConnection=function(){};
ops.OperationRouter.signalProcessingBatchStart="router/batchstart";ops.OperationRouter.signalProcessingBatchEnd="router/batchend";ops.TrivialOperationRouter=function(){var f=new core.EventNotifier([ops.OperationRouter.signalProcessingBatchStart,ops.OperationRouter.signalProcessingBatchEnd]),k,a,e=0;this.setOperationFactory=function(a){k=a};this.setPlaybackFunction=function(c){a=c};this.push=function(c){e+=1;f.emit(ops.OperationRouter.signalProcessingBatchStart,{});c.forEach(function(c){c=c.spec();c.timestamp=Date.now();c=k.create(c);c.group="g"+e;a(c)});f.emit(ops.OperationRouter.signalProcessingBatchEnd,{})};this.close=function(a){a()};
this.subscribe=function(a,e){f.subscribe(a,e)};this.unsubscribe=function(a,e){f.unsubscribe(a,e)};this.hasLocalUnsyncedOps=function(){return!1};this.hasSessionHostConnection=function(){return!0}};ops.Session=function(f){function k(a){c.emit(ops.OdtDocument.signalProcessingBatchStart,a)}function a(a){c.emit(ops.OdtDocument.signalProcessingBatchEnd,a)}var e=new ops.OperationFactory,c=new ops.OdtDocument(f),m=null;this.setOperationFactory=function(a){e=a;m&&m.setOperationFactory(e)};this.setOperationRouter=function(f){m&&(m.unsubscribe(ops.OperationRouter.signalProcessingBatchStart,k),m.unsubscribe(ops.OperationRouter.signalProcessingBatchEnd,a));m=f;m.subscribe(ops.OperationRouter.signalProcessingBatchStart,
k);m.subscribe(ops.OperationRouter.signalProcessingBatchEnd,a);f.setPlaybackFunction(function(a){c.emit(ops.OdtDocument.signalOperationStart,a);return a.execute(c)?(c.emit(ops.OdtDocument.signalOperationEnd,a),!0):!1});f.setOperationFactory(e)};this.getOperationFactory=function(){return e};this.getOdtDocument=function(){return c};this.enqueue=function(a){m.push(a)};this.close=function(a){m.close(function(e){e?a(e):c.close(a)})};this.destroy=function(a){c.destroy(a)};this.setOperationRouter(new ops.TrivialOperationRouter)};gui.AnnotationController=function(f,k,a){function e(){var b=p.getCursor(a),b=b&&b.getNode(),d=!1;b&&(d=!h.isWithinAnnotation(b,p.getRootNode()));d!==q&&(q=d,g.emit(gui.AnnotationController.annotatableChanged,q))}function c(b){b.getMemberId()===a&&e()}function m(b){b===a&&e()}function n(b){b.getMemberId()===a&&e()}var p=f.getOdtDocument(),q=!1,g=new core.EventNotifier([gui.AnnotationController.annotatableChanged]),h=odf.OdfUtils,d=core.StepDirection.NEXT;this.isAnnotatable=function(){return q};this.addAnnotation=
function(){var b=new ops.OpAddAnnotation,d=p.getCursorSelection(a),c=d.length,d=d.position;q&&(0===c?c=void 0:(d=0<=c?d:d+c,c=Math.abs(c)),b.init({memberid:a,position:d,length:c,name:a+Date.now()}),f.enqueue([b]))};this.removeAnnotation=function(b){var c,e;c=p.getMember(a).getProperties().fullName;if(!0!==k.getState(gui.CommonConstraints.EDIT.ANNOTATIONS.ONLY_DELETE_OWN)||c===h.getAnnotationCreator(b))c=p.convertDomPointToCursorStep(b,0,d),e=p.convertDomPointToCursorStep(b,b.childNodes.length),b=
new ops.OpRemoveAnnotation,b.init({memberid:a,position:c,length:e-c}),e=new ops.OpMoveCursor,e.init({memberid:a,position:0<c?c-1:c,length:0}),f.enqueue([b,e])};this.subscribe=function(b,a){g.subscribe(b,a)};this.unsubscribe=function(b,a){g.unsubscribe(b,a)};this.destroy=function(b){p.unsubscribe(ops.Document.signalCursorAdded,c);p.unsubscribe(ops.Document.signalCursorRemoved,m);p.unsubscribe(ops.Document.signalCursorMoved,n);b()};k.registerConstraint(gui.CommonConstraints.EDIT.ANNOTATIONS.ONLY_DELETE_OWN);
p.subscribe(ops.Document.signalCursorAdded,c);p.subscribe(ops.Document.signalCursorRemoved,m);p.subscribe(ops.Document.signalCursorMoved,n);e()};gui.AnnotationController.annotatableChanged="annotatable/changed";gui.Avatar=function(f,k){var a=this,e,c,m;this.setColor=function(a){c.style.borderColor=a};this.setImageUrl=function(e){a.isVisible()?c.src=e:m=e};this.isVisible=function(){return"block"===e.style.display};this.show=function(){m&&(c.src=m,m=void 0);e.style.display="block"};this.hide=function(){e.style.display="none"};this.markAsFocussed=function(a){a?e.classList.add("active"):e.classList.remove("active")};this.destroy=function(a){f.removeChild(e);a()};(function(){var a=f.ownerDocument;e=a.createElement("div");
c=a.createElement("img");e.appendChild(c);e.style.display=k?"block":"none";e.className="handle";f.appendChild(e)})()};gui.StepInfo=function(){};gui.StepInfo.VisualDirection={LEFT_TO_RIGHT:0,RIGHT_TO_LEFT:1};gui.StepInfo.prototype.container=function(){};gui.StepInfo.prototype.offset=function(){};gui.VisualStepScanner=function(){};gui.VisualStepScanner.prototype.process=function(f,k,a){};gui.GuiStepUtils=function(){function f(c){c=a.getContentBounds(c);var f,g=null;if(c)if(c.container.nodeType===Node.TEXT_NODE)f=c.container.ownerDocument.createRange(),f.setStart(c.container,c.startOffset),f.setEnd(c.container,c.endOffset),(g=0<f.getClientRects().length?f.getBoundingClientRect():null)&&" "===c.container.data.substring(c.startOffset,c.endOffset)&&1>=g.width&&(g=null),f.detach();else if(k.isCharacterElement(c.container)||k.isCharacterFrame(c.container))g=e.getBoundingClientRect(c.container);
return g}var k=odf.OdfUtils,a=new odf.StepUtils,e=core.DomUtils,c=core.StepDirection.NEXT,m=gui.StepInfo.VisualDirection.LEFT_TO_RIGHT,n=gui.StepInfo.VisualDirection.RIGHT_TO_LEFT;this.getContentRect=f;this.moveToFilteredStep=function(a,e,g){function h(b,a){a.process(w,l,y)&&(b=!0,!t&&a.token&&(t=a.token));return b}var d=e===c,b,k,l,y,t,z=a.snapshot();b=!1;var w;do b=f(a),w={token:a.snapshot(),container:a.container,offset:a.offset,direction:e,visualDirection:e===c?m:n},k=a.nextStep()?f(a):null,a.restore(w.token),
d?(l=b,y=k):(l=k,y=b),b=g.reduce(h,!1);while(!b&&a.advanceStep(e));b||g.forEach(function(b){!t&&b.token&&(t=b.token)});a.restore(t||z);return Boolean(t)}};gui.Caret=function(f,k,a,e){function c(){h.style.opacity="0"===h.style.opacity?"1":"0";x.trigger()}function m(){l.selectNodeContents(r);return l.getBoundingClientRect()}function n(){Object.keys(D).forEach(function(b){G[b]=D[b]})}function p(){if(!1===D.isShown||f.getSelectionType()!==ops.OdtCursor.RangeSelection||!e&&!f.getSelectedRange().collapsed)D.visibility="hidden",h.style.visibility="hidden",x.cancel();else if(D.visibility="visible",h.style.visibility="visible",!1===D.isFocused)h.style.opacity=
"1",x.cancel();else{if(u||G.visibility!==D.visibility)h.style.opacity="1",x.cancel();x.trigger()}if(H||C){var a;a=f.getNode();var c,l,r=t.getBoundingClientRect(y.getSizer()),p=!1,q=0;a.removeAttributeNS("urn:webodf:names:cursor","caret-sizer-active");if(0<a.getClientRects().length)l=m(),q=l.left-t.getBoundingClientRect(a).left,p=!0;else if(w.setPosition(a,0),l=z.getContentRect(w),!l&&w.nextStep()&&(c=z.getContentRect(w))&&(l=c,p=!0),l||(a.setAttributeNS("urn:webodf:names:cursor","caret-sizer-active",
"true"),l=m(),p=!0),!l)for(runtime.log("WARN: No suitable client rectangle found for visual caret for "+f.getMemberId());a;){if(0<a.getClientRects().length){l=t.getBoundingClientRect(a);p=!0;break}a=a.parentNode}l=t.translateRect(l,r,y.getZoomLevel());a={top:l.top,height:l.height,right:p?l.left:l.right,width:t.adaptRangeDifferenceToZoomLevel(q,y.getZoomLevel())};8>a.height&&(a={top:a.top-(8-a.height)/2,height:8,right:a.right});g.style.height=a.height+"px";g.style.top=a.top+"px";g.style.left=a.right-
a.width+"px";g.style.width=a.width?a.width+"px":"";b&&(a=runtime.getWindow().getComputedStyle(f.getNode(),null),a.font?b.style.font=a.font:(b.style.fontStyle=a.fontStyle,b.style.fontVariant=a.fontVariant,b.style.fontWeight=a.fontWeight,b.style.fontSize=a.fontSize,b.style.lineHeight=a.lineHeight,b.style.fontFamily=a.fontFamily))}!G.isScrolled&&D.isShown&&C&&k.scrollIntoView(h.getBoundingClientRect());G.isFocused!==D.isFocused&&d.markAsFocussed(D.isFocused);n();H=C=u=!1}function q(b){g.parentNode.removeChild(g);r.parentNode.removeChild(r);
b()}var g,h,d,b,r,l,y=f.getDocument().getCanvas(),t=core.DomUtils,z=new gui.GuiStepUtils,w,s,x,u=!1,C=!1,H=!1,D={isFocused:!1,isShown:!0,visibility:"hidden"},G={isFocused:!D.isFocused,isShown:!D.isShown,visibility:"hidden"};jQuery('.webodfeditor-canvascontainer').off().on('keyup scroll', function(e){if(e.which){G.isScrolled = false;return;}G.isScrolled = true;});this.handleUpdate=function(){H=!0;s.trigger()};this.refreshCursorBlinking=function(){u=!0;s.trigger()};this.setFocus=function(){D.isFocused=!0;s.trigger()};this.removeFocus=function(){D.isFocused=!1;s.trigger()};this.show=function(){D.isShown=!0;s.trigger()};this.hide=function(){D.isShown=
!1;s.trigger()};this.setAvatarImageUrl=function(b){d.setImageUrl(b)};this.setColor=function(b){h.style.borderColor=b;d.setColor(b)};this.getCursor=function(){return f};this.getFocusElement=function(){return h};this.toggleHandleVisibility=function(){d.isVisible()?d.hide():d.show()};this.showHandle=function(){d.show()};this.hideHandle=function(){d.hide()};this.setOverlayElement=function(a){b=a;g.appendChild(a);H=!0;s.trigger()};this.ensureVisible=function(){C=!0;s.trigger()};this.getBoundingClientRect=
function(){return t.getBoundingClientRect(g)};this.destroy=function(b){core.Async.destroyAll([s.destroy,x.destroy,d.destroy,q],b)};(function(){var b=f.getDocument(),e=[b.createRootFilter(f.getMemberId()),b.getPositionFilter()],m=b.getDOMDocument();l=m.createRange();r=m.createElement("span");r.className="webodf-caretSizer";r.textContent="|";f.getNode().appendChild(r);g=m.createElement("div");g.setAttributeNS("urn:webodf:names:editinfo","editinfo:memberid",f.getMemberId());g.className="webodf-caretOverlay";
h=m.createElement("div");h.className="caret";g.appendChild(h);d=new gui.Avatar(g,a);y.getSizer().appendChild(g);w=b.createStepIterator(f.getNode(),0,e,b.getRootNode());s=core.Task.createRedrawTask(p);x=core.Task.createTimeoutTask(c,500);s.triggerImmediate()})()};odf.TextSerializer=function(){function f(e){var c="",m=k.filter?k.filter.acceptNode(e):NodeFilter.FILTER_ACCEPT,n=e.nodeType,p;if((m===NodeFilter.FILTER_ACCEPT||m===NodeFilter.FILTER_SKIP)&&a.isTextContentContainingNode(e))for(p=e.firstChild;p;)c+=f(p),p=p.nextSibling;m===NodeFilter.FILTER_ACCEPT&&(n===Node.ELEMENT_NODE&&a.isParagraph(e)?c+="\n":n===Node.TEXT_NODE&&e.textContent&&(c+=e.textContent));return c}var k=this,a=odf.OdfUtils;this.filter=null;this.writeToString=function(a){if(!a)return"";
a=f(a);"\n"===a[a.length-1]&&(a=a.substr(0,a.length-1));return a}};gui.MimeDataExporter=function(){var f;this.exportRangeToDataTransfer=function(k,a){var e;e=a.startContainer.ownerDocument.createElement("span");e.appendChild(a.cloneContents());e=f.writeToString(e);try{k.setData("text/plain",e)}catch(c){k.setData("Text",e)}};f=new odf.TextSerializer;f.filter=new odf.OdfNodeFilter};gui.Clipboard=function(f){this.setDataFromRange=function(k,a){var e,c=k.clipboardData;e=runtime.getWindow();!c&&e&&(c=e.clipboardData);c?(e=!0,f.exportRangeToDataTransfer(c,a),k.preventDefault()):e=!1;return e}};gui.SessionContext=function(f,k){var a=f.getOdtDocument(),e=odf.OdfUtils;this.isLocalCursorWithinOwnAnnotation=function(){var c=a.getCursor(k),f;if(!c)return!1;f=c&&c.getNode();c=a.getMember(k).getProperties().fullName;return(f=e.getParentAnnotation(f,a.getRootNode()))&&e.getAnnotationCreator(f)===c?!0:!1}};gui.StyleSummary=function(f){function k(a,e){var k=a+"|"+e,q;c.hasOwnProperty(k)||(q=[],f.forEach(function(c){c=(c=c.styleProperties[a])&&c[e];-1===q.indexOf(c)&&q.push(c)}),c[k]=q);return c[k]}function a(a,c,e){return function(){var f=k(a,c);return e.length>=f.length&&f.every(function(a){return-1!==e.indexOf(a)})}}function e(a,c){var e=k(a,c);return 1===e.length?e[0]:void 0}var c={};this.getPropertyValues=k;this.getCommonValue=e;this.isBold=a("style:text-properties","fo:font-weight",["bold"]);this.isItalic=
a("style:text-properties","fo:font-style",["italic"]);this.hasUnderline=a("style:text-properties","style:text-underline-style",["solid"]);this.hasStrikeThrough=a("style:text-properties","style:text-line-through-style",["solid"]);this.fontSize=function(){var a=e("style:text-properties","fo:font-size");return a&&parseFloat(a)};this.fontName=function(){return e("style:text-properties","style:font-name")};this.isAlignedLeft=a("style:paragraph-properties","fo:text-align",["left","start"]);this.isAlignedCenter=
a("style:paragraph-properties","fo:text-align",["center"]);this.isAlignedRight=a("style:paragraph-properties","fo:text-align",["right","end"]);this.isAlignedJustified=a("style:paragraph-properties","fo:text-align",["justify"]);this.text={isBold:this.isBold,isItalic:this.isItalic,hasUnderline:this.hasUnderline,hasStrikeThrough:this.hasStrikeThrough,fontSize:this.fontSize,fontName:this.fontName};this.paragraph={isAlignedLeft:this.isAlignedLeft,isAlignedCenter:this.isAlignedCenter,isAlignedRight:this.isAlignedRight,
isAlignedJustified:this.isAlignedJustified}};gui.DirectFormattingController=function(f,k,a,e,c,m,n){function p(){return V.value().styleSummary}function q(){return V.value().enabledFeatures}function g(b){var a;b.collapsed?(a=b.startContainer,a.hasChildNodes()&&b.startOffset<a.childNodes.length&&(a=a.childNodes.item(b.startOffset)),b=[a]):b=ba.getTextElements(b,!0,!1);return b}function h(){var b=v.getCursor(e),d=b&&b.getSelectedRange(),c=[],c=[],f=!0,l={directTextStyling:!0,directParagraphStyling:!0};d&&(c=g(d),0===c.length&&(c=[d.startContainer,
d.endContainer],f=!1),c=v.getFormatting().getAppliedStyles(c));void 0!==c[0]&&Z&&(c[0].styleProperties=I.mergeObjects(c[0].styleProperties,Z));!0===k.getState(gui.CommonConstraints.EDIT.REVIEW_MODE)&&(l.directTextStyling=l.directParagraphStyling=a.isLocalCursorWithinOwnAnnotation());l.directTextStyling&&(l.directTextStyling=f&&void 0!==b&&b.getSelectionType()===ops.OdtCursor.RangeSelection);return{enabledFeatures:l,appliedStyles:c,styleSummary:new gui.StyleSummary(c)}}function d(b,a){var d={};Object.keys(b).forEach(function(c){var e=
b[c](),f=a[c]();e!==f&&(d[c]=f)});return d}function b(){var b,a;a=E.styleSummary;var c=V.value(),e=c.styleSummary,f=E.enabledFeatures,g=c.enabledFeatures;b=d(a.text,e.text);a=d(a.paragraph,e.paragraph);f=!(g.directTextStyling===f.directTextStyling&&g.directParagraphStyling===f.directParagraphStyling);E=c;f&&T.emit(gui.DirectFormattingController.enabledChanged,g);0<Object.keys(b).length&&T.emit(gui.DirectFormattingController.textStylingChanged,b);0<Object.keys(a).length&&T.emit(gui.DirectFormattingController.paragraphStylingChanged,
a)}function r(){V.reset();b()}function l(b){("string"===typeof b?b:b.getMemberId())===e&&V.reset()}function y(){V.reset()}function t(b){var a=v.getCursor(e);b=b.paragraphElement;a&&ba.getParagraphElement(a.getNode())===b&&V.reset()}function z(b,a){a(!b());return!0}function w(b){if(q().directTextStyling){var a=v.getCursorSelection(e),d={"style:text-properties":b};0!==a.length?(b=new ops.OpApplyDirectStyling,b.init({memberid:e,position:a.position,length:a.length,setProperties:d}),f.enqueue([b])):(Z=
I.mergeObjects(Z||{},d),V.reset())}}function s(b,a){var d={};d[b]=a;w(d)}function x(b){b=b.spec();Z&&b.memberid===e&&"SplitParagraph"!==b.optype&&(Z=null,V.reset())}function u(b){s("fo:font-weight",b?"bold":"normal")}function C(b){s("fo:font-style",b?"italic":"normal")}function H(b){s("style:text-underline-style",b?"solid":"none")}function D(b){s("style:text-line-through-style",b?"solid":"none")}function G(b){if(q().directParagraphStyling){var a=v.getCursor(e).getSelectedRange(),a=ba.getParagraphElements(a),
d=v.getFormatting(),g=[],l={},h;a.forEach(function(a){var f=v.convertDomPointToCursorStep(a,0,N),m=a.getAttributeNS(odf.Namespaces.textns,"style-name"),k;a=m?l.hasOwnProperty(m)?l[m]:void 0:h;a||(a=c.generateStyleName(),m?(l[m]=a,k=d.createDerivedStyleObject(m,"paragraph",{})):(h=a,k={}),k=b(k),m=new ops.OpAddStyle,m.init({memberid:e,styleName:a.toString(),styleFamily:"paragraph",isAutomaticStyle:!0,setProperties:k}),g.push(m));m=new ops.OpSetParagraphStyle;m.init({memberid:e,styleName:a.toString(),
position:f});g.push(m)});f.enqueue(g)}}function B(b){G(function(a){return I.mergeObjects(a,b)})}function J(b){B({"style:paragraph-properties":{"fo:text-align":b}})}function P(b,a){var d=v.getFormatting().getDefaultTabStopDistance(),c=a["style:paragraph-properties"],e;c&&(c=c["fo:margin-left"],e=ba.parseLength(c));return I.mergeObjects(a,{"style:paragraph-properties":{"fo:margin-left":e&&e.unit===d.unit?e.value+b*d.value+e.unit:b*d.value+d.unit}})}function Q(b,a){var d=g(b),d=0===d.length?[b.startContainer]:
d,d=v.getFormatting().getAppliedStyles(d),c=0<d.length?d[0].styleProperties:void 0,e=v.getFormatting().getAppliedStylesForElement(a).styleProperties;if(!c||"text"!==c["style:family"]||!c["style:text-properties"])return!1;if(!e||!e["style:text-properties"])return!0;c=c["style:text-properties"];e=e["style:text-properties"];return!Object.keys(c).every(function(b){return c[b]===e[b]})}function A(){}function Y(){return!1}var S=this,v=f.getOdtDocument(),I=new core.Utils,ba=odf.OdfUtils,T=new core.EventNotifier([gui.DirectFormattingController.enabledChanged,
gui.DirectFormattingController.textStylingChanged,gui.DirectFormattingController.paragraphStylingChanged]),F=odf.Namespaces.textns,N=core.StepDirection.NEXT,Z=null,E,V;this.enabledFeatures=q;this.formatTextSelection=w;this.createCursorStyleOp=function(b,a,d){var c=null,f=Z;d&&(f=(d=V.value().appliedStyles[0])&&d.styleProperties);f&&f["style:text-properties"]&&(c=new ops.OpApplyDirectStyling,c.init({memberid:e,position:b,length:a,setProperties:{"style:text-properties":f["style:text-properties"]}}),
Z=null,V.reset());return c};this.setBold=u;this.setItalic=C;this.setHasUnderline=H;this.setHasStrikethrough=D;this.setFontSize=function(b){s("fo:font-size",b+"pt")};this.setFontName=function(b){s("style:font-name",b)};this.getAppliedStyles=function(){return V.value().appliedStyles};this.toggleBold=z.bind(S,function(){return p().isBold()},u);this.toggleItalic=z.bind(S,function(){return p().isItalic()},C);this.toggleUnderline=z.bind(S,function(){return p().hasUnderline()},H);this.toggleStrikethrough=
z.bind(S,function(){return p().hasStrikeThrough()},D);this.isBold=function(){return p().isBold()};this.isItalic=function(){return p().isItalic()};this.hasUnderline=function(){return p().hasUnderline()};this.hasStrikeThrough=function(){return p().hasStrikeThrough()};this.fontSize=function(){return p().fontSize()};this.fontName=function(){return p().fontName()};this.isAlignedLeft=function(){return p().isAlignedLeft()};this.isAlignedCenter=function(){return p().isAlignedCenter()};this.isAlignedRight=
function(){return p().isAlignedRight()};this.isAlignedJustified=function(){return p().isAlignedJustified()};this.alignParagraphLeft=function(){J("left");return!0};this.alignParagraphCenter=function(){J("center");return!0};this.alignParagraphRight=function(){J("right");return!0};this.alignParagraphJustified=function(){J("justify");return!0};this.indent=function(){G(P.bind(null,1));return!0};this.outdent=function(){G(P.bind(null,-1));return!0};this.createParagraphStyleOps=function(b){if(!q().directParagraphStyling)return[];
var a=v.getCursor(e),d=a.getSelectedRange(),f=[],g,l;a.hasForwardSelection()?(g=a.getAnchorNode(),l=a.getNode()):(g=a.getNode(),l=a.getAnchorNode());a=ba.getParagraphElement(l);runtime.assert(Boolean(a),"DirectFormattingController: Cursor outside paragraph");var h=a,m=[v.getPositionFilter(),v.createRootFilter(e)];if(!1!==v.createStepIterator(d.endContainer,d.endOffset,m,h).nextStep())return f;l!==g&&(a=ba.getParagraphElement(g));if(!Z&&!Q(d,a))return f;d=(d=V.value().appliedStyles[0])&&d.styleProperties;
if(!d)return f;if(a=a.getAttributeNS(F,"style-name"))d={"style:text-properties":d["style:text-properties"]},d=v.getFormatting().createDerivedStyleObject(a,"paragraph",d);g=c.generateStyleName();a=new ops.OpAddStyle;a.init({memberid:e,styleName:g,styleFamily:"paragraph",isAutomaticStyle:!0,setProperties:d});f.push(a);a=new ops.OpSetParagraphStyle;a.init({memberid:e,styleName:g,position:b});f.push(a);return f};this.subscribe=function(b,a){T.subscribe(b,a)};this.unsubscribe=function(b,a){T.unsubscribe(b,
a)};this.destroy=function(a){v.unsubscribe(ops.Document.signalCursorAdded,l);v.unsubscribe(ops.Document.signalCursorRemoved,l);v.unsubscribe(ops.Document.signalCursorMoved,l);v.unsubscribe(ops.OdtDocument.signalParagraphStyleModified,y);v.unsubscribe(ops.OdtDocument.signalParagraphChanged,t);v.unsubscribe(ops.OdtDocument.signalOperationEnd,x);v.unsubscribe(ops.OdtDocument.signalProcessingBatchEnd,b);k.unsubscribe(gui.CommonConstraints.EDIT.REVIEW_MODE,r);a()};(function(){v.subscribe(ops.Document.signalCursorAdded,
l);v.subscribe(ops.Document.signalCursorRemoved,l);v.subscribe(ops.Document.signalCursorMoved,l);v.subscribe(ops.OdtDocument.signalParagraphStyleModified,y);v.subscribe(ops.OdtDocument.signalParagraphChanged,t);v.subscribe(ops.OdtDocument.signalOperationEnd,x);v.subscribe(ops.OdtDocument.signalProcessingBatchEnd,b);k.subscribe(gui.CommonConstraints.EDIT.REVIEW_MODE,r);V=new core.LazyProperty(h);E=V.value();m||(S.formatTextSelection=A,S.setBold=A,S.setItalic=A,S.setHasUnderline=A,S.setHasStrikethrough=
A,S.setFontSize=A,S.setFontName=A,S.toggleBold=Y,S.toggleItalic=Y,S.toggleUnderline=Y,S.toggleStrikethrough=Y);n||(S.alignParagraphCenter=A,S.alignParagraphJustified=A,S.alignParagraphLeft=A,S.alignParagraphRight=A,S.createParagraphStyleOps=function(){return[]},S.indent=A,S.outdent=A)})()};gui.DirectFormattingController.enabledChanged="enabled/changed";gui.DirectFormattingController.textStylingChanged="textStyling/changed";gui.DirectFormattingController.paragraphStylingChanged="paragraphStyling/changed";
gui.DirectFormattingController.SelectionInfo=function(){};gui.KeyboardHandler=function(){function f(a,e){e||(e=k.None);switch(a){case gui.KeyboardHandler.KeyCode.LeftMeta:case gui.KeyboardHandler.KeyCode.RightMeta:case gui.KeyboardHandler.KeyCode.MetaInMozilla:e|=k.Meta;break;case gui.KeyboardHandler.KeyCode.Ctrl:e|=k.Ctrl;break;case gui.KeyboardHandler.KeyCode.Alt:e|=k.Alt;break;case gui.KeyboardHandler.KeyCode.Shift:e|=k.Shift}return a+":"+e}var k=gui.KeyboardHandler.Modifier,a=null,e={};this.setDefault=function(c){a=c};this.bind=function(a,m,k,p){a=f(a,
m);runtime.assert(p||!1===e.hasOwnProperty(a),"tried to overwrite the callback handler of key combo: "+a);e[a]=k};this.unbind=function(a,m){var k=f(a,m);delete e[k]};this.reset=function(){a=null;e={}};this.handleEvent=function(c){var m=c.keyCode,n=k.None;c.metaKey&&(n|=k.Meta);c.ctrlKey&&(n|=k.Ctrl);c.altKey&&(n|=k.Alt);c.shiftKey&&(n|=k.Shift);m=f(m,n);m=e[m];n=!1;m?n=m():null!==a&&(n=a(c));n&&(c.preventDefault?c.preventDefault():c.returnValue=!1)}};
gui.KeyboardHandler.Modifier={None:0,Meta:1,Ctrl:2,Alt:4,CtrlAlt:6,Shift:8,MetaShift:9,CtrlShift:10,AltShift:12};gui.KeyboardHandler.KeyCode={Backspace:8,Tab:9,Clear:12,Enter:13,Shift:16,Ctrl:17,Alt:18,End:35,Home:36,Left:37,Up:38,Right:39,Down:40,Delete:46,A:65,B:66,C:67,D:68,E:69,F:70,G:71,H:72,I:73,J:74,K:75,L:76,M:77,N:78,O:79,P:80,Q:81,R:82,S:83,T:84,U:85,V:86,W:87,X:88,Y:89,Z:90,LeftMeta:91,RightMeta:93,MetaInMozilla:224};gui.HyperlinkClickHandler=function(f,k,a){function e(){var b=f();runtime.assert(Boolean(b.classList),"Document container has no classList element");b.classList.remove("webodf-inactiveLinks")}function c(){var b=f();runtime.assert(Boolean(b.classList),"Document container has no classList element");b.classList.add("webodf-inactiveLinks")}function m(){d.removeEventListener("focus",c,!1);r.forEach(function(b){k.unbind(b.keyCode,b.modifier);a.unbind(b.keyCode,b.modifier)});r.length=0}function n(b){m();
if(b!==p.None){d.addEventListener("focus",c,!1);switch(b){case p.Ctrl:r.push({keyCode:q.Ctrl,modifier:p.None});break;case p.Meta:r.push({keyCode:q.LeftMeta,modifier:p.None}),r.push({keyCode:q.RightMeta,modifier:p.None}),r.push({keyCode:q.MetaInMozilla,modifier:p.None})}r.forEach(function(b){k.bind(b.keyCode,b.modifier,e);a.bind(b.keyCode,b.modifier,c)})}}var p=gui.KeyboardHandler.Modifier,q=gui.KeyboardHandler.KeyCode,g=xmldom.XPath,h=odf.OdfUtils,d=runtime.getWindow(),b=p.None,r=[];runtime.assert(null!==
d,"Expected to be run in an environment which has a global window, like a browser.");this.handleClick=function(a){var c=a.target||a.srcElement,e,m;a.ctrlKey?e=p.Ctrl:a.metaKey&&(e=p.Meta);if(b===p.None||b===e){a:{for(;null!==c;){if(h.isHyperlink(c))break a;if(h.isParagraph(c))break;c=c.parentNode}c=null}c&&(c=h.getHyperlinkTarget(c),""!==c&&("#"===c[0]?(c=c.substring(1),e=f(),m=g.getODFElementsWithXPath(e,"//text:bookmark-start[@text:name='"+c+"']",odf.Namespaces.lookupNamespaceURI),0===m.length&&
(m=g.getODFElementsWithXPath(e,"//text:bookmark[@text:name='"+c+"']",odf.Namespaces.lookupNamespaceURI)),0<m.length&&m[0].scrollIntoView(!0)):/^\s*(javascript|data):/.test(c)?runtime.log("WARN:","potentially malicious URL ignored"):d.open(c),a.preventDefault?a.preventDefault():a.returnValue=!1))}};this.setModifier=function(a){b!==a&&(runtime.assert(a===p.None||a===p.Ctrl||a===p.Meta,"Unsupported KeyboardHandler.Modifier value: "+a),b=a,b!==p.None?c():e(),n(b))};this.getModifier=function(){return b};
this.destroy=function(b){c();m();b()}};gui.EventManager=function(f){function k(b){function a(b,d,c){var e,f=!1;e="on"+d;b.attachEvent&&(b.attachEvent(e,c),f=!0);!f&&b.addEventListener&&(b.addEventListener(d,c,!1),f=!0);f&&!x[d]||!b.hasOwnProperty(e)||(b[e]=c)}function d(b,a,c){var e="on"+a;b.detachEvent&&b.detachEvent(e,c);b.removeEventListener&&b.removeEventListener(a,c,!1);b[e]===c&&(b[e]=null)}function c(a){if(-1===f.indexOf(a)){f.push(a);if(e.filters.every(function(b){return b(a)}))try{g.emit(b,a)}catch(d){runtime.log("Error occurred while processing "+
b+":\n"+d.message+"\n"+d.stack)}runtime.setTimeout(function(){f.splice(f.indexOf(a),1)},0)}}var e=this,f=[],g=new core.EventNotifier([b]);this.filters=[];this.subscribe=function(a){g.subscribe(b,a)};this.unsubscribe=function(a){g.unsubscribe(b,a)};this.destroy=function(){d(s,b,c);d(D,b,c);d(G,b,c)};u[b]&&a(s,b,c);a(D,b,c);a(G,b,c)}function a(b,a,d){function c(a){d(a,e,function(a){a.type=b;f.emit(b,a)})}var e={},f=new core.EventNotifier([b]);this.subscribe=function(a){f.subscribe(b,a)};this.unsubscribe=
function(a){f.unsubscribe(b,a)};this.destroy=function(){a.forEach(function(b){B.unsubscribe(b,c)})};(function(){a.forEach(function(b){B.subscribe(b,c)})})()}function e(b){runtime.clearTimeout(b);delete J[b]}function c(b,a){var d=runtime.setTimeout(function(){b();e(d)},a);J[d]=!0;return d}function m(b,a,d){var f=b.touches.length,g=b.touches[0],l=a.timer;"touchmove"===b.type||"touchend"===b.type?l&&e(l):"touchstart"===b.type&&(1!==f?runtime.clearTimeout(l):l=c(function(){d({clientX:g.clientX,clientY:g.clientY,
pageX:g.pageX,pageY:g.pageY,target:b.target||b.srcElement||null,detail:1})},400));a.timer=l}function n(b,a,d){var c=b.touches[0],e=b.target||b.srcElement||null,f=a.target;1!==b.touches.length||"touchend"===b.type?f=null:"touchstart"===b.type&&"webodf-draggable"===e.getAttribute("class")?f=e:"touchmove"===b.type&&f&&(b.preventDefault(),b.stopPropagation(),d({clientX:c.clientX,clientY:c.clientY,pageX:c.pageX,pageY:c.pageY,target:f,detail:1}));a.target=f}function p(b,a,d){var c=b.target||b.srcElement||
null,e=a.dragging;"drag"===b.type?e=!0:"touchend"===b.type&&e&&(e=!1,b=b.changedTouches[0],d({clientX:b.clientX,clientY:b.clientY,pageX:b.pageX,pageY:b.pageY,target:c,detail:1}));a.dragging=e}function q(){G.classList.add("webodf-touchEnabled");B.unsubscribe("touchstart",q)}function g(b){var a=b.scrollX,d=b.scrollY;this.restore=function(){b.scrollX===a&&b.scrollY===d||b.scrollTo(a,d)}}function h(b){var a=b.scrollTop,d=b.scrollLeft;this.restore=function(){if(b.scrollTop!==a||b.scrollLeft!==d)b.scrollTop=
a,b.scrollLeft=d}}function d(b,a){var d=H[b]||C[b]||null;!d&&a&&(d=H[b]=new k(b));return d}function b(b,a){d(b,!0).subscribe(a)}function r(b,a){var c=d(b,!1);c&&c.unsubscribe(a)}function l(){return f.getDOMDocument().activeElement===D}function y(){l()&&D.blur();D.setAttribute("disabled","true")}function t(){D.removeAttribute("disabled")}function z(b){for(var a=[];b;)(b.scrollWidth>b.clientWidth||b.scrollHeight>b.clientHeight)&&a.push(new h(b)),b=b.parentNode;a.push(new g(s));return a}function w(){var b;
l()||(b=z(D),t(),D.focus(),b.forEach(function(b){b.restore()}))}var s=runtime.getWindow(),x={beforecut:!0,beforepaste:!0,longpress:!0,drag:!0,dragstop:!0},u={mousedown:!0,mouseup:!0,focus:!0},C={},H={},D,G=f.getCanvas().getElement(),B=this,J={};this.addFilter=function(b,a){d(b,!0).filters.push(a)};this.removeFilter=function(b,a){var c=d(b,!0),e=c.filters.indexOf(a);-1!==e&&c.filters.splice(e,1)};this.subscribe=b;this.unsubscribe=r;this.hasFocus=l;this.focus=w;this.getEventTrap=function(){return D};
this.setEditing=function(b){var a=l();a&&D.blur();b?D.removeAttribute("readOnly"):D.setAttribute("readOnly","true");a&&w()};this.destroy=function(b){r("touchstart",q);Object.keys(J).forEach(function(b){e(parseInt(b,10))});J.length=0;Object.keys(C).forEach(function(b){C[b].destroy()});C={};r("mousedown",y);r("mouseup",t);r("contextmenu",t);Object.keys(H).forEach(function(b){H[b].destroy()});H={};D.parentNode.removeChild(D);b()};(function(){var d=f.getOdfCanvas().getSizer(),c=d.ownerDocument;runtime.assert(Boolean(s),
"EventManager requires a window object to operate correctly");D=c.createElement("textarea");D.id="eventTrap";D.setAttribute("tabindex","-1");D.setAttribute("readOnly","true");D.setAttribute("rows","1");d.appendChild(D);b("mousedown",y);b("mouseup",t);b("contextmenu",t);C.longpress=new a("longpress",["touchstart","touchmove","touchend"],m);C.drag=new a("drag",["touchstart","touchmove","touchend"],n);C.dragstop=new a("dragstop",["drag","touchend"],p);b("touchstart",q)})()};gui.IOSSafariSupport=function(f){function k(){a.innerHeight!==a.outerHeight&&(e.style.display="none",runtime.requestAnimationFrame(function(){e.style.display="block"}))}var a=runtime.getWindow(),e=f.getEventTrap();this.destroy=function(a){f.unsubscribe("focus",k);e.removeAttribute("autocapitalize");e.style.WebkitTransform="";a()};f.subscribe("focus",k);e.setAttribute("autocapitalize","off");e.style.WebkitTransform="translateX(-10000px)"};gui.HyperlinkController=function(f,k,a,e){function c(){var c=!0;!0===k.getState(gui.CommonConstraints.EDIT.REVIEW_MODE)&&(c=a.isLocalCursorWithinOwnAnnotation());c!==g&&(g=c,q.emit(gui.HyperlinkController.enabledChanged,g))}function m(a){a.getMemberId()===e&&c()}var n=odf.OdfUtils,p=f.getOdtDocument(),q=new core.EventNotifier([gui.HyperlinkController.enabledChanged]),g=!1;this.isEnabled=function(){return g};this.subscribe=function(a,d){q.subscribe(a,d)};this.unsubscribe=function(a,d){q.unsubscribe(a,
d)};this.addHyperlink=function(a,d){if(g){var b=p.getCursorSelection(e),c=new ops.OpApplyHyperlink,l=[];if(0===b.length||d)d=d||a,c=new ops.OpInsertText,c.init({memberid:e,position:b.position,text:d}),b.length=d.length,l.push(c);c=new ops.OpApplyHyperlink;c.init({memberid:e,position:b.position,length:b.length,hyperlink:a});l.push(c);f.enqueue(l)}};this.removeHyperlinks=function(){if(g){var a=p.createPositionIterator(p.getRootNode()),d=p.getCursor(e).getSelectedRange(),b=n.getHyperlinkElements(d),
c=d.collapsed&&1===b.length,l=p.getDOMDocument().createRange(),m=[],k,q;0!==b.length&&(b.forEach(function(b){l.selectNodeContents(b);k=p.convertDomToCursorRange({anchorNode:l.startContainer,anchorOffset:l.startOffset,focusNode:l.endContainer,focusOffset:l.endOffset});q=new ops.OpRemoveHyperlink;q.init({memberid:e,position:k.position,length:k.length});m.push(q)}),c||(c=b[0],-1===d.comparePoint(c,0)&&(l.setStart(c,0),l.setEnd(d.startContainer,d.startOffset),k=p.convertDomToCursorRange({anchorNode:l.startContainer,
anchorOffset:l.startOffset,focusNode:l.endContainer,focusOffset:l.endOffset}),0<k.length&&(q=new ops.OpApplyHyperlink,q.init({memberid:e,position:k.position,length:k.length,hyperlink:n.getHyperlinkTarget(c)}),m.push(q))),b=b[b.length-1],a.moveToEndOfNode(b),a=a.unfilteredDomOffset(),1===d.comparePoint(b,a)&&(l.setStart(d.endContainer,d.endOffset),l.setEnd(b,a),k=p.convertDomToCursorRange({anchorNode:l.startContainer,anchorOffset:l.startOffset,focusNode:l.endContainer,focusOffset:l.endOffset}),0<k.length&&
(q=new ops.OpApplyHyperlink,q.init({memberid:e,position:k.position,length:k.length,hyperlink:n.getHyperlinkTarget(b)}),m.push(q)))),f.enqueue(m),l.detach())}};this.destroy=function(a){p.unsubscribe(ops.Document.signalCursorMoved,m);k.unsubscribe(gui.CommonConstraints.EDIT.REVIEW_MODE,c);a()};p.subscribe(ops.Document.signalCursorMoved,m);k.subscribe(gui.CommonConstraints.EDIT.REVIEW_MODE,c);c()};gui.HyperlinkController.enabledChanged="enabled/changed";gui.ImageController=function(f,k,a,e,c){function m(){var d=!0;!0===k.getState(gui.CommonConstraints.EDIT.REVIEW_MODE)&&(d=a.isLocalCursorWithinOwnAnnotation());d!==r&&(r=d,b.emit(gui.ImageController.enabledChanged,r))}function n(b){b.getMemberId()===e&&m()}var p={"image/gif":".gif","image/jpeg":".jpg","image/png":".png"},q=odf.Namespaces.textns,g=f.getOdtDocument(),h=odf.OdfUtils,d=g.getFormatting(),b=new core.EventNotifier([gui.HyperlinkController.enabledChanged]),r=!1;this.isEnabled=function(){return r};
this.subscribe=function(a,d){b.subscribe(a,d)};this.unsubscribe=function(a,d){b.unsubscribe(a,d)};this.insertImage=function(b,a,m,k){if(r){runtime.assert(0<m&&0<k,"Both width and height of the image should be greater than 0px.");k={width:m,height:k};if(m=h.getParagraphElement(g.getCursor(e).getNode()).getAttributeNS(q,"style-name")){m=d.getContentSize(m,"paragraph");var n=1,s=1;k.width>m.width&&(n=m.width/k.width);k.height>m.height&&(s=m.height/k.height);m=Math.min(n,s);k={width:k.width*m,height:k.height*
m}}m=k.width+"px";k=k.height+"px";var x=g.getOdfCanvas().odfContainer().rootElement.styles,n=b.toLowerCase(),s=p.hasOwnProperty(n)?p[n]:null,u,n=[];runtime.assert(null!==s,"Image type is not supported: "+b);s="Pictures/"+c.generateImageName()+s;u=new ops.OpSetBlob;u.init({memberid:e,filename:s,mimetype:b,content:a});n.push(u);d.getStyleElement("Graphics","graphic",[x])||(b=new ops.OpAddStyle,b.init({memberid:e,styleName:"Graphics",styleFamily:"graphic",isAutomaticStyle:!1,setProperties:{"style:graphic-properties":{"text:anchor-type":"paragraph",
"svg:x":"0cm","svg:y":"0cm","style:wrap":"dynamic","style:number-wrapped-paragraphs":"no-limit","style:wrap-contour":"false","style:vertical-pos":"top","style:vertical-rel":"paragraph","style:horizontal-pos":"center","style:horizontal-rel":"paragraph"}}}),n.push(b));b=c.generateStyleName();a=new ops.OpAddStyle;a.init({memberid:e,styleName:b,styleFamily:"graphic",isAutomaticStyle:!0,setProperties:{"style:parent-style-name":"Graphics","style:graphic-properties":{"style:vertical-pos":"top","style:vertical-rel":"baseline",
"style:horizontal-pos":"center","style:horizontal-rel":"paragraph","fo:background-color":"transparent","style:background-transparency":"100%","style:shadow":"none","style:mirror":"none","fo:clip":"rect(0cm, 0cm, 0cm, 0cm)","draw:luminance":"0%","draw:contrast":"0%","draw:red":"0%","draw:green":"0%","draw:blue":"0%","draw:gamma":"100%","draw:color-inversion":"false","draw:image-opacity":"100%","draw:color-mode":"standard"}}});n.push(a);u=new ops.OpInsertImage;u.init({memberid:e,position:g.getCursorPosition(e),
filename:s,frameWidth:m,frameHeight:k,frameStyleName:b,frameName:c.generateFrameName()});n.push(u);f.enqueue(n)}};this.destroy=function(b){g.unsubscribe(ops.Document.signalCursorMoved,n);k.unsubscribe(gui.CommonConstraints.EDIT.REVIEW_MODE,m);b()};g.subscribe(ops.Document.signalCursorMoved,n);k.subscribe(gui.CommonConstraints.EDIT.REVIEW_MODE,m);m()};gui.ImageController.enabledChanged="enabled/changed";gui.ImageSelector=function(f){function k(){var a=f.getSizer(),m=c.createElement("div");m.id="imageSelector";m.style.borderWidth="1px";a.appendChild(m);e.forEach(function(a){var e=c.createElement("div");e.className=a;m.appendChild(e)});return m}var a=odf.Namespaces.svgns,e="topLeft topRight bottomRight bottomLeft topMiddle rightMiddle bottomMiddle leftMiddle".split(" "),c=f.getElement().ownerDocument,m=!1;this.select=function(e){var p,q,g=c.getElementById("imageSelector");g||(g=k());m=!0;p=g.parentNode;
q=e.getBoundingClientRect();var h=p.getBoundingClientRect(),d=f.getZoomLevel();p=(q.left-h.left)/d-1;q=(q.top-h.top)/d-1;g.style.display="block";g.style.left=p+"px";g.style.top=q+"px";g.style.width=e.getAttributeNS(a,"width");g.style.height=e.getAttributeNS(a,"height")};this.clearSelection=function(){var a;m&&(a=c.getElementById("imageSelector"))&&(a.style.display="none");m=!1};this.isSelectorElement=function(a){var e=c.getElementById("imageSelector");return e?a===e||a.parentNode===e:!1}};(function(){function f(f){function a(a){n=a.which&&String.fromCharCode(a.which)===m;m=void 0;return!1===n}function e(){n=!1}function c(a){m=a.data;n=!1}var m,n=!1;this.destroy=function(m){f.unsubscribe("textInput",e);f.unsubscribe("compositionend",c);f.removeFilter("keypress",a);m()};f.subscribe("textInput",e);f.subscribe("compositionend",c);f.addFilter("keypress",a)}gui.InputMethodEditor=function(k,a){function e(a){b&&(a?b.getNode().setAttributeNS(d,"composing","true"):(b.getNode().removeAttributeNS(d,
"composing"),y.textContent=""))}function c(){z&&(z=!1,e(!1),s.emit(gui.InputMethodEditor.signalCompositionEnd,{data:w}),w="")}function m(){D||(D=!0,c(),b&&b.getSelectedRange().collapsed?r.value="":r.value=u.writeToString(b.getSelectedRange().cloneContents()),r.setSelectionRange(0,r.value.length),D=!1)}function n(){a.hasFocus()&&t.trigger()}function p(){x=void 0;t.cancel();e(!0);z||s.emit(gui.InputMethodEditor.signalCompositionStart,{data:""})}function q(b){b=x=b.data;z=!0;w+=b;t.trigger()}function g(b){b.data!==
x&&(b=b.data,z=!0,w+=b,t.trigger());x=void 0}function h(){y.textContent=r.value}var d="urn:webodf:names:cursor",b=null,r=a.getEventTrap(),l=r.ownerDocument,y,t,z=!1,w="",s=new core.EventNotifier([gui.InputMethodEditor.signalCompositionStart,gui.InputMethodEditor.signalCompositionEnd]),x,u,C=[],H,D=!1;this.subscribe=s.subscribe;this.unsubscribe=s.unsubscribe;this.registerCursor=function(d){d.getMemberId()===k&&(b=d,b.getNode().appendChild(y),d.subscribe(ops.OdtCursor.signalCursorUpdated,n),a.subscribe("input",
h),a.subscribe("compositionupdate",h))};this.removeCursor=function(d){b&&d===k&&(b.getNode().removeChild(y),b.unsubscribe(ops.OdtCursor.signalCursorUpdated,n),a.unsubscribe("input",h),a.unsubscribe("compositionupdate",h),b=null)};this.destroy=function(b){a.unsubscribe("compositionstart",p);a.unsubscribe("compositionend",q);a.unsubscribe("textInput",g);a.unsubscribe("keypress",c);a.unsubscribe("focus",m);core.Async.destroyAll(H,b)};(function(){u=new odf.TextSerializer;u.filter=new odf.OdfNodeFilter;
a.subscribe("compositionstart",p);a.subscribe("compositionend",q);a.subscribe("textInput",g);a.subscribe("keypress",c);a.subscribe("focus",m);C.push(new f(a));H=C.map(function(b){return b.destroy});y=l.createElement("span");y.setAttribute("id","composer");t=core.Task.createTimeoutTask(m,1);H.push(t.destroy)})()};gui.InputMethodEditor.signalCompositionStart="input/compositionstart";gui.InputMethodEditor.signalCompositionEnd="input/compositionend"})();gui.MetadataController=function(f,k){function a(a){m.emit(gui.MetadataController.signalMetadataChanged,a)}function e(a){var c=-1===n.indexOf(a);c||runtime.log("Setting "+a+" is restricted.");return c}var c=f.getOdtDocument(),m=new core.EventNotifier([gui.MetadataController.signalMetadataChanged]),n=["dc:creator","dc:date","meta:editing-cycles","meta:editing-duration","meta:document-statistic"];this.setMetadata=function(a,c){var g={},h="",d;a&&Object.keys(a).filter(e).forEach(function(b){g[b]=a[b]});
c&&(h=c.filter(e).join(","));if(0<h.length||0<Object.keys(g).length)d=new ops.OpUpdateMetadata,d.init({memberid:k,setProperties:g,removedProperties:0<h.length?{attributes:h}:null}),f.enqueue([d])};this.getMetadata=function(a){var e;runtime.assert("string"===typeof a,"Property must be a string");e=a.split(":");runtime.assert(2===e.length,"Property must be a namespace-prefixed string");a=odf.Namespaces.lookupNamespaceURI(e[0]);runtime.assert(Boolean(a),"Prefix must be for an ODF namespace.");return c.getOdfCanvas().odfContainer().getMetadata(a,
e[1])};this.subscribe=function(a,c){m.subscribe(a,c)};this.unsubscribe=function(a,c){m.unsubscribe(a,c)};this.destroy=function(e){c.unsubscribe(ops.OdtDocument.signalMetadataUpdated,a);e()};c.subscribe(ops.OdtDocument.signalMetadataUpdated,a)};gui.MetadataController.signalMetadataChanged="metadata/changed";gui.PasteController=function(f,k,a,e){function c(){p=!0===k.getState(gui.CommonConstraints.EDIT.REVIEW_MODE)?a.isLocalCursorWithinOwnAnnotation():!0}function m(a){a.getMemberId()===e&&c()}var n=f.getOdtDocument(),p=!1,q=odf.Namespaces.textns,g=core.StepDirection.NEXT,h=odf.OdfUtils;this.isEnabled=function(){return p};this.paste=function(a){if(p){var b=n.getCursorPosition(e),c=n.getCursor(e).getNode(),c=h.getParagraphElement(c),l=c.getAttributeNS(q,"style-name")||"",m=b,k=[],z=n.convertDomPointToCursorStep(c,
0,g);a.replace(/\r/g,"").split("\n").forEach(function(b){var a=new ops.OpInsertText,d=new ops.OpSplitParagraph;a.init({memberid:e,position:m,text:b,moveCursor:!0});k.push(a);m+=b.length;d.init({memberid:e,position:m,paragraphStyleName:l,sourceParagraphPosition:z,moveCursor:!0});k.push(d);z=m+=1});k.pop();f.enqueue(k)}};this.destroy=function(a){n.unsubscribe(ops.Document.signalCursorMoved,m);k.unsubscribe(gui.CommonConstraints.EDIT.REVIEW_MODE,c);a()};n.subscribe(ops.Document.signalCursorMoved,m);
k.subscribe(gui.CommonConstraints.EDIT.REVIEW_MODE,c);c()};gui.ClosestXOffsetScanner=function(f){function k(a){return null!==a&&void 0!==c?Math.abs(a-f)>c:!1}function a(a){null!==a&&!1===k(a)&&(c=Math.abs(a-f))}var e=this,c,m=gui.StepInfo.VisualDirection.LEFT_TO_RIGHT;this.token=void 0;this.process=function(c,f,q){var g,h;c.visualDirection===m?(g=f&&f.right,h=q&&q.left):(g=f&&f.left,h=q&&q.right);if(k(g)||k(h))return!0;if(f||q)a(g),a(h),e.token=c.token;return!1}};gui.LineBoundaryScanner=function(){var f=this,k=null;this.token=void 0;this.process=function(a,e,c){var m;if(m=c)if(k){var n=k;m=Math.min(n.bottom-n.top,c.bottom-c.top);var p=Math.max(n.top,c.top),n=Math.min(n.bottom,c.bottom)-p;m=0.4>=(0<m?n/m:0)}else m=!1;!e||c&&!m||(f.token=a.token);if(m)return!0;k=(a=k)&&e?{left:Math.min(a.left,e.left),right:Math.max(a.right,e.right),top:Math.min(a.top,e.top),bottom:Math.min(a.bottom,e.bottom)}:a||e;return!1}};gui.ParagraphBoundaryScanner=function(){var f=this,k=!1,a,e=odf.OdfUtils;this.token=void 0;this.process=function(c){var m=e.getParagraphElement(c.container());k||(a=m,k=!0);if(a!==m)return!0;f.token=c.token;return!1}};odf.WordBoundaryFilter=function(f,k){function a(b,a,d){for(var c=null,e=f.getRootNode(),g;b!==e&&null!==b&&null===c;)g=0>a?b.previousSibling:b.nextSibling,d(g)===NodeFilter.FILTER_ACCEPT&&(c=g),b=b.parentNode;return c}function e(b,a){var d;return null===b?r.NO_NEIGHBOUR:n.isCharacterElement(b)?r.SPACE_CHAR:b.nodeType===c||n.isTextSpan(b)||n.isHyperlink(b)?(d=b.textContent.charAt(a()),q.test(d)?r.SPACE_CHAR:p.test(d)?r.PUNCTUATION_CHAR:r.WORD_CHAR):r.OTHER}var c=Node.TEXT_NODE,m=Node.ELEMENT_NODE,
n=odf.OdfUtils,p=/[!-#%-*,-\/:-;?-@\[-\]_{}\u00a1\u00ab\u00b7\u00bb\u00bf;\u00b7\u055a-\u055f\u0589-\u058a\u05be\u05c0\u05c3\u05c6\u05f3-\u05f4\u0609-\u060a\u060c-\u060d\u061b\u061e-\u061f\u066a-\u066d\u06d4\u0700-\u070d\u07f7-\u07f9\u0964-\u0965\u0970\u0df4\u0e4f\u0e5a-\u0e5b\u0f04-\u0f12\u0f3a-\u0f3d\u0f85\u0fd0-\u0fd4\u104a-\u104f\u10fb\u1361-\u1368\u166d-\u166e\u169b-\u169c\u16eb-\u16ed\u1735-\u1736\u17d4-\u17d6\u17d8-\u17da\u1800-\u180a\u1944-\u1945\u19de-\u19df\u1a1e-\u1a1f\u1b5a-\u1b60\u1c3b-\u1c3f\u1c7e-\u1c7f\u2000-\u206e\u207d-\u207e\u208d-\u208e\u3008-\u3009\u2768-\u2775\u27c5-\u27c6\u27e6-\u27ef\u2983-\u2998\u29d8-\u29db\u29fc-\u29fd\u2cf9-\u2cfc\u2cfe-\u2cff\u2e00-\u2e7e\u3000-\u303f\u30a0\u30fb\ua60d-\ua60f\ua673\ua67e\ua874-\ua877\ua8ce-\ua8cf\ua92e-\ua92f\ua95f\uaa5c-\uaa5f\ufd3e-\ufd3f\ufe10-\ufe19\ufe30-\ufe52\ufe54-\ufe61\ufe63\ufe68\ufe6a-\ufe6b\uff01-\uff03\uff05-\uff0a\uff0c-\uff0f\uff1a-\uff1b\uff1f-\uff20\uff3b-\uff3d\uff3f\uff5b\uff5d\uff5f-\uff65]|\ud800[\udd00-\udd01\udf9f\udfd0]|\ud802[\udd1f\udd3f\ude50-\ude58]|\ud809[\udc00-\udc7e]/,
q=/\s/,g=core.PositionFilter.FilterResult.FILTER_ACCEPT,h=core.PositionFilter.FilterResult.FILTER_REJECT,d=odf.WordBoundaryFilter.IncludeWhitespace.TRAILING,b=odf.WordBoundaryFilter.IncludeWhitespace.LEADING,r={NO_NEIGHBOUR:0,SPACE_CHAR:1,PUNCTUATION_CHAR:2,WORD_CHAR:3,OTHER:4};this.acceptPosition=function(c){var f=c.container(),n=c.leftNode(),p=c.rightNode(),q=c.unfilteredDomOffset,s=function(){return c.unfilteredDomOffset()-1};f.nodeType===m&&(null===p&&(p=a(f,1,c.getNodeFilter())),null===n&&(n=
a(f,-1,c.getNodeFilter())));f!==p&&(q=function(){return 0});f!==n&&null!==n&&(s=function(){return n.textContent.length-1});f=e(n,s);p=e(p,q);return f===r.WORD_CHAR&&p===r.WORD_CHAR||f===r.PUNCTUATION_CHAR&&p===r.PUNCTUATION_CHAR||k===d&&f!==r.NO_NEIGHBOUR&&p===r.SPACE_CHAR||k===b&&f===r.SPACE_CHAR&&p!==r.NO_NEIGHBOUR?h:g}};odf.WordBoundaryFilter.IncludeWhitespace={None:0,TRAILING:1,LEADING:2};gui.SelectionController=function(f,k){function a(b){var a=b.spec();if(b.isEdit||a.memberid===k)H=void 0,D.cancel()}function e(){var b=t.getCursor(k).getNode();return t.createStepIterator(b,0,[s,u],t.getRootElement(b))}function c(b,a,d){d=new odf.WordBoundaryFilter(t,d);var c=t.getRootElement(b)||t.getRootNode(),e=t.createRootFilter(c);return t.createStepIterator(b,a,[s,e,d],c)}function m(b,a){return a?{anchorNode:b.startContainer,anchorOffset:b.startOffset,focusNode:b.endContainer,focusOffset:b.endOffset}:
{anchorNode:b.endContainer,anchorOffset:b.endOffset,focusNode:b.startContainer,focusOffset:b.startOffset}}function n(b,a,d){var c=new ops.OpMoveCursor;c.init({memberid:k,position:b,length:a||0,selectionType:d});return c}function p(b,a,d){var c;c=t.getCursor(k);c=m(c.getSelectedRange(),c.hasForwardSelection());c.focusNode=b;c.focusOffset=a;d||(c.anchorNode=c.focusNode,c.anchorOffset=c.focusOffset);b=t.convertDomToCursorRange(c);f.enqueue([n(b.position,b.length)])}function q(b){var a;a=c(b.startContainer,
b.startOffset,G);a.roundToPreviousStep()&&b.setStart(a.container(),a.offset());a=c(b.endContainer,b.endOffset,B);a.roundToNextStep()&&b.setEnd(a.container(),a.offset())}function g(b){var a=w.getParagraphElements(b),d=a[0],a=a[a.length-1];d&&b.setStart(d,0);a&&(w.isParagraph(b.endContainer)&&0===b.endOffset?b.setEndBefore(a):b.setEnd(a,a.childNodes.length))}function h(b,a,d,c){var e,f;c?(e=d.startContainer,f=d.startOffset):(e=d.endContainer,f=d.endOffset);z.containsNode(b,e)||(f=0>z.comparePoints(b,
0,e,f)?0:b.childNodes.length,e=b);b=t.createStepIterator(e,f,a,w.getParagraphElement(e)||b);b.roundToClosestStep()||runtime.assert(!1,"No step found in requested range");c?d.setStart(b.container(),b.offset()):d.setEnd(b.container(),b.offset())}function d(b,a){var d=e();d.advanceStep(b)&&p(d.container(),d.offset(),a)}function b(b,a){var d,c=H,f=[new gui.LineBoundaryScanner,new gui.ParagraphBoundaryScanner];void 0===c&&C&&(c=C());isNaN(c)||(d=e(),x.moveToFilteredStep(d,b,f)&&d.advanceStep(b)&&(f=[new gui.ClosestXOffsetScanner(c),
new gui.LineBoundaryScanner,new gui.ParagraphBoundaryScanner],x.moveToFilteredStep(d,b,f)&&(p(d.container(),d.offset(),a),H=c,D.restart())))}function r(b,a){var d=e(),c=[new gui.LineBoundaryScanner,new gui.ParagraphBoundaryScanner];x.moveToFilteredStep(d,b,c)&&p(d.container(),d.offset(),a)}function l(b,a){var d=t.getCursor(k),d=m(d.getSelectedRange(),d.hasForwardSelection()),d=c(d.focusNode,d.focusOffset,G);d.advanceStep(b)&&p(d.container(),d.offset(),a)}function y(b,a,d){var c=!1,e=t.getCursor(k),
e=m(e.getSelectedRange(),e.hasForwardSelection()),c=t.getRootElement(e.focusNode);runtime.assert(Boolean(c),"SelectionController: Cursor outside root");e=t.createStepIterator(e.focusNode,e.focusOffset,[s,u],c);e.roundToClosestStep();e.advanceStep(b)&&(d=d(e.container()))&&(b===J?(e.setPosition(d,0),c=e.roundToNextStep()):(e.setPosition(d,d.childNodes.length),c=e.roundToPreviousStep()),c&&p(e.container(),e.offset(),a))}var t=f.getOdtDocument(),z=core.DomUtils,w=odf.OdfUtils,s=t.getPositionFilter(),
x=new gui.GuiStepUtils,u=t.createRootFilter(k),C=null,H,D,G=odf.WordBoundaryFilter.IncludeWhitespace.TRAILING,B=odf.WordBoundaryFilter.IncludeWhitespace.LEADING,J=core.StepDirection.PREVIOUS,P=core.StepDirection.NEXT;this.selectionToRange=function(b){var a=0<=z.comparePoints(b.anchorNode,b.anchorOffset,b.focusNode,b.focusOffset),d=b.focusNode.ownerDocument.createRange();a?(d.setStart(b.anchorNode,b.anchorOffset),d.setEnd(b.focusNode,b.focusOffset)):(d.setStart(b.focusNode,b.focusOffset),d.setEnd(b.anchorNode,
b.anchorOffset));return{range:d,hasForwardSelection:a}};this.rangeToSelection=m;this.selectImage=function(b){var a=t.getRootElement(b),d=t.createRootFilter(a),a=t.createStepIterator(b,0,[d,t.getPositionFilter()],a),c;a.roundToPreviousStep()||runtime.assert(!1,"No walkable position before frame");d=a.container();c=a.offset();a.setPosition(b,b.childNodes.length);a.roundToNextStep()||runtime.assert(!1,"No walkable position after frame");b=t.convertDomToCursorRange({anchorNode:d,anchorOffset:c,focusNode:a.container(),
focusOffset:a.offset()});b=n(b.position,b.length,ops.OdtCursor.RegionSelection);f.enqueue([b])};this.expandToWordBoundaries=q;this.expandToParagraphBoundaries=g;this.selectRange=function(b,a,d){var c=t.getOdfCanvas().getElement(),e,l=[s];e=z.containsNode(c,b.startContainer);c=z.containsNode(c,b.endContainer);if(e||c)if(e&&c&&(2===d?q(b):3<=d&&g(b)),(d=a?t.getRootElement(b.startContainer):t.getRootElement(b.endContainer))||(d=t.getRootNode()),l.push(t.createRootFilter(d)),h(d,l,b,!0),h(d,l,b,!1),b=
m(b,a),a=t.convertDomToCursorRange(b),b=t.getCursorSelection(k),a.position!==b.position||a.length!==b.length)b=n(a.position,a.length,ops.OdtCursor.RangeSelection),f.enqueue([b])};this.moveCursorToLeft=function(){d(J,!1);return!0};this.moveCursorToRight=function(){d(P,!1);return!0};this.extendSelectionToLeft=function(){d(J,!0);return!0};this.extendSelectionToRight=function(){d(P,!0);return!0};this.setCaretXPositionLocator=function(b){C=b};this.moveCursorUp=function(){b(J,!1);return!0};this.moveCursorDown=
function(){b(P,!1);return!0};this.extendSelectionUp=function(){b(J,!0);return!0};this.extendSelectionDown=function(){b(P,!0);return!0};this.moveCursorBeforeWord=function(){l(J,!1);return!0};this.moveCursorPastWord=function(){l(P,!1);return!0};this.extendSelectionBeforeWord=function(){l(J,!0);return!0};this.extendSelectionPastWord=function(){l(P,!0);return!0};this.moveCursorToLineStart=function(){r(J,!1);return!0};this.moveCursorToLineEnd=function(){r(P,!1);return!0};this.extendSelectionToLineStart=
function(){r(J,!0);return!0};this.extendSelectionToLineEnd=function(){r(P,!0);return!0};this.extendSelectionToParagraphStart=function(){y(J,!0,w.getParagraphElement);return!0};this.extendSelectionToParagraphEnd=function(){y(P,!0,w.getParagraphElement);return!0};this.moveCursorToParagraphStart=function(){y(J,!1,w.getParagraphElement);return!0};this.moveCursorToParagraphEnd=function(){y(P,!1,w.getParagraphElement);return!0};this.moveCursorToDocumentStart=function(){y(J,!1,t.getRootElement);return!0};
this.moveCursorToDocumentEnd=function(){y(P,!1,t.getRootElement);return!0};this.extendSelectionToDocumentStart=function(){y(J,!0,t.getRootElement);return!0};this.extendSelectionToDocumentEnd=function(){y(P,!0,t.getRootElement);return!0};this.extendSelectionToEntireDocument=function(){var b=t.getCursor(k),b=t.getRootElement(b.getNode()),a,d,c;runtime.assert(Boolean(b),"SelectionController: Cursor outside root");c=t.createStepIterator(b,0,[s,u],b);c.roundToClosestStep();a=c.container();d=c.offset();
c.setPosition(b,b.childNodes.length);c.roundToClosestStep();b=t.convertDomToCursorRange({anchorNode:a,anchorOffset:d,focusNode:c.container(),focusOffset:c.offset()});f.enqueue([n(b.position,b.length)]);return!0};this.destroy=function(b){t.unsubscribe(ops.OdtDocument.signalOperationStart,a);core.Async.destroyAll([D.destroy],b)};(function(){D=core.Task.createTimeoutTask(function(){H=void 0},2E3);t.subscribe(ops.OdtDocument.signalOperationStart,a)})()};gui.TextController=function(f,k,a,e,c,m){function n(){y=!0===k.getState(gui.CommonConstraints.EDIT.REVIEW_MODE)?a.isLocalCursorWithinOwnAnnotation():!0}function p(b){b.getMemberId()===e&&n()}function q(a,d,c){var e=[b.getPositionFilter()];c&&e.push(b.createRootFilter(a.startContainer));c=b.createStepIterator(a.startContainer,a.startOffset,e,d);c.roundToClosestStep()||runtime.assert(!1,"No walkable step found in paragraph element at range start");d=b.convertDomPointToCursorStep(c.container(),c.offset());
a.collapsed?a=d:(c.setPosition(a.endContainer,a.endOffset),c.roundToClosestStep()||runtime.assert(!1,"No walkable step found in paragraph element at range end"),a=b.convertDomPointToCursorStep(c.container(),c.offset()));return{position:d,length:a-d}}function g(b){var a,d,c,f=r.getParagraphElements(b),g=b.cloneRange(),h=[];a=f[0];1<f.length&&(r.hasNoODFContent(a)&&(a=f[f.length-1]),d=a.getAttributeNS(odf.Namespaces.textns,"style-name")||"");f.forEach(function(a,f){var m,k;g.setStart(a,0);g.collapse(!0);
m=q(g,a,!1).position;0<f&&(k=new ops.OpMergeParagraph,k.init({memberid:e,paragraphStyleName:d,destinationStartPosition:c,sourceStartPosition:m,moveCursor:1===f}),h.unshift(k));c=m;g.selectNodeContents(a);if(m=l.rangeIntersection(g,b))m=q(m,a,!0),0<m.length&&(k=new ops.OpRemoveText,k.init({memberid:e,position:m.position,length:m.length}),h.unshift(k))});return h}function h(b){0>b.length&&(b.position+=b.length,b.length=-b.length);return b}function d(a){if(!y)return!1;var d,c=b.getCursor(e).getSelectedRange().cloneRange(),
l=h(b.getCursorSelection(e)),m;if(0===l.length){l=void 0;d=b.getCursor(e).getNode();m=b.getRootElement(d);var k=[b.getPositionFilter(),b.createRootFilter(m)];m=b.createStepIterator(d,0,k,m);m.roundToClosestStep()&&(a?m.nextStep():m.previousStep())&&(l=h(b.convertDomToCursorRange({anchorNode:d,anchorOffset:0,focusNode:m.container(),focusOffset:m.offset()})),a?(c.setStart(d,0),c.setEnd(m.container(),m.offset())):(c.setStart(m.container(),m.offset()),c.setEnd(d,0)))}l&&f.enqueue(g(c));return void 0!==
l}var b=f.getOdtDocument(),r=odf.OdfUtils,l=core.DomUtils,y=!1,t=odf.Namespaces.textns,z=core.StepDirection.NEXT;this.isEnabled=function(){return y};this.enqueueParagraphSplittingOps=function(){if(!y)return!1;var a=b.getCursor(e),d=a.getSelectedRange(),c=h(b.getCursorSelection(e)),l=[],a=r.getParagraphElement(a.getNode()),k=a.getAttributeNS(t,"style-name")||"";0<c.length&&(l=l.concat(g(d)));d=new ops.OpSplitParagraph;d.init({memberid:e,position:c.position,paragraphStyleName:k,sourceParagraphPosition:b.convertDomPointToCursorStep(a,
0,z),moveCursor:!0});l.push(d);m&&(c=m(c.position+1),l=l.concat(c));f.enqueue(l);return!0};this.removeTextByBackspaceKey=function(){return d(!1)};this.removeTextByDeleteKey=function(){return d(!0)};this.removeCurrentSelection=function(){if(!y)return!1;var a=b.getCursor(e).getSelectedRange();f.enqueue(g(a));return!0};this.insertText=function(a){if(y){var d=b.getCursor(e).getSelectedRange(),l=h(b.getCursorSelection(e)),m=[],k=!1;0<l.length&&(m=m.concat(g(d)),k=!0);d=new ops.OpInsertText;d.init({memberid:e,
position:l.position,text:a,moveCursor:!0});m.push(d);c&&(a=c(l.position,a.length,k))&&m.push(a);f.enqueue(m)}};this.destroy=function(a){b.unsubscribe(ops.Document.signalCursorMoved,p);k.unsubscribe(gui.CommonConstraints.EDIT.REVIEW_MODE,n);a()};b.subscribe(ops.Document.signalCursorMoved,p);k.subscribe(gui.CommonConstraints.EDIT.REVIEW_MODE,n);n()};gui.UndoManager=function(){};gui.UndoManager.prototype.subscribe=function(f,k){};gui.UndoManager.prototype.unsubscribe=function(f,k){};gui.UndoManager.prototype.setDocument=function(f){};gui.UndoManager.prototype.setInitialState=function(){};gui.UndoManager.prototype.initialize=function(){};gui.UndoManager.prototype.purgeInitialState=function(){};gui.UndoManager.prototype.setPlaybackFunction=function(f){};gui.UndoManager.prototype.hasUndoStates=function(){};
gui.UndoManager.prototype.hasRedoStates=function(){};gui.UndoManager.prototype.moveForward=function(f){};gui.UndoManager.prototype.moveBackward=function(f){};gui.UndoManager.prototype.onOperationExecuted=function(f){};gui.UndoManager.prototype.isDocumentModified=function(){};gui.UndoManager.prototype.setDocumentModified=function(f){};gui.UndoManager.signalUndoStackChanged="undoStackChanged";gui.UndoManager.signalUndoStateCreated="undoStateCreated";gui.UndoManager.signalUndoStateModified="undoStateModified";
gui.UndoManager.signalDocumentModifiedChanged="documentModifiedChanged";gui.SessionControllerOptions=function(){this.annotationsEnabled=this.directParagraphStylingEnabled=this.directTextStylingEnabled=!1};
(function(){var f=core.PositionFilter.FilterResult.FILTER_ACCEPT;gui.SessionController=function(k,a,e,c){function m(b){return b.target||b.srcElement||null}function n(b,a){var d=v.getDOMDocument(),c=null;d.caretRangeFromPoint?(d=d.caretRangeFromPoint(b,a),c={container:d.startContainer,offset:d.startOffset}):d.caretPositionFromPoint&&(d=d.caretPositionFromPoint(b,a))&&d.offsetNode&&(c={container:d.offsetNode,offset:d.offset});return c}function p(b){var d=v.getCursor(a).getSelectedRange();d.collapsed?
b.preventDefault():Z.setDataFromRange(b,d)?ha.removeCurrentSelection():runtime.log("Cut operation failed")}function q(){return!1!==v.getCursor(a).getSelectedRange().collapsed}function g(b){var d=v.getCursor(a).getSelectedRange();d.collapsed?b.preventDefault():Z.setDataFromRange(b,d)||runtime.log("Copy operation failed")}function h(b){var a;S.clipboardData&&S.clipboardData.getData?a=S.clipboardData.getData("Text"):b.clipboardData&&b.clipboardData.getData&&(a=b.clipboardData.getData("text/plain"));
a&&(ha.removeCurrentSelection(),pa.paste(a));b.preventDefault?b.preventDefault():b.returnValue=!1}function d(){return!1}function b(b){if(R)R.onOperationExecuted(b)}function r(b){v.emit(ops.OdtDocument.signalUndoStackChanged,b)}function l(){var b;return R?(b=L.hasFocus(),R.moveBackward(1),b&&L.focus(),!0):!1}function y(){var b;return R?(b=L.hasFocus(),R.moveForward(1),b&&L.focus(),!0):!1}function t(b){var d=v.getCursor(a).getSelectedRange(),c=m(b).getAttribute("end");d&&c&&(b=n(b.clientX,b.clientY))&&
(ia.setUnfilteredPosition(b.container,b.offset),O.acceptPosition(ia)===f&&(d=d.cloneRange(),"left"===c?d.setStart(ia.container(),ia.unfilteredDomOffset()):d.setEnd(ia.container(),ia.unfilteredDomOffset()),e.setSelectedRange(d,"right"===c),v.emit(ops.Document.signalCursorMoved,e)))}function z(){X.selectRange(e.getSelectedRange(),e.hasForwardSelection(),1)}function w(){var b=S.getSelection(),a=0<b.rangeCount&&X.selectionToRange(b);ca&&a&&(W=!0,la.clearSelection(),ia.setUnfilteredPosition(b.focusNode,
b.focusOffset),O.acceptPosition(ia)===f&&(2===na?X.expandToWordBoundaries(a.range):3<=na&&X.expandToParagraphBoundaries(a.range),e.setSelectedRange(a.range,a.hasForwardSelection),v.emit(ops.Document.signalCursorMoved,e)))}function s(b){var d=m(b),c=v.getCursor(a);if(ca=null!==d&&T.containsNode(v.getOdfCanvas().getElement(),d))W=!1,d=v.getRootElement(d)||v.getRootNode(),O=v.createRootFilter(d),na=0===b.button?b.detail:0,c&&b.shiftKey?S.getSelection().collapse(c.getAnchorNode(),0):(b=S.getSelection(),
d=c.getSelectedRange(),b.extend?c.hasForwardSelection()?(b.collapse(d.startContainer,d.startOffset),b.extend(d.endContainer,d.endOffset)):(b.collapse(d.endContainer,d.endOffset),b.extend(d.startContainer,d.startOffset)):(b.removeAllRanges(),b.addRange(d.cloneRange()))),1<na&&w()}function x(b){var a=v.getRootElement(b),d=v.createRootFilter(a),a=v.createStepIterator(b,0,[d,v.getPositionFilter()],a);a.setPosition(b,b.childNodes.length);return a.roundToNextStep()?{container:a.container(),offset:a.offset()}:
null}function u(b){var a;a=(a=S.getSelection())?{anchorNode:a.anchorNode,anchorOffset:a.anchorOffset,focusNode:a.focusNode,focusOffset:a.focusOffset}:null;var d=S.getSelection().isCollapsed,c,e;a.anchorNode||a.focusNode||!(c=n(b.clientX,b.clientY))||(a.anchorNode=c.container,a.anchorOffset=c.offset,a.focusNode=a.anchorNode,a.focusOffset=a.anchorOffset);if(F.isImage(a.focusNode)&&0===a.focusOffset&&F.isCharacterFrame(a.focusNode.parentNode)){if(e=a.focusNode.parentNode,c=e.getBoundingClientRect(),
b.clientX>c.left&&(c=x(e)))a.focusNode=c.container,a.focusOffset=c.offset,d&&(a.anchorNode=a.focusNode,a.anchorOffset=a.focusOffset)}else F.isImage(a.focusNode.firstChild)&&1===a.focusOffset&&F.isCharacterFrame(a.focusNode)&&(c=x(a.focusNode))&&(a.anchorNode=a.focusNode=c.container,a.anchorOffset=a.focusOffset=c.offset);a.anchorNode&&a.focusNode&&(a=X.selectionToRange(a),X.selectRange(a.range,a.hasForwardSelection,0===b.button?b.detail:0));L.focus()}function C(b){var a;if(a=n(b.clientX,b.clientY))b=
a.container,a=a.offset,b={anchorNode:b,anchorOffset:a,focusNode:b,focusOffset:a},b=X.selectionToRange(b),X.selectRange(b.range,b.hasForwardSelection,2),L.focus()}function H(b){var a=m(b),d,c,f;ja.processRequests();ca&&(F.isImage(a)&&F.isCharacterFrame(a.parentNode)&&S.getSelection().isCollapsed?(X.selectImage(a.parentNode),L.focus()):la.isSelectorElement(a)?L.focus():W?(a=e.getSelectedRange(),c=a.collapsed,F.isImage(a.endContainer)&&0===a.endOffset&&F.isCharacterFrame(a.endContainer.parentNode)&&
(f=a.endContainer.parentNode,f=x(f))&&(a.setEnd(f.container,f.offset),c&&a.collapse(!1)),X.selectRange(a,e.hasForwardSelection(),0===b.button?b.detail:0),L.focus()):ta?u(b):(d=T.cloneEvent(b),aa=runtime.setTimeout(function(){u(d)},0)),na=0,W=ca=!1)}function D(b){var d=v.getCursor(a).getSelectedRange();d.collapsed||N.exportRangeToDataTransfer(b.dataTransfer,d)}function G(){ca&&L.focus();na=0;W=ca=!1}function B(b){H(b)}function J(b){var a=m(b),d=null;"annotationRemoveButton"===a.className?(runtime.assert(ea,
"Remove buttons are displayed on annotations while annotation editing is disabled in the controller."),d=a.parentNode.getElementsByTagNameNS(odf.Namespaces.officens,"annotation").item(0),ga.removeAnnotation(d),L.focus()):"webodf-draggable"!==a.getAttribute("class")&&H(b)}function P(b){(b=b.data)&&(-1===b.indexOf("\n")?ha.insertText(b):pa.paste(b))}function Q(b){return function(){b();return!0}}function A(b){return function(d){return v.getCursor(a).getSelectionType()===ops.OdtCursor.RangeSelection?
b(d):!0}}function Y(a){L.unsubscribe("keydown",E.handleEvent);L.unsubscribe("keypress",V.handleEvent);L.unsubscribe("keyup",$.handleEvent);L.unsubscribe("copy",g);L.unsubscribe("mousedown",s);L.unsubscribe("mousemove",ja.trigger);L.unsubscribe("mouseup",J);L.unsubscribe("contextmenu",B);L.unsubscribe("dragstart",D);L.unsubscribe("dragend",G);L.unsubscribe("click",oa.handleClick);L.unsubscribe("longpress",C);L.unsubscribe("drag",t);L.unsubscribe("dragstop",z);v.unsubscribe(ops.OdtDocument.signalOperationEnd,
fa.trigger);v.unsubscribe(ops.Document.signalCursorAdded,ka.registerCursor);v.unsubscribe(ops.Document.signalCursorRemoved,ka.removeCursor);v.unsubscribe(ops.OdtDocument.signalOperationEnd,b);a()}var S=runtime.getWindow(),v=k.getOdtDocument(),I=new gui.SessionConstraints,ba=new gui.SessionContext(k,a),T=core.DomUtils,F=odf.OdfUtils,N=new gui.MimeDataExporter,Z=new gui.Clipboard(N),E=new gui.KeyboardHandler,V=new gui.KeyboardHandler,$=new gui.KeyboardHandler,ca=!1,U=new odf.ObjectNameGenerator(v.getOdfCanvas().odfContainer(),
a),W=!1,O=null,aa,R=null,L=new gui.EventManager(v),ea=c.annotationsEnabled,ga=new gui.AnnotationController(k,I,a),da=new gui.DirectFormattingController(k,I,ba,a,U,c.directTextStylingEnabled,c.directParagraphStylingEnabled),ha=new gui.TextController(k,I,ba,a,da.createCursorStyleOp,da.createParagraphStyleOps),ma=new gui.ImageController(k,I,ba,a,U),la=new gui.ImageSelector(v.getOdfCanvas()),ia=v.createPositionIterator(v.getRootNode()),ja,fa,pa=new gui.PasteController(k,I,ba,a),ka=new gui.InputMethodEditor(a,
L),na=0,oa=new gui.HyperlinkClickHandler(v.getOdfCanvas().getElement,E,$),qa=new gui.HyperlinkController(k,I,ba,a),X=new gui.SelectionController(k,a),ua=new gui.MetadataController(k,a),K=gui.KeyboardHandler.Modifier,M=gui.KeyboardHandler.KeyCode,ra=-1!==S.navigator.appVersion.toLowerCase().indexOf("mac"),ta=-1!==["iPad","iPod","iPhone"].indexOf(S.navigator.platform),sa;runtime.assert(null!==S,"Expected to be run in an environment which has a global window, like a browser.");this.undo=l;this.redo=
y;this.insertLocalCursor=function(){runtime.assert(void 0===k.getOdtDocument().getCursor(a),"Inserting local cursor a second time.");var b=new ops.OpAddCursor;b.init({memberid:a});k.enqueue([b]);L.focus()};this.removeLocalCursor=function(){runtime.assert(void 0!==k.getOdtDocument().getCursor(a),"Removing local cursor without inserting before.");var b=new ops.OpRemoveCursor;b.init({memberid:a});k.enqueue([b])};this.startEditing=function(){ka.subscribe(gui.InputMethodEditor.signalCompositionStart,ha.removeCurrentSelection);
ka.subscribe(gui.InputMethodEditor.signalCompositionEnd,P);L.subscribe("beforecut",q);L.subscribe("cut",p);L.subscribe("beforepaste",d);L.subscribe("paste",h);R&&R.initialize();L.setEditing(!0);oa.setModifier(ra?K.Meta:K.Ctrl);E.bind(M.Backspace,K.None,Q(ha.removeTextByBackspaceKey),!0);E.bind(M.Delete,K.None,ha.removeTextByDeleteKey);E.bind(M.Tab,K.None,A(function(){ha.insertText("\t");return!0}));ra?(E.bind(M.Clear,K.None,ha.removeCurrentSelection),E.bind(M.B,K.Meta,A(da.toggleBold)),E.bind(M.I,
K.Meta,A(da.toggleItalic)),E.bind(M.U,K.Meta,A(da.toggleUnderline)),E.bind(M.L,K.MetaShift,A(da.alignParagraphLeft)),E.bind(M.E,K.MetaShift,A(da.alignParagraphCenter)),E.bind(M.R,K.MetaShift,A(da.alignParagraphRight)),E.bind(M.J,K.MetaShift,A(da.alignParagraphJustified)),ea&&E.bind(M.C,K.MetaShift,ga.addAnnotation),E.bind(M.Z,K.Meta,l),E.bind(M.Z,K.MetaShift,y)):(E.bind(M.B,K.Ctrl,A(da.toggleBold)),E.bind(M.I,K.Ctrl,A(da.toggleItalic)),E.bind(M.U,K.Ctrl,A(da.toggleUnderline)),E.bind(M.L,K.CtrlShift,
A(da.alignParagraphLeft)),E.bind(M.E,K.CtrlShift,A(da.alignParagraphCenter)),E.bind(M.R,K.CtrlShift,A(da.alignParagraphRight)),E.bind(M.J,K.CtrlShift,A(da.alignParagraphJustified)),ea&&E.bind(M.C,K.CtrlAlt,ga.addAnnotation),E.bind(M.Z,K.Ctrl,l),E.bind(M.Z,K.CtrlShift,y));V.setDefault(A(function(b){var a;a=null===b.which||void 0===b.which?String.fromCharCode(b.keyCode):0!==b.which&&0!==b.charCode?String.fromCharCode(b.which):null;return!a||b.altKey||b.ctrlKey||b.metaKey?!1:(ha.insertText(a),!0)}));
V.bind(M.Enter,K.None,A(ha.enqueueParagraphSplittingOps))};this.endEditing=function(){ka.unsubscribe(gui.InputMethodEditor.signalCompositionStart,ha.removeCurrentSelection);ka.unsubscribe(gui.InputMethodEditor.signalCompositionEnd,P);L.unsubscribe("cut",p);L.unsubscribe("beforecut",q);L.unsubscribe("paste",h);L.unsubscribe("beforepaste",d);L.setEditing(!1);oa.setModifier(K.None);E.bind(M.Backspace,K.None,function(){return!0},!0);E.unbind(M.Delete,K.None);E.unbind(M.Tab,K.None);ra?(E.unbind(M.Clear,
K.None),E.unbind(M.B,K.Meta),E.unbind(M.I,K.Meta),E.unbind(M.U,K.Meta),E.unbind(M.L,K.MetaShift),E.unbind(M.E,K.MetaShift),E.unbind(M.R,K.MetaShift),E.unbind(M.J,K.MetaShift),ea&&E.unbind(M.C,K.MetaShift),E.unbind(M.Z,K.Meta),E.unbind(M.Z,K.MetaShift)):(E.unbind(M.B,K.Ctrl),E.unbind(M.I,K.Ctrl),E.unbind(M.U,K.Ctrl),E.unbind(M.L,K.CtrlShift),E.unbind(M.E,K.CtrlShift),E.unbind(M.R,K.CtrlShift),E.unbind(M.J,K.CtrlShift),ea&&E.unbind(M.C,K.CtrlAlt),E.unbind(M.Z,K.Ctrl),E.unbind(M.Z,K.CtrlShift));V.setDefault(null);
V.unbind(M.Enter,K.None)};this.getInputMemberId=function(){return a};this.getSession=function(){return k};this.getSessionConstraints=function(){return I};this.setUndoManager=function(b){R&&R.unsubscribe(gui.UndoManager.signalUndoStackChanged,r);if(R=b)R.setDocument(v),R.setPlaybackFunction(k.enqueue),R.subscribe(gui.UndoManager.signalUndoStackChanged,r)};this.getUndoManager=function(){return R};this.getMetadataController=function(){return ua};this.getAnnotationController=function(){return ga};this.getDirectFormattingController=
function(){return da};this.getHyperlinkClickHandler=function(){return oa};this.getHyperlinkController=function(){return qa};this.getImageController=function(){return ma};this.getSelectionController=function(){return X};this.getTextController=function(){return ha};this.getEventManager=function(){return L};this.getKeyboardHandlers=function(){return{keydown:E,keypress:V}};this.destroy=function(b){var a=[ja.destroy,fa.destroy,da.destroy,ka.destroy,L.destroy,oa.destroy,qa.destroy,ua.destroy,X.destroy,
ha.destroy,Y];sa&&a.unshift(sa.destroy);runtime.clearTimeout(aa);core.Async.destroyAll(a,b)};ja=core.Task.createRedrawTask(w);fa=core.Task.createRedrawTask(function(){var b=v.getCursor(a);if(b&&b.getSelectionType()===ops.OdtCursor.RegionSelection&&(b=F.getImageElements(b.getSelectedRange())[0])){la.select(b.parentNode);return}la.clearSelection()});E.bind(M.Left,K.None,A(X.moveCursorToLeft));E.bind(M.Right,K.None,A(X.moveCursorToRight));E.bind(M.Up,K.None,A(X.moveCursorUp));E.bind(M.Down,K.None,A(X.moveCursorDown));
E.bind(M.Left,K.Shift,A(X.extendSelectionToLeft));E.bind(M.Right,K.Shift,A(X.extendSelectionToRight));E.bind(M.Up,K.Shift,A(X.extendSelectionUp));E.bind(M.Down,K.Shift,A(X.extendSelectionDown));E.bind(M.Home,K.None,A(X.moveCursorToLineStart));E.bind(M.End,K.None,A(X.moveCursorToLineEnd));E.bind(M.Home,K.Ctrl,A(X.moveCursorToDocumentStart));E.bind(M.End,K.Ctrl,A(X.moveCursorToDocumentEnd));E.bind(M.Home,K.Shift,A(X.extendSelectionToLineStart));E.bind(M.End,K.Shift,A(X.extendSelectionToLineEnd));E.bind(M.Up,
K.CtrlShift,A(X.extendSelectionToParagraphStart));E.bind(M.Down,K.CtrlShift,A(X.extendSelectionToParagraphEnd));E.bind(M.Home,K.CtrlShift,A(X.extendSelectionToDocumentStart));E.bind(M.End,K.CtrlShift,A(X.extendSelectionToDocumentEnd));ra?(E.bind(M.Left,K.Alt,A(X.moveCursorBeforeWord)),E.bind(M.Right,K.Alt,A(X.moveCursorPastWord)),E.bind(M.Left,K.Meta,A(X.moveCursorToLineStart)),E.bind(M.Right,K.Meta,A(X.moveCursorToLineEnd)),E.bind(M.Home,K.Meta,A(X.moveCursorToDocumentStart)),E.bind(M.End,K.Meta,
A(X.moveCursorToDocumentEnd)),E.bind(M.Left,K.AltShift,A(X.extendSelectionBeforeWord)),E.bind(M.Right,K.AltShift,A(X.extendSelectionPastWord)),E.bind(M.Left,K.MetaShift,A(X.extendSelectionToLineStart)),E.bind(M.Right,K.MetaShift,A(X.extendSelectionToLineEnd)),E.bind(M.Up,K.AltShift,A(X.extendSelectionToParagraphStart)),E.bind(M.Down,K.AltShift,A(X.extendSelectionToParagraphEnd)),E.bind(M.Up,K.MetaShift,A(X.extendSelectionToDocumentStart)),E.bind(M.Down,K.MetaShift,A(X.extendSelectionToDocumentEnd)),
E.bind(M.A,K.Meta,A(X.extendSelectionToEntireDocument))):(E.bind(M.Left,K.Ctrl,A(X.moveCursorBeforeWord)),E.bind(M.Right,K.Ctrl,A(X.moveCursorPastWord)),E.bind(M.Left,K.CtrlShift,A(X.extendSelectionBeforeWord)),E.bind(M.Right,K.CtrlShift,A(X.extendSelectionPastWord)),E.bind(M.A,K.Ctrl,A(X.extendSelectionToEntireDocument)));ta&&(sa=new gui.IOSSafariSupport(L));L.subscribe("keydown",E.handleEvent);L.subscribe("keypress",V.handleEvent);L.subscribe("keyup",$.handleEvent);L.subscribe("copy",g);L.subscribe("mousedown",
s);L.subscribe("mousemove",ja.trigger);L.subscribe("mouseup",J);L.subscribe("contextmenu",B);L.subscribe("dragstart",D);L.subscribe("dragend",G);L.subscribe("click",oa.handleClick);L.subscribe("longpress",C);L.subscribe("drag",t);L.subscribe("dragstop",z);v.subscribe(ops.OdtDocument.signalOperationEnd,fa.trigger);v.subscribe(ops.Document.signalCursorAdded,ka.registerCursor);v.subscribe(ops.Document.signalCursorRemoved,ka.removeCursor);v.subscribe(ops.OdtDocument.signalOperationEnd,b)}})();gui.CaretManager=function(f,k){function a(a){return m.hasOwnProperty(a)?m[a]:null}function e(){return Object.keys(m).map(function(a){return m[a]})}function c(a){var c=m[a];c&&(delete m[a],a===f.getInputMemberId()?(p.unsubscribe(ops.OdtDocument.signalProcessingBatchEnd,c.ensureVisible),p.unsubscribe(ops.Document.signalCursorMoved,c.refreshCursorBlinking),q.unsubscribe("compositionupdate",c.handleUpdate),q.unsubscribe("compositionend",c.handleUpdate),q.unsubscribe("focus",c.setFocus),q.unsubscribe("blur",
c.removeFocus),n.removeEventListener("focus",c.show,!1),n.removeEventListener("blur",c.hide,!1)):p.unsubscribe(ops.OdtDocument.signalProcessingBatchEnd,c.handleUpdate),c.destroy(function(){}))}var m={},n=runtime.getWindow(),p=f.getSession().getOdtDocument(),q=f.getEventManager();this.registerCursor=function(a,c,d){var b=a.getMemberId();a=new gui.Caret(a,k,c,d);m[b]=a;b===f.getInputMemberId()?(runtime.log("Starting to track input on new cursor of "+b),p.subscribe(ops.OdtDocument.signalProcessingBatchEnd,
a.ensureVisible),p.subscribe(ops.Document.signalCursorMoved,a.refreshCursorBlinking),q.subscribe("compositionupdate",a.handleUpdate),q.subscribe("compositionend",a.handleUpdate),q.subscribe("focus",a.setFocus),q.subscribe("blur",a.removeFocus),n.addEventListener("focus",a.show,!1),n.addEventListener("blur",a.hide,!1),a.setOverlayElement(q.getEventTrap())):p.subscribe(ops.OdtDocument.signalProcessingBatchEnd,a.handleUpdate);return a};this.getCaret=a;this.getCarets=e;this.destroy=function(a){var h=
e().map(function(a){return a.destroy});f.getSelectionController().setCaretXPositionLocator(null);p.unsubscribe(ops.Document.signalCursorRemoved,c);m={};core.Async.destroyAll(h,a)};f.getSelectionController().setCaretXPositionLocator(function(){var c=a(f.getInputMemberId()),e;c&&(e=c.getBoundingClientRect());return e?e.right:void 0});p.subscribe(ops.Document.signalCursorRemoved,c)};gui.EditInfoHandle=function(f){var k=[],a,e=f.ownerDocument,c=e.documentElement.namespaceURI;this.setEdits=function(f){k=f;var n,p,q,g;core.DomUtils.removeAllChildNodes(a);for(f=0;f<k.length;f+=1)n=e.createElementNS(c,"div"),n.className="editInfo",p=e.createElementNS(c,"span"),p.className="editInfoColor",p.setAttributeNS("urn:webodf:names:editinfo","editinfo:memberid",k[f].memberid),q=e.createElementNS(c,"span"),q.className="editInfoAuthor",q.setAttributeNS("urn:webodf:names:editinfo","editinfo:memberid",
k[f].memberid),g=e.createElementNS(c,"span"),g.className="editInfoTime",g.setAttributeNS("urn:webodf:names:editinfo","editinfo:memberid",k[f].memberid),g.appendChild(e.createTextNode(k[f].time.toString())),n.appendChild(p),n.appendChild(q),n.appendChild(g),a.appendChild(n)};this.show=function(){a.style.display="block"};this.hide=function(){a.style.display="none"};this.destroy=function(c){f.removeChild(a);c()};a=e.createElementNS(c,"div");a.setAttribute("class","editInfoHandle");a.style.display="none";
f.appendChild(a)};ops.EditInfo=function(f,k){function a(){var a=[],e;for(e in c)c.hasOwnProperty(e)&&a.push({memberid:e,time:c[e].time});a.sort(function(a,c){return a.time-c.time});return a}var e,c={};this.getNode=function(){return e};this.getOdtDocument=function(){return k};this.getEdits=function(){return c};this.getSortedEdits=function(){return a()};this.addEdit=function(a,e){c[a]={time:e}};this.clearEdits=function(){c={}};this.destroy=function(a){f.parentNode&&f.removeChild(e);a()};e=k.getDOMDocument().createElementNS("urn:webodf:names:editinfo",
"editinfo");f.insertBefore(e,f.firstChild)};gui.EditInfoMarker=function(f,k){function a(a,d){return runtime.setTimeout(function(){n.style.opacity=a},d)}var e=this,c,m,n,p,q,g;this.addEdit=function(c,d){var b=Date.now()-d;f.addEdit(c,d);m.setEdits(f.getSortedEdits());n.setAttributeNS("urn:webodf:names:editinfo","editinfo:memberid",c);runtime.clearTimeout(q);runtime.clearTimeout(g);1E4>b?(p=a(1,0),q=a(0.5,1E4-b),g=a(0.2,2E4-b)):1E4<=b&&2E4>b?(p=a(0.5,0),g=a(0.2,2E4-b)):p=a(0.2,0)};this.getEdits=function(){return f.getEdits()};this.clearEdits=
function(){f.clearEdits();m.setEdits([]);n.hasAttributeNS("urn:webodf:names:editinfo","editinfo:memberid")&&n.removeAttributeNS("urn:webodf:names:editinfo","editinfo:memberid")};this.getEditInfo=function(){return f};this.show=function(){n.style.display="block"};this.hide=function(){e.hideHandle();n.style.display="none"};this.showHandle=function(){m.show()};this.hideHandle=function(){m.hide()};this.destroy=function(a){runtime.clearTimeout(p);runtime.clearTimeout(q);runtime.clearTimeout(g);c.removeChild(n);
m.destroy(function(d){d?a(d):f.destroy(a)})};(function(){var a=f.getOdtDocument().getDOMDocument();n=a.createElementNS(a.documentElement.namespaceURI,"div");n.setAttribute("class","editInfoMarker");n.onmouseover=function(){e.showHandle()};n.onmouseout=function(){e.hideHandle()};c=f.getNode();c.appendChild(n);m=new gui.EditInfoHandle(c);k||e.hide()})()};gui.HyperlinkTooltipView=function(f,k){var a=core.DomUtils,e=odf.OdfUtils,c=runtime.getWindow(),m,n,p;runtime.assert(null!==c,"Expected to be run in an environment which has a global window, like a browser.");this.showTooltip=function(q){var g=q.target||q.srcElement,h=f.getSizer(),d=f.getZoomLevel(),b;a:{for(;g;){if(e.isHyperlink(g))break a;if(e.isParagraph(g)||e.isInlineRoot(g))break;g=g.parentNode}g=null}if(g){a.containsNode(h,p)||h.appendChild(p);b=n;var r;switch(k()){case gui.KeyboardHandler.Modifier.Ctrl:r=
runtime.tr("Ctrl-click to follow link");break;case gui.KeyboardHandler.Modifier.Meta:r=runtime.tr("\u2318-click to follow link");break;default:r=""}b.textContent=r;m.textContent=e.getHyperlinkTarget(g);p.style.display="block";b=c.innerWidth-p.offsetWidth-15;g=q.clientX>b?b:q.clientX+15;b=c.innerHeight-p.offsetHeight-10;q=q.clientY>b?b:q.clientY+10;h=h.getBoundingClientRect();g=(g-h.left)/d;q=(q-h.top)/d;p.style.left=g+"px";p.style.top=q+"px"}};this.hideTooltip=function(){p.style.display="none"};this.destroy=
function(a){p.parentNode&&p.parentNode.removeChild(p);a()};(function(){var a=f.getElement().ownerDocument;m=a.createElement("span");n=a.createElement("span");m.className="webodf-hyperlinkTooltipLink";n.className="webodf-hyperlinkTooltipText";p=a.createElement("div");p.className="webodf-hyperlinkTooltip";p.appendChild(m);p.appendChild(n);f.getElement().appendChild(p)})()};gui.OdfFieldView=function(f){function k(){var a=odf.OdfSchema.getFields().map(function(a){return a.replace(":","|")}),e=a.join(",\n")+"\n{ background-color: #D0D0D0; }\n",a=a.map(function(a){return a+":empty::after"}).join(",\n")+"\n{ content:' '; white-space: pre; }\n";return e+"\n"+a}var a,e=f.getElement().ownerDocument;this.showFieldHighlight=function(){a.appendChild(e.createTextNode(k()))};this.hideFieldHighlight=function(){for(var c=a.sheet,e=c.cssRules;e.length;)c.deleteRule(e.length-1)};this.destroy=
function(c){a.parentNode&&a.parentNode.removeChild(a);c()};a=function(){var a=e.getElementsByTagName("head").item(0),f=e.createElement("style"),k="";f.type="text/css";f.media="screen, print, handheld, projection";odf.Namespaces.forEachPrefix(function(a,c){k+="@namespace "+a+" url("+c+");\n"});f.appendChild(e.createTextNode(k));a.appendChild(f);return f}()};gui.ShadowCursor=function(f){var k=f.getDOMDocument().createRange(),a=!0;this.removeFromDocument=function(){};this.getMemberId=function(){return gui.ShadowCursor.ShadowCursorMemberId};this.getSelectedRange=function(){return k};this.setSelectedRange=function(e,c){k=e;a=!1!==c};this.hasForwardSelection=function(){return a};this.getDocument=function(){return f};this.getSelectionType=function(){return ops.OdtCursor.RangeSelection};k.setStart(f.getRootNode(),0)};gui.ShadowCursor.ShadowCursorMemberId="";gui.SelectionView=function(f){};gui.SelectionView.prototype.rerender=function(){};gui.SelectionView.prototype.show=function(){};gui.SelectionView.prototype.hide=function(){};gui.SelectionView.prototype.destroy=function(f){};gui.SelectionViewManager=function(f){function k(){return Object.keys(a).map(function(e){return a[e]})}var a={};this.getSelectionView=function(e){return a.hasOwnProperty(e)?a[e]:null};this.getSelectionViews=k;this.removeSelectionView=function(e){a.hasOwnProperty(e)&&(a[e].destroy(function(){}),delete a[e])};this.hideSelectionView=function(e){a.hasOwnProperty(e)&&a[e].hide()};this.showSelectionView=function(e){a.hasOwnProperty(e)&&a[e].show()};this.rerenderSelectionViews=function(){Object.keys(a).forEach(function(e){a[e].rerender()})};
this.registerCursor=function(e,c){var m=e.getMemberId(),k=new f(e);c?k.show():k.hide();return a[m]=k};this.destroy=function(a){function c(k,p){p?a(p):k<f.length?f[k].destroy(function(a){c(k+1,a)}):a()}var f=k();c(0,void 0)}};gui.SessionViewOptions=function(){this.caretBlinksOnRangeSelect=this.caretAvatarsInitiallyVisible=this.editInfoMarkersInitiallyVisible=!0};
(function(){gui.SessionView=function(f,k,a,e,c,m){function n(b){b.memberId===k&&H.getViewport().scrollIntoView(b.annotation.getBoundingClientRect())}function p(){var b=document.getElementsByTagName("head").item(0),a=document.createElement("style");a.type="text/css";a.media="screen, print, handheld, projection";b.appendChild(a);return a}function q(b,a,d){function c(a,d,e){d=a+'[editinfo|memberid="'+b+'"]'+e+d;a:{var f=w.firstChild;for(a=a+'[editinfo|memberid="'+b+'"]'+e+"{";f;){if(f.nodeType===Node.TEXT_NODE&&
0===f.data.indexOf(a)){a=f;break a}f=f.nextSibling}a=null}a?a.data=d:w.appendChild(document.createTextNode(d))}c("div.editInfoMarker","{ background-color: "+d+"; }","");c("span.editInfoColor","{ background-color: "+d+"; }","");c("span.editInfoAuthor",'{ content: "'+a+'"; }',":before");c("dc|creator","{ background-color: "+d+"; }","");c(".webodf-selectionOverlay","{ fill: "+d+"; stroke: "+d+";}","");b===k&&(c(".webodf-touchEnabled .webodf-selectionOverlay","{ display: block; }"," > .webodf-draggable"),
b=gui.ShadowCursor.ShadowCursorMemberId,c(".webodf-selectionOverlay","{ fill: "+d+"; stroke: "+d+";}",""),c(".webodf-touchEnabled .webodf-selectionOverlay","{ display: block; }"," > .webodf-draggable"))}function g(b){var a,d;for(d in u)u.hasOwnProperty(d)&&(a=u[d],b?a.show():a.hide())}function h(b){c.getCarets().forEach(function(a){b?a.showHandle():a.hideHandle()})}function d(b){var a=b.getMemberId();b=b.getProperties();q(a,b.fullName,b.color)}function b(b){var d=b.getMemberId(),e=a.getOdtDocument().getMember(d).getProperties();
c.registerCursor(b,B,J);m.registerCursor(b,!0);if(b=c.getCaret(d))b.setAvatarImageUrl(e.imageUrl),b.setColor(e.color);runtime.log("+++ View here +++ eagerly created an Caret for '"+d+"'! +++")}function r(b){b=b.getMemberId();var a=m.getSelectionView(k),d=m.getSelectionView(gui.ShadowCursor.ShadowCursorMemberId),e=c.getCaret(k);b===k?(d.hide(),a&&a.show(),e&&e.show()):b===gui.ShadowCursor.ShadowCursorMemberId&&(d.show(),a&&a.hide(),e&&e.hide())}function l(b){m.removeSelectionView(b)}function y(b){var d=
b.paragraphElement,c=b.memberId;b=b.timeStamp;var e,f="",g=d.getElementsByTagNameNS(x,"editinfo").item(0);g?(f=g.getAttributeNS(x,"id"),e=u[f]):(f=Math.random().toString(),e=new ops.EditInfo(d,a.getOdtDocument()),e=new gui.EditInfoMarker(e,G),g=d.getElementsByTagNameNS(x,"editinfo").item(0),g.setAttributeNS(x,"id",f),u[f]=e);e.addEdit(c,new Date(b));D.trigger()}function t(){var b;s.hasChildNodes()&&core.DomUtils.removeAllChildNodes(s);!0===e.getState(gui.CommonConstraints.EDIT.ANNOTATIONS.ONLY_DELETE_OWN)&&
(b=a.getOdtDocument().getMember(k))&&(b=b.getProperties().fullName,s.appendChild(document.createTextNode(".annotationWrapper:not([creator = '"+b+"']) .annotationRemoveButton { display: none; }")))}function z(a){var c=Object.keys(u).map(function(b){return u[b]});C.unsubscribe(ops.Document.signalMemberAdded,d);C.unsubscribe(ops.Document.signalMemberUpdated,d);C.unsubscribe(ops.Document.signalCursorAdded,b);C.unsubscribe(ops.Document.signalCursorRemoved,l);C.unsubscribe(ops.OdtDocument.signalParagraphChanged,
y);C.unsubscribe(ops.Document.signalCursorMoved,r);C.unsubscribe(ops.OdtDocument.signalParagraphChanged,m.rerenderSelectionViews);C.unsubscribe(ops.OdtDocument.signalTableAdded,m.rerenderSelectionViews);C.unsubscribe(ops.OdtDocument.signalParagraphStyleModified,m.rerenderSelectionViews);e.unsubscribe(gui.CommonConstraints.EDIT.ANNOTATIONS.ONLY_DELETE_OWN,t);C.unsubscribe(ops.Document.signalMemberAdded,t);C.unsubscribe(ops.Document.signalMemberUpdated,t);w.parentNode.removeChild(w);s.parentNode.removeChild(s);
(function Y(b,d){d?a(d):b<c.length?c[b].destroy(function(a){Y(b+1,a)}):a()})(0,void 0)}var w,s,x="urn:webodf:names:editinfo",u={},C,H,D,G=void 0!==f.editInfoMarkersInitiallyVisible?Boolean(f.editInfoMarkersInitiallyVisible):!0,B=void 0!==f.caretAvatarsInitiallyVisible?Boolean(f.caretAvatarsInitiallyVisible):!0,J=void 0!==f.caretBlinksOnRangeSelect?Boolean(f.caretBlinksOnRangeSelect):!0;this.showEditInfoMarkers=function(){G||(G=!0,g(G))};this.hideEditInfoMarkers=function(){G&&(G=!1,g(G))};this.showCaretAvatars=
function(){B||(B=!0,h(B))};this.hideCaretAvatars=function(){B&&(B=!1,h(B))};this.getSession=function(){return a};this.getCaret=function(b){return c.getCaret(b)};this.destroy=function(b){var a=[D.destroy,z];C.unsubscribe(ops.OdtDocument.signalAnnotationAdded,n);core.Async.destroyAll(a,b)};C=a.getOdtDocument();H=C.getOdfCanvas();C.subscribe(ops.OdtDocument.signalAnnotationAdded,n);C.subscribe(ops.Document.signalMemberAdded,d);C.subscribe(ops.Document.signalMemberUpdated,d);C.subscribe(ops.Document.signalCursorAdded,
b);C.subscribe(ops.Document.signalCursorRemoved,l);C.subscribe(ops.OdtDocument.signalParagraphChanged,y);C.subscribe(ops.Document.signalCursorMoved,r);C.subscribe(ops.OdtDocument.signalParagraphChanged,m.rerenderSelectionViews);C.subscribe(ops.OdtDocument.signalTableAdded,m.rerenderSelectionViews);C.subscribe(ops.OdtDocument.signalParagraphStyleModified,m.rerenderSelectionViews);e.subscribe(gui.CommonConstraints.EDIT.ANNOTATIONS.ONLY_DELETE_OWN,t);C.subscribe(ops.Document.signalMemberAdded,t);C.subscribe(ops.Document.signalMemberUpdated,
t);w=p();w.appendChild(document.createTextNode("@namespace editinfo url(urn:webodf:names:editinfo);"));w.appendChild(document.createTextNode("@namespace dc url(http://purl.org/dc/elements/1.1/);"));s=p();t();D=core.Task.createRedrawTask(function(){var b=H.getAnnotationViewManager();b&&(b.rehighlightAnnotations(),C.fixCursorPositions())})}})();gui.SvgSelectionView=function(f){function k(){var a=b.getRootNode();r!==a&&(r=a,l=b.getCanvas().getSizer(),l.appendChild(t),t.setAttribute("class","webodf-selectionOverlay"),w.setAttribute("class","webodf-draggable"),s.setAttribute("class","webodf-draggable"),w.setAttribute("end","left"),s.setAttribute("end","right"),w.setAttribute("r",8),s.setAttribute("r",8),t.appendChild(z),t.appendChild(w),t.appendChild(s))}function a(b){b=b.getBoundingClientRect();return Boolean(b&&0!==b.height)}function e(b){var d=
x.getTextElements(b,!0,!1),c=b.cloneRange(),e=b.cloneRange();b=b.cloneRange();if(!d.length)return null;var f;a:{f=0;var g=d[f],l=c.startContainer===g?c.startOffset:0,h=l;c.setStart(g,l);for(c.setEnd(g,h);!a(c);){if(g.nodeType===Node.ELEMENT_NODE&&h<g.childNodes.length)h=g.childNodes.length;else if(g.nodeType===Node.TEXT_NODE&&h<g.length)h+=1;else if(d[f])g=d[f],f+=1,l=h=0;else{f=!1;break a}c.setStart(g,l);c.setEnd(g,h)}f=!0}if(!f)return null;a:{f=d.length-1;g=d[f];h=l=e.endContainer===g?e.endOffset:
g.nodeType===Node.TEXT_NODE?g.length:g.childNodes.length;e.setStart(g,l);for(e.setEnd(g,h);!a(e);){if(g.nodeType===Node.ELEMENT_NODE&&0<l)l=0;else if(g.nodeType===Node.TEXT_NODE&&0<l)l-=1;else if(d[f])g=d[f],f-=1,l=h=g.length||g.childNodes.length;else{d=!1;break a}e.setStart(g,l);e.setEnd(g,h)}d=!0}if(!d)return null;b.setStart(c.startContainer,c.startOffset);b.setEnd(e.endContainer,e.endOffset);return{firstRange:c,lastRange:e,fillerRange:b}}function c(b,a){var d={};d.top=Math.min(b.top,a.top);d.left=
Math.min(b.left,a.left);d.right=Math.max(b.right,a.right);d.bottom=Math.max(b.bottom,a.bottom);d.width=d.right-d.left;d.height=d.bottom-d.top;return d}function m(b,a){a&&0<a.width&&0<a.height&&(b=b?c(b,a):a);return b}function n(a){function d(b){D.setUnfilteredPosition(b,0);return t.acceptNode(b)===G&&s.acceptPosition(D)===G?G:B}function c(b){var a=null;d(b)===G&&(a=u.getBoundingClientRect(b));return a}var e=a.commonAncestorContainer,f=a.startContainer,g=a.endContainer,l=a.startOffset,h=a.endOffset,
k,n,r=null,p,q=y.createRange(),s,t=new odf.OdfNodeFilter,w;if(f===e||g===e)return q=a.cloneRange(),r=q.getBoundingClientRect(),q.detach(),r;for(a=f;a.parentNode!==e;)a=a.parentNode;for(n=g;n.parentNode!==e;)n=n.parentNode;s=b.createRootFilter(f);for(e=a.nextSibling;e&&e!==n;)p=c(e),r=m(r,p),e=e.nextSibling;if(x.isParagraph(a))r=m(r,u.getBoundingClientRect(a));else if(a.nodeType===Node.TEXT_NODE)e=a,q.setStart(e,l),q.setEnd(e,e===n?h:e.length),p=q.getBoundingClientRect(),r=m(r,p);else for(w=y.createTreeWalker(a,
NodeFilter.SHOW_TEXT,d,!1),e=w.currentNode=f;e&&e!==g;)q.setStart(e,l),q.setEnd(e,e.length),p=q.getBoundingClientRect(),r=m(r,p),k=e,l=0,e=w.nextNode();k||(k=f);if(x.isParagraph(n))r=m(r,u.getBoundingClientRect(n));else if(n.nodeType===Node.TEXT_NODE)e=n,q.setStart(e,e===a?l:0),q.setEnd(e,h),p=q.getBoundingClientRect(),r=m(r,p);else for(w=y.createTreeWalker(n,NodeFilter.SHOW_TEXT,d,!1),e=w.currentNode=g;e&&e!==k;)if(q.setStart(e,0),q.setEnd(e,h),p=q.getBoundingClientRect(),r=m(r,p),e=w.previousNode())h=
e.length;return r}function p(b,a){var d=b.getBoundingClientRect(),c={width:0};c.top=d.top;c.bottom=d.bottom;c.height=d.height;c.left=c.right=a?d.right:d.left;return c}function q(){var b=f.getSelectedRange(),a;if(a=H&&f.getSelectionType()===ops.OdtCursor.RangeSelection&&!b.collapsed){k();var d=u.getBoundingClientRect(l),g=C.getZoomLevel(),b=e(b),h,m,r,q,y,x;if(b){a=b.firstRange;h=b.lastRange;m=b.fillerRange;r=u.translateRect(p(a,!1),d,g);y=u.translateRect(p(h,!0),d,g);q=(q=n(m))?u.translateRect(q,
d,g):c(r,y);x=q.left;q=r.left+Math.max(0,q.width-(r.left-q.left));d=Math.min(r.top,y.top);g=y.top+y.height;x=[{x:r.left,y:d+r.height},{x:r.left,y:d},{x:q,y:d},{x:q,y:g-y.height},{x:y.right,y:g-y.height},{x:y.right,y:g},{x:x,y:g},{x:x,y:d+r.height},{x:r.left,y:d+r.height}];q="";var D;for(D=0;D<x.length;D+=1)q+=x[D].x+","+x[D].y+" ";z.setAttribute("points",q);w.setAttribute("cx",r.left);w.setAttribute("cy",d+r.height/2);s.setAttribute("cx",y.right);s.setAttribute("cy",g-y.height/2);a.detach();h.detach();
m.detach()}a=Boolean(b)}t.style.display=a?"block":"none"}function g(b){H&&b===f&&J.trigger()}function h(b){b=8/b;w.setAttribute("r",b);s.setAttribute("r",b)}function d(b){l.removeChild(t);l.classList.remove("webodf-virtualSelections");f.getDocument().unsubscribe(ops.Document.signalCursorMoved,g);C.unsubscribe(gui.ZoomHelper.signalZoomChanged,h);b()}var b=f.getDocument(),r,l,y=b.getDOMDocument(),t=y.createElementNS("http://www.w3.org/2000/svg","svg"),z=y.createElementNS("http://www.w3.org/2000/svg",
"polygon"),w=y.createElementNS("http://www.w3.org/2000/svg","circle"),s=y.createElementNS("http://www.w3.org/2000/svg","circle"),x=odf.OdfUtils,u=core.DomUtils,C=b.getCanvas().getZoomHelper(),H=!0,D=f.getDocument().createPositionIterator(b.getRootNode()),G=NodeFilter.FILTER_ACCEPT,B=NodeFilter.FILTER_REJECT,J;this.rerender=function(){H&&J.trigger()};this.show=function(){H=!0;J.trigger()};this.hide=function(){H=!1;J.trigger()};this.destroy=function(b){core.Async.destroyAll([J.destroy,d],b)};(function(){var b=
f.getMemberId();J=core.Task.createRedrawTask(q);k();t.setAttributeNS("urn:webodf:names:editinfo","editinfo:memberid",b);l.classList.add("webodf-virtualSelections");f.getDocument().subscribe(ops.Document.signalCursorMoved,g);C.subscribe(gui.ZoomHelper.signalZoomChanged,h);h(C.getZoomLevel())})()};gui.UndoStateRules=function(){function f(a,e){var f=a.length;this.previous=function(){for(f-=1;0<=f;f-=1)if(e(a[f]))return a[f];return null}}function k(a){a=a.spec();var e;a.hasOwnProperty("position")&&(e=a.position);return e}function a(a){return a.isEdit}function e(a,e,f){if(!f)return f=k(a)-k(e),0===f||1===Math.abs(f);a=k(a);e=k(e);f=k(f);return a-e===e-f}this.isEditOperation=a;this.isPartOfOperationSet=function(c,m){var k=void 0!==c.group,p;if(!c.isEdit||0===m.length)return!0;p=m[m.length-1];if(k&&
c.group===p.group)return!0;a:switch(c.spec().optype){case "RemoveText":case "InsertText":p=!0;break a;default:p=!1}if(p&&m.some(a)){if(k){var q;k=c.spec().optype;p=new f(m,a);var g=p.previous(),h=null,d,b;runtime.assert(Boolean(g),"No edit operations found in state");b=g.group;runtime.assert(void 0!==b,"Operation has no group");for(d=1;g&&g.group===b;){if(k===g.spec().optype){q=g;break}g=p.previous()}if(q){for(g=p.previous();g;){if(g.group!==b){if(2===d)break;b=g.group;d+=1}if(k===g.spec().optype){h=
g;break}g=p.previous()}q=e(c,q,h)}else q=!1;return q}q=c.spec().optype;k=new f(m,a);p=k.previous();runtime.assert(Boolean(p),"No edit operations found in state");q=q===p.spec().optype?e(c,p,k.previous()):!1;return q}return!1}};(function(){function f(a,c){this.mainId=void 0!==a?a:-1;this.subId=void 0!==c?c:-1}function k(e,c,k){function n(a,d){return a+(e.isEditOperation(d)?1:0)}var p,q,g;this.addOperation=function(a){e.isEditOperation(a)&&(g+=1);q.push(a)};this.isNextStateId=function(a){return a.mainId===p&&a.subId===g};this.getNextStateId=function(){return new f(p,g)};this.getOperations=function(){return q};p=a+=1;q=c||[];g=c&&k?c.reduce(n,0):0}var a=0;gui.TrivialUndoManager=function(a){function c(){return!0!==u.isNextStateId(x)}
function m(b){b=b.getOperations();0<b.length&&(B=!0,w(b),B=!1)}function n(){D.emit(gui.UndoManager.signalUndoStackChanged,{undoAvailable:r.hasUndoStates(),redoAvailable:r.hasRedoStates()})}function p(b){var a=c();b!==a&&D.emit(gui.UndoManager.signalDocumentModifiedChanged,a)}function q(){u!==z&&u!==C[C.length-1]&&C.push(u)}function g(b){var a=b.previousSibling||b.nextSibling;b.parentNode.removeChild(b);y.normalizeTextNodes(a)}function h(b){return Object.keys(b).map(function(a){return b[a]})}function d(b){function a(b){var g=
b.spec();if(e[g.memberid])switch(g.optype){case "AddCursor":d[g.memberid]||(d[g.memberid]=b,delete e[g.memberid],f-=1);break;case "MoveCursor":c[g.memberid]||(c[g.memberid]=b)}}var d={},c={},e={},f,g;g=b.pop();s.getMemberIds().forEach(function(b){e[b]=!0});for(f=Object.keys(e).length;g&&0<f;)g=g.getOperations(),g.reverse(),g.forEach(a),g=b.pop();return new k(G,h(d).concat(h(c)))}function b(){var b=c(),a=t=s.cloneDocumentElement();y.getElementsByTagNameNS(a,l,"cursor").forEach(g);y.getElementsByTagNameNS(a,
l,"anchor").forEach(g);q();u=z=d([z].concat(C));C.length=0;H.length=0;b||(x=u.getNextStateId());n();p(b)}var r=this,l="urn:webodf:names:cursor",y=core.DomUtils,t,z,w,s,x,u,C=[],H=[],D=new core.EventNotifier([gui.UndoManager.signalUndoStackChanged,gui.UndoManager.signalUndoStateCreated,gui.UndoManager.signalUndoStateModified,gui.UndoManager.signalDocumentModifiedChanged,gui.TrivialUndoManager.signalDocumentRootReplaced]),G=a||new gui.UndoStateRules,B=!1;this.subscribe=function(b,a){D.subscribe(b,a)};
this.unsubscribe=function(b,a){D.unsubscribe(b,a)};this.isDocumentModified=c;this.setDocumentModified=function(b){c()!==b&&(x=b?new f:u.getNextStateId(),D.emit(gui.UndoManager.signalDocumentModifiedChanged,b))};this.hasUndoStates=function(){return 0<C.length};this.hasRedoStates=function(){return 0<H.length};this.setDocument=function(b){s=b};this.purgeInitialState=function(){var b=c();C.length=0;H.length=0;u=z=new k(G);x=u.getNextStateId();t=null;n();p(b)};this.setInitialState=b;this.initialize=function(){t||
b()};this.setPlaybackFunction=function(b){w=b};this.onOperationExecuted=function(b){if(!B){var a=c();G.isEditOperation(b)&&(u===z||0<H.length)||!G.isPartOfOperationSet(b,u.getOperations())?(H.length=0,q(),u=new k(G,[b],!0),C.push(u),D.emit(gui.UndoManager.signalUndoStateCreated,{operations:u.getOperations()}),n()):(u.addOperation(b),D.emit(gui.UndoManager.signalUndoStateModified,{operations:u.getOperations()}));p(a)}};this.moveForward=function(b){for(var a=0,d=c(),e;b&&H.length;)e=H.pop(),C.push(e),
m(e),b-=1,a+=1;a&&(u=C[C.length-1],n(),p(d));return a};this.moveBackward=function(b){for(var a=0,d=c();b&&C.length;)H.push(C.pop()),b-=1,a+=1;a&&(s.getMemberIds().forEach(function(b){s.removeCursor(b)}),s.setDocumentElement(t.cloneNode(!0)),D.emit(gui.TrivialUndoManager.signalDocumentRootReplaced,{}),m(z),C.forEach(m),u=C[C.length-1]||z,n(),p(d));return a};u=z=new k(G);x=u.getNextStateId()};gui.TrivialUndoManager.signalDocumentRootReplaced="documentRootReplaced"})();odf.GraphicProperties=function(f,k,a){var e=this,c=odf.Namespaces.stylens,m=odf.Namespaces.svgns;this.verticalPos=function(){return e.data.value("verticalPos")};this.verticalRel=function(){return e.data.value("verticalRel")};this.horizontalPos=function(){return e.data.value("horizontalPos")};this.horizontalRel=function(){return e.data.value("horizontalRel")};this.strokeWidth=function(){return e.data.value("strokeWidth")};e.data=new odf.LazyStyleProperties(void 0===a?void 0:a.data,{verticalPos:function(){var a=
f.getAttributeNS(c,"vertical-pos");return""===a?void 0:a},verticalRel:function(){var a=f.getAttributeNS(c,"vertical-rel");return""===a?void 0:a},horizontalPos:function(){var a=f.getAttributeNS(c,"horizontal-pos");return""===a?void 0:a},horizontalRel:function(){var a=f.getAttributeNS(c,"horizontal-rel");return""===a?void 0:a},strokeWidth:function(){var a=f.getAttributeNS(m,"stroke-width");return k.parseLength(a)}})};
odf.ComputedGraphicProperties=function(){var f;this.setGraphicProperties=function(k){f=k};this.verticalPos=function(){return f&&f.verticalPos()||"from-top"};this.verticalRel=function(){return f&&f.verticalRel()||"page"};this.horizontalPos=function(){return f&&f.horizontalPos()||"from-left"};this.horizontalRel=function(){return f&&f.horizontalRel()||"page"}};odf.PageLayoutProperties=function(f,k,a){var e=this,c=odf.Namespaces.fons;this.pageHeight=function(){return e.data.value("pageHeight")||1123};this.pageWidth=function(){return e.data.value("pageWidth")||794};e.data=new odf.LazyStyleProperties(void 0===a?void 0:a.data,{pageHeight:function(){var a;f&&(a=f.getAttributeNS(c,"page-height"),a=k.parseLength(a));return a},pageWidth:function(){var a;f&&(a=f.getAttributeNS(c,"page-width"),a=k.parseLength(a));return a}})};
odf.PageLayout=function(f,k,a){var e=null;f&&(e=k.getPropertiesElement("page-layout-properties",f));this.pageLayout=new odf.PageLayoutProperties(e,k,a&&a.pageLayout)};odf.PageLayoutCache=function(){};odf.PageLayoutCache.prototype.getPageLayout=function(f){};odf.PageLayoutCache.prototype.getDefaultPageLayout=function(){};odf.ParagraphProperties=function(f,k,a){var e=this,c=odf.Namespaces.fons;this.marginTop=function(){return e.data.value("marginTop")};e.data=new odf.LazyStyleProperties(void 0===a?void 0:a.data,{marginTop:function(){var e=f.getAttributeNS(c,"margin-top");return k.parsePositiveLengthOrPercent(e,"marginTop",a&&a.data)}})};
odf.ComputedParagraphProperties=function(){var f={},k=[];this.setStyleChain=function(a){k=a;f={}};this.marginTop=function(){var a,e;if(f.hasOwnProperty("marginTop"))a=f.marginTop;else{for(e=0;void 0===a&&e<k.length;e+=1)a=k[e].marginTop();f.marginTop=a}return a||0}};odf.TextProperties=function(f,k,a){var e=this,c=odf.Namespaces.fons;this.fontSize=function(){return e.data.value("fontSize")};e.data=new odf.LazyStyleProperties(void 0===a?void 0:a.data,{fontSize:function(){var e=f.getAttributeNS(c,"font-size");return k.parsePositiveLengthOrPercent(e,"fontSize",a&&a.data)}})};
odf.ComputedTextProperties=function(){var f={},k=[];this.setStyleChain=function(a){k=a;f={}};this.fontSize=function(){var a,e;if(f.hasOwnProperty("fontSize"))a=f.fontSize;else{for(e=0;void 0===a&&e<k.length;e+=1)a=k[e].fontSize();f.fontSize=a}return a||12}};odf.MasterPage=function(f,k){var a;f?(a=f.getAttributeNS(odf.Namespaces.stylens,"page-layout-name"),this.pageLayout=k.getPageLayout(a)):this.pageLayout=k.getDefaultPageLayout()};odf.MasterPageCache=function(){};odf.MasterPageCache.prototype.getMasterPage=function(f){};
odf.StylePileEntry=function(f,k,a,e){this.masterPage=function(){var c=f.getAttributeNS(odf.Namespaces.stylens,"master-page-name"),e=null;c&&(e=a.getMasterPage(c));return e};(function(a){var m=f.getAttributeNS(odf.Namespaces.stylens,"family"),n=null;if("graphic"===m||"chart"===m)a.graphic=void 0===e?void 0:e.graphic,n=k.getPropertiesElement("graphic-properties",f,n),null!==n&&(a.graphic=new odf.GraphicProperties(n,k,a.graphic));if("paragraph"===m||"table-cell"===m||"graphic"===m||"presentation"===
m||"chart"===m)a.paragraph=void 0===e?void 0:e.paragraph,n=k.getPropertiesElement("paragraph-properties",f,n),null!==n&&(a.paragraph=new odf.ParagraphProperties(n,k,a.paragraph));if("text"===m||"paragraph"===m||"table-cell"===m||"graphic"===m||"presentation"===m||"chart"===m)a.text=void 0===e?void 0:e.text,n=k.getPropertiesElement("text-properties",f,n),null!==n&&(a.text=new odf.TextProperties(n,k,a.text))})(this)};
odf.StylePile=function(f,k){function a(a,d){var b,c;a.hasAttributeNS(e,"parent-style-name")&&(c=a.getAttributeNS(e,"parent-style-name"),-1===d.indexOf(c)&&(b=g(c,d)));return new odf.StylePileEntry(a,f,k,b)}var e=odf.Namespaces.stylens,c={},m={},n,p={},q={},g;g=function(e,d){var b=p[e],f;!b&&(f=c[e])&&(d.push(e),b=a(f,d),p[e]=b);return b};this.getStyle=function(e){var d=q[e]||p[e],b,f=[];d||(b=m[e],b||(b=c[e])&&f.push(e),b&&(d=a(b,f)));return d};this.addCommonStyle=function(a){var d;a.hasAttributeNS(e,
"name")&&(d=a.getAttributeNS(e,"name"),c.hasOwnProperty(d)||(c[d]=a))};this.addAutomaticStyle=function(a){var d;a.hasAttributeNS(e,"name")&&(d=a.getAttributeNS(e,"name"),m.hasOwnProperty(d)||(m[d]=a))};this.setDefaultStyle=function(c){void 0===n&&(n=a(c,[]))};this.getDefaultStyle=function(){return n}};odf.ComputedGraphicStyle=function(){this.text=new odf.ComputedTextProperties;this.paragraph=new odf.ComputedParagraphProperties;this.graphic=new odf.ComputedGraphicProperties};
odf.ComputedParagraphStyle=function(){this.text=new odf.ComputedTextProperties;this.paragraph=new odf.ComputedParagraphProperties};odf.ComputedTextStyle=function(){this.text=new odf.ComputedTextProperties};
odf.StyleCache=function(f){function k(b,a,d,c){a=d.getAttributeNS(a,"class-names");var e;if(a)for(a=a.split(" "),e=0;e<a.length;e+=1)if(d=a[e])c.push(b),c.push(d)}function a(b,a){var d=t.getStyleName("paragraph",b);void 0!==d&&(a.push("paragraph"),a.push(d));b.namespaceURI!==l||"h"!==b.localName&&"p"!==b.localName||k("paragraph",l,b,a);return a}function e(b,a,d){var c=[],e,f,g,l;for(e=0;e<b.length;e+=2)g=b[e],l=b[e+1],g=p[g],l=g.getStyle(l),void 0!==l&&(l=l[a],void 0!==l&&l!==f&&(c.push(l),f=l));
g=p[d];if(l=g.getDefaultStyle())l=l[a],void 0!==l&&l!==f&&c.push(l);return c}function c(b,d){var e=t.getStyleName("text",b),g=b.parentNode;void 0!==e&&(d.push("text"),d.push(e));"span"===b.localName&&b.namespaceURI===l&&k("text",l,b,d);if(!g||g===f)return d;g.namespaceURI!==l||"p"!==g.localName&&"h"!==g.localName?c(g,d):a(g,d);return d}function m(b){b=b.getAttributeNS(y,"family");return p[b]}var n=this,p,q,g,h,d,b,r,l=odf.Namespaces.textns,y=odf.Namespaces.stylens,t=new odf.StyleInfo,z=new odf.StyleParseUtils,
w,s,x,u,C,H;this.getComputedGraphicStyle=function(b){var a=[];b=t.getStyleName("graphic",b);void 0!==b&&(a.push("graphic"),a.push(b));b=a.join("/");var d=h[b];runtime.assert(0===a.length%2,"Invalid style chain.");void 0===d&&(d=new odf.ComputedGraphicStyle,d.graphic.setGraphicProperties(e(a,"graphic","graphic")[0]),d.text.setStyleChain(e(a,"text","graphic")),d.paragraph.setStyleChain(e(a,"paragraph","graphic")),h[b]=d);return d};this.getComputedParagraphStyle=function(b){b=a(b,[]);var d=b.join("/"),
c=g[d];runtime.assert(0===b.length%2,"Invalid style chain.");void 0===c&&(c=new odf.ComputedParagraphStyle,c.text.setStyleChain(e(b,"text","paragraph")),c.paragraph.setStyleChain(e(b,"paragraph","paragraph")),g[d]=c);return c};this.getComputedTextStyle=function(b){b=c(b,[]);var a=b.join("/"),d=q[a];runtime.assert(0===b.length%2,"Invalid style chain.");void 0===d&&(d=new odf.ComputedTextStyle,d.text.setStyleChain(e(b,"text","text")),q[a]=d);return d};this.getPageLayout=function(b){var a=H[b];a||((a=
C[b])?(a=new odf.PageLayout(a,z,u),H[b]=a):a=u);return a};this.getDefaultPageLayout=function(){return u};this.getMasterPage=function(b){var a=s[b];void 0===a&&((a=w[b])?(a=new odf.MasterPage(a,n),s[b]=a):a=null);return a};this.getDefaultMasterPage=function(){return x};this.update=function(){var a,c,e=null,l=null;q={};g={};h={};w={};s={};H={};C={};d=new odf.StylePile(z,n);b=new odf.StylePile(z,n);r=new odf.StylePile(z,n);p={text:d,paragraph:b,graphic:r};for(a=f.styles.firstElementChild;a;)a.namespaceURI===
y&&((c=m(a))?"style"===a.localName?c.addCommonStyle(a):"default-style"===a.localName&&c.setDefaultStyle(a):"default-page-layout"===a.localName&&(e=a)),a=a.nextElementSibling;u=new odf.PageLayout(e,z);for(a=f.automaticStyles.firstElementChild;a;)a.namespaceURI===y&&((c=m(a))&&"style"===a.localName?c.addAutomaticStyle(a):"page-layout"===a.localName&&(C[a.getAttributeNS(y,"name")]=a)),a=a.nextElementSibling;for(a=f.masterStyles.firstElementChild;a;)a.namespaceURI===y&&"master-page"===a.localName&&(l=
l||a,c=a,e=c.getAttributeNS(y,"name"),0<e.length&&!w.hasOwnProperty(e)&&(w[e]=c)),a=a.nextElementSibling;x=new odf.MasterPage(l,n)}};ops.OperationTransformMatrix=function(){function f(a){a.position+=a.length;a.length*=-1}function k(a){var b=0>a.length;b&&f(a);return b}function a(a,b){function c(f){a[f]===b&&e.push(f)}var e=[];a&&["style:parent-style-name","style:next-style-name"].forEach(c);return e}function e(a,b){function c(e){a[e]===b&&delete a[e]}a&&["style:parent-style-name","style:next-style-name"].forEach(c)}function c(a){var b={};Object.keys(a).forEach(function(e){b[e]="object"===typeof a[e]?c(a[e]):a[e]});return b}function m(a,
b,c,e){var f,g=!1,h=!1,k,m=[];e&&e.attributes&&(m=e.attributes.split(","));a&&(c||0<m.length)&&Object.keys(a).forEach(function(b){var e=a[b],f;"object"!==typeof e&&(c&&(f=c[b]),void 0!==f?(delete a[b],h=!0,f===e&&(delete c[b],g=!0)):-1!==m.indexOf(b)&&(delete a[b],h=!0))});if(b&&b.attributes&&(c||0<m.length)){k=b.attributes.split(",");for(e=0;e<k.length;e+=1)if(f=k[e],c&&void 0!==c[f]||m&&-1!==m.indexOf(f))k.splice(e,1),e-=1,h=!0;0<k.length?b.attributes=k.join(","):delete b.attributes}return{majorChanged:g,
minorChanged:h}}function n(a){for(var b in a)if(a.hasOwnProperty(b))return!0;return!1}function p(a){for(var b in a)if(a.hasOwnProperty(b)&&("attributes"!==b||0<a.attributes.length))return!0;return!1}function q(a,b,c,e,f){var g=a?a[f]:null,h=b?b[f]:null,k=c?c[f]:null,q=e?e[f]:null,x;x=m(g,h,k,q);g&&!n(g)&&delete a[f];h&&!p(h)&&delete b[f];k&&!n(k)&&delete c[f];q&&!p(q)&&delete e[f];return x}function g(a,b){return{opSpecsA:[a],opSpecsB:[b]}}var h;h={AddAnnotation:{AddAnnotation:function(a,b,c){var e;
a.position<b.position?(e=a,c=b):b.position<a.position?(e=b,c=a):(e=c?a:b,c=c?b:a);c.position<e.position+e.length&&(e.length+=2);c.position+=2;return{opSpecsA:[a],opSpecsB:[b]}},AddCursor:g,AddMember:g,AddStyle:g,ApplyDirectStyling:function(a,b){a.position<=b.position?b.position+=2:a.position<=b.position+b.length&&(b.length+=2);return{opSpecsA:[a],opSpecsB:[b]}},InsertText:function(a,b){b.position<=a.position?a.position+=b.text.length:(void 0!==a.length&&b.position<=a.position+a.length&&(a.length+=
b.text.length),b.position+=2);return{opSpecsA:[a],opSpecsB:[b]}},MergeParagraph:function(a,b){b.sourceStartPosition<=a.position?a.position-=1:(void 0!==a.length&&b.sourceStartPosition<=a.position+a.length&&(a.length-=1),b.sourceStartPosition+=2,a.position<b.destinationStartPosition&&(b.destinationStartPosition+=2));return{opSpecsA:[a],opSpecsB:[b]}},MoveCursor:function(a,b){var c=k(b);a.position<b.position?b.position+=2:a.position<b.position+b.length&&(b.length+=2);c&&f(b);return{opSpecsA:[a],opSpecsB:[b]}},
RemoveAnnotation:function(a,b){a.position<b.position?(b.position<a.position+a.length&&(a.length-=b.length+2),b.position+=2):a.position-=b.length+2;return{opSpecsA:[a],opSpecsB:[b]}},RemoveCursor:g,RemoveMember:g,RemoveStyle:g,RemoveText:function(a,b){var c=b.position,e=b.position+b.length,f,g=[a],h=[b];a.position<=b.position?b.position+=2:a.position<e&&(b.length=a.position-b.position,f={optype:"RemoveText",memberid:b.memberid,timestamp:b.timestamp,position:a.position+2,length:e-a.position},h.unshift(f));
b.position+b.length<=a.position?(a.position-=b.length,void 0!==a.length&&f&&(a.length=f.length>=a.length?0:a.length-f.length)):void 0!==a.length&&(f=a.position+a.length,e<=f?a.length-=b.length:c<f&&(a.length=c-a.position));return{opSpecsA:g,opSpecsB:h}},SetParagraphStyle:function(a,b){a.position<b.position&&(b.position+=2);return{opSpecsA:[a],opSpecsB:[b]}},SplitParagraph:function(a,b){a.position<b.sourceParagraphPosition&&(b.sourceParagraphPosition+=2);b.position<=a.position?a.position+=1:(void 0!==
a.length&&b.position<=a.position+a.length&&(a.length+=1),b.position+=2);return{opSpecsA:[a],opSpecsB:[b]}},UpdateMember:g,UpdateMetadata:g,UpdateParagraphStyle:g},AddCursor:{AddCursor:g,AddMember:g,AddStyle:g,ApplyDirectStyling:g,InsertText:g,MergeParagraph:g,MoveCursor:g,RemoveAnnotation:g,RemoveCursor:g,RemoveMember:g,RemoveStyle:g,RemoveText:g,SetParagraphStyle:g,SplitParagraph:g,UpdateMember:g,UpdateMetadata:g,UpdateParagraphStyle:g},AddMember:{AddStyle:g,ApplyDirectStyling:g,InsertText:g,MergeParagraph:g,
MoveCursor:g,RemoveAnnotation:g,RemoveCursor:g,RemoveStyle:g,RemoveText:g,SetParagraphStyle:g,SplitParagraph:g,UpdateMetadata:g,UpdateParagraphStyle:g},AddStyle:{AddStyle:g,ApplyDirectStyling:g,InsertText:g,MergeParagraph:g,MoveCursor:g,RemoveAnnotation:g,RemoveCursor:g,RemoveMember:g,RemoveStyle:function(d,b){var c,f=[d],g=[b];d.styleFamily===b.styleFamily&&(c=a(d.setProperties,b.styleName),0<c.length&&(c={optype:"UpdateParagraphStyle",memberid:b.memberid,timestamp:b.timestamp,styleName:d.styleName,
removedProperties:{attributes:c.join(",")}},g.unshift(c)),e(d.setProperties,b.styleName));return{opSpecsA:f,opSpecsB:g}},RemoveText:g,SetParagraphStyle:g,SplitParagraph:g,UpdateMember:g,UpdateMetadata:g,UpdateParagraphStyle:g},ApplyDirectStyling:{ApplyDirectStyling:function(a,b,e){var f,g,h,k,m,p,x,u;k=[a];h=[b];if(!(a.position+a.length<=b.position||a.position>=b.position+b.length)){f=e?a:b;g=e?b:a;if(a.position!==b.position||a.length!==b.length)p=c(f),x=c(g);b=q(g.setProperties,null,f.setProperties,
null,"style:text-properties");if(b.majorChanged||b.minorChanged)h=[],a=[],k=f.position+f.length,m=g.position+g.length,g.position<f.position?b.minorChanged&&(u=c(x),u.length=f.position-g.position,a.push(u),g.position=f.position,g.length=m-g.position):f.position<g.position&&b.majorChanged&&(u=c(p),u.length=g.position-f.position,h.push(u),f.position=g.position,f.length=k-f.position),m>k?b.minorChanged&&(p=x,p.position=k,p.length=m-k,a.push(p),g.length=k-g.position):k>m&&b.majorChanged&&(p.position=m,
p.length=k-m,h.push(p),f.length=m-f.position),f.setProperties&&n(f.setProperties)&&h.push(f),g.setProperties&&n(g.setProperties)&&a.push(g),e?(k=h,h=a):k=a}return{opSpecsA:k,opSpecsB:h}},InsertText:function(a,b){b.position<=a.position?a.position+=b.text.length:b.position<=a.position+a.length&&(a.length+=b.text.length);return{opSpecsA:[a],opSpecsB:[b]}},MergeParagraph:function(a,b){var c=a.position,e=a.position+a.length;c>=b.sourceStartPosition&&(c-=1);e>=b.sourceStartPosition&&(e-=1);a.position=c;
a.length=e-c;return{opSpecsA:[a],opSpecsB:[b]}},MoveCursor:g,RemoveAnnotation:function(a,b){var c=a.position,e=a.position+a.length,f=b.position+b.length,g=[a],h=[b];b.position<=c&&e<=f?g=[]:(f<c&&(c-=b.length+2),f<e&&(e-=b.length+2),a.position=c,a.length=e-c);return{opSpecsA:g,opSpecsB:h}},RemoveCursor:g,RemoveMember:g,RemoveStyle:g,RemoveText:function(a,b){var c=a.position+a.length,e=b.position+b.length,f=[a],g=[b];e<=a.position?a.position-=b.length:b.position<c&&(a.position<b.position?a.length=
e<c?a.length-b.length:b.position-a.position:(a.position=b.position,e<c?a.length=c-e:f=[]));return{opSpecsA:f,opSpecsB:g}},SetParagraphStyle:g,SplitParagraph:function(a,b){b.position<a.position?a.position+=1:b.position<a.position+a.length&&(a.length+=1);return{opSpecsA:[a],opSpecsB:[b]}},UpdateMember:g,UpdateMetadata:g,UpdateParagraphStyle:g},InsertText:{InsertText:function(a,b,c){a.position<b.position?b.position+=a.text.length:a.position>b.position?a.position+=b.text.length:c?b.position+=a.text.length:
a.position+=b.text.length;return{opSpecsA:[a],opSpecsB:[b]}},MergeParagraph:function(a,b){a.position>=b.sourceStartPosition?a.position-=1:(a.position<b.sourceStartPosition&&(b.sourceStartPosition+=a.text.length),a.position<b.destinationStartPosition&&(b.destinationStartPosition+=a.text.length));return{opSpecsA:[a],opSpecsB:[b]}},MoveCursor:function(a,b){var c=k(b);a.position<b.position?b.position+=a.text.length:a.position<b.position+b.length&&(b.length+=a.text.length);c&&f(b);return{opSpecsA:[a],
opSpecsB:[b]}},RemoveAnnotation:function(a,b){var c=a.position,e=b.position+b.length,f=[a],g=[b];b.position<=c&&c<=e?(f=[],b.length+=a.text.length):e<a.position?a.position-=b.length+2:b.position+=a.text.length;return{opSpecsA:f,opSpecsB:g}},RemoveCursor:g,RemoveMember:g,RemoveStyle:g,RemoveText:function(a,b){var c;c=b.position+b.length;var e=[a],f=[b];c<=a.position?a.position-=b.length:a.position<=b.position?b.position+=a.text.length:(b.length=a.position-b.position,c={optype:"RemoveText",memberid:b.memberid,
timestamp:b.timestamp,position:a.position+a.text.length,length:c-a.position},f.unshift(c),a.position=b.position);return{opSpecsA:e,opSpecsB:f}},SetParagraphStyle:function(a,b){b.position>a.position&&(b.position+=a.text.length);return{opSpecsA:[a],opSpecsB:[b]}},SplitParagraph:function(a,b){a.position<b.sourceParagraphPosition&&(b.sourceParagraphPosition+=a.text.length);a.position<=b.position?b.position+=a.text.length:a.position+=1;return{opSpecsA:[a],opSpecsB:[b]}},UpdateMember:g,UpdateMetadata:g,
UpdateParagraphStyle:g},MergeParagraph:{MergeParagraph:function(a,b,c){var e=[a],f=[b],g;a.destinationStartPosition===b.destinationStartPosition?(e=[],f=[],a.moveCursor&&(g={optype:"MoveCursor",memberid:a.memberid,timestamp:a.timestamp,position:a.sourceStartPosition-1},e.push(g)),b.moveCursor&&(g={optype:"MoveCursor",memberid:b.memberid,timestamp:b.timestamp,position:b.sourceStartPosition-1},f.push(g)),a=c?a:b,a={optype:"SetParagraphStyle",memberid:a.memberid,timestamp:a.timestamp,position:a.destinationStartPosition,
styleName:a.paragraphStyleName},c?e.push(a):f.push(a)):b.sourceStartPosition===a.destinationStartPosition?(a.destinationStartPosition=b.destinationStartPosition,a.sourceStartPosition-=1,a.paragraphStyleName=b.paragraphStyleName):a.sourceStartPosition===b.destinationStartPosition?(b.destinationStartPosition=a.destinationStartPosition,b.sourceStartPosition-=1,b.paragraphStyleName=a.paragraphStyleName):a.destinationStartPosition<b.destinationStartPosition?(b.destinationStartPosition-=1,b.sourceStartPosition-=
1):(a.destinationStartPosition-=1,a.sourceStartPosition-=1);return{opSpecsA:e,opSpecsB:f}},MoveCursor:function(a,b){var c=b.position,e=b.position+b.length,f=Math.min(c,e),c=Math.max(c,e);f>=a.sourceStartPosition&&(f-=1);c>=a.sourceStartPosition&&(c-=1);0<=b.length?(b.position=f,b.length=c-f):(b.position=c,b.length=f-c);return{opSpecsA:[a],opSpecsB:[b]}},RemoveAnnotation:function(a,b){var c=b.position+b.length,e=[a],f=[b];b.position<=a.destinationStartPosition&&a.sourceStartPosition<=c?(e=[],b.length-=
1):a.sourceStartPosition<b.position?b.position-=1:(c<a.destinationStartPosition&&(a.destinationStartPosition-=b.length+2),c<a.sourceStartPosition&&(a.sourceStartPosition-=b.length+2));return{opSpecsA:e,opSpecsB:f}},RemoveCursor:g,RemoveMember:g,RemoveStyle:g,RemoveText:function(a,b){b.position>=a.sourceStartPosition?b.position-=1:(b.position<a.destinationStartPosition&&(a.destinationStartPosition-=b.length),b.position<a.sourceStartPosition&&(a.sourceStartPosition-=b.length));return{opSpecsA:[a],opSpecsB:[b]}},
SetParagraphStyle:function(a,b){var c=[a],e=[b];if(b.position>a.sourceStartPosition)b.position-=1;else if(b.position===a.destinationStartPosition||b.position===a.sourceStartPosition)b.position=a.destinationStartPosition,a.paragraphStyleName=b.styleName;return{opSpecsA:c,opSpecsB:e}},SplitParagraph:function(a,b){var c,e=[a],f=[b];b.position<a.destinationStartPosition?(a.destinationStartPosition+=1,a.sourceStartPosition+=1):b.position>=a.destinationStartPosition&&b.position<a.sourceStartPosition?(b.paragraphStyleName=
a.paragraphStyleName,c={optype:"SetParagraphStyle",memberid:a.memberid,timestamp:a.timestamp,position:a.destinationStartPosition,styleName:a.paragraphStyleName},e.push(c),b.position===a.sourceStartPosition-1&&a.moveCursor&&(c={optype:"MoveCursor",memberid:a.memberid,timestamp:a.timestamp,position:b.position,length:0},e.push(c)),a.destinationStartPosition=b.position+1,a.sourceStartPosition+=1):b.position>=a.sourceStartPosition&&(b.position-=1,b.sourceParagraphPosition-=1);return{opSpecsA:e,opSpecsB:f}},
UpdateMember:g,UpdateMetadata:g,UpdateParagraphStyle:g},MoveCursor:{MoveCursor:g,RemoveAnnotation:function(a,b){var c=k(a),e=a.position+a.length,g=b.position+b.length;b.position<=a.position&&e<=g?(a.position=b.position-1,a.length=0):(g<a.position?a.position-=b.length+2:g<e&&(a.length-=b.length+2),c&&f(a));return{opSpecsA:[a],opSpecsB:[b]}},RemoveCursor:function(a,b){return{opSpecsA:a.memberid===b.memberid?[]:[a],opSpecsB:[b]}},RemoveMember:g,RemoveStyle:g,RemoveText:function(a,b){var c=k(a),e=a.position+
a.length,g=b.position+b.length;g<=a.position?a.position-=b.length:b.position<e&&(a.position<b.position?a.length=g<e?a.length-b.length:b.position-a.position:(a.position=b.position,a.length=g<e?e-g:0));c&&f(a);return{opSpecsA:[a],opSpecsB:[b]}},SetParagraphStyle:g,SplitParagraph:function(a,b){var c=k(a);b.position<a.position?a.position+=1:b.position<a.position+a.length&&(a.length+=1);c&&f(a);return{opSpecsA:[a],opSpecsB:[b]}},UpdateMember:g,UpdateMetadata:g,UpdateParagraphStyle:g},RemoveAnnotation:{RemoveAnnotation:function(a,
b){var c=[a],e=[b];a.position===b.position&&a.length===b.length?(c=[],e=[]):a.position<b.position?b.position-=a.length+2:a.position-=b.length+2;return{opSpecsA:c,opSpecsB:e}},RemoveCursor:g,RemoveMember:g,RemoveStyle:g,RemoveText:function(a,b){var c=a.position+a.length,e=b.position+b.length,f=[a],g=[b];a.position<=b.position&&e<=c?(g=[],a.length-=b.length):e<a.position?a.position-=b.length:b.position<a.position?(a.position=b.position+1,b.length-=a.length+2):b.position-=a.length+2;return{opSpecsA:f,
opSpecsB:g}},SetParagraphStyle:function(a,b){var c=b.position,e=a.position+a.length,f=[a],g=[b];a.position<=c&&c<=e?g=[]:e<c&&(b.position-=a.length+2);return{opSpecsA:f,opSpecsB:g}},SplitParagraph:function(a,b){var c=b.position,e=a.position+a.length,f=[a],g=[b];a.position<=c&&c<=e?(g=[],a.length+=1):(e<b.sourceParagraphPosition&&(b.sourceParagraphPosition-=a.length+2),e<c?b.position-=a.length+2:a.position+=1);return{opSpecsA:f,opSpecsB:g}},UpdateMember:g,UpdateMetadata:g,UpdateParagraphStyle:g},RemoveCursor:{RemoveCursor:function(a,
b){var c=a.memberid===b.memberid;return{opSpecsA:c?[]:[a],opSpecsB:c?[]:[b]}},RemoveMember:g,RemoveStyle:g,RemoveText:g,SetParagraphStyle:g,SplitParagraph:g,UpdateMember:g,UpdateMetadata:g,UpdateParagraphStyle:g},RemoveMember:{RemoveStyle:g,RemoveText:g,SetParagraphStyle:g,SplitParagraph:g,UpdateMetadata:g,UpdateParagraphStyle:g},RemoveStyle:{RemoveStyle:function(a,b){var c=a.styleName===b.styleName&&a.styleFamily===b.styleFamily;return{opSpecsA:c?[]:[a],opSpecsB:c?[]:[b]}},RemoveText:g,SetParagraphStyle:function(a,
b){var c,e=[a],f=[b];"paragraph"===a.styleFamily&&a.styleName===b.styleName&&(c={optype:"SetParagraphStyle",memberid:a.memberid,timestamp:a.timestamp,position:b.position,styleName:""},e.unshift(c),b.styleName="");return{opSpecsA:e,opSpecsB:f}},SplitParagraph:g,UpdateMember:g,UpdateMetadata:g,UpdateParagraphStyle:function(c,b){var f,g=[c],h=[b];"paragraph"===c.styleFamily&&(f=a(b.setProperties,c.styleName),0<f.length&&(f={optype:"UpdateParagraphStyle",memberid:c.memberid,timestamp:c.timestamp,styleName:b.styleName,
removedProperties:{attributes:f.join(",")}},g.unshift(f)),c.styleName===b.styleName?h=[]:e(b.setProperties,c.styleName));return{opSpecsA:g,opSpecsB:h}}},RemoveText:{RemoveText:function(a,b){var c=a.position+a.length,e=b.position+b.length,f=[a],g=[b];e<=a.position?a.position-=b.length:c<=b.position?b.position-=a.length:b.position<c&&(a.position<b.position?(a.length=e<c?a.length-b.length:b.position-a.position,c<e?(b.position=a.position,b.length=e-c):g=[]):(c<e?b.length-=a.length:b.position<a.position?
b.length=a.position-b.position:g=[],e<c?(a.position=b.position,a.length=c-e):f=[]));return{opSpecsA:f,opSpecsB:g}},SetParagraphStyle:function(a,b){a.position<b.position&&(b.position-=a.length);return{opSpecsA:[a],opSpecsB:[b]}},SplitParagraph:function(a,b){var c=a.position+a.length,e=[a],f=[b];b.position<=a.position?a.position+=1:b.position<c&&(a.length=b.position-a.position,c={optype:"RemoveText",memberid:a.memberid,timestamp:a.timestamp,position:b.position+1,length:c-b.position},e.unshift(c));a.position+
a.length<=b.position?b.position-=a.length:a.position<b.position&&(b.position=a.position);a.position+a.length<b.sourceParagraphPosition&&(b.sourceParagraphPosition-=a.length);return{opSpecsA:e,opSpecsB:f}},UpdateMember:g,UpdateMetadata:g,UpdateParagraphStyle:g},SetParagraphStyle:{SetParagraphStyle:function(a,b,c){a.position===b.position&&(c?b.styleName=a.styleName:a.styleName=b.styleName);return{opSpecsA:[a],opSpecsB:[b]}},SplitParagraph:function(a,b){var e=[a],f=[b],g;a.position>b.position?a.position+=
1:a.position===b.sourceParagraphPosition&&(b.paragraphStyleName=a.styleName,g=c(a),g.position=b.position+1,e.push(g));return{opSpecsA:e,opSpecsB:f}},UpdateMember:g,UpdateMetadata:g,UpdateParagraphStyle:g},SplitParagraph:{SplitParagraph:function(a,b,c){var e,f;a.position<b.position?e=!0:b.position<a.position?f=!0:a.position===b.position&&(c?e=!0:f=!0);e?(b.position+=1,b.sourceParagraphPosition=a.position<b.sourceParagraphPosition?b.sourceParagraphPosition+1:a.position+1):f&&(a.position+=1,a.sourceParagraphPosition=
b.position<b.sourceParagraphPosition?a.sourceParagraphPosition+1:b.position+1);return{opSpecsA:[a],opSpecsB:[b]}},UpdateMember:g,UpdateMetadata:g,UpdateParagraphStyle:g},UpdateMember:{UpdateMetadata:g,UpdateParagraphStyle:g},UpdateMetadata:{UpdateMetadata:function(a,b,c){var e,f=[a],g=[b];e=c?a:b;a=c?b:a;m(a.setProperties||null,a.removedProperties||null,e.setProperties||null,e.removedProperties||null);e.setProperties&&n(e.setProperties)||e.removedProperties&&p(e.removedProperties)||(c?f=[]:g=[]);
a.setProperties&&n(a.setProperties)||a.removedProperties&&p(a.removedProperties)||(c?g=[]:f=[]);return{opSpecsA:f,opSpecsB:g}},UpdateParagraphStyle:g},UpdateParagraphStyle:{UpdateParagraphStyle:function(a,b,c){var e,f=[a],g=[b];a.styleName===b.styleName&&(e=c?a:b,a=c?b:a,q(a.setProperties,a.removedProperties,e.setProperties,e.removedProperties,"style:paragraph-properties"),q(a.setProperties,a.removedProperties,e.setProperties,e.removedProperties,"style:text-properties"),m(a.setProperties||null,a.removedProperties||
null,e.setProperties||null,e.removedProperties||null),e.setProperties&&n(e.setProperties)||e.removedProperties&&p(e.removedProperties)||(c?f=[]:g=[]),a.setProperties&&n(a.setProperties)||a.removedProperties&&p(a.removedProperties)||(c?g=[]:f=[]));return{opSpecsA:f,opSpecsB:g}}}};this.passUnchanged=g;this.extendTransformations=function(a){Object.keys(a).forEach(function(b){var c=a[b],e,f=h.hasOwnProperty(b);runtime.log((f?"Extending":"Adding")+" map for optypeA: "+b);f||(h[b]={});e=h[b];Object.keys(c).forEach(function(a){var d=
e.hasOwnProperty(a);runtime.assert(b<=a,"Wrong order:"+b+", "+a);runtime.log(" "+(d?"Overwriting":"Adding")+" entry for optypeB: "+a);e[a]=c[a]})})};this.transformOpspecVsOpspec=function(a,b){var c=a.optype<=b.optype,e;runtime.log("Crosstransforming:");runtime.log(runtime.toJson(a));runtime.log(runtime.toJson(b));c||(e=a,a=b,b=e);(e=(e=h[a.optype])&&e[b.optype])?(e=e(a,b,!c),c||null===e||(e={opSpecsA:e.opSpecsB,opSpecsB:e.opSpecsA})):e=null;runtime.log("result:");e?(runtime.log(runtime.toJson(e.opSpecsA)),
runtime.log(runtime.toJson(e.opSpecsB))):runtime.log("null");return e}};ops.OperationTransformer=function(){function f(a,e){for(var c,m,n=[],p=[];0<a.length&&e;){c=a.shift();c=k.transformOpspecVsOpspec(c,e);if(!c)return null;n=n.concat(c.opSpecsA);if(0===c.opSpecsB.length){n=n.concat(a);e=null;break}for(;1<c.opSpecsB.length;){m=f(a,c.opSpecsB.shift());if(!m)return null;p=p.concat(m.opSpecsB);a=m.opSpecsA}e=c.opSpecsB.pop()}e&&p.push(e);return{opSpecsA:n,opSpecsB:p}}var k=new ops.OperationTransformMatrix;this.getOperationTransformMatrix=function(){return k};this.transform=
function(a,e){for(var c,k=[];0<e.length;){c=f(a,e.shift());if(!c)return null;a=c.opSpecsA;k=k.concat(c.opSpecsB)}return{opSpecsA:a,opSpecsB:k}}};var webodf_css='@namespace draw url(urn:oasis:names:tc:opendocument:xmlns:drawing:1.0);@namespace fo url(urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0);@namespace office url(urn:oasis:names:tc:opendocument:xmlns:office:1.0);@namespace presentation url(urn:oasis:names:tc:opendocument:xmlns:presentation:1.0);@namespace style url(urn:oasis:names:tc:opendocument:xmlns:style:1.0);@namespace svg url(urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0);@namespace table url(urn:oasis:names:tc:opendocument:xmlns:table:1.0);@namespace text url(urn:oasis:names:tc:opendocument:xmlns:text:1.0);@namespace webodfhelper url(urn:webodf:names:helper);@namespace cursor url(urn:webodf:names:cursor);@namespace editinfo url(urn:webodf:names:editinfo);@namespace annotation url(urn:webodf:names:annotation);@namespace dc url(http://purl.org/dc/elements/1.1/);@namespace svgns url(http://www.w3.org/2000/svg);office|document > *, office|document-content > * {display: none;}office|body, office|document {display: inline-block;position: relative;}text|p, text|h {display: block;padding: 0;margin: 0;line-height: normal;position: relative;}text|p::after, text|h::after {content: "\\200B";white-space: pre;}*[webodfhelper|containsparagraphanchor] {position: relative;}text|s {white-space: pre;}text|tab {display: inline;white-space: pre;}text|tracked-changes {display: none;}office|binary-data {display: none;}office|text {display: block;text-align: left;overflow: visible;word-wrap: break-word;}office|text::selection {background: transparent;}.webodf-virtualSelections *::selection {background: transparent;}.webodf-virtualSelections *::-moz-selection {background: transparent;}office|text * draw|text-box {display: block;border: 1px solid #d3d3d3;}office|text draw|frame {z-index: 1;}office|spreadsheet {display: block;border-collapse: collapse;empty-cells: show;font-family: sans-serif;font-size: 10pt;text-align: left;page-break-inside: avoid;overflow: hidden;}office|presentation {display: inline-block;text-align: left;}#shadowContent {display: inline-block;text-align: left;}draw|page {display: block;position: relative;overflow: hidden;}presentation|notes, presentation|footer-decl, presentation|date-time-decl {display: none;}@media print {draw|page {border: 1pt solid black;page-break-inside: avoid;}presentation|notes {}}office|spreadsheet text|p {border: 0px;padding: 1px;margin: 0px;}office|spreadsheet table|table {margin: 3px;}office|spreadsheet table|table:after {}office|spreadsheet table|table-row {counter-increment: row;}office|spreadsheet table|table-row:before {width: 3em;background: #cccccc;border: 1px solid black;text-align: center;content: counter(row);display: table-cell;}office|spreadsheet table|table-cell {border: 1px solid #cccccc;}table|table {display: table;}draw|frame table|table {width: 100%;height: 100%;background: white;}table|table-header-rows {display: table-header-group;}table|table-row {display: table-row;}table|table-column {display: table-column;}table|table-cell {width: 0.889in;display: table-cell;word-break: break-all;}draw|frame {display: block;}draw|image {display: block;width: 100%;height: 100%;top: 0px;left: 0px;background-repeat: no-repeat;background-size: 100% 100%;-moz-background-size: 100% 100%;}draw|frame > draw|image:nth-of-type(n+2) {display: none;}text|list:before {display: none;content:"";}text|list {display: block;}text|list-item {display: block;}text|number {display:none;}text|a {color: blue;text-decoration: underline;cursor: pointer;}.webodf-inactiveLinks text|a {cursor: text;}text|note-citation {vertical-align: super;font-size: smaller;}text|note-body {display: none;}text|note:hover text|note-citation {background: #dddddd;}text|note:hover text|note-body {display: block;left:1em;max-width: 80%;position: absolute;background: #ffffaa;}text|bibliography-source {display: none;}svg|title, svg|desc {display: none;}video {width: 100%;height: 100%}cursor|anchor {display: none;}cursor|cursor {display: none;}.webodf-caretOverlay {position: absolute;top: 5%;height: 1em;z-index: 10;padding-left: 1px;pointer-events: none;}.webodf-caretOverlay .caret {position: absolute;border-left: 2px solid black;top: 0;bottom: 0;right: 0;}.webodf-caretOverlay .handle {position: absolute;margin-top: 5px;padding-top: 3px;margin-left: auto;margin-right: auto;width: 64px;height: 68px;border-radius: 5px;opacity: 0.3;text-align: center;background-color: black;box-shadow: 0px 0px 5px rgb(90, 90, 90);border: 1px solid black;top: -85px;right: -32px;}.webodf-caretOverlay .handle > img {box-shadow: 0px 0px 5px rgb(90, 90, 90) inset;background-color: rgb(200, 200, 200);border-radius: 5px;border: 2px solid;height: 60px;width: 60px;display: block;margin: auto;}.webodf-caretOverlay .handle.active {opacity: 0.8;}.webodf-caretOverlay .handle:after {content: " ";position: absolute;width: 0px;height: 0px;border-style: solid;border-width: 8.7px 5px 0 5px;border-color: black transparent transparent transparent;top: 100%;left: 43%;}.webodf-caretSizer {display: inline-block;width: 0;visibility: hidden;}#eventTrap {display: block;position: absolute;bottom: 0;left: 0;outline: none;opacity: 0;color: rgba(255, 255, 255, 0);pointer-events: none;white-space: pre;overflow: hidden;}cursor|cursor > #composer {text-decoration: underline;}cursor|cursor[cursor|caret-sizer-active="true"],cursor|cursor[cursor|composing="true"] {display: inline;}editinfo|editinfo {display: inline-block;}.editInfoMarker {position: absolute;width: 10px;height: 100%;left: -20px;opacity: 0.8;top: 0;border-radius: 5px;background-color: transparent;box-shadow: 0px 0px 5px rgba(50, 50, 50, 0.75);}.editInfoMarker:hover {box-shadow: 0px 0px 8px rgba(0, 0, 0, 1);}.editInfoHandle {position: absolute;background-color: black;padding: 5px;border-radius: 5px;opacity: 0.8;box-shadow: 0px 0px 5px rgba(50, 50, 50, 0.75);bottom: 100%;margin-bottom: 10px;z-index: 3;left: -25px;}.editInfoHandle:after {content: " ";position: absolute;width: 0px;height: 0px;border-style: solid;border-width: 8.7px 5px 0 5px;border-color: black transparent transparent transparent;top: 100%;left: 5px;}.editInfo {font-family: sans-serif;font-weight: normal;font-style: normal;text-decoration: none;color: white;width: 100%;height: 12pt;}.editInfoColor {float: left;width: 10pt;height: 10pt;border: 1px solid white;}.editInfoAuthor {float: left;margin-left: 5pt;font-size: 10pt;text-align: left;height: 12pt;line-height: 12pt;}.editInfoTime {float: right;margin-left: 30pt;font-size: 8pt;font-style: italic;color: yellow;height: 12pt;line-height: 12pt;}.annotationWrapper {display: inline;position: relative;}.annotationRemoveButton:before {content: "\u00d7";color: white;padding: 5px;line-height: 1em;}.annotationRemoveButton {width: 20px;height: 20px;border-radius: 10px;background-color: black;box-shadow: 0px 0px 5px rgba(50, 50, 50, 0.75);position: absolute;top: -10px;left: -10px;z-index: 3;text-align: center;font-family: sans-serif;font-style: normal;font-weight: normal;text-decoration: none;font-size: 15px;}.annotationRemoveButton:hover {cursor: pointer;box-shadow: 0px 0px 5px rgba(0, 0, 0, 1);}.annotationNote {width: 4cm;position: absolute;display: inline;z-index: 10;top: 0;}.annotationNote > office|annotation {display: block;text-align: left;}.annotationConnector {position: absolute;display: inline;top: 0;z-index: 2;border-top: 1px dashed brown;}.annotationConnector.angular {-moz-transform-origin: left top;-webkit-transform-origin: left top;-ms-transform-origin: left top;transform-origin: left top;}.annotationConnector.horizontal {left: 0;}.annotationConnector.horizontal:before {content: "";display: inline;position: absolute;width: 0px;height: 0px;border-style: solid;border-width: 8.7px 5px 0 5px;border-color: brown transparent transparent transparent;top: -1px;left: -5px;}office|annotation {width: 100%;height: 100%;display: none;background: rgb(198, 238, 184);background: -moz-linear-gradient(90deg, rgb(198, 238, 184) 30%, rgb(180, 196, 159) 100%);background: -webkit-linear-gradient(90deg, rgb(198, 238, 184) 30%, rgb(180, 196, 159) 100%);background: -o-linear-gradient(90deg, rgb(198, 238, 184) 30%, rgb(180, 196, 159) 100%);background: -ms-linear-gradient(90deg, rgb(198, 238, 184) 30%, rgb(180, 196, 159) 100%);background: linear-gradient(180deg, rgb(198, 238, 184) 30%, rgb(180, 196, 159) 100%);box-shadow: 0 3px 4px -3px #ccc;}office|annotation > dc|creator {display: block;font-size: 10pt;font-weight: normal;font-style: normal;font-family: sans-serif;color: white;background-color: brown;padding: 4px;}office|annotation > dc|date {display: block;font-size: 10pt;font-weight: normal;font-style: normal;font-family: sans-serif;border: 4px solid transparent;color: black;}office|annotation > text|list {display: block;padding: 5px;}office|annotation text|p {font-size: 10pt;color: black;font-weight: normal;font-style: normal;text-decoration: none;font-family: sans-serif;}#annotationsPane {background-color: #EAEAEA;width: 4cm;height: 100%;display: none;position: absolute;outline: 1px solid #ccc;}.webodf-annotationHighlight {background-color: yellow;position: relative;}.webodf-selectionOverlay {position: absolute;pointer-events: none;top: 0;left: 0;top: 0;left: 0;width: 100%;height: 100%;z-index: 15;}.webodf-selectionOverlay > polygon {fill-opacity: 0.3;stroke-opacity: 0.8;stroke-width: 1;fill-rule: evenodd;}.webodf-selectionOverlay > .webodf-draggable {fill-opacity: 0.8;stroke-opacity: 0;stroke-width: 8;pointer-events: all;display: none;-moz-transform-origin: center center;-webkit-transform-origin: center center;-ms-transform-origin: center center;transform-origin: center center;}#imageSelector {display: none;position: absolute;border-style: solid;border-color: black;}#imageSelector > div {width: 5px;height: 5px;display: block;position: absolute;border: 1px solid black;background-color: #ffffff;}#imageSelector > .topLeft {top: -4px;left: -4px;}#imageSelector > .topRight {top: -4px;right: -4px;}#imageSelector > .bottomRight {right: -4px;bottom: -4px;}#imageSelector > .bottomLeft {bottom: -4px;left: -4px;}#imageSelector > .topMiddle {top: -4px;left: 50%;margin-left: -2.5px;}#imageSelector > .rightMiddle {top: 50%;right: -4px;margin-top: -2.5px;}#imageSelector > .bottomMiddle {bottom: -4px;left: 50%;margin-left: -2.5px;}#imageSelector > .leftMiddle {top: 50%;left: -4px;margin-top: -2.5px;}div.webodf-customScrollbars::-webkit-scrollbar{width: 8px;height: 8px;background-color: transparent;}div.webodf-customScrollbars::-webkit-scrollbar-track{background-color: transparent;}div.webodf-customScrollbars::-webkit-scrollbar-thumb{background-color: #444;border-radius: 4px;}.webodf-hyperlinkTooltip {display: none;color: white;background-color: black;border-radius: 5px;box-shadow: 2px 2px 5px gray;padding: 3px;position: absolute;max-width: 210px;text-align: left;word-break: break-all;z-index: 16;}.webodf-hyperlinkTooltipText {display: block;font-weight: bold;}';