/* This is a generated file. DO NOT EDIT. Copyright (C) 2010-2015 KO GmbH @licstart This file is the compiled version of the WebODF library. WebODF 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. WebODF 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 . @licend @source: http://www.webodf.org/ @source: https://github.com/kogmbh/WebODF/ */ var webodf_version="0.5.6";function Runtime(){}Runtime.prototype.getVariable=function(f){};Runtime.prototype.toJson=function(f){};Runtime.prototype.fromJson=function(f){};Runtime.prototype.byteArrayFromString=function(f,l){};Runtime.prototype.byteArrayToString=function(f,l){};Runtime.prototype.read=function(f,l,a,d){};Runtime.prototype.readFile=function(f,l,a){};Runtime.prototype.readFileSync=function(f,l){};Runtime.prototype.loadXML=function(f,l){};Runtime.prototype.writeFile=function(f,l,a){}; Runtime.prototype.deleteFile=function(f,l){};Runtime.prototype.log=function(f,l){};Runtime.prototype.setTimeout=function(f,l){};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,l){};var IS_COMPILED_CODE=!0; Runtime.byteArrayToString=function(f,l){function a(a){var d="",b,n=a.length;for(b=0;bg?m.push(g):(b+=1,e=a[b],194<=g&&224>g?m.push((g&31)<<6|e&63):(b+=1,c=a[b],224<=g&&240>g?m.push((g&15)<<12|(e&63)<<6|c&63):(b+=1,r=a[b],240<=g&&245>g&&(g=(g&7)<<18|(e&63)<<12|(c&63)<<6|r&63,g-=65536,m.push((g>>10)+55296,(g&1023)+56320))))),1E3<=m.length&& (d+=String.fromCharCode.apply(null,m),m.length=0);return d+String.fromCharCode.apply(null,m)}var b;"utf8"===l?b=d(f):("binary"!==l&&this.log("Unsupported encoding: "+l),b=a(f));return b};Runtime.getVariable=function(f){try{return eval(f)}catch(l){}};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,l){if(!f)throw this.log("alert","ASSERTION FAILED:\n"+l),Error(l);}; function BrowserRuntime(){function f(a){var d=a.length,g,e,c=0;for(g=0;ge&&(c+=1,g+=1);return c}function l(a,d,g){var e=a.length,c,r;d=new Uint8Array(new ArrayBuffer(d));g?(d[0]=239,d[1]=187,d[2]=191,r=3):r=0;for(g=0;gc?(d[r]=c,r+=1):2048>c?(d[r]=192|c>>>6,d[r+1]=128|c&63,r+=2):55040>=c||57344<=c?(d[r]=224|c>>>12&15,d[r+1]=128|c>>>6&63,d[r+2]=128|c&63,r+=3):(g+=1,c=(c-55296<<10|a.charCodeAt(g)-56320)+65536, d[r]=240|c>>>18&7,d[r+1]=128|c>>>12&63,d[r+2]=128|c>>>6&63,d[r+3]=128|c&63,r+=4);return d}function a(d){var a=d.length,g=new Uint8Array(new ArrayBuffer(a)),e;for(e=0;ee.status||0===e.status?g(null):g("Status "+String(e.status)+": "+e.responseText||e.statusText):g("File "+d+" is empty."))};c=a.buffer&&!e.sendAsBinary?a.buffer:q.byteArrayToString(a,"binary");try{e.sendAsBinary?e.sendAsBinary(c):e.send(c)}catch(r){q.log("HUH? "+ r+" "+a),g(r.message)}};this.deleteFile=function(d,a){var g=new XMLHttpRequest;g.open("DELETE",d,!0);g.onreadystatechange=function(){4===g.readyState&&(200>g.status&&300<=g.status?a(g.responseText):a(null))};g.send(null)};this.loadXML=function(d,a){var g=new XMLHttpRequest;g.open("GET",d,!0);g.overrideMimeType&&g.overrideMimeType("text/xml");g.onreadystatechange=function(){4===g.readyState&&(0!==g.status||g.responseText?200===g.status||0===g.status?a(null,g.responseXML):a(g.responseText,null):a("File "+ d+" is empty.",null))};try{g.send(null)}catch(e){a(e.message,null)}};this.log=d;this.enableAlerts=!0;this.assert=Runtime.assert;this.setTimeout=function(d,a){return setTimeout(function(){d()},a)};this.clearTimeout=function(d){clearTimeout(d)};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(d){return(new DOMParser).parseFromString(d,"text/xml")};this.exit=function(a){d("Calling exit with code "+String(a)+", but exit() is not implemented.")};this.getWindow=function(){return window};this.requestAnimationFrame=function(d){var a=window.requestAnimationFrame||window.webkitRequestAnimationFrame||window.mozRequestAnimationFrame||window.msRequestAnimationFrame,g=0;if(a)a.bind(window),g=a(d);else return setTimeout(d,15);return g};this.cancelAnimationFrame=function(d){var a=window.cancelAnimationFrame|| window.webkitCancelAnimationFrame||window.mozCancelAnimationFrame||window.msCancelAnimationFrame;a?(a.bind(window),a(d)):clearTimeout(d)}} function NodeJSRuntime(){function f(d){var a=d.length,g,e=new Uint8Array(new ArrayBuffer(a));for(g=0;g").implementation} function RhinoRuntime(){var f=this,l={},a=l.javax.xml.parsers.DocumentBuilderFactory.newInstance(),d,b,h="";a.setValidating(!1);a.setNamespaceAware(!0);a.setExpandEntityReferences(!1);a.setSchema(null);b=l.org.xml.sax.EntityResolver({resolveEntity:function(d,a){var b=new l.java.io.FileReader(a);return new l.org.xml.sax.InputSource(b)}});d=a.newDocumentBuilder();d.setEntityResolver(b);this.byteArrayFromString=function(d,a){var b,h=d.length,g=new Uint8Array(new ArrayBuffer(h));for(b=0;b>>18],k+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[e>>>12&63],k+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[e>>>6&63],k+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[e& 63];r===d+1?(e=c[r]<<4,k+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[e>>>6],k+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[e&63],k+="=="):r===d&&(e=c[r]<<10|c[r+1]<<2,k+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[e>>>12],k+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[e>>>6&63],k+="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"[e&63],k+="=");return k}function a(e){e=e.replace(/[^A-Za-z0-9+\/]+/g, "");var c=e.length,r=new Uint8Array(new ArrayBuffer(3*c)),d=e.length%4,a=0,b,J;for(b=0;b>16,r[a+1]=J>>8&255,r[a+2]=J&255,a+=3;c=3*c-[0,0,2,1][d];return r.subarray(0,c)}function d(e){var c,k,r=e.length,d=0,a=new Uint8Array(new ArrayBuffer(3*r));for(c=0;ck?a[d++]=k:(2048>k?a[d++]=192|k>>>6:(a[d++]=224|k>>>12&15,a[d++]=128|k>>>6&63),a[d++]=128|k&63);return a.subarray(0, d)}function b(e){var c,k,r,d,a=e.length,b=new Uint8Array(new ArrayBuffer(a)),g=0;for(c=0;ck?b[g++]=k:(c+=1,r=e[c],224>k?b[g++]=(k&31)<<6|r&63:(c+=1,d=e[c],b[g++]=(k&15)<<12|(r&63)<<6|d&63));return b.subarray(0,g)}function h(c){return l(f(c))}function p(c){return String.fromCharCode.apply(String,a(c))}function q(c){return b(f(c))}function n(c){c=b(c);for(var e="",k=0;ke?b+=String.fromCharCode(e):(a+=1,r=c.charCodeAt(a)&255,224>e?b+=String.fromCharCode((e&31)<<6|r&63):(a+=1,d=c.charCodeAt(a)&255,b+=String.fromCharCode((e&15)<<12|(r&63)<<6|d&63)));return b}function g(c,e){function k(){var a=d+1E5;a>c.length&&(a=c.length);r+=m(c,d,a);d=a;a=d===c.length;e(r,a)&&!a&&runtime.setTimeout(k,0)}var r="",d=0;1E5>c.length?e(m(c,0,c.length),!0):("string"!==typeof c&&(c=c.slice()),k())}function e(c){return d(f(c))}function c(c){return String.fromCharCode.apply(String, d(c))}function r(c){return String.fromCharCode.apply(String,d(f(c)))}var k=function(c){var e={},k,r;k=0;for(r=c.length;kb-d&&(b=Math.max(2*b,d+a),a=new Uint8Array(new ArrayBuffer(b)),a.set(h),h=a)}var a=this,d=0,b=1024,h=new Uint8Array(new ArrayBuffer(b));this.appendByteArrayWriter=function(d){a.appendByteArray(d.getByteArray())};this.appendByteArray=function(a){var b=a.length;l(b);h.set(a,d);d+=b};this.appendArray=function(a){var b=a.length;l(b);h.set(a,d);d+=b};this.appendUInt16LE=function(d){a.appendArray([d&255,d>>8&255])};this.appendUInt32LE=function(d){a.appendArray([d& 255,d>>8&255,d>>16&255,d>>24&255])};this.appendString=function(d){a.appendByteArray(runtime.byteArrayFromString(d,f))};this.getLength=function(){return d};this.getByteArray=function(){var a=new Uint8Array(new ArrayBuffer(d));a.set(h.subarray(0,d));return a}};core.CSSUnits=function(){var f=this,l={"in":1,cm:2.54,mm:25.4,pt:72,pc:12,px:96};this.convert=function(a,d,b){return a*l[b]/l[d]};this.convertMeasure=function(a,d){var b,h;a&&d&&(b=parseFloat(a),h=a.replace(b.toString(),""),b=f.convert(b,h,d));return b};this.getUnits=function(a){return a.substr(a.length-2,a.length)}};(function(){function f(){var d,b,h,p,f,l,m,g,e;void 0===a&&(b=(d=runtime.getWindow())&&d.document,l=b.documentElement,m=b.body,a={rangeBCRIgnoresElementBCR:!1,unscaledRangeClientRects:!1,elementBCRIgnoresBodyScroll:!1},b&&(p=b.createElement("div"),p.style.position="absolute",p.style.left="-99999px",p.style.transform="scale(2)",p.style["-webkit-transform"]="scale(2)",f=b.createElement("div"),p.appendChild(f),m.appendChild(p),d=b.createRange(),d.selectNode(f),a.rangeBCRIgnoresElementBCR=0===d.getClientRects().length, f.appendChild(b.createTextNode("Rect transform test")),b=f.getBoundingClientRect(),h=d.getBoundingClientRect(),a.unscaledRangeClientRects=2=c.compareBoundaryPoints(Range.START_TO_START,e)&&0<=c.compareBoundaryPoints(Range.END_TO_END,e)}function h(c,e){return 0>=c.compareBoundaryPoints(Range.END_TO_START,e)&&0<=c.compareBoundaryPoints(Range.START_TO_END,e)}function p(c,e){var d=null;c.nodeType===Node.TEXT_NODE&&(0===c.length?(c.parentNode.removeChild(c),e.nodeType===Node.TEXT_NODE&&(d=e)):(e.nodeType===Node.TEXT_NODE&&(c.appendData(e.data),e.parentNode.removeChild(e)),d=c));return d} function q(c){for(var e=c.parentNode;c.firstChild;)e.insertBefore(c.firstChild,c);e.removeChild(c);return e}function n(c,e){for(var d=c.parentNode,a=c.firstChild,b;a;)b=a.nextSibling,n(a,e),a=b;d&&e(c)&&q(c);return d}function m(c,e){return c===e||Boolean(c.compareDocumentPosition(e)&Node.DOCUMENT_POSITION_CONTAINED_BY)}function g(c,e){return f().unscaledRangeClientRects?c:c/e}function e(c,k,d){Object.keys(k).forEach(function(a){var b=a.split(":"),g=b[1],h=d(b[0]),b=k[a],p=typeof b;"object"===p?Object.keys(b).length&& (a=h?c.getElementsByTagNameNS(h,g)[0]||c.ownerDocument.createElementNS(h,a):c.getElementsByTagName(g)[0]||c.ownerDocument.createElement(a),c.appendChild(a),e(a,b,d)):h&&(runtime.assert("number"===p||"string"===p,"attempting to map unsupported type '"+p+"' (key: "+a+")"),c.setAttributeNS(h,a,String(b)))})}var c=null;this.splitBoundaries=function(c){var e,a=[],b,g,h;if(c.startContainer.nodeType===Node.TEXT_NODE||c.endContainer.nodeType===Node.TEXT_NODE){b=c.endContainer;g=c.endContainer.nodeType!== Node.TEXT_NODE?c.endOffset===c.endContainer.childNodes.length:!1;h=c.endOffset;e=c.endContainer;if(hf))throw runtime.log("alert","watchdog timeout"),"timeout!";if(0l))throw runtime.log("alert","watchdog loop overflow"),"loop overflow";}};core.NodeFilterChain=function(f){var l=NodeFilter.FILTER_REJECT,a=NodeFilter.FILTER_ACCEPT;this.acceptNode=function(d){var b;for(b=0;b "+c.length),runtime.assert(0<=a,"Error in setPosition: "+a+" < 0"),a===c.length&&(g.nextSibling()?e=0:g.parentNode()?e=1:runtime.assert(!1,"Error in setUnfilteredPosition: position not valid."))):ad.windowBits&&(d.windowBits=-d.windowBits,0===d.windowBits&&(d.windowBits=-15));!(0<=d.windowBits&&16>d.windowBits)||a&&a.windowBits||(d.windowBits+=32);15d.windowBits&&0===(d.windowBits&15)&&(d.windowBits|=15);this.err=0;this.msg="";this.ended=!1;this.chunks= [];this.strm=new e;this.strm.avail_out=0;a=f.inflateInit2(this.strm,d.windowBits);if(a!==m.Z_OK)throw Error(g[a]);this.header=new c;f.inflateGetHeader(this.strm,this.header)};r.prototype.push=function(c,e){var a=this.strm,d=this.options.chunkSize,b,g,r,h,A;if(this.ended)return!1;g=e===~~e?e:!0===e?m.Z_FINISH:m.Z_NO_FLUSH;a.input="string"===typeof c?n.binstring2buf(c):c;a.next_in=0;a.avail_in=a.input.length;do{0===a.avail_out&&(a.output=new q.Buf8(d),a.next_out=0,a.avail_out=d);b=f.inflate(a,m.Z_NO_FLUSH); if(b!==m.Z_STREAM_END&&b!==m.Z_OK)return this.onEnd(b),this.ended=!0,!1;if(a.next_out&&(0===a.avail_out||b===m.Z_STREAM_END||0===a.avail_in&&g===m.Z_FINISH))if("string"===this.options.to)r=n.utf8border(a.output,a.next_out),h=a.next_out-r,A=n.buf2string(a.output,r),a.next_out=h,a.avail_out=d-h,h&&q.arraySet(a.output,a.output,r,h,0),this.onData(A);else this.onData(q.shrinkBuf(a.output,a.next_out))}while((0e&&(c.subarray&&n||!c.subarray&&q))return String.fromCharCode.apply(null,f.shrinkBuf(c,e));for(var a="",d=0;da;a++)e[a]=252<=a?6:248<= a?5:240<=a?4:224<=a?3:192<=a?2:1;e[254]=e[254]=1;b.string2buf=function(c){var e,a,d,b,g,h=c.length,m=0;for(b=0;ba?1:2048>a?2:65536>a?3:4;e=new f.Buf8(m);for(b=g=0;ga?e[g++]=a:(2048>a?e[g++]=192|a>>>6:(65536>a?e[g++]=224|a>>>12:(e[g++]= 240|a>>>18,e[g++]=128|a>>>12&63),e[g++]=128|a>>>6&63),e[g++]=128|a&63);return e};b.buf2binstring=function(c){return h(c,c.length)};b.binstring2buf=function(c){for(var a=new f.Buf8(c.length),e=0,d=a.length;eg)m[b++]=g;else if(f=e[g],4g?m[b++]=g:(g-=65536,m[b++]= 55296|g>>10&1023,m[b++]=56320|g&1023)}return h(m,b)};b.utf8border=function(c,a){var d;a=a||c.length;a>c.length&&(a=c.length);for(d=a-1;0<=d&&128===(c[d]&192);)d--;return 0>d||0===d?a:d+e[c[d]]>a?d:a}},{"./common":2}],4:[function(a,d,b){d.exports=function(a,d,b,f){var m=a&65535|0;a=a>>>16&65535|0;for(var g=0;0!==b;){g=2E3b;b++){a=b;for(var h=0;8>h;h++)a=a&1?3988292384^a>>>1:a>>>1;d[b]=a}return d}();d.exports=function(a,d,b,f){b=f+b;for(a^= -1;f>>8^h[(a^d[f])&255];return a^-1}},{}],7:[function(a,d,b){d.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,d,b){d.exports=function(a,d){var b,f,m,g,e,c,r,k,x,t,y,v,s,w,u,A,E,B,F,J,H,Q,N,z;b=a.state;f=a.next_in;N=a.input;m=f+(a.avail_in-5);g=a.next_out;z=a.output;e=g-(d-a.avail_out);c=g+(a.avail_out-257);r=b.dmax;k=b.wsize;x=b.whave;t=b.wnext;y=b.window;v=b.hold;s=b.bits; w=b.lencode;u=b.distcode;A=(1<s&&(v+=N[f++]<>>24;v>>>=F;s-=F;F=B>>>16&255;if(0===F)z[g++]=B&65535;else if(F&16){J=B&65535;if(F&=15)s>>=F,s-=F;15>s&&(v+=N[f++]<>>24;v>>>=F;s-=F;F=B>>>16&255;if(F&16){B&=65535;F&=15;sr){a.msg="invalid distance too far back"; b.mode=30;break a}v>>>=F;s-=F;F=g-e;if(B>F){F=B-F;if(F>x&&b.sane){a.msg="invalid distance too far back";b.mode=30;break a}H=0;Q=y;if(0===t){if(H+=k-F,F>3;f-=J;s-=J<<3;a.next_in=f;a.next_out=g;a.avail_in=f>>24&255)+(c>>>8&65280)+((c&65280)<<8)+((c&255)<<24)}function f(){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 e.Buf16(320);this.work= new e.Buf16(288);this.distdyn=this.lendyn=null;this.was=this.back=this.sane=0}function q(c){var a;if(!c||!c.state)return y;a=c.state;c.total_in=c.total_out=a.total=0;c.msg="";a.wrap&&(c.adler=a.wrap&1);a.mode=v;a.last=0;a.havedict=0;a.dmax=32768;a.head=null;a.hold=0;a.bits=0;a.lencode=a.lendyn=new e.Buf32(s);a.distcode=a.distdyn=new e.Buf32(w);a.sane=1;a.back=-1;return t}function n(c){var a;if(!c||!c.state)return y;a=c.state;a.wsize=0;a.whave=0;a.wnext=0;return q(c)}function m(c,a){var e,d;if(!c|| !c.state)return y;d=c.state;0>a?(e=0,a=-a):(e=(a>>4)+1,48>a&&(a&=15));if(a&&(8>a||15s;){if(0===m)break a;m--;n+=g[p++]<>>8&255;b.check=r(b.check,W,2,0);s=n=0;b.mode=2;break}b.flags=0;b.head&&(b.head.done=!1);if(!(b.wrap&1)||(((n&255)<<8)+(n>>8))%31){a.msg="incorrect header check";b.mode=30;break}if(8!==(n&15)){a.msg="unknown compression method";b.mode=30;break}n>>>=4;s-=4;P=(n&15)+8;if(0===b.wbits)b.wbits=P;else if(P>b.wbits){a.msg="invalid window size";b.mode=30;break}b.dmax=1<s;){if(0===m)break a;m--;n+=g[p++]<>8&1);b.flags&512&&(W[0]=n&255,W[1]=n>>>8&255,b.check=r(b.check,W,2,0));s=n=0;b.mode=3;case 3:for(;32>s;){if(0===m)break a;m--;n+=g[p++]<>>8&255,W[2]=n>>>16&255,W[3]=n>>>24&255,b.check=r(b.check,W,4,0));s=n=0;b.mode=4;case 4:for(;16>s;){if(0===m)break a;m--;n+=g[p++]<>8);b.flags&512&&(W[0]=n&255,W[1]=n>>>8&255,b.check=r(b.check,W,2,0));s=n=0;b.mode=5;case 5:if(b.flags&1024){for(;16>s;){if(0===m)break a;m--;n+=g[p++]<>>8&255,b.check=r(b.check,W,2,0));s=n=0}else b.head&&(b.head.extra=null);b.mode=6;case 6:if(b.flags&1024&&(D=b.length,D>m&&(D=m),D&&(b.head&&(P=b.head.extra_len-b.length,b.head.extra||(b.head.extra=Array(b.head.extra_len)),e.arraySet(b.head.extra, g,p,D,P)),b.flags&512&&(b.check=r(b.check,g,D,p)),m-=D,p+=D,b.length-=D),b.length))break a;b.length=0;b.mode=7;case 7:if(b.flags&2048){if(0===m)break a;D=0;do P=g[p+D++],b.head&&P&&65536>b.length&&(b.head.name+=String.fromCharCode(P));while(P&&Db.length&&(b.head.comment+=String.fromCharCode(P));while(P&&D< m);b.flags&512&&(b.check=r(b.check,g,D,p));m-=D;p+=D;if(P)break a}else b.head&&(b.head.comment=null);b.mode=9;case 9:if(b.flags&512){for(;16>s;){if(0===m)break a;m--;n+=g[p++]<>9&1,b.head.done=!0);a.adler=b.check=0;b.mode=12;break;case 10:for(;32>s;){if(0===m)break a;m--;n+=g[p++]<>>=s&7;s-=s&7;b.mode=27;break}for(;3>s;){if(0===m)break a;m--;n+=g[p++]<>>=1;s-=1;switch(n&3){case 0:b.mode=14;break;case 1:D=b;if(u){P=void 0;A=new e.Buf32(512);E=new e.Buf32(32);for(P=0;144>P;)D.lens[P++]=8;for(;256>P;)D.lens[P++]=9;for(;280>P;)D.lens[P++]=7;for(;288>P;)D.lens[P++]=8;x(1,D.lens,0,288,A,0,D.work,{bits:9});for(P=0;32>P;)D.lens[P++]=5;x(2,D.lens, 0,32,E,0,D.work,{bits:5});u=!1}D.lencode=A;D.lenbits=9;D.distcode=E;D.distbits=5;b.mode=20;if(6===d){n>>>=2;s-=2;break a}break;case 2:b.mode=17;break;case 3:a.msg="invalid block type",b.mode=30}n>>>=2;s-=2;break;case 14:n>>>=s&7;for(s-=s&7;32>s;){if(0===m)break a;m--;n+=g[p++]<>>16^65535)){a.msg="invalid stored block lengths";b.mode=30;break}b.length=n&65535;s=n=0;b.mode=15;if(6===d)break a;case 15:b.mode=16;case 16:if(D=b.length){D>m&&(D=m);D>q&&(D=q);if(0===D)break a;e.arraySet(f, g,p,D,z);m-=D;p+=D;q-=D;z+=D;b.length-=D;break}b.mode=12;break;case 17:for(;14>s;){if(0===m)break a;m--;n+=g[p++]<>>=5;s-=5;b.ndist=(n&31)+1;n>>>=5;s-=5;b.ncode=(n&15)+4;n>>>=4;s-=4;if(286s;){if(0===m)break a;m--;n+=g[p++]<>>=3;s-=3}for(;19>b.have;)b.lens[O[b.have++]]=0;b.lencode=b.lendyn;b.lenbits=7; D={bits:b.lenbits};U=x(0,b.lens,0,19,b.lencode,0,b.work,D);b.lenbits=D.bits;if(U){a.msg="invalid code lengths set";b.mode=30;break}b.have=0;b.mode=19;case 19:for(;b.have>>24;V=D>>>16&255;$=D&65535;if(C<=s)break;if(0===m)break a;m--;n+=g[p++]<$)n>>>=C,s-=C,b.lens[b.have++]=$;else{if(16===$){for(D=C+2;s>>=C;s-=C;if(0===b.have){a.msg="invalid bit length repeat";b.mode=30;break}P= b.lens[b.have-1];D=3+(n&3);n>>>=2;s-=2}else if(17===$){for(D=C+3;s>>=C;s-=C;P=0;D=3+(n&7);n>>>=3;s-=3}else{for(D=C+7;s>>=C;s-=C;P=0;D=11+(n&127);n>>>=7;s-=7}if(b.have+D>b.nlen+b.ndist){a.msg="invalid bit length repeat";b.mode=30;break}for(;D--;)b.lens[b.have++]=P}}if(30===b.mode)break;if(0===b.lens[256]){a.msg="invalid code -- missing end-of-block";b.mode=30;break}b.lenbits=9;D={bits:b.lenbits};U=x(1,b.lens, 0,b.nlen,b.lencode,0,b.work,D);b.lenbits=D.bits;if(U){a.msg="invalid literal/lengths set";b.mode=30;break}b.distbits=6;b.distcode=b.distdyn;D={bits:b.distbits};U=x(2,b.lens,b.nlen,b.ndist,b.distcode,0,b.work,D);b.distbits=D.bits;if(U){a.msg="invalid distances set";b.mode=30;break}b.mode=20;if(6===d)break a;case 20:b.mode=21;case 21:if(6<=m&&258<=q){a.next_out=z;a.avail_out=q;a.next_in=p;a.avail_in=m;b.hold=n;b.bits=s;k(a,T);z=a.next_out;f=a.output;q=a.avail_out;p=a.next_in;g=a.input;m=a.avail_in; n=b.hold;s=b.bits;12===b.mode&&(b.back=-1);break}for(b.back=0;;){D=b.lencode[n&(1<>>24;V=D>>>16&255;$=D&65535;if(C<=s)break;if(0===m)break a;m--;n+=g[p++]<>P)];C=D>>>24;V=D>>>16&255;$=D&65535;if(P+C<=s)break;if(0===m)break a;m--;n+=g[p++]<>>=P;s-=P;b.back+=P}n>>>=C;s-=C;b.back+=C;b.length=$;if(0===V){b.mode=26;break}if(V&32){b.back=-1;b.mode=12;break}if(V&64){a.msg="invalid literal/length code"; b.mode=30;break}b.extra=V&15;b.mode=22;case 22:if(b.extra){for(D=b.extra;s>>=b.extra;s-=b.extra;b.back+=b.extra}b.was=b.length;b.mode=23;case 23:for(;;){D=b.distcode[n&(1<>>24;V=D>>>16&255;$=D&65535;if(C<=s)break;if(0===m)break a;m--;n+=g[p++]<>P)];C=D>>>24;V=D>>>16&255;$=D&65535;if(P+C<=s)break;if(0===m)break a;m--;n+=g[p++]<>>=P;s-=P;b.back+=P}n>>>=C;s-=C;b.back+=C;if(V&64){a.msg="invalid distance code";b.mode=30;break}b.offset=$;b.extra=V&15;b.mode=24;case 24:if(b.extra){for(D=b.extra;s>>=b.extra;s-=b.extra;b.back+=b.extra}if(b.offset>b.dmax){a.msg="invalid distance too far back";b.mode=30;break}b.mode=25;case 25:if(0===q)break a;D=T-q;if(b.offset>D){D=b.offset-D;if(D>b.whave&&b.sane){a.msg="invalid distance too far back";b.mode=30;break}D> b.wnext?(D-=b.wnext,P=b.wsize-D):P=b.wnext-D;D>b.length&&(D=b.length);Z=b.window}else Z=f,P=z-b.offset,D=b.length;D>q&&(D=q);q-=D;b.length-=D;do f[z++]=Z[P++];while(--D);0===b.length&&(b.mode=21);break;case 26:if(0===q)break a;f[z++]=b.length;q--;b.mode=21;break;case 27:if(b.wrap){for(;32>s;){if(0===m)break a;m--;n|=g[p++]<s;){if(0===m)break a;m--;n+=g[p++]<b.mode&&(27>b.mode||4!==d))g=a.output,p=a.next_out,z=T-a.avail_out,q=a.state,null===q.window&&(q.wsize=1<=q.wsize?(e.arraySet(q.window,g,p-q.wsize,q.wsize,0),q.wnext=0,q.whave=q.wsize):(m=q.wsize-q.wnext,m>z&&(m=z),e.arraySet(q.window,g,p-z,m,q.wnext),(z-=m)?(e.arraySet(q.window,g,p-z,z,0),q.wnext=z,q.whave=q.wsize):(q.wnext+=m,q.wnext===q.wsize&&(q.wnext=0),q.whave=s;s++)G[s]=0;for(w=0;wA&&(E=A);if(0===A)return k[x++]=20971520,k[x++]=20971520,y.bits=1,0;for(u=1;u=s;s++)if(J<<=1,J-=G[s],0>J)return-1;if(0s;s++)B[s+1]=B[s]+G[s];for(w=0;wI?(P=ba[T+t[w]],Z=Y[R+t[w]]):(P=96,Z=0);J=1<>F)+N]=D<<24|P<<16|Z|0;while(0!==N);for(J=1<>=1;0!==J?(Q&=J-1,Q+=J):Q=0;w++;if(0===--G[s]){if(s===A)break;s=b[c+t[w]]}if(s>E&&(Q&d)!==z){0===F&&(F=E);v+=u;B=s-F;for(J=1<=J)break;B++;J<<=1}H+=1<>>8^g;return b^-1}function b(a){return new Date((a>>25&127)+1980,(a>>21&15)-1,a>>16&31,a>>11&15, a>>5&63,(a&31)<<1)}function h(a){var c=a.getFullYear();return 1980>c?0:c-1980<<25|a.getMonth()+1<<21|a.getDate()<<16|a.getHours()<<11|a.getMinutes()<<5|a.getSeconds()>>1}function p(c,e){var d,g,k,r,f,h,m,n=this;this.load=function(b){if(null!==n.data)b(null,n.data);else{var e=f+34+g+k+256;e+m>t&&(e=t-m);a(m,e,function(a,e){if(a||null===e)b(a,e);else a:{var d=e,g=new core.ByteArray(d),k=g.readUInt32LE(),m;if(67324752!==k)b("File entry signature is wrong."+k.toString()+" "+d.length.toString(),null); else{g.pos+=22;k=g.readUInt16LE();m=g.readUInt16LE();g.pos+=k+m;if(r){d=d.subarray(g.pos,g.pos+f);if(f!==d.length){b("The amount of compressed bytes read was "+d.length.toString()+" instead of "+f.toString()+" for "+n.filename+" in "+c+".",null);break a}d=v(d,h)}else d=d.subarray(g.pos,g.pos+h);h!==d.length?b("The amount of bytes read was "+d.length.toString()+" instead of "+h.toString()+" for "+n.filename+" in "+c+".",null):(n.data=d,b(null,d))}}})}};this.set=function(a,c,b,e){n.filename=a;n.data= c;n.compressed=b;n.date=e};this.error=null;e&&(d=e.readUInt32LE(),33639248!==d?this.error="Central directory entry has wrong signature at position "+(e.pos-4).toString()+' for file "'+c+'": '+e.data.length.toString():(e.pos+=6,r=e.readUInt16LE(),this.date=b(e.readUInt32LE()),e.readUInt32LE(),f=e.readUInt32LE(),h=e.readUInt32LE(),g=e.readUInt16LE(),k=e.readUInt16LE(),d=e.readUInt16LE(),e.pos+=8,m=e.readUInt32LE(),this.filename=runtime.byteArrayToString(e.data.subarray(e.pos,e.pos+g),"utf8"),this.data= null,e.pos+=g+k+d))}function q(c,b){if(22!==c.length)b("Central directory length should be 22.",s);else{var e=new core.ByteArray(c),d;d=e.readUInt32LE();101010256!==d?b("Central directory signature is wrong: "+d.toString(),s):(d=e.readUInt16LE(),0!==d?b("Zip files with non-zero disk numbers are not supported.",s):(d=e.readUInt16LE(),0!==d?b("Zip files with non-zero disk numbers are not supported.",s):(d=e.readUInt16LE(),y=e.readUInt16LE(),d!==y?b("Number of entries is inconsistent.",s):(d=e.readUInt32LE(), e=e.readUInt16LE(),e=t-22-d,a(e,t-e,function(a,c){if(a||null===c)b(a,s);else a:{var e=new core.ByteArray(c),d,g;k=[];for(d=0;da.value||"%"===a.unit)?null:a}function F(a){return(a=E(a))&&"%"!==a.unit?null:a}function J(a){switch(a.namespaceURI){case odf.Namespaces.drawns:case odf.Namespaces.svgns:case odf.Namespaces.dr3dns:return!1;case odf.Namespaces.textns:switch(a.localName){case "note-body":case "ruby-text":return!1}break;case odf.Namespaces.officens:switch(a.localName){case "annotation":case "binary-data":case "event-listeners":return!1}break;default:switch(a.localName){case "cursor":case "editinfo":return!1}}return!0} function H(a,c){for(;0=c.value||"%"===c.unit)?null:c;return c||F(a)};this.parseFoLineHeight= function(a){return B(a)||F(a)};this.isTextContentContainingNode=J;this.getTextNodes=function(a,c){var b;b=G.getNodesInRange(a,function(a){var c=NodeFilter.FILTER_REJECT;a.nodeType===Node.TEXT_NODE?Boolean(h(a)&&(!q(a.textContent)||A(a,0)))&&(c=NodeFilter.FILTER_ACCEPT):J(a)&&(c=NodeFilter.FILTER_SKIP);return c},NodeFilter.SHOW_ELEMENT|NodeFilter.SHOW_TEXT);c||H(a,b);return b};this.getTextElements=Q;this.getParagraphElements=function(a){var c;c=G.getNodesInRange(a,function(a){var c=NodeFilter.FILTER_REJECT; if(b(a))c=NodeFilter.FILTER_ACCEPT;else if(J(a)||n(a))c=NodeFilter.FILTER_SKIP;return c},NodeFilter.SHOW_ELEMENT);N(a.startContainer,c,b);return c};this.getImageElements=function(a){var c;c=G.getNodesInRange(a,function(a){var c=NodeFilter.FILTER_SKIP;f(a)&&(c=NodeFilter.FILTER_ACCEPT);return c},NodeFilter.SHOW_ELEMENT);N(a.startContainer,c,f);return c};this.getHyperlinkElements=function(a){var c=[],e=a.cloneRange();a.collapsed&&a.endContainer.nodeType===Node.ELEMENT_NODE&&(a=z(a.endContainer,a.endOffset), a.nodeType===Node.TEXT_NODE&&e.setEnd(a,1));Q(e,!0,!1).forEach(function(a){for(a=a.parentNode;!b(a);){if(d(a)&&-1===c.indexOf(a)){c.push(a);break}a=a.parentNode}});e.detach();return c};this.getNormalizedFontFamilyName=function(a){/^(["'])(?:.|[\n\r])*?\1$/.test(a)||(a=a.replace(/^[ \t\r\n\f]*((?:.|[\n\r])*?)[ \t\r\n\f]*$/,"$1"),/[ \t\r\n\f]/.test(a)&&(a="'"+a.replace(/[ \t\r\n\f]+/g," ")+"'"));return a}};odf.OdfUtils=new odf.OdfUtilsImpl;gui.OdfTextBodyNodeFilter=function(){var f=odf.OdfUtils,l=Node.TEXT_NODE,a=NodeFilter.FILTER_REJECT,d=NodeFilter.FILTER_ACCEPT,b=odf.Namespaces.textns;this.acceptNode=function(h){if(h.nodeType===l){if(!f.isGroupingElement(h.parentNode))return a}else if(h.namespaceURI===b&&"tracked-changes"===h.localName)return a;return d}};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,b,c){return-1!==a&&(a=f&&c.push(l(a.substring(b,d)))):"["===a[d]&&(0>=f&&(b=d+1),f+=1),d+=1;return d};n=function(a,e,c){var r,k,f,h;for(r=0;r/g,">").replace(/'/g,"'").replace(/"/g,""")}function a(b,f){var p="",q=d.filter?d.filter.acceptNode(f):NodeFilter.FILTER_ACCEPT,n;if(q===NodeFilter.FILTER_ACCEPT&&f.nodeType===Node.ELEMENT_NODE){b.push();n=b.getQName(f);var m,g=f.attributes,e,c,r,k="",x;m="<"+n;e=g.length;for(c=0;c")}if(q===NodeFilter.FILTER_ACCEPT||q===NodeFilter.FILTER_SKIP){for(q=f.firstChild;q;)p+=a(b,q),q=q.nextSibling;f.nodeValue&&(p+=l(f.nodeValue))}n&&(p+="",b.pop());return p}var d=this;this.filter=null;this.writeToString=function(b,d){if(!b)return"";var p=new f(d);return a(p,b)}};(function(){function f(a){var b,c=q.length;for(b=0;bc)break;k=k.nextSibling}a.insertBefore(b,k)}}}var b=new odf.StyleInfo,h=core.DomUtils,p=odf.Namespaces.stylens,q="meta settings scripts font-face-decls styles automatic-styles master-styles body".split(" "), n=Date.now()+"_webodf_",m=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,b,c,d){var k=this;this.size=0;this.type=null;this.name=a;this.container=c;this.url=null;this.mimetype=b;this.onstatereadychange=this.document=null;this.EMPTY=0;this.LOADING=1;this.DONE=2;this.state=this.EMPTY;this.data="";this.load=function(){null!==d&&(this.mimetype=b,d.loadAsDataURL(a,b,function(a,c){a&&runtime.log(a);k.url=c;if(k.onchange)k.onchange(k);if(k.onstatereadychange)k.onstatereadychange(k)}))}};odf.OdfPart.prototype.load=function(){}; odf.OdfPart.prototype.getUrl=function(){return this.data?"data:;base64,"+m.toBase64(this.data):null};odf.OdfContainer=function e(c,f){function k(a){for(var c=a.firstChild,b;c;)b=c.nextSibling,c.nodeType===Node.ELEMENT_NODE?k(c):c.nodeType===Node.PROCESSING_INSTRUCTION_NODE&&a.removeChild(c),c=b}function q(a){var c={},b,e,d=a.ownerDocument.createNodeIterator(a,NodeFilter.SHOW_ELEMENT,null,!1);for(a=d.nextNode();a;)"urn:oasis:names:tc:opendocument:xmlns:office:1.0"===a.namespaceURI&&("annotation"=== a.localName?(b=a.getAttributeNS("urn:oasis:names:tc:opendocument:xmlns:office:1.0","name"))&&(c.hasOwnProperty(b)?runtime.log("Warning: annotation name used more than once with : '"+b+"'"):c[b]=a):"annotation-end"===a.localName&&((b=a.getAttributeNS("urn:oasis:names:tc:opendocument:xmlns:office:1.0","name"))?c.hasOwnProperty(b)?(e=c[b],e.annotationEndElement?runtime.log("Warning: annotation name used more than once with : '"+b+"'"):e.annotationEndElement= a):runtime.log("Warning: annotation end without an annotation start, name: '"+b+"'"):runtime.log("Warning: annotation end without a name found"))),a=d.nextNode()}function t(a,c){for(var b=a&&a.firstChild;b;)b.nodeType===Node.ELEMENT_NODE&&b.setAttributeNS("urn:webodf:names:scope","scope",c),b=b.nextSibling}function y(a,c){for(var b=U.rootElement.meta,b=b&&b.firstChild;b&&(b.namespaceURI!==a||b.localName!==c);)b=b.nextSibling;for(b=b&&b.firstChild;b&&b.nodeType!==Node.TEXT_NODE;)b=b.nextSibling;return b? b.data:null}function v(a){var c={},b;for(a=a.firstChild;a;)a.nodeType===Node.ELEMENT_NODE&&a.namespaceURI===p&&"font-face"===a.localName&&(b=a.getAttributeNS(p,"name"),c[b]=a),a=a.nextSibling;return c}function s(a,c){var b=null,e,d,k;if(a)for(b=a.cloneNode(!0),e=b.firstElementChild;e;)d=e.nextElementSibling,(k=e.getAttributeNS("urn:webodf:names:scope","scope"))&&k!==c&&b.removeChild(e),e=d;return b}function w(a,c){var e,d,k,f=null,r={};if(a)for(c.forEach(function(a){b.collectUsedFontFaces(r,a)}), f=a.cloneNode(!0),e=f.firstElementChild;e;)d=e.nextElementSibling,k=e.getAttributeNS(p,"name"),r[k]||f.removeChild(e),e=d;return f}function u(a){var c=U.rootElement.ownerDocument,b;if(a){k(a.documentElement);try{b=c.importNode(a.documentElement,!0)}catch(e){}}return b}function A(a){U.state=a;if(U.onchange)U.onchange(U);if(U.onstatereadychange)U.onstatereadychange(U)}function E(a){aa=null;U.rootElement=a;a.fontFaceDecls=h.getDirectChild(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","font-face-decls"); a.styles=h.getDirectChild(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","styles");a.automaticStyles=h.getDirectChild(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","automatic-styles");a.masterStyles=h.getDirectChild(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","master-styles");a.body=h.getDirectChild(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","body");a.meta=h.getDirectChild(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","meta");a.settings=h.getDirectChild(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0", "settings");a.scripts=h.getDirectChild(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","scripts");q(a)}function B(a){var c=u(a),k=U.rootElement,f;c&&"document-styles"===c.localName&&"urn:oasis:names:tc:opendocument:xmlns:office:1.0"===c.namespaceURI?(k.fontFaceDecls=h.getDirectChild(c,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","font-face-decls"),d(k,k.fontFaceDecls),f=h.getDirectChild(c,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","styles"),k.styles=f||a.createElementNS("urn:oasis:names:tc:opendocument:xmlns:office:1.0", "styles"),d(k,k.styles),f=h.getDirectChild(c,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","automatic-styles"),k.automaticStyles=f||a.createElementNS("urn:oasis:names:tc:opendocument:xmlns:office:1.0","automatic-styles"),t(k.automaticStyles,"document-styles"),d(k,k.automaticStyles),c=h.getDirectChild(c,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","master-styles"),k.masterStyles=c||a.createElementNS("urn:oasis:names:tc:opendocument:xmlns:office:1.0","master-styles"),d(k,k.masterStyles), b.prefixStyleNames(k.automaticStyles,n,k.masterStyles)):A(e.INVALID)}function F(a){a=u(a);var c,k,f,r;if(a&&"document-content"===a.localName&&"urn:oasis:names:tc:opendocument:xmlns:office:1.0"===a.namespaceURI){c=U.rootElement;f=h.getDirectChild(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","font-face-decls");if(c.fontFaceDecls&&f){r=c.fontFaceDecls;var m,n,q,l,z={};k=v(r);l=v(f);for(f=f.firstElementChild;f;){m=f.nextElementSibling;if(f.namespaceURI===p&&"font-face"===f.localName)if(n=f.getAttributeNS(p, "name"),k.hasOwnProperty(n)){if(!f.isEqualNode(k[n])){q=n;for(var Q=k,s=l,x=0,Y=void 0,Y=q=q.replace(/\d+$/,"");Q.hasOwnProperty(Y)||s.hasOwnProperty(Y);)x+=1,Y=q+x;q=Y;f.setAttributeNS(p,"style:name",q);r.appendChild(f);k[q]=f;delete l[n];z[n]=q}}else r.appendChild(f),k[n]=f,delete l[n];f=m}r=z}else f&&(c.fontFaceDecls=f,d(c,f));k=h.getDirectChild(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","automatic-styles");t(k,"document-content");r&&b.changeFontFaceNames(k,r);if(c.automaticStyles&&k)for(r= k.firstChild;r;)c.automaticStyles.appendChild(r),r=k.firstChild;else k&&(c.automaticStyles=k,d(c,k));a=h.getDirectChild(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","body");if(null===a)throw" tag is mising.";c.body=a;d(c,c.body)}else A(e.INVALID)}function J(a){a=u(a);var c;a&&"document-meta"===a.localName&&"urn:oasis:names:tc:opendocument:xmlns:office:1.0"===a.namespaceURI&&(c=U.rootElement,c.meta=h.getDirectChild(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","meta"), d(c,c.meta))}function H(a){a=u(a);var c;a&&"document-settings"===a.localName&&"urn:oasis:names:tc:opendocument:xmlns:office:1.0"===a.namespaceURI&&(c=U.rootElement,c.settings=h.getDirectChild(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","settings"),d(c,c.settings))}function Q(a){a=u(a);var c;if(a&&"manifest"===a.localName&&"urn:oasis:names:tc:opendocument:xmlns:manifest:1.0"===a.namespaceURI)for(c=U.rootElement,c.manifest=a,a=c.manifest.firstElementChild;a;)"file-entry"===a.localName&&"urn:oasis:names:tc:opendocument:xmlns:manifest:1.0"=== a.namespaceURI&&(O[a.getAttributeNS("urn:oasis:names:tc:opendocument:xmlns:manifest:1.0","full-path")]=a.getAttributeNS("urn:oasis:names:tc:opendocument:xmlns:manifest:1.0","media-type")),a=a.nextElementSibling}function N(a,c,b){a=h.getElementsByTagName(a,c);var e;for(e=0;e'}function G(){var a=new xmldom.LSSerializer,c=I("document-meta");a.filter=new odf.OdfNodeFilter;c+=a.writeToString(U.rootElement.meta,odf.Namespaces.namespaceMap);return c+""}function ba(a,c){var b=document.createElementNS("urn:oasis:names:tc:opendocument:xmlns:manifest:1.0","manifest:file-entry");b.setAttributeNS("urn:oasis:names:tc:opendocument:xmlns:manifest:1.0","manifest:full-path",a);b.setAttributeNS("urn:oasis:names:tc:opendocument:xmlns:manifest:1.0", "manifest:media-type",c);return b}function T(){var a=runtime.parseXML(''),c=a.documentElement,b=new xmldom.LSSerializer,e;for(e in O)O.hasOwnProperty(e)&&c.appendChild(ba(e,O[e]));b.filter=new odf.OdfNodeFilter;return'\n'+b.writeToString(a,odf.Namespaces.namespaceMap)}function D(){var a,c,e,d=odf.Namespaces.namespaceMap, k=new xmldom.LSSerializer,f=I("document-styles");c=s(U.rootElement.automaticStyles,"document-styles");e=U.rootElement.masterStyles.cloneNode(!0);a=w(U.rootElement.fontFaceDecls,[e,U.rootElement.styles,c]);b.removePrefixFromStyleNames(c,n,e);k.filter=new l(e,c);f+=k.writeToString(a,d);f+=k.writeToString(U.rootElement.styles,d);f+=k.writeToString(c,d);f+=k.writeToString(e,d);return f+""}function P(){var c,b,e=odf.Namespaces.namespaceMap,d=new xmldom.LSSerializer,k=I("document-content"); b=s(U.rootElement.automaticStyles,"document-content");c=w(U.rootElement.fontFaceDecls,[b]);d.filter=new a(U.rootElement.body,b);k+=d.writeToString(c,e);k+=d.writeToString(b,e);k+=d.writeToString(U.rootElement.body,e);return k+""}function Z(a,c){runtime.loadXML(a,function(a,b){if(a)c(a);else if(b){z(b);Y(b.documentElement);var d=u(b);d&&"document"===d.localName&&"urn:oasis:names:tc:opendocument:xmlns:office:1.0"===d.namespaceURI?(E(d),A(e.DONE)):A(e.INVALID)}else c("No DOM was loaded.")})} function C(a,c){var b;b=U.rootElement;var e=b.meta;e||(b.meta=e=document.createElementNS("urn:oasis:names:tc:opendocument:xmlns:office:1.0","meta"),d(b,e));b=e;a&&h.mapKeyValObjOntoNode(b,a,odf.Namespaces.lookupNamespaceURI);c&&h.removeKeyElementsFromNode(b,c,odf.Namespaces.lookupNamespaceURI)}function V(a,c){function b(a,c){var e;c||(c=a);e=document.createElementNS("urn:oasis:names:tc:opendocument:xmlns:office:1.0",c);r[a]=e;r.appendChild(e)}var d=new core.Zip("",null),k="application/vnd.oasis.opendocument."+ a+(!0===c?"-template":""),f=runtime.byteArrayFromString(k,"utf8"),r=U.rootElement,h=document.createElementNS("urn:oasis:names:tc:opendocument:xmlns:office:1.0",a);d.save("mimetype",f,!1,new Date);b("meta");b("settings");b("scripts");b("fontFaceDecls","font-face-decls");b("styles");b("automaticStyles","automatic-styles");b("masterStyles","master-styles");b("body");r.body.appendChild(h);O["/"]=k;O["settings.xml"]="text/xml";O["meta.xml"]="text/xml";O["styles.xml"]="text/xml";O["content.xml"]="text/xml"; A(e.DONE);return d}function $(){var a,c=new Date,b="";U.rootElement.settings&&U.rootElement.settings.firstElementChild&&(a=new xmldom.LSSerializer,b=I("document-settings"),a.filter=new odf.OdfNodeFilter,b+=a.writeToString(U.rootElement.settings,odf.Namespaces.namespaceMap),b+="");(a=b)?(a=runtime.byteArrayFromString(a,"utf8"),W.save("settings.xml",a,!0,c)):W.remove("settings.xml");b=runtime.getWindow();a="WebODF/"+webodf.Version;b&&(a=a+" "+b.navigator.userAgent);C({"meta:generator":a}, null);a=runtime.byteArrayFromString(G(),"utf8");W.save("meta.xml",a,!0,c);a=runtime.byteArrayFromString(D(),"utf8");W.save("styles.xml",a,!0,c);a=runtime.byteArrayFromString(P(),"utf8");W.save("content.xml",a,!0,c);a=runtime.byteArrayFromString(T(),"utf8");W.save("META-INF/manifest.xml",a,!0,c)}function ca(a,c){$();W.writeAs(a,function(a){c(a)})}var U=this,W,O={},aa,S="";this.onstatereadychange=f;this.state=this.onchange=null;this.getMetadata=y;this.setRootElement=E;this.getContentElement=function(){var a; aa||(a=U.rootElement.body,aa=h.getDirectChild(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","text")||h.getDirectChild(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","presentation")||h.getDirectChild(a,"urn:oasis:names:tc:opendocument:xmlns:office:1.0","spreadsheet"));if(!aa)throw"Could not find content element in .";return aa};this.getDocumentType=function(){var a=U.getContentElement();return a&&a.localName};this.isTemplate=function(){return"-template"===O["/"].substr(-9)}; this.setIsTemplate=function(a){var c=O["/"],b="-template"===c.substr(-9);a!==b&&(c=a?c+"-template":c.substr(0,c.length-9),O["/"]=c,a=runtime.byteArrayFromString(c,"utf8"),W.save("mimetype",a,!1,new Date))};this.getPart=function(a){return new odf.OdfPart(a,O[a],U,W)};this.getPartData=function(a,c){W.load(a,c)};this.setMetadata=C;this.incrementEditingCycles=function(){var a=y(odf.Namespaces.metans,"editing-cycles"),a=a?parseInt(a,10):0;isNaN(a)&&(a=0);C({"meta:editing-cycles":a+1},null);return a+1}; this.createByteArray=function(a,c){$();W.createByteArray(a,c)};this.saveAs=ca;this.save=function(a){ca(S,a)};this.getUrl=function(){return S};this.setBlob=function(a,c,b){b=m.convertBase64ToByteArray(b);W.save(a,b,!1,new Date);O.hasOwnProperty(a)&&runtime.log(a+" has been overwritten.");O[a]=c};this.removeBlob=function(a){var c=W.remove(a);runtime.assert(c,"file is not found: "+a);delete O[a]};this.state=e.LOADING;this.rootElement=function(a){var c=document.createElementNS(a.namespaceURI,a.localName), b;a=new a.Type;for(b in a)a.hasOwnProperty(b)&&(c[b]=a[b]);return c}({Type:odf.ODFDocumentElement,namespaceURI:odf.ODFDocumentElement.namespaceURI,localName:odf.ODFDocumentElement.localName});c===odf.OdfContainer.DocumentType.TEXT?W=V("text"):c===odf.OdfContainer.DocumentType.TEXT_TEMPLATE?W=V("text",!0):c===odf.OdfContainer.DocumentType.PRESENTATION?W=V("presentation"):c===odf.OdfContainer.DocumentType.PRESENTATION_TEMPLATE?W=V("presentation",!0):c===odf.OdfContainer.DocumentType.SPREADSHEET?W=V("spreadsheet"): c===odf.OdfContainer.DocumentType.SPREADSHEET_TEMPLATE?W=V("spreadsheet",!0):(S=c,W=new core.Zip(S,function(a,c){W=c;a?Z(S,function(c){a&&(W.error=a+"\n"+c,A(e.INVALID))}):R([{path:"styles.xml",handler:B},{path:"content.xml",handler:F},{path:"meta.xml",handler:J},{path:"settings.xml",handler:H},{path:"META-INF/manifest.xml",handler:Q}])}))};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,l,a,d){function b(a){var b=a.annotationEndElement,e=m.createRange(),d=a.getAttributeNS(odf.Namespaces.officens,"name");b&&(e.setStart(a,a.childNodes.length),e.setEnd(b,0),a=g.getTextNodes(e,!1),a.forEach(function(a){var b;a:{for(b=a.parentNode;b.namespaceURI!==odf.Namespaces.officens||"body"!==b.localName;){if(b.namespaceURI===c&&"webodf-annotationHighlight"===b.className&&b.getAttribute("annotation")===d){b=!0;break a}b=b.parentNode}b=!1}b||(b=m.createElement("span"), b.className="webodf-annotationHighlight",b.setAttribute("annotation",d),a.parentNode.replaceChild(b,a),b.appendChild(a))}));e.detach()}function h(c){var b=f.getSizer();c?(a.style.display="inline-block",b.style.paddingRight=e.getComputedStyle(a).width):(a.style.display="none",b.style.paddingRight=0);f.refreshSize()}function p(){n.sort(function(a,c){return 0!==(a.compareDocumentPosition(c)&Node.DOCUMENT_POSITION_FOLLOWING)?-1:1})}function q(){var c;for(c=0;c=(h.getBoundingClientRect().top-p.bottom)/b?e.style.top=Math.abs(h.getBoundingClientRect().top-p.bottom)/b+20+"px":e.style.top="0px");g.style.left=d.getBoundingClientRect().width/ b+"px";var d=g.style,h=g.getBoundingClientRect().left/b,m=g.getBoundingClientRect().top/b,p=e.getBoundingClientRect().left/b,q=e.getBoundingClientRect().top/b,l=0,E=0,l=p-h,l=l*l,E=q-m,E=E*E,h=Math.sqrt(l+E);d.width=h+"px";m=Math.asin((e.getBoundingClientRect().top-g.getBoundingClientRect().top)/(b*parseFloat(g.style.width)));g.style.transform="rotate("+m+"rad)";g.style.MozTransform="rotate("+m+"rad)";g.style.WebkitTransform="rotate("+m+"rad)";g.style.msTransform="rotate("+m+"rad)"}}var n=[],m=l.ownerDocument, g=odf.OdfUtils,e=runtime.getWindow(),c="http://www.w3.org/1999/xhtml";runtime.assert(Boolean(e),"Expected to be run in an environment which has a global window, like a browser.");this.rerenderAnnotations=q;this.rehighlightAnnotations=function(){n.forEach(function(a){b(a)})};this.getMinimumHeightForAnnotationPane=function(){return"none"!==a.style.display&&0p||l.bottom>p)f.scrollTop=l.bottom-l.top<=p-b?f.scrollTop+(l.bottom-p):f.scrollTop+(l.top-b);l.lefth&&(f.scrollLeft=l.right-l.left<=h-d?f.scrollLeft+(l.right-h):f.scrollLeft-(d-l.left))}}};(function(){function f(a,h,p,q,n){var m,g=0,e;for(e in a)if(a.hasOwnProperty(e)){if(g===p){m=e;break}g+=1}m?h.getPartData(a[m].href,function(c,e){if(c)runtime.log(c);else if(e){var k="@font-face { font-family: "+(a[m].family||m)+"; src: url(data:application/x-font-ttf;charset=binary;base64,"+d.convertUTF8ArrayToBase64(e)+') format("truetype"); }';try{q.insertRule(k,q.cssRules.length)}catch(g){runtime.log("Problem inserting rule in CSS: "+runtime.toJson(g)+"\nRule: "+k)}}else runtime.log("missing font data for "+ a[m].href);f(a,h,p+1,q,n)}):n&&n()}var l=xmldom.XPath,a=odf.OdfUtils,d=new core.Base64;odf.FontLoader=function(){this.loadFonts=function(b,d){for(var p=b.rootElement.fontFaceDecls;d.cssRules.length;)d.deleteRule(d.cssRules.length-1);if(p){var q={},n,m,g,e;if(p)for(p=l.getODFElementsWithXPath(p,"style:font-face[svg:font-face-src]",odf.Namespaces.lookupNamespaceURI),n=0;n text|list-item:first-child > :not(text|list):first-child:before',w+="{",w+="counter-increment: "+s+" 0;",w+="}",f(a,w));for(;p.counterIdStack.length>=q;)p.counterIdStack.pop();p.counterIdStack.push(s);u=p.contentRules[q.toString()]||"";for(w=1;w<=q;w+=1)u=u.replace(w+"webodf-listLevel",p.counterIdStack[w-1]);w='text|list[webodfhelper|counter-id="'+l+'"] > text|list-item > :not(text|list):first-child:before'; w+="{";w+=u;w+="counter-increment: "+s+";";w+="}";f(a,w)}for(d=d.firstElementChild;d;)b(c,d,g,p),d=d.nextElementSibling}else p.continuedCounterIdStack=[]}var d=0,e="",c={};this.createCounterRules=function(a,e,f){var h=e.getAttributeNS(p,"id"),n=[];f&&(f=f.getAttributeNS("urn:webodf:names:helper","counter-id"),n=c[f].slice(0));a=new l(a,n);h?h="Y"+h:(d+=1,h="X"+d);b(h,e,0,a);c[h+"-level1-1"]=a.counterIdStack};this.initialiseCreatedCounters=function(){var c;c="office|document{"+("counter-reset: "+e+ ";");c+="}";f(a,c)}}var d=odf.Namespaces.fons,b=odf.Namespaces.stylens,h=odf.Namespaces.textns,p=odf.Namespaces.xmlns,q={1:"decimal",a:"lower-latin",A:"upper-latin",i:"lower-roman",I:"upper-roman"};odf.ListStyleToCss=function(){function n(a){var b=r.parseLength(a);return b?c.convert(b.value,b.unit,"px"):(runtime.log("Could not parse value '"+a+"'."),0)}function m(a){return a.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}function g(a,c){var b;a&&(b=a.getAttributeNS(h,"style-name"));return b===c}function e(c, d,e){d=d.getElementsByTagNameNS(h,"list");c=new a(c);var f,r,n,l,u,A,E={},B;for(B=0;B text|list-item > text|list",x-=1;x=t&&t.getAttributeNS(d,"text-align")||"left";switch(x){case "end":x="right";break;case "start":x="left"}"label-alignment"===H?(N=Q&&Q.getAttributeNS(d,"margin-left")||"0px",R=Q&&Q.getAttributeNS(d,"text-indent")||"0px",I=Q&&Q.getAttributeNS(h,"label-followed-by"),Q=n(N)):(N=t&&t.getAttributeNS(h,"space-before")||"0px",z=t&&t.getAttributeNS(h,"min-label-width")||"0px", Y=t&&t.getAttributeNS(h,"min-label-distance")||"0px",Q=n(N)+n(z));t=q+" > text|list-item";t+="{";t+="margin-left: "+Q+"px;";t+="}";f(g,t);t=q+" > text|list-item > text|list";t+="{";t+="margin-left: "+-Q+"px;";t+="}";f(g,t);t=q+" > text|list-item > :not(text|list):first-child:before";t+="{";t+="text-align: "+x+";";t+="display: inline-block;";"label-alignment"===H?(t+="margin-left: "+R+";","listtab"===I&&(t+="padding-right: 0.2cm;")):(t+="min-width: "+z+";",t+="margin-left: "+(0===parseFloat(z)?"": "-")+z+";",t+="padding-right: "+Y+";");t+="}";f(g,t)}e=e.nextElementSibling}});e(a,g,r)}}})();odf.LazyStyleProperties=function(f,l){var a={};this.value=function(d){var b;a.hasOwnProperty(d)?b=a[d]:(b=l[d](),void 0===b&&f&&(b=f.value(d)),a[d]=b);return b};this.reset=function(d){f=d;a={}}}; odf.StyleParseUtils=function(){function f(a){var d,b;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;b=a&&a.unit;"px"===b?d=a.value:"cm"===b?d=96*(a.value/2.54):"mm"===b?d=96*(a.value/25.4):"in"===b?d=96*a.value:"pt"===b?d=a.value/0.75:"pc"===b&&(d=16*a.value);return d}var l=odf.Namespaces.stylens;this.parseLength=f;this.parsePositiveLengthOrPercent=function(a,d,b){var h;a&&(h=parseFloat(a.substr(0, a.indexOf("%"))),isNaN(h)&&(h=void 0));var p;void 0!==h?(b&&(p=b.value(d)),h=void 0===p?void 0:h*(p/100)):h=f(a);return h};this.getPropertiesElement=function(a,d,b){for(d=b?b.nextElementSibling:d.firstElementChild;null!==d&&(d.localName!==a||d.namespaceURI!==l);)d=d.nextElementSibling;return d};this.parseAttributeList=function(a){a&&(a=a.replace(/^\s*(.*?)\s*$/g,"$1"));return a&&0r.value&&(k="0.75pt"+f);f=k}else if(z.hasOwnProperty(e[1])){var k= a,h=e[0],r=e[1],m=R.parseLength(f),n=void 0,p=void 0,q=void 0,s=void 0,q=void 0;if(m&&"%"===m.unit){n=m.value/100;p=l(k.parentNode);for(s="0";p;){if(q=x.getDirectChild(p,g,"paragraph-properties"))if(q=R.parseLength(q.getAttributeNS(h,r))){if("%"!==q.unit){s=q.value*n+q.unit;break}n*=q.value/100}p=l(p)}f=s}}e[2]&&(b+=e[2]+":"+f+";")}return b}function d(a,c,b,e){return c+c+b+b+e+e}function b(a,c){var e=[a],d=c.derivedStyles;Object.keys(d).forEach(function(a){a=b(a,d[a]);e=e.concat(a)});return e}function h(a, c,e,d){function f(c,b){var e=[],d;c.forEach(function(a){g.forEach(function(c){e.push('draw|page[webodfhelper|page-style-name="'+c+'"] draw|frame[presentation|class="'+a+'"]')})});0v&&(c=v);for(b=Math.floor(c/a)*a;!e&&0<=b;)e=k[b],b-=a;for(e=e||y;e.nextBookmark&&e.nextBookmark.steps<= c;)d.check(),e=e.nextBookmark;runtime.assert(-1===c||e.steps<=c,"Bookmark @"+p(e)+" at step "+e.steps+" exceeds requested step of "+c);return e}function e(a){a.previousBookmark&&(a.previousBookmark.nextBookmark=a.nextBookmark);a.nextBookmark&&(a.nextBookmark.previousBookmark=a.previousBookmark)}function c(a){for(var c,b=null;!b&&a&&a!==l;)(c=n(a))&&(b=x[c])&&b.node!==a&&(runtime.log("Cloned node detected. Creating new bookmark"),b=null,a.removeAttributeNS(r,"nodeId")),a=a.parentNode;return b}var r= "urn:webodf:names:steps",k={},x={},t=core.DomUtils,y,v,s=Node.DOCUMENT_POSITION_FOLLOWING,w=Node.DOCUMENT_POSITION_PRECEDING,u;this.updateBookmark=function(c,d){var f,h=Math.ceil(c/a)*a,r,p,q;if(void 0!==v&&vr.steps)k[h]=p;u()};this.setToClosestStep=function(a,c){var b;u();b=g(a);b.setIteratorPosition(c); return b.steps};this.setToClosestDomPoint=function(a,b,e){var d,f;u();if(a===l&&0===b)d=y;else if(a===l&&b===l.childNodes.length)for(f in d=y,k)k.hasOwnProperty(f)&&(a=k[f],a.steps>d.steps&&(d=a));else if(d=c(a.childNodes.item(b)||a),!d)for(e.setUnfilteredPosition(a,b);!d&&e.previousNode();)d=c(e.getCurrentNode());d=d||y;void 0!==v&&d.steps>v&&(d=g(v));d.setIteratorPosition(e);return d.steps};this.damageCacheAfterStep=function(a){0>a&&(a=-1);void 0===v?v=a:ac)throw new RangeError("Requested steps is negative ("+c+")");for(e=p.setToClosestStep(c,l);en.comparePoints(f,0,c,e),c=f,e=e?0:f.childNodes.length);l.setUnfilteredPosition(c,e);h(l,d)||l.setUnfilteredPosition(c,e);d=l.container();e=l.unfilteredDomOffset();c=p.setToClosestDomPoint(d,e,l);if(0>n.comparePoints(l.container(),l.unfilteredDomOffset(),d,e))return 0=m.textNode.length?null:m.textNode.splitText(m.offset));for(c=m.textNode;c!==e;){c=c.parentNode;r=c.cloneNode(!1);k&&r.appendChild(k);if(x)for(;x&&x.nextSibling;)r.appendChild(x.nextSibling);else for(;c.firstChild;)r.appendChild(c.firstChild);c.parentNode.insertBefore(r,c.nextSibling);x=c;k=r}p.isListItem(k)&&(k=k.childNodes.item(0));h?k.setAttributeNS(q,"text:style-name",h):k.removeAttributeNS(q,"style-name");0===m.textNode.length&& m.textNode.parentNode.removeChild(m.textNode);a.emit(ops.OdtDocument.signalStepsInserted,{position:d});t&&b&&(a.moveCursor(f,d+1,0),a.emit(ops.Document.signalCursorMoved,t));a.fixCursorPositions();a.getOdfCanvas().refreshSize();a.emit(ops.OdtDocument.signalParagraphChanged,{paragraphElement:g,memberId:f,timeStamp:l});a.emit(ops.OdtDocument.signalParagraphChanged,{paragraphElement:k,memberId:f,timeStamp:l});a.getOdfCanvas().rerenderAnnotations();return!0};this.spec=function(){return{optype:"SplitParagraph", memberid:f,timestamp:l,position:d,sourceParagraphPosition:a,paragraphStyleName:h,moveCursor:b}}};ops.OpUpdateMember=function(){function f(a){var b="//dc:creator[@editinfo:memberid='"+l+"']";a=xmldom.XPath.getODFElementsWithXPath(a.getRootNode(),b,function(a){return"editinfo"===a?"urn:webodf:names:editinfo":odf.Namespaces.lookupNamespaceURI(a)});for(b=0;b=h.width&&(h=null),f.detach();else if(l.isCharacterElement(b.container)||l.isCharacterFrame(b.container))h=d.getBoundingClientRect(b.container); return h}var l=odf.OdfUtils,a=new odf.StepUtils,d=core.DomUtils,b=core.StepDirection.NEXT,h=gui.StepInfo.VisualDirection.LEFT_TO_RIGHT,p=gui.StepInfo.VisualDirection.RIGHT_TO_LEFT;this.getContentRect=f;this.moveToFilteredStep=function(a,d,m){function g(a,b){b.process(v,k,x)&&(a=!0,!t&&b.token&&(t=b.token));return a}var e=d===b,c,l,k,x,t,y=a.snapshot();c=!1;var v;do c=f(a),v={token:a.snapshot(),container:a.container,offset:a.offset,direction:d,visualDirection:d===b?h:p},l=a.nextStep()?f(a):null,a.restore(v.token), e?(k=c,x=l):(k=l,x=c),c=m.reduce(g,!1);while(!c&&a.advanceStep(d));c||m.forEach(function(a){!t&&a.token&&(t=a.token)});a.restore(t||y);return Boolean(t)}};gui.Caret=function(f,l,a,d){function b(){g.style.opacity="0"===g.style.opacity?"1":"0";w.trigger()}function h(){k.selectNodeContents(r);return k.getBoundingClientRect()}function p(){Object.keys(B).forEach(function(a){F[a]=B[a]})}function q(){if(!1===B.isShown||f.getSelectionType()!==ops.OdtCursor.RangeSelection||!d&&!f.getSelectedRange().collapsed)B.visibility="hidden",g.style.visibility="hidden",w.cancel();else if(B.visibility="visible",g.style.visibility="visible",!1===B.isFocused)g.style.opacity= "1",w.cancel();else{if(u||F.visibility!==B.visibility)g.style.opacity="1",w.cancel();w.trigger()}if(E||A){var a;a=f.getNode();var b,k,n=t.getBoundingClientRect(x.getSizer()),r=!1,q=0;a.removeAttributeNS("urn:webodf:names:cursor","caret-sizer-active");if(0a.height&&(a={top:a.top-(8-a.height)/2,height:8,right:a.right});m.style.height=a.height+"px";m.style.top=a.top+"px";m.style.left=a.right- a.width+"px";m.style.width=a.width?a.width+"px":"";c&&(a=runtime.getWindow().getComputedStyle(f.getNode(),null),a.font?c.style.font=a.font:(c.style.fontStyle=a.fontStyle,c.style.fontVariant=a.fontVariant,c.style.fontWeight=a.fontWeight,c.style.fontSize=a.fontSize,c.style.lineHeight=a.lineHeight,c.style.fontFamily=a.fontFamily))}B.isShown&&A&&l.scrollIntoView(g.getBoundingClientRect());F.isFocused!==B.isFocused&&e.markAsFocussed(B.isFocused);p();E=A=u=!1}function n(a){m.parentNode.removeChild(m);r.parentNode.removeChild(r); a()}var m,g,e,c,r,k,x=f.getDocument().getCanvas(),t=core.DomUtils,y=new gui.GuiStepUtils,v,s,w,u=!1,A=!1,E=!1,B={isFocused:!1,isShown:!0,visibility:"hidden"},F={isFocused:!B.isFocused,isShown:!B.isShown,visibility:"hidden"};this.handleUpdate=function(){E=!0;s.trigger()};this.refreshCursorBlinking=function(){u=!0;s.trigger()};this.setFocus=function(){B.isFocused=!0;s.trigger()};this.removeFocus=function(){B.isFocused=!1;s.trigger()};this.show=function(){B.isShown=!0;s.trigger()};this.hide=function(){B.isShown= !1;s.trigger()};this.setAvatarImageUrl=function(a){e.setImageUrl(a)};this.setColor=function(a){g.style.borderColor=a;e.setColor(a)};this.getCursor=function(){return f};this.getFocusElement=function(){return g};this.toggleHandleVisibility=function(){e.isVisible()?e.hide():e.show()};this.showHandle=function(){e.show()};this.hideHandle=function(){e.hide()};this.setOverlayElement=function(a){c=a;m.appendChild(a);E=!0;s.trigger()};this.ensureVisible=function(){A=!0;s.trigger()};this.getBoundingClientRect= function(){return t.getBoundingClientRect(m)};this.destroy=function(a){core.Async.destroyAll([s.destroy,w.destroy,e.destroy,n],a)};(function(){var c=f.getDocument(),d=[c.createRootFilter(f.getMemberId()),c.getPositionFilter()],h=c.getDOMDocument();k=h.createRange();r=h.createElement("span");r.className="webodf-caretSizer";r.textContent="|";f.getNode().appendChild(r);m=h.createElement("div");m.setAttributeNS("urn:webodf:names:editinfo","editinfo:memberid",f.getMemberId());m.className="webodf-caretOverlay"; g=h.createElement("div");g.className="caret";m.appendChild(g);e=new gui.Avatar(m,a);x.getSizer().appendChild(m);v=c.createStepIterator(f.getNode(),0,d,c.getRootNode());s=core.Task.createRedrawTask(q);w=core.Task.createTimeoutTask(b,500);s.triggerImmediate()})()};odf.TextSerializer=function(){function f(d){var b="",h=l.filter?l.filter.acceptNode(d):NodeFilter.FILTER_ACCEPT,p=d.nodeType,q;if((h===NodeFilter.FILTER_ACCEPT||h===NodeFilter.FILTER_SKIP)&&a.isTextContentContainingNode(d))for(q=d.firstChild;q;)b+=f(q),q=q.nextSibling;h===NodeFilter.FILTER_ACCEPT&&(p===Node.ELEMENT_NODE&&a.isParagraph(d)?b+="\n":p===Node.TEXT_NODE&&d.textContent&&(b+=d.textContent));return b}var l=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(l,a){var d;d=a.startContainer.ownerDocument.createElement("span");d.appendChild(a.cloneContents());d=f.writeToString(d);try{l.setData("text/plain",d)}catch(b){l.setData("Text",d)}};f=new odf.TextSerializer;f.filter=new odf.OdfNodeFilter};gui.Clipboard=function(f){this.setDataFromRange=function(l,a){var d,b=l.clipboardData;d=runtime.getWindow();!b&&d&&(b=d.clipboardData);b?(d=!0,f.exportRangeToDataTransfer(b,a),l.preventDefault()):d=!1;return d}};gui.SessionContext=function(f,l){var a=f.getOdtDocument(),d=odf.OdfUtils;this.isLocalCursorWithinOwnAnnotation=function(){var b=a.getCursor(l),f;if(!b)return!1;f=b&&b.getNode();b=a.getMember(l).getProperties().fullName;return(f=d.getParentAnnotation(f,a.getRootNode()))&&d.getAnnotationCreator(f)===b?!0:!1}};gui.StyleSummary=function(f){function l(a,d){var l=a+"|"+d,n;b.hasOwnProperty(l)||(n=[],f.forEach(function(b){b=(b=b.styleProperties[a])&&b[d];-1===n.indexOf(b)&&n.push(b)}),b[l]=n);return b[l]}function a(a,b,d){return function(){var f=l(a,b);return d.length>=f.length&&f.every(function(a){return-1!==d.indexOf(a)})}}function d(a,b){var d=l(a,b);return 1===d.length?d[0]:void 0}var b={};this.getPropertyValues=l;this.getCommonValue=d;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=d("style:text-properties","fo:font-size");return a&&parseFloat(a)};this.fontName=function(){return d("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,l,a,d,b,h,p){function q(){return V.value().styleSummary}function n(){return V.value().enabledFeatures}function m(a){var b;a.collapsed?(b=a.startContainer,b.hasChildNodes()&&a.startOffseta.clientWidth||a.scrollHeight>a.clientHeight)&&b.push(new g(a)),a=a.parentNode;b.push(new m(s));return b}function v(){var a; k()||(a=y(B),t(),B.focus(),a.forEach(function(a){a.restore()}))}var s=runtime.getWindow(),w={beforecut:!0,beforepaste:!0,longpress:!0,drag:!0,dragstop:!0},u={mousedown:!0,mouseup:!0,focus:!0},A={},E={},B,F=f.getCanvas().getElement(),J=this,H={};this.addFilter=function(a,b){e(a,!0).filters.push(b)};this.removeFilter=function(a,b){var c=e(a,!0),d=c.filters.indexOf(b);-1!==d&&c.filters.splice(d,1)};this.subscribe=c;this.unsubscribe=r;this.hasFocus=k;this.focus=v;this.getEventTrap=function(){return B}; this.setEditing=function(a){var b=k();b&&B.blur();a?B.removeAttribute("readOnly"):B.setAttribute("readOnly","true");b&&v()};this.destroy=function(a){r("touchstart",n);Object.keys(H).forEach(function(a){d(parseInt(a,10))});H.length=0;Object.keys(A).forEach(function(a){A[a].destroy()});A={};r("mousedown",x);r("mouseup",t);r("contextmenu",t);Object.keys(E).forEach(function(a){E[a].destroy()});E={};B.parentNode.removeChild(B);a()};(function(){var b=f.getOdfCanvas().getSizer(),e=b.ownerDocument;runtime.assert(Boolean(s), "EventManager requires a window object to operate correctly");B=e.createElement("textarea");B.id="eventTrap";B.setAttribute("tabindex","-1");B.setAttribute("readOnly","true");B.setAttribute("rows","1");b.appendChild(B);c("mousedown",x);c("mouseup",t);c("contextmenu",t);A.longpress=new a("longpress",["touchstart","touchmove","touchend"],h);A.drag=new a("drag",["touchstart","touchmove","touchend"],p);A.dragstop=new a("dragstop",["drag","touchend"],q);c("touchstart",n)})()};gui.IOSSafariSupport=function(f){function l(){a.innerHeight!==a.outerHeight&&(d.style.display="none",runtime.requestAnimationFrame(function(){d.style.display="block"}))}var a=runtime.getWindow(),d=f.getEventTrap();this.destroy=function(a){f.unsubscribe("focus",l);d.removeAttribute("autocapitalize");d.style.WebkitTransform="";a()};f.subscribe("focus",l);d.setAttribute("autocapitalize","off");d.style.WebkitTransform="translateX(-10000px)"};gui.HyperlinkController=function(f,l,a,d){function b(){var b=!0;!0===l.getState(gui.CommonConstraints.EDIT.REVIEW_MODE)&&(b=a.isLocalCursorWithinOwnAnnotation());b!==m&&(m=b,n.emit(gui.HyperlinkController.enabledChanged,m))}function h(a){a.getMemberId()===d&&b()}var p=odf.OdfUtils,q=f.getOdtDocument(),n=new core.EventNotifier([gui.HyperlinkController.enabledChanged]),m=!1;this.isEnabled=function(){return m};this.subscribe=function(a,b){n.subscribe(a,b)};this.unsubscribe=function(a,b){n.unsubscribe(a, b)};this.addHyperlink=function(a,b){if(m){var c=q.getCursorSelection(d),h=new ops.OpApplyHyperlink,k=[];if(0===c.length||b)b=b||a,h=new ops.OpInsertText,h.init({memberid:d,position:c.position,text:b}),c.length=b.length,k.push(h);h=new ops.OpApplyHyperlink;h.init({memberid:d,position:c.position,length:c.length,hyperlink:a});k.push(h);f.enqueue(k)}};this.removeHyperlinks=function(){if(m){var a=q.createPositionIterator(q.getRootNode()),b=q.getCursor(d).getSelectedRange(),c=p.getHyperlinkElements(b), h=b.collapsed&&1===c.length,k=q.getDOMDocument().createRange(),l=[],n,y;0!==c.length&&(c.forEach(function(a){k.selectNodeContents(a);n=q.convertDomToCursorRange({anchorNode:k.startContainer,anchorOffset:k.startOffset,focusNode:k.endContainer,focusOffset:k.endOffset});y=new ops.OpRemoveHyperlink;y.init({memberid:d,position:n.position,length:n.length});l.push(y)}),h||(h=c[0],-1===b.comparePoint(h,0)&&(k.setStart(h,0),k.setEnd(b.startContainer,b.startOffset),n=q.convertDomToCursorRange({anchorNode:k.startContainer, anchorOffset:k.startOffset,focusNode:k.endContainer,focusOffset:k.endOffset}),0h.width&&(p=h.width/l.width);l.height>h.height&&(s=h.height/l.height);h=Math.min(p,s);l={width:l.width*h,height:l.height* h}}h=l.width+"px";l=l.height+"px";var w=m.getOdfCanvas().odfContainer().rootElement.styles,p=a.toLowerCase(),s=q.hasOwnProperty(p)?q[p]:null,u,p=[];runtime.assert(null!==s,"Image type is not supported: "+a);s="Pictures/"+b.generateImageName()+s;u=new ops.OpSetBlob;u.init({memberid:d,filename:s,mimetype:a,content:c});p.push(u);e.getStyleElement("Graphics","graphic",[w])||(a=new ops.OpAddStyle,a.init({memberid:d,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"}}}),p.push(a));a=b.generateStyleName();c=new ops.OpAddStyle;c.init({memberid:d,styleName:a,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"}}});p.push(c);u=new ops.OpInsertImage;u.init({memberid:d,position:m.getCursorPosition(d), filename:s,frameWidth:h,frameHeight:l,frameStyleName:a,frameName:b.generateFrameName()});p.push(u);f.enqueue(p)}};this.destroy=function(a){m.unsubscribe(ops.Document.signalCursorMoved,p);l.unsubscribe(gui.CommonConstraints.EDIT.REVIEW_MODE,h);a()};m.subscribe(ops.Document.signalCursorMoved,p);l.subscribe(gui.CommonConstraints.EDIT.REVIEW_MODE,h);h()};gui.ImageController.enabledChanged="enabled/changed";gui.ImageSelector=function(f){function l(){var a=f.getSizer(),h=b.createElement("div");h.id="imageSelector";h.style.borderWidth="1px";a.appendChild(h);d.forEach(function(a){var d=b.createElement("div");d.className=a;h.appendChild(d)});return h}var a=odf.Namespaces.svgns,d="topLeft topRight bottomRight bottomLeft topMiddle rightMiddle bottomMiddle leftMiddle".split(" "),b=f.getElement().ownerDocument,h=!1;this.select=function(d){var q,n,m=b.getElementById("imageSelector");m||(m=l());h=!0;q=m.parentNode; n=d.getBoundingClientRect();var g=q.getBoundingClientRect(),e=f.getZoomLevel();q=(n.left-g.left)/e-1;n=(n.top-g.top)/e-1;m.style.display="block";m.style.left=q+"px";m.style.top=n+"px";m.style.width=d.getAttributeNS(a,"width");m.style.height=d.getAttributeNS(a,"height")};this.clearSelection=function(){var a;h&&(a=b.getElementById("imageSelector"))&&(a.style.display="none");h=!1};this.isSelectorElement=function(a){var d=b.getElementById("imageSelector");return d?a===d||a.parentNode===d:!1}};(function(){function f(f){function a(a){p=a.which&&String.fromCharCode(a.which)===h;h=void 0;return!1===p}function d(){p=!1}function b(a){h=a.data;p=!1}var h,p=!1;this.destroy=function(h){f.unsubscribe("textInput",d);f.unsubscribe("compositionend",b);f.removeFilter("keypress",a);h()};f.subscribe("textInput",d);f.subscribe("compositionend",b);f.addFilter("keypress",a)}gui.InputMethodEditor=function(l,a){function d(a){c&&(a?c.getNode().setAttributeNS(e,"composing","true"):(c.getNode().removeAttributeNS(e, "composing"),x.textContent=""))}function b(){y&&(y=!1,d(!1),s.emit(gui.InputMethodEditor.signalCompositionEnd,{data:v}),v="")}function h(){B||(B=!0,b(),c&&c.getSelectedRange().collapsed?r.value="":r.value=u.writeToString(c.getSelectedRange().cloneContents()),r.setSelectionRange(0,r.value.length),B=!1)}function p(){a.hasFocus()&&t.trigger()}function q(){w=void 0;t.cancel();d(!0);y||s.emit(gui.InputMethodEditor.signalCompositionStart,{data:""})}function n(a){a=w=a.data;y=!0;v+=a;t.trigger()}function m(a){a.data!== w&&(a=a.data,y=!0,v+=a,t.trigger());w=void 0}function g(){x.textContent=r.value}var e="urn:webodf:names:cursor",c=null,r=a.getEventTrap(),k=r.ownerDocument,x,t,y=!1,v="",s=new core.EventNotifier([gui.InputMethodEditor.signalCompositionStart,gui.InputMethodEditor.signalCompositionEnd]),w,u,A=[],E,B=!1;this.subscribe=s.subscribe;this.unsubscribe=s.unsubscribe;this.registerCursor=function(b){b.getMemberId()===l&&(c=b,c.getNode().appendChild(x),b.subscribe(ops.OdtCursor.signalCursorUpdated,p),a.subscribe("input", g),a.subscribe("compositionupdate",g))};this.removeCursor=function(b){c&&b===l&&(c.getNode().removeChild(x),c.unsubscribe(ops.OdtCursor.signalCursorUpdated,p),a.unsubscribe("input",g),a.unsubscribe("compositionupdate",g),c=null)};this.destroy=function(c){a.unsubscribe("compositionstart",q);a.unsubscribe("compositionend",n);a.unsubscribe("textInput",m);a.unsubscribe("keypress",b);a.unsubscribe("focus",h);core.Async.destroyAll(E,c)};(function(){u=new odf.TextSerializer;u.filter=new odf.OdfNodeFilter; a.subscribe("compositionstart",q);a.subscribe("compositionend",n);a.subscribe("textInput",m);a.subscribe("keypress",b);a.subscribe("focus",h);A.push(new f(a));E=A.map(function(a){return a.destroy});x=k.createElement("span");x.setAttribute("id","composer");t=core.Task.createTimeoutTask(h,1);E.push(t.destroy)})()};gui.InputMethodEditor.signalCompositionStart="input/compositionstart";gui.InputMethodEditor.signalCompositionEnd="input/compositionend"})();gui.MetadataController=function(f,l){function a(a){h.emit(gui.MetadataController.signalMetadataChanged,a)}function d(a){var b=-1===p.indexOf(a);b||runtime.log("Setting "+a+" is restricted.");return b}var b=f.getOdtDocument(),h=new core.EventNotifier([gui.MetadataController.signalMetadataChanged]),p=["dc:creator","dc:date","meta:editing-cycles","meta:editing-duration","meta:document-statistic"];this.setMetadata=function(a,b){var h={},g="",e;a&&Object.keys(a).filter(d).forEach(function(b){h[b]=a[b]}); b&&(g=b.filter(d).join(","));if(0b:!1}function a(a){null!==a&&!1===l(a)&&(b=Math.abs(a-f))}var d=this,b,h=gui.StepInfo.VisualDirection.LEFT_TO_RIGHT;this.token=void 0;this.process=function(b,f,n){var m,g;b.visualDirection===h?(m=f&&f.right,g=n&&n.left):(m=f&&f.left,g=n&&n.right);if(l(m)||l(g))return!0;if(f||n)a(m),a(g),d.token=b.token;return!1}};gui.LineBoundaryScanner=function(){var f=this,l=null;this.token=void 0;this.process=function(a,d,b){var h;if(h=b)if(l){var p=l;h=Math.min(p.bottom-p.top,b.bottom-b.top);var q=Math.max(p.top,b.top),p=Math.min(p.bottom,b.bottom)-q;h=0.4>=(0b?a.previousSibling:a.nextSibling,c(g)===NodeFilter.FILTER_ACCEPT&&(e=g),a=a.parentNode;return e}function d(a,c){var e;return null===a?r.NO_NEIGHBOUR:p.isCharacterElement(a)?r.SPACE_CHAR:a.nodeType===b||p.isTextSpan(a)||p.isHyperlink(a)?(e=a.textContent.charAt(c()),n.test(e)?r.SPACE_CHAR:q.test(e)?r.PUNCTUATION_CHAR:r.WORD_CHAR):r.OTHER}var b=Node.TEXT_NODE,h=Node.ELEMENT_NODE, p=odf.OdfUtils,q=/[!-#%-*,-\/:-;?-@\[-\]_{}\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]/, n=/\s/,m=core.PositionFilter.FilterResult.FILTER_ACCEPT,g=core.PositionFilter.FilterResult.FILTER_REJECT,e=odf.WordBoundaryFilter.IncludeWhitespace.TRAILING,c=odf.WordBoundaryFilter.IncludeWhitespace.LEADING,r={NO_NEIGHBOUR:0,SPACE_CHAR:1,PUNCTUATION_CHAR:2,WORD_CHAR:3,OTHER:4};this.acceptPosition=function(b){var f=b.container(),p=b.leftNode(),n=b.rightNode(),q=b.unfilteredDomOffset,s=function(){return b.unfilteredDomOffset()-1};f.nodeType===h&&(null===n&&(n=a(f,1,b.getNodeFilter())),null===p&&(p= a(f,-1,b.getNodeFilter())));f!==n&&(q=function(){return 0});f!==p&&null!==p&&(s=function(){return p.textContent.length-1});f=d(p,s);n=d(n,q);return f===r.WORD_CHAR&&n===r.WORD_CHAR||f===r.PUNCTUATION_CHAR&&n===r.PUNCTUATION_CHAR||l===e&&f!==r.NO_NEIGHBOUR&&n===r.SPACE_CHAR||l===c&&f===r.SPACE_CHAR&&n!==r.NO_NEIGHBOUR?g:m}};odf.WordBoundaryFilter.IncludeWhitespace={None:0,TRAILING:1,LEADING:2};gui.SelectionController=function(f,l){function a(a){var b=a.spec();if(a.isEdit||b.memberid===l)E=void 0,B.cancel()}function d(){var a=t.getCursor(l).getNode();return t.createStepIterator(a,0,[s,u],t.getRootElement(a))}function b(a,b,c){c=new odf.WordBoundaryFilter(t,c);var e=t.getRootElement(a)||t.getRootNode(),d=t.createRootFilter(e);return t.createStepIterator(a,b,[s,d,c],e)}function h(a,b){return b?{anchorNode:a.startContainer,anchorOffset:a.startOffset,focusNode:a.endContainer,focusOffset:a.endOffset}: {anchorNode:a.endContainer,anchorOffset:a.endOffset,focusNode:a.startContainer,focusOffset:a.startOffset}}function p(a,b,c){var e=new ops.OpMoveCursor;e.init({memberid:l,position:a,length:b||0,selectionType:c});return e}function q(a,b,c){var e;e=t.getCursor(l);e=h(e.getSelectedRange(),e.hasForwardSelection());e.focusNode=a;e.focusOffset=b;c||(e.anchorNode=e.focusNode,e.anchorOffset=e.focusOffset);a=t.convertDomToCursorRange(e);f.enqueue([p(a.position,a.length)])}function n(a){var c;c=b(a.startContainer, a.startOffset,F);c.roundToPreviousStep()&&a.setStart(c.container(),c.offset());c=b(a.endContainer,a.endOffset,J);c.roundToNextStep()&&a.setEnd(c.container(),c.offset())}function m(a){var b=v.getParagraphElements(a),c=b[0],b=b[b.length-1];c&&a.setStart(c,0);b&&(v.isParagraph(a.endContainer)&&0===a.endOffset?a.setEndBefore(b):a.setEnd(b,b.childNodes.length))}function g(a,b,c,e){var d,f;e?(d=c.startContainer,f=c.startOffset):(d=c.endContainer,f=c.endOffset);y.containsNode(a,d)||(f=0>y.comparePoints(a, 0,d,f)?0:a.childNodes.length,d=a);a=t.createStepIterator(d,f,b,v.getParagraphElement(d)||a);a.roundToClosestStep()||runtime.assert(!1,"No step found in requested range");e?c.setStart(a.container(),a.offset()):c.setEnd(a.container(),a.offset())}function e(a,b){var c=d();c.advanceStep(a)&&q(c.container(),c.offset(),b)}function c(a,b){var c,e=E,f=[new gui.LineBoundaryScanner,new gui.ParagraphBoundaryScanner];void 0===e&&A&&(e=A());isNaN(e)||(c=d(),w.moveToFilteredStep(c,a,f)&&c.advanceStep(a)&&(f=[new gui.ClosestXOffsetScanner(e), new gui.LineBoundaryScanner,new gui.ParagraphBoundaryScanner],w.moveToFilteredStep(c,a,f)&&(q(c.container(),c.offset(),b),E=e,B.restart())))}function r(a,b){var c=d(),e=[new gui.LineBoundaryScanner,new gui.ParagraphBoundaryScanner];w.moveToFilteredStep(c,a,e)&&q(c.container(),c.offset(),b)}function k(a,c){var e=t.getCursor(l),e=h(e.getSelectedRange(),e.hasForwardSelection()),e=b(e.focusNode,e.focusOffset,F);e.advanceStep(a)&&q(e.container(),e.offset(),c)}function x(a,b,c){var e=!1,d=t.getCursor(l), d=h(d.getSelectedRange(),d.hasForwardSelection()),e=t.getRootElement(d.focusNode);runtime.assert(Boolean(e),"SelectionController: Cursor outside root");d=t.createStepIterator(d.focusNode,d.focusOffset,[s,u],e);d.roundToClosestStep();d.advanceStep(a)&&(c=c(d.container()))&&(a===H?(d.setPosition(c,0),e=d.roundToNextStep()):(d.setPosition(c,c.childNodes.length),e=d.roundToPreviousStep()),e&&q(d.container(),d.offset(),b))}var t=f.getOdtDocument(),y=core.DomUtils,v=odf.OdfUtils,s=t.getPositionFilter(), w=new gui.GuiStepUtils,u=t.createRootFilter(l),A=null,E,B,F=odf.WordBoundaryFilter.IncludeWhitespace.TRAILING,J=odf.WordBoundaryFilter.IncludeWhitespace.LEADING,H=core.StepDirection.PREVIOUS,Q=core.StepDirection.NEXT;this.selectionToRange=function(a){var b=0<=y.comparePoints(a.anchorNode,a.anchorOffset,a.focusNode,a.focusOffset),c=a.focusNode.ownerDocument.createRange();b?(c.setStart(a.anchorNode,a.anchorOffset),c.setEnd(a.focusNode,a.focusOffset)):(c.setStart(a.focusNode,a.focusOffset),c.setEnd(a.anchorNode, a.anchorOffset));return{range:c,hasForwardSelection:b}};this.rangeToSelection=h;this.selectImage=function(a){var b=t.getRootElement(a),c=t.createRootFilter(b),b=t.createStepIterator(a,0,[c,t.getPositionFilter()],b),e;b.roundToPreviousStep()||runtime.assert(!1,"No walkable position before frame");c=b.container();e=b.offset();b.setPosition(a,a.childNodes.length);b.roundToNextStep()||runtime.assert(!1,"No walkable position after frame");a=t.convertDomToCursorRange({anchorNode:c,anchorOffset:e,focusNode:b.container(), focusOffset:b.offset()});a=p(a.position,a.length,ops.OdtCursor.RegionSelection);f.enqueue([a])};this.expandToWordBoundaries=n;this.expandToParagraphBoundaries=m;this.selectRange=function(a,b,c){var e=t.getOdfCanvas().getElement(),d,k=[s];d=y.containsNode(e,a.startContainer);e=y.containsNode(e,a.endContainer);if(d||e)if(d&&e&&(2===c?n(a):3<=c&&m(a)),(c=b?t.getRootElement(a.startContainer):t.getRootElement(a.endContainer))||(c=t.getRootNode()),k.push(t.createRootFilter(c)),g(c,k,a,!0),g(c,k,a,!1),a= h(a,b),b=t.convertDomToCursorRange(a),a=t.getCursorSelection(l),b.position!==a.position||b.length!==a.length)a=p(b.position,b.length,ops.OdtCursor.RangeSelection),f.enqueue([a])};this.moveCursorToLeft=function(){e(H,!1);return!0};this.moveCursorToRight=function(){e(Q,!1);return!0};this.extendSelectionToLeft=function(){e(H,!0);return!0};this.extendSelectionToRight=function(){e(Q,!0);return!0};this.setCaretXPositionLocator=function(a){A=a};this.moveCursorUp=function(){c(H,!1);return!0};this.moveCursorDown= function(){c(Q,!1);return!0};this.extendSelectionUp=function(){c(H,!0);return!0};this.extendSelectionDown=function(){c(Q,!0);return!0};this.moveCursorBeforeWord=function(){k(H,!1);return!0};this.moveCursorPastWord=function(){k(Q,!1);return!0};this.extendSelectionBeforeWord=function(){k(H,!0);return!0};this.extendSelectionPastWord=function(){k(Q,!0);return!0};this.moveCursorToLineStart=function(){r(H,!1);return!0};this.moveCursorToLineEnd=function(){r(Q,!1);return!0};this.extendSelectionToLineStart= function(){r(H,!0);return!0};this.extendSelectionToLineEnd=function(){r(Q,!0);return!0};this.extendSelectionToParagraphStart=function(){x(H,!0,v.getParagraphElement);return!0};this.extendSelectionToParagraphEnd=function(){x(Q,!0,v.getParagraphElement);return!0};this.moveCursorToParagraphStart=function(){x(H,!1,v.getParagraphElement);return!0};this.moveCursorToParagraphEnd=function(){x(Q,!1,v.getParagraphElement);return!0};this.moveCursorToDocumentStart=function(){x(H,!1,t.getRootElement);return!0}; this.moveCursorToDocumentEnd=function(){x(Q,!1,t.getRootElement);return!0};this.extendSelectionToDocumentStart=function(){x(H,!0,t.getRootElement);return!0};this.extendSelectionToDocumentEnd=function(){x(Q,!0,t.getRootElement);return!0};this.extendSelectionToEntireDocument=function(){var a=t.getCursor(l),a=t.getRootElement(a.getNode()),b,c,e;runtime.assert(Boolean(a),"SelectionController: Cursor outside root");e=t.createStepIterator(a,0,[s,u],a);e.roundToClosestStep();b=e.container();c=e.offset(); e.setPosition(a,a.childNodes.length);e.roundToClosestStep();a=t.convertDomToCursorRange({anchorNode:b,anchorOffset:c,focusNode:e.container(),focusOffset:e.offset()});f.enqueue([p(a.position,a.length)]);return!0};this.destroy=function(b){t.unsubscribe(ops.OdtDocument.signalOperationStart,a);core.Async.destroyAll([B.destroy],b)};(function(){B=core.Task.createTimeoutTask(function(){E=void 0},2E3);t.subscribe(ops.OdtDocument.signalOperationStart,a)})()};gui.TextController=function(f,l,a,d,b,h){function p(){x=!0===l.getState(gui.CommonConstraints.EDIT.REVIEW_MODE)?a.isLocalCursorWithinOwnAnnotation():!0}function q(a){a.getMemberId()===d&&p()}function n(a,b,e){var d=[c.getPositionFilter()];e&&d.push(c.createRootFilter(a.startContainer));e=c.createStepIterator(a.startContainer,a.startOffset,d,b);e.roundToClosestStep()||runtime.assert(!1,"No walkable step found in paragraph element at range start");b=c.convertDomPointToCursorStep(e.container(),e.offset()); a.collapsed?a=b:(e.setPosition(a.endContainer,a.endOffset),e.roundToClosestStep()||runtime.assert(!1,"No walkable step found in paragraph element at range end"),a=c.convertDomPointToCursorStep(e.container(),e.offset()));return{position:b,length:a-b}}function m(a){var b,c,e,f=r.getParagraphElements(a),g=a.cloneRange(),h=[];b=f[0];1a.length&&(a.position+=a.length,a.length=-a.length);return a}function e(a){if(!x)return!1;var b,e=c.getCursor(d).getSelectedRange().cloneRange(), k=g(c.getCursorSelection(d)),h;if(0===k.length){k=void 0;b=c.getCursor(d).getNode();h=c.getRootElement(b);var l=[c.getPositionFilter(),c.createRootFilter(h)];h=c.createStepIterator(b,0,l,h);h.roundToClosestStep()&&(a?h.nextStep():h.previousStep())&&(k=g(c.convertDomToCursorRange({anchorNode:b,anchorOffset:0,focusNode:h.container(),focusOffset:h.offset()})),a?(e.setStart(b,0),e.setEnd(h.container(),h.offset())):(e.setStart(h.container(),h.offset()),e.setEnd(b,0)))}k&&f.enqueue(m(e));return void 0!== k}var c=f.getOdtDocument(),r=odf.OdfUtils,k=core.DomUtils,x=!1,t=odf.Namespaces.textns,y=core.StepDirection.NEXT;this.isEnabled=function(){return x};this.enqueueParagraphSplittingOps=function(){if(!x)return!1;var a=c.getCursor(d),b=a.getSelectedRange(),e=g(c.getCursorSelection(d)),k=[],a=r.getParagraphElement(a.getNode()),l=a.getAttributeNS(t,"style-name")||"";0e.left&&(e=w(d)))b.focusNode=e.container,b.focusOffset=e.offset,c&&(b.anchorNode=b.focusNode,b.anchorOffset=b.focusOffset)}else D.isImage(b.focusNode.firstChild)&&1===b.focusOffset&&D.isCharacterFrame(b.focusNode)&&(e=w(b.focusNode))&&(b.anchorNode=b.focusNode=e.container,b.anchorOffset=b.focusOffset=e.offset);b.anchorNode&&b.focusNode&&(b=X.selectionToRange(b),X.selectRange(b.range,b.hasForwardSelection,0===a.button?a.detail:0));L.focus()}function A(a){var b;if(b=p(a.clientX,a.clientY))a= b.container,b=b.offset,a={anchorNode:a,anchorOffset:b,focusNode:a,focusOffset:b},a=X.selectionToRange(a),X.selectRange(a.range,a.hasForwardSelection,2),L.focus()}function E(a){var b=h(a),c,e,f;ja.processRequests();ca&&(D.isImage(b)&&D.isCharacterFrame(b.parentNode)&&R.getSelection().isCollapsed?(X.selectImage(b.parentNode),L.focus()):la.isSelectorElement(b)?L.focus():W?(b=d.getSelectedRange(),e=b.collapsed,D.isImage(b.endContainer)&&0===b.endOffset&&D.isCharacterFrame(b.endContainer.parentNode)&& (f=b.endContainer.parentNode,f=w(f))&&(b.setEnd(f.container,f.offset),e&&b.collapse(!1)),X.selectRange(b,d.hasForwardSelection(),0===a.button?a.detail:0),L.focus()):ta?u(a):(c=T.cloneEvent(a),aa=runtime.setTimeout(function(){u(c)},0)),na=0,W=ca=!1)}function B(b){var c=I.getCursor(a).getSelectedRange();c.collapsed||P.exportRangeToDataTransfer(b.dataTransfer,c)}function F(){ca&&L.focus();na=0;W=ca=!1}function J(a){E(a)}function H(a){var b=h(a),c=null;"annotationRemoveButton"===b.className?(runtime.assert(ea, "Remove buttons are displayed on annotations while annotation editing is disabled in the controller."),c=b.parentNode.getElementsByTagNameNS(odf.Namespaces.officens,"annotation").item(0),ga.removeAnnotation(c),L.focus()):"webodf-draggable"!==b.getAttribute("class")&&E(a)}function Q(a){(a=a.data)&&(-1===a.indexOf("\n")?ha.insertText(a):pa.paste(a))}function N(a){return function(){a();return!0}}function z(b){return function(c){return I.getCursor(a).getSelectionType()===ops.OdtCursor.RangeSelection? b(c):!0}}function Y(a){L.unsubscribe("keydown",C.handleEvent);L.unsubscribe("keypress",V.handleEvent);L.unsubscribe("keyup",$.handleEvent);L.unsubscribe("copy",m);L.unsubscribe("mousedown",s);L.unsubscribe("mousemove",ja.trigger);L.unsubscribe("mouseup",H);L.unsubscribe("contextmenu",J);L.unsubscribe("dragstart",B);L.unsubscribe("dragend",F);L.unsubscribe("click",oa.handleClick);L.unsubscribe("longpress",A);L.unsubscribe("drag",t);L.unsubscribe("dragstop",y);I.unsubscribe(ops.OdtDocument.signalOperationEnd, fa.trigger);I.unsubscribe(ops.Document.signalCursorAdded,ka.registerCursor);I.unsubscribe(ops.Document.signalCursorRemoved,ka.removeCursor);I.unsubscribe(ops.OdtDocument.signalOperationEnd,c);a()}var R=runtime.getWindow(),I=l.getOdtDocument(),G=new gui.SessionConstraints,ba=new gui.SessionContext(l,a),T=core.DomUtils,D=odf.OdfUtils,P=new gui.MimeDataExporter,Z=new gui.Clipboard(P),C=new gui.KeyboardHandler,V=new gui.KeyboardHandler,$=new gui.KeyboardHandler,ca=!1,U=new odf.ObjectNameGenerator(I.getOdfCanvas().odfContainer(), a),W=!1,O=null,aa,S=null,L=new gui.EventManager(I),ea=b.annotationsEnabled,ga=new gui.AnnotationController(l,G,a),da=new gui.DirectFormattingController(l,G,ba,a,U,b.directTextStylingEnabled,b.directParagraphStylingEnabled),ha=new gui.TextController(l,G,ba,a,da.createCursorStyleOp,da.createParagraphStyleOps),ma=new gui.ImageController(l,G,ba,a,U),la=new gui.ImageSelector(I.getOdfCanvas()),ia=I.createPositionIterator(I.getRootNode()),ja,fa,pa=new gui.PasteController(l,G,ba,a),ka=new gui.InputMethodEditor(a, L),na=0,oa=new gui.HyperlinkClickHandler(I.getOdfCanvas().getElement,C,$),qa=new gui.HyperlinkController(l,G,ba,a),X=new gui.SelectionController(l,a),ua=new gui.MetadataController(l,a),K=gui.KeyboardHandler.Modifier,M=gui.KeyboardHandler.KeyCode,ra=-1!==R.navigator.appVersion.toLowerCase().indexOf("mac"),ta=-1!==["iPad","iPod","iPhone"].indexOf(R.navigator.platform),sa;runtime.assert(null!==R,"Expected to be run in an environment which has a global window, like a browser.");this.undo=k;this.redo= x;this.insertLocalCursor=function(){runtime.assert(void 0===l.getOdtDocument().getCursor(a),"Inserting local cursor a second time.");var b=new ops.OpAddCursor;b.init({memberid:a});l.enqueue([b]);L.focus()};this.removeLocalCursor=function(){runtime.assert(void 0!==l.getOdtDocument().getCursor(a),"Removing local cursor without inserting before.");var b=new ops.OpRemoveCursor;b.init({memberid:a});l.enqueue([b])};this.startEditing=function(){ka.subscribe(gui.InputMethodEditor.signalCompositionStart,ha.removeCurrentSelection); ka.subscribe(gui.InputMethodEditor.signalCompositionEnd,Q);L.subscribe("beforecut",n);L.subscribe("cut",q);L.subscribe("beforepaste",e);L.subscribe("paste",g);S&&S.initialize();L.setEditing(!0);oa.setModifier(ra?K.Meta:K.Ctrl);C.bind(M.Backspace,K.None,N(ha.removeTextByBackspaceKey),!0);C.bind(M.Delete,K.None,ha.removeTextByDeleteKey);C.bind(M.Tab,K.None,z(function(){ha.insertText("\t");return!0}));ra?(C.bind(M.Clear,K.None,ha.removeCurrentSelection),C.bind(M.B,K.Meta,z(da.toggleBold)),C.bind(M.I, K.Meta,z(da.toggleItalic)),C.bind(M.U,K.Meta,z(da.toggleUnderline)),C.bind(M.L,K.MetaShift,z(da.alignParagraphLeft)),C.bind(M.E,K.MetaShift,z(da.alignParagraphCenter)),C.bind(M.R,K.MetaShift,z(da.alignParagraphRight)),C.bind(M.J,K.MetaShift,z(da.alignParagraphJustified)),ea&&C.bind(M.C,K.MetaShift,ga.addAnnotation),C.bind(M.Z,K.Meta,k),C.bind(M.Z,K.MetaShift,x)):(C.bind(M.B,K.Ctrl,z(da.toggleBold)),C.bind(M.I,K.Ctrl,z(da.toggleItalic)),C.bind(M.U,K.Ctrl,z(da.toggleUnderline)),C.bind(M.L,K.CtrlShift, z(da.alignParagraphLeft)),C.bind(M.E,K.CtrlShift,z(da.alignParagraphCenter)),C.bind(M.R,K.CtrlShift,z(da.alignParagraphRight)),C.bind(M.J,K.CtrlShift,z(da.alignParagraphJustified)),ea&&C.bind(M.C,K.CtrlAlt,ga.addAnnotation),C.bind(M.Z,K.Ctrl,k),C.bind(M.Z,K.CtrlShift,x));V.setDefault(z(function(a){var b;b=null===a.which||void 0===a.which?String.fromCharCode(a.keyCode):0!==a.which&&0!==a.charCode?String.fromCharCode(a.which):null;return!b||a.altKey||a.ctrlKey||a.metaKey?!1:(ha.insertText(b),!0)})); V.bind(M.Enter,K.None,z(ha.enqueueParagraphSplittingOps))};this.endEditing=function(){ka.unsubscribe(gui.InputMethodEditor.signalCompositionStart,ha.removeCurrentSelection);ka.unsubscribe(gui.InputMethodEditor.signalCompositionEnd,Q);L.unsubscribe("cut",q);L.unsubscribe("beforecut",n);L.unsubscribe("paste",g);L.unsubscribe("beforepaste",e);L.setEditing(!1);oa.setModifier(K.None);C.bind(M.Backspace,K.None,function(){return!0},!0);C.unbind(M.Delete,K.None);C.unbind(M.Tab,K.None);ra?(C.unbind(M.Clear, K.None),C.unbind(M.B,K.Meta),C.unbind(M.I,K.Meta),C.unbind(M.U,K.Meta),C.unbind(M.L,K.MetaShift),C.unbind(M.E,K.MetaShift),C.unbind(M.R,K.MetaShift),C.unbind(M.J,K.MetaShift),ea&&C.unbind(M.C,K.MetaShift),C.unbind(M.Z,K.Meta),C.unbind(M.Z,K.MetaShift)):(C.unbind(M.B,K.Ctrl),C.unbind(M.I,K.Ctrl),C.unbind(M.U,K.Ctrl),C.unbind(M.L,K.CtrlShift),C.unbind(M.E,K.CtrlShift),C.unbind(M.R,K.CtrlShift),C.unbind(M.J,K.CtrlShift),ea&&C.unbind(M.C,K.CtrlAlt),C.unbind(M.Z,K.Ctrl),C.unbind(M.Z,K.CtrlShift));V.setDefault(null); V.unbind(M.Enter,K.None)};this.getInputMemberId=function(){return a};this.getSession=function(){return l};this.getSessionConstraints=function(){return G};this.setUndoManager=function(a){S&&S.unsubscribe(gui.UndoManager.signalUndoStackChanged,r);if(S=a)S.setDocument(I),S.setPlaybackFunction(l.enqueue),S.subscribe(gui.UndoManager.signalUndoStackChanged,r)};this.getUndoManager=function(){return S};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:C,keypress:V}};this.destroy=function(a){var b=[ja.destroy,fa.destroy,da.destroy,ka.destroy,L.destroy,oa.destroy,qa.destroy,ua.destroy,X.destroy, ha.destroy,Y];sa&&b.unshift(sa.destroy);runtime.clearTimeout(aa);core.Async.destroyAll(b,a)};ja=core.Task.createRedrawTask(v);fa=core.Task.createRedrawTask(function(){var b=I.getCursor(a);if(b&&b.getSelectionType()===ops.OdtCursor.RegionSelection&&(b=D.getImageElements(b.getSelectedRange())[0])){la.select(b.parentNode);return}la.clearSelection()});C.bind(M.Left,K.None,z(X.moveCursorToLeft));C.bind(M.Right,K.None,z(X.moveCursorToRight));C.bind(M.Up,K.None,z(X.moveCursorUp));C.bind(M.Down,K.None,z(X.moveCursorDown)); C.bind(M.Left,K.Shift,z(X.extendSelectionToLeft));C.bind(M.Right,K.Shift,z(X.extendSelectionToRight));C.bind(M.Up,K.Shift,z(X.extendSelectionUp));C.bind(M.Down,K.Shift,z(X.extendSelectionDown));C.bind(M.Home,K.None,z(X.moveCursorToLineStart));C.bind(M.End,K.None,z(X.moveCursorToLineEnd));C.bind(M.Home,K.Ctrl,z(X.moveCursorToDocumentStart));C.bind(M.End,K.Ctrl,z(X.moveCursorToDocumentEnd));C.bind(M.Home,K.Shift,z(X.extendSelectionToLineStart));C.bind(M.End,K.Shift,z(X.extendSelectionToLineEnd));C.bind(M.Up, K.CtrlShift,z(X.extendSelectionToParagraphStart));C.bind(M.Down,K.CtrlShift,z(X.extendSelectionToParagraphEnd));C.bind(M.Home,K.CtrlShift,z(X.extendSelectionToDocumentStart));C.bind(M.End,K.CtrlShift,z(X.extendSelectionToDocumentEnd));ra?(C.bind(M.Left,K.Alt,z(X.moveCursorBeforeWord)),C.bind(M.Right,K.Alt,z(X.moveCursorPastWord)),C.bind(M.Left,K.Meta,z(X.moveCursorToLineStart)),C.bind(M.Right,K.Meta,z(X.moveCursorToLineEnd)),C.bind(M.Home,K.Meta,z(X.moveCursorToDocumentStart)),C.bind(M.End,K.Meta, z(X.moveCursorToDocumentEnd)),C.bind(M.Left,K.AltShift,z(X.extendSelectionBeforeWord)),C.bind(M.Right,K.AltShift,z(X.extendSelectionPastWord)),C.bind(M.Left,K.MetaShift,z(X.extendSelectionToLineStart)),C.bind(M.Right,K.MetaShift,z(X.extendSelectionToLineEnd)),C.bind(M.Up,K.AltShift,z(X.extendSelectionToParagraphStart)),C.bind(M.Down,K.AltShift,z(X.extendSelectionToParagraphEnd)),C.bind(M.Up,K.MetaShift,z(X.extendSelectionToDocumentStart)),C.bind(M.Down,K.MetaShift,z(X.extendSelectionToDocumentEnd)), C.bind(M.A,K.Meta,z(X.extendSelectionToEntireDocument))):(C.bind(M.Left,K.Ctrl,z(X.moveCursorBeforeWord)),C.bind(M.Right,K.Ctrl,z(X.moveCursorPastWord)),C.bind(M.Left,K.CtrlShift,z(X.extendSelectionBeforeWord)),C.bind(M.Right,K.CtrlShift,z(X.extendSelectionPastWord)),C.bind(M.A,K.Ctrl,z(X.extendSelectionToEntireDocument)));ta&&(sa=new gui.IOSSafariSupport(L));L.subscribe("keydown",C.handleEvent);L.subscribe("keypress",V.handleEvent);L.subscribe("keyup",$.handleEvent);L.subscribe("copy",m);L.subscribe("mousedown", s);L.subscribe("mousemove",ja.trigger);L.subscribe("mouseup",H);L.subscribe("contextmenu",J);L.subscribe("dragstart",B);L.subscribe("dragend",F);L.subscribe("click",oa.handleClick);L.subscribe("longpress",A);L.subscribe("drag",t);L.subscribe("dragstop",y);I.subscribe(ops.OdtDocument.signalOperationEnd,fa.trigger);I.subscribe(ops.Document.signalCursorAdded,ka.registerCursor);I.subscribe(ops.Document.signalCursorRemoved,ka.removeCursor);I.subscribe(ops.OdtDocument.signalOperationEnd,c)}})();gui.CaretManager=function(f,l){function a(a){return h.hasOwnProperty(a)?h[a]:null}function d(){return Object.keys(h).map(function(a){return h[a]})}function b(a){var b=h[a];b&&(delete h[a],a===f.getInputMemberId()?(q.unsubscribe(ops.OdtDocument.signalProcessingBatchEnd,b.ensureVisible),q.unsubscribe(ops.Document.signalCursorMoved,b.refreshCursorBlinking),n.unsubscribe("compositionupdate",b.handleUpdate),n.unsubscribe("compositionend",b.handleUpdate),n.unsubscribe("focus",b.setFocus),n.unsubscribe("blur", b.removeFocus),p.removeEventListener("focus",b.show,!1),p.removeEventListener("blur",b.hide,!1)):q.unsubscribe(ops.OdtDocument.signalProcessingBatchEnd,b.handleUpdate),b.destroy(function(){}))}var h={},p=runtime.getWindow(),q=f.getSession().getOdtDocument(),n=f.getEventManager();this.registerCursor=function(a,b,e){var c=a.getMemberId();a=new gui.Caret(a,l,b,e);h[c]=a;c===f.getInputMemberId()?(runtime.log("Starting to track input on new cursor of "+c),q.subscribe(ops.OdtDocument.signalProcessingBatchEnd, a.ensureVisible),q.subscribe(ops.Document.signalCursorMoved,a.refreshCursorBlinking),n.subscribe("compositionupdate",a.handleUpdate),n.subscribe("compositionend",a.handleUpdate),n.subscribe("focus",a.setFocus),n.subscribe("blur",a.removeFocus),p.addEventListener("focus",a.show,!1),p.addEventListener("blur",a.hide,!1),a.setOverlayElement(n.getEventTrap())):q.subscribe(ops.OdtDocument.signalProcessingBatchEnd,a.handleUpdate);return a};this.getCaret=a;this.getCarets=d;this.destroy=function(a){var g= d().map(function(a){return a.destroy});f.getSelectionController().setCaretXPositionLocator(null);q.unsubscribe(ops.Document.signalCursorRemoved,b);h={};core.Async.destroyAll(g,a)};f.getSelectionController().setCaretXPositionLocator(function(){var b=a(f.getInputMemberId()),d;b&&(d=b.getBoundingClientRect());return d?d.right:void 0});q.subscribe(ops.Document.signalCursorRemoved,b)};gui.EditInfoHandle=function(f){var l=[],a,d=f.ownerDocument,b=d.documentElement.namespaceURI;this.setEdits=function(f){l=f;var p,q,n,m;core.DomUtils.removeAllChildNodes(a);for(f=0;fc?(q=a(1,0),n=a(0.5,1E4-c),m=a(0.2,2E4-c)):1E4<=c&&2E4>c?(q=a(0.5,0),m=a(0.2,2E4-c)):q=a(0.2,0)};this.getEdits=function(){return f.getEdits()};this.clearEdits= function(){f.clearEdits();h.setEdits([]);p.hasAttributeNS("urn:webodf:names:editinfo","editinfo:memberid")&&p.removeAttributeNS("urn:webodf:names:editinfo","editinfo:memberid")};this.getEditInfo=function(){return f};this.show=function(){p.style.display="block"};this.hide=function(){d.hideHandle();p.style.display="none"};this.showHandle=function(){h.show()};this.hideHandle=function(){h.hide()};this.destroy=function(a){runtime.clearTimeout(q);runtime.clearTimeout(n);runtime.clearTimeout(m);b.removeChild(p); h.destroy(function(b){b?a(b):f.destroy(a)})};(function(){var a=f.getOdtDocument().getDOMDocument();p=a.createElementNS(a.documentElement.namespaceURI,"div");p.setAttribute("class","editInfoMarker");p.onmouseover=function(){d.showHandle()};p.onmouseout=function(){d.hideHandle()};b=f.getNode();b.appendChild(p);h=new gui.EditInfoHandle(b);l||d.hide()})()};gui.HyperlinkTooltipView=function(f,l){var a=core.DomUtils,d=odf.OdfUtils,b=runtime.getWindow(),h,p,q;runtime.assert(null!==b,"Expected to be run in an environment which has a global window, like a browser.");this.showTooltip=function(n){var m=n.target||n.srcElement,g=f.getSizer(),e=f.getZoomLevel(),c;a:{for(;m;){if(d.isHyperlink(m))break a;if(d.isParagraph(m)||d.isInlineRoot(m))break;m=m.parentNode}m=null}if(m){a.containsNode(g,q)||g.appendChild(q);c=p;var r;switch(l()){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=""}c.textContent=r;h.textContent=d.getHyperlinkTarget(m);q.style.display="block";c=b.innerWidth-q.offsetWidth-15;m=n.clientX>c?c:n.clientX+15;c=b.innerHeight-q.offsetHeight-10;n=n.clientY>c?c:n.clientY+10;g=g.getBoundingClientRect();m=(m-g.left)/e;n=(n-g.top)/e;q.style.left=m+"px";q.style.top=n+"px"}};this.hideTooltip=function(){q.style.display="none"};this.destroy= function(a){q.parentNode&&q.parentNode.removeChild(q);a()};(function(){var a=f.getElement().ownerDocument;h=a.createElement("span");p=a.createElement("span");h.className="webodf-hyperlinkTooltipLink";p.className="webodf-hyperlinkTooltipText";q=a.createElement("div");q.className="webodf-hyperlinkTooltip";q.appendChild(h);q.appendChild(p);f.getElement().appendChild(q)})()};gui.OdfFieldView=function(f){function l(){var a=odf.OdfSchema.getFields().map(function(a){return a.replace(":","|")}),d=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 d+"\n"+a}var a,d=f.getElement().ownerDocument;this.showFieldHighlight=function(){a.appendChild(d.createTextNode(l()))};this.hideFieldHighlight=function(){for(var b=a.sheet,d=b.cssRules;d.length;)b.deleteRule(d.length-1)};this.destroy= function(b){a.parentNode&&a.parentNode.removeChild(a);b()};a=function(){var a=d.getElementsByTagName("head").item(0),f=d.createElement("style"),l="";f.type="text/css";f.media="screen, print, handheld, projection";odf.Namespaces.forEachPrefix(function(a,b){l+="@namespace "+a+" url("+b+");\n"});f.appendChild(d.createTextNode(l));a.appendChild(f);return f}()};gui.ShadowCursor=function(f){var l=f.getDOMDocument().createRange(),a=!0;this.removeFromDocument=function(){};this.getMemberId=function(){return gui.ShadowCursor.ShadowCursorMemberId};this.getSelectedRange=function(){return l};this.setSelectedRange=function(d,b){l=d;a=!1!==b};this.hasForwardSelection=function(){return a};this.getDocument=function(){return f};this.getSelectionType=function(){return ops.OdtCursor.RangeSelection};l.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 l(){return Object.keys(a).map(function(d){return a[d]})}var a={};this.getSelectionView=function(d){return a.hasOwnProperty(d)?a[d]:null};this.getSelectionViews=l;this.removeSelectionView=function(d){a.hasOwnProperty(d)&&(a[d].destroy(function(){}),delete a[d])};this.hideSelectionView=function(d){a.hasOwnProperty(d)&&a[d].hide()};this.showSelectionView=function(d){a.hasOwnProperty(d)&&a[d].show()};this.rerenderSelectionViews=function(){Object.keys(a).forEach(function(d){a[d].rerender()})}; this.registerCursor=function(d,b){var h=d.getMemberId(),l=new f(d);b?l.show():l.hide();return a[h]=l};this.destroy=function(a){function b(l,q){q?a(q):l .webodf-draggable"), a=gui.ShadowCursor.ShadowCursorMemberId,e(".webodf-selectionOverlay","{ fill: "+c+"; stroke: "+c+";}",""),e(".webodf-touchEnabled .webodf-selectionOverlay","{ display: block; }"," > .webodf-draggable"))}function m(a){var b,c;for(c in u)u.hasOwnProperty(c)&&(b=u[c],a?b.show():b.hide())}function g(a){b.getCarets().forEach(function(b){a?b.showHandle():b.hideHandle()})}function e(a){var b=a.getMemberId();a=a.getProperties();n(b,a.fullName,a.color)}function c(c){var e=c.getMemberId(),d=a.getOdtDocument().getMember(e).getProperties(); b.registerCursor(c,J,H);h.registerCursor(c,!0);if(c=b.getCaret(e))c.setAvatarImageUrl(d.imageUrl),c.setColor(d.color);runtime.log("+++ View here +++ eagerly created an Caret for '"+e+"'! +++")}function r(a){a=a.getMemberId();var c=h.getSelectionView(l),e=h.getSelectionView(gui.ShadowCursor.ShadowCursorMemberId),d=b.getCaret(l);a===l?(e.hide(),c&&c.show(),d&&d.show()):a===gui.ShadowCursor.ShadowCursorMemberId&&(e.show(),c&&c.hide(),d&&d.hide())}function k(a){h.removeSelectionView(a)}function x(b){var c= b.paragraphElement,e=b.memberId;b=b.timeStamp;var d,f="",k=c.getElementsByTagNameNS(w,"editinfo").item(0);k?(f=k.getAttributeNS(w,"id"),d=u[f]):(f=Math.random().toString(),d=new ops.EditInfo(c,a.getOdtDocument()),d=new gui.EditInfoMarker(d,F),k=c.getElementsByTagNameNS(w,"editinfo").item(0),k.setAttributeNS(w,"id",f),u[f]=d);d.addEdit(e,new Date(b));B.trigger()}function t(){var b;s.hasChildNodes()&&core.DomUtils.removeAllChildNodes(s);!0===d.getState(gui.CommonConstraints.EDIT.ANNOTATIONS.ONLY_DELETE_OWN)&& (b=a.getOdtDocument().getMember(l))&&(b=b.getProperties().fullName,s.appendChild(document.createTextNode(".annotationWrapper:not([creator = '"+b+"']) .annotationRemoveButton { display: none; }")))}function y(a){var b=Object.keys(u).map(function(a){return u[a]});A.unsubscribe(ops.Document.signalMemberAdded,e);A.unsubscribe(ops.Document.signalMemberUpdated,e);A.unsubscribe(ops.Document.signalCursorAdded,c);A.unsubscribe(ops.Document.signalCursorRemoved,k);A.unsubscribe(ops.OdtDocument.signalParagraphChanged, x);A.unsubscribe(ops.Document.signalCursorMoved,r);A.unsubscribe(ops.OdtDocument.signalParagraphChanged,h.rerenderSelectionViews);A.unsubscribe(ops.OdtDocument.signalTableAdded,h.rerenderSelectionViews);A.unsubscribe(ops.OdtDocument.signalParagraphStyleModified,h.rerenderSelectionViews);d.unsubscribe(gui.CommonConstraints.EDIT.ANNOTATIONS.ONLY_DELETE_OWN,t);A.unsubscribe(ops.Document.signalMemberAdded,t);A.unsubscribe(ops.Document.signalMemberUpdated,t);v.parentNode.removeChild(v);s.parentNode.removeChild(s); (function Y(c,e){e?a(e):ca.length;b&&f(a);return b}function a(a,b){function d(g){a[g]===b&&f.push(g)}var f=[];a&&["style:parent-style-name","style:next-style-name"].forEach(d);return f}function d(a,b){function d(f){a[f]===b&&delete a[f]}a&&["style:parent-style-name","style:next-style-name"].forEach(d)}function b(a){var c={};Object.keys(a).forEach(function(d){c[d]="object"===typeof a[d]?b(a[d]):a[d]});return c}function h(a, b,d,f){var g,h=!1,l=!1,m,n=[];f&&f.attributes&&(n=f.attributes.split(","));a&&(d||0=c.position+c.length)){f=d?a:c;g=d?c:a;if(a.position!==c.position||a.length!==c.length)q=b(f),w=b(g);c=n(g.setProperties,null,f.setProperties,null,"style:text-properties");if(c.majorChanged||c.minorChanged)h=[],a=[],l=f.position+f.length,m=g.position+g.length,g.positionl?c.minorChanged&&(q=w,q.position=l,q.length=m-l,a.push(q),g.length=l-g.position):l>m&&c.majorChanged&&(q.position=m,q.length=l-m,h.push(q),f.length=m-f.position),f.setProperties&&p(f.setProperties)&&h.push(f),g.setProperties&&p(g.setProperties)&&a.push(g),d?(l=h,h=a):l=a}return{opSpecsA:l,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 d=a.position,f=a.position+a.length;d>=b.sourceStartPosition&&(d-=1);f>=b.sourceStartPosition&&(f-=1);a.position=d;a.length=f-d;return{opSpecsA:[a],opSpecsB:[b]}},MoveCursor:m,RemoveCursor:m,RemoveMember:m,RemoveStyle:m,RemoveText:function(a,b){var d=a.position+a.length,f=b.position+b.length,g=[a],h=[b];f<=a.position?a.position-=b.length:b.positionb.position?a.position+=b.text.length:d?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.positiona.position&&(b.position+=a.text.length);return{opSpecsA:[a], opSpecsB:[b]}},SplitParagraph:function(a,b){a.position=a.sourceStartPosition&&(g-=1);d>=a.sourceStartPosition&& (d-=1);0<=b.length?(b.position=g,b.length=d-g):(b.position=d,b.length=g-d);return{opSpecsA:[a],opSpecsB:[b]}},RemoveCursor:m,RemoveMember:m,RemoveStyle:m,RemoveText:function(a,b){b.position>=a.sourceStartPosition?b.position-=1:(b.positiona.sourceStartPosition)b.position-= 1;else if(b.position===a.destinationStartPosition||b.position===a.sourceStartPosition)b.position=a.destinationStartPosition,a.paragraphStyleName=b.styleName;return{opSpecsA:d,opSpecsB:f}},SplitParagraph:function(a,b){var d,f=[a],g=[b];b.position=a.destinationStartPosition&&b.position=a.sourceStartPosition&&(b.position-=1,b.sourceParagraphPosition-=1);return{opSpecsA:f,opSpecsB:g}},UpdateMember:m,UpdateMetadata:m,UpdateParagraphStyle:m},MoveCursor:{MoveCursor:m,RemoveCursor:function(a, b){return{opSpecsA:a.memberid===b.memberid?[]:[a],opSpecsB:[b]}},RemoveMember:m,RemoveStyle:m,RemoveText:function(a,b){var d=l(a),g=a.position+a.length,h=b.position+b.length;h<=a.position?a.position-=b.length:b.positionc.position?a.position+=1:a.position===c.sourceParagraphPosition&&(c.paragraphStyleName=a.styleName,g=b(a),g.position=c.position+1,d.push(g));return{opSpecsA:d,opSpecsB:f}},UpdateMember:m,UpdateMetadata:m,UpdateParagraphStyle:m},SplitParagraph:{SplitParagraph:function(a,b,d){var f,g;a.position