tinymce
Version:
Web based JavaScript HTML WYSIWYG editor control.
1,660 lines (1,618 loc) • 1.04 MB
JavaScript
/**
* Copyright (c) Tiny Technologies, Inc. All rights reserved.
* Licensed under the LGPL or a commercial license.
* For LGPL see License.txt in the project root for license information.
* For commercial licenses see https://www.tiny.cloud/
*
* Version: 5.3.1 (2020-05-27)
*/
(function (domGlobals) {
'use strict';
var typeOf = function (x) {
if (x === null) {
return 'null';
}
if (x === undefined) {
return 'undefined';
}
var t = typeof x;
if (t === 'object' && (Array.prototype.isPrototypeOf(x) || x.constructor && x.constructor.name === 'Array')) {
return 'array';
}
if (t === 'object' && (String.prototype.isPrototypeOf(x) || x.constructor && x.constructor.name === 'String')) {
return 'string';
}
return t;
};
var isEquatableType = function (x) {
return [
'undefined',
'boolean',
'number',
'string',
'function',
'xml',
'null'
].indexOf(x) !== -1;
};
var sort = function (xs, compareFn) {
var clone = Array.prototype.slice.call(xs);
return clone.sort(compareFn);
};
var contramap = function (eqa, f) {
return eq(function (x, y) {
return eqa.eq(f(x), f(y));
});
};
var eq = function (f) {
return { eq: f };
};
var tripleEq = eq(function (x, y) {
return x === y;
});
var eqString = tripleEq;
var eqArray = function (eqa) {
return eq(function (x, y) {
if (x.length !== y.length) {
return false;
}
var len = x.length;
for (var i = 0; i < len; i++) {
if (!eqa.eq(x[i], y[i])) {
return false;
}
}
return true;
});
};
var eqSortedArray = function (eqa, compareFn) {
return contramap(eqArray(eqa), function (xs) {
return sort(xs, compareFn);
});
};
var eqRecord = function (eqa) {
return eq(function (x, y) {
var kx = Object.keys(x);
var ky = Object.keys(y);
if (!eqSortedArray(eqString).eq(kx, ky)) {
return false;
}
var len = kx.length;
for (var i = 0; i < len; i++) {
var q = kx[i];
if (!eqa.eq(x[q], y[q])) {
return false;
}
}
return true;
});
};
var eqAny = eq(function (x, y) {
if (x === y) {
return true;
}
var tx = typeOf(x);
var ty = typeOf(y);
if (tx !== ty) {
return false;
}
if (isEquatableType(tx)) {
return x === y;
} else if (tx === 'array') {
return eqArray(eqAny).eq(x, y);
} else if (tx === 'object') {
return eqRecord(eqAny).eq(x, y);
}
return false;
});
var noop = function () {
};
var compose = function (fa, fb) {
return function () {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
return fa(fb.apply(null, args));
};
};
var constant = function (value) {
return function () {
return value;
};
};
var identity = function (x) {
return x;
};
function curry(fn) {
var initialArgs = [];
for (var _i = 1; _i < arguments.length; _i++) {
initialArgs[_i - 1] = arguments[_i];
}
return function () {
var restArgs = [];
for (var _i = 0; _i < arguments.length; _i++) {
restArgs[_i] = arguments[_i];
}
var all = initialArgs.concat(restArgs);
return fn.apply(null, all);
};
}
var not = function (f) {
return function (t) {
return !f(t);
};
};
var die = function (msg) {
return function () {
throw new Error(msg);
};
};
var never = constant(false);
var always = constant(true);
var none = function () {
return NONE;
};
var NONE = function () {
var eq = function (o) {
return o.isNone();
};
var call = function (thunk) {
return thunk();
};
var id = function (n) {
return n;
};
var me = {
fold: function (n, _s) {
return n();
},
is: never,
isSome: never,
isNone: always,
getOr: id,
getOrThunk: call,
getOrDie: function (msg) {
throw new Error(msg || 'error: getOrDie called on none.');
},
getOrNull: constant(null),
getOrUndefined: constant(undefined),
or: id,
orThunk: call,
map: none,
each: noop,
bind: none,
exists: never,
forall: always,
filter: none,
equals: eq,
equals_: eq,
toArray: function () {
return [];
},
toString: constant('none()')
};
return me;
}();
var some = function (a) {
var constant_a = constant(a);
var self = function () {
return me;
};
var bind = function (f) {
return f(a);
};
var me = {
fold: function (n, s) {
return s(a);
},
is: function (v) {
return a === v;
},
isSome: always,
isNone: never,
getOr: constant_a,
getOrThunk: constant_a,
getOrDie: constant_a,
getOrNull: constant_a,
getOrUndefined: constant_a,
or: self,
orThunk: self,
map: function (f) {
return some(f(a));
},
each: function (f) {
f(a);
},
bind: bind,
exists: bind,
forall: bind,
filter: function (f) {
return f(a) ? me : NONE;
},
toArray: function () {
return [a];
},
toString: function () {
return 'some(' + a + ')';
},
equals: function (o) {
return o.is(a);
},
equals_: function (o, elementEq) {
return o.fold(never, function (b) {
return elementEq(a, b);
});
}
};
return me;
};
var from = function (value) {
return value === null || value === undefined ? NONE : some(value);
};
var Option = {
some: some,
none: none,
from: from
};
var typeOf$1 = function (x) {
var t = typeof x;
if (x === null) {
return 'null';
} else if (t === 'object' && (Array.prototype.isPrototypeOf(x) || x.constructor && x.constructor.name === 'Array')) {
return 'array';
} else if (t === 'object' && (String.prototype.isPrototypeOf(x) || x.constructor && x.constructor.name === 'String')) {
return 'string';
} else {
return t;
}
};
var isType = function (type) {
return function (value) {
return typeOf$1(value) === type;
};
};
var isSimpleType = function (type) {
return function (value) {
return typeof value === type;
};
};
var eq$1 = function (t) {
return function (a) {
return t === a;
};
};
var isString = isType('string');
var isObject = isType('object');
var isArray = isType('array');
var isNull = eq$1(null);
var isBoolean = isSimpleType('boolean');
var isUndefined = eq$1(undefined);
var isFunction = isSimpleType('function');
var isNumber = isSimpleType('number');
var nativeSlice = Array.prototype.slice;
var nativeIndexOf = Array.prototype.indexOf;
var nativePush = Array.prototype.push;
var rawIndexOf = function (ts, t) {
return nativeIndexOf.call(ts, t);
};
var indexOf = function (xs, x) {
var r = rawIndexOf(xs, x);
return r === -1 ? Option.none() : Option.some(r);
};
var contains = function (xs, x) {
return rawIndexOf(xs, x) > -1;
};
var exists = function (xs, pred) {
for (var i = 0, len = xs.length; i < len; i++) {
var x = xs[i];
if (pred(x, i)) {
return true;
}
}
return false;
};
var map = function (xs, f) {
var len = xs.length;
var r = new Array(len);
for (var i = 0; i < len; i++) {
var x = xs[i];
r[i] = f(x, i);
}
return r;
};
var each = function (xs, f) {
for (var i = 0, len = xs.length; i < len; i++) {
var x = xs[i];
f(x, i);
}
};
var eachr = function (xs, f) {
for (var i = xs.length - 1; i >= 0; i--) {
var x = xs[i];
f(x, i);
}
};
var partition = function (xs, pred) {
var pass = [];
var fail = [];
for (var i = 0, len = xs.length; i < len; i++) {
var x = xs[i];
var arr = pred(x, i) ? pass : fail;
arr.push(x);
}
return {
pass: pass,
fail: fail
};
};
var filter = function (xs, pred) {
var r = [];
for (var i = 0, len = xs.length; i < len; i++) {
var x = xs[i];
if (pred(x, i)) {
r.push(x);
}
}
return r;
};
var foldr = function (xs, f, acc) {
eachr(xs, function (x) {
acc = f(acc, x);
});
return acc;
};
var foldl = function (xs, f, acc) {
each(xs, function (x) {
acc = f(acc, x);
});
return acc;
};
var findUntil = function (xs, pred, until) {
for (var i = 0, len = xs.length; i < len; i++) {
var x = xs[i];
if (pred(x, i)) {
return Option.some(x);
} else if (until(x, i)) {
break;
}
}
return Option.none();
};
var find = function (xs, pred) {
return findUntil(xs, pred, never);
};
var findIndex = function (xs, pred) {
for (var i = 0, len = xs.length; i < len; i++) {
var x = xs[i];
if (pred(x, i)) {
return Option.some(i);
}
}
return Option.none();
};
var flatten = function (xs) {
var r = [];
for (var i = 0, len = xs.length; i < len; ++i) {
if (!isArray(xs[i])) {
throw new Error('Arr.flatten item ' + i + ' was not an array, input: ' + xs);
}
nativePush.apply(r, xs[i]);
}
return r;
};
var bind = function (xs, f) {
return flatten(map(xs, f));
};
var forall = function (xs, pred) {
for (var i = 0, len = xs.length; i < len; ++i) {
var x = xs[i];
if (pred(x, i) !== true) {
return false;
}
}
return true;
};
var reverse = function (xs) {
var r = nativeSlice.call(xs, 0);
r.reverse();
return r;
};
var difference = function (a1, a2) {
return filter(a1, function (x) {
return !contains(a2, x);
});
};
var mapToObject = function (xs, f) {
var r = {};
for (var i = 0, len = xs.length; i < len; i++) {
var x = xs[i];
r[String(x)] = f(x, i);
}
return r;
};
var sort$1 = function (xs, comparator) {
var copy = nativeSlice.call(xs, 0);
copy.sort(comparator);
return copy;
};
var head = function (xs) {
return xs.length === 0 ? Option.none() : Option.some(xs[0]);
};
var last = function (xs) {
return xs.length === 0 ? Option.none() : Option.some(xs[xs.length - 1]);
};
var from$1 = isFunction(Array.from) ? Array.from : function (x) {
return nativeSlice.call(x);
};
var keys = Object.keys;
var hasOwnProperty = Object.hasOwnProperty;
var each$1 = function (obj, f) {
var props = keys(obj);
for (var k = 0, len = props.length; k < len; k++) {
var i = props[k];
var x = obj[i];
f(x, i);
}
};
var map$1 = function (obj, f) {
return tupleMap(obj, function (x, i) {
return {
k: i,
v: f(x, i)
};
});
};
var tupleMap = function (obj, f) {
var r = {};
each$1(obj, function (x, i) {
var tuple = f(x, i);
r[tuple.k] = tuple.v;
});
return r;
};
var objAcc = function (r) {
return function (x, i) {
r[i] = x;
};
};
var internalFilter = function (obj, pred, onTrue, onFalse) {
var r = {};
each$1(obj, function (x, i) {
(pred(x, i) ? onTrue : onFalse)(x, i);
});
return r;
};
var bifilter = function (obj, pred) {
var t = {};
var f = {};
internalFilter(obj, pred, objAcc(t), objAcc(f));
return {
t: t,
f: f
};
};
var filter$1 = function (obj, pred) {
var t = {};
internalFilter(obj, pred, objAcc(t), noop);
return t;
};
var mapToArray = function (obj, f) {
var r = [];
each$1(obj, function (value, name) {
r.push(f(value, name));
});
return r;
};
var values = function (obj) {
return mapToArray(obj, function (v) {
return v;
});
};
var get = function (obj, key) {
return has(obj, key) ? Option.from(obj[key]) : Option.none();
};
var has = function (obj, key) {
return hasOwnProperty.call(obj, key);
};
var equal = function (a1, a2, eq) {
if (eq === void 0) {
eq = eqAny;
}
return eqRecord(eq).eq(a1, a2);
};
var __assign = function () {
__assign = Object.assign || function __assign(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s)
if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
function __rest(s, e) {
var t = {};
for (var p in s)
if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
t[p] = s[p];
if (s != null && typeof Object.getOwnPropertySymbols === 'function')
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
t[p[i]] = s[p[i]];
}
return t;
}
function __spreadArrays() {
for (var s = 0, i = 0, il = arguments.length; i < il; i++)
s += arguments[i].length;
for (var r = Array(s), k = 0, i = 0; i < il; i++)
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
r[k] = a[j];
return r;
}
var fromHtml = function (html, scope) {
var doc = scope || domGlobals.document;
var div = doc.createElement('div');
div.innerHTML = html;
if (!div.hasChildNodes() || div.childNodes.length > 1) {
domGlobals.console.error('HTML does not have a single root node', html);
throw new Error('HTML must have a single root node');
}
return fromDom(div.childNodes[0]);
};
var fromTag = function (tag, scope) {
var doc = scope || domGlobals.document;
var node = doc.createElement(tag);
return fromDom(node);
};
var fromText = function (text, scope) {
var doc = scope || domGlobals.document;
var node = doc.createTextNode(text);
return fromDom(node);
};
var fromDom = function (node) {
if (node === null || node === undefined) {
throw new Error('Node cannot be null or undefined');
}
return { dom: constant(node) };
};
var fromPoint = function (docElm, x, y) {
var doc = docElm.dom();
return Option.from(doc.elementFromPoint(x, y)).map(fromDom);
};
var Element = {
fromHtml: fromHtml,
fromTag: fromTag,
fromText: fromText,
fromDom: fromDom,
fromPoint: fromPoint
};
var cached = function (f) {
var called = false;
var r;
return function () {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
if (!called) {
called = true;
r = f.apply(null, args);
}
return r;
};
};
var firstMatch = function (regexes, s) {
for (var i = 0; i < regexes.length; i++) {
var x = regexes[i];
if (x.test(s)) {
return x;
}
}
return undefined;
};
var find$1 = function (regexes, agent) {
var r = firstMatch(regexes, agent);
if (!r) {
return {
major: 0,
minor: 0
};
}
var group = function (i) {
return Number(agent.replace(r, '$' + i));
};
return nu(group(1), group(2));
};
var detect = function (versionRegexes, agent) {
var cleanedAgent = String(agent).toLowerCase();
if (versionRegexes.length === 0) {
return unknown();
}
return find$1(versionRegexes, cleanedAgent);
};
var unknown = function () {
return nu(0, 0);
};
var nu = function (major, minor) {
return {
major: major,
minor: minor
};
};
var Version = {
nu: nu,
detect: detect,
unknown: unknown
};
var edge = 'Edge';
var chrome = 'Chrome';
var ie = 'IE';
var opera = 'Opera';
var firefox = 'Firefox';
var safari = 'Safari';
var unknown$1 = function () {
return nu$1({
current: undefined,
version: Version.unknown()
});
};
var nu$1 = function (info) {
var current = info.current;
var version = info.version;
var isBrowser = function (name) {
return function () {
return current === name;
};
};
return {
current: current,
version: version,
isEdge: isBrowser(edge),
isChrome: isBrowser(chrome),
isIE: isBrowser(ie),
isOpera: isBrowser(opera),
isFirefox: isBrowser(firefox),
isSafari: isBrowser(safari)
};
};
var Browser = {
unknown: unknown$1,
nu: nu$1,
edge: constant(edge),
chrome: constant(chrome),
ie: constant(ie),
opera: constant(opera),
firefox: constant(firefox),
safari: constant(safari)
};
var windows = 'Windows';
var ios = 'iOS';
var android = 'Android';
var linux = 'Linux';
var osx = 'OSX';
var solaris = 'Solaris';
var freebsd = 'FreeBSD';
var chromeos = 'ChromeOS';
var unknown$2 = function () {
return nu$2({
current: undefined,
version: Version.unknown()
});
};
var nu$2 = function (info) {
var current = info.current;
var version = info.version;
var isOS = function (name) {
return function () {
return current === name;
};
};
return {
current: current,
version: version,
isWindows: isOS(windows),
isiOS: isOS(ios),
isAndroid: isOS(android),
isOSX: isOS(osx),
isLinux: isOS(linux),
isSolaris: isOS(solaris),
isFreeBSD: isOS(freebsd),
isChromeOS: isOS(chromeos)
};
};
var OperatingSystem = {
unknown: unknown$2,
nu: nu$2,
windows: constant(windows),
ios: constant(ios),
android: constant(android),
linux: constant(linux),
osx: constant(osx),
solaris: constant(solaris),
freebsd: constant(freebsd),
chromeos: constant(chromeos)
};
var DeviceType = function (os, browser, userAgent, mediaMatch) {
var isiPad = os.isiOS() && /ipad/i.test(userAgent) === true;
var isiPhone = os.isiOS() && !isiPad;
var isMobile = os.isiOS() || os.isAndroid();
var isTouch = isMobile || mediaMatch('(pointer:coarse)');
var isTablet = isiPad || !isiPhone && isMobile && mediaMatch('(min-device-width:768px)');
var isPhone = isiPhone || isMobile && !isTablet;
var iOSwebview = browser.isSafari() && os.isiOS() && /safari/i.test(userAgent) === false;
var isDesktop = !isPhone && !isTablet && !iOSwebview;
return {
isiPad: constant(isiPad),
isiPhone: constant(isiPhone),
isTablet: constant(isTablet),
isPhone: constant(isPhone),
isTouch: constant(isTouch),
isAndroid: os.isAndroid,
isiOS: os.isiOS,
isWebView: constant(iOSwebview),
isDesktop: constant(isDesktop)
};
};
var detect$1 = function (candidates, userAgent) {
var agent = String(userAgent).toLowerCase();
return find(candidates, function (candidate) {
return candidate.search(agent);
});
};
var detectBrowser = function (browsers, userAgent) {
return detect$1(browsers, userAgent).map(function (browser) {
var version = Version.detect(browser.versionRegexes, userAgent);
return {
current: browser.name,
version: version
};
});
};
var detectOs = function (oses, userAgent) {
return detect$1(oses, userAgent).map(function (os) {
var version = Version.detect(os.versionRegexes, userAgent);
return {
current: os.name,
version: version
};
});
};
var UaString = {
detectBrowser: detectBrowser,
detectOs: detectOs
};
var checkRange = function (str, substr, start) {
return substr === '' || str.length >= substr.length && str.substr(start, start + substr.length) === substr;
};
var contains$1 = function (str, substr) {
return str.indexOf(substr) !== -1;
};
var startsWith = function (str, prefix) {
return checkRange(str, prefix, 0);
};
var blank = function (r) {
return function (s) {
return s.replace(r, '');
};
};
var trim = blank(/^\s+|\s+$/g);
var lTrim = blank(/^\s+/g);
var rTrim = blank(/\s+$/g);
var normalVersionRegex = /.*?version\/\ ?([0-9]+)\.([0-9]+).*/;
var checkContains = function (target) {
return function (uastring) {
return contains$1(uastring, target);
};
};
var browsers = [
{
name: 'Edge',
versionRegexes: [/.*?edge\/ ?([0-9]+)\.([0-9]+)$/],
search: function (uastring) {
return contains$1(uastring, 'edge/') && contains$1(uastring, 'chrome') && contains$1(uastring, 'safari') && contains$1(uastring, 'applewebkit');
}
},
{
name: 'Chrome',
versionRegexes: [
/.*?chrome\/([0-9]+)\.([0-9]+).*/,
normalVersionRegex
],
search: function (uastring) {
return contains$1(uastring, 'chrome') && !contains$1(uastring, 'chromeframe');
}
},
{
name: 'IE',
versionRegexes: [
/.*?msie\ ?([0-9]+)\.([0-9]+).*/,
/.*?rv:([0-9]+)\.([0-9]+).*/
],
search: function (uastring) {
return contains$1(uastring, 'msie') || contains$1(uastring, 'trident');
}
},
{
name: 'Opera',
versionRegexes: [
normalVersionRegex,
/.*?opera\/([0-9]+)\.([0-9]+).*/
],
search: checkContains('opera')
},
{
name: 'Firefox',
versionRegexes: [/.*?firefox\/\ ?([0-9]+)\.([0-9]+).*/],
search: checkContains('firefox')
},
{
name: 'Safari',
versionRegexes: [
normalVersionRegex,
/.*?cpu os ([0-9]+)_([0-9]+).*/
],
search: function (uastring) {
return (contains$1(uastring, 'safari') || contains$1(uastring, 'mobile/')) && contains$1(uastring, 'applewebkit');
}
}
];
var oses = [
{
name: 'Windows',
search: checkContains('win'),
versionRegexes: [/.*?windows\ nt\ ?([0-9]+)\.([0-9]+).*/]
},
{
name: 'iOS',
search: function (uastring) {
return contains$1(uastring, 'iphone') || contains$1(uastring, 'ipad');
},
versionRegexes: [
/.*?version\/\ ?([0-9]+)\.([0-9]+).*/,
/.*cpu os ([0-9]+)_([0-9]+).*/,
/.*cpu iphone os ([0-9]+)_([0-9]+).*/
]
},
{
name: 'Android',
search: checkContains('android'),
versionRegexes: [/.*?android\ ?([0-9]+)\.([0-9]+).*/]
},
{
name: 'OSX',
search: checkContains('mac os x'),
versionRegexes: [/.*?mac\ os\ x\ ?([0-9]+)_([0-9]+).*/]
},
{
name: 'Linux',
search: checkContains('linux'),
versionRegexes: []
},
{
name: 'Solaris',
search: checkContains('sunos'),
versionRegexes: []
},
{
name: 'FreeBSD',
search: checkContains('freebsd'),
versionRegexes: []
},
{
name: 'ChromeOS',
search: checkContains('cros'),
versionRegexes: [/.*?chrome\/([0-9]+)\.([0-9]+).*/]
}
];
var PlatformInfo = {
browsers: constant(browsers),
oses: constant(oses)
};
var detect$2 = function (userAgent, mediaMatch) {
var browsers = PlatformInfo.browsers();
var oses = PlatformInfo.oses();
var browser = UaString.detectBrowser(browsers, userAgent).fold(Browser.unknown, Browser.nu);
var os = UaString.detectOs(oses, userAgent).fold(OperatingSystem.unknown, OperatingSystem.nu);
var deviceType = DeviceType(os, browser, userAgent, mediaMatch);
return {
browser: browser,
os: os,
deviceType: deviceType
};
};
var PlatformDetection = { detect: detect$2 };
var mediaMatch = function (query) {
return domGlobals.window.matchMedia(query).matches;
};
var platform = cached(function () {
return PlatformDetection.detect(domGlobals.navigator.userAgent, mediaMatch);
});
var detect$3 = function () {
return platform();
};
var toArray = function (target, f) {
var r = [];
var recurse = function (e) {
r.push(e);
return f(e);
};
var cur = f(target);
do {
cur = cur.bind(recurse);
} while (cur.isSome());
return r;
};
var compareDocumentPosition = function (a, b, match) {
return (a.compareDocumentPosition(b) & match) !== 0;
};
var documentPositionContainedBy = function (a, b) {
return compareDocumentPosition(a, b, domGlobals.Node.DOCUMENT_POSITION_CONTAINED_BY);
};
var COMMENT = 8;
var DOCUMENT = 9;
var ELEMENT = 1;
var TEXT = 3;
var ELEMENT$1 = ELEMENT;
var DOCUMENT$1 = DOCUMENT;
var is = function (element, selector) {
var dom = element.dom();
if (dom.nodeType !== ELEMENT$1) {
return false;
} else {
var elem = dom;
if (elem.matches !== undefined) {
return elem.matches(selector);
} else if (elem.msMatchesSelector !== undefined) {
return elem.msMatchesSelector(selector);
} else if (elem.webkitMatchesSelector !== undefined) {
return elem.webkitMatchesSelector(selector);
} else if (elem.mozMatchesSelector !== undefined) {
return elem.mozMatchesSelector(selector);
} else {
throw new Error('Browser lacks native selectors');
}
}
};
var bypassSelector = function (dom) {
return dom.nodeType !== ELEMENT$1 && dom.nodeType !== DOCUMENT$1 || dom.childElementCount === 0;
};
var all = function (selector, scope) {
var base = scope === undefined ? domGlobals.document : scope.dom();
return bypassSelector(base) ? [] : map(base.querySelectorAll(selector), Element.fromDom);
};
var one = function (selector, scope) {
var base = scope === undefined ? domGlobals.document : scope.dom();
return bypassSelector(base) ? Option.none() : Option.from(base.querySelector(selector)).map(Element.fromDom);
};
var eq$2 = function (e1, e2) {
return e1.dom() === e2.dom();
};
var regularContains = function (e1, e2) {
var d1 = e1.dom();
var d2 = e2.dom();
return d1 === d2 ? false : d1.contains(d2);
};
var ieContains = function (e1, e2) {
return documentPositionContainedBy(e1.dom(), e2.dom());
};
var contains$2 = function (e1, e2) {
return detect$3().browser.isIE() ? ieContains(e1, e2) : regularContains(e1, e2);
};
var owner = function (element) {
return Element.fromDom(element.dom().ownerDocument);
};
var documentElement = function (element) {
return Element.fromDom(element.dom().ownerDocument.documentElement);
};
var defaultView = function (element) {
return Element.fromDom(element.dom().ownerDocument.defaultView);
};
var parent = function (element) {
return Option.from(element.dom().parentNode).map(Element.fromDom);
};
var parents = function (element, isRoot) {
var stop = isFunction(isRoot) ? isRoot : never;
var dom = element.dom();
var ret = [];
while (dom.parentNode !== null && dom.parentNode !== undefined) {
var rawParent = dom.parentNode;
var p = Element.fromDom(rawParent);
ret.push(p);
if (stop(p) === true) {
break;
} else {
dom = rawParent;
}
}
return ret;
};
var siblings = function (element) {
var filterSelf = function (elements) {
return filter(elements, function (x) {
return !eq$2(element, x);
});
};
return parent(element).map(children).map(filterSelf).getOr([]);
};
var prevSibling = function (element) {
return Option.from(element.dom().previousSibling).map(Element.fromDom);
};
var nextSibling = function (element) {
return Option.from(element.dom().nextSibling).map(Element.fromDom);
};
var prevSiblings = function (element) {
return reverse(toArray(element, prevSibling));
};
var nextSiblings = function (element) {
return toArray(element, nextSibling);
};
var children = function (element) {
return map(element.dom().childNodes, Element.fromDom);
};
var child = function (element, index) {
var cs = element.dom().childNodes;
return Option.from(cs[index]).map(Element.fromDom);
};
var firstChild = function (element) {
return child(element, 0);
};
var lastChild = function (element) {
return child(element, element.dom().childNodes.length - 1);
};
var childNodesCount = function (element) {
return element.dom().childNodes.length;
};
var before = function (marker, element) {
var parent$1 = parent(marker);
parent$1.each(function (v) {
v.dom().insertBefore(element.dom(), marker.dom());
});
};
var after = function (marker, element) {
var sibling = nextSibling(marker);
sibling.fold(function () {
var parent$1 = parent(marker);
parent$1.each(function (v) {
append(v, element);
});
}, function (v) {
before(v, element);
});
};
var prepend = function (parent, element) {
var firstChild$1 = firstChild(parent);
firstChild$1.fold(function () {
append(parent, element);
}, function (v) {
parent.dom().insertBefore(element.dom(), v.dom());
});
};
var append = function (parent, element) {
parent.dom().appendChild(element.dom());
};
var wrap = function (element, wrapper) {
before(element, wrapper);
append(wrapper, element);
};
var before$1 = function (marker, elements) {
each(elements, function (x) {
before(marker, x);
});
};
var append$1 = function (parent, elements) {
each(elements, function (x) {
append(parent, x);
});
};
var empty = function (element) {
element.dom().textContent = '';
each(children(element), function (rogue) {
remove(rogue);
});
};
var remove = function (element) {
var dom = element.dom();
if (dom.parentNode !== null) {
dom.parentNode.removeChild(dom);
}
};
var unwrap = function (wrapper) {
var children$1 = children(wrapper);
if (children$1.length > 0) {
before$1(wrapper, children$1);
}
remove(wrapper);
};
var Global = typeof domGlobals.window !== 'undefined' ? domGlobals.window : Function('return this;')();
var name = function (element) {
var r = element.dom().nodeName;
return r.toLowerCase();
};
var type = function (element) {
return element.dom().nodeType;
};
var isType$1 = function (t) {
return function (element) {
return type(element) === t;
};
};
var isComment = function (element) {
return type(element) === COMMENT || name(element) === '#comment';
};
var isElement = isType$1(ELEMENT);
var isText = isType$1(TEXT);
var inBody = function (element) {
var dom = isText(element) ? element.dom().parentNode : element.dom();
return dom !== undefined && dom !== null && dom.ownerDocument.body.contains(dom);
};
var r = function (left, top) {
var translate = function (x, y) {
return r(left + x, top + y);
};
return {
left: constant(left),
top: constant(top),
translate: translate
};
};
var Position = r;
var boxPosition = function (dom) {
var box = dom.getBoundingClientRect();
return Position(box.left, box.top);
};
var firstDefinedOrZero = function (a, b) {
if (a !== undefined) {
return a;
} else {
return b !== undefined ? b : 0;
}
};
var absolute = function (element) {
var doc = element.dom().ownerDocument;
var body = doc.body;
var win = doc.defaultView;
var html = doc.documentElement;
if (body === element.dom()) {
return Position(body.offsetLeft, body.offsetTop);
}
var scrollTop = firstDefinedOrZero(win.pageYOffset, html.scrollTop);
var scrollLeft = firstDefinedOrZero(win.pageXOffset, html.scrollLeft);
var clientTop = firstDefinedOrZero(html.clientTop, body.clientTop);
var clientLeft = firstDefinedOrZero(html.clientLeft, body.clientLeft);
return viewport(element).translate(scrollLeft - clientLeft, scrollTop - clientTop);
};
var viewport = function (element) {
var dom = element.dom();
var doc = dom.ownerDocument;
var body = doc.body;
if (body === dom) {
return Position(body.offsetLeft, body.offsetTop);
}
if (!inBody(element)) {
return Position(0, 0);
}
return boxPosition(dom);
};
var get$1 = function (_DOC) {
var doc = _DOC !== undefined ? _DOC.dom() : domGlobals.document;
var x = doc.body.scrollLeft || doc.documentElement.scrollLeft;
var y = doc.body.scrollTop || doc.documentElement.scrollTop;
return Position(x, y);
};
var to = function (x, y, _DOC) {
var doc = _DOC !== undefined ? _DOC.dom() : domGlobals.document;
var win = doc.defaultView;
win.scrollTo(x, y);
};
var intoView = function (element, alignToTop) {
var isSafari = detect$3().browser.isSafari();
if (isSafari && isFunction(element.dom().scrollIntoViewIfNeeded)) {
element.dom().scrollIntoViewIfNeeded(false);
} else {
element.dom().scrollIntoView(alignToTop);
}
};
var get$2 = function (_win) {
var win = _win === undefined ? domGlobals.window : _win;
return Option.from(win['visualViewport']);
};
var bounds = function (x, y, width, height) {
return {
x: x,
y: y,
width: width,
height: height,
right: x + width,
bottom: y + height
};
};
var getBounds = function (_win) {
var win = _win === undefined ? domGlobals.window : _win;
var doc = win.document;
var scroll = get$1(Element.fromDom(doc));
return get$2(win).fold(function () {
var html = win.document.documentElement;
var width = html.clientWidth;
var height = html.clientHeight;
return bounds(scroll.left(), scroll.top(), width, height);
}, function (visualViewport) {
return bounds(Math.max(visualViewport.pageLeft, scroll.left()), Math.max(visualViewport.pageTop, scroll.top()), visualViewport.width, visualViewport.height);
});
};
var isNodeType = function (type) {
return function (node) {
return !!node && node.nodeType === type;
};
};
var isRestrictedNode = function (node) {
return !!node && !Object.getPrototypeOf(node);
};
var isElement$1 = isNodeType(1);
var matchNodeNames = function (names) {
var lowercasedNames = names.map(function (s) {
return s.toLowerCase();
});
return function (node) {
if (node && node.nodeName) {
var nodeName = node.nodeName.toLowerCase();
return contains(lowercasedNames, nodeName);
}
return false;
};
};
var matchStyleValues = function (name, values) {
var items = values.toLowerCase().split(' ');
return function (node) {
var i, cssValue;
if (isElement$1(node)) {
for (i = 0; i < items.length; i++) {
var computed = node.ownerDocument.defaultView.getComputedStyle(node, null);
cssValue = computed ? computed.getPropertyValue(name) : null;
if (cssValue === items[i]) {
return true;
}
}
}
return false;
};
};
var hasAttribute = function (attrName) {
return function (node) {
return isElement$1(node) && node.hasAttribute(attrName);
};
};
var hasAttributeValue = function (attrName, attrValue) {
return function (node) {
return isElement$1(node) && node.getAttribute(attrName) === attrValue;
};
};
var isBogus = function (node) {
return isElement$1(node) && node.hasAttribute('data-mce-bogus');
};
var isBogusAll = function (node) {
return isElement$1(node) && node.getAttribute('data-mce-bogus') === 'all';
};
var isTable = function (node) {
return isElement$1(node) && node.tagName === 'TABLE';
};
var hasContentEditableState = function (value) {
return function (node) {
if (isElement$1(node)) {
if (node.contentEditable === value) {
return true;
}
if (node.getAttribute('data-mce-contenteditable') === value) {
return true;
}
}
return false;
};
};
var isTextareaOrInput = matchNodeNames([
'textarea',
'input'
]);
var isText$1 = isNodeType(3);
var isComment$1 = isNodeType(8);
var isDocument = isNodeType(9);
var isDocumentFragment = isNodeType(11);
var isBr = matchNodeNames(['br']);
var isContentEditableTrue = hasContentEditableState('true');
var isContentEditableFalse = hasContentEditableState('false');
var isSupported = function (dom) {
return dom.style !== undefined && isFunction(dom.style.getPropertyValue);
};
var rawSet = function (dom, key, value) {
if (isString(value) || isBoolean(value) || isNumber(value)) {
dom.setAttribute(key, value + '');
} else {
domGlobals.console.error('Invalid call to Attr.set. Key ', key, ':: Value ', value, ':: Element ', dom);
throw new Error('Attribute value was not simple');
}
};
var set = function (element, key, value) {
rawSet(element.dom(), key, value);
};
var setAll = function (element, attrs) {
var dom = element.dom();
each$1(attrs, function (v, k) {
rawSet(dom, k, v);
});
};
var get$3 = function (element, key) {
var v = element.dom().getAttribute(key);
return v === null ? undefined : v;
};
var getOpt = function (element, key) {
return Option.from(get$3(element, key));
};
var has$1 = function (element, key) {
var dom = element.dom();
return dom && dom.hasAttribute ? dom.hasAttribute(key) : false;
};
var remove$1 = function (element, key) {
element.dom().removeAttribute(key);
};
var get$4 = function (element, property) {
var dom = element.dom();
var styles = domGlobals.window.getComputedStyle(dom);
var r = styles.getPropertyValue(property);
return r === '' && !inBody(element) ? getUnsafeProperty(dom, property) : r;
};
var getUnsafeProperty = function (dom, property) {
return isSupported(dom) ? dom.style.getPropertyValue(property) : '';
};
var getRaw = function (element, property) {
var dom = element.dom();
var raw = getUnsafeProperty(dom, property);
return Option.from(raw).filter(function (r) {
return r.length > 0;
});
};
var getAllRaw = function (element) {
var css = {};
var dom = element.dom();
if (isSupported(dom)) {
for (var i = 0; i < dom.style.length; i++) {
var ruleName = dom.style.item(i);
css[ruleName] = dom.style[ruleName];
}
}
return css;
};
var reflow = function (e) {
return e.dom().offsetWidth;
};
var browser = detect$3().browser;
var firstElement = function (nodes) {
return find(nodes, isElement);
};
var getTableCaptionDeltaY = function (elm) {
if (browser.isFirefox() && name(elm) === 'table') {
return firstElement(children(elm)).filter(function (elm) {
return name(elm) === 'caption';
}).bind(function (caption) {
return firstElement(nextSiblings(caption)).map(function (body) {
var bodyTop = body.dom().offsetTop;
var captionTop = caption.dom().offsetTop;
var captionHeight = caption.dom().offsetHeight;
return bodyTop <= captionTop ? -captionHeight : 0;
});
}).getOr(0);
} else {
return 0;
}
};
var hasChild = function (elm, child) {
return elm.children && contains(elm.children, child);
};
var getPos = function (body, elm, rootElm) {
var x = 0, y = 0, offsetParent;
var doc = body.ownerDocument;
var pos;
rootElm = rootElm ? rootElm : body;
if (elm) {
if (rootElm === body && elm.getBoundingClientRect && get$4(Element.fromDom(body), 'position') === 'static') {
pos = elm.getBoundingClientRect();
x = pos.left + (doc.documentElement.scrollLeft || body.scrollLeft) - doc.documentElement.clientLeft;
y = pos.top + (doc.documentElement.scrollTop || body.scrollTop) - doc.documentElement.clientTop;
return {
x: x,
y: y
};
}
offsetParent = elm;
while (offsetParent && offsetParent !== rootElm && offsetParent.nodeType && !hasChild(offsetParent, rootElm)) {
x += offsetParent.offsetLeft || 0;
y += offsetParent.offsetTop || 0;
offsetParent = offsetParent.offsetParent;
}
offsetParent = elm.parentNode;
while (offsetParent && offsetParent !== rootElm && offsetParent.nodeType && !hasChild(offsetParent, rootElm)) {
x -= offsetParent.scrollLeft || 0;
y -= offsetParent.scrollTop || 0;
offsetParent = offsetParent.parentNode;
}
y += getTableCaptionDeltaY(Element.fromDom(elm));
}
return {
x: x,
y: y
};
};
var exports$1 = {}, module$1 = { exports: exports$1 };
(function (define, exports, module, require) {
(function (f) {
if (typeof exports === 'object' && typeof module !== 'undefined') {
module.exports = f();
} else if (typeof define === 'function' && define.amd) {
define([], f);
} else {
var g;
if (typeof window !== 'undefined') {
g = window;
} else if (typeof global !== 'undefined') {
g = global;
} else if (typeof self !== 'undefined') {
g = self;
} else {
g = this;
}
g.EphoxContactWrapper = f();
}
}(function () {
return function () {
function r(e, n, t) {
function o(i, f) {
if (!n[i]) {
if (!e[i]) {
var c = 'function' == typeof require && require;
if (!f && c)
return c(i, !0);
if (u)
return u(i, !0);
var a = new Error('Cannot find module \'' + i + '\'');
throw a.code = 'MODULE_NOT_FOUND', a;
}
var p = n[i] = { exports: {} };
e[i][0].call(p.exports, function (r) {
var n = e[i][1][r];
return o(n || r);
}, p, p.exports, r, e, n, t);
}
return n[i].exports;
}
for (var u = 'function' == typeof require && require, i = 0; i < t.length; i++)
o(t[i]);
return o;
}
return r;
}()({
1: [
function (require, module, exports) {
var process = module.exports = {};
var cachedSetTimeout;
var cachedClearTimeout;
function defaultSetTimout() {
throw new Error('setTimeout has not been defined');
}
function defaultClearTimeout() {
throw new Error('clearTimeout has not been defined');
}
(function () {
try {
if (typeof setTimeout === 'function') {
cachedSetTimeout = setTimeout;
} else {
cachedSetTimeout = defaultSetTimout;
}
} catch (e) {
cachedSetTimeout = defaultSetTimout;
}
try {
if (typeof clearTimeout === 'function') {
cachedClearTimeout = clearTimeout;
} else {
cachedClearTimeout = defaultClearTimeout;
}
} catch (e) {
cachedClearTimeout = defaultClearTimeout;
}
}());
function runTimeout(fun) {
if (cachedSetTimeout === setTimeout) {
return setTimeout(fun, 0);
}
if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
cachedSetTimeout = setTimeout;
return setTimeout(fun, 0);
}
try {
return cachedSetTimeout(fun, 0);
} catch (e) {
try {
return cachedSetTimeout.call(null, fun, 0);
} catch (e) {
return cachedSetTimeout.call(this, fun, 0);
}
}
}
function runClearTimeout(marker) {
if (cachedClearTimeout === clearTimeout) {
return clearTimeout(marker);
}
if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
cachedClearTimeout = clearTimeout;
return clearTimeout(marker);
}
try {
return cachedClearTimeout(marker);
} catch (e) {
try {
return cachedClearTimeout.call(null, marker);
} catch (e) {
return cachedClearTimeout.call(this, marker);
}
}
}
var queue = [];
var draining = false;
var currentQueue;
var queueIndex = -1;
function cleanUpNextTick() {
if (!draining || !currentQueue) {
return;
}
draining = false;
if (currentQueue.length) {
queue = currentQueue.concat(queue);
} else {
queueIndex = -1;
}
if (queue.length) {
drainQueue();
}
}
function drainQueue() {
if (draining) {
return;
}
var timeout = runTimeout(cleanUpNextTick);
draining = true;
var len = queue.length;
while (len) {
currentQueue = queue;
queue = [];
while (++queueIndex < len) {
if (currentQueue) {
currentQueue[queueIndex].run();
}
}
queueIndex = -1;
len = queue.length;
}
currentQueue = null;
draining = false;
runClearTimeout(timeout);
}
process.nextTick = function (fun) {
var args = new Array(arguments.length - 1);
if (arguments.length > 1) {
for (var i = 1; i < arguments.length; i++) {
args[i - 1] = arguments[i];
}
}
queue.push(new Item(fun, args));
if (queue.length === 1 && !draining) {
runTimeout(drainQueue);
}
};
function Item(fun, array) {
this.fun = fun;
this.array = array;
}
Item.prototype.run = function () {