diff --git a/VERSION b/VERSION index 290e8195..37c26074 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -7.8.0.1397 +7.9.0.1398 diff --git a/core/core.js b/core/core.js index e34a2d87..a986447a 100644 --- a/core/core.js +++ b/core/core.js @@ -1,3 +1,3 @@ -!function(e){var t={};function i(n){if(t[n])return t[n].exports;var r=t[n]={i:n,l:!1,exports:{}};return e[n].call(r.exports,r,r.exports,i),r.l=!0,r.exports}i.m=e,i.c=t,i.d=function(e,t,n){i.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},i.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},i.t=function(e,t){if(1&t&&(e=i(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(i.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)i.d(n,r,function(t){return e[t]}.bind(null,r));return n},i.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return i.d(t,"a",t),t},i.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},i.p="",i(i.s=5)}([function(module,__webpack_exports__,__webpack_require__){"use strict";function _typeof(e){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}var md5,_unused_webpack_default_export=md5;!function(){var HxOverrides=function(){};HxOverrides.__name__=!0,HxOverrides.dateStr=function(e){var t=e.getMonth()+1,i=e.getDate(),n=e.getHours(),r=e.getMinutes(),s=e.getSeconds();return e.getFullYear()+"-"+(t<10?"0"+t:""+t)+"-"+(i<10?"0"+i:""+i)+" "+(n<10?"0"+n:""+n)+":"+(r<10?"0"+r:""+r)+":"+(s<10?"0"+s:""+s)},HxOverrides.strDate=function(e){switch(e.length){case 8:var t=e.split(":"),i=new Date;return i.setTime(0),i.setUTCHours(t[0]),i.setUTCMinutes(t[1]),i.setUTCSeconds(t[2]),i;case 10:t=e.split("-");return new Date(t[0],t[1]-1,t[2],0,0,0);case 19:var n=(t=e.split(" "))[0].split("-"),r=t[1].split(":");return new Date(n[0],n[1]-1,n[2],r[0],r[1],r[2]);default:throw"Invalid date format : "+e}},HxOverrides.cca=function(e,t){var i=e.charCodeAt(t);if(i==i)return i},HxOverrides.substr=function(e,t,i){return null!=t&&0!=t&&null!=i&&i<0?"":(null==i&&(i=e.length),t<0?(t=e.length+t)<0&&(t=0):i<0&&(i=e.length+i-t),e.substr(t,i))},HxOverrides.remove=function(e,t){for(var i=0,n=e.length;i>>32-t},str2blks:function(e){for(var t=1+(e.length+8>>6),i=new Array,n=0,r=16*t;n>2]|=HxOverrides.cca(e,s)<<(8*e.length+s)%4*8,s++;i[s>>2]|=128<<(8*e.length+s)%4*8;var a=8*e.length,o=16*t-2;return i[o]=255&a,i[o]|=(a>>>8&255)<<8,i[o]|=(a>>>16&255)<<16,i[o]|=(a>>>24&255)<<24,i},rhex:function(e){for(var t="",i=0;i<4;){var n=i++;t+="0123456789abcdef".charAt(e>>8*n+4&15)+"0123456789abcdef".charAt(e>>8*n&15)}return t},addme:function(e,t){var i=(65535&e)+(65535&t);return(e>>16)+(t>>16)+(i>>16)<<16|65535&i},bitAND:function(e,t){return(e>>>1&t>>>1)<<1|1&e&t},bitXOR:function(e,t){return(e>>>1^t>>>1)<<1|1&e^1&t},bitOR:function(e,t){return(e>>>1|t>>>1)<<1|(1&e|1&t)},__class__:haxe.Md5},haxe.Timer=function(e){var t=this;this.id=window.setInterval(function(){t.run()},e)},haxe.Timer.__name__=!0,haxe.Timer.delay=function(e,t){var i=new haxe.Timer(t);return i.run=function(){i.stop(),e()},i},haxe.Timer.measure=function(e,t){var i=haxe.Timer.stamp(),n=e();return haxe.Log.trace(haxe.Timer.stamp()-i+"s",t),n},haxe.Timer.stamp=function(){return(new Date).getTime()/1e3},haxe.Timer.prototype={run:function(){},stop:function(){null!=this.id&&(window.clearInterval(this.id),this.id=null)},__class__:haxe.Timer};var js=js||{},$_;function $bind(e,t){var i=function e(){return e.method.apply(e.scope,arguments)};return i.scope=e,i.method=t,i}js.Boot=function(){},js.Boot.__name__=!0,js.Boot.__unhtml=function(e){return e.split("&").join("&").split("<").join("<").split(">").join(">")},js.Boot.__trace=function(e,t){var i,n=null!=t?t.fileName+":"+t.lineNumber+": ":"";n+=js.Boot.__string_rec(e,""),"undefined"!=typeof document&&null!=(i=document.getElementById("haxe:trace"))?i.innerHTML+=js.Boot.__unhtml(n)+"
":"undefined"!=typeof console&&null!=console.log&&console.log(n)},js.Boot.__clear_trace=function(){var e=document.getElementById("haxe:trace");null!=e&&(e.innerHTML="")},js.Boot.isClass=function(e){return e.__name__},js.Boot.isEnum=function(e){return e.__ename__},js.Boot.getClass=function(e){return e.__class__},js.Boot.__string_rec=function(e,t){if(null==e)return"null";if(t.length>=5)return"<...>";var i=_typeof(e);switch("function"==i&&(e.__name__||e.__ename__)&&(i="object"),i){case"object":if(e instanceof Array){if(e.__enum__){if(2==e.length)return e[0];var n=e[0]+"(";t+="\t";for(var r=2,s=e.length;r0?",":"")+js.Boot.__string_rec(e[l],t)}return n+="]"}var c;try{c=e.toString}catch(e){return"???"}if(null!=c&&c!=Object.toString){var u=e.toString();if("[object Object]"!=u)return u}var h=null;n="{\n";t+="\t";var d=null!=e.hasOwnProperty;for(var h in e)d&&!e.hasOwnProperty(h)||"prototype"!=h&&"__class__"!=h&&"__super__"!=h&&"__interfaces__"!=h&&"__properties__"!=h&&(2!=n.length&&(n+=", \n"),n+=t+h+" : "+js.Boot.__string_rec(e[h],t));return n+="\n"+(t=t.substring(1))+"}";case"function":return"";case"string":return e;default:return String(e)}},js.Boot.__interfLoop=function(e,t){if(null==e)return!1;if(e==t)return!0;var i=e.__interfaces__;if(null!=i)for(var n=0,r=i.length;n>>32-t},str2blks:function(e){for(var t=1+(e.length+8>>6),i=new Array,n=0,r=16*t;n>2]|=HxOverrides.cca(e,s)<<(8*e.length+s)%4*8,s++;i[s>>2]|=128<<(8*e.length+s)%4*8;var a=8*e.length,o=16*t-2;return i[o]=255&a,i[o]|=(a>>>8&255)<<8,i[o]|=(a>>>16&255)<<16,i[o]|=(a>>>24&255)<<24,i},rhex:function(e){for(var t="",i=0;i<4;){var n=i++;t+="0123456789abcdef".charAt(e>>8*n+4&15)+"0123456789abcdef".charAt(e>>8*n&15)}return t},addme:function(e,t){var i=(65535&e)+(65535&t);return(e>>16)+(t>>16)+(i>>16)<<16|65535&i},bitAND:function(e,t){return(e>>>1&t>>>1)<<1|1&e&t},bitXOR:function(e,t){return(e>>>1^t>>>1)<<1|1&e^1&t},bitOR:function(e,t){return(e>>>1|t>>>1)<<1|(1&e|1&t)},__class__:haxe.Md5},haxe.Timer=function(e){var t=this;this.id=window.setInterval(function(){t.run()},e)},haxe.Timer.__name__=!0,haxe.Timer.delay=function(e,t){var i=new haxe.Timer(t);return i.run=function(){i.stop(),e()},i},haxe.Timer.measure=function(e,t){var i=haxe.Timer.stamp(),n=e();return haxe.Log.trace(haxe.Timer.stamp()-i+"s",t),n},haxe.Timer.stamp=function(){return(new Date).getTime()/1e3},haxe.Timer.prototype={run:function(){},stop:function(){null!=this.id&&(window.clearInterval(this.id),this.id=null)},__class__:haxe.Timer};var js=js||{},$_;function $bind(e,t){var i=function e(){return e.method.apply(e.scope,arguments)};return i.scope=e,i.method=t,i}js.Boot=function(){},js.Boot.__name__=!0,js.Boot.__unhtml=function(e){return e.split("&").join("&").split("<").join("<").split(">").join(">")},js.Boot.__trace=function(e,t){var i,n=null!=t?t.fileName+":"+t.lineNumber+": ":"";n+=js.Boot.__string_rec(e,""),"undefined"!=typeof document&&null!=(i=document.getElementById("haxe:trace"))?i.innerHTML+=js.Boot.__unhtml(n)+"
":"undefined"!=typeof console&&null!=console.log&&console.log(n)},js.Boot.__clear_trace=function(){var e=document.getElementById("haxe:trace");null!=e&&(e.innerHTML="")},js.Boot.isClass=function(e){return e.__name__},js.Boot.isEnum=function(e){return e.__ename__},js.Boot.getClass=function(e){return e.__class__},js.Boot.__string_rec=function(e,t){if(null==e)return"null";if(t.length>=5)return"<...>";var i=_typeof(e);switch("function"==i&&(e.__name__||e.__ename__)&&(i="object"),i){case"object":if(e instanceof Array){if(e.__enum__){if(2==e.length)return e[0];var n=e[0]+"(";t+="\t";for(var r=2,s=e.length;r0?",":"")+js.Boot.__string_rec(e[l],t)}return n+="]"}var c;try{c=e.toString}catch(e){return"???"}if(null!=c&&c!=Object.toString){var u=e.toString();if("[object Object]"!=u)return u}var h=null;n="{\n";t+="\t";var d=null!=e.hasOwnProperty;for(var h in e)d&&!e.hasOwnProperty(h)||"prototype"!=h&&"__class__"!=h&&"__super__"!=h&&"__interfaces__"!=h&&"__properties__"!=h&&(2!=n.length&&(n+=", \n"),n+=t+h+" : "+js.Boot.__string_rec(e[h],t));return n+="\n"+(t=t.substring(1))+"}";case"function":return"";case"string":return e;default:return String(e)}},js.Boot.__interfLoop=function(e,t){if(null==e)return!1;if(e==t)return!0;var i=e.__interfaces__;if(null!=i)for(var n=0,r=i.length;n=0&&l.splice(t,1)}function m(e){var t=document.createElement("style");if(void 0===e.attrs.type&&(e.attrs.type="text/css"),void 0===e.attrs.nonce){var n=function(){0;return i.nc}();n&&(e.attrs.nonce=n)}return g(t,e.attrs),d(e,t),t}function g(e,t){Object.keys(t).forEach(function(i){e.setAttribute(i,t[i])})}function p(e,t){var i,n,r,s;if(t.transform&&e.css){if(!(s="function"==typeof t.transform?t.transform(e.css):t.transform.default(e.css)))return function(){};e.css=s}if(t.singleton){var l=o++;i=a||(a=m(t)),n=b.bind(null,i,l,!1),r=b.bind(null,i,l,!0)}else e.sourceMap&&"function"==typeof URL&&"function"==typeof URL.createObjectURL&&"function"==typeof URL.revokeObjectURL&&"function"==typeof Blob&&"function"==typeof btoa?(i=function(e){var t=document.createElement("link");return void 0===e.attrs.type&&(e.attrs.type="text/css"),e.attrs.rel="stylesheet",g(t,e.attrs),d(e,t),t}(t),n=function(e,t,i){var n=i.css,r=i.sourceMap,s=void 0===t.convertToAbsoluteUrls&&r;(t.convertToAbsoluteUrls||s)&&(n=c(n));r&&(n+="\n/*# sourceMappingURL=data:application/json;base64,"+btoa(unescape(encodeURIComponent(JSON.stringify(r))))+" */");var a=new Blob([n],{type:"text/css"}),o=e.href;e.href=URL.createObjectURL(a),o&&URL.revokeObjectURL(o)}.bind(null,i,t),r=function(){f(i),i.href&&URL.revokeObjectURL(i.href)}):(i=m(t),n=function(e,t){var i=t.css,n=t.media;n&&e.setAttribute("media",n);if(e.styleSheet)e.styleSheet.cssText=i;else{for(;e.firstChild;)e.removeChild(e.firstChild);e.appendChild(document.createTextNode(i))}}.bind(null,i),r=function(){f(i)});return n(e),function(t){if(t){if(t.css===e.css&&t.media===e.media&&t.sourceMap===e.sourceMap)return;n(e=t)}else r()}}e.exports=function(e,t){if("undefined"!=typeof DEBUG&&DEBUG&&"object"!=typeof document)throw new Error("The style-loader cannot be used in a non-browser environment");(t=t||{}).attrs="object"==typeof t.attrs?t.attrs:{},t.singleton||"boolean"==typeof t.singleton||(t.singleton=r()),t.insertInto||(t.insertInto="head"),t.insertAt||(t.insertAt="bottom");var i=h(e,t);return u(i,t),function(e){for(var r=[],s=0;s«/mo»",ampElement:"«mo»&«/mo»"}}},{key:"safeGoodBlackboardCharacters",get:function(){return{ltElement:"«mo»§lt;«/mo»",gtElement:"«mo»§gt;«/mo»",ampElement:"«mo»§amp;«/mo»"}}}]),e}();function s(e,t){for(var i=0;i",doubleQuote:'"',ampersand:"&",quote:"'"},r.safeXmlCharacters={tagOpener:"«",tagCloser:"»",doubleQuote:"¨",ampersand:"§",quote:"`",realDoubleQuote:"¨"};var a=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e)}return function(e,t,i){t&&s(e.prototype,t),i&&s(e,i)}(e,null,[{key:"isMathmlInAttribute",value:function(e,t){var i=new RegExp("^['\"][\\s]*=[\\s]*[\\w-]+([\\s]*(\"[^\"]*\"|'[^']*')[\\s]*=[\\s]*[\\w-]+[\\s]*)*[\\s]+gmi<"),n=e.substring(0,t).split("").reverse().join("");return i.test(n)}},{key:"safeXmlDecode",value:function(e){e=(e=(e=(e=e.split(r.safeXmlCharactersEntities.tagOpener).join(r.safeXmlCharacters.tagOpener)).split(r.safeXmlCharactersEntities.tagCloser).join(r.safeXmlCharacters.tagCloser)).split(r.safeXmlCharactersEntities.doubleQuote).join(r.safeXmlCharacters.doubleQuote)).split(r.safeXmlCharactersEntities.realDoubleQuote).join(r.safeXmlCharacters.realDoubleQuote),"_wrs_blackboard"in window&&window._wrs_blackboard&&(e=(e=(e=e.split(r.safeBadBlackboardCharacters.ltElement).join(r.safeGoodBlackboardCharacters.ltElement)).split(r.safeBadBlackboardCharacters.gtElement).join(r.safeGoodBlackboardCharacters.gtElement)).split(r.safeBadBlackboardCharacters.ampElement).join(r.safeGoodBlackboardCharacters.ampElement)),e=(e=(e=(e=(e=e.split(r.safeXmlCharacters.tagOpener).join(r.xmlCharacters.tagOpener)).split(r.safeXmlCharacters.tagCloser).join(r.xmlCharacters.tagCloser)).split(r.safeXmlCharacters.doubleQuote).join(r.xmlCharacters.doubleQuote)).split(r.safeXmlCharacters.ampersand).join(r.xmlCharacters.ampersand)).split(r.safeXmlCharacters.quote).join(r.xmlCharacters.quote);for(var t="",i=null,n=0;n128)t+="&#"+e.codePointAt(i)+";",e.codePointAt(i)>65535&&i++;else if("&"==n){var r=e.indexOf(";",i+1);if(r>=0){var s=document.createElement("span");s.innerHTML=e.substring(i,r+1),t+="&#"+v.fixedCharCodeAt(s.textContent||s.innerText,0)+";",i=r}else t+=n}else t+=n}return t}},{key:"addCustomEditorClassAttribute",value:function(e,t){var i="",n=e.indexOf("");if(-1==e.indexOf("class"))return i=e.substr(n,r)+' class="wrs_'+t+'">',i+=e.substr(r+1,e.length)}return e}},{key:"removeCustomEditorClassAttribute",value:function(e,t){return-1===e.indexOf("class")||-1===e.indexOf("wrs_"+t)?e:-1!==e.indexOf('class="wrs_'+t+'"')?e.replace('class="wrs_'+t+'"',""):e.replace("wrs_"+t,"")}},{key:"insertSemanticsMathml",value:function(e,t,i){if(""==t)return e;var n='',r=e.indexOf(">"),s=e.indexOf(""),a=e.substring(e.indexOf("<"),e.indexOf(">")).indexOf("math");if(-1!=r&&-1!=s&&a){var o=e.substring(r+1,s);if(0!=o.indexOf(""))var l=""+o+""+n+t+"";else l=""+o+n+t+"";return e.replace(o,l)}return e}},{key:"removeSemantics",value:function(e,t){var i='',n=e,r=e.indexOf("");if(-1!=r){var s=e.indexOf(i,r+"".length);-1!=s&&(n=e.substring(0,r)+e.substring(r+"".length,s)+"")}return n}},{key:"removeSemanticsOcurrences",value:function(e){for(var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:r.xmlCharacters,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"application/json",n=t.tagOpener+"math",s=t.tagOpener+"/math"+t.tagCloser,a="/"+t.tagCloser,o=t.tagCloser,l=t.tagOpener+"semantics"+t.tagCloser,c=t.tagOpener+"annotation encoding="+t.doubleQuote+i+t.doubleQuote+t.tagCloser,u="",h=e.indexOf(n),d=0;-1!==h;){u+=e.substring(d,h);var f=e.indexOf(s,h),m=e.indexOf(a,h),g=e.indexOf(o,h);-1!==f?d=f:m===g-1&&(d=m);var p=e.indexOf(l,h);if(-1!==p){var v=e.substring(h,p),b=e.indexOf(c,h);if(-1!==b)u+=v+e.substring(p+l.length,b)+s,h=e.indexOf(n,h+n.length),d+=s.length;else d=h,h=e.indexOf(n,h+n.length)}else d=h,h=e.indexOf(n,h+n.length)}return u+=e.substring(d,e.length)}},{key:"containClass",value:function(e,t){var i=e.indexOf("class");if(-1==i)return!1;var n=e.indexOf(">",i);return-1!=e.substring(i,n).indexOf(t)}},{key:"isEmpty",value:function(e){var t=e.indexOf(">"),i=e.indexOf("/>"),n=!1;if(-1!==i&&i===t-1&&(n=!0),!n){var r=new RegExp("").exec(e);r&&(n=t+1===r.index)}return n}}]),e}();function o(e,t){for(var i=0;i=0;--n)if(i[n]==t)return!0;return!1}},{key:"removeClass",value:function(e,t){for(var i="",n=e.className.split(" "),r=0;r").join("").split("").join("")).split("").join("
").split("").join("
");var n=e.createElement("div",{},i);return n.innerHTML=t,function t(n){if(n.getAttribute&&"WirisParam"==n.getAttribute("wirisObject")){for(var r={},s=0;s0){i+=">";for(n=0;n"}else"DIV"==t.nodeName||"SCRIPT"==t.nodeName?i+=">":i+="/>";return i}return 3==t.nodeType?e.htmlEntities(t.nodeValue):""}}},{key:"concatenateUrl",value:function(e,t){var i="";return e.indexOf("/")!=e.length&&0!=t.indexOf("/")&&(i="/"),(e+i+t).replace(/([^:]\/)\/+/g,"$1")}},{key:"htmlEntities",value:function(e){return e.split("&").join("&").split("<").join("<").split(">").join(">").split('"').join(""")}},{key:"htmlEntitiesDecode",value:function(e){return e.split(""").join('"').split(">").join(">").split("<").join("<").split("&").join("&")}},{key:"createHttpRequest",value:function(){if("file://"==window.location.toString().substr(0,window.location.toString().lastIndexOf("/")+1).substr(0,7))throw Core.getStringManager().getString("exception_cross_site");if("undefined"!=typeof XMLHttpRequest)return new XMLHttpRequest;try{return new ActiveXObject("Msxml2.XMLHTTP")}catch(e){try{return new ActiveXObject("Microsoft.XMLHTTP")}catch(e){}}return!1}},{key:"httpBuildQuery",value:function(t){var i="";for(var n in t)null!=t[n]&&(i+=e.urlEncode(n)+"="+e.urlEncode(t[n])+"&");return"&"==i.substring(i.length-1)&&(i=i.substring(0,i.length-1)),i}},{key:"propertiesToString",value:function(t){var i=[];for(var n in t)t.hasOwnProperty(n)&&i.push(n);for(var r=i.length,s=0;s0&&(i[s]=l,i[a]=o)}var c="";for(s=0;ss?s:r;for(n=0;n0){var i=e.substring(t+1).split("&"),n=new Object;for(t=0;t1&&(n[r[0]]=decodeURIComponent(r[1].replace(/\+/g," ")))}return n}return new Object}},{key:"urlEncode",value:function(e){return encodeURIComponent(e)}},{key:"getWIRISImageOutput",value:function(t,i,n){var s=e.createObject(t);if(s){if(s.className==l.get("imageClassName")||s.getAttribute(l.get("imageMathmlAttribute"))){if(!i)return t;var o=s.getAttribute(l.get("imageMathmlAttribute"));return l.get("saveHandTraces")||(o=a.removeSemanticsOcurrences(o,r.safeXmlCharacters)),null==o&&(o=s.getAttribute("alt")),n||(o=a.safeXmlDecode(o)),o}if(s.className==l.get("CASClassName")){var c=s.getAttribute(l.get("CASMathmlAttribute"));c=a.safeXmlDecode(c);var u=e.createObject(c);u.setAttribute("src",s.src);var h=e.createObjectCode(u);return n&&(h=a.safeXmlEncode(h)),h}}return t}},{key:"getNodeLength",value:function(e){function t(t){return e.apply(this,arguments)}return t.toString=function(){return e.toString()},t}(function(e){if(3==e.nodeType)return e.nodeValue.length;if(1==e.nodeType){var t={IMG:1,BR:1}[e.nodeName.toUpperCase()];void 0===t&&(t=0);for(var i=0;i0)return 0==c.text.length?e.getSelectedItem(t,i,!0):null;r.document.execCommand("InsertImage",!1,"#");var s,a=c.parentElement();return"IMG"!=a.nodeName.toUpperCase()&&(c.pasteHTML(''),a=r.document.getElementById("wrs_openEditorWindow_temporalObject")),a.nextSibling&&3==a.nextSibling.nodeType?(o=a.nextSibling,s=0):a.previousSibling&&3==a.previousSibling.nodeType?s=(o=a.previousSibling).nodeValue.length:(o=r.document.createTextNode(""),a.parentNode.insertBefore(o,a),s=0),a.parentNode.removeChild(a),{node:o,caretPosition:s}}return c.length>1?null:{node:c.item(0)}}if(r.getSelection){var o,l=r.getSelection();try{var c=l.getRangeAt(0)}catch(e){c=r.document.createRange()}if(3==(o=c.startContainer).nodeType)return{node:o,caretPosition:c.startOffset};if(o!=c.endContainer)return null;if(1==o.nodeType){var u=c.startOffset;if(o.childNodes[u])return{node:o.childNodes[u]}}}return null}},{key:"getSelectedItemOnTextarea",value:function(e){var t=document.createTextNode(e.value),i=g.getLatexFromTextNode(t,e.selectionStart);return null===i?null:{node:t,caretPosition:e.selectionStart,startPosition:i.startPosition,endPosition:i.endPosition}}},{key:"getElementsByNameFromString",value:function(e,t,i){var n=[];e=e.toLowerCase();t=t.toLowerCase();for(var r=e.indexOf("<"+t+" ");-1!=r;){var s;s=i?">":"";var a=e.indexOf(s,r);-1!=a?(a+=s.length,n.push({start:r,end:a})):a=r+1,r=e.indexOf("<"+t+" ",a)}return n}},{key:"decode64",value:function(e){var t="+".charCodeAt(0),i="/".charCodeAt(0),n="0".charCodeAt(0),r="a".charCodeAt(0),s="A".charCodeAt(0),a="-".charCodeAt(0),o="_".charCodeAt(0),l=e.charCodeAt(0);return l===t||l===a?62:l===i||l===o?63:l0)throw new Error("Invalid string. Length must be a multiple of 4");var r=new Array;if(i)a=i;else var s="="===t.charAt(t.length-2)?2:"="===t.charAt(t.length-1)?1:0,a=s>0?t.length-4:t.length;for(var o=0;o>16&255),r.push(n>>8&255),r.push(255&n);return s&&(2===s?(n=e.decode64(t.charAt(o))<<2|e.decode64(t.charAt(o+1))>>4,r.push(255&n)):1===s&&(n=e.decode64(t.charAt(o))<<10|e.decode64(t.charAt(o+1))<<4|e.decode64(t.charAt(o+2))>>2,r.push(n>>8&255),r.push(255&n))),r}},{key:"readInt32",value:function(e){if(e.length<4)return!1;var t=e.splice(0,4);return t[0]<<24|t[1]<<16|t[2]<<8|t[3]<<0}},{key:"readByte",value:function(e){return e.shift()<<0}},{key:"readBytes",value:function(e,t,i){return e.splice(t,i)}},{key:"updateTextArea",value:function(e,t){if(e&&t)if(e.focus(),null!=e.selectionStart){var i=e.selectionEnd;e.value=e.value.substring(0,e.selectionStart)+t+e.value.substring(e.selectionEnd,e.value.length),e.selectionEnd=i+t.length}else{document.selection.createRange().text=t}}},{key:"updateExistingTextOnTextarea",value:function(e,t,i,n){e.focus(),e.value=e.value.substring(0,i)+t+e.value.substring(n,e.value.length),e.selectionEnd=i+t.length}},{key:"addArgument",value:function(e,t,i){return e+(e.indexOf("?")>0?"&":"?")+t+"="+i}}]),e}();function b(e,t){for(var i=0;i-1,this.deviceProperties.isIOS=this.ua.indexOf("ipad")>-1||this.ua.indexOf("iphone")>-1,this.toolbar=null,this.modalDialogInstance=null,this.listeners=new y,this.mathML=null,this.isNewElement=!0,this.integrationModel=null,this.isEditorLoaded=!1}return function(e,t,i){t&&E(e.prototype,t),i&&E(e,i)}(e,[{key:"addListener",value:function(e){this.listeners.add(e)}},{key:"setIntegrationModel",value:function(e){this.integrationModel=e}},{key:"setModalDialogInstance",value:function(e){this.modalDialogInstance=e}},{key:"insert",value:function(){this.updateTitle(this.modalDialogInstance),this.insertEditor(this.modalDialogInstance)}},{key:"insertEditor",value:function(){if("com"in window&&"wiris"in window.com&&"jsEditor"in window.com.wiris){if(this.editor=com.wiris.jsEditor.JsEditor.newInstance(this.editorAttributes),this.editor.insertInto(this.modalDialogInstance.contentContainer),this.editor.focus(),this.modalDialogInstance.rtl&&this.editor.action("rtl"),this.editor.getEditorModel().isRTL()&&(this.editor.element.style.direction="rtl"),this.editor.getEditorModel().addEditorListener(this.editorListener),this.modalDialogInstance.deviceProperties.isIOS){setTimeout(function(){this.modalDialogInstance.hideKeyboard()},400);var t=document.getElementsByClassName("wrs_formulaDisplay")[0];v.addEvent(t,"focus",this.modalDialogInstance.handleOpenedIosSoftkeyboard),v.addEvent(t,"blur",this.modalDialogInstance.handleClosedIosSoftkeyboard)}this.listeners.fire("onLoad",{}),this.isEditorLoaded=!0}else setTimeout(e.prototype.insertEditor.bind(this,this.modalDialogInstance),100)}},{key:"init",value:function(){for(var e=window.location.search.substring(1).split("&"),t=0;t=0&&(version=e[t].substring(2))}var i=document.createElement("script");i.type="text/javascript";var n=l.get("editorUrl"),r=document.createElement("a");r.href=n,0==window.location.href.indexOf("https://")&&"http:"==r.protocol&&(r.protocol="https:"),n="80"==r.port||"443"==r.port?r.protocol+"//"+r.hostname+"/"+r.pathname:r.protocol+"//"+r.hostname+":"+r.port+"/"+r.pathname;var s={};"editor"in this.environment?s.editor=this.environment.editor:s.editor="unknown","mode"in this.environment?s.mode=this.environment.mode:s.mode=l.get("saveMode"),"version"in this.environment?s.version=this.environment.version:s.version=l.get("version"),i.src=n+"?lang="+this.language+"&stats-editor="+s.editor+"&stats-mode="+s.mode+"&stats-version="+s.version,document.getElementsByTagName("head")[0].appendChild(i)}},{key:"setInitialContent",value:function(){this.isNewElement||this.setMathML(this.mathML)}},{key:"setMathML",value:function(e,t){void 0===t&&(t=!1),this.editor.setMathMLWithCallback(e,function(){this.editorListener.setWaitingForChanges(!0)}.bind(this)),setTimeout(function(){this.editorListener.setIsContentChanged(!1)}.bind(this),500),t||this.onFocus()}},{key:"onFocus",value:function(){void 0!==this.editor&&null!=this.editor&&this.editor.focus()}},{key:"submitAction",value:function(){if(this.editor.isFormulaEmpty())this.integrationModel.updateFormula(null);else{var e=this.editor.getMathMLWithSemantics();if(null!=this.customEditors.getActiveEditor())e=a.addCustomEditorClassAttribute(e,this.customEditors.getActiveEditor().toolbar);else for(var t in this.customEditors.editors)e=a.removeCustomEditorClassAttribute(e,t);var i=a.mathMLEntities(e);this.integrationModel.updateFormula(i)}this.customEditors.disable(),this.integrationModel.notifyWindowClosed(),this.setEmptyMathML(),this.customEditors.disable()}},{key:"setEmptyMathML",value:function(){this.deviceProperties.isAndroid||this.deviceProperties.isIOS?this.editor.getEditorModel().isRTL()?this.setMathML('[]"',!0):this.setMathML('[]"',!0):this.editor.getEditorModel().isRTL()?this.setMathML('',!0):this.setMathML("",!0)}},{key:"onOpen",value:function(){this.isNewElement?this.setEmptyMathML():this.setMathML(this.mathML),this.updateToolbar(),this.onFocus()}},{key:"updateToolbar",value:function(){var e;if(this.updateTitle(this.modalDialogInstance),e=this.customEditors.getActiveEditor()){var t=e.toolbar?e.toolbar:_wrs_int_wirisProperties.toolbar;null!=this.toolbar&&this.toolbar==t||this.setToolbar(t)}else{t=this.getToolbar();null!=this.toolbar&&this.toolbar==t||(this.setToolbar(t),this.customEditors.disable())}}},{key:"updateTitle",value:function(){var e;(e=this.customEditors.getActiveEditor())?this.modalDialogInstance.setTitle(e.title):this.modalDialogInstance.setTitle("MathType")}},{key:"getToolbar",value:function(){var e;return"general"==(e="toolbar"in this.editorAttributes?this.editorAttributes.toolbar:"general")&&(e="undefined"==typeof _wrs_int_wirisProperties||void 0===_wrs_int_wirisProperties.toolbar?"general":_wrs_int_wirisProperties.toolbar),e}},{key:"setToolbar",value:function(e){this.toolbar=e,this.editor.setParams({toolbar:this.toolbar})}},{key:"hasChanges",value:function(){return!this.editor.isFormulaEmpty()&&this.editorListener.getIsContentChanged()}}]),e}();function k(e,t){for(var i=0;i-1,r=i.indexOf("ipad")>-1||i.indexOf("iphone")>-1;this.iosSoftkeyboardOpened=!1,this.iosMeasureUnit=-1==i.indexOf("crios")?"%":"vh",this.iosDivHeight="100"+this.iosMeasureUnit;var s=window.outerWidth,a=window.outerHeight,o=s>a,l=sa||l&&this.attributes.width>s);this.instanceId=document.getElementsByClassName("wrs_modal_dialogContainer").length,this.deviceProperties={orientation:o?"landscape":"portait",isAndroid:!!n,isIOS:!!r,isMobile:c,isDesktop:!c&&!r&&!n},this.properties={created:!1,state:"",previousState:"",position:{bottom:0,right:10},size:{height:338,width:580}};var u={class:"wrs_modal_overlay"};u.id=this.getElementId(u.class),this.overlay=v.createElement("div",u),(u={}).class="wrs_modal_title_bar",u.id=this.getElementId(u.class),this.titleBar=v.createElement("div",u),(u={}).class="wrs_modal_title",u.id=this.getElementId(u.class),this.title=v.createElement("div",u),this.title.innerHTML="",(u={}).class="wrs_modal_close_button",u.id=this.getElementId(u.class),u.title=$.getStringManager().getString("close"),this.closeDiv=v.createElement("a",u),this.closeDiv.setAttribute("role","button"),(u={}).class="wrs_modal_stack_button",u.id=this.getElementId(u.class),u.title="Exit full-screen",this.stackDiv=v.createElement("a",u),this.stackDiv.setAttribute("role","button"),(u={}).class="wrs_modal_maximize_button",u.id=this.getElementId(u.class),u.title=$.getStringManager().getString("fullscreen"),this.maximizeDiv=v.createElement("a",u),this.maximizeDiv.setAttribute("role","button"),(u={}).class="wrs_modal_minimize_button",u.id=this.getElementId(u.class),u.title=$.getStringManager().getString("minimise"),this.minimizeDiv=v.createElement("a",u),this.minimizeDiv.setAttribute("role","button"),(u={}).class="wrs_modal_dialogContainer",u.id=this.getElementId(u.class),this.container=v.createElement("div",u),(u={}).class="wrs_modal_wrapper",u.id=this.getElementId(u.class),this.wrapper=v.createElement("div",u),(u={}).class="wrs_content_container",u.id=this.getElementId(u.class),this.contentContainer=v.createElement("div",u),(u={}).class="wrs_modal_controls",u.id=this.getElementId(u.class),this.controls=v.createElement("div",u),(u={}).class="wrs_modal_buttons_container",u.id=this.getElementId(u.class),this.buttonContainer=v.createElement("div",u),this.submitButton=this.createSubmitButton({id:this.getElementId("wrs_modal_button_accept"),class:"wrs_modal_button_accept",innerHTML:$.getStringManager().getString("accept")},this.submitAction.bind(this)),this.cancelButton=this.createSubmitButton({id:this.getElementId("wrs_modal_button_cancel"),class:"wrs_modal_button_cancel",innerHTML:$.getStringManager().getString("cancel")},this.cancelAction.bind(this)),this.contentManager=null;var h={cancelString:$.getStringManager().getString("cancel"),submitString:$.getStringManager().getString("close"),message:$.getStringManager().getString("close_modal_warning")},d={closeCallback:function(){this.close()}.bind(this),cancelCallback:function(){this.focus()}.bind(this)},f={overlayElement:this.container,callbacks:d,strings:h};this.popup=new O(f),this.rtl=!1,"rtl"in this.attributes&&(this.rtl=this.attributes.rtl),this.handleOpenedIosSoftkeyboard=this.handleOpenedIosSoftkeyboard.bind(this),this.handleClosedIosSoftkeyboard=this.handleClosedIosSoftkeyboard.bind(this)}return function(e,t,i){t&&S(e.prototype,t),i&&S(e,i)}(e,[{key:"setContentManager",value:function(e){this.contentManager=e}},{key:"getContentManager",value:function(){return this.contentManager}},{key:"submitAction",value:function(){void 0!==this.contentManager.submitAction&&this.contentManager.submitAction(),this.close()}},{key:"cancelAction",value:function(){void 0===this.contentManager.hasChanges?this.close():this.contentManager.hasChanges()?this.showPopUpMessage():this.close()}},{key:"createSubmitButton",value:function(e,t){function i(e,t){this.element=document.createElement("button"),this.element.id=e.id,this.element.className=e.class,this.element.innerHTML=e.innerHTML,v.addEvent(this.element,"click",t)}return i.prototype.getElement=function(){return this.element},new i(e,t).getElement()}},{key:"create",value:function(){this.titleBar.appendChild(this.closeDiv),this.titleBar.appendChild(this.stackDiv),this.titleBar.appendChild(this.maximizeDiv),this.titleBar.appendChild(this.minimizeDiv),this.titleBar.appendChild(this.title),this.deviceProperties.isDesktop&&this.container.appendChild(this.titleBar),this.wrapper.appendChild(this.contentContainer),this.wrapper.appendChild(this.controls),this.controls.appendChild(this.buttonContainer),this.buttonContainer.appendChild(this.submitButton),this.buttonContainer.appendChild(this.cancelButton),this.container.appendChild(this.wrapper),this.recalculateScrollBar(),document.body.appendChild(this.container),document.body.appendChild(this.overlay),this.deviceProperties.isDesktop?(this.createModalWindowDesktop(),this.createResizeButtons(),this.addListeners(),l.get("modalWindowFullScreen")&&this.maximize()):this.deviceProperties.isAndroid?this.createModalWindowAndroid():this.deviceProperties.isIOS&&!this.deviceProperties.isMobile&&this.createModalWindowIos(),null!=this.contentManager&&this.contentManager.insert(this),this.properties.open=!0,this.properties.created=!0,this.isRTL()&&(this.container.style.right=window.innerWidth-this.scrollbarWidth-this.container.offsetWidth+"px",this.container.className+=" wrs_modal_rtl")}},{key:"createResizeButtons",value:function(){this.resizerBR=document.createElement("div"),this.resizerBR.className="wrs_bottom_right_resizer",this.resizerBR.innerHTML="◢",this.resizerTL=document.createElement("div"),this.resizerTL.className="wrs_bottom_left_resizer",this.container.appendChild(this.resizerBR),this.titleBar.appendChild(this.resizerTL),v.addEvent(this.resizerBR,"mousedown",this.activateResizeStateBR.bind(this)),v.addEvent(this.resizerTL,"mousedown",this.activateResizeStateTL.bind(this))}},{key:"activateResizeStateBR",value:function(e){this.initializeResizeProperties(e,!1)}},{key:"activateResizeStateTL",value:function(e){this.initializeResizeProperties(e,!0)}},{key:"initializeResizeProperties",value:function(e,t){v.addClass(document.body,"wrs_noselect"),v.addClass(this.overlay,"wrs_overlay_active"),this.resizeDataObject={x:this.eventClient(e).X,y:this.eventClient(e).Y},this.initialWidth=parseInt(this.container.style.width),this.initialHeight=parseInt(this.container.style.height),t?this.leftScale=!0:(this.initialRight=parseInt(this.container.style.right),this.initialBottom=parseInt(this.container.style.bottom)),this.initialRight||(this.initialRight=0),this.initialBottom||(this.initialBottom=0),document.body.style["user-select"]="none"}},{key:"open",value:function(){if(this.removeClass("wrs_closed"),(this.deviceProperties.isIOS||this.deviceProperties.isAndroid||this.deviceProperties.isMobile)&&(this.restoreWebsiteScale(),this.blockWebsiteScroll(),setTimeout(function(){this.hideKeyboard()}.bind(this),400)),this.properties.created?(this.properties.open||(this.properties.open=!0,this.deviceProperties.isAndroid||this.deviceProperties.isIOS||this.restoreState()),this.deviceProperties.isDesktop&&l.get("modalWindowFullScreen")&&this.maximize(),this.deviceProperties.isIOS&&(this.iosSoftkeyboardOpened=!1,this.setContainerHeight("100"+this.iosMeasureUnit))):this.create(),!1===this.contentManager.isEditorLoaded){var e=y.newListener("onLoad",function(){this.contentManager.onOpen(this)}.bind(this));this.contentManager.addListener(e)}else this.contentManager.onOpen(this)}},{key:"close",value:function(){this.removeClass("wrs_maximized"),this.removeClass("wrs_minimized"),this.removeClass("wrs_stack"),this.addClass("wrs_closed"),this.saveModalProperties(),this.unblockWebsiteScroll(),this.properties.open=!1}},{key:"restoreWebsiteScale",value:function(){var e=document.querySelector("meta[name=viewport]"),t=["initial-scale=","minimum-scale=","maximum-scale="],i=["1.0","1.0","1.0"],n=function(e,t){var n=e.getAttribute("content");if(n){for(var r=n.split(","),s="",a=[],o=0;o=0||navigator.userAgent.search("Trident/")>=0||navigator.userAgent.search("Edge/")>=0}},{key:"isRTL",value:function(){return"ar"==this.attributes.language||"he"==this.attributes.language||this.rtl}},{key:"addClass",value:function(e){v.addClass(this.overlay,e),v.addClass(this.titleBar,e),v.addClass(this.overlay,e),v.addClass(this.container,e),v.addClass(this.contentContainer,e),v.addClass(this.stackDiv,e),v.addClass(this.minimizeDiv,e),v.addClass(this.maximizeDiv,e),v.addClass(this.wrapper,e)}},{key:"removeClass",value:function(e){v.removeClass(this.overlay,e),v.removeClass(this.titleBar,e),v.removeClass(this.overlay,e),v.removeClass(this.container,e),v.removeClass(this.contentContainer,e),v.removeClass(this.stackDiv,e),v.removeClass(this.minimizeDiv,e),v.removeClass(this.maximizeDiv,e),v.removeClass(this.wrapper,e)}},{key:"createModalWindowDesktop",value:function(){this.addClass("wrs_modal_desktop"),this.stack()}},{key:"createModalWindowAndroid",value:function(){this.addClass("wrs_modal_android"),window.addEventListener("resize",this.orientationChangeAndroidSoftkeyboard.bind(this))}},{key:"createModalWindowIos",value:function(){this.addClass("wrs_modal_ios"),window.addEventListener("resize",this.orientationChangeIosSoftkeyboard.bind(this))}},{key:"restoreState",value:function(){"maximized"==this.properties.state?this.maximize():"minimized"==this.properties.state?(this.properties.state=this.properties.previousState,this.properties.previousState="",this.minimize()):this.stack()}},{key:"stack",value:function(){this.properties.previousState=this.properties.state,this.properties.state="stack",this.removeClass("wrs_maximized"),this.minimizeDiv.title="Minimise",this.removeClass("wrs_minimized"),this.addClass("wrs_stack"),this.restoreModalProperties(),void 0!==this.resizerBR&&void 0!==this.resizerTL&&this.setResizeButtonsVisibility(),this.recalculateScrollBar(),this.recalculatePosition(),this.recalculateScale(),this.focus()}},{key:"minimize",value:function(){this.saveModalProperties(),"minimized"==this.properties.state&&"stack"==this.properties.previousState?this.stack():"minimized"==this.properties.state&&"maximized"==this.properties.previousState?this.maximize():(this.container.style.height="30px",this.container.style.width="250px",this.container.style.bottom="0px",this.container.style.right="10px",this.removeListeners(),this.properties.previousState=this.properties.state,this.properties.state="minimized",this.setResizeButtonsVisibility(),this.minimizeDiv.title="Maximise",v.containsClass(this.overlay,"wrs_stack")?this.removeClass("wrs_stack"):this.removeClass("wrs_maximized"),this.addClass("wrs_minimized"))}},{key:"maximize",value:function(){this.saveModalProperties(),"maximized"!=this.properties.state&&(this.properties.previousState=this.properties.state,this.properties.state="maximized"),this.setResizeButtonsVisibility(),v.containsClass(this.overlay,"wrs_minimized")?(this.minimizeDiv.title="Minimise",this.removeClass("wrs_minimized")):v.containsClass(this.overlay,"wrs_stack")&&(this.container.style.left=null,this.container.style.top=null,this.removeClass("wrs_stack")),this.addClass("wrs_maximized"),this.setSize(parseInt(.8*window.innerHeight),parseInt(.8*window.innerWidth));this.container.clientHeight>700&&(this.container.style.height="700px"),this.container.clientWidth>1200&&(this.container.style.width="1200px"),this.setPosition(window.innerHeight/2-this.container.offsetHeight/2,window.innerWidth/2-this.container.offsetWidth/2),this.recalculateScale(),this.recalculatePosition(),this.recalculateSize(),this.focus()}},{key:"setSize",value:function(e,t){this.container.style.height=e+"px",this.container.style.width=t+"px",this.recalculateSize()}},{key:"setPosition",value:function(e,t){this.container.style.bottom=e+"px",this.container.style.right=t+"px"}},{key:"saveModalProperties",value:function(){"stack"==this.properties.state&&(this.properties.position.bottom=parseInt(this.container.style.bottom),this.properties.position.right=parseInt(this.container.style.right),this.properties.size.width=parseInt(this.container.style.width),this.properties.size.height=parseInt(this.container.style.height))}},{key:"restoreModalProperties",value:function(){"stack"==this.properties.state&&(this.setPosition(this.properties.position.bottom,this.properties.position.right),this.setSize(this.properties.size.height,this.properties.size.width))}},{key:"recalculateSize",value:function(){this.wrapper.style.width=this.container.clientWidth-12+"px",this.wrapper.style.height=this.container.clientHeight-38+"px",this.contentContainer.style.height=parseInt(this.wrapper.offsetHeight-50)+"px"}},{key:"setResizeButtonsVisibility",value:function(){"stack"==this.properties.state?(this.resizerTL.style.visibility="visible",this.resizerBR.style.visibility="visible"):(this.resizerTL.style.visibility="hidden",this.resizerBR.style.visibility="hidden")}},{key:"addListeners",value:function(){this.maximizeDiv.addEventListener("click",this.maximize.bind(this),!0),this.stackDiv.addEventListener("click",this.stack.bind(this),!0),this.minimizeDiv.addEventListener("click",this.minimize.bind(this),!0),this.closeDiv.addEventListener("click",this.cancelAction.bind(this)),v.addEvent(window,"mousedown",this.startDrag.bind(this)),v.addEvent(window,"mouseup",this.stopDrag.bind(this)),v.addEvent(window,"mousemove",this.drag.bind(this)),v.addEvent(window,"resize",this.onWindowResize.bind(this)),v.addEvent(window,"keydown",this.onKeyDown.bind(this))}},{key:"removeListeners",value:function(){v.removeEvent(window,"mousedown",this.startDrag),v.removeEvent(window,"mouseup",this.stopDrag),v.removeEvent(window,"mousemove",this.drag),v.removeEvent(window,"resize",this.onWindowResize),v.removeEvent(window,"keydown",this.onKeyDown)}},{key:"eventClient",value:function(e){if(void 0===e.clientX&&e.changedTouches){var t={X:e.changedTouches[0].clientX,Y:e.changedTouches[0].clientY};return t}return t={X:e.clientX,Y:e.clientY}}},{key:"startDrag",value:function(e){"minimized"!=this.properties.state&&e.target===this.title&&(void 0!==this.dragDataObject&&null!==this.dragDataObject||(e=e||event,this.dragDataObject={x:this.eventClient(e).X,y:this.eventClient(e).Y},this.lastDrag={x:"0px",y:"0px"},""==this.container.style.right&&(this.container.style.right="0px"),""==this.container.style.bottom&&(this.container.style.bottom="0px"),this.isIE11(),v.addClass(document.body,"wrs_noselect"),v.addClass(this.overlay,"wrs_overlay_active"),this.limitWindow=this.getLimitWindow()))}},{key:"drag",value:function(e){if(this.dragDataObject){e.preventDefault(),e=e||event;var t=Math.min(this.eventClient(e).Y,this.limitWindow.minPointer.y);t=Math.max(this.limitWindow.maxPointer.y,t);var i=Math.min(this.eventClient(e).X,this.limitWindow.minPointer.x),n=(i=Math.max(this.limitWindow.maxPointer.x,i))-this.dragDataObject.x+"px",r=t-this.dragDataObject.y+"px";this.lastDrag={x:n,y:r},this.container.style.transform="translate3d("+n+","+r+",0)"}if(this.resizeDataObject){var s;i=Math.min(this.eventClient(e).X,window.innerWidth-this.scrollbarWidth-7),t=Math.min(this.eventClient(e).Y,window.innerHeight-7);i<0&&(i=0),t<0&&(t=0),s=this.leftScale?-1:1,this.container.style.width=this.initialWidth+s*(i-this.resizeDataObject.x)+"px",this.container.style.height=this.initialHeight+s*(t-this.resizeDataObject.y)+"px",this.leftScale||(this.resizeDataObject.x-i-this.initialWidth<-580?this.container.style.right=this.initialRight-(i-this.resizeDataObject.x)+"px":(this.container.style.right=this.initialRight+this.initialWidth-580+"px",this.container.style.width="580px"),this.resizeDataObject.y-t580?(this.container.style.width=Math.min(parseInt(this.container.style.width),window.innerWidth-this.scrollbarWidth)+"px",e=!0):(this.container.style.width="580px",e=!0),parseInt(this.container.style.height)>338?(this.container.style.height=Math.min(parseInt(this.container.style.height),window.innerHeight)+"px",e=!0):(this.container.style.height="338px",e=!0),e&&this.recalculateSize()}},{key:"recalculateScrollBar",value:function(){this.hasScrollBar=window.innerWidth>document.documentElement.clientWidth,this.hasScrollBar?this.scrollbarWidth=this.getScrollBarWidth():this.scrollbarWidth=0}},{key:"hideKeyboard",value:function(){document.activeElement.blur()}},{key:"focus",value:function(){null!=this.contentManager&&void 0!==this.contentManager.onFocus&&this.contentManager.onFocus()}},{key:"portraitMode",value:function(){return window.innerHeight>window.innerWidth}},{key:"handleOpenedIosSoftkeyboard",value:function(){this.iosSoftkeyboardOpened||null==this.iosDivHeight||this.iosDivHeight!="100"+this.iosMeasureUnit||(this.portraitMode()?this.setContainerHeight("63"+this.iosMeasureUnit):this.setContainerHeight("40"+this.iosMeasureUnit)),this.iosSoftkeyboardOpened=!0}},{key:"handleClosedIosSoftkeyboard",value:function(){this.iosSoftkeyboardOpened=!1,this.setContainerHeight("100"+this.iosMeasureUnit)}},{key:"orientationChangeIosSoftkeyboard",value:function(){this.iosSoftkeyboardOpened?this.portraitMode()?this.setContainerHeight("63"+this.iosMeasureUnit):this.setContainerHeight("40"+this.iosMeasureUnit):this.setContainerHeight("100"+this.iosMeasureUnit)}},{key:"orientationChangeAndroidSoftkeyboard",value:function(){this.setContainerHeight("100%")}},{key:"setContainerHeight",value:function(e){this.iosDivHeight=e,this.wrapper.style.height=e}},{key:"showPopUpMessage",value:function(){"minimized"==this.properties.state&&this.stack(),this.popup.show()}},{key:"setTitle",value:function(e){this.title.innerHTML=e}},{key:"getElementId",value:function(e){return e+"["+this.instanceId+"]"}}]),e}();function I(e){return(I="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function A(e,t){for(var i=0;i=4;){v.readInt32(e);var t=v.readInt32(e);if(1229472850==t){var i=v.readInt32(e),n=v.readInt32(e);v.readInt32(e),v.readByte(e)}else if(1650545477==t)var r=v.readInt32(e);else if(1883789683==t){var s=v.readInt32(e);s=Math.round(s/39.37),v.readInt32(e),v.readByte(e)}v.readInt32(e)}if(void 0!==i){var a=new Array;return a.cw=i,a.ch=n,a.dpi=s,r&&(a.cb=r),a}}}]),e}();function P(e,t){for(var i=0;i"),m=c.substring(0,f),p=m.split(" width=").join(' class="Wiriscas" width=');c=(c=c.split(m).join(p)).split("'").join('"')}}var b='';t=t.substring(0,n[o].start+s)+b+t.substring(n[o].end+s),s+=b.length-(n[o].end-n[o].start)}}return t}},{key:"initParseEditMode",value:function(e){if(-1!=l.get("parseModes").indexOf("latex"))for(var t=v.getElementsByNameFromString(e,"img",!0),i='encoding="LaTeX">',n=0,r=0;r",d),m=h.substring(d,f),g="$$"+v.htmlEntitiesDecode(m)+"$$";e=e.substring(0,t[r].start+n)+g+e.substring(t[r].end+n),n+=g.length-(t[r].end-t[r].start)}}}}return e}},{key:"endParse",value:function(t){var i=e.endParseEditMode(t);return e.endParseSaveMode(i)}},{key:"endParseEditMode",value:function(e){if(-1!=l.get("parseModes").indexOf("latex")){for(var t="",i=0,n=e.indexOf("$$");-1!=n;){if(t+=e.substring(i,n),-1!=(i=e.indexOf("$$",n+2))){var r=e.substring(n+2,i);r=v.htmlEntitiesDecode(r),t+=g.getMathMLFromLatex(r,!0),i+=2}else t+="$$",i=n+2;n=e.indexOf("$$",i)}e=t+=e.substring(i,e.length)}return e}},{key:"endParseSaveMode",value:function(t){return l.get("saveMode")&&("safeXml"==l.get("saveMode")?t=e.codeImgTransform(t,"img2mathml"):"xml"==l.get("saveMode")?t=e.codeImgTransform(t,"img2mathml"):"base64"==l.get("saveMode")&&"image"==l.get("editMode")&&(t=e.codeImgTransform(t,"img264"))),t}},{key:"createShowImageSrc",value:function(e,t){var i=[],n="mml,color,centerbaseline,zoom,dpi,fontSize,fontFamily,defaultStretchy,backgroundColor,format".split(",");for(var r in n){var s=n[r];void 0!==e[s]&&(i[s]=e[s])}var a={};for(var r in e)"mml"!=r&&(a[r]=e[r]);return a.formula=com.wiris.js.JsPluginTools.md5encode(v.propertiesToString(i)),a.lang=void 0===t?"en":t,a.version=l.get("version"),f.getService("showimage",v.httpBuildQuery(a),!0)}},{key:"codeImgTransform",value:function(t,i){for(var n="",r=0,s=/"==h&&(r=u+1);++u}if(r",u):c.length,a.isMathmlInAttribute(t,u)||-1!=d)s+=t.substring(u,h);else{var f=t.substring(u,h);f=i==r.safeXmlCharacters?a.safeXmlDecode(f):a.mathMLEntities(f),s+=v.createObjectCode(e.mathmlToImgObject(document,f,null,n))}u=t.indexOf(o,h)}return s+=t.substring(h,t.length)}}]),e}();if("undefined"!=typeof MutationObserver){var D=new MutationObserver(function(e){e.forEach(function(e){e.oldValue===l.get("imageClassName")&&"class"===e.attributeName&&-1==e.target.className.indexOf(l.get("imageClassName"))&&(e.target.className=l.get("imageClassName"))})});B.observer=Object.create(D),B.observer.Config={attributes:!0,attributeOldValue:!0},B.observer.observe=function(e){this.__proto__.observe(e,this.Config)}}function R(e,t){for(var i=0;i=0&&(t=e[i].src.substr(0,n-1))}return t}},{key:"setLanguage",value:function(e){this.language=e}},{key:"setCore",value:function(e){this.core=e,e.setIntegrationModel(this)}},{key:"getCore",value:function(){return this.core}},{key:"setTarget",value:function(e){this.target=e,this.isIframe="IFRAME"===this.target.tagName.toUpperCase()}},{key:"setEditorObject",value:function(e){this.editorObject=e}},{key:"openNewFormulaEditor",value:function(){this.core.editionProperties.isNewElement=!0,this.core.openModalDialog(this.target,this.isIframe)}},{key:"openExistingFormulaEditor",value:function(){this.core.editionProperties.isNewElement=!1,this.core.openModalDialog(this.target,this.isIframe)}},{key:"updateFormula",value:function(e){this.isIframe?this.core.updateFormula(this.target.contentWindow,this.target.contentWindow,e,null):this.core.updateFormula(this.target,window,e,null)}},{key:"getSelection",value:function(){return this.isIframe?(this.target.contentWindow.focus(),this.target.contentWindow.getSelection()):(this.target.focus(),window.getSelection())}},{key:"addEvents",value:function(){var e=this.isIframe?this.target.contentWindow.document:this.target;v.addElementEvents(e,function(e,t){this.doubleClickHandler(e,t)}.bind(this),function(e,t){this.mousedownHandler(e,t)}.bind(this),function(e,t){this.mouseupHandler(e,t)}.bind(this))}},{key:"doubleClickHandler",value:function(e){if("img"==e.nodeName.toLowerCase()){if(this.core.getCustomEditors().disable(),e.hasAttribute("data-custom-editor")){var t=e.getAttribute("data-custom-editor");this.core.getCustomEditors().enable(t)}v.containsClass(e,l.get("imageClassName"))&&(this.core.editionProperties.temporalImage=e,this.core.editionProperties.isNewElement=!0,this.openExistingFormulaEditor())}}},{key:"mouseupHandler",value:function(){this.temporalImageResizing&&setTimeout(function(){T.fixAfterResize(this.temporalImageResizing)}.bind(this),10)}},{key:"mousedownHandler",value:function(e){"img"==e.nodeName.toLowerCase()&&v.containsClass(e,l.get("imageClassName"))&&(this.temporalImageResizing=e)}},{key:"getLanguage",value:function(){return this.getBrowserLanguage()}},{key:"getBrowserLanguage",value:function(){return navigator.userLanguage?navigator.userLanguage.substring(0,2):navigator.language?navigator.language.substring(0,2):"en"}},{key:"callbackFunction",value:function(){var e=y.newListener("onTargetReady",function(){this.addEvents(this.target)}.bind(this));this.listeners.add(e)}},{key:"notifyWindowClosed",value:function(){}},{key:"getMathmlFromTextNode",value:function(e,t){}},{key:"fillNonLatexNode",value:function(e,t,i){}},{key:"getSelectedItem",value:function(e,t){}}]),e}();function J(e,t){for(var i=0;i=0?"EDGE":e.search("Chrome/")>=0?"CHROME":e.search("Trident/")>=0?"IE":e.search("Firefox/")>=0?"FIREFOX":e.search("Safari/")>=0?"SAFARI":void 0}(),this.listeners=new y}return function(e,t,i){t&&J(e.prototype,t),i&&J(e,i)}(e,[{key:"init",value:function(e){this.load(e)}},{key:"setIntegrationModel",value:function(e){this.integrationModel=e}},{key:"setEnvironment",value:function(e){"editor"in e&&(this.environment.editor=e.editor),"mode"in e&&(this.environment.mode=e.mode),"version"in e&&(this.environment.version=e.version)}},{key:"getModalDialog",value:function(){return this.modalDialog}},{key:"load",value:function(t){var i="undefined"!=typeof XMLHttpRequest?new XMLHttpRequest:new ActiveXObject("Microsoft.XMLHTTP");this.integrationPath=0==t.indexOf("/")||0==t.indexOf("http")?t:v.concatenateUrl(this.integrationModel.getPath(),t),i.open("GET",this.integrationPath,!1),i.onload=function(t){var n=this;if(4===i.readyState){var r=JSON.parse(i.responseText);Object.keys(r);if(l.addConfiguration(r),l.addConfiguration(H),this.loadServicePaths(),this.loadLangFile(),this.loadCSS(),null===e.stringManager){var s=y.newListener("onLoad",function(){n.listeners.fire("onLoad",{})});e.stringManager.addListener(s)}else this.listeners.fire("onLoad",{})}}.bind(this),i.send(null)}},{key:"loadServicePaths",value:function(){var e=this.integrationPath.replace("configurationjs","createimage"),t=this.integrationPath.replace("configurationjs","showimage"),i=(e=this.integrationPath.replace("configurationjs","createimage"),this.integrationPath.replace("configurationjs","getmathml")),n=this.integrationPath.replace("configurationjs","service");if(0==this.integrationPath.indexOf("/")){var r=this.getServerPath();t=r+t,e=r+e,i=r+i,n=r+n}f.setServicePath("showimage",t),f.setServicePath("createimage",e),f.setServicePath("service",n),f.setServicePath("getmathml",i)}},{key:"getServerPath",value:function(){var e=this.integrationModel.getPath(),t=e.indexOf("/",e.indexOf("/")+2);return e.substr(0,t)}},{key:"loadLangFile",value:function(){var t="ar,ca,cs,da,de,en,es,et,eu,fi,fr,gl,he,hr,hu,it,ja,ko,nl,no,pl,pt,pt_br,ru,sv,tr,zh,el".split(","),i=this.language;-1==t.indexOf(i)&&(i=i.substr(0,2)),-1==t.indexOf(i)&&(i="en");var n=document.createElement("script");n.type="text/javascript",n.src=this.integrationModel.getPath()+"/"+this.integrationModel.langFolderName+"/"+i+"/strings.js",n.onload=function(){e.getStringManager().loadStrings(wrs_strings)},document.getElementsByTagName("head")[0].appendChild(n)}},{key:"loadCSS",value:function(){var e=document.createElement("link");e.setAttribute("rel","stylesheet"),e.setAttribute("type","text/css"),e.setAttribute("href",v.concatenateUrl(this.integrationModel.getPath(),"/core/styles.css")),document.getElementsByTagName("head")[0].appendChild(e)}},{key:"addListener",value:function(e){this.listeners.add(e)}},{key:"updateFormula",value:function(t,i,n,r){var s=new F;for(var a in s.mathml=n,s.wirisProperties={},r)s.wirisProperties[a]=r[a];if(s.language=this.language,s.editMode=this.editMode,!this.listeners.fire("onBeforeFormulaInsertion",s)&&!e.globalListeners.fire("onBeforeFormulaInsertion",s)){n=s.mathml,r=s.wirisProperties;var o=new F;if(o.editMode=this.editMode,o.windowTarget=i,o.focusElement=t,n)if("latex"==this.editMode)o.latex=g.getLatexFromMathML(n),this.integrationModel.fillNonLatexNode&&!o.latex?this.integrationModel.fillNonLatexNode(o,i,n):o.node=i.document.createTextNode("$$"+o.latex+"$$"),this.insertElementOnSelection(o.node,t,i);else if("iframes"==this.editMode){var l=wrs_mathmlToIframeObject(i,n);this.insertElementOnSelection(l,t,i)}else o.node=B.mathmlToImgObject(i.document,n,r,this.language),this.insertElementOnSelection(o.node,t,i);else this.insertElementOnSelection(null,t,i);this.listeners.fire("onAfterFormulaInsertion",o)||e.globalListeners.fire("onAfterFormulaInsertion",o)}}},{key:"placeCaretAfterNode",value:function(e){this.integrationModel.getSelection();var t=e.ownerDocument;if(void 0!==t.getSelection&&e.parentElement){var i=t.createRange();i.setStartAfter(e),i.collapse(!0);var n=t.getSelection();n.removeAllRanges(),n.addRange(i),t.body.focus()}}},{key:"insertElementOnSelection",value:function(e,t,i){if(this.editionProperties.isNewElement)if(e)if("textarea"==t.type)v.updateTextArea(t,e.textContent);else if(document.selection&&0==document.getSelection){var n=i.document.selection.createRange();if(i.document.execCommand("InsertImage",!1,e.src),"parentElement"in n||(i.document.execCommand("delete",!1),n=i.document.selection.createRange(),i.document.execCommand("InsertImage",!1,e.src)),"parentElement"in n){var r=n.parentElement();"IMG"==r.nodeName.toUpperCase()?r.parentNode.replaceChild(e,r):n.pasteHTML(v.createObjectCode(e))}}else{var s,a=this.integrationModel.getSelection();this.editionProperties.range?(s=this.editionProperties.range,this.editionProperties.range=null):s=a.getRangeAt(0),s.deleteContents();var o=s.startContainer,l=s.startOffset;3==o.nodeType?(o=o.splitText(l)).parentNode.insertBefore(e,o):1==o.nodeType&&o.insertBefore(e,o.childNodes[l]),this.placeCaretAfterNode(e)}else if("textarea"==t.type)t.focus();else{var c=this.integrationModel.getSelection();if(c.removeAllRanges(),this.editionProperties.range){var u=this.editionProperties.range;this.editionProperties.range=null,c.addRange(u)}}else if(this.editionProperties.latexRange)document.selection&&0==document.getSelection?(this.editionProperties.isNewElement=!0,this.editionProperties.latexRange.select(),this.insertElementOnSelection(e,t,i)):(this.editionProperties.latexRange.deleteContents(),this.editionProperties.latexRange.insertNode(e),this.placeCaretAfterNode(e));else if("textarea"==t.type){var h;h=void 0!==this.integrationModel.getSelectedItem?this.integrationModel.getSelectedItem(t,!1):v.getSelectedItemOnTextarea(t),v.updateExistingTextOnTextarea(t,e.textContent,h.startPosition,h.endPosition)}else e&&"img"===e.nodeName.toLowerCase()?T.clone(e,this.editionProperties.temporalImage):this.editionProperties.temporalImage.remove(),this.placeCaretAfterNode(this.editionProperties.temporalImage)}},{key:"openModalDialog",value:function(e,t){this.editMode="images";try{if(t){e.contentWindow.focus();var i=e.contentWindow.getSelection();this.editionProperties.range=i.getRangeAt(0)}else{e.focus();var n=getSelection();this.editionProperties.range=n.getRangeAt(0)}}catch(e){this.editionProperties.range=null}var r;if(void 0===t&&(t=!0),this.editionProperties.latexRange=null,e)if(r=void 0!==this.integrationModel.getSelectedItem?this.integrationModel.getSelectedItem(e,t):v.getSelectedItem(e,t)){if(!r.caretPosition&&v.containsClass(r.node,l.get("imageClassName")))this.editionProperties.temporalImage=r.node,this.editionProperties.isNewElement=!1;else if(3===r.node.nodeType)if(this.integrationModel.getMathmlFromTextNode){var s=this.integrationModel.getMathmlFromTextNode(r.node,r.caretPosition);s&&(this.editMode="latex",this.editionProperties.isNewElement=!1,this.editionProperties.temporalImage=document.createElement("img"),this.editionProperties.temporalImage.setAttribute(l.get("imageMathmlAttribute"),a.safeXmlEncode(s)))}else{var o=g.getLatexFromTextNode(r.node,r.caretPosition);if(o){var c=g.getMathMLFromLatex(o.latex);this.editMode="latex",this.editionProperties.isNewElement=!1,this.editionProperties.temporalImage=document.createElement("img"),this.editionProperties.temporalImage.setAttribute(l.get("imageMathmlAttribute"),a.safeXmlEncode(c));var u=t?e.contentWindow:window;if("textarea"!==e.tagName.toLowerCase())if(document.selection){for(var h=0,d=o.startNode.previousSibling;d;)h+=v.getNodeLength(d),d=d.previousSibling;this.editionProperties.latexRange=u.document.selection.createRange(),this.editionProperties.latexRange.moveToElementText(o.startNode.parentNode),this.editionProperties.latexRange.move("character",h+o.startPosition),this.editionProperties.latexRange.moveEnd("character",o.latex.length+4)}else this.editionProperties.latexRange=u.document.createRange(),this.editionProperties.latexRange.setStart(o.startNode,o.startPosition),this.editionProperties.latexRange.setEnd(o.endNode,o.endPosition)}}}else"textarea"===e.tagName.toLowerCase()&&(this.editMode="latex");for(var f=l.get("editorAttributes").split(", "),m={},p=0,b=f.length;p>>32-t},str2blks:function(e){for(var t=1+(e.length+8>>6),i=new Array,n=0,r=16*t;n>2]|=HxOverrides.cca(e,s)<<(8*e.length+s)%4*8,s++;i[s>>2]|=128<<(8*e.length+s)%4*8;var o=8*e.length,a=16*t-2;return i[a]=255&o,i[a]|=(o>>>8&255)<<8,i[a]|=(o>>>16&255)<<16,i[a]|=(o>>>24&255)<<24,i},rhex:function(e){for(var t="",i=0;i<4;){var n=i++;t+="0123456789abcdef".charAt(e>>8*n+4&15)+"0123456789abcdef".charAt(e>>8*n&15)}return t},addme:function(e,t){var i=(65535&e)+(65535&t);return(e>>16)+(t>>16)+(i>>16)<<16|65535&i},bitAND:function(e,t){return(e>>>1&t>>>1)<<1|1&e&t},bitXOR:function(e,t){return(e>>>1^t>>>1)<<1|1&e^1&t},bitOR:function(e,t){return(e>>>1|t>>>1)<<1|(1&e|1&t)},__class__:haxe.Md5},haxe.Timer=function(e){var t=this;this.id=window.setInterval(function(){t.run()},e)},haxe.Timer.__name__=!0,haxe.Timer.delay=function(e,t){var i=new haxe.Timer(t);return i.run=function(){i.stop(),e()},i},haxe.Timer.measure=function(e,t){var i=haxe.Timer.stamp(),n=e();return haxe.Log.trace(haxe.Timer.stamp()-i+"s",t),n},haxe.Timer.stamp=function(){return(new Date).getTime()/1e3},haxe.Timer.prototype={run:function(){},stop:function(){null!=this.id&&(window.clearInterval(this.id),this.id=null)},__class__:haxe.Timer};var js=js||{},$_;function $bind(e,t){var i=function e(){return e.method.apply(e.scope,arguments)};return i.scope=e,i.method=t,i}js.Boot=function(){},js.Boot.__name__=!0,js.Boot.__unhtml=function(e){return e.split("&").join("&").split("<").join("<").split(">").join(">")},js.Boot.__trace=function(e,t){var i,n=null!=t?t.fileName+":"+t.lineNumber+": ":"";n+=js.Boot.__string_rec(e,""),"undefined"!=typeof document&&null!=(i=document.getElementById("haxe:trace"))?i.innerHTML+=js.Boot.__unhtml(n)+"
":"undefined"!=typeof console&&null!=console.log&&console.log(n)},js.Boot.__clear_trace=function(){var e=document.getElementById("haxe:trace");null!=e&&(e.innerHTML="")},js.Boot.isClass=function(e){return e.__name__},js.Boot.isEnum=function(e){return e.__ename__},js.Boot.getClass=function(e){return e.__class__},js.Boot.__string_rec=function(e,t){if(null==e)return"null";if(t.length>=5)return"<...>";var i=_typeof(e);switch("function"==i&&(e.__name__||e.__ename__)&&(i="object"),i){case"object":if(e instanceof Array){if(e.__enum__){if(2==e.length)return e[0];var n=e[0]+"(";t+="\t";for(var r=2,s=e.length;r0?",":"")+js.Boot.__string_rec(e[l],t)}return n+="]"}var c;try{c=e.toString}catch(e){return"???"}if(null!=c&&c!=Object.toString){var u=e.toString();if("[object Object]"!=u)return u}var h=null;n="{\n";t+="\t";var d=null!=e.hasOwnProperty;for(var h in e)d&&!e.hasOwnProperty(h)||"prototype"!=h&&"__class__"!=h&&"__super__"!=h&&"__interfaces__"!=h&&"__properties__"!=h&&(2!=n.length&&(n+=", \n"),n+=t+h+" : "+js.Boot.__string_rec(e[h],t));return n+="\n"+(t=t.substring(1))+"}";case"function":return"";case"string":return e;default:return String(e)}},js.Boot.__interfLoop=function(e,t){if(null==e)return!1;if(e==t)return!0;var i=e.__interfaces__;if(null!=i)for(var n=0,r=i.length;n>>32-t},str2blks:function(e){for(var t=1+(e.length+8>>6),i=new Array,n=0,r=16*t;n>2]|=HxOverrides.cca(e,s)<<(8*e.length+s)%4*8,s++;i[s>>2]|=128<<(8*e.length+s)%4*8;var o=8*e.length,a=16*t-2;return i[a]=255&o,i[a]|=(o>>>8&255)<<8,i[a]|=(o>>>16&255)<<16,i[a]|=(o>>>24&255)<<24,i},rhex:function(e){for(var t="",i=0;i<4;){var n=i++;t+="0123456789abcdef".charAt(e>>8*n+4&15)+"0123456789abcdef".charAt(e>>8*n&15)}return t},addme:function(e,t){var i=(65535&e)+(65535&t);return(e>>16)+(t>>16)+(i>>16)<<16|65535&i},bitAND:function(e,t){return(e>>>1&t>>>1)<<1|1&e&t},bitXOR:function(e,t){return(e>>>1^t>>>1)<<1|1&e^1&t},bitOR:function(e,t){return(e>>>1|t>>>1)<<1|(1&e|1&t)},__class__:haxe.Md5},haxe.Timer=function(e){var t=this;this.id=window.setInterval(function(){t.run()},e)},haxe.Timer.__name__=!0,haxe.Timer.delay=function(e,t){var i=new haxe.Timer(t);return i.run=function(){i.stop(),e()},i},haxe.Timer.measure=function(e,t){var i=haxe.Timer.stamp(),n=e();return haxe.Log.trace(haxe.Timer.stamp()-i+"s",t),n},haxe.Timer.stamp=function(){return(new Date).getTime()/1e3},haxe.Timer.prototype={run:function(){},stop:function(){null!=this.id&&(window.clearInterval(this.id),this.id=null)},__class__:haxe.Timer};var js=js||{},$_;function $bind(e,t){var i=function e(){return e.method.apply(e.scope,arguments)};return i.scope=e,i.method=t,i}js.Boot=function(){},js.Boot.__name__=!0,js.Boot.__unhtml=function(e){return e.split("&").join("&").split("<").join("<").split(">").join(">")},js.Boot.__trace=function(e,t){var i,n=null!=t?t.fileName+":"+t.lineNumber+": ":"";n+=js.Boot.__string_rec(e,""),"undefined"!=typeof document&&null!=(i=document.getElementById("haxe:trace"))?i.innerHTML+=js.Boot.__unhtml(n)+"
":"undefined"!=typeof console&&null!=console.log&&console.log(n)},js.Boot.__clear_trace=function(){var e=document.getElementById("haxe:trace");null!=e&&(e.innerHTML="")},js.Boot.isClass=function(e){return e.__name__},js.Boot.isEnum=function(e){return e.__ename__},js.Boot.getClass=function(e){return e.__class__},js.Boot.__string_rec=function(e,t){if(null==e)return"null";if(t.length>=5)return"<...>";var i=_typeof(e);switch("function"==i&&(e.__name__||e.__ename__)&&(i="object"),i){case"object":if(e instanceof Array){if(e.__enum__){if(2==e.length)return e[0];var n=e[0]+"(";t+="\t";for(var r=2,s=e.length;r0?",":"")+js.Boot.__string_rec(e[l],t)}return n+="]"}var c;try{c=e.toString}catch(e){return"???"}if(null!=c&&c!=Object.toString){var u=e.toString();if("[object Object]"!=u)return u}var h=null;n="{\n";t+="\t";var d=null!=e.hasOwnProperty;for(var h in e)d&&!e.hasOwnProperty(h)||"prototype"!=h&&"__class__"!=h&&"__super__"!=h&&"__interfaces__"!=h&&"__properties__"!=h&&(2!=n.length&&(n+=", \n"),n+=t+h+" : "+js.Boot.__string_rec(e[h],t));return n+="\n"+(t=t.substring(1))+"}";case"function":return"";case"string":return e;default:return String(e)}},js.Boot.__interfLoop=function(e,t){if(null==e)return!1;if(e==t)return!0;var i=e.__interfaces__;if(null!=i)for(var n=0,r=i.length;n=0&&l.splice(t,1)}function m(e){var t=document.createElement("style");if(void 0===e.attrs.type&&(e.attrs.type="text/css"),void 0===e.attrs.nonce){var n=function(){0;return i.nc}();n&&(e.attrs.nonce=n)}return g(t,e.attrs),d(e,t),t}function g(e,t){Object.keys(t).forEach(function(i){e.setAttribute(i,t[i])})}function p(e,t){var i,n,r,s;if(t.transform&&e.css){if(!(s="function"==typeof t.transform?t.transform(e.css):t.transform.default(e.css)))return function(){};e.css=s}if(t.singleton){var l=a++;i=o||(o=m(t)),n=b.bind(null,i,l,!1),r=b.bind(null,i,l,!0)}else e.sourceMap&&"function"==typeof URL&&"function"==typeof URL.createObjectURL&&"function"==typeof URL.revokeObjectURL&&"function"==typeof Blob&&"function"==typeof btoa?(i=function(e){var t=document.createElement("link");return void 0===e.attrs.type&&(e.attrs.type="text/css"),e.attrs.rel="stylesheet",g(t,e.attrs),d(e,t),t}(t),n=function(e,t,i){var n=i.css,r=i.sourceMap,s=void 0===t.convertToAbsoluteUrls&&r;(t.convertToAbsoluteUrls||s)&&(n=c(n));r&&(n+="\n/*# sourceMappingURL=data:application/json;base64,"+btoa(unescape(encodeURIComponent(JSON.stringify(r))))+" */");var o=new Blob([n],{type:"text/css"}),a=e.href;e.href=URL.createObjectURL(o),a&&URL.revokeObjectURL(a)}.bind(null,i,t),r=function(){f(i),i.href&&URL.revokeObjectURL(i.href)}):(i=m(t),n=function(e,t){var i=t.css,n=t.media;n&&e.setAttribute("media",n);if(e.styleSheet)e.styleSheet.cssText=i;else{for(;e.firstChild;)e.removeChild(e.firstChild);e.appendChild(document.createTextNode(i))}}.bind(null,i),r=function(){f(i)});return n(e),function(t){if(t){if(t.css===e.css&&t.media===e.media&&t.sourceMap===e.sourceMap)return;n(e=t)}else r()}}e.exports=function(e,t){if("undefined"!=typeof DEBUG&&DEBUG&&"object"!=typeof document)throw new Error("The style-loader cannot be used in a non-browser environment");(t=t||{}).attrs="object"==typeof t.attrs?t.attrs:{},t.singleton||"boolean"==typeof t.singleton||(t.singleton=r()),t.insertInto||(t.insertInto="head"),t.insertAt||(t.insertAt="bottom");var i=h(e,t);return u(i,t),function(e){for(var r=[],s=0;s«/mo»",ampElement:"«mo»&«/mo»"}}},{key:"safeGoodBlackboardCharacters",get:function(){return{ltElement:"«mo»§lt;«/mo»",gtElement:"«mo»§gt;«/mo»",ampElement:"«mo»§amp;«/mo»"}}}]),e}();function s(e,t){for(var i=0;i",doubleQuote:'"',ampersand:"&",quote:"'"},r.safeXmlCharacters={tagOpener:"«",tagCloser:"»",doubleQuote:"¨",ampersand:"§",quote:"`",realDoubleQuote:"¨"};var o=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e)}return function(e,t,i){t&&s(e.prototype,t),i&&s(e,i)}(e,null,[{key:"isMathmlInAttribute",value:function(e,t){var i=new RegExp("^['\"][\\s]*=[\\s]*[\\w-]+([\\s]*(\"[^\"]*\"|'[^']*')[\\s]*=[\\s]*[\\w-]+[\\s]*)*[\\s]+gmi<"),n=e.substring(0,t).split("").reverse().join("");return i.test(n)}},{key:"safeXmlDecode",value:function(e){e=(e=(e=(e=e.split(r.safeXmlCharactersEntities.tagOpener).join(r.safeXmlCharacters.tagOpener)).split(r.safeXmlCharactersEntities.tagCloser).join(r.safeXmlCharacters.tagCloser)).split(r.safeXmlCharactersEntities.doubleQuote).join(r.safeXmlCharacters.doubleQuote)).split(r.safeXmlCharactersEntities.realDoubleQuote).join(r.safeXmlCharacters.realDoubleQuote),"_wrs_blackboard"in window&&window._wrs_blackboard&&(e=(e=(e=e.split(r.safeBadBlackboardCharacters.ltElement).join(r.safeGoodBlackboardCharacters.ltElement)).split(r.safeBadBlackboardCharacters.gtElement).join(r.safeGoodBlackboardCharacters.gtElement)).split(r.safeBadBlackboardCharacters.ampElement).join(r.safeGoodBlackboardCharacters.ampElement)),e=(e=(e=(e=(e=e.split(r.safeXmlCharacters.tagOpener).join(r.xmlCharacters.tagOpener)).split(r.safeXmlCharacters.tagCloser).join(r.xmlCharacters.tagCloser)).split(r.safeXmlCharacters.doubleQuote).join(r.xmlCharacters.doubleQuote)).split(r.safeXmlCharacters.ampersand).join(r.xmlCharacters.ampersand)).split(r.safeXmlCharacters.quote).join(r.xmlCharacters.quote);for(var t="",i=null,n=0;n128)t+="&#"+e.codePointAt(i)+";",e.codePointAt(i)>65535&&i++;else if("&"==n){var r=e.indexOf(";",i+1);if(r>=0){var s=document.createElement("span");s.innerHTML=e.substring(i,r+1),t+="&#"+v.fixedCharCodeAt(s.textContent||s.innerText,0)+";",i=r}else t+=n}else t+=n}return t}},{key:"addCustomEditorClassAttribute",value:function(e,t){var i="",n=e.indexOf("");if(-1==e.indexOf("class"))return i=e.substr(n,r)+' class="wrs_'+t+'">',i+=e.substr(r+1,e.length)}return e}},{key:"removeCustomEditorClassAttribute",value:function(e,t){return-1===e.indexOf("class")||-1===e.indexOf("wrs_"+t)?e:-1!==e.indexOf('class="wrs_'+t+'"')?e.replace('class="wrs_'+t+'"',""):e.replace("wrs_"+t,"")}},{key:"addAnnotation",value:function(t,i,n){var r="";if(-1!==t.indexOf("");r=t.substring(0,s)+'').concat(i,"")+t.substring(s)}else if(e.isEmpty(t)){var o=t.indexOf("/>"),a=t.indexOf(">"),l=a===o?o:a;r=t.substring(0,l)+'>').concat(i,"")}else{var c=t.indexOf(">")+1,u=t.lastIndexOf(""),h=t.substring(c,u);r=t.substring(0,c)+"".concat(h,'').concat(i,"")}return r}},{key:"removeAnnotation",value:function(t,i){var n=t,r=''),s=t.indexOf(r);if(-1!==s){for(var o=!1,a=t.indexOf("",s)+"".length;n=t.substring(0,s)+t.substring(l)}else n=e.removeSemantics(t)}return n}},{key:"removeSemantics",value:function(e){var t=e,i=e.indexOf("");if(-1!=i){var n=e.indexOf("".length);-1!=n&&(t=e.substring(0,i)+e.substring(i+"".length,n)+"")}return t}},{key:"removeSemanticsOcurrences",value:function(e){for(var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:r.xmlCharacters,i=t.tagOpener+"math",n=t.tagOpener+"/math"+t.tagCloser,s="/"+t.tagCloser,o=t.tagCloser,a=t.tagOpener+"semantics"+t.tagCloser,l=t.tagOpener+"annotation encoding=",c="",u=e.indexOf(i),h=0;-1!==u;){c+=e.substring(h,u);var d=e.indexOf(n,u),f=e.indexOf(s,u),m=e.indexOf(o,u);-1!==d?h=d:f===m-1&&(h=f);var g=e.indexOf(a,u);if(-1!==g){var p=e.substring(u,g),v=e.indexOf(l,u);if(-1!==v)c+=p+e.substring(g+a.length,v)+n,u=e.indexOf(i,u+i.length),h+=n.length;else h=u,u=e.indexOf(i,u+i.length)}else h=u,u=e.indexOf(i,u+i.length)}return c+=e.substring(h,e.length)}},{key:"containClass",value:function(e,t){var i=e.indexOf("class");if(-1==i)return!1;var n=e.indexOf(">",i);return-1!=e.substring(i,n).indexOf(t)}},{key:"isEmpty",value:function(e){var t=e.indexOf(">"),i=e.indexOf("/>"),n=!1;if(-1!==i&&i===t-1&&(n=!0),!n){var r=new RegExp("").exec(e);r&&(n=t+1===r.index)}return n}}]),e}();function a(e,t){for(var i=0;i=0;--n)if(i[n]==t)return!0;return!1}},{key:"removeClass",value:function(e,t){for(var i="",n=e.className.split(" "),r=0;r").join("").split("").join("")).split("").join("
").split("").join("
");var n=e.createElement("div",{},i);return n.innerHTML=t,function t(n){if(n.getAttribute&&"WirisParam"==n.getAttribute("wirisObject")){for(var r={},s=0;s0){i+=">";for(n=0;n"}else"DIV"==t.nodeName||"SCRIPT"==t.nodeName?i+=">":i+="/>";return i}return 3==t.nodeType?e.htmlEntities(t.nodeValue):""}}},{key:"concatenateUrl",value:function(e,t){var i="";return e.indexOf("/")!=e.length&&0!=t.indexOf("/")&&(i="/"),(e+i+t).replace(/([^:]\/)\/+/g,"$1")}},{key:"htmlEntities",value:function(e){return e.split("&").join("&").split("<").join("<").split(">").join(">").split('"').join(""")}},{key:"htmlEntitiesDecode",value:function(e){return e.split(""").join('"').split(">").join(">").split("<").join("<").split("&").join("&")}},{key:"createHttpRequest",value:function(){if("file://"==window.location.toString().substr(0,window.location.toString().lastIndexOf("/")+1).substr(0,7))throw Core.getStringManager().getString("exception_cross_site");if("undefined"!=typeof XMLHttpRequest)return new XMLHttpRequest;try{return new ActiveXObject("Msxml2.XMLHTTP")}catch(e){try{return new ActiveXObject("Microsoft.XMLHTTP")}catch(e){}}return!1}},{key:"httpBuildQuery",value:function(t){var i="";for(var n in t)null!=t[n]&&(i+=e.urlEncode(n)+"="+e.urlEncode(t[n])+"&");return"&"==i.substring(i.length-1)&&(i=i.substring(0,i.length-1)),i}},{key:"propertiesToString",value:function(t){var i=[];for(var n in t)t.hasOwnProperty(n)&&i.push(n);for(var r=i.length,s=0;s0&&(i[s]=l,i[o]=a)}var c="";for(s=0;ss?s:r;for(n=0;n0){var i=e.substring(t+1).split("&"),n=new Object;for(t=0;t1&&(n[r[0]]=decodeURIComponent(r[1].replace(/\+/g," ")))}return n}return new Object}},{key:"urlEncode",value:function(e){return encodeURIComponent(e)}},{key:"getWIRISImageOutput",value:function(t,i,n){var s=e.createObject(t);if(s){if(s.className==l.get("imageClassName")||s.getAttribute(l.get("imageMathmlAttribute"))){if(!i)return t;var a=s.getAttribute(l.get("imageMathmlAttribute"));return l.get("saveHandTraces")||(a=o.removeSemanticsOcurrences(a,r.safeXmlCharacters)),null==a&&(a=s.getAttribute("alt")),n||(a=o.safeXmlDecode(a)),a}if(s.className==l.get("CASClassName")){var c=s.getAttribute(l.get("CASMathmlAttribute"));c=o.safeXmlDecode(c);var u=e.createObject(c);u.setAttribute("src",s.src);var h=e.createObjectCode(u);return n&&(h=o.safeXmlEncode(h)),h}}return t}},{key:"getNodeLength",value:function(e){function t(t){return e.apply(this,arguments)}return t.toString=function(){return e.toString()},t}(function(e){if(3==e.nodeType)return e.nodeValue.length;if(1==e.nodeType){var t={IMG:1,BR:1}[e.nodeName.toUpperCase()];void 0===t&&(t=0);for(var i=0;i0)return 0==c.text.length?e.getSelectedItem(t,i,!0):null;r.document.execCommand("InsertImage",!1,"#");var s,o=c.parentElement();return"IMG"!=o.nodeName.toUpperCase()&&(c.pasteHTML(''),o=r.document.getElementById("wrs_openEditorWindow_temporalObject")),o.nextSibling&&3==o.nextSibling.nodeType?(a=o.nextSibling,s=0):o.previousSibling&&3==o.previousSibling.nodeType?s=(a=o.previousSibling).nodeValue.length:(a=r.document.createTextNode(""),o.parentNode.insertBefore(a,o),s=0),o.parentNode.removeChild(o),{node:a,caretPosition:s}}return c.length>1?null:{node:c.item(0)}}if(r.getSelection){var a,l=r.getSelection();try{var c=l.getRangeAt(0)}catch(e){c=r.document.createRange()}if(3==(a=c.startContainer).nodeType)return{node:a,caretPosition:c.startOffset};if(a!=c.endContainer)return null;if(1==a.nodeType){var u=c.startOffset;if(a.childNodes[u])return{node:a.childNodes[u]}}}return null}},{key:"getSelectedItemOnTextarea",value:function(e){var t=document.createTextNode(e.value),i=g.getLatexFromTextNode(t,e.selectionStart);return null===i?null:{node:t,caretPosition:e.selectionStart,startPosition:i.startPosition,endPosition:i.endPosition}}},{key:"getElementsByNameFromString",value:function(e,t,i){var n=[];e=e.toLowerCase();t=t.toLowerCase();for(var r=e.indexOf("<"+t+" ");-1!=r;){var s;s=i?">":"";var o=e.indexOf(s,r);-1!=o?(o+=s.length,n.push({start:r,end:o})):o=r+1,r=e.indexOf("<"+t+" ",o)}return n}},{key:"decode64",value:function(e){var t="+".charCodeAt(0),i="/".charCodeAt(0),n="0".charCodeAt(0),r="a".charCodeAt(0),s="A".charCodeAt(0),o="-".charCodeAt(0),a="_".charCodeAt(0),l=e.charCodeAt(0);return l===t||l===o?62:l===i||l===a?63:l0)throw new Error("Invalid string. Length must be a multiple of 4");var r=new Array;if(i)o=i;else var s="="===t.charAt(t.length-2)?2:"="===t.charAt(t.length-1)?1:0,o=s>0?t.length-4:t.length;for(var a=0;a>16&255),r.push(n>>8&255),r.push(255&n);return s&&(2===s?(n=e.decode64(t.charAt(a))<<2|e.decode64(t.charAt(a+1))>>4,r.push(255&n)):1===s&&(n=e.decode64(t.charAt(a))<<10|e.decode64(t.charAt(a+1))<<4|e.decode64(t.charAt(a+2))>>2,r.push(n>>8&255),r.push(255&n))),r}},{key:"readInt32",value:function(e){if(e.length<4)return!1;var t=e.splice(0,4);return t[0]<<24|t[1]<<16|t[2]<<8|t[3]<<0}},{key:"readByte",value:function(e){return e.shift()<<0}},{key:"readBytes",value:function(e,t,i){return e.splice(t,i)}},{key:"updateTextArea",value:function(e,t){if(e&&t)if(e.focus(),null!=e.selectionStart){var i=e.selectionEnd;e.value=e.value.substring(0,e.selectionStart)+t+e.value.substring(e.selectionEnd,e.value.length),e.selectionEnd=i+t.length}else{document.selection.createRange().text=t}}},{key:"updateExistingTextOnTextarea",value:function(e,t,i,n){e.focus(),e.value=e.value.substring(0,i)+t+e.value.substring(n,e.value.length),e.selectionEnd=i+t.length}},{key:"addArgument",value:function(e,t,i){return e+(e.indexOf("?")>0?"&":"?")+t+"="+i}}]),e}();function b(e,t){for(var i=0;i-1,this.deviceProperties.isIOS=this.ua.indexOf("ipad")>-1||this.ua.indexOf("iphone")>-1,this.toolbar=null,this.modalDialogInstance=null,this.listeners=new y,this.mathML=null,this.isNewElement=!0,this.integrationModel=null,this.isEditorLoaded=!1}return function(e,t,i){t&&E(e.prototype,t),i&&E(e,i)}(e,[{key:"addListener",value:function(e){this.listeners.add(e)}},{key:"setIntegrationModel",value:function(e){this.integrationModel=e}},{key:"setModalDialogInstance",value:function(e){this.modalDialogInstance=e}},{key:"insert",value:function(){this.updateTitle(this.modalDialogInstance),this.insertEditor(this.modalDialogInstance)}},{key:"insertEditor",value:function(){if("com"in window&&"wiris"in window.com&&"jsEditor"in window.com.wiris){if(this.editor=com.wiris.jsEditor.JsEditor.newInstance(this.editorAttributes),this.editor.insertInto(this.modalDialogInstance.contentContainer),this.editor.focus(),this.modalDialogInstance.rtl&&this.editor.action("rtl"),this.editor.getEditorModel().isRTL()&&(this.editor.element.style.direction="rtl"),this.editor.getEditorModel().addEditorListener(this.editorListener),this.modalDialogInstance.deviceProperties.isIOS){setTimeout(function(){this.modalDialogInstance.hideKeyboard()},400);var t=document.getElementsByClassName("wrs_formulaDisplay")[0];v.addEvent(t,"focus",this.modalDialogInstance.handleOpenedIosSoftkeyboard),v.addEvent(t,"blur",this.modalDialogInstance.handleClosedIosSoftkeyboard)}this.listeners.fire("onLoad",{}),this.isEditorLoaded=!0}else setTimeout(e.prototype.insertEditor.bind(this,this.modalDialogInstance),100)}},{key:"init",value:function(){for(var e=window.location.search.substring(1).split("&"),t=0;t=0&&(version=e[t].substring(2))}var i=document.createElement("script");i.type="text/javascript";var n=l.get("editorUrl"),r=document.createElement("a");r.href=n,0==window.location.href.indexOf("https://")&&"http:"==r.protocol&&(r.protocol="https:"),n="80"==r.port||"443"==r.port?r.protocol+"//"+r.hostname+"/"+r.pathname:r.protocol+"//"+r.hostname+":"+r.port+"/"+r.pathname;var s={};"editor"in this.environment?s.editor=this.environment.editor:s.editor="unknown","mode"in this.environment?s.mode=this.environment.mode:s.mode=l.get("saveMode"),"version"in this.environment?s.version=this.environment.version:s.version=l.get("version"),i.src=n+"?lang="+this.language+"&stats-editor="+s.editor+"&stats-mode="+s.mode+"&stats-version="+s.version,document.getElementsByTagName("head")[0].appendChild(i)}},{key:"setInitialContent",value:function(){this.isNewElement||this.setMathML(this.mathML)}},{key:"setMathML",value:function(e,t){void 0===t&&(t=!1),this.editor.setMathMLWithCallback(e,function(){this.editorListener.setWaitingForChanges(!0)}.bind(this)),setTimeout(function(){this.editorListener.setIsContentChanged(!1)}.bind(this),500),t||this.onFocus()}},{key:"onFocus",value:function(){void 0!==this.editor&&null!=this.editor&&this.editor.focus()}},{key:"submitAction",value:function(){if(this.editor.isFormulaEmpty())this.integrationModel.updateFormula(null);else{var e=this.editor.getMathMLWithSemantics();if(null!=this.customEditors.getActiveEditor())e=o.addCustomEditorClassAttribute(e,this.customEditors.getActiveEditor().toolbar);else for(var t in this.customEditors.editors)e=o.removeCustomEditorClassAttribute(e,t);var i=o.mathMLEntities(e);this.integrationModel.updateFormula(i)}this.customEditors.disable(),this.integrationModel.notifyWindowClosed(),this.setEmptyMathML(),this.customEditors.disable()}},{key:"setEmptyMathML",value:function(){this.deviceProperties.isAndroid||this.deviceProperties.isIOS?this.editor.getEditorModel().isRTL()?this.setMathML('[]',!0):this.setMathML('[]',!0):this.editor.getEditorModel().isRTL()?this.setMathML('',!0):this.setMathML("",!0)}},{key:"onOpen",value:function(){this.isNewElement?this.setEmptyMathML():this.setMathML(this.mathML),this.updateToolbar(),this.onFocus()}},{key:"updateToolbar",value:function(){var e;if(this.updateTitle(this.modalDialogInstance),e=this.customEditors.getActiveEditor()){var t=e.toolbar?e.toolbar:_wrs_int_wirisProperties.toolbar;null!=this.toolbar&&this.toolbar==t||this.setToolbar(t)}else{t=this.getToolbar();null!=this.toolbar&&this.toolbar==t||(this.setToolbar(t),this.customEditors.disable())}}},{key:"updateTitle",value:function(){var e;(e=this.customEditors.getActiveEditor())?this.modalDialogInstance.setTitle(e.title):this.modalDialogInstance.setTitle("MathType")}},{key:"getToolbar",value:function(){var e;return"general"==(e="toolbar"in this.editorAttributes?this.editorAttributes.toolbar:"general")&&(e="undefined"==typeof _wrs_int_wirisProperties||void 0===_wrs_int_wirisProperties.toolbar?"general":_wrs_int_wirisProperties.toolbar),e}},{key:"setToolbar",value:function(e){this.toolbar=e,this.editor.setParams({toolbar:this.toolbar})}},{key:"hasChanges",value:function(){return!this.editor.isFormulaEmpty()&&this.editorListener.getIsContentChanged()}}]),e}();function O(e,t){for(var i=0;i-1,r=i.indexOf("ipad")>-1||i.indexOf("iphone")>-1;this.iosSoftkeyboardOpened=!1,this.iosMeasureUnit=-1==i.indexOf("crios")?"%":"vh",this.iosDivHeight="100"+this.iosMeasureUnit;var s=window.outerWidth,o=window.outerHeight,a=s>o,l=so||l&&this.attributes.width>s);this.instanceId=document.getElementsByClassName("wrs_modal_dialogContainer").length,this.deviceProperties={orientation:a?"landscape":"portait",isAndroid:!!n,isIOS:!!r,isMobile:c,isDesktop:!c&&!r&&!n},this.properties={created:!1,state:"",previousState:"",position:{bottom:0,right:10},size:{height:338,width:580}},this.websiteBeforeLockParameters=null;var u={class:"wrs_modal_overlay"};u.id=this.getElementId(u.class),this.overlay=v.createElement("div",u),(u={}).class="wrs_modal_title_bar",u.id=this.getElementId(u.class),this.titleBar=v.createElement("div",u),(u={}).class="wrs_modal_title",u.id=this.getElementId(u.class),this.title=v.createElement("div",u),this.title.innerHTML="",(u={}).class="wrs_modal_close_button",u.id=this.getElementId(u.class),u.title=$.getStringManager().getString("close"),this.closeDiv=v.createElement("a",u),this.closeDiv.setAttribute("role","button"),(u={}).class="wrs_modal_stack_button",u.id=this.getElementId(u.class),u.title="Exit full-screen",this.stackDiv=v.createElement("a",u),this.stackDiv.setAttribute("role","button"),(u={}).class="wrs_modal_maximize_button",u.id=this.getElementId(u.class),u.title=$.getStringManager().getString("fullscreen"),this.maximizeDiv=v.createElement("a",u),this.maximizeDiv.setAttribute("role","button"),(u={}).class="wrs_modal_minimize_button",u.id=this.getElementId(u.class),u.title=$.getStringManager().getString("minimise"),this.minimizeDiv=v.createElement("a",u),this.minimizeDiv.setAttribute("role","button"),(u={}).class="wrs_modal_dialogContainer",u.id=this.getElementId(u.class),this.container=v.createElement("div",u),(u={}).class="wrs_modal_wrapper",u.id=this.getElementId(u.class),this.wrapper=v.createElement("div",u),(u={}).class="wrs_content_container",u.id=this.getElementId(u.class),this.contentContainer=v.createElement("div",u),(u={}).class="wrs_modal_controls",u.id=this.getElementId(u.class),this.controls=v.createElement("div",u),(u={}).class="wrs_modal_buttons_container",u.id=this.getElementId(u.class),this.buttonContainer=v.createElement("div",u),this.submitButton=this.createSubmitButton({id:this.getElementId("wrs_modal_button_accept"),class:"wrs_modal_button_accept",innerHTML:$.getStringManager().getString("accept")},this.submitAction.bind(this)),this.cancelButton=this.createSubmitButton({id:this.getElementId("wrs_modal_button_cancel"),class:"wrs_modal_button_cancel",innerHTML:$.getStringManager().getString("cancel")},this.cancelAction.bind(this)),this.contentManager=null;var h={cancelString:$.getStringManager().getString("cancel"),submitString:$.getStringManager().getString("close"),message:$.getStringManager().getString("close_modal_warning")},d={closeCallback:function(){this.close()}.bind(this),cancelCallback:function(){this.focus()}.bind(this)},f={overlayElement:this.container,callbacks:d,strings:h};this.popup=new M(f),this.rtl=!1,"rtl"in this.attributes&&(this.rtl=this.attributes.rtl),this.handleOpenedIosSoftkeyboard=this.handleOpenedIosSoftkeyboard.bind(this),this.handleClosedIosSoftkeyboard=this.handleClosedIosSoftkeyboard.bind(this)}return function(e,t,i){t&&S(e.prototype,t),i&&S(e,i)}(e,[{key:"setContentManager",value:function(e){this.contentManager=e}},{key:"getContentManager",value:function(){return this.contentManager}},{key:"submitAction",value:function(){void 0!==this.contentManager.submitAction&&this.contentManager.submitAction(),this.close()}},{key:"cancelAction",value:function(){void 0===this.contentManager.hasChanges?this.close():this.contentManager.hasChanges()?this.showPopUpMessage():this.close()}},{key:"createSubmitButton",value:function(e,t){function i(e,t){this.element=document.createElement("button"),this.element.id=e.id,this.element.className=e.class,this.element.innerHTML=e.innerHTML,v.addEvent(this.element,"click",t)}return i.prototype.getElement=function(){return this.element},new i(e,t).getElement()}},{key:"create",value:function(){this.titleBar.appendChild(this.closeDiv),this.titleBar.appendChild(this.stackDiv),this.titleBar.appendChild(this.maximizeDiv),this.titleBar.appendChild(this.minimizeDiv),this.titleBar.appendChild(this.title),this.deviceProperties.isDesktop&&this.container.appendChild(this.titleBar),this.wrapper.appendChild(this.contentContainer),this.wrapper.appendChild(this.controls),this.controls.appendChild(this.buttonContainer),this.buttonContainer.appendChild(this.submitButton),this.buttonContainer.appendChild(this.cancelButton),this.container.appendChild(this.wrapper),this.recalculateScrollBar(),document.body.appendChild(this.container),document.body.appendChild(this.overlay),this.deviceProperties.isDesktop?(this.createModalWindowDesktop(),this.createResizeButtons(),this.addListeners(),l.get("modalWindowFullScreen")&&this.maximize()):this.deviceProperties.isAndroid?this.createModalWindowAndroid():this.deviceProperties.isIOS&&!this.deviceProperties.isMobile&&this.createModalWindowIos(),null!=this.contentManager&&this.contentManager.insert(this),this.properties.open=!0,this.properties.created=!0,this.isRTL()&&(this.container.style.right=window.innerWidth-this.scrollbarWidth-this.container.offsetWidth+"px",this.container.className+=" wrs_modal_rtl")}},{key:"createResizeButtons",value:function(){this.resizerBR=document.createElement("div"),this.resizerBR.className="wrs_bottom_right_resizer",this.resizerBR.innerHTML="◢",this.resizerTL=document.createElement("div"),this.resizerTL.className="wrs_bottom_left_resizer",this.container.appendChild(this.resizerBR),this.titleBar.appendChild(this.resizerTL),v.addEvent(this.resizerBR,"mousedown",this.activateResizeStateBR.bind(this)),v.addEvent(this.resizerTL,"mousedown",this.activateResizeStateTL.bind(this))}},{key:"activateResizeStateBR",value:function(e){this.initializeResizeProperties(e,!1)}},{key:"activateResizeStateTL",value:function(e){this.initializeResizeProperties(e,!0)}},{key:"initializeResizeProperties",value:function(e,t){v.addClass(document.body,"wrs_noselect"),v.addClass(this.overlay,"wrs_overlay_active"),this.resizeDataObject={x:this.eventClient(e).X,y:this.eventClient(e).Y},this.initialWidth=parseInt(this.container.style.width),this.initialHeight=parseInt(this.container.style.height),t?this.leftScale=!0:(this.initialRight=parseInt(this.container.style.right),this.initialBottom=parseInt(this.container.style.bottom)),this.initialRight||(this.initialRight=0),this.initialBottom||(this.initialBottom=0),document.body.style["user-select"]="none"}},{key:"open",value:function(){if(this.removeClass("wrs_closed"),(this.deviceProperties.isIOS||this.deviceProperties.isAndroid||this.deviceProperties.isMobile)&&(this.restoreWebsiteScale(),this.lockWebsiteScroll(),setTimeout(function(){this.hideKeyboard()}.bind(this),400)),this.properties.created?(this.properties.open||(this.properties.open=!0,this.deviceProperties.isAndroid||this.deviceProperties.isIOS||this.restoreState()),this.deviceProperties.isDesktop&&l.get("modalWindowFullScreen")&&this.maximize(),this.deviceProperties.isIOS&&(this.iosSoftkeyboardOpened=!1,this.setContainerHeight("100"+this.iosMeasureUnit))):this.create(),!1===this.contentManager.isEditorLoaded){var e=y.newListener("onLoad",function(){this.contentManager.onOpen(this)}.bind(this));this.contentManager.addListener(e)}else this.contentManager.onOpen(this)}},{key:"close",value:function(){this.removeClass("wrs_maximized"),this.removeClass("wrs_minimized"),this.removeClass("wrs_stack"),this.addClass("wrs_closed"),this.saveModalProperties(),this.unlockWebsiteScroll(),this.properties.open=!1}},{key:"restoreWebsiteScale",value:function(){var e=document.querySelector("meta[name=viewport]"),t=["initial-scale=","minimum-scale=","maximum-scale="],i=["1.0","1.0","1.0"],n=function(e,t){var n=e.getAttribute("content");if(n){for(var r=n.split(","),s="",o=[],a=0;a=0||navigator.userAgent.search("Trident/")>=0||navigator.userAgent.search("Edge/")>=0}},{key:"isRTL",value:function(){return"ar"==this.attributes.language||"he"==this.attributes.language||this.rtl}},{key:"addClass",value:function(e){v.addClass(this.overlay,e),v.addClass(this.titleBar,e),v.addClass(this.overlay,e),v.addClass(this.container,e),v.addClass(this.contentContainer,e),v.addClass(this.stackDiv,e),v.addClass(this.minimizeDiv,e),v.addClass(this.maximizeDiv,e),v.addClass(this.wrapper,e)}},{key:"removeClass",value:function(e){v.removeClass(this.overlay,e),v.removeClass(this.titleBar,e),v.removeClass(this.overlay,e),v.removeClass(this.container,e),v.removeClass(this.contentContainer,e),v.removeClass(this.stackDiv,e),v.removeClass(this.minimizeDiv,e),v.removeClass(this.maximizeDiv,e),v.removeClass(this.wrapper,e)}},{key:"createModalWindowDesktop",value:function(){this.addClass("wrs_modal_desktop"),this.stack()}},{key:"createModalWindowAndroid",value:function(){this.addClass("wrs_modal_android"),window.addEventListener("resize",this.orientationChangeAndroidSoftkeyboard.bind(this))}},{key:"createModalWindowIos",value:function(){this.addClass("wrs_modal_ios"),window.addEventListener("resize",this.orientationChangeIosSoftkeyboard.bind(this))}},{key:"restoreState",value:function(){"maximized"==this.properties.state?this.maximize():"minimized"==this.properties.state?(this.properties.state=this.properties.previousState,this.properties.previousState="",this.minimize()):this.stack()}},{key:"stack",value:function(){this.properties.previousState=this.properties.state,this.properties.state="stack",this.removeClass("wrs_maximized"),this.minimizeDiv.title="Minimise",this.removeClass("wrs_minimized"),this.addClass("wrs_stack"),this.restoreModalProperties(),void 0!==this.resizerBR&&void 0!==this.resizerTL&&this.setResizeButtonsVisibility(),this.recalculateScrollBar(),this.recalculatePosition(),this.recalculateScale(),this.focus()}},{key:"minimize",value:function(){this.saveModalProperties(),"minimized"==this.properties.state&&"stack"==this.properties.previousState?this.stack():"minimized"==this.properties.state&&"maximized"==this.properties.previousState?this.maximize():(this.container.style.height="30px",this.container.style.width="250px",this.container.style.bottom="0px",this.container.style.right="10px",this.removeListeners(),this.properties.previousState=this.properties.state,this.properties.state="minimized",this.setResizeButtonsVisibility(),this.minimizeDiv.title="Maximise",v.containsClass(this.overlay,"wrs_stack")?this.removeClass("wrs_stack"):this.removeClass("wrs_maximized"),this.addClass("wrs_minimized"))}},{key:"maximize",value:function(){this.saveModalProperties(),"maximized"!=this.properties.state&&(this.properties.previousState=this.properties.state,this.properties.state="maximized"),this.setResizeButtonsVisibility(),v.containsClass(this.overlay,"wrs_minimized")?(this.minimizeDiv.title="Minimise",this.removeClass("wrs_minimized")):v.containsClass(this.overlay,"wrs_stack")&&(this.container.style.left=null,this.container.style.top=null,this.removeClass("wrs_stack")),this.addClass("wrs_maximized"),this.setSize(parseInt(.8*window.innerHeight),parseInt(.8*window.innerWidth));this.container.clientHeight>700&&(this.container.style.height="700px"),this.container.clientWidth>1200&&(this.container.style.width="1200px"),this.setPosition(window.innerHeight/2-this.container.offsetHeight/2,window.innerWidth/2-this.container.offsetWidth/2),this.recalculateScale(),this.recalculatePosition(),this.recalculateSize(),this.focus()}},{key:"setSize",value:function(e,t){this.container.style.height=e+"px",this.container.style.width=t+"px",this.recalculateSize()}},{key:"setPosition",value:function(e,t){this.container.style.bottom=e+"px",this.container.style.right=t+"px"}},{key:"saveModalProperties",value:function(){"stack"==this.properties.state&&(this.properties.position.bottom=parseInt(this.container.style.bottom),this.properties.position.right=parseInt(this.container.style.right),this.properties.size.width=parseInt(this.container.style.width),this.properties.size.height=parseInt(this.container.style.height))}},{key:"restoreModalProperties",value:function(){"stack"==this.properties.state&&(this.setPosition(this.properties.position.bottom,this.properties.position.right),this.setSize(this.properties.size.height,this.properties.size.width))}},{key:"recalculateSize",value:function(){this.wrapper.style.width=this.container.clientWidth-12+"px",this.wrapper.style.height=this.container.clientHeight-38+"px",this.contentContainer.style.height=parseInt(this.wrapper.offsetHeight-50)+"px"}},{key:"setResizeButtonsVisibility",value:function(){"stack"==this.properties.state?(this.resizerTL.style.visibility="visible",this.resizerBR.style.visibility="visible"):(this.resizerTL.style.visibility="hidden",this.resizerBR.style.visibility="hidden")}},{key:"addListeners",value:function(){this.maximizeDiv.addEventListener("click",this.maximize.bind(this),!0),this.stackDiv.addEventListener("click",this.stack.bind(this),!0),this.minimizeDiv.addEventListener("click",this.minimize.bind(this),!0),this.closeDiv.addEventListener("click",this.cancelAction.bind(this)),this.overlay.addEventListener("click",this.cancelAction.bind(this)),v.addEvent(window,"mousedown",this.startDrag.bind(this)),v.addEvent(window,"mouseup",this.stopDrag.bind(this)),v.addEvent(window,"mousemove",this.drag.bind(this)),v.addEvent(window,"resize",this.onWindowResize.bind(this)),v.addEvent(window,"keydown",this.onKeyDown.bind(this))}},{key:"removeListeners",value:function(){v.removeEvent(window,"mousedown",this.startDrag),v.removeEvent(window,"mouseup",this.stopDrag),v.removeEvent(window,"mousemove",this.drag),v.removeEvent(window,"resize",this.onWindowResize),v.removeEvent(window,"keydown",this.onKeyDown)}},{key:"eventClient",value:function(e){if(void 0===e.clientX&&e.changedTouches){var t={X:e.changedTouches[0].clientX,Y:e.changedTouches[0].clientY};return t}return t={X:e.clientX,Y:e.clientY}}},{key:"startDrag",value:function(e){"minimized"!=this.properties.state&&e.target===this.title&&(void 0!==this.dragDataObject&&null!==this.dragDataObject||(e=e||event,this.dragDataObject={x:this.eventClient(e).X,y:this.eventClient(e).Y},this.lastDrag={x:"0px",y:"0px"},""==this.container.style.right&&(this.container.style.right="0px"),""==this.container.style.bottom&&(this.container.style.bottom="0px"),this.isIE11(),v.addClass(document.body,"wrs_noselect"),v.addClass(this.overlay,"wrs_overlay_active"),this.limitWindow=this.getLimitWindow()))}},{key:"drag",value:function(e){if(this.dragDataObject){e.preventDefault(),e=e||event;var t=Math.min(this.eventClient(e).Y,this.limitWindow.minPointer.y);t=Math.max(this.limitWindow.maxPointer.y,t);var i=Math.min(this.eventClient(e).X,this.limitWindow.minPointer.x),n=(i=Math.max(this.limitWindow.maxPointer.x,i))-this.dragDataObject.x+"px",r=t-this.dragDataObject.y+"px";this.lastDrag={x:n,y:r},this.container.style.transform="translate3d("+n+","+r+",0)"}if(this.resizeDataObject){var s;i=Math.min(this.eventClient(e).X,window.innerWidth-this.scrollbarWidth-7),t=Math.min(this.eventClient(e).Y,window.innerHeight-7);i<0&&(i=0),t<0&&(t=0),s=this.leftScale?-1:1,this.container.style.width=this.initialWidth+s*(i-this.resizeDataObject.x)+"px",this.container.style.height=this.initialHeight+s*(t-this.resizeDataObject.y)+"px",this.leftScale||(this.resizeDataObject.x-i-this.initialWidth<-580?this.container.style.right=this.initialRight-(i-this.resizeDataObject.x)+"px":(this.container.style.right=this.initialRight+this.initialWidth-580+"px",this.container.style.width="580px"),this.resizeDataObject.y-t580?(this.container.style.width=Math.min(parseInt(this.container.style.width),window.innerWidth-this.scrollbarWidth)+"px",e=!0):(this.container.style.width="580px",e=!0),parseInt(this.container.style.height)>338?(this.container.style.height=Math.min(parseInt(this.container.style.height),window.innerHeight)+"px",e=!0):(this.container.style.height="338px",e=!0),e&&this.recalculateSize()}},{key:"recalculateScrollBar",value:function(){this.hasScrollBar=window.innerWidth>document.documentElement.clientWidth,this.hasScrollBar?this.scrollbarWidth=this.getScrollBarWidth():this.scrollbarWidth=0}},{key:"hideKeyboard",value:function(){document.activeElement.blur()}},{key:"focus",value:function(){null!=this.contentManager&&void 0!==this.contentManager.onFocus&&this.contentManager.onFocus()}},{key:"portraitMode",value:function(){return window.innerHeight>window.innerWidth}},{key:"handleOpenedIosSoftkeyboard",value:function(){this.iosSoftkeyboardOpened||null==this.iosDivHeight||this.iosDivHeight!="100"+this.iosMeasureUnit||(this.portraitMode()?this.setContainerHeight("63"+this.iosMeasureUnit):this.setContainerHeight("40"+this.iosMeasureUnit)),this.iosSoftkeyboardOpened=!0}},{key:"handleClosedIosSoftkeyboard",value:function(){this.iosSoftkeyboardOpened=!1,this.setContainerHeight("100"+this.iosMeasureUnit)}},{key:"orientationChangeIosSoftkeyboard",value:function(){this.iosSoftkeyboardOpened?this.portraitMode()?this.setContainerHeight("63"+this.iosMeasureUnit):this.setContainerHeight("40"+this.iosMeasureUnit):this.setContainerHeight("100"+this.iosMeasureUnit)}},{key:"orientationChangeAndroidSoftkeyboard",value:function(){this.setContainerHeight("100%")}},{key:"setContainerHeight",value:function(e){this.iosDivHeight=e,this.wrapper.style.height=e}},{key:"showPopUpMessage",value:function(){"minimized"==this.properties.state&&this.stack(),this.popup.show()}},{key:"setTitle",value:function(e){this.title.innerHTML=e}},{key:"getElementId",value:function(e){return e+"["+this.instanceId+"]"}}]),e}();function I(e){return(I="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function A(e,t){for(var i=0;i=4;){v.readInt32(e);var t=v.readInt32(e);if(1229472850==t){var i=v.readInt32(e),n=v.readInt32(e);v.readInt32(e),v.readByte(e)}else if(1650545477==t)var r=v.readInt32(e);else if(1883789683==t){var s=v.readInt32(e);s=Math.round(s/39.37),v.readInt32(e),v.readByte(e)}v.readInt32(e)}if(void 0!==i){var o=new Array;return o.cw=i,o.ch=n,o.dpi=s,r&&(o.cb=r),o}}}]),e}();function T(e,t){for(var i=0;i"),m=c.substring(0,f),p=m.split(" width=").join(' class="Wiriscas" width=');c=(c=c.split(m).join(p)).split("'").join('"')}}var b='';t=t.substring(0,n[a].start+s)+b+t.substring(n[a].end+s),s+=b.length-(n[a].end-n[a].start)}}return t}},{key:"initParseEditMode",value:function(e){if(-1!=l.get("parseModes").indexOf("latex"))for(var t=v.getElementsByNameFromString(e,"img",!0),i='encoding="LaTeX">',n=0,r=0;r",d),m=h.substring(d,f),g="$$"+v.htmlEntitiesDecode(m)+"$$";e=e.substring(0,t[r].start+n)+g+e.substring(t[r].end+n),n+=g.length-(t[r].end-t[r].start)}}}}return e}},{key:"endParse",value:function(t){var i=e.endParseEditMode(t);return e.endParseSaveMode(i)}},{key:"endParseEditMode",value:function(e){if(-1!=l.get("parseModes").indexOf("latex")){for(var t="",i=0,n=e.indexOf("$$");-1!=n;){if(t+=e.substring(i,n),-1!=(i=e.indexOf("$$",n+2))){var r=e.substring(n+2,i),s=v.htmlEntitiesDecode(r),a=g.getMathMLFromLatex(s,!0);l.get("saveHandTraces")||(a=o.removeAnnotation(a,"application/json")),t+=a,i+=2}else t+="$$",i=n+2;n=e.indexOf("$$",i)}e=t+=e.substring(i,e.length)}return e}},{key:"endParseSaveMode",value:function(t){return l.get("saveMode")&&("safeXml"==l.get("saveMode")?t=e.codeImgTransform(t,"img2mathml"):"xml"==l.get("saveMode")?t=e.codeImgTransform(t,"img2mathml"):"base64"==l.get("saveMode")&&"image"==l.get("editMode")&&(t=e.codeImgTransform(t,"img264"))),t}},{key:"createShowImageSrc",value:function(e,t){var i=[],n="mml,color,centerbaseline,zoom,dpi,fontSize,fontFamily,defaultStretchy,backgroundColor,format".split(",");for(var r in n){var s=n[r];void 0!==e[s]&&(i[s]=e[s])}var o={};for(var r in e)"mml"!=r&&(o[r]=e[r]);return o.formula=com.wiris.js.JsPluginTools.md5encode(v.propertiesToString(i)),o.lang=void 0===t?"en":t,o.version=l.get("version"),f.getService("showimage",v.httpBuildQuery(o),!0)}},{key:"codeImgTransform",value:function(t,i){for(var n="",r=0,s=/"==h&&(r=u+1);++u}if(r",u):c.length,o.isMathmlInAttribute(t,u)||-1!=d)s+=t.substring(u,h);else{var f=t.substring(u,h);f=i==r.safeXmlCharacters?o.safeXmlDecode(f):o.mathMLEntities(f),s+=v.createObjectCode(e.mathmlToImgObject(document,f,null,n))}u=t.indexOf(a,h)}return s+=t.substring(h,t.length)}}]),e}();if("undefined"!=typeof MutationObserver){var D=new MutationObserver(function(e){e.forEach(function(e){e.oldValue===l.get("imageClassName")&&"class"===e.attributeName&&-1==e.target.className.indexOf(l.get("imageClassName"))&&(e.target.className=l.get("imageClassName"))})});B.observer=Object.create(D),B.observer.Config={attributes:!0,attributeOldValue:!0},B.observer.observe=function(e){this.__proto__.observe(e,this.Config)}}function R(e,t){for(var i=0;i=0&&(t=e[i].src.substr(0,n-1))}return t}},{key:"setLanguage",value:function(e){this.language=e}},{key:"setCore",value:function(e){this.core=e,e.setIntegrationModel(this)}},{key:"getCore",value:function(){return this.core}},{key:"setTarget",value:function(e){this.target=e,this.isIframe="IFRAME"===this.target.tagName.toUpperCase()}},{key:"setEditorObject",value:function(e){this.editorObject=e}},{key:"openNewFormulaEditor",value:function(){this.core.editionProperties.isNewElement=!0,this.core.openModalDialog(this.target,this.isIframe)}},{key:"openExistingFormulaEditor",value:function(){this.core.editionProperties.isNewElement=!1,this.core.openModalDialog(this.target,this.isIframe)}},{key:"updateFormula",value:function(e){this.isIframe?this.core.updateFormula(this.target.contentWindow,this.target.contentWindow,e,null):this.core.updateFormula(this.target,window,e,null)}},{key:"getSelection",value:function(){return this.isIframe?(this.target.contentWindow.focus(),this.target.contentWindow.getSelection()):(this.target.focus(),window.getSelection())}},{key:"addEvents",value:function(){var e=this.isIframe?this.target.contentWindow.document:this.target;v.addElementEvents(e,function(e,t){this.doubleClickHandler(e,t)}.bind(this),function(e,t){this.mousedownHandler(e,t)}.bind(this),function(e,t){this.mouseupHandler(e,t)}.bind(this))}},{key:"doubleClickHandler",value:function(e){if("img"==e.nodeName.toLowerCase()){if(this.core.getCustomEditors().disable(),e.hasAttribute("data-custom-editor")){var t=e.getAttribute("data-custom-editor");this.core.getCustomEditors().enable(t)}v.containsClass(e,l.get("imageClassName"))&&(this.core.editionProperties.temporalImage=e,this.core.editionProperties.isNewElement=!0,this.openExistingFormulaEditor())}}},{key:"mouseupHandler",value:function(){this.temporalImageResizing&&setTimeout(function(){P.fixAfterResize(this.temporalImageResizing)}.bind(this),10)}},{key:"mousedownHandler",value:function(e){"img"==e.nodeName.toLowerCase()&&v.containsClass(e,l.get("imageClassName"))&&(this.temporalImageResizing=e)}},{key:"getLanguage",value:function(){return this.getBrowserLanguage()}},{key:"getBrowserLanguage",value:function(){return navigator.userLanguage?navigator.userLanguage.substring(0,2):navigator.language?navigator.language.substring(0,2):"en"}},{key:"callbackFunction",value:function(){var e=y.newListener("onTargetReady",function(){this.addEvents(this.target)}.bind(this));this.listeners.add(e)}},{key:"notifyWindowClosed",value:function(){}},{key:"getMathmlFromTextNode",value:function(e,t){}},{key:"fillNonLatexNode",value:function(e,t,i){}},{key:"getSelectedItem",value:function(e,t){}}]),e}();function J(e,t){for(var i=0;i=0?"EDGE":e.search("Chrome/")>=0?"CHROME":e.search("Trident/")>=0?"IE":e.search("Firefox/")>=0?"FIREFOX":e.search("Safari/")>=0?"SAFARI":void 0}(),this.listeners=new y}return function(e,t,i){t&&J(e.prototype,t),i&&J(e,i)}(e,[{key:"init",value:function(e){this.load(e)}},{key:"setIntegrationModel",value:function(e){this.integrationModel=e}},{key:"setEnvironment",value:function(e){"editor"in e&&(this.environment.editor=e.editor),"mode"in e&&(this.environment.mode=e.mode),"version"in e&&(this.environment.version=e.version)}},{key:"getModalDialog",value:function(){return this.modalDialog}},{key:"load",value:function(t){var i="undefined"!=typeof XMLHttpRequest?new XMLHttpRequest:new ActiveXObject("Microsoft.XMLHTTP");this.integrationPath=0==t.indexOf("/")||0==t.indexOf("http")?t:v.concatenateUrl(this.integrationModel.getPath(),t),i.open("GET",this.integrationPath,!1),i.onload=function(t){var n=this;if(4===i.readyState){var r=JSON.parse(i.responseText);Object.keys(r);if(l.addConfiguration(r),l.addConfiguration(H),this.loadServicePaths(),this.loadLangFile(),this.loadCSS(),null===e.stringManager){var s=y.newListener("onLoad",function(){n.listeners.fire("onLoad",{})});e.stringManager.addListener(s)}else this.listeners.fire("onLoad",{})}}.bind(this),i.send(null)}},{key:"loadServicePaths",value:function(){var e=this.integrationPath.replace("configurationjs","createimage"),t=this.integrationPath.replace("configurationjs","showimage"),i=(e=this.integrationPath.replace("configurationjs","createimage"),this.integrationPath.replace("configurationjs","getmathml")),n=this.integrationPath.replace("configurationjs","service");if(0==this.integrationPath.indexOf("/")){var r=this.getServerPath();t=r+t,e=r+e,i=r+i,n=r+n}f.setServicePath("showimage",t),f.setServicePath("createimage",e),f.setServicePath("service",n),f.setServicePath("getmathml",i)}},{key:"getServerPath",value:function(){var e=this.integrationModel.getPath(),t=e.indexOf("/",e.indexOf("/")+2);return e.substr(0,t)}},{key:"loadLangFile",value:function(){var t="ar,ca,cs,da,de,en,es,et,eu,fi,fr,gl,he,hr,hu,it,ja,ko,nl,no,pl,pt,pt_br,ru,sv,tr,zh,el".split(","),i=this.language;-1==t.indexOf(i)&&(i=i.substr(0,2)),-1==t.indexOf(i)&&(i="en");var n=document.createElement("script");n.type="text/javascript",n.src=this.integrationModel.getPath()+"/"+this.integrationModel.langFolderName+"/"+i+"/strings.js",n.onload=function(){e.getStringManager().loadStrings(wrs_strings)},document.getElementsByTagName("head")[0].appendChild(n)}},{key:"loadCSS",value:function(){var e=document.createElement("link");e.setAttribute("rel","stylesheet"),e.setAttribute("type","text/css"),e.setAttribute("href",v.concatenateUrl(this.integrationModel.getPath(),"/core/styles.css")),document.getElementsByTagName("head")[0].appendChild(e)}},{key:"addListener",value:function(e){this.listeners.add(e)}},{key:"updateFormula",value:function(t,i,n,r){var s=new F;for(var o in s.mathml=n,s.wirisProperties={},r)s.wirisProperties[o]=r[o];if(s.language=this.language,s.editMode=this.editMode,!this.listeners.fire("onBeforeFormulaInsertion",s)&&!e.globalListeners.fire("onBeforeFormulaInsertion",s)){n=s.mathml,r=s.wirisProperties;var a=new F;if(a.editMode=this.editMode,a.windowTarget=i,a.focusElement=t,n)if("latex"==this.editMode)a.latex=g.getLatexFromMathML(n),this.integrationModel.fillNonLatexNode&&!a.latex?this.integrationModel.fillNonLatexNode(a,i,n):a.node=i.document.createTextNode("$$"+a.latex+"$$"),this.insertElementOnSelection(a.node,t,i);else if("iframes"==this.editMode){var l=wrs_mathmlToIframeObject(i,n);this.insertElementOnSelection(l,t,i)}else a.node=B.mathmlToImgObject(i.document,n,r,this.language),this.insertElementOnSelection(a.node,t,i);else this.insertElementOnSelection(null,t,i);this.listeners.fire("onAfterFormulaInsertion",a)||e.globalListeners.fire("onAfterFormulaInsertion",a)}}},{key:"placeCaretAfterNode",value:function(e){this.integrationModel.getSelection();var t=e.ownerDocument;if(void 0!==t.getSelection&&e.parentElement){var i=t.createRange();i.setStartAfter(e),i.collapse(!0);var n=t.getSelection();n.removeAllRanges(),n.addRange(i),t.body.focus()}}},{key:"insertElementOnSelection",value:function(e,t,i){if(this.editionProperties.isNewElement)if(e)if("textarea"==t.type)v.updateTextArea(t,e.textContent);else if(document.selection&&0==document.getSelection){var n=i.document.selection.createRange();if(i.document.execCommand("InsertImage",!1,e.src),"parentElement"in n||(i.document.execCommand("delete",!1),n=i.document.selection.createRange(),i.document.execCommand("InsertImage",!1,e.src)),"parentElement"in n){var r=n.parentElement();"IMG"==r.nodeName.toUpperCase()?r.parentNode.replaceChild(e,r):n.pasteHTML(v.createObjectCode(e))}}else{var s,o=this.integrationModel.getSelection();this.editionProperties.range?(s=this.editionProperties.range,this.editionProperties.range=null):s=o.getRangeAt(0),s.deleteContents();var a=s.startContainer,l=s.startOffset;3==a.nodeType?(a=a.splitText(l)).parentNode.insertBefore(e,a):1==a.nodeType&&a.insertBefore(e,a.childNodes[l]),this.placeCaretAfterNode(e)}else if("textarea"==t.type)t.focus();else{var c=this.integrationModel.getSelection();if(c.removeAllRanges(),this.editionProperties.range){var u=this.editionProperties.range;this.editionProperties.range=null,c.addRange(u)}}else if(this.editionProperties.latexRange)document.selection&&0==document.getSelection?(this.editionProperties.isNewElement=!0,this.editionProperties.latexRange.select(),this.insertElementOnSelection(e,t,i)):(this.editionProperties.latexRange.deleteContents(),this.editionProperties.latexRange.insertNode(e),this.placeCaretAfterNode(e));else if("textarea"==t.type){var h;h=void 0!==this.integrationModel.getSelectedItem?this.integrationModel.getSelectedItem(t,!1):v.getSelectedItemOnTextarea(t),v.updateExistingTextOnTextarea(t,e.textContent,h.startPosition,h.endPosition)}else e&&"img"===e.nodeName.toLowerCase()?P.clone(e,this.editionProperties.temporalImage):this.editionProperties.temporalImage.remove(),this.placeCaretAfterNode(this.editionProperties.temporalImage)}},{key:"openModalDialog",value:function(e,t){this.editMode="images";try{if(t){e.contentWindow.focus();var i=e.contentWindow.getSelection();this.editionProperties.range=i.getRangeAt(0)}else{e.focus();var n=getSelection();this.editionProperties.range=n.getRangeAt(0)}}catch(e){this.editionProperties.range=null}var r;if(void 0===t&&(t=!0),this.editionProperties.latexRange=null,e)if(r=void 0!==this.integrationModel.getSelectedItem?this.integrationModel.getSelectedItem(e,t):v.getSelectedItem(e,t)){if(!r.caretPosition&&v.containsClass(r.node,l.get("imageClassName")))this.editionProperties.temporalImage=r.node,this.editionProperties.isNewElement=!1;else if(3===r.node.nodeType)if(this.integrationModel.getMathmlFromTextNode){var s=this.integrationModel.getMathmlFromTextNode(r.node,r.caretPosition);s&&(this.editMode="latex",this.editionProperties.isNewElement=!1,this.editionProperties.temporalImage=document.createElement("img"),this.editionProperties.temporalImage.setAttribute(l.get("imageMathmlAttribute"),o.safeXmlEncode(s)))}else{var a=g.getLatexFromTextNode(r.node,r.caretPosition);if(a){var c=g.getMathMLFromLatex(a.latex);this.editMode="latex",this.editionProperties.isNewElement=!1,this.editionProperties.temporalImage=document.createElement("img"),this.editionProperties.temporalImage.setAttribute(l.get("imageMathmlAttribute"),o.safeXmlEncode(c));var u=t?e.contentWindow:window;if("textarea"!==e.tagName.toLowerCase())if(document.selection){for(var h=0,d=a.startNode.previousSibling;d;)h+=v.getNodeLength(d),d=d.previousSibling;this.editionProperties.latexRange=u.document.selection.createRange(),this.editionProperties.latexRange.moveToElementText(a.startNode.parentNode),this.editionProperties.latexRange.move("character",h+a.startPosition),this.editionProperties.latexRange.moveEnd("character",a.latex.length+4)}else this.editionProperties.latexRange=u.document.createRange(),this.editionProperties.latexRange.setStart(a.startNode,a.startPosition),this.editionProperties.latexRange.setEnd(a.endNode,a.endPosition)}}}else"textarea"===e.tagName.toLowerCase()&&(this.editMode="latex");for(var f=l.get("editorAttributes").split(", "),m={},p=0,b=f.length;p=i)){var r,s=t.charCodeAt(n);return s>=55296&&s<=56319&&i>n+1&&(r=t.charCodeAt(n+1))>=56320&&r<=57343?1024*(s-55296)+r-56320+65536:s}};Object.defineProperty?Object.defineProperty(String.prototype,"codePointAt",{value:e,configurable:!0,writable:!0}):String.prototype.codePointAt=e}(),"function"!=typeof Object.assign&&Object.defineProperty(Object,"assign",{value:function(e,t){if(null==e)throw new TypeError("Cannot convert undefined or null to object");for(var i=Object(e),n=1;n=i)){var r,s=t.charCodeAt(n);return s>=55296&&s<=56319&&i>n+1&&(r=t.charCodeAt(n+1))>=56320&&r<=57343?1024*(s-55296)+r-56320+65536:s}};Object.defineProperty?Object.defineProperty(String.prototype,"codePointAt",{value:e,configurable:!0,writable:!0}):String.prototype.codePointAt=e}(),"function"!=typeof Object.assign&&Object.defineProperty(Object,"assign",{value:function(e,t){if(null==e)throw new TypeError("Cannot convert undefined or null to object");for(var i=Object(e),n=1;n[]"', true); + this.setMathML('[]', true); } else { - this.setMathML('[]"', true); + this.setMathML('[]', true); } } else { if (this.editor.getEditorModel().isRTL()) { diff --git a/core/src/latex.js b/core/src/latex.js index d3f2382d..5566018c 100644 --- a/core/src/latex.js +++ b/core/src/latex.js @@ -16,6 +16,7 @@ export default class Latex { * @return {string} LaTeX string generated by the MathML argument. */ static getLatexFromMathML(mathml) { + const mathmlWithoutSemantics = MathML.removeSemantics(mathml); /** * @type {TextCache} */ @@ -23,7 +24,7 @@ export default class Latex { var data = { 'service': 'mathml2latex', - 'mml': mathml + 'mml': mathmlWithoutSemantics }; var jsonResponse = JSON.parse(ServiceProvider.getService('service', data)); @@ -35,8 +36,8 @@ export default class Latex { latex = jsonResponse.result.text; const latexHtmlEntitiesEncoded = Util.htmlEntities(latex); // Inserting LaTeX semantics. - mathml = MathML.insertSemanticsMathml(mathml, latexHtmlEntitiesEncoded, 'LaTeX'); - cache.populate(latex, mathml); + const mathmlWithSemantics = MathML.addAnnotation(mathml, latexHtmlEntitiesEncoded, 'LaTeX'); + cache.populate(latex, mathmlWithSemantics); } return latex; @@ -76,7 +77,7 @@ export default class Latex { // Populate LatexCache. if (mathml.indexOf('semantics') == -1 && mathml.indexOf('annotation') == -1 ) { - mathml = MathML.insertSemanticsMathml(mathml, latex, 'LaTeX'); + mathml = MathML.addAnnotation(mathml, latex, 'LaTeX'); output = mathml; } else { diff --git a/core/src/mathml.js b/core/src/mathml.js index 93636a6a..c5ac6788 100644 --- a/core/src/mathml.js +++ b/core/src/mathml.js @@ -191,56 +191,79 @@ export default class MathML { } /** - * Add annotation tag to mathml without it (mathml comes from LaTeX string) - * @param {string} mathml - MathML code generated by a LaTeX string. - * @param {string} latex - original LaTeX string - * @param {string} withoutLatexTranslate - true if not exists latex translation from mathml. false otherwise. - * @param {string} encoding - encoding attribute. - * @returns {string} MathML containing LaTeX code on annotation tag. + * Adds annotation tag in MathML element. + * @param {String} mathml - valid MathML. + * @param {String} content - value to put inside annotation tag. + * @param {String} annotationEncoding - annotation encoding. + * @returns {String} - 'mathml' with an annotation that contains 'content' and encoding 'encoding'. */ - static insertSemanticsMathml(mathml, latex, encoding) { - - // If latex is empty, insert semantics doesn't provide information. We can avoid semantics insertion and return the mathml. - if (latex == "") { - return mathml; + static addAnnotation(mathml, content, annotationEncoding) { + // If contains annotation, also contains semantics tag. + const containsAnnotation = mathml.indexOf(''); + mathmlWithAnnotation = mathml.substring(0, closeSemanticsIndex) + `${content}` + mathml.substring(closeSemanticsIndex); + } + else if (MathML.isEmpty(mathml)) { + const endIndexInline = mathml.indexOf('/>'); + const endIndexNonInline = mathml.indexOf('>'); + const endIndex = endIndexNonInline === endIndexInline ? endIndexInline : endIndexNonInline; + mathmlWithAnnotation = mathml.substring(0, endIndex) + `>${content}`; + } + else { + const beginMathMLContent = mathml.indexOf('>') + 1; + const endMathmlContent = mathml.lastIndexOf(''); + const mathmlContent = mathml.substring(beginMathMLContent, endMathmlContent); + mathmlWithAnnotation = mathml.substring(0, beginMathMLContent) + `${mathmlContent}${content}`; } - var firstEndTag = '>'; - var mathTagEnd = '<' + '/math' + '>'; - var openSemantics = '<' + 'semantics' + '>'; - var closeSemantics = '<' + '/semantics' + '>'; - var openTarget = ''; - var closeTarget = '<' + '/annotation' + '>'; - var mrowOpen = ''; - var mrowClose = ''; - - var indexMathBegin = mathml.indexOf(firstEndTag); - var indexMathEnd = mathml.indexOf(mathTagEnd); - var mathBeginExists = mathml.substring(mathml.indexOf('<'), mathml.indexOf('>')).indexOf('math'); - - if (indexMathBegin != -1 && indexMathEnd != -1 && mathBeginExists) { - var mathmlContent = mathml.substring(indexMathBegin + 1, indexMathEnd); - if (mathmlContent.indexOf(mrowOpen) != 0) { - var mathmlContentSemantics = openSemantics + mrowOpen + mathmlContent + mrowClose + openTarget + latex + closeTarget + closeSemantics; - } else { - var mathmlContentSemantics = openSemantics + mathmlContent + openTarget + latex + closeTarget + closeSemantics; + return mathmlWithAnnotation; + } + + /** + * Removes specific annotation tag in MathML element. In case of remove the unique annotation, also is removed semantics tag. + * @param {String} mathml - valid MathML. + * @param {String} annotationEncoding - annotation encoding to remove. + * @returns {String} - 'mathml' without the annotation encoding specified. + */ + static removeAnnotation(mathml, annotationEncoding) { + let mathmlWithoutAnnotation = mathml; + const openAnnotationTag = ``; + const closeAnnotationTag = ''; + const startAnnotationIndex = mathml.indexOf(openAnnotationTag); + if (startAnnotationIndex !== -1) { + let differentAnnotationFound = false; + let differentAnnotationIndex = mathml.indexOf(''; - var openSemantics = '<' + 'semantics' + '>'; - var openAnnotation = ''; + static removeSemantics(mathml) { + var mathTagEnd = ''; + var openSemantics = ''; + var openAnnotation = ' core MathType JavaScript engine - 7.8.0.1397 + 7.9.0.1398 GPL 3.0+ diff --git a/version.php b/version.php index e4b5b3a7..37100898 100644 --- a/version.php +++ b/version.php @@ -25,9 +25,9 @@ defined('MOODLE_INTERNAL') || die(); -$plugin->version = 2018110900; -$plugin->release = '7.8.0.1397'; +$plugin->version = 2018121200; +$plugin->release = '7.9.0.1398'; $plugin->requires = 2014050800; $plugin->component = 'atto_wiris'; -$plugin->dependencies = array ('filter_wiris' => 2018110900); +$plugin->dependencies = array ('filter_wiris' => 2018121200); $plugin->maturity = MATURITY_STABLE; diff --git a/wirisplugin-generic.js b/wirisplugin-generic.js index ed3257d6..f2b67735 100644 --- a/wirisplugin-generic.js +++ b/wirisplugin-generic.js @@ -1,3 +1,3 @@ -!function(e){var t={};function i(n){if(t[n])return t[n].exports;var r=t[n]={i:n,l:!1,exports:{}};return e[n].call(r.exports,r,r.exports,i),r.l=!0,r.exports}i.m=e,i.c=t,i.d=function(e,t,n){i.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},i.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},i.t=function(e,t){if(1&t&&(e=i(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(i.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var r in e)i.d(n,r,function(t){return e[t]}.bind(null,r));return n},i.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return i.d(t,"a",t),t},i.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},i.p="",i(i.s=5)}([function(module,__webpack_exports__,__webpack_require__){"use strict";function _typeof(e){return(_typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}var md5,_unused_webpack_default_export=md5;!function(){var HxOverrides=function(){};HxOverrides.__name__=!0,HxOverrides.dateStr=function(e){var t=e.getMonth()+1,i=e.getDate(),n=e.getHours(),r=e.getMinutes(),s=e.getSeconds();return e.getFullYear()+"-"+(t<10?"0"+t:""+t)+"-"+(i<10?"0"+i:""+i)+" "+(n<10?"0"+n:""+n)+":"+(r<10?"0"+r:""+r)+":"+(s<10?"0"+s:""+s)},HxOverrides.strDate=function(e){switch(e.length){case 8:var t=e.split(":"),i=new Date;return i.setTime(0),i.setUTCHours(t[0]),i.setUTCMinutes(t[1]),i.setUTCSeconds(t[2]),i;case 10:t=e.split("-");return new Date(t[0],t[1]-1,t[2],0,0,0);case 19:var n=(t=e.split(" "))[0].split("-"),r=t[1].split(":");return new Date(n[0],n[1]-1,n[2],r[0],r[1],r[2]);default:throw"Invalid date format : "+e}},HxOverrides.cca=function(e,t){var i=e.charCodeAt(t);if(i==i)return i},HxOverrides.substr=function(e,t,i){return null!=t&&0!=t&&null!=i&&i<0?"":(null==i&&(i=e.length),t<0?(t=e.length+t)<0&&(t=0):i<0&&(i=e.length+i-t),e.substr(t,i))},HxOverrides.remove=function(e,t){for(var i=0,n=e.length;i>>32-t},str2blks:function(e){for(var t=1+(e.length+8>>6),i=new Array,n=0,r=16*t;n>2]|=HxOverrides.cca(e,s)<<(8*e.length+s)%4*8,s++;i[s>>2]|=128<<(8*e.length+s)%4*8;var o=8*e.length,a=16*t-2;return i[a]=255&o,i[a]|=(o>>>8&255)<<8,i[a]|=(o>>>16&255)<<16,i[a]|=(o>>>24&255)<<24,i},rhex:function(e){for(var t="",i=0;i<4;){var n=i++;t+="0123456789abcdef".charAt(e>>8*n+4&15)+"0123456789abcdef".charAt(e>>8*n&15)}return t},addme:function(e,t){var i=(65535&e)+(65535&t);return(e>>16)+(t>>16)+(i>>16)<<16|65535&i},bitAND:function(e,t){return(e>>>1&t>>>1)<<1|1&e&t},bitXOR:function(e,t){return(e>>>1^t>>>1)<<1|1&e^1&t},bitOR:function(e,t){return(e>>>1|t>>>1)<<1|(1&e|1&t)},__class__:haxe.Md5},haxe.Timer=function(e){var t=this;this.id=window.setInterval(function(){t.run()},e)},haxe.Timer.__name__=!0,haxe.Timer.delay=function(e,t){var i=new haxe.Timer(t);return i.run=function(){i.stop(),e()},i},haxe.Timer.measure=function(e,t){var i=haxe.Timer.stamp(),n=e();return haxe.Log.trace(haxe.Timer.stamp()-i+"s",t),n},haxe.Timer.stamp=function(){return(new Date).getTime()/1e3},haxe.Timer.prototype={run:function(){},stop:function(){null!=this.id&&(window.clearInterval(this.id),this.id=null)},__class__:haxe.Timer};var js=js||{},$_;function $bind(e,t){var i=function e(){return e.method.apply(e.scope,arguments)};return i.scope=e,i.method=t,i}js.Boot=function(){},js.Boot.__name__=!0,js.Boot.__unhtml=function(e){return e.split("&").join("&").split("<").join("<").split(">").join(">")},js.Boot.__trace=function(e,t){var i,n=null!=t?t.fileName+":"+t.lineNumber+": ":"";n+=js.Boot.__string_rec(e,""),"undefined"!=typeof document&&null!=(i=document.getElementById("haxe:trace"))?i.innerHTML+=js.Boot.__unhtml(n)+"
":"undefined"!=typeof console&&null!=console.log&&console.log(n)},js.Boot.__clear_trace=function(){var e=document.getElementById("haxe:trace");null!=e&&(e.innerHTML="")},js.Boot.isClass=function(e){return e.__name__},js.Boot.isEnum=function(e){return e.__ename__},js.Boot.getClass=function(e){return e.__class__},js.Boot.__string_rec=function(e,t){if(null==e)return"null";if(t.length>=5)return"<...>";var i=_typeof(e);switch("function"==i&&(e.__name__||e.__ename__)&&(i="object"),i){case"object":if(e instanceof Array){if(e.__enum__){if(2==e.length)return e[0];var n=e[0]+"(";t+="\t";for(var r=2,s=e.length;r0?",":"")+js.Boot.__string_rec(e[l],t)}return n+="]"}var c;try{c=e.toString}catch(e){return"???"}if(null!=c&&c!=Object.toString){var u=e.toString();if("[object Object]"!=u)return u}var h=null;n="{\n";t+="\t";var d=null!=e.hasOwnProperty;for(var h in e)d&&!e.hasOwnProperty(h)||"prototype"!=h&&"__class__"!=h&&"__super__"!=h&&"__interfaces__"!=h&&"__properties__"!=h&&(2!=n.length&&(n+=", \n"),n+=t+h+" : "+js.Boot.__string_rec(e[h],t));return n+="\n"+(t=t.substring(1))+"}";case"function":return"";case"string":return e;default:return String(e)}},js.Boot.__interfLoop=function(e,t){if(null==e)return!1;if(e==t)return!0;var i=e.__interfaces__;if(null!=i)for(var n=0,r=i.length;n>>32-t},str2blks:function(e){for(var t=1+(e.length+8>>6),i=new Array,n=0,r=16*t;n>2]|=HxOverrides.cca(e,s)<<(8*e.length+s)%4*8,s++;i[s>>2]|=128<<(8*e.length+s)%4*8;var o=8*e.length,a=16*t-2;return i[a]=255&o,i[a]|=(o>>>8&255)<<8,i[a]|=(o>>>16&255)<<16,i[a]|=(o>>>24&255)<<24,i},rhex:function(e){for(var t="",i=0;i<4;){var n=i++;t+="0123456789abcdef".charAt(e>>8*n+4&15)+"0123456789abcdef".charAt(e>>8*n&15)}return t},addme:function(e,t){var i=(65535&e)+(65535&t);return(e>>16)+(t>>16)+(i>>16)<<16|65535&i},bitAND:function(e,t){return(e>>>1&t>>>1)<<1|1&e&t},bitXOR:function(e,t){return(e>>>1^t>>>1)<<1|1&e^1&t},bitOR:function(e,t){return(e>>>1|t>>>1)<<1|(1&e|1&t)},__class__:haxe.Md5},haxe.Timer=function(e){var t=this;this.id=window.setInterval(function(){t.run()},e)},haxe.Timer.__name__=!0,haxe.Timer.delay=function(e,t){var i=new haxe.Timer(t);return i.run=function(){i.stop(),e()},i},haxe.Timer.measure=function(e,t){var i=haxe.Timer.stamp(),n=e();return haxe.Log.trace(haxe.Timer.stamp()-i+"s",t),n},haxe.Timer.stamp=function(){return(new Date).getTime()/1e3},haxe.Timer.prototype={run:function(){},stop:function(){null!=this.id&&(window.clearInterval(this.id),this.id=null)},__class__:haxe.Timer};var js=js||{},$_;function $bind(e,t){var i=function e(){return e.method.apply(e.scope,arguments)};return i.scope=e,i.method=t,i}js.Boot=function(){},js.Boot.__name__=!0,js.Boot.__unhtml=function(e){return e.split("&").join("&").split("<").join("<").split(">").join(">")},js.Boot.__trace=function(e,t){var i,n=null!=t?t.fileName+":"+t.lineNumber+": ":"";n+=js.Boot.__string_rec(e,""),"undefined"!=typeof document&&null!=(i=document.getElementById("haxe:trace"))?i.innerHTML+=js.Boot.__unhtml(n)+"
":"undefined"!=typeof console&&null!=console.log&&console.log(n)},js.Boot.__clear_trace=function(){var e=document.getElementById("haxe:trace");null!=e&&(e.innerHTML="")},js.Boot.isClass=function(e){return e.__name__},js.Boot.isEnum=function(e){return e.__ename__},js.Boot.getClass=function(e){return e.__class__},js.Boot.__string_rec=function(e,t){if(null==e)return"null";if(t.length>=5)return"<...>";var i=_typeof(e);switch("function"==i&&(e.__name__||e.__ename__)&&(i="object"),i){case"object":if(e instanceof Array){if(e.__enum__){if(2==e.length)return e[0];var n=e[0]+"(";t+="\t";for(var r=2,s=e.length;r0?",":"")+js.Boot.__string_rec(e[l],t)}return n+="]"}var c;try{c=e.toString}catch(e){return"???"}if(null!=c&&c!=Object.toString){var u=e.toString();if("[object Object]"!=u)return u}var h=null;n="{\n";t+="\t";var d=null!=e.hasOwnProperty;for(var h in e)d&&!e.hasOwnProperty(h)||"prototype"!=h&&"__class__"!=h&&"__super__"!=h&&"__interfaces__"!=h&&"__properties__"!=h&&(2!=n.length&&(n+=", \n"),n+=t+h+" : "+js.Boot.__string_rec(e[h],t));return n+="\n"+(t=t.substring(1))+"}";case"function":return"";case"string":return e;default:return String(e)}},js.Boot.__interfLoop=function(e,t){if(null==e)return!1;if(e==t)return!0;var i=e.__interfaces__;if(null!=i)for(var n=0,r=i.length;n=0&&l.splice(t,1)}function m(e){var t=document.createElement("style");if(void 0===e.attrs.type&&(e.attrs.type="text/css"),void 0===e.attrs.nonce){var n=function(){0;return i.nc}();n&&(e.attrs.nonce=n)}return g(t,e.attrs),d(e,t),t}function g(e,t){Object.keys(t).forEach(function(i){e.setAttribute(i,t[i])})}function p(e,t){var i,n,r,s;if(t.transform&&e.css){if(!(s="function"==typeof t.transform?t.transform(e.css):t.transform.default(e.css)))return function(){};e.css=s}if(t.singleton){var l=a++;i=o||(o=m(t)),n=b.bind(null,i,l,!1),r=b.bind(null,i,l,!0)}else e.sourceMap&&"function"==typeof URL&&"function"==typeof URL.createObjectURL&&"function"==typeof URL.revokeObjectURL&&"function"==typeof Blob&&"function"==typeof btoa?(i=function(e){var t=document.createElement("link");return void 0===e.attrs.type&&(e.attrs.type="text/css"),e.attrs.rel="stylesheet",g(t,e.attrs),d(e,t),t}(t),n=function(e,t,i){var n=i.css,r=i.sourceMap,s=void 0===t.convertToAbsoluteUrls&&r;(t.convertToAbsoluteUrls||s)&&(n=c(n));r&&(n+="\n/*# sourceMappingURL=data:application/json;base64,"+btoa(unescape(encodeURIComponent(JSON.stringify(r))))+" */");var o=new Blob([n],{type:"text/css"}),a=e.href;e.href=URL.createObjectURL(o),a&&URL.revokeObjectURL(a)}.bind(null,i,t),r=function(){f(i),i.href&&URL.revokeObjectURL(i.href)}):(i=m(t),n=function(e,t){var i=t.css,n=t.media;n&&e.setAttribute("media",n);if(e.styleSheet)e.styleSheet.cssText=i;else{for(;e.firstChild;)e.removeChild(e.firstChild);e.appendChild(document.createTextNode(i))}}.bind(null,i),r=function(){f(i)});return n(e),function(t){if(t){if(t.css===e.css&&t.media===e.media&&t.sourceMap===e.sourceMap)return;n(e=t)}else r()}}e.exports=function(e,t){if("undefined"!=typeof DEBUG&&DEBUG&&"object"!=typeof document)throw new Error("The style-loader cannot be used in a non-browser environment");(t=t||{}).attrs="object"==typeof t.attrs?t.attrs:{},t.singleton||"boolean"==typeof t.singleton||(t.singleton=r()),t.insertInto||(t.insertInto="head"),t.insertAt||(t.insertAt="bottom");var i=h(e,t);return u(i,t),function(e){for(var r=[],s=0;s«/mo»",ampElement:"«mo»&«/mo»"}}},{key:"safeGoodBlackboardCharacters",get:function(){return{ltElement:"«mo»§lt;«/mo»",gtElement:"«mo»§gt;«/mo»",ampElement:"«mo»§amp;«/mo»"}}}]),e}();function s(e,t){for(var i=0;i",doubleQuote:'"',ampersand:"&",quote:"'"},r.safeXmlCharacters={tagOpener:"«",tagCloser:"»",doubleQuote:"¨",ampersand:"§",quote:"`",realDoubleQuote:"¨"};var o=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e)}return function(e,t,i){t&&s(e.prototype,t),i&&s(e,i)}(e,null,[{key:"isMathmlInAttribute",value:function(e,t){var i=new RegExp("^['\"][\\s]*=[\\s]*[\\w-]+([\\s]*(\"[^\"]*\"|'[^']*')[\\s]*=[\\s]*[\\w-]+[\\s]*)*[\\s]+gmi<"),n=e.substring(0,t).split("").reverse().join("");return i.test(n)}},{key:"safeXmlDecode",value:function(e){e=(e=(e=(e=e.split(r.safeXmlCharactersEntities.tagOpener).join(r.safeXmlCharacters.tagOpener)).split(r.safeXmlCharactersEntities.tagCloser).join(r.safeXmlCharacters.tagCloser)).split(r.safeXmlCharactersEntities.doubleQuote).join(r.safeXmlCharacters.doubleQuote)).split(r.safeXmlCharactersEntities.realDoubleQuote).join(r.safeXmlCharacters.realDoubleQuote),"_wrs_blackboard"in window&&window._wrs_blackboard&&(e=(e=(e=e.split(r.safeBadBlackboardCharacters.ltElement).join(r.safeGoodBlackboardCharacters.ltElement)).split(r.safeBadBlackboardCharacters.gtElement).join(r.safeGoodBlackboardCharacters.gtElement)).split(r.safeBadBlackboardCharacters.ampElement).join(r.safeGoodBlackboardCharacters.ampElement)),e=(e=(e=(e=(e=e.split(r.safeXmlCharacters.tagOpener).join(r.xmlCharacters.tagOpener)).split(r.safeXmlCharacters.tagCloser).join(r.xmlCharacters.tagCloser)).split(r.safeXmlCharacters.doubleQuote).join(r.xmlCharacters.doubleQuote)).split(r.safeXmlCharacters.ampersand).join(r.xmlCharacters.ampersand)).split(r.safeXmlCharacters.quote).join(r.xmlCharacters.quote);for(var t="",i=null,n=0;n128)t+="&#"+e.codePointAt(i)+";",e.codePointAt(i)>65535&&i++;else if("&"==n){var r=e.indexOf(";",i+1);if(r>=0){var s=document.createElement("span");s.innerHTML=e.substring(i,r+1),t+="&#"+v.fixedCharCodeAt(s.textContent||s.innerText,0)+";",i=r}else t+=n}else t+=n}return t}},{key:"addCustomEditorClassAttribute",value:function(e,t){var i="",n=e.indexOf("");if(-1==e.indexOf("class"))return i=e.substr(n,r)+' class="wrs_'+t+'">',i+=e.substr(r+1,e.length)}return e}},{key:"removeCustomEditorClassAttribute",value:function(e,t){return-1===e.indexOf("class")||-1===e.indexOf("wrs_"+t)?e:-1!==e.indexOf('class="wrs_'+t+'"')?e.replace('class="wrs_'+t+'"',""):e.replace("wrs_"+t,"")}},{key:"insertSemanticsMathml",value:function(e,t,i){if(""==t)return e;var n='',r=e.indexOf(">"),s=e.indexOf(""),o=e.substring(e.indexOf("<"),e.indexOf(">")).indexOf("math");if(-1!=r&&-1!=s&&o){var a=e.substring(r+1,s);if(0!=a.indexOf(""))var l=""+a+""+n+t+"
";else l=""+a+n+t+"
";return e.replace(a,l)}return e}},{key:"removeSemantics",value:function(e,t){var i='',n=e,r=e.indexOf("");if(-1!=r){var s=e.indexOf(i,r+"".length);-1!=s&&(n=e.substring(0,r)+e.substring(r+"".length,s)+"")}return n}},{key:"removeSemanticsOcurrences",value:function(e){for(var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:r.xmlCharacters,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"application/json",n=t.tagOpener+"math",s=t.tagOpener+"/math"+t.tagCloser,o="/"+t.tagCloser,a=t.tagCloser,l=t.tagOpener+"semantics"+t.tagCloser,c=t.tagOpener+"annotation encoding="+t.doubleQuote+i+t.doubleQuote+t.tagCloser,u="",h=e.indexOf(n),d=0;-1!==h;){u+=e.substring(d,h);var f=e.indexOf(s,h),m=e.indexOf(o,h),g=e.indexOf(a,h);-1!==f?d=f:m===g-1&&(d=m);var p=e.indexOf(l,h);if(-1!==p){var v=e.substring(h,p),b=e.indexOf(c,h);if(-1!==b)u+=v+e.substring(p+l.length,b)+s,h=e.indexOf(n,h+n.length),d+=s.length;else d=h,h=e.indexOf(n,h+n.length)}else d=h,h=e.indexOf(n,h+n.length)}return u+=e.substring(d,e.length)}},{key:"containClass",value:function(e,t){var i=e.indexOf("class");if(-1==i)return!1;var n=e.indexOf(">",i);return-1!=e.substring(i,n).indexOf(t)}},{key:"isEmpty",value:function(e){var t=e.indexOf(">"),i=e.indexOf("/>"),n=!1;if(-1!==i&&i===t-1&&(n=!0),!n){var r=new RegExp("").exec(e);r&&(n=t+1===r.index)}return n}}]),e}();function a(e,t){for(var i=0;i=0;--n)if(i[n]==t)return!0;return!1}},{key:"removeClass",value:function(e,t){for(var i="",n=e.className.split(" "),r=0;r").join("").split("").join("")).split("").join("
").split("").join("
");var n=e.createElement("div",{},i);return n.innerHTML=t,function t(n){if(n.getAttribute&&"WirisParam"==n.getAttribute("wirisObject")){for(var r={},s=0;s0){i+=">";for(n=0;n"}else"DIV"==t.nodeName||"SCRIPT"==t.nodeName?i+=">":i+="/>";return i}return 3==t.nodeType?e.htmlEntities(t.nodeValue):""}}},{key:"concatenateUrl",value:function(e,t){var i="";return e.indexOf("/")!=e.length&&0!=t.indexOf("/")&&(i="/"),(e+i+t).replace(/([^:]\/)\/+/g,"$1")}},{key:"htmlEntities",value:function(e){return e.split("&").join("&").split("<").join("<").split(">").join(">").split('"').join(""")}},{key:"htmlEntitiesDecode",value:function(e){return e.split(""").join('"').split(">").join(">").split("<").join("<").split("&").join("&")}},{key:"createHttpRequest",value:function(){if("file://"==window.location.toString().substr(0,window.location.toString().lastIndexOf("/")+1).substr(0,7))throw Core.getStringManager().getString("exception_cross_site");if("undefined"!=typeof XMLHttpRequest)return new XMLHttpRequest;try{return new ActiveXObject("Msxml2.XMLHTTP")}catch(e){try{return new ActiveXObject("Microsoft.XMLHTTP")}catch(e){}}return!1}},{key:"httpBuildQuery",value:function(t){var i="";for(var n in t)null!=t[n]&&(i+=e.urlEncode(n)+"="+e.urlEncode(t[n])+"&");return"&"==i.substring(i.length-1)&&(i=i.substring(0,i.length-1)),i}},{key:"propertiesToString",value:function(t){var i=[];for(var n in t)t.hasOwnProperty(n)&&i.push(n);for(var r=i.length,s=0;s0&&(i[s]=l,i[o]=a)}var c="";for(s=0;ss?s:r;for(n=0;n0){var i=e.substring(t+1).split("&"),n=new Object;for(t=0;t1&&(n[r[0]]=decodeURIComponent(r[1].replace(/\+/g," ")))}return n}return new Object}},{key:"urlEncode",value:function(e){return encodeURIComponent(e)}},{key:"getWIRISImageOutput",value:function(t,i,n){var s=e.createObject(t);if(s){if(s.className==l.get("imageClassName")||s.getAttribute(l.get("imageMathmlAttribute"))){if(!i)return t;var a=s.getAttribute(l.get("imageMathmlAttribute"));return l.get("saveHandTraces")||(a=o.removeSemanticsOcurrences(a,r.safeXmlCharacters)),null==a&&(a=s.getAttribute("alt")),n||(a=o.safeXmlDecode(a)),a}if(s.className==l.get("CASClassName")){var c=s.getAttribute(l.get("CASMathmlAttribute"));c=o.safeXmlDecode(c);var u=e.createObject(c);u.setAttribute("src",s.src);var h=e.createObjectCode(u);return n&&(h=o.safeXmlEncode(h)),h}}return t}},{key:"getNodeLength",value:function(e){function t(t){return e.apply(this,arguments)}return t.toString=function(){return e.toString()},t}(function(e){if(3==e.nodeType)return e.nodeValue.length;if(1==e.nodeType){var t={IMG:1,BR:1}[e.nodeName.toUpperCase()];void 0===t&&(t=0);for(var i=0;i0)return 0==c.text.length?e.getSelectedItem(t,i,!0):null;r.document.execCommand("InsertImage",!1,"#");var s,o=c.parentElement();return"IMG"!=o.nodeName.toUpperCase()&&(c.pasteHTML(''),o=r.document.getElementById("wrs_openEditorWindow_temporalObject")),o.nextSibling&&3==o.nextSibling.nodeType?(a=o.nextSibling,s=0):o.previousSibling&&3==o.previousSibling.nodeType?s=(a=o.previousSibling).nodeValue.length:(a=r.document.createTextNode(""),o.parentNode.insertBefore(a,o),s=0),o.parentNode.removeChild(o),{node:a,caretPosition:s}}return c.length>1?null:{node:c.item(0)}}if(r.getSelection){var a,l=r.getSelection();try{var c=l.getRangeAt(0)}catch(e){c=r.document.createRange()}if(3==(a=c.startContainer).nodeType)return{node:a,caretPosition:c.startOffset};if(a!=c.endContainer)return null;if(1==a.nodeType){var u=c.startOffset;if(a.childNodes[u])return{node:a.childNodes[u]}}}return null}},{key:"getSelectedItemOnTextarea",value:function(e){var t=document.createTextNode(e.value),i=g.getLatexFromTextNode(t,e.selectionStart);return null===i?null:{node:t,caretPosition:e.selectionStart,startPosition:i.startPosition,endPosition:i.endPosition}}},{key:"getElementsByNameFromString",value:function(e,t,i){var n=[];e=e.toLowerCase();t=t.toLowerCase();for(var r=e.indexOf("<"+t+" ");-1!=r;){var s;s=i?">":"";var o=e.indexOf(s,r);-1!=o?(o+=s.length,n.push({start:r,end:o})):o=r+1,r=e.indexOf("<"+t+" ",o)}return n}},{key:"decode64",value:function(e){var t="+".charCodeAt(0),i="/".charCodeAt(0),n="0".charCodeAt(0),r="a".charCodeAt(0),s="A".charCodeAt(0),o="-".charCodeAt(0),a="_".charCodeAt(0),l=e.charCodeAt(0);return l===t||l===o?62:l===i||l===a?63:l0)throw new Error("Invalid string. Length must be a multiple of 4");var r=new Array;if(i)o=i;else var s="="===t.charAt(t.length-2)?2:"="===t.charAt(t.length-1)?1:0,o=s>0?t.length-4:t.length;for(var a=0;a>16&255),r.push(n>>8&255),r.push(255&n);return s&&(2===s?(n=e.decode64(t.charAt(a))<<2|e.decode64(t.charAt(a+1))>>4,r.push(255&n)):1===s&&(n=e.decode64(t.charAt(a))<<10|e.decode64(t.charAt(a+1))<<4|e.decode64(t.charAt(a+2))>>2,r.push(n>>8&255),r.push(255&n))),r}},{key:"readInt32",value:function(e){if(e.length<4)return!1;var t=e.splice(0,4);return t[0]<<24|t[1]<<16|t[2]<<8|t[3]<<0}},{key:"readByte",value:function(e){return e.shift()<<0}},{key:"readBytes",value:function(e,t,i){return e.splice(t,i)}},{key:"updateTextArea",value:function(e,t){if(e&&t)if(e.focus(),null!=e.selectionStart){var i=e.selectionEnd;e.value=e.value.substring(0,e.selectionStart)+t+e.value.substring(e.selectionEnd,e.value.length),e.selectionEnd=i+t.length}else{document.selection.createRange().text=t}}},{key:"updateExistingTextOnTextarea",value:function(e,t,i,n){e.focus(),e.value=e.value.substring(0,i)+t+e.value.substring(n,e.value.length),e.selectionEnd=i+t.length}},{key:"addArgument",value:function(e,t,i){return e+(e.indexOf("?")>0?"&":"?")+t+"="+i}}]),e}();function b(e,t){for(var i=0;i-1,this.deviceProperties.isIOS=this.ua.indexOf("ipad")>-1||this.ua.indexOf("iphone")>-1,this.toolbar=null,this.modalDialogInstance=null,this.listeners=new y,this.mathML=null,this.isNewElement=!0,this.integrationModel=null,this.isEditorLoaded=!1}return function(e,t,i){t&&E(e.prototype,t),i&&E(e,i)}(e,[{key:"addListener",value:function(e){this.listeners.add(e)}},{key:"setIntegrationModel",value:function(e){this.integrationModel=e}},{key:"setModalDialogInstance",value:function(e){this.modalDialogInstance=e}},{key:"insert",value:function(){this.updateTitle(this.modalDialogInstance),this.insertEditor(this.modalDialogInstance)}},{key:"insertEditor",value:function(){if("com"in window&&"wiris"in window.com&&"jsEditor"in window.com.wiris){if(this.editor=com.wiris.jsEditor.JsEditor.newInstance(this.editorAttributes),this.editor.insertInto(this.modalDialogInstance.contentContainer),this.editor.focus(),this.modalDialogInstance.rtl&&this.editor.action("rtl"),this.editor.getEditorModel().isRTL()&&(this.editor.element.style.direction="rtl"),this.editor.getEditorModel().addEditorListener(this.editorListener),this.modalDialogInstance.deviceProperties.isIOS){setTimeout(function(){this.modalDialogInstance.hideKeyboard()},400);var t=document.getElementsByClassName("wrs_formulaDisplay")[0];v.addEvent(t,"focus",this.modalDialogInstance.handleOpenedIosSoftkeyboard),v.addEvent(t,"blur",this.modalDialogInstance.handleClosedIosSoftkeyboard)}this.listeners.fire("onLoad",{}),this.isEditorLoaded=!0}else setTimeout(e.prototype.insertEditor.bind(this,this.modalDialogInstance),100)}},{key:"init",value:function(){for(var e=window.location.search.substring(1).split("&"),t=0;t=0&&(version=e[t].substring(2))}var i=document.createElement("script");i.type="text/javascript";var n=l.get("editorUrl"),r=document.createElement("a");r.href=n,0==window.location.href.indexOf("https://")&&"http:"==r.protocol&&(r.protocol="https:"),n="80"==r.port||"443"==r.port?r.protocol+"//"+r.hostname+"/"+r.pathname:r.protocol+"//"+r.hostname+":"+r.port+"/"+r.pathname;var s={};"editor"in this.environment?s.editor=this.environment.editor:s.editor="unknown","mode"in this.environment?s.mode=this.environment.mode:s.mode=l.get("saveMode"),"version"in this.environment?s.version=this.environment.version:s.version=l.get("version"),i.src=n+"?lang="+this.language+"&stats-editor="+s.editor+"&stats-mode="+s.mode+"&stats-version="+s.version,document.getElementsByTagName("head")[0].appendChild(i)}},{key:"setInitialContent",value:function(){this.isNewElement||this.setMathML(this.mathML)}},{key:"setMathML",value:function(e,t){void 0===t&&(t=!1),this.editor.setMathMLWithCallback(e,function(){this.editorListener.setWaitingForChanges(!0)}.bind(this)),setTimeout(function(){this.editorListener.setIsContentChanged(!1)}.bind(this),500),t||this.onFocus()}},{key:"onFocus",value:function(){void 0!==this.editor&&null!=this.editor&&this.editor.focus()}},{key:"submitAction",value:function(){if(this.editor.isFormulaEmpty())this.integrationModel.updateFormula(null);else{var e=this.editor.getMathMLWithSemantics();if(null!=this.customEditors.getActiveEditor())e=o.addCustomEditorClassAttribute(e,this.customEditors.getActiveEditor().toolbar);else for(var t in this.customEditors.editors)e=o.removeCustomEditorClassAttribute(e,t);var i=o.mathMLEntities(e);this.integrationModel.updateFormula(i)}this.customEditors.disable(),this.integrationModel.notifyWindowClosed(),this.setEmptyMathML(),this.customEditors.disable()}},{key:"setEmptyMathML",value:function(){this.deviceProperties.isAndroid||this.deviceProperties.isIOS?this.editor.getEditorModel().isRTL()?this.setMathML('[]"',!0):this.setMathML('[]"',!0):this.editor.getEditorModel().isRTL()?this.setMathML('',!0):this.setMathML("",!0)}},{key:"onOpen",value:function(){this.isNewElement?this.setEmptyMathML():this.setMathML(this.mathML),this.updateToolbar(),this.onFocus()}},{key:"updateToolbar",value:function(){var e;if(this.updateTitle(this.modalDialogInstance),e=this.customEditors.getActiveEditor()){var t=e.toolbar?e.toolbar:_wrs_int_wirisProperties.toolbar;null!=this.toolbar&&this.toolbar==t||this.setToolbar(t)}else{t=this.getToolbar();null!=this.toolbar&&this.toolbar==t||(this.setToolbar(t),this.customEditors.disable())}}},{key:"updateTitle",value:function(){var e;(e=this.customEditors.getActiveEditor())?this.modalDialogInstance.setTitle(e.title):this.modalDialogInstance.setTitle("MathType")}},{key:"getToolbar",value:function(){var e;return"general"==(e="toolbar"in this.editorAttributes?this.editorAttributes.toolbar:"general")&&(e="undefined"==typeof _wrs_int_wirisProperties||void 0===_wrs_int_wirisProperties.toolbar?"general":_wrs_int_wirisProperties.toolbar),e}},{key:"setToolbar",value:function(e){this.toolbar=e,this.editor.setParams({toolbar:this.toolbar})}},{key:"hasChanges",value:function(){return!this.editor.isFormulaEmpty()&&this.editorListener.getIsContentChanged()}}]),e}();function k(e,t){for(var i=0;i-1,r=i.indexOf("ipad")>-1||i.indexOf("iphone")>-1;this.iosSoftkeyboardOpened=!1,this.iosMeasureUnit=-1==i.indexOf("crios")?"%":"vh",this.iosDivHeight="100"+this.iosMeasureUnit;var s=window.outerWidth,o=window.outerHeight,a=s>o,l=so||l&&this.attributes.width>s);this.instanceId=document.getElementsByClassName("wrs_modal_dialogContainer").length,this.deviceProperties={orientation:a?"landscape":"portait",isAndroid:!!n,isIOS:!!r,isMobile:c,isDesktop:!c&&!r&&!n},this.properties={created:!1,state:"",previousState:"",position:{bottom:0,right:10},size:{height:338,width:580}};var u={class:"wrs_modal_overlay"};u.id=this.getElementId(u.class),this.overlay=v.createElement("div",u),(u={}).class="wrs_modal_title_bar",u.id=this.getElementId(u.class),this.titleBar=v.createElement("div",u),(u={}).class="wrs_modal_title",u.id=this.getElementId(u.class),this.title=v.createElement("div",u),this.title.innerHTML="",(u={}).class="wrs_modal_close_button",u.id=this.getElementId(u.class),u.title=V.getStringManager().getString("close"),this.closeDiv=v.createElement("a",u),this.closeDiv.setAttribute("role","button"),(u={}).class="wrs_modal_stack_button",u.id=this.getElementId(u.class),u.title="Exit full-screen",this.stackDiv=v.createElement("a",u),this.stackDiv.setAttribute("role","button"),(u={}).class="wrs_modal_maximize_button",u.id=this.getElementId(u.class),u.title=V.getStringManager().getString("fullscreen"),this.maximizeDiv=v.createElement("a",u),this.maximizeDiv.setAttribute("role","button"),(u={}).class="wrs_modal_minimize_button",u.id=this.getElementId(u.class),u.title=V.getStringManager().getString("minimise"),this.minimizeDiv=v.createElement("a",u),this.minimizeDiv.setAttribute("role","button"),(u={}).class="wrs_modal_dialogContainer",u.id=this.getElementId(u.class),this.container=v.createElement("div",u),(u={}).class="wrs_modal_wrapper",u.id=this.getElementId(u.class),this.wrapper=v.createElement("div",u),(u={}).class="wrs_content_container",u.id=this.getElementId(u.class),this.contentContainer=v.createElement("div",u),(u={}).class="wrs_modal_controls",u.id=this.getElementId(u.class),this.controls=v.createElement("div",u),(u={}).class="wrs_modal_buttons_container",u.id=this.getElementId(u.class),this.buttonContainer=v.createElement("div",u),this.submitButton=this.createSubmitButton({id:this.getElementId("wrs_modal_button_accept"),class:"wrs_modal_button_accept",innerHTML:V.getStringManager().getString("accept")},this.submitAction.bind(this)),this.cancelButton=this.createSubmitButton({id:this.getElementId("wrs_modal_button_cancel"),class:"wrs_modal_button_cancel",innerHTML:V.getStringManager().getString("cancel")},this.cancelAction.bind(this)),this.contentManager=null;var h={cancelString:V.getStringManager().getString("cancel"),submitString:V.getStringManager().getString("close"),message:V.getStringManager().getString("close_modal_warning")},d={closeCallback:function(){this.close()}.bind(this),cancelCallback:function(){this.focus()}.bind(this)},f={overlayElement:this.container,callbacks:d,strings:h};this.popup=new M(f),this.rtl=!1,"rtl"in this.attributes&&(this.rtl=this.attributes.rtl),this.handleOpenedIosSoftkeyboard=this.handleOpenedIosSoftkeyboard.bind(this),this.handleClosedIosSoftkeyboard=this.handleClosedIosSoftkeyboard.bind(this)}return function(e,t,i){t&&S(e.prototype,t),i&&S(e,i)}(e,[{key:"setContentManager",value:function(e){this.contentManager=e}},{key:"getContentManager",value:function(){return this.contentManager}},{key:"submitAction",value:function(){void 0!==this.contentManager.submitAction&&this.contentManager.submitAction(),this.close()}},{key:"cancelAction",value:function(){void 0===this.contentManager.hasChanges?this.close():this.contentManager.hasChanges()?this.showPopUpMessage():this.close()}},{key:"createSubmitButton",value:function(e,t){function i(e,t){this.element=document.createElement("button"),this.element.id=e.id,this.element.className=e.class,this.element.innerHTML=e.innerHTML,v.addEvent(this.element,"click",t)}return i.prototype.getElement=function(){return this.element},new i(e,t).getElement()}},{key:"create",value:function(){this.titleBar.appendChild(this.closeDiv),this.titleBar.appendChild(this.stackDiv),this.titleBar.appendChild(this.maximizeDiv),this.titleBar.appendChild(this.minimizeDiv),this.titleBar.appendChild(this.title),this.deviceProperties.isDesktop&&this.container.appendChild(this.titleBar),this.wrapper.appendChild(this.contentContainer),this.wrapper.appendChild(this.controls),this.controls.appendChild(this.buttonContainer),this.buttonContainer.appendChild(this.submitButton),this.buttonContainer.appendChild(this.cancelButton),this.container.appendChild(this.wrapper),this.recalculateScrollBar(),document.body.appendChild(this.container),document.body.appendChild(this.overlay),this.deviceProperties.isDesktop?(this.createModalWindowDesktop(),this.createResizeButtons(),this.addListeners(),l.get("modalWindowFullScreen")&&this.maximize()):this.deviceProperties.isAndroid?this.createModalWindowAndroid():this.deviceProperties.isIOS&&!this.deviceProperties.isMobile&&this.createModalWindowIos(),null!=this.contentManager&&this.contentManager.insert(this),this.properties.open=!0,this.properties.created=!0,this.isRTL()&&(this.container.style.right=window.innerWidth-this.scrollbarWidth-this.container.offsetWidth+"px",this.container.className+=" wrs_modal_rtl")}},{key:"createResizeButtons",value:function(){this.resizerBR=document.createElement("div"),this.resizerBR.className="wrs_bottom_right_resizer",this.resizerBR.innerHTML="◢",this.resizerTL=document.createElement("div"),this.resizerTL.className="wrs_bottom_left_resizer",this.container.appendChild(this.resizerBR),this.titleBar.appendChild(this.resizerTL),v.addEvent(this.resizerBR,"mousedown",this.activateResizeStateBR.bind(this)),v.addEvent(this.resizerTL,"mousedown",this.activateResizeStateTL.bind(this))}},{key:"activateResizeStateBR",value:function(e){this.initializeResizeProperties(e,!1)}},{key:"activateResizeStateTL",value:function(e){this.initializeResizeProperties(e,!0)}},{key:"initializeResizeProperties",value:function(e,t){v.addClass(document.body,"wrs_noselect"),v.addClass(this.overlay,"wrs_overlay_active"),this.resizeDataObject={x:this.eventClient(e).X,y:this.eventClient(e).Y},this.initialWidth=parseInt(this.container.style.width),this.initialHeight=parseInt(this.container.style.height),t?this.leftScale=!0:(this.initialRight=parseInt(this.container.style.right),this.initialBottom=parseInt(this.container.style.bottom)),this.initialRight||(this.initialRight=0),this.initialBottom||(this.initialBottom=0),document.body.style["user-select"]="none"}},{key:"open",value:function(){if(this.removeClass("wrs_closed"),(this.deviceProperties.isIOS||this.deviceProperties.isAndroid||this.deviceProperties.isMobile)&&(this.restoreWebsiteScale(),this.blockWebsiteScroll(),setTimeout(function(){this.hideKeyboard()}.bind(this),400)),this.properties.created?(this.properties.open||(this.properties.open=!0,this.deviceProperties.isAndroid||this.deviceProperties.isIOS||this.restoreState()),this.deviceProperties.isDesktop&&l.get("modalWindowFullScreen")&&this.maximize(),this.deviceProperties.isIOS&&(this.iosSoftkeyboardOpened=!1,this.setContainerHeight("100"+this.iosMeasureUnit))):this.create(),!1===this.contentManager.isEditorLoaded){var e=y.newListener("onLoad",function(){this.contentManager.onOpen(this)}.bind(this));this.contentManager.addListener(e)}else this.contentManager.onOpen(this)}},{key:"close",value:function(){this.removeClass("wrs_maximized"),this.removeClass("wrs_minimized"),this.removeClass("wrs_stack"),this.addClass("wrs_closed"),this.saveModalProperties(),this.unblockWebsiteScroll(),this.properties.open=!1}},{key:"restoreWebsiteScale",value:function(){var e=document.querySelector("meta[name=viewport]"),t=["initial-scale=","minimum-scale=","maximum-scale="],i=["1.0","1.0","1.0"],n=function(e,t){var n=e.getAttribute("content");if(n){for(var r=n.split(","),s="",o=[],a=0;a=0||navigator.userAgent.search("Trident/")>=0||navigator.userAgent.search("Edge/")>=0}},{key:"isRTL",value:function(){return"ar"==this.attributes.language||"he"==this.attributes.language||this.rtl}},{key:"addClass",value:function(e){v.addClass(this.overlay,e),v.addClass(this.titleBar,e),v.addClass(this.overlay,e),v.addClass(this.container,e),v.addClass(this.contentContainer,e),v.addClass(this.stackDiv,e),v.addClass(this.minimizeDiv,e),v.addClass(this.maximizeDiv,e),v.addClass(this.wrapper,e)}},{key:"removeClass",value:function(e){v.removeClass(this.overlay,e),v.removeClass(this.titleBar,e),v.removeClass(this.overlay,e),v.removeClass(this.container,e),v.removeClass(this.contentContainer,e),v.removeClass(this.stackDiv,e),v.removeClass(this.minimizeDiv,e),v.removeClass(this.maximizeDiv,e),v.removeClass(this.wrapper,e)}},{key:"createModalWindowDesktop",value:function(){this.addClass("wrs_modal_desktop"),this.stack()}},{key:"createModalWindowAndroid",value:function(){this.addClass("wrs_modal_android"),window.addEventListener("resize",this.orientationChangeAndroidSoftkeyboard.bind(this))}},{key:"createModalWindowIos",value:function(){this.addClass("wrs_modal_ios"),window.addEventListener("resize",this.orientationChangeIosSoftkeyboard.bind(this))}},{key:"restoreState",value:function(){"maximized"==this.properties.state?this.maximize():"minimized"==this.properties.state?(this.properties.state=this.properties.previousState,this.properties.previousState="",this.minimize()):this.stack()}},{key:"stack",value:function(){this.properties.previousState=this.properties.state,this.properties.state="stack",this.removeClass("wrs_maximized"),this.minimizeDiv.title="Minimise",this.removeClass("wrs_minimized"),this.addClass("wrs_stack"),this.restoreModalProperties(),void 0!==this.resizerBR&&void 0!==this.resizerTL&&this.setResizeButtonsVisibility(),this.recalculateScrollBar(),this.recalculatePosition(),this.recalculateScale(),this.focus()}},{key:"minimize",value:function(){this.saveModalProperties(),"minimized"==this.properties.state&&"stack"==this.properties.previousState?this.stack():"minimized"==this.properties.state&&"maximized"==this.properties.previousState?this.maximize():(this.container.style.height="30px",this.container.style.width="250px",this.container.style.bottom="0px",this.container.style.right="10px",this.removeListeners(),this.properties.previousState=this.properties.state,this.properties.state="minimized",this.setResizeButtonsVisibility(),this.minimizeDiv.title="Maximise",v.containsClass(this.overlay,"wrs_stack")?this.removeClass("wrs_stack"):this.removeClass("wrs_maximized"),this.addClass("wrs_minimized"))}},{key:"maximize",value:function(){this.saveModalProperties(),"maximized"!=this.properties.state&&(this.properties.previousState=this.properties.state,this.properties.state="maximized"),this.setResizeButtonsVisibility(),v.containsClass(this.overlay,"wrs_minimized")?(this.minimizeDiv.title="Minimise",this.removeClass("wrs_minimized")):v.containsClass(this.overlay,"wrs_stack")&&(this.container.style.left=null,this.container.style.top=null,this.removeClass("wrs_stack")),this.addClass("wrs_maximized"),this.setSize(parseInt(.8*window.innerHeight),parseInt(.8*window.innerWidth));this.container.clientHeight>700&&(this.container.style.height="700px"),this.container.clientWidth>1200&&(this.container.style.width="1200px"),this.setPosition(window.innerHeight/2-this.container.offsetHeight/2,window.innerWidth/2-this.container.offsetWidth/2),this.recalculateScale(),this.recalculatePosition(),this.recalculateSize(),this.focus()}},{key:"setSize",value:function(e,t){this.container.style.height=e+"px",this.container.style.width=t+"px",this.recalculateSize()}},{key:"setPosition",value:function(e,t){this.container.style.bottom=e+"px",this.container.style.right=t+"px"}},{key:"saveModalProperties",value:function(){"stack"==this.properties.state&&(this.properties.position.bottom=parseInt(this.container.style.bottom),this.properties.position.right=parseInt(this.container.style.right),this.properties.size.width=parseInt(this.container.style.width),this.properties.size.height=parseInt(this.container.style.height))}},{key:"restoreModalProperties",value:function(){"stack"==this.properties.state&&(this.setPosition(this.properties.position.bottom,this.properties.position.right),this.setSize(this.properties.size.height,this.properties.size.width))}},{key:"recalculateSize",value:function(){this.wrapper.style.width=this.container.clientWidth-12+"px",this.wrapper.style.height=this.container.clientHeight-38+"px",this.contentContainer.style.height=parseInt(this.wrapper.offsetHeight-50)+"px"}},{key:"setResizeButtonsVisibility",value:function(){"stack"==this.properties.state?(this.resizerTL.style.visibility="visible",this.resizerBR.style.visibility="visible"):(this.resizerTL.style.visibility="hidden",this.resizerBR.style.visibility="hidden")}},{key:"addListeners",value:function(){this.maximizeDiv.addEventListener("click",this.maximize.bind(this),!0),this.stackDiv.addEventListener("click",this.stack.bind(this),!0),this.minimizeDiv.addEventListener("click",this.minimize.bind(this),!0),this.closeDiv.addEventListener("click",this.cancelAction.bind(this)),v.addEvent(window,"mousedown",this.startDrag.bind(this)),v.addEvent(window,"mouseup",this.stopDrag.bind(this)),v.addEvent(window,"mousemove",this.drag.bind(this)),v.addEvent(window,"resize",this.onWindowResize.bind(this)),v.addEvent(window,"keydown",this.onKeyDown.bind(this))}},{key:"removeListeners",value:function(){v.removeEvent(window,"mousedown",this.startDrag),v.removeEvent(window,"mouseup",this.stopDrag),v.removeEvent(window,"mousemove",this.drag),v.removeEvent(window,"resize",this.onWindowResize),v.removeEvent(window,"keydown",this.onKeyDown)}},{key:"eventClient",value:function(e){if(void 0===e.clientX&&e.changedTouches){var t={X:e.changedTouches[0].clientX,Y:e.changedTouches[0].clientY};return t}return t={X:e.clientX,Y:e.clientY}}},{key:"startDrag",value:function(e){"minimized"!=this.properties.state&&e.target===this.title&&(void 0!==this.dragDataObject&&null!==this.dragDataObject||(e=e||event,this.dragDataObject={x:this.eventClient(e).X,y:this.eventClient(e).Y},this.lastDrag={x:"0px",y:"0px"},""==this.container.style.right&&(this.container.style.right="0px"),""==this.container.style.bottom&&(this.container.style.bottom="0px"),this.isIE11(),v.addClass(document.body,"wrs_noselect"),v.addClass(this.overlay,"wrs_overlay_active"),this.limitWindow=this.getLimitWindow()))}},{key:"drag",value:function(e){if(this.dragDataObject){e.preventDefault(),e=e||event;var t=Math.min(this.eventClient(e).Y,this.limitWindow.minPointer.y);t=Math.max(this.limitWindow.maxPointer.y,t);var i=Math.min(this.eventClient(e).X,this.limitWindow.minPointer.x),n=(i=Math.max(this.limitWindow.maxPointer.x,i))-this.dragDataObject.x+"px",r=t-this.dragDataObject.y+"px";this.lastDrag={x:n,y:r},this.container.style.transform="translate3d("+n+","+r+",0)"}if(this.resizeDataObject){var s;i=Math.min(this.eventClient(e).X,window.innerWidth-this.scrollbarWidth-7),t=Math.min(this.eventClient(e).Y,window.innerHeight-7);i<0&&(i=0),t<0&&(t=0),s=this.leftScale?-1:1,this.container.style.width=this.initialWidth+s*(i-this.resizeDataObject.x)+"px",this.container.style.height=this.initialHeight+s*(t-this.resizeDataObject.y)+"px",this.leftScale||(this.resizeDataObject.x-i-this.initialWidth<-580?this.container.style.right=this.initialRight-(i-this.resizeDataObject.x)+"px":(this.container.style.right=this.initialRight+this.initialWidth-580+"px",this.container.style.width="580px"),this.resizeDataObject.y-t580?(this.container.style.width=Math.min(parseInt(this.container.style.width),window.innerWidth-this.scrollbarWidth)+"px",e=!0):(this.container.style.width="580px",e=!0),parseInt(this.container.style.height)>338?(this.container.style.height=Math.min(parseInt(this.container.style.height),window.innerHeight)+"px",e=!0):(this.container.style.height="338px",e=!0),e&&this.recalculateSize()}},{key:"recalculateScrollBar",value:function(){this.hasScrollBar=window.innerWidth>document.documentElement.clientWidth,this.hasScrollBar?this.scrollbarWidth=this.getScrollBarWidth():this.scrollbarWidth=0}},{key:"hideKeyboard",value:function(){document.activeElement.blur()}},{key:"focus",value:function(){null!=this.contentManager&&void 0!==this.contentManager.onFocus&&this.contentManager.onFocus()}},{key:"portraitMode",value:function(){return window.innerHeight>window.innerWidth}},{key:"handleOpenedIosSoftkeyboard",value:function(){this.iosSoftkeyboardOpened||null==this.iosDivHeight||this.iosDivHeight!="100"+this.iosMeasureUnit||(this.portraitMode()?this.setContainerHeight("63"+this.iosMeasureUnit):this.setContainerHeight("40"+this.iosMeasureUnit)),this.iosSoftkeyboardOpened=!0}},{key:"handleClosedIosSoftkeyboard",value:function(){this.iosSoftkeyboardOpened=!1,this.setContainerHeight("100"+this.iosMeasureUnit)}},{key:"orientationChangeIosSoftkeyboard",value:function(){this.iosSoftkeyboardOpened?this.portraitMode()?this.setContainerHeight("63"+this.iosMeasureUnit):this.setContainerHeight("40"+this.iosMeasureUnit):this.setContainerHeight("100"+this.iosMeasureUnit)}},{key:"orientationChangeAndroidSoftkeyboard",value:function(){this.setContainerHeight("100%")}},{key:"setContainerHeight",value:function(e){this.iosDivHeight=e,this.wrapper.style.height=e}},{key:"showPopUpMessage",value:function(){"minimized"==this.properties.state&&this.stack(),this.popup.show()}},{key:"setTitle",value:function(e){this.title.innerHTML=e}},{key:"getElementId",value:function(e){return e+"["+this.instanceId+"]"}}]),e}();function I(e){return(I="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function T(e,t){for(var i=0;i=4;){v.readInt32(e);var t=v.readInt32(e);if(1229472850==t){var i=v.readInt32(e),n=v.readInt32(e);v.readInt32(e),v.readByte(e)}else if(1650545477==t)var r=v.readInt32(e);else if(1883789683==t){var s=v.readInt32(e);s=Math.round(s/39.37),v.readInt32(e),v.readByte(e)}v.readInt32(e)}if(void 0!==i){var o=new Array;return o.cw=i,o.ch=n,o.dpi=s,r&&(o.cb=r),o}}}]),e}();function A(e,t){for(var i=0;i"),m=c.substring(0,f),p=m.split(" width=").join(' class="Wiriscas" width=');c=(c=c.split(m).join(p)).split("'").join('"')}}var b='';t=t.substring(0,n[a].start+s)+b+t.substring(n[a].end+s),s+=b.length-(n[a].end-n[a].start)}}return t}},{key:"initParseEditMode",value:function(e){if(-1!=l.get("parseModes").indexOf("latex"))for(var t=v.getElementsByNameFromString(e,"img",!0),i='encoding="LaTeX">',n=0,r=0;r",d),m=h.substring(d,f),g="$$"+v.htmlEntitiesDecode(m)+"$$";e=e.substring(0,t[r].start+n)+g+e.substring(t[r].end+n),n+=g.length-(t[r].end-t[r].start)}}}}return e}},{key:"endParse",value:function(t){var i=e.endParseEditMode(t);return e.endParseSaveMode(i)}},{key:"endParseEditMode",value:function(e){if(-1!=l.get("parseModes").indexOf("latex")){for(var t="",i=0,n=e.indexOf("$$");-1!=n;){if(t+=e.substring(i,n),-1!=(i=e.indexOf("$$",n+2))){var r=e.substring(n+2,i);r=v.htmlEntitiesDecode(r),t+=g.getMathMLFromLatex(r,!0),i+=2}else t+="$$",i=n+2;n=e.indexOf("$$",i)}e=t+=e.substring(i,e.length)}return e}},{key:"endParseSaveMode",value:function(t){return l.get("saveMode")&&("safeXml"==l.get("saveMode")?t=e.codeImgTransform(t,"img2mathml"):"xml"==l.get("saveMode")?t=e.codeImgTransform(t,"img2mathml"):"base64"==l.get("saveMode")&&"image"==l.get("editMode")&&(t=e.codeImgTransform(t,"img264"))),t}},{key:"createShowImageSrc",value:function(e,t){var i=[],n="mml,color,centerbaseline,zoom,dpi,fontSize,fontFamily,defaultStretchy,backgroundColor,format".split(",");for(var r in n){var s=n[r];void 0!==e[s]&&(i[s]=e[s])}var o={};for(var r in e)"mml"!=r&&(o[r]=e[r]);return o.formula=com.wiris.js.JsPluginTools.md5encode(v.propertiesToString(i)),o.lang=void 0===t?"en":t,o.version=l.get("version"),f.getService("showimage",v.httpBuildQuery(o),!0)}},{key:"codeImgTransform",value:function(t,i){for(var n="",r=0,s=/"==h&&(r=u+1);++u}if(r",u):c.length,o.isMathmlInAttribute(t,u)||-1!=d)s+=t.substring(u,h);else{var f=t.substring(u,h);f=i==r.safeXmlCharacters?o.safeXmlDecode(f):o.mathMLEntities(f),s+=v.createObjectCode(e.mathmlToImgObject(document,f,null,n))}u=t.indexOf(a,h)}return s+=t.substring(h,t.length)}}]),e}();if("undefined"!=typeof MutationObserver){var D=new MutationObserver(function(e){e.forEach(function(e){e.oldValue===l.get("imageClassName")&&"class"===e.attributeName&&-1==e.target.className.indexOf(l.get("imageClassName"))&&(e.target.className=l.get("imageClassName"))})});B.observer=Object.create(D),B.observer.Config={attributes:!0,attributeOldValue:!0},B.observer.observe=function(e){this.__proto__.observe(e,this.Config)}}function R(e,t){for(var i=0;i=0&&(t=e[i].src.substr(0,n-1))}return t}},{key:"setLanguage",value:function(e){this.language=e}},{key:"setCore",value:function(e){this.core=e,e.setIntegrationModel(this)}},{key:"getCore",value:function(){return this.core}},{key:"setTarget",value:function(e){this.target=e,this.isIframe="IFRAME"===this.target.tagName.toUpperCase()}},{key:"setEditorObject",value:function(e){this.editorObject=e}},{key:"openNewFormulaEditor",value:function(){this.core.editionProperties.isNewElement=!0,this.core.openModalDialog(this.target,this.isIframe)}},{key:"openExistingFormulaEditor",value:function(){this.core.editionProperties.isNewElement=!1,this.core.openModalDialog(this.target,this.isIframe)}},{key:"updateFormula",value:function(e){this.isIframe?this.core.updateFormula(this.target.contentWindow,this.target.contentWindow,e,null):this.core.updateFormula(this.target,window,e,null)}},{key:"getSelection",value:function(){return this.isIframe?(this.target.contentWindow.focus(),this.target.contentWindow.getSelection()):(this.target.focus(),window.getSelection())}},{key:"addEvents",value:function(){var e=this.isIframe?this.target.contentWindow.document:this.target;v.addElementEvents(e,function(e,t){this.doubleClickHandler(e,t)}.bind(this),function(e,t){this.mousedownHandler(e,t)}.bind(this),function(e,t){this.mouseupHandler(e,t)}.bind(this))}},{key:"doubleClickHandler",value:function(e){if("img"==e.nodeName.toLowerCase()){if(this.core.getCustomEditors().disable(),e.hasAttribute("data-custom-editor")){var t=e.getAttribute("data-custom-editor");this.core.getCustomEditors().enable(t)}v.containsClass(e,l.get("imageClassName"))&&(this.core.editionProperties.temporalImage=e,this.core.editionProperties.isNewElement=!0,this.openExistingFormulaEditor())}}},{key:"mouseupHandler",value:function(){this.temporalImageResizing&&setTimeout(function(){P.fixAfterResize(this.temporalImageResizing)}.bind(this),10)}},{key:"mousedownHandler",value:function(e){"img"==e.nodeName.toLowerCase()&&v.containsClass(e,l.get("imageClassName"))&&(this.temporalImageResizing=e)}},{key:"getLanguage",value:function(){return this.getBrowserLanguage()}},{key:"getBrowserLanguage",value:function(){return navigator.userLanguage?navigator.userLanguage.substring(0,2):navigator.language?navigator.language.substring(0,2):"en"}},{key:"callbackFunction",value:function(){var e=y.newListener("onTargetReady",function(){this.addEvents(this.target)}.bind(this));this.listeners.add(e)}},{key:"notifyWindowClosed",value:function(){}},{key:"getMathmlFromTextNode",value:function(e,t){}},{key:"fillNonLatexNode",value:function(e,t,i){}},{key:"getSelectedItem",value:function(e,t){}}]),e}();function J(e,t){for(var i=0;i=0?"EDGE":e.search("Chrome/")>=0?"CHROME":e.search("Trident/")>=0?"IE":e.search("Firefox/")>=0?"FIREFOX":e.search("Safari/")>=0?"SAFARI":void 0}(),this.listeners=new y}return function(e,t,i){t&&J(e.prototype,t),i&&J(e,i)}(e,[{key:"init",value:function(e){this.load(e)}},{key:"setIntegrationModel",value:function(e){this.integrationModel=e}},{key:"setEnvironment",value:function(e){"editor"in e&&(this.environment.editor=e.editor),"mode"in e&&(this.environment.mode=e.mode),"version"in e&&(this.environment.version=e.version)}},{key:"getModalDialog",value:function(){return this.modalDialog}},{key:"load",value:function(t){var i="undefined"!=typeof XMLHttpRequest?new XMLHttpRequest:new ActiveXObject("Microsoft.XMLHTTP");this.integrationPath=0==t.indexOf("/")||0==t.indexOf("http")?t:v.concatenateUrl(this.integrationModel.getPath(),t),i.open("GET",this.integrationPath,!1),i.onload=function(t){var n=this;if(4===i.readyState){var r=JSON.parse(i.responseText);Object.keys(r);if(l.addConfiguration(r),l.addConfiguration(H),this.loadServicePaths(),this.loadLangFile(),this.loadCSS(),null===e.stringManager){var s=y.newListener("onLoad",function(){n.listeners.fire("onLoad",{})});e.stringManager.addListener(s)}else this.listeners.fire("onLoad",{})}}.bind(this),i.send(null)}},{key:"loadServicePaths",value:function(){var e=this.integrationPath.replace("configurationjs","createimage"),t=this.integrationPath.replace("configurationjs","showimage"),i=(e=this.integrationPath.replace("configurationjs","createimage"),this.integrationPath.replace("configurationjs","getmathml")),n=this.integrationPath.replace("configurationjs","service");if(0==this.integrationPath.indexOf("/")){var r=this.getServerPath();t=r+t,e=r+e,i=r+i,n=r+n}f.setServicePath("showimage",t),f.setServicePath("createimage",e),f.setServicePath("service",n),f.setServicePath("getmathml",i)}},{key:"getServerPath",value:function(){var e=this.integrationModel.getPath(),t=e.indexOf("/",e.indexOf("/")+2);return e.substr(0,t)}},{key:"loadLangFile",value:function(){var t="ar,ca,cs,da,de,en,es,et,eu,fi,fr,gl,he,hr,hu,it,ja,ko,nl,no,pl,pt,pt_br,ru,sv,tr,zh,el".split(","),i=this.language;-1==t.indexOf(i)&&(i=i.substr(0,2)),-1==t.indexOf(i)&&(i="en");var n=document.createElement("script");n.type="text/javascript",n.src=this.integrationModel.getPath()+"/"+this.integrationModel.langFolderName+"/"+i+"/strings.js",n.onload=function(){e.getStringManager().loadStrings(wrs_strings)},document.getElementsByTagName("head")[0].appendChild(n)}},{key:"loadCSS",value:function(){var e=document.createElement("link");e.setAttribute("rel","stylesheet"),e.setAttribute("type","text/css"),e.setAttribute("href",v.concatenateUrl(this.integrationModel.getPath(),"/core/styles.css")),document.getElementsByTagName("head")[0].appendChild(e)}},{key:"addListener",value:function(e){this.listeners.add(e)}},{key:"updateFormula",value:function(t,i,n,r){var s=new F;for(var o in s.mathml=n,s.wirisProperties={},r)s.wirisProperties[o]=r[o];if(s.language=this.language,s.editMode=this.editMode,!this.listeners.fire("onBeforeFormulaInsertion",s)&&!e.globalListeners.fire("onBeforeFormulaInsertion",s)){n=s.mathml,r=s.wirisProperties;var a=new F;if(a.editMode=this.editMode,a.windowTarget=i,a.focusElement=t,n)if("latex"==this.editMode)a.latex=g.getLatexFromMathML(n),this.integrationModel.fillNonLatexNode&&!a.latex?this.integrationModel.fillNonLatexNode(a,i,n):a.node=i.document.createTextNode("$$"+a.latex+"$$"),this.insertElementOnSelection(a.node,t,i);else if("iframes"==this.editMode){var l=wrs_mathmlToIframeObject(i,n);this.insertElementOnSelection(l,t,i)}else a.node=B.mathmlToImgObject(i.document,n,r,this.language),this.insertElementOnSelection(a.node,t,i);else this.insertElementOnSelection(null,t,i);this.listeners.fire("onAfterFormulaInsertion",a)||e.globalListeners.fire("onAfterFormulaInsertion",a)}}},{key:"placeCaretAfterNode",value:function(e){this.integrationModel.getSelection();var t=e.ownerDocument;if(void 0!==t.getSelection&&e.parentElement){var i=t.createRange();i.setStartAfter(e),i.collapse(!0);var n=t.getSelection();n.removeAllRanges(),n.addRange(i),t.body.focus()}}},{key:"insertElementOnSelection",value:function(e,t,i){if(this.editionProperties.isNewElement)if(e)if("textarea"==t.type)v.updateTextArea(t,e.textContent);else if(document.selection&&0==document.getSelection){var n=i.document.selection.createRange();if(i.document.execCommand("InsertImage",!1,e.src),"parentElement"in n||(i.document.execCommand("delete",!1),n=i.document.selection.createRange(),i.document.execCommand("InsertImage",!1,e.src)),"parentElement"in n){var r=n.parentElement();"IMG"==r.nodeName.toUpperCase()?r.parentNode.replaceChild(e,r):n.pasteHTML(v.createObjectCode(e))}}else{var s,o=this.integrationModel.getSelection();this.editionProperties.range?(s=this.editionProperties.range,this.editionProperties.range=null):s=o.getRangeAt(0),s.deleteContents();var a=s.startContainer,l=s.startOffset;3==a.nodeType?(a=a.splitText(l)).parentNode.insertBefore(e,a):1==a.nodeType&&a.insertBefore(e,a.childNodes[l]),this.placeCaretAfterNode(e)}else if("textarea"==t.type)t.focus();else{var c=this.integrationModel.getSelection();if(c.removeAllRanges(),this.editionProperties.range){var u=this.editionProperties.range;this.editionProperties.range=null,c.addRange(u)}}else if(this.editionProperties.latexRange)document.selection&&0==document.getSelection?(this.editionProperties.isNewElement=!0,this.editionProperties.latexRange.select(),this.insertElementOnSelection(e,t,i)):(this.editionProperties.latexRange.deleteContents(),this.editionProperties.latexRange.insertNode(e),this.placeCaretAfterNode(e));else if("textarea"==t.type){var h;h=void 0!==this.integrationModel.getSelectedItem?this.integrationModel.getSelectedItem(t,!1):v.getSelectedItemOnTextarea(t),v.updateExistingTextOnTextarea(t,e.textContent,h.startPosition,h.endPosition)}else e&&"img"===e.nodeName.toLowerCase()?P.clone(e,this.editionProperties.temporalImage):this.editionProperties.temporalImage.remove(),this.placeCaretAfterNode(this.editionProperties.temporalImage)}},{key:"openModalDialog",value:function(e,t){this.editMode="images";try{if(t){e.contentWindow.focus();var i=e.contentWindow.getSelection();this.editionProperties.range=i.getRangeAt(0)}else{e.focus();var n=getSelection();this.editionProperties.range=n.getRangeAt(0)}}catch(e){this.editionProperties.range=null}var r;if(void 0===t&&(t=!0),this.editionProperties.latexRange=null,e)if(r=void 0!==this.integrationModel.getSelectedItem?this.integrationModel.getSelectedItem(e,t):v.getSelectedItem(e,t)){if(!r.caretPosition&&v.containsClass(r.node,l.get("imageClassName")))this.editionProperties.temporalImage=r.node,this.editionProperties.isNewElement=!1;else if(3===r.node.nodeType)if(this.integrationModel.getMathmlFromTextNode){var s=this.integrationModel.getMathmlFromTextNode(r.node,r.caretPosition);s&&(this.editMode="latex",this.editionProperties.isNewElement=!1,this.editionProperties.temporalImage=document.createElement("img"),this.editionProperties.temporalImage.setAttribute(l.get("imageMathmlAttribute"),o.safeXmlEncode(s)))}else{var a=g.getLatexFromTextNode(r.node,r.caretPosition);if(a){var c=g.getMathMLFromLatex(a.latex);this.editMode="latex",this.editionProperties.isNewElement=!1,this.editionProperties.temporalImage=document.createElement("img"),this.editionProperties.temporalImage.setAttribute(l.get("imageMathmlAttribute"),o.safeXmlEncode(c));var u=t?e.contentWindow:window;if("textarea"!==e.tagName.toLowerCase())if(document.selection){for(var h=0,d=a.startNode.previousSibling;d;)h+=v.getNodeLength(d),d=d.previousSibling;this.editionProperties.latexRange=u.document.selection.createRange(),this.editionProperties.latexRange.moveToElementText(a.startNode.parentNode),this.editionProperties.latexRange.move("character",h+a.startPosition),this.editionProperties.latexRange.moveEnd("character",a.latex.length+4)}else this.editionProperties.latexRange=u.document.createRange(),this.editionProperties.latexRange.setStart(a.startNode,a.startPosition),this.editionProperties.latexRange.setEnd(a.endNode,a.endPosition)}}}else"textarea"===e.tagName.toLowerCase()&&(this.editMode="latex");for(var f=l.get("editorAttributes").split(", "),m={},p=0,b=f.length;p>>32-t},str2blks:function(e){for(var t=1+(e.length+8>>6),i=new Array,n=0,r=16*t;n>2]|=HxOverrides.cca(e,s)<<(8*e.length+s)%4*8,s++;i[s>>2]|=128<<(8*e.length+s)%4*8;var o=8*e.length,a=16*t-2;return i[a]=255&o,i[a]|=(o>>>8&255)<<8,i[a]|=(o>>>16&255)<<16,i[a]|=(o>>>24&255)<<24,i},rhex:function(e){for(var t="",i=0;i<4;){var n=i++;t+="0123456789abcdef".charAt(e>>8*n+4&15)+"0123456789abcdef".charAt(e>>8*n&15)}return t},addme:function(e,t){var i=(65535&e)+(65535&t);return(e>>16)+(t>>16)+(i>>16)<<16|65535&i},bitAND:function(e,t){return(e>>>1&t>>>1)<<1|1&e&t},bitXOR:function(e,t){return(e>>>1^t>>>1)<<1|1&e^1&t},bitOR:function(e,t){return(e>>>1|t>>>1)<<1|(1&e|1&t)},__class__:haxe.Md5},haxe.Timer=function(e){var t=this;this.id=window.setInterval(function(){t.run()},e)},haxe.Timer.__name__=!0,haxe.Timer.delay=function(e,t){var i=new haxe.Timer(t);return i.run=function(){i.stop(),e()},i},haxe.Timer.measure=function(e,t){var i=haxe.Timer.stamp(),n=e();return haxe.Log.trace(haxe.Timer.stamp()-i+"s",t),n},haxe.Timer.stamp=function(){return(new Date).getTime()/1e3},haxe.Timer.prototype={run:function(){},stop:function(){null!=this.id&&(window.clearInterval(this.id),this.id=null)},__class__:haxe.Timer};var js=js||{},$_;function $bind(e,t){var i=function e(){return e.method.apply(e.scope,arguments)};return i.scope=e,i.method=t,i}js.Boot=function(){},js.Boot.__name__=!0,js.Boot.__unhtml=function(e){return e.split("&").join("&").split("<").join("<").split(">").join(">")},js.Boot.__trace=function(e,t){var i,n=null!=t?t.fileName+":"+t.lineNumber+": ":"";n+=js.Boot.__string_rec(e,""),"undefined"!=typeof document&&null!=(i=document.getElementById("haxe:trace"))?i.innerHTML+=js.Boot.__unhtml(n)+"
":"undefined"!=typeof console&&null!=console.log&&console.log(n)},js.Boot.__clear_trace=function(){var e=document.getElementById("haxe:trace");null!=e&&(e.innerHTML="")},js.Boot.isClass=function(e){return e.__name__},js.Boot.isEnum=function(e){return e.__ename__},js.Boot.getClass=function(e){return e.__class__},js.Boot.__string_rec=function(e,t){if(null==e)return"null";if(t.length>=5)return"<...>";var i=_typeof(e);switch("function"==i&&(e.__name__||e.__ename__)&&(i="object"),i){case"object":if(e instanceof Array){if(e.__enum__){if(2==e.length)return e[0];var n=e[0]+"(";t+="\t";for(var r=2,s=e.length;r0?",":"")+js.Boot.__string_rec(e[l],t)}return n+="]"}var c;try{c=e.toString}catch(e){return"???"}if(null!=c&&c!=Object.toString){var u=e.toString();if("[object Object]"!=u)return u}var h=null;n="{\n";t+="\t";var d=null!=e.hasOwnProperty;for(var h in e)d&&!e.hasOwnProperty(h)||"prototype"!=h&&"__class__"!=h&&"__super__"!=h&&"__interfaces__"!=h&&"__properties__"!=h&&(2!=n.length&&(n+=", \n"),n+=t+h+" : "+js.Boot.__string_rec(e[h],t));return n+="\n"+(t=t.substring(1))+"}";case"function":return"";case"string":return e;default:return String(e)}},js.Boot.__interfLoop=function(e,t){if(null==e)return!1;if(e==t)return!0;var i=e.__interfaces__;if(null!=i)for(var n=0,r=i.length;n>>32-t},str2blks:function(e){for(var t=1+(e.length+8>>6),i=new Array,n=0,r=16*t;n>2]|=HxOverrides.cca(e,s)<<(8*e.length+s)%4*8,s++;i[s>>2]|=128<<(8*e.length+s)%4*8;var o=8*e.length,a=16*t-2;return i[a]=255&o,i[a]|=(o>>>8&255)<<8,i[a]|=(o>>>16&255)<<16,i[a]|=(o>>>24&255)<<24,i},rhex:function(e){for(var t="",i=0;i<4;){var n=i++;t+="0123456789abcdef".charAt(e>>8*n+4&15)+"0123456789abcdef".charAt(e>>8*n&15)}return t},addme:function(e,t){var i=(65535&e)+(65535&t);return(e>>16)+(t>>16)+(i>>16)<<16|65535&i},bitAND:function(e,t){return(e>>>1&t>>>1)<<1|1&e&t},bitXOR:function(e,t){return(e>>>1^t>>>1)<<1|1&e^1&t},bitOR:function(e,t){return(e>>>1|t>>>1)<<1|(1&e|1&t)},__class__:haxe.Md5},haxe.Timer=function(e){var t=this;this.id=window.setInterval(function(){t.run()},e)},haxe.Timer.__name__=!0,haxe.Timer.delay=function(e,t){var i=new haxe.Timer(t);return i.run=function(){i.stop(),e()},i},haxe.Timer.measure=function(e,t){var i=haxe.Timer.stamp(),n=e();return haxe.Log.trace(haxe.Timer.stamp()-i+"s",t),n},haxe.Timer.stamp=function(){return(new Date).getTime()/1e3},haxe.Timer.prototype={run:function(){},stop:function(){null!=this.id&&(window.clearInterval(this.id),this.id=null)},__class__:haxe.Timer};var js=js||{},$_;function $bind(e,t){var i=function e(){return e.method.apply(e.scope,arguments)};return i.scope=e,i.method=t,i}js.Boot=function(){},js.Boot.__name__=!0,js.Boot.__unhtml=function(e){return e.split("&").join("&").split("<").join("<").split(">").join(">")},js.Boot.__trace=function(e,t){var i,n=null!=t?t.fileName+":"+t.lineNumber+": ":"";n+=js.Boot.__string_rec(e,""),"undefined"!=typeof document&&null!=(i=document.getElementById("haxe:trace"))?i.innerHTML+=js.Boot.__unhtml(n)+"
":"undefined"!=typeof console&&null!=console.log&&console.log(n)},js.Boot.__clear_trace=function(){var e=document.getElementById("haxe:trace");null!=e&&(e.innerHTML="")},js.Boot.isClass=function(e){return e.__name__},js.Boot.isEnum=function(e){return e.__ename__},js.Boot.getClass=function(e){return e.__class__},js.Boot.__string_rec=function(e,t){if(null==e)return"null";if(t.length>=5)return"<...>";var i=_typeof(e);switch("function"==i&&(e.__name__||e.__ename__)&&(i="object"),i){case"object":if(e instanceof Array){if(e.__enum__){if(2==e.length)return e[0];var n=e[0]+"(";t+="\t";for(var r=2,s=e.length;r0?",":"")+js.Boot.__string_rec(e[l],t)}return n+="]"}var c;try{c=e.toString}catch(e){return"???"}if(null!=c&&c!=Object.toString){var u=e.toString();if("[object Object]"!=u)return u}var h=null;n="{\n";t+="\t";var d=null!=e.hasOwnProperty;for(var h in e)d&&!e.hasOwnProperty(h)||"prototype"!=h&&"__class__"!=h&&"__super__"!=h&&"__interfaces__"!=h&&"__properties__"!=h&&(2!=n.length&&(n+=", \n"),n+=t+h+" : "+js.Boot.__string_rec(e[h],t));return n+="\n"+(t=t.substring(1))+"}";case"function":return"";case"string":return e;default:return String(e)}},js.Boot.__interfLoop=function(e,t){if(null==e)return!1;if(e==t)return!0;var i=e.__interfaces__;if(null!=i)for(var n=0,r=i.length;n=0&&l.splice(t,1)}function m(e){var t=document.createElement("style");if(void 0===e.attrs.type&&(e.attrs.type="text/css"),void 0===e.attrs.nonce){var n=function(){0;return i.nc}();n&&(e.attrs.nonce=n)}return g(t,e.attrs),d(e,t),t}function g(e,t){Object.keys(t).forEach(function(i){e.setAttribute(i,t[i])})}function p(e,t){var i,n,r,s;if(t.transform&&e.css){if(!(s="function"==typeof t.transform?t.transform(e.css):t.transform.default(e.css)))return function(){};e.css=s}if(t.singleton){var l=a++;i=o||(o=m(t)),n=b.bind(null,i,l,!1),r=b.bind(null,i,l,!0)}else e.sourceMap&&"function"==typeof URL&&"function"==typeof URL.createObjectURL&&"function"==typeof URL.revokeObjectURL&&"function"==typeof Blob&&"function"==typeof btoa?(i=function(e){var t=document.createElement("link");return void 0===e.attrs.type&&(e.attrs.type="text/css"),e.attrs.rel="stylesheet",g(t,e.attrs),d(e,t),t}(t),n=function(e,t,i){var n=i.css,r=i.sourceMap,s=void 0===t.convertToAbsoluteUrls&&r;(t.convertToAbsoluteUrls||s)&&(n=c(n));r&&(n+="\n/*# sourceMappingURL=data:application/json;base64,"+btoa(unescape(encodeURIComponent(JSON.stringify(r))))+" */");var o=new Blob([n],{type:"text/css"}),a=e.href;e.href=URL.createObjectURL(o),a&&URL.revokeObjectURL(a)}.bind(null,i,t),r=function(){f(i),i.href&&URL.revokeObjectURL(i.href)}):(i=m(t),n=function(e,t){var i=t.css,n=t.media;n&&e.setAttribute("media",n);if(e.styleSheet)e.styleSheet.cssText=i;else{for(;e.firstChild;)e.removeChild(e.firstChild);e.appendChild(document.createTextNode(i))}}.bind(null,i),r=function(){f(i)});return n(e),function(t){if(t){if(t.css===e.css&&t.media===e.media&&t.sourceMap===e.sourceMap)return;n(e=t)}else r()}}e.exports=function(e,t){if("undefined"!=typeof DEBUG&&DEBUG&&"object"!=typeof document)throw new Error("The style-loader cannot be used in a non-browser environment");(t=t||{}).attrs="object"==typeof t.attrs?t.attrs:{},t.singleton||"boolean"==typeof t.singleton||(t.singleton=r()),t.insertInto||(t.insertInto="head"),t.insertAt||(t.insertAt="bottom");var i=h(e,t);return u(i,t),function(e){for(var r=[],s=0;s«/mo»",ampElement:"«mo»&«/mo»"}}},{key:"safeGoodBlackboardCharacters",get:function(){return{ltElement:"«mo»§lt;«/mo»",gtElement:"«mo»§gt;«/mo»",ampElement:"«mo»§amp;«/mo»"}}}]),e}();function s(e,t){for(var i=0;i",doubleQuote:'"',ampersand:"&",quote:"'"},r.safeXmlCharacters={tagOpener:"«",tagCloser:"»",doubleQuote:"¨",ampersand:"§",quote:"`",realDoubleQuote:"¨"};var o=function(){function e(){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e)}return function(e,t,i){t&&s(e.prototype,t),i&&s(e,i)}(e,null,[{key:"isMathmlInAttribute",value:function(e,t){var i=new RegExp("^['\"][\\s]*=[\\s]*[\\w-]+([\\s]*(\"[^\"]*\"|'[^']*')[\\s]*=[\\s]*[\\w-]+[\\s]*)*[\\s]+gmi<"),n=e.substring(0,t).split("").reverse().join("");return i.test(n)}},{key:"safeXmlDecode",value:function(e){e=(e=(e=(e=e.split(r.safeXmlCharactersEntities.tagOpener).join(r.safeXmlCharacters.tagOpener)).split(r.safeXmlCharactersEntities.tagCloser).join(r.safeXmlCharacters.tagCloser)).split(r.safeXmlCharactersEntities.doubleQuote).join(r.safeXmlCharacters.doubleQuote)).split(r.safeXmlCharactersEntities.realDoubleQuote).join(r.safeXmlCharacters.realDoubleQuote),"_wrs_blackboard"in window&&window._wrs_blackboard&&(e=(e=(e=e.split(r.safeBadBlackboardCharacters.ltElement).join(r.safeGoodBlackboardCharacters.ltElement)).split(r.safeBadBlackboardCharacters.gtElement).join(r.safeGoodBlackboardCharacters.gtElement)).split(r.safeBadBlackboardCharacters.ampElement).join(r.safeGoodBlackboardCharacters.ampElement)),e=(e=(e=(e=(e=e.split(r.safeXmlCharacters.tagOpener).join(r.xmlCharacters.tagOpener)).split(r.safeXmlCharacters.tagCloser).join(r.xmlCharacters.tagCloser)).split(r.safeXmlCharacters.doubleQuote).join(r.xmlCharacters.doubleQuote)).split(r.safeXmlCharacters.ampersand).join(r.xmlCharacters.ampersand)).split(r.safeXmlCharacters.quote).join(r.xmlCharacters.quote);for(var t="",i=null,n=0;n128)t+="&#"+e.codePointAt(i)+";",e.codePointAt(i)>65535&&i++;else if("&"==n){var r=e.indexOf(";",i+1);if(r>=0){var s=document.createElement("span");s.innerHTML=e.substring(i,r+1),t+="&#"+v.fixedCharCodeAt(s.textContent||s.innerText,0)+";",i=r}else t+=n}else t+=n}return t}},{key:"addCustomEditorClassAttribute",value:function(e,t){var i="",n=e.indexOf("");if(-1==e.indexOf("class"))return i=e.substr(n,r)+' class="wrs_'+t+'">',i+=e.substr(r+1,e.length)}return e}},{key:"removeCustomEditorClassAttribute",value:function(e,t){return-1===e.indexOf("class")||-1===e.indexOf("wrs_"+t)?e:-1!==e.indexOf('class="wrs_'+t+'"')?e.replace('class="wrs_'+t+'"',""):e.replace("wrs_"+t,"")}},{key:"addAnnotation",value:function(t,i,n){var r="";if(-1!==t.indexOf("");r=t.substring(0,s)+'').concat(i,"")+t.substring(s)}else if(e.isEmpty(t)){var o=t.indexOf("/>"),a=t.indexOf(">"),l=a===o?o:a;r=t.substring(0,l)+'>').concat(i,"")}else{var c=t.indexOf(">")+1,u=t.lastIndexOf(""),h=t.substring(c,u);r=t.substring(0,c)+"".concat(h,'').concat(i,"")}return r}},{key:"removeAnnotation",value:function(t,i){var n=t,r=''),s=t.indexOf(r);if(-1!==s){for(var o=!1,a=t.indexOf("",s)+"".length;n=t.substring(0,s)+t.substring(l)}else n=e.removeSemantics(t)}return n}},{key:"removeSemantics",value:function(e){var t=e,i=e.indexOf("");if(-1!=i){var n=e.indexOf("".length);-1!=n&&(t=e.substring(0,i)+e.substring(i+"".length,n)+"")}return t}},{key:"removeSemanticsOcurrences",value:function(e){for(var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:r.xmlCharacters,i=t.tagOpener+"math",n=t.tagOpener+"/math"+t.tagCloser,s="/"+t.tagCloser,o=t.tagCloser,a=t.tagOpener+"semantics"+t.tagCloser,l=t.tagOpener+"annotation encoding=",c="",u=e.indexOf(i),h=0;-1!==u;){c+=e.substring(h,u);var d=e.indexOf(n,u),f=e.indexOf(s,u),m=e.indexOf(o,u);-1!==d?h=d:f===m-1&&(h=f);var g=e.indexOf(a,u);if(-1!==g){var p=e.substring(u,g),v=e.indexOf(l,u);if(-1!==v)c+=p+e.substring(g+a.length,v)+n,u=e.indexOf(i,u+i.length),h+=n.length;else h=u,u=e.indexOf(i,u+i.length)}else h=u,u=e.indexOf(i,u+i.length)}return c+=e.substring(h,e.length)}},{key:"containClass",value:function(e,t){var i=e.indexOf("class");if(-1==i)return!1;var n=e.indexOf(">",i);return-1!=e.substring(i,n).indexOf(t)}},{key:"isEmpty",value:function(e){var t=e.indexOf(">"),i=e.indexOf("/>"),n=!1;if(-1!==i&&i===t-1&&(n=!0),!n){var r=new RegExp("").exec(e);r&&(n=t+1===r.index)}return n}}]),e}();function a(e,t){for(var i=0;i=0;--n)if(i[n]==t)return!0;return!1}},{key:"removeClass",value:function(e,t){for(var i="",n=e.className.split(" "),r=0;r").join("").split("").join("")).split("").join("
").split("").join("
");var n=e.createElement("div",{},i);return n.innerHTML=t,function t(n){if(n.getAttribute&&"WirisParam"==n.getAttribute("wirisObject")){for(var r={},s=0;s0){i+=">";for(n=0;n"}else"DIV"==t.nodeName||"SCRIPT"==t.nodeName?i+=">":i+="/>";return i}return 3==t.nodeType?e.htmlEntities(t.nodeValue):""}}},{key:"concatenateUrl",value:function(e,t){var i="";return e.indexOf("/")!=e.length&&0!=t.indexOf("/")&&(i="/"),(e+i+t).replace(/([^:]\/)\/+/g,"$1")}},{key:"htmlEntities",value:function(e){return e.split("&").join("&").split("<").join("<").split(">").join(">").split('"').join(""")}},{key:"htmlEntitiesDecode",value:function(e){return e.split(""").join('"').split(">").join(">").split("<").join("<").split("&").join("&")}},{key:"createHttpRequest",value:function(){if("file://"==window.location.toString().substr(0,window.location.toString().lastIndexOf("/")+1).substr(0,7))throw Core.getStringManager().getString("exception_cross_site");if("undefined"!=typeof XMLHttpRequest)return new XMLHttpRequest;try{return new ActiveXObject("Msxml2.XMLHTTP")}catch(e){try{return new ActiveXObject("Microsoft.XMLHTTP")}catch(e){}}return!1}},{key:"httpBuildQuery",value:function(t){var i="";for(var n in t)null!=t[n]&&(i+=e.urlEncode(n)+"="+e.urlEncode(t[n])+"&");return"&"==i.substring(i.length-1)&&(i=i.substring(0,i.length-1)),i}},{key:"propertiesToString",value:function(t){var i=[];for(var n in t)t.hasOwnProperty(n)&&i.push(n);for(var r=i.length,s=0;s0&&(i[s]=l,i[o]=a)}var c="";for(s=0;ss?s:r;for(n=0;n0){var i=e.substring(t+1).split("&"),n=new Object;for(t=0;t1&&(n[r[0]]=decodeURIComponent(r[1].replace(/\+/g," ")))}return n}return new Object}},{key:"urlEncode",value:function(e){return encodeURIComponent(e)}},{key:"getWIRISImageOutput",value:function(t,i,n){var s=e.createObject(t);if(s){if(s.className==l.get("imageClassName")||s.getAttribute(l.get("imageMathmlAttribute"))){if(!i)return t;var a=s.getAttribute(l.get("imageMathmlAttribute"));return l.get("saveHandTraces")||(a=o.removeSemanticsOcurrences(a,r.safeXmlCharacters)),null==a&&(a=s.getAttribute("alt")),n||(a=o.safeXmlDecode(a)),a}if(s.className==l.get("CASClassName")){var c=s.getAttribute(l.get("CASMathmlAttribute"));c=o.safeXmlDecode(c);var u=e.createObject(c);u.setAttribute("src",s.src);var h=e.createObjectCode(u);return n&&(h=o.safeXmlEncode(h)),h}}return t}},{key:"getNodeLength",value:function(e){function t(t){return e.apply(this,arguments)}return t.toString=function(){return e.toString()},t}(function(e){if(3==e.nodeType)return e.nodeValue.length;if(1==e.nodeType){var t={IMG:1,BR:1}[e.nodeName.toUpperCase()];void 0===t&&(t=0);for(var i=0;i0)return 0==c.text.length?e.getSelectedItem(t,i,!0):null;r.document.execCommand("InsertImage",!1,"#");var s,o=c.parentElement();return"IMG"!=o.nodeName.toUpperCase()&&(c.pasteHTML(''),o=r.document.getElementById("wrs_openEditorWindow_temporalObject")),o.nextSibling&&3==o.nextSibling.nodeType?(a=o.nextSibling,s=0):o.previousSibling&&3==o.previousSibling.nodeType?s=(a=o.previousSibling).nodeValue.length:(a=r.document.createTextNode(""),o.parentNode.insertBefore(a,o),s=0),o.parentNode.removeChild(o),{node:a,caretPosition:s}}return c.length>1?null:{node:c.item(0)}}if(r.getSelection){var a,l=r.getSelection();try{var c=l.getRangeAt(0)}catch(e){c=r.document.createRange()}if(3==(a=c.startContainer).nodeType)return{node:a,caretPosition:c.startOffset};if(a!=c.endContainer)return null;if(1==a.nodeType){var u=c.startOffset;if(a.childNodes[u])return{node:a.childNodes[u]}}}return null}},{key:"getSelectedItemOnTextarea",value:function(e){var t=document.createTextNode(e.value),i=g.getLatexFromTextNode(t,e.selectionStart);return null===i?null:{node:t,caretPosition:e.selectionStart,startPosition:i.startPosition,endPosition:i.endPosition}}},{key:"getElementsByNameFromString",value:function(e,t,i){var n=[];e=e.toLowerCase();t=t.toLowerCase();for(var r=e.indexOf("<"+t+" ");-1!=r;){var s;s=i?">":"";var o=e.indexOf(s,r);-1!=o?(o+=s.length,n.push({start:r,end:o})):o=r+1,r=e.indexOf("<"+t+" ",o)}return n}},{key:"decode64",value:function(e){var t="+".charCodeAt(0),i="/".charCodeAt(0),n="0".charCodeAt(0),r="a".charCodeAt(0),s="A".charCodeAt(0),o="-".charCodeAt(0),a="_".charCodeAt(0),l=e.charCodeAt(0);return l===t||l===o?62:l===i||l===a?63:l0)throw new Error("Invalid string. Length must be a multiple of 4");var r=new Array;if(i)o=i;else var s="="===t.charAt(t.length-2)?2:"="===t.charAt(t.length-1)?1:0,o=s>0?t.length-4:t.length;for(var a=0;a>16&255),r.push(n>>8&255),r.push(255&n);return s&&(2===s?(n=e.decode64(t.charAt(a))<<2|e.decode64(t.charAt(a+1))>>4,r.push(255&n)):1===s&&(n=e.decode64(t.charAt(a))<<10|e.decode64(t.charAt(a+1))<<4|e.decode64(t.charAt(a+2))>>2,r.push(n>>8&255),r.push(255&n))),r}},{key:"readInt32",value:function(e){if(e.length<4)return!1;var t=e.splice(0,4);return t[0]<<24|t[1]<<16|t[2]<<8|t[3]<<0}},{key:"readByte",value:function(e){return e.shift()<<0}},{key:"readBytes",value:function(e,t,i){return e.splice(t,i)}},{key:"updateTextArea",value:function(e,t){if(e&&t)if(e.focus(),null!=e.selectionStart){var i=e.selectionEnd;e.value=e.value.substring(0,e.selectionStart)+t+e.value.substring(e.selectionEnd,e.value.length),e.selectionEnd=i+t.length}else{document.selection.createRange().text=t}}},{key:"updateExistingTextOnTextarea",value:function(e,t,i,n){e.focus(),e.value=e.value.substring(0,i)+t+e.value.substring(n,e.value.length),e.selectionEnd=i+t.length}},{key:"addArgument",value:function(e,t,i){return e+(e.indexOf("?")>0?"&":"?")+t+"="+i}}]),e}();function b(e,t){for(var i=0;i-1,this.deviceProperties.isIOS=this.ua.indexOf("ipad")>-1||this.ua.indexOf("iphone")>-1,this.toolbar=null,this.modalDialogInstance=null,this.listeners=new y,this.mathML=null,this.isNewElement=!0,this.integrationModel=null,this.isEditorLoaded=!1}return function(e,t,i){t&&E(e.prototype,t),i&&E(e,i)}(e,[{key:"addListener",value:function(e){this.listeners.add(e)}},{key:"setIntegrationModel",value:function(e){this.integrationModel=e}},{key:"setModalDialogInstance",value:function(e){this.modalDialogInstance=e}},{key:"insert",value:function(){this.updateTitle(this.modalDialogInstance),this.insertEditor(this.modalDialogInstance)}},{key:"insertEditor",value:function(){if("com"in window&&"wiris"in window.com&&"jsEditor"in window.com.wiris){if(this.editor=com.wiris.jsEditor.JsEditor.newInstance(this.editorAttributes),this.editor.insertInto(this.modalDialogInstance.contentContainer),this.editor.focus(),this.modalDialogInstance.rtl&&this.editor.action("rtl"),this.editor.getEditorModel().isRTL()&&(this.editor.element.style.direction="rtl"),this.editor.getEditorModel().addEditorListener(this.editorListener),this.modalDialogInstance.deviceProperties.isIOS){setTimeout(function(){this.modalDialogInstance.hideKeyboard()},400);var t=document.getElementsByClassName("wrs_formulaDisplay")[0];v.addEvent(t,"focus",this.modalDialogInstance.handleOpenedIosSoftkeyboard),v.addEvent(t,"blur",this.modalDialogInstance.handleClosedIosSoftkeyboard)}this.listeners.fire("onLoad",{}),this.isEditorLoaded=!0}else setTimeout(e.prototype.insertEditor.bind(this,this.modalDialogInstance),100)}},{key:"init",value:function(){for(var e=window.location.search.substring(1).split("&"),t=0;t=0&&(version=e[t].substring(2))}var i=document.createElement("script");i.type="text/javascript";var n=l.get("editorUrl"),r=document.createElement("a");r.href=n,0==window.location.href.indexOf("https://")&&"http:"==r.protocol&&(r.protocol="https:"),n="80"==r.port||"443"==r.port?r.protocol+"//"+r.hostname+"/"+r.pathname:r.protocol+"//"+r.hostname+":"+r.port+"/"+r.pathname;var s={};"editor"in this.environment?s.editor=this.environment.editor:s.editor="unknown","mode"in this.environment?s.mode=this.environment.mode:s.mode=l.get("saveMode"),"version"in this.environment?s.version=this.environment.version:s.version=l.get("version"),i.src=n+"?lang="+this.language+"&stats-editor="+s.editor+"&stats-mode="+s.mode+"&stats-version="+s.version,document.getElementsByTagName("head")[0].appendChild(i)}},{key:"setInitialContent",value:function(){this.isNewElement||this.setMathML(this.mathML)}},{key:"setMathML",value:function(e,t){void 0===t&&(t=!1),this.editor.setMathMLWithCallback(e,function(){this.editorListener.setWaitingForChanges(!0)}.bind(this)),setTimeout(function(){this.editorListener.setIsContentChanged(!1)}.bind(this),500),t||this.onFocus()}},{key:"onFocus",value:function(){void 0!==this.editor&&null!=this.editor&&this.editor.focus()}},{key:"submitAction",value:function(){if(this.editor.isFormulaEmpty())this.integrationModel.updateFormula(null);else{var e=this.editor.getMathMLWithSemantics();if(null!=this.customEditors.getActiveEditor())e=o.addCustomEditorClassAttribute(e,this.customEditors.getActiveEditor().toolbar);else for(var t in this.customEditors.editors)e=o.removeCustomEditorClassAttribute(e,t);var i=o.mathMLEntities(e);this.integrationModel.updateFormula(i)}this.customEditors.disable(),this.integrationModel.notifyWindowClosed(),this.setEmptyMathML(),this.customEditors.disable()}},{key:"setEmptyMathML",value:function(){this.deviceProperties.isAndroid||this.deviceProperties.isIOS?this.editor.getEditorModel().isRTL()?this.setMathML('[]',!0):this.setMathML('[]',!0):this.editor.getEditorModel().isRTL()?this.setMathML('',!0):this.setMathML("",!0)}},{key:"onOpen",value:function(){this.isNewElement?this.setEmptyMathML():this.setMathML(this.mathML),this.updateToolbar(),this.onFocus()}},{key:"updateToolbar",value:function(){var e;if(this.updateTitle(this.modalDialogInstance),e=this.customEditors.getActiveEditor()){var t=e.toolbar?e.toolbar:_wrs_int_wirisProperties.toolbar;null!=this.toolbar&&this.toolbar==t||this.setToolbar(t)}else{t=this.getToolbar();null!=this.toolbar&&this.toolbar==t||(this.setToolbar(t),this.customEditors.disable())}}},{key:"updateTitle",value:function(){var e;(e=this.customEditors.getActiveEditor())?this.modalDialogInstance.setTitle(e.title):this.modalDialogInstance.setTitle("MathType")}},{key:"getToolbar",value:function(){var e;return"general"==(e="toolbar"in this.editorAttributes?this.editorAttributes.toolbar:"general")&&(e="undefined"==typeof _wrs_int_wirisProperties||void 0===_wrs_int_wirisProperties.toolbar?"general":_wrs_int_wirisProperties.toolbar),e}},{key:"setToolbar",value:function(e){this.toolbar=e,this.editor.setParams({toolbar:this.toolbar})}},{key:"hasChanges",value:function(){return!this.editor.isFormulaEmpty()&&this.editorListener.getIsContentChanged()}}]),e}();function O(e,t){for(var i=0;i-1,r=i.indexOf("ipad")>-1||i.indexOf("iphone")>-1;this.iosSoftkeyboardOpened=!1,this.iosMeasureUnit=-1==i.indexOf("crios")?"%":"vh",this.iosDivHeight="100"+this.iosMeasureUnit;var s=window.outerWidth,o=window.outerHeight,a=s>o,l=so||l&&this.attributes.width>s);this.instanceId=document.getElementsByClassName("wrs_modal_dialogContainer").length,this.deviceProperties={orientation:a?"landscape":"portait",isAndroid:!!n,isIOS:!!r,isMobile:c,isDesktop:!c&&!r&&!n},this.properties={created:!1,state:"",previousState:"",position:{bottom:0,right:10},size:{height:338,width:580}},this.websiteBeforeLockParameters=null;var u={class:"wrs_modal_overlay"};u.id=this.getElementId(u.class),this.overlay=v.createElement("div",u),(u={}).class="wrs_modal_title_bar",u.id=this.getElementId(u.class),this.titleBar=v.createElement("div",u),(u={}).class="wrs_modal_title",u.id=this.getElementId(u.class),this.title=v.createElement("div",u),this.title.innerHTML="",(u={}).class="wrs_modal_close_button",u.id=this.getElementId(u.class),u.title=V.getStringManager().getString("close"),this.closeDiv=v.createElement("a",u),this.closeDiv.setAttribute("role","button"),(u={}).class="wrs_modal_stack_button",u.id=this.getElementId(u.class),u.title="Exit full-screen",this.stackDiv=v.createElement("a",u),this.stackDiv.setAttribute("role","button"),(u={}).class="wrs_modal_maximize_button",u.id=this.getElementId(u.class),u.title=V.getStringManager().getString("fullscreen"),this.maximizeDiv=v.createElement("a",u),this.maximizeDiv.setAttribute("role","button"),(u={}).class="wrs_modal_minimize_button",u.id=this.getElementId(u.class),u.title=V.getStringManager().getString("minimise"),this.minimizeDiv=v.createElement("a",u),this.minimizeDiv.setAttribute("role","button"),(u={}).class="wrs_modal_dialogContainer",u.id=this.getElementId(u.class),this.container=v.createElement("div",u),(u={}).class="wrs_modal_wrapper",u.id=this.getElementId(u.class),this.wrapper=v.createElement("div",u),(u={}).class="wrs_content_container",u.id=this.getElementId(u.class),this.contentContainer=v.createElement("div",u),(u={}).class="wrs_modal_controls",u.id=this.getElementId(u.class),this.controls=v.createElement("div",u),(u={}).class="wrs_modal_buttons_container",u.id=this.getElementId(u.class),this.buttonContainer=v.createElement("div",u),this.submitButton=this.createSubmitButton({id:this.getElementId("wrs_modal_button_accept"),class:"wrs_modal_button_accept",innerHTML:V.getStringManager().getString("accept")},this.submitAction.bind(this)),this.cancelButton=this.createSubmitButton({id:this.getElementId("wrs_modal_button_cancel"),class:"wrs_modal_button_cancel",innerHTML:V.getStringManager().getString("cancel")},this.cancelAction.bind(this)),this.contentManager=null;var h={cancelString:V.getStringManager().getString("cancel"),submitString:V.getStringManager().getString("close"),message:V.getStringManager().getString("close_modal_warning")},d={closeCallback:function(){this.close()}.bind(this),cancelCallback:function(){this.focus()}.bind(this)},f={overlayElement:this.container,callbacks:d,strings:h};this.popup=new S(f),this.rtl=!1,"rtl"in this.attributes&&(this.rtl=this.attributes.rtl),this.handleOpenedIosSoftkeyboard=this.handleOpenedIosSoftkeyboard.bind(this),this.handleClosedIosSoftkeyboard=this.handleClosedIosSoftkeyboard.bind(this)}return function(e,t,i){t&&M(e.prototype,t),i&&M(e,i)}(e,[{key:"setContentManager",value:function(e){this.contentManager=e}},{key:"getContentManager",value:function(){return this.contentManager}},{key:"submitAction",value:function(){void 0!==this.contentManager.submitAction&&this.contentManager.submitAction(),this.close()}},{key:"cancelAction",value:function(){void 0===this.contentManager.hasChanges?this.close():this.contentManager.hasChanges()?this.showPopUpMessage():this.close()}},{key:"createSubmitButton",value:function(e,t){function i(e,t){this.element=document.createElement("button"),this.element.id=e.id,this.element.className=e.class,this.element.innerHTML=e.innerHTML,v.addEvent(this.element,"click",t)}return i.prototype.getElement=function(){return this.element},new i(e,t).getElement()}},{key:"create",value:function(){this.titleBar.appendChild(this.closeDiv),this.titleBar.appendChild(this.stackDiv),this.titleBar.appendChild(this.maximizeDiv),this.titleBar.appendChild(this.minimizeDiv),this.titleBar.appendChild(this.title),this.deviceProperties.isDesktop&&this.container.appendChild(this.titleBar),this.wrapper.appendChild(this.contentContainer),this.wrapper.appendChild(this.controls),this.controls.appendChild(this.buttonContainer),this.buttonContainer.appendChild(this.submitButton),this.buttonContainer.appendChild(this.cancelButton),this.container.appendChild(this.wrapper),this.recalculateScrollBar(),document.body.appendChild(this.container),document.body.appendChild(this.overlay),this.deviceProperties.isDesktop?(this.createModalWindowDesktop(),this.createResizeButtons(),this.addListeners(),l.get("modalWindowFullScreen")&&this.maximize()):this.deviceProperties.isAndroid?this.createModalWindowAndroid():this.deviceProperties.isIOS&&!this.deviceProperties.isMobile&&this.createModalWindowIos(),null!=this.contentManager&&this.contentManager.insert(this),this.properties.open=!0,this.properties.created=!0,this.isRTL()&&(this.container.style.right=window.innerWidth-this.scrollbarWidth-this.container.offsetWidth+"px",this.container.className+=" wrs_modal_rtl")}},{key:"createResizeButtons",value:function(){this.resizerBR=document.createElement("div"),this.resizerBR.className="wrs_bottom_right_resizer",this.resizerBR.innerHTML="◢",this.resizerTL=document.createElement("div"),this.resizerTL.className="wrs_bottom_left_resizer",this.container.appendChild(this.resizerBR),this.titleBar.appendChild(this.resizerTL),v.addEvent(this.resizerBR,"mousedown",this.activateResizeStateBR.bind(this)),v.addEvent(this.resizerTL,"mousedown",this.activateResizeStateTL.bind(this))}},{key:"activateResizeStateBR",value:function(e){this.initializeResizeProperties(e,!1)}},{key:"activateResizeStateTL",value:function(e){this.initializeResizeProperties(e,!0)}},{key:"initializeResizeProperties",value:function(e,t){v.addClass(document.body,"wrs_noselect"),v.addClass(this.overlay,"wrs_overlay_active"),this.resizeDataObject={x:this.eventClient(e).X,y:this.eventClient(e).Y},this.initialWidth=parseInt(this.container.style.width),this.initialHeight=parseInt(this.container.style.height),t?this.leftScale=!0:(this.initialRight=parseInt(this.container.style.right),this.initialBottom=parseInt(this.container.style.bottom)),this.initialRight||(this.initialRight=0),this.initialBottom||(this.initialBottom=0),document.body.style["user-select"]="none"}},{key:"open",value:function(){if(this.removeClass("wrs_closed"),(this.deviceProperties.isIOS||this.deviceProperties.isAndroid||this.deviceProperties.isMobile)&&(this.restoreWebsiteScale(),this.lockWebsiteScroll(),setTimeout(function(){this.hideKeyboard()}.bind(this),400)),this.properties.created?(this.properties.open||(this.properties.open=!0,this.deviceProperties.isAndroid||this.deviceProperties.isIOS||this.restoreState()),this.deviceProperties.isDesktop&&l.get("modalWindowFullScreen")&&this.maximize(),this.deviceProperties.isIOS&&(this.iosSoftkeyboardOpened=!1,this.setContainerHeight("100"+this.iosMeasureUnit))):this.create(),!1===this.contentManager.isEditorLoaded){var e=y.newListener("onLoad",function(){this.contentManager.onOpen(this)}.bind(this));this.contentManager.addListener(e)}else this.contentManager.onOpen(this)}},{key:"close",value:function(){this.removeClass("wrs_maximized"),this.removeClass("wrs_minimized"),this.removeClass("wrs_stack"),this.addClass("wrs_closed"),this.saveModalProperties(),this.unlockWebsiteScroll(),this.properties.open=!1}},{key:"restoreWebsiteScale",value:function(){var e=document.querySelector("meta[name=viewport]"),t=["initial-scale=","minimum-scale=","maximum-scale="],i=["1.0","1.0","1.0"],n=function(e,t){var n=e.getAttribute("content");if(n){for(var r=n.split(","),s="",o=[],a=0;a=0||navigator.userAgent.search("Trident/")>=0||navigator.userAgent.search("Edge/")>=0}},{key:"isRTL",value:function(){return"ar"==this.attributes.language||"he"==this.attributes.language||this.rtl}},{key:"addClass",value:function(e){v.addClass(this.overlay,e),v.addClass(this.titleBar,e),v.addClass(this.overlay,e),v.addClass(this.container,e),v.addClass(this.contentContainer,e),v.addClass(this.stackDiv,e),v.addClass(this.minimizeDiv,e),v.addClass(this.maximizeDiv,e),v.addClass(this.wrapper,e)}},{key:"removeClass",value:function(e){v.removeClass(this.overlay,e),v.removeClass(this.titleBar,e),v.removeClass(this.overlay,e),v.removeClass(this.container,e),v.removeClass(this.contentContainer,e),v.removeClass(this.stackDiv,e),v.removeClass(this.minimizeDiv,e),v.removeClass(this.maximizeDiv,e),v.removeClass(this.wrapper,e)}},{key:"createModalWindowDesktop",value:function(){this.addClass("wrs_modal_desktop"),this.stack()}},{key:"createModalWindowAndroid",value:function(){this.addClass("wrs_modal_android"),window.addEventListener("resize",this.orientationChangeAndroidSoftkeyboard.bind(this))}},{key:"createModalWindowIos",value:function(){this.addClass("wrs_modal_ios"),window.addEventListener("resize",this.orientationChangeIosSoftkeyboard.bind(this))}},{key:"restoreState",value:function(){"maximized"==this.properties.state?this.maximize():"minimized"==this.properties.state?(this.properties.state=this.properties.previousState,this.properties.previousState="",this.minimize()):this.stack()}},{key:"stack",value:function(){this.properties.previousState=this.properties.state,this.properties.state="stack",this.removeClass("wrs_maximized"),this.minimizeDiv.title="Minimise",this.removeClass("wrs_minimized"),this.addClass("wrs_stack"),this.restoreModalProperties(),void 0!==this.resizerBR&&void 0!==this.resizerTL&&this.setResizeButtonsVisibility(),this.recalculateScrollBar(),this.recalculatePosition(),this.recalculateScale(),this.focus()}},{key:"minimize",value:function(){this.saveModalProperties(),"minimized"==this.properties.state&&"stack"==this.properties.previousState?this.stack():"minimized"==this.properties.state&&"maximized"==this.properties.previousState?this.maximize():(this.container.style.height="30px",this.container.style.width="250px",this.container.style.bottom="0px",this.container.style.right="10px",this.removeListeners(),this.properties.previousState=this.properties.state,this.properties.state="minimized",this.setResizeButtonsVisibility(),this.minimizeDiv.title="Maximise",v.containsClass(this.overlay,"wrs_stack")?this.removeClass("wrs_stack"):this.removeClass("wrs_maximized"),this.addClass("wrs_minimized"))}},{key:"maximize",value:function(){this.saveModalProperties(),"maximized"!=this.properties.state&&(this.properties.previousState=this.properties.state,this.properties.state="maximized"),this.setResizeButtonsVisibility(),v.containsClass(this.overlay,"wrs_minimized")?(this.minimizeDiv.title="Minimise",this.removeClass("wrs_minimized")):v.containsClass(this.overlay,"wrs_stack")&&(this.container.style.left=null,this.container.style.top=null,this.removeClass("wrs_stack")),this.addClass("wrs_maximized"),this.setSize(parseInt(.8*window.innerHeight),parseInt(.8*window.innerWidth));this.container.clientHeight>700&&(this.container.style.height="700px"),this.container.clientWidth>1200&&(this.container.style.width="1200px"),this.setPosition(window.innerHeight/2-this.container.offsetHeight/2,window.innerWidth/2-this.container.offsetWidth/2),this.recalculateScale(),this.recalculatePosition(),this.recalculateSize(),this.focus()}},{key:"setSize",value:function(e,t){this.container.style.height=e+"px",this.container.style.width=t+"px",this.recalculateSize()}},{key:"setPosition",value:function(e,t){this.container.style.bottom=e+"px",this.container.style.right=t+"px"}},{key:"saveModalProperties",value:function(){"stack"==this.properties.state&&(this.properties.position.bottom=parseInt(this.container.style.bottom),this.properties.position.right=parseInt(this.container.style.right),this.properties.size.width=parseInt(this.container.style.width),this.properties.size.height=parseInt(this.container.style.height))}},{key:"restoreModalProperties",value:function(){"stack"==this.properties.state&&(this.setPosition(this.properties.position.bottom,this.properties.position.right),this.setSize(this.properties.size.height,this.properties.size.width))}},{key:"recalculateSize",value:function(){this.wrapper.style.width=this.container.clientWidth-12+"px",this.wrapper.style.height=this.container.clientHeight-38+"px",this.contentContainer.style.height=parseInt(this.wrapper.offsetHeight-50)+"px"}},{key:"setResizeButtonsVisibility",value:function(){"stack"==this.properties.state?(this.resizerTL.style.visibility="visible",this.resizerBR.style.visibility="visible"):(this.resizerTL.style.visibility="hidden",this.resizerBR.style.visibility="hidden")}},{key:"addListeners",value:function(){this.maximizeDiv.addEventListener("click",this.maximize.bind(this),!0),this.stackDiv.addEventListener("click",this.stack.bind(this),!0),this.minimizeDiv.addEventListener("click",this.minimize.bind(this),!0),this.closeDiv.addEventListener("click",this.cancelAction.bind(this)),this.overlay.addEventListener("click",this.cancelAction.bind(this)),v.addEvent(window,"mousedown",this.startDrag.bind(this)),v.addEvent(window,"mouseup",this.stopDrag.bind(this)),v.addEvent(window,"mousemove",this.drag.bind(this)),v.addEvent(window,"resize",this.onWindowResize.bind(this)),v.addEvent(window,"keydown",this.onKeyDown.bind(this))}},{key:"removeListeners",value:function(){v.removeEvent(window,"mousedown",this.startDrag),v.removeEvent(window,"mouseup",this.stopDrag),v.removeEvent(window,"mousemove",this.drag),v.removeEvent(window,"resize",this.onWindowResize),v.removeEvent(window,"keydown",this.onKeyDown)}},{key:"eventClient",value:function(e){if(void 0===e.clientX&&e.changedTouches){var t={X:e.changedTouches[0].clientX,Y:e.changedTouches[0].clientY};return t}return t={X:e.clientX,Y:e.clientY}}},{key:"startDrag",value:function(e){"minimized"!=this.properties.state&&e.target===this.title&&(void 0!==this.dragDataObject&&null!==this.dragDataObject||(e=e||event,this.dragDataObject={x:this.eventClient(e).X,y:this.eventClient(e).Y},this.lastDrag={x:"0px",y:"0px"},""==this.container.style.right&&(this.container.style.right="0px"),""==this.container.style.bottom&&(this.container.style.bottom="0px"),this.isIE11(),v.addClass(document.body,"wrs_noselect"),v.addClass(this.overlay,"wrs_overlay_active"),this.limitWindow=this.getLimitWindow()))}},{key:"drag",value:function(e){if(this.dragDataObject){e.preventDefault(),e=e||event;var t=Math.min(this.eventClient(e).Y,this.limitWindow.minPointer.y);t=Math.max(this.limitWindow.maxPointer.y,t);var i=Math.min(this.eventClient(e).X,this.limitWindow.minPointer.x),n=(i=Math.max(this.limitWindow.maxPointer.x,i))-this.dragDataObject.x+"px",r=t-this.dragDataObject.y+"px";this.lastDrag={x:n,y:r},this.container.style.transform="translate3d("+n+","+r+",0)"}if(this.resizeDataObject){var s;i=Math.min(this.eventClient(e).X,window.innerWidth-this.scrollbarWidth-7),t=Math.min(this.eventClient(e).Y,window.innerHeight-7);i<0&&(i=0),t<0&&(t=0),s=this.leftScale?-1:1,this.container.style.width=this.initialWidth+s*(i-this.resizeDataObject.x)+"px",this.container.style.height=this.initialHeight+s*(t-this.resizeDataObject.y)+"px",this.leftScale||(this.resizeDataObject.x-i-this.initialWidth<-580?this.container.style.right=this.initialRight-(i-this.resizeDataObject.x)+"px":(this.container.style.right=this.initialRight+this.initialWidth-580+"px",this.container.style.width="580px"),this.resizeDataObject.y-t580?(this.container.style.width=Math.min(parseInt(this.container.style.width),window.innerWidth-this.scrollbarWidth)+"px",e=!0):(this.container.style.width="580px",e=!0),parseInt(this.container.style.height)>338?(this.container.style.height=Math.min(parseInt(this.container.style.height),window.innerHeight)+"px",e=!0):(this.container.style.height="338px",e=!0),e&&this.recalculateSize()}},{key:"recalculateScrollBar",value:function(){this.hasScrollBar=window.innerWidth>document.documentElement.clientWidth,this.hasScrollBar?this.scrollbarWidth=this.getScrollBarWidth():this.scrollbarWidth=0}},{key:"hideKeyboard",value:function(){document.activeElement.blur()}},{key:"focus",value:function(){null!=this.contentManager&&void 0!==this.contentManager.onFocus&&this.contentManager.onFocus()}},{key:"portraitMode",value:function(){return window.innerHeight>window.innerWidth}},{key:"handleOpenedIosSoftkeyboard",value:function(){this.iosSoftkeyboardOpened||null==this.iosDivHeight||this.iosDivHeight!="100"+this.iosMeasureUnit||(this.portraitMode()?this.setContainerHeight("63"+this.iosMeasureUnit):this.setContainerHeight("40"+this.iosMeasureUnit)),this.iosSoftkeyboardOpened=!0}},{key:"handleClosedIosSoftkeyboard",value:function(){this.iosSoftkeyboardOpened=!1,this.setContainerHeight("100"+this.iosMeasureUnit)}},{key:"orientationChangeIosSoftkeyboard",value:function(){this.iosSoftkeyboardOpened?this.portraitMode()?this.setContainerHeight("63"+this.iosMeasureUnit):this.setContainerHeight("40"+this.iosMeasureUnit):this.setContainerHeight("100"+this.iosMeasureUnit)}},{key:"orientationChangeAndroidSoftkeyboard",value:function(){this.setContainerHeight("100%")}},{key:"setContainerHeight",value:function(e){this.iosDivHeight=e,this.wrapper.style.height=e}},{key:"showPopUpMessage",value:function(){"minimized"==this.properties.state&&this.stack(),this.popup.show()}},{key:"setTitle",value:function(e){this.title.innerHTML=e}},{key:"getElementId",value:function(e){return e+"["+this.instanceId+"]"}}]),e}();function I(e){return(I="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function P(e,t){for(var i=0;i=4;){v.readInt32(e);var t=v.readInt32(e);if(1229472850==t){var i=v.readInt32(e),n=v.readInt32(e);v.readInt32(e),v.readByte(e)}else if(1650545477==t)var r=v.readInt32(e);else if(1883789683==t){var s=v.readInt32(e);s=Math.round(s/39.37),v.readInt32(e),v.readByte(e)}v.readInt32(e)}if(void 0!==i){var o=new Array;return o.cw=i,o.ch=n,o.dpi=s,r&&(o.cb=r),o}}}]),e}();function T(e,t){for(var i=0;i"),m=c.substring(0,f),p=m.split(" width=").join(' class="Wiriscas" width=');c=(c=c.split(m).join(p)).split("'").join('"')}}var b='';t=t.substring(0,n[a].start+s)+b+t.substring(n[a].end+s),s+=b.length-(n[a].end-n[a].start)}}return t}},{key:"initParseEditMode",value:function(e){if(-1!=l.get("parseModes").indexOf("latex"))for(var t=v.getElementsByNameFromString(e,"img",!0),i='encoding="LaTeX">',n=0,r=0;r",d),m=h.substring(d,f),g="$$"+v.htmlEntitiesDecode(m)+"$$";e=e.substring(0,t[r].start+n)+g+e.substring(t[r].end+n),n+=g.length-(t[r].end-t[r].start)}}}}return e}},{key:"endParse",value:function(t){var i=e.endParseEditMode(t);return e.endParseSaveMode(i)}},{key:"endParseEditMode",value:function(e){if(-1!=l.get("parseModes").indexOf("latex")){for(var t="",i=0,n=e.indexOf("$$");-1!=n;){if(t+=e.substring(i,n),-1!=(i=e.indexOf("$$",n+2))){var r=e.substring(n+2,i),s=v.htmlEntitiesDecode(r),a=g.getMathMLFromLatex(s,!0);l.get("saveHandTraces")||(a=o.removeAnnotation(a,"application/json")),t+=a,i+=2}else t+="$$",i=n+2;n=e.indexOf("$$",i)}e=t+=e.substring(i,e.length)}return e}},{key:"endParseSaveMode",value:function(t){return l.get("saveMode")&&("safeXml"==l.get("saveMode")?t=e.codeImgTransform(t,"img2mathml"):"xml"==l.get("saveMode")?t=e.codeImgTransform(t,"img2mathml"):"base64"==l.get("saveMode")&&"image"==l.get("editMode")&&(t=e.codeImgTransform(t,"img264"))),t}},{key:"createShowImageSrc",value:function(e,t){var i=[],n="mml,color,centerbaseline,zoom,dpi,fontSize,fontFamily,defaultStretchy,backgroundColor,format".split(",");for(var r in n){var s=n[r];void 0!==e[s]&&(i[s]=e[s])}var o={};for(var r in e)"mml"!=r&&(o[r]=e[r]);return o.formula=com.wiris.js.JsPluginTools.md5encode(v.propertiesToString(i)),o.lang=void 0===t?"en":t,o.version=l.get("version"),f.getService("showimage",v.httpBuildQuery(o),!0)}},{key:"codeImgTransform",value:function(t,i){for(var n="",r=0,s=/"==h&&(r=u+1);++u}if(r",u):c.length,o.isMathmlInAttribute(t,u)||-1!=d)s+=t.substring(u,h);else{var f=t.substring(u,h);f=i==r.safeXmlCharacters?o.safeXmlDecode(f):o.mathMLEntities(f),s+=v.createObjectCode(e.mathmlToImgObject(document,f,null,n))}u=t.indexOf(a,h)}return s+=t.substring(h,t.length)}}]),e}();if("undefined"!=typeof MutationObserver){var D=new MutationObserver(function(e){e.forEach(function(e){e.oldValue===l.get("imageClassName")&&"class"===e.attributeName&&-1==e.target.className.indexOf(l.get("imageClassName"))&&(e.target.className=l.get("imageClassName"))})});B.observer=Object.create(D),B.observer.Config={attributes:!0,attributeOldValue:!0},B.observer.observe=function(e){this.__proto__.observe(e,this.Config)}}function R(e,t){for(var i=0;i=0&&(t=e[i].src.substr(0,n-1))}return t}},{key:"setLanguage",value:function(e){this.language=e}},{key:"setCore",value:function(e){this.core=e,e.setIntegrationModel(this)}},{key:"getCore",value:function(){return this.core}},{key:"setTarget",value:function(e){this.target=e,this.isIframe="IFRAME"===this.target.tagName.toUpperCase()}},{key:"setEditorObject",value:function(e){this.editorObject=e}},{key:"openNewFormulaEditor",value:function(){this.core.editionProperties.isNewElement=!0,this.core.openModalDialog(this.target,this.isIframe)}},{key:"openExistingFormulaEditor",value:function(){this.core.editionProperties.isNewElement=!1,this.core.openModalDialog(this.target,this.isIframe)}},{key:"updateFormula",value:function(e){this.isIframe?this.core.updateFormula(this.target.contentWindow,this.target.contentWindow,e,null):this.core.updateFormula(this.target,window,e,null)}},{key:"getSelection",value:function(){return this.isIframe?(this.target.contentWindow.focus(),this.target.contentWindow.getSelection()):(this.target.focus(),window.getSelection())}},{key:"addEvents",value:function(){var e=this.isIframe?this.target.contentWindow.document:this.target;v.addElementEvents(e,function(e,t){this.doubleClickHandler(e,t)}.bind(this),function(e,t){this.mousedownHandler(e,t)}.bind(this),function(e,t){this.mouseupHandler(e,t)}.bind(this))}},{key:"doubleClickHandler",value:function(e){if("img"==e.nodeName.toLowerCase()){if(this.core.getCustomEditors().disable(),e.hasAttribute("data-custom-editor")){var t=e.getAttribute("data-custom-editor");this.core.getCustomEditors().enable(t)}v.containsClass(e,l.get("imageClassName"))&&(this.core.editionProperties.temporalImage=e,this.core.editionProperties.isNewElement=!0,this.openExistingFormulaEditor())}}},{key:"mouseupHandler",value:function(){this.temporalImageResizing&&setTimeout(function(){A.fixAfterResize(this.temporalImageResizing)}.bind(this),10)}},{key:"mousedownHandler",value:function(e){"img"==e.nodeName.toLowerCase()&&v.containsClass(e,l.get("imageClassName"))&&(this.temporalImageResizing=e)}},{key:"getLanguage",value:function(){return this.getBrowserLanguage()}},{key:"getBrowserLanguage",value:function(){return navigator.userLanguage?navigator.userLanguage.substring(0,2):navigator.language?navigator.language.substring(0,2):"en"}},{key:"callbackFunction",value:function(){var e=y.newListener("onTargetReady",function(){this.addEvents(this.target)}.bind(this));this.listeners.add(e)}},{key:"notifyWindowClosed",value:function(){}},{key:"getMathmlFromTextNode",value:function(e,t){}},{key:"fillNonLatexNode",value:function(e,t,i){}},{key:"getSelectedItem",value:function(e,t){}}]),e}();function J(e,t){for(var i=0;i=0?"EDGE":e.search("Chrome/")>=0?"CHROME":e.search("Trident/")>=0?"IE":e.search("Firefox/")>=0?"FIREFOX":e.search("Safari/")>=0?"SAFARI":void 0}(),this.listeners=new y}return function(e,t,i){t&&J(e.prototype,t),i&&J(e,i)}(e,[{key:"init",value:function(e){this.load(e)}},{key:"setIntegrationModel",value:function(e){this.integrationModel=e}},{key:"setEnvironment",value:function(e){"editor"in e&&(this.environment.editor=e.editor),"mode"in e&&(this.environment.mode=e.mode),"version"in e&&(this.environment.version=e.version)}},{key:"getModalDialog",value:function(){return this.modalDialog}},{key:"load",value:function(t){var i="undefined"!=typeof XMLHttpRequest?new XMLHttpRequest:new ActiveXObject("Microsoft.XMLHTTP");this.integrationPath=0==t.indexOf("/")||0==t.indexOf("http")?t:v.concatenateUrl(this.integrationModel.getPath(),t),i.open("GET",this.integrationPath,!1),i.onload=function(t){var n=this;if(4===i.readyState){var r=JSON.parse(i.responseText);Object.keys(r);if(l.addConfiguration(r),l.addConfiguration(H),this.loadServicePaths(),this.loadLangFile(),this.loadCSS(),null===e.stringManager){var s=y.newListener("onLoad",function(){n.listeners.fire("onLoad",{})});e.stringManager.addListener(s)}else this.listeners.fire("onLoad",{})}}.bind(this),i.send(null)}},{key:"loadServicePaths",value:function(){var e=this.integrationPath.replace("configurationjs","createimage"),t=this.integrationPath.replace("configurationjs","showimage"),i=(e=this.integrationPath.replace("configurationjs","createimage"),this.integrationPath.replace("configurationjs","getmathml")),n=this.integrationPath.replace("configurationjs","service");if(0==this.integrationPath.indexOf("/")){var r=this.getServerPath();t=r+t,e=r+e,i=r+i,n=r+n}f.setServicePath("showimage",t),f.setServicePath("createimage",e),f.setServicePath("service",n),f.setServicePath("getmathml",i)}},{key:"getServerPath",value:function(){var e=this.integrationModel.getPath(),t=e.indexOf("/",e.indexOf("/")+2);return e.substr(0,t)}},{key:"loadLangFile",value:function(){var t="ar,ca,cs,da,de,en,es,et,eu,fi,fr,gl,he,hr,hu,it,ja,ko,nl,no,pl,pt,pt_br,ru,sv,tr,zh,el".split(","),i=this.language;-1==t.indexOf(i)&&(i=i.substr(0,2)),-1==t.indexOf(i)&&(i="en");var n=document.createElement("script");n.type="text/javascript",n.src=this.integrationModel.getPath()+"/"+this.integrationModel.langFolderName+"/"+i+"/strings.js",n.onload=function(){e.getStringManager().loadStrings(wrs_strings)},document.getElementsByTagName("head")[0].appendChild(n)}},{key:"loadCSS",value:function(){var e=document.createElement("link");e.setAttribute("rel","stylesheet"),e.setAttribute("type","text/css"),e.setAttribute("href",v.concatenateUrl(this.integrationModel.getPath(),"/core/styles.css")),document.getElementsByTagName("head")[0].appendChild(e)}},{key:"addListener",value:function(e){this.listeners.add(e)}},{key:"updateFormula",value:function(t,i,n,r){var s=new F;for(var o in s.mathml=n,s.wirisProperties={},r)s.wirisProperties[o]=r[o];if(s.language=this.language,s.editMode=this.editMode,!this.listeners.fire("onBeforeFormulaInsertion",s)&&!e.globalListeners.fire("onBeforeFormulaInsertion",s)){n=s.mathml,r=s.wirisProperties;var a=new F;if(a.editMode=this.editMode,a.windowTarget=i,a.focusElement=t,n)if("latex"==this.editMode)a.latex=g.getLatexFromMathML(n),this.integrationModel.fillNonLatexNode&&!a.latex?this.integrationModel.fillNonLatexNode(a,i,n):a.node=i.document.createTextNode("$$"+a.latex+"$$"),this.insertElementOnSelection(a.node,t,i);else if("iframes"==this.editMode){var l=wrs_mathmlToIframeObject(i,n);this.insertElementOnSelection(l,t,i)}else a.node=B.mathmlToImgObject(i.document,n,r,this.language),this.insertElementOnSelection(a.node,t,i);else this.insertElementOnSelection(null,t,i);this.listeners.fire("onAfterFormulaInsertion",a)||e.globalListeners.fire("onAfterFormulaInsertion",a)}}},{key:"placeCaretAfterNode",value:function(e){this.integrationModel.getSelection();var t=e.ownerDocument;if(void 0!==t.getSelection&&e.parentElement){var i=t.createRange();i.setStartAfter(e),i.collapse(!0);var n=t.getSelection();n.removeAllRanges(),n.addRange(i),t.body.focus()}}},{key:"insertElementOnSelection",value:function(e,t,i){if(this.editionProperties.isNewElement)if(e)if("textarea"==t.type)v.updateTextArea(t,e.textContent);else if(document.selection&&0==document.getSelection){var n=i.document.selection.createRange();if(i.document.execCommand("InsertImage",!1,e.src),"parentElement"in n||(i.document.execCommand("delete",!1),n=i.document.selection.createRange(),i.document.execCommand("InsertImage",!1,e.src)),"parentElement"in n){var r=n.parentElement();"IMG"==r.nodeName.toUpperCase()?r.parentNode.replaceChild(e,r):n.pasteHTML(v.createObjectCode(e))}}else{var s,o=this.integrationModel.getSelection();this.editionProperties.range?(s=this.editionProperties.range,this.editionProperties.range=null):s=o.getRangeAt(0),s.deleteContents();var a=s.startContainer,l=s.startOffset;3==a.nodeType?(a=a.splitText(l)).parentNode.insertBefore(e,a):1==a.nodeType&&a.insertBefore(e,a.childNodes[l]),this.placeCaretAfterNode(e)}else if("textarea"==t.type)t.focus();else{var c=this.integrationModel.getSelection();if(c.removeAllRanges(),this.editionProperties.range){var u=this.editionProperties.range;this.editionProperties.range=null,c.addRange(u)}}else if(this.editionProperties.latexRange)document.selection&&0==document.getSelection?(this.editionProperties.isNewElement=!0,this.editionProperties.latexRange.select(),this.insertElementOnSelection(e,t,i)):(this.editionProperties.latexRange.deleteContents(),this.editionProperties.latexRange.insertNode(e),this.placeCaretAfterNode(e));else if("textarea"==t.type){var h;h=void 0!==this.integrationModel.getSelectedItem?this.integrationModel.getSelectedItem(t,!1):v.getSelectedItemOnTextarea(t),v.updateExistingTextOnTextarea(t,e.textContent,h.startPosition,h.endPosition)}else e&&"img"===e.nodeName.toLowerCase()?A.clone(e,this.editionProperties.temporalImage):this.editionProperties.temporalImage.remove(),this.placeCaretAfterNode(this.editionProperties.temporalImage)}},{key:"openModalDialog",value:function(e,t){this.editMode="images";try{if(t){e.contentWindow.focus();var i=e.contentWindow.getSelection();this.editionProperties.range=i.getRangeAt(0)}else{e.focus();var n=getSelection();this.editionProperties.range=n.getRangeAt(0)}}catch(e){this.editionProperties.range=null}var r;if(void 0===t&&(t=!0),this.editionProperties.latexRange=null,e)if(r=void 0!==this.integrationModel.getSelectedItem?this.integrationModel.getSelectedItem(e,t):v.getSelectedItem(e,t)){if(!r.caretPosition&&v.containsClass(r.node,l.get("imageClassName")))this.editionProperties.temporalImage=r.node,this.editionProperties.isNewElement=!1;else if(3===r.node.nodeType)if(this.integrationModel.getMathmlFromTextNode){var s=this.integrationModel.getMathmlFromTextNode(r.node,r.caretPosition);s&&(this.editMode="latex",this.editionProperties.isNewElement=!1,this.editionProperties.temporalImage=document.createElement("img"),this.editionProperties.temporalImage.setAttribute(l.get("imageMathmlAttribute"),o.safeXmlEncode(s)))}else{var a=g.getLatexFromTextNode(r.node,r.caretPosition);if(a){var c=g.getMathMLFromLatex(a.latex);this.editMode="latex",this.editionProperties.isNewElement=!1,this.editionProperties.temporalImage=document.createElement("img"),this.editionProperties.temporalImage.setAttribute(l.get("imageMathmlAttribute"),o.safeXmlEncode(c));var u=t?e.contentWindow:window;if("textarea"!==e.tagName.toLowerCase())if(document.selection){for(var h=0,d=a.startNode.previousSibling;d;)h+=v.getNodeLength(d),d=d.previousSibling;this.editionProperties.latexRange=u.document.selection.createRange(),this.editionProperties.latexRange.moveToElementText(a.startNode.parentNode),this.editionProperties.latexRange.move("character",h+a.startPosition),this.editionProperties.latexRange.moveEnd("character",a.latex.length+4)}else this.editionProperties.latexRange=u.document.createRange(),this.editionProperties.latexRange.setStart(a.startNode,a.startPosition),this.editionProperties.latexRange.setEnd(a.endNode,a.endPosition)}}}else"textarea"===e.tagName.toLowerCase()&&(this.editMode="latex");for(var f=l.get("editorAttributes").split(", "),m={},p=0,b=f.length;p=i)){var r,s=t.charCodeAt(n);return s>=55296&&s<=56319&&i>n+1&&(r=t.charCodeAt(n+1))>=56320&&r<=57343?1024*(s-55296)+r-56320+65536:s}};Object.defineProperty?Object.defineProperty(String.prototype,"codePointAt",{value:e,configurable:!0,writable:!0}):String.prototype.codePointAt=e}(),"function"!=typeof Object.assign&&Object.defineProperty(Object,"assign",{value:function(e,t){if(null==e)throw new TypeError("Cannot convert undefined or null to object");for(var i=Object(e),n=1;n=i)){var r,s=t.charCodeAt(n);return s>=55296&&s<=56319&&i>n+1&&(r=t.charCodeAt(n+1))>=56320&&r<=57343?1024*(s-55296)+r-56320+65536:s}};Object.defineProperty?Object.defineProperty(String.prototype,"codePointAt",{value:e,configurable:!0,writable:!0}):String.prototype.codePointAt=e}(),"function"!=typeof Object.assign&&Object.defineProperty(Object,"assign",{value:function(e,t){if(null==e)throw new TypeError("Cannot convert undefined or null to object");for(var i=Object(e),n=1;n