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