@tabler/core
Version:
Premium and Open Source dashboard template with responsive and high quality UI.
1,616 lines (1,560 loc) • 1.16 MB
JavaScript
/**
* TinyMCE version 7.5.1 (TBD)
*/
(function () {
'use strict';
const getPrototypeOf$2 = Object.getPrototypeOf;
const hasProto = (v, constructor, predicate) => {
var _a;
if (predicate(v, constructor.prototype)) {
return true;
} else {
return ((_a = v.constructor) === null || _a === void 0 ? void 0 : _a.name) === constructor.name;
}
};
const typeOf = x => {
const t = typeof x;
if (x === null) {
return 'null';
} else if (t === 'object' && Array.isArray(x)) {
return 'array';
} else if (t === 'object' && hasProto(x, String, (o, proto) => proto.isPrototypeOf(o))) {
return 'string';
} else {
return t;
}
};
const isType$1 = type => value => typeOf(value) === type;
const isSimpleType = type => value => typeof value === type;
const eq$1 = t => a => t === a;
const is$2 = (value, constructor) => isObject(value) && hasProto(value, constructor, (o, proto) => getPrototypeOf$2(o) === proto);
const isString = isType$1('string');
const isObject = isType$1('object');
const isPlainObject = value => is$2(value, Object);
const isArray = isType$1('array');
const isNull = eq$1(null);
const isBoolean = isSimpleType('boolean');
const isUndefined = eq$1(undefined);
const isNullable = a => a === null || a === undefined;
const isNonNullable = a => !isNullable(a);
const isFunction = isSimpleType('function');
const isNumber = isSimpleType('number');
const isArrayOf = (value, pred) => {
if (isArray(value)) {
for (let i = 0, len = value.length; i < len; ++i) {
if (!pred(value[i])) {
return false;
}
}
return true;
}
return false;
};
const noop = () => {
};
const noarg = f => () => f();
const compose = (fa, fb) => {
return (...args) => {
return fa(fb.apply(null, args));
};
};
const compose1 = (fbc, fab) => a => fbc(fab(a));
const constant$1 = value => {
return () => {
return value;
};
};
const identity = x => {
return x;
};
const tripleEquals = (a, b) => {
return a === b;
};
function curry(fn, ...initialArgs) {
return (...restArgs) => {
const all = initialArgs.concat(restArgs);
return fn.apply(null, all);
};
}
const not = f => t => !f(t);
const die = msg => {
return () => {
throw new Error(msg);
};
};
const apply$1 = f => {
return f();
};
const never = constant$1(false);
const always = constant$1(true);
class Optional {
constructor(tag, value) {
this.tag = tag;
this.value = value;
}
static some(value) {
return new Optional(true, value);
}
static none() {
return Optional.singletonNone;
}
fold(onNone, onSome) {
if (this.tag) {
return onSome(this.value);
} else {
return onNone();
}
}
isSome() {
return this.tag;
}
isNone() {
return !this.tag;
}
map(mapper) {
if (this.tag) {
return Optional.some(mapper(this.value));
} else {
return Optional.none();
}
}
bind(binder) {
if (this.tag) {
return binder(this.value);
} else {
return Optional.none();
}
}
exists(predicate) {
return this.tag && predicate(this.value);
}
forall(predicate) {
return !this.tag || predicate(this.value);
}
filter(predicate) {
if (!this.tag || predicate(this.value)) {
return this;
} else {
return Optional.none();
}
}
getOr(replacement) {
return this.tag ? this.value : replacement;
}
or(replacement) {
return this.tag ? this : replacement;
}
getOrThunk(thunk) {
return this.tag ? this.value : thunk();
}
orThunk(thunk) {
return this.tag ? this : thunk();
}
getOrDie(message) {
if (!this.tag) {
throw new Error(message !== null && message !== void 0 ? message : 'Called getOrDie on None');
} else {
return this.value;
}
}
static from(value) {
return isNonNullable(value) ? Optional.some(value) : Optional.none();
}
getOrNull() {
return this.tag ? this.value : null;
}
getOrUndefined() {
return this.value;
}
each(worker) {
if (this.tag) {
worker(this.value);
}
}
toArray() {
return this.tag ? [this.value] : [];
}
toString() {
return this.tag ? `some(${ this.value })` : 'none()';
}
}
Optional.singletonNone = new Optional(false);
const nativeSlice = Array.prototype.slice;
const nativeIndexOf = Array.prototype.indexOf;
const nativePush = Array.prototype.push;
const rawIndexOf = (ts, t) => nativeIndexOf.call(ts, t);
const indexOf = (xs, x) => {
const r = rawIndexOf(xs, x);
return r === -1 ? Optional.none() : Optional.some(r);
};
const contains$2 = (xs, x) => rawIndexOf(xs, x) > -1;
const exists = (xs, pred) => {
for (let i = 0, len = xs.length; i < len; i++) {
const x = xs[i];
if (pred(x, i)) {
return true;
}
}
return false;
};
const range$2 = (num, f) => {
const r = [];
for (let i = 0; i < num; i++) {
r.push(f(i));
}
return r;
};
const chunk$1 = (array, size) => {
const r = [];
for (let i = 0; i < array.length; i += size) {
const s = nativeSlice.call(array, i, i + size);
r.push(s);
}
return r;
};
const map$2 = (xs, f) => {
const len = xs.length;
const r = new Array(len);
for (let i = 0; i < len; i++) {
const x = xs[i];
r[i] = f(x, i);
}
return r;
};
const each$1 = (xs, f) => {
for (let i = 0, len = xs.length; i < len; i++) {
const x = xs[i];
f(x, i);
}
};
const eachr = (xs, f) => {
for (let i = xs.length - 1; i >= 0; i--) {
const x = xs[i];
f(x, i);
}
};
const partition$3 = (xs, pred) => {
const pass = [];
const fail = [];
for (let i = 0, len = xs.length; i < len; i++) {
const x = xs[i];
const arr = pred(x, i) ? pass : fail;
arr.push(x);
}
return {
pass,
fail
};
};
const filter$2 = (xs, pred) => {
const r = [];
for (let i = 0, len = xs.length; i < len; i++) {
const x = xs[i];
if (pred(x, i)) {
r.push(x);
}
}
return r;
};
const foldr = (xs, f, acc) => {
eachr(xs, (x, i) => {
acc = f(acc, x, i);
});
return acc;
};
const foldl = (xs, f, acc) => {
each$1(xs, (x, i) => {
acc = f(acc, x, i);
});
return acc;
};
const findUntil = (xs, pred, until) => {
for (let i = 0, len = xs.length; i < len; i++) {
const x = xs[i];
if (pred(x, i)) {
return Optional.some(x);
} else if (until(x, i)) {
break;
}
}
return Optional.none();
};
const find$5 = (xs, pred) => {
return findUntil(xs, pred, never);
};
const findIndex$1 = (xs, pred) => {
for (let i = 0, len = xs.length; i < len; i++) {
const x = xs[i];
if (pred(x, i)) {
return Optional.some(i);
}
}
return Optional.none();
};
const flatten = xs => {
const r = [];
for (let 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;
};
const bind$3 = (xs, f) => flatten(map$2(xs, f));
const forall = (xs, pred) => {
for (let i = 0, len = xs.length; i < len; ++i) {
const x = xs[i];
if (pred(x, i) !== true) {
return false;
}
}
return true;
};
const reverse = xs => {
const r = nativeSlice.call(xs, 0);
r.reverse();
return r;
};
const difference = (a1, a2) => filter$2(a1, x => !contains$2(a2, x));
const mapToObject = (xs, f) => {
const r = {};
for (let i = 0, len = xs.length; i < len; i++) {
const x = xs[i];
r[String(x)] = f(x, i);
}
return r;
};
const pure$2 = x => [x];
const sort = (xs, comparator) => {
const copy = nativeSlice.call(xs, 0);
copy.sort(comparator);
return copy;
};
const get$i = (xs, i) => i >= 0 && i < xs.length ? Optional.some(xs[i]) : Optional.none();
const head = xs => get$i(xs, 0);
const last$1 = xs => get$i(xs, xs.length - 1);
const from = isFunction(Array.from) ? Array.from : x => nativeSlice.call(x);
const findMap = (arr, f) => {
for (let i = 0; i < arr.length; i++) {
const r = f(arr[i], i);
if (r.isSome()) {
return r;
}
}
return Optional.none();
};
const keys = Object.keys;
const hasOwnProperty = Object.hasOwnProperty;
const each = (obj, f) => {
const props = keys(obj);
for (let k = 0, len = props.length; k < len; k++) {
const i = props[k];
const x = obj[i];
f(x, i);
}
};
const map$1 = (obj, f) => {
return tupleMap(obj, (x, i) => ({
k: i,
v: f(x, i)
}));
};
const tupleMap = (obj, f) => {
const r = {};
each(obj, (x, i) => {
const tuple = f(x, i);
r[tuple.k] = tuple.v;
});
return r;
};
const objAcc = r => (x, i) => {
r[i] = x;
};
const internalFilter = (obj, pred, onTrue, onFalse) => {
each(obj, (x, i) => {
(pred(x, i) ? onTrue : onFalse)(x, i);
});
};
const bifilter = (obj, pred) => {
const t = {};
const f = {};
internalFilter(obj, pred, objAcc(t), objAcc(f));
return {
t,
f
};
};
const filter$1 = (obj, pred) => {
const t = {};
internalFilter(obj, pred, objAcc(t), noop);
return t;
};
const mapToArray = (obj, f) => {
const r = [];
each(obj, (value, name) => {
r.push(f(value, name));
});
return r;
};
const find$4 = (obj, pred) => {
const props = keys(obj);
for (let k = 0, len = props.length; k < len; k++) {
const i = props[k];
const x = obj[i];
if (pred(x, i, obj)) {
return Optional.some(x);
}
}
return Optional.none();
};
const values = obj => {
return mapToArray(obj, identity);
};
const get$h = (obj, key) => {
return has$2(obj, key) ? Optional.from(obj[key]) : Optional.none();
};
const has$2 = (obj, key) => hasOwnProperty.call(obj, key);
const hasNonNullableKey = (obj, key) => has$2(obj, key) && obj[key] !== undefined && obj[key] !== null;
const is$1 = (lhs, rhs, comparator = tripleEquals) => lhs.exists(left => comparator(left, rhs));
const equals = (lhs, rhs, comparator = tripleEquals) => lift2(lhs, rhs, comparator).getOr(lhs.isNone() && rhs.isNone());
const cat = arr => {
const r = [];
const push = x => {
r.push(x);
};
for (let i = 0; i < arr.length; i++) {
arr[i].each(push);
}
return r;
};
const sequence = arr => {
const r = [];
for (let i = 0; i < arr.length; i++) {
const x = arr[i];
if (x.isSome()) {
r.push(x.getOrDie());
} else {
return Optional.none();
}
}
return Optional.some(r);
};
const lift2 = (oa, ob, f) => oa.isSome() && ob.isSome() ? Optional.some(f(oa.getOrDie(), ob.getOrDie())) : Optional.none();
const lift3 = (oa, ob, oc, f) => oa.isSome() && ob.isSome() && oc.isSome() ? Optional.some(f(oa.getOrDie(), ob.getOrDie(), oc.getOrDie())) : Optional.none();
const mapFrom = (a, f) => a !== undefined && a !== null ? Optional.some(f(a)) : Optional.none();
const someIf = (b, a) => b ? Optional.some(a) : Optional.none();
const addToEnd = (str, suffix) => {
return str + suffix;
};
const removeFromStart = (str, numChars) => {
return str.substring(numChars);
};
const checkRange = (str, substr, start) => substr === '' || str.length >= substr.length && str.substr(start, start + substr.length) === substr;
const removeLeading = (str, prefix) => {
return startsWith(str, prefix) ? removeFromStart(str, prefix.length) : str;
};
const ensureTrailing = (str, suffix) => {
return endsWith(str, suffix) ? str : addToEnd(str, suffix);
};
const contains$1 = (str, substr, start = 0, end) => {
const idx = str.indexOf(substr, start);
if (idx !== -1) {
return isUndefined(end) ? true : idx + substr.length <= end;
} else {
return false;
}
};
const startsWith = (str, prefix) => {
return checkRange(str, prefix, 0);
};
const endsWith = (str, suffix) => {
return checkRange(str, suffix, str.length - suffix.length);
};
const blank = r => s => s.replace(r, '');
const trim$1 = blank(/^\s+|\s+$/g);
const isNotEmpty = s => s.length > 0;
const isEmpty = s => !isNotEmpty(s);
const isSupported = dom => dom.style !== undefined && isFunction(dom.style.getPropertyValue);
const fromHtml$2 = (html, scope) => {
const doc = scope || document;
const div = doc.createElement('div');
div.innerHTML = html;
if (!div.hasChildNodes() || div.childNodes.length > 1) {
const message = 'HTML does not have a single root node';
console.error(message, html);
throw new Error(message);
}
return fromDom(div.childNodes[0]);
};
const fromTag = (tag, scope) => {
const doc = scope || document;
const node = doc.createElement(tag);
return fromDom(node);
};
const fromText = (text, scope) => {
const doc = scope || document;
const node = doc.createTextNode(text);
return fromDom(node);
};
const fromDom = node => {
if (node === null || node === undefined) {
throw new Error('Node cannot be null or undefined');
}
return { dom: node };
};
const fromPoint = (docElm, x, y) => Optional.from(docElm.dom.elementFromPoint(x, y)).map(fromDom);
const SugarElement = {
fromHtml: fromHtml$2,
fromTag,
fromText,
fromDom,
fromPoint
};
const Global = typeof window !== 'undefined' ? window : Function('return this;')();
const path$1 = (parts, scope) => {
let o = scope !== undefined && scope !== null ? scope : Global;
for (let i = 0; i < parts.length && o !== undefined && o !== null; ++i) {
o = o[parts[i]];
}
return o;
};
const resolve = (p, scope) => {
const parts = p.split('.');
return path$1(parts, scope);
};
const unsafe = (name, scope) => {
return resolve(name, scope);
};
const getOrDie$1 = (name, scope) => {
const actual = unsafe(name, scope);
if (actual === undefined || actual === null) {
throw new Error(name + ' not available on this browser');
}
return actual;
};
const getPrototypeOf$1 = Object.getPrototypeOf;
const sandHTMLElement = scope => {
return getOrDie$1('HTMLElement', scope);
};
const isPrototypeOf = x => {
const scope = resolve('ownerDocument.defaultView', x);
return isObject(x) && (sandHTMLElement(scope).prototype.isPrototypeOf(x) || /^HTML\w*Element$/.test(getPrototypeOf$1(x).constructor.name));
};
const DOCUMENT = 9;
const DOCUMENT_FRAGMENT = 11;
const ELEMENT = 1;
const TEXT = 3;
const name$3 = element => {
const r = element.dom.nodeName;
return r.toLowerCase();
};
const type$1 = element => element.dom.nodeType;
const isType = t => element => type$1(element) === t;
const isHTMLElement = element => isElement$1(element) && isPrototypeOf(element.dom);
const isElement$1 = isType(ELEMENT);
const isText = isType(TEXT);
const isDocument = isType(DOCUMENT);
const isDocumentFragment = isType(DOCUMENT_FRAGMENT);
const isTag = tag => e => isElement$1(e) && name$3(e) === tag;
const is = (element, selector) => {
const dom = element.dom;
if (dom.nodeType !== ELEMENT) {
return false;
} else {
const 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');
}
}
};
const bypassSelector = dom => dom.nodeType !== ELEMENT && dom.nodeType !== DOCUMENT && dom.nodeType !== DOCUMENT_FRAGMENT || dom.childElementCount === 0;
const all$3 = (selector, scope) => {
const base = scope === undefined ? document : scope.dom;
return bypassSelector(base) ? [] : map$2(base.querySelectorAll(selector), SugarElement.fromDom);
};
const one = (selector, scope) => {
const base = scope === undefined ? document : scope.dom;
return bypassSelector(base) ? Optional.none() : Optional.from(base.querySelector(selector)).map(SugarElement.fromDom);
};
const eq = (e1, e2) => e1.dom === e2.dom;
const contains = (e1, e2) => {
const d1 = e1.dom;
const d2 = e2.dom;
return d1 === d2 ? false : d1.contains(d2);
};
const owner$4 = element => SugarElement.fromDom(element.dom.ownerDocument);
const documentOrOwner = dos => isDocument(dos) ? dos : owner$4(dos);
const documentElement = element => SugarElement.fromDom(documentOrOwner(element).dom.documentElement);
const defaultView = element => SugarElement.fromDom(documentOrOwner(element).dom.defaultView);
const parent = element => Optional.from(element.dom.parentNode).map(SugarElement.fromDom);
const parentNode = element => parent(element);
const parentElement = element => Optional.from(element.dom.parentElement).map(SugarElement.fromDom);
const parents = (element, isRoot) => {
const stop = isFunction(isRoot) ? isRoot : never;
let dom = element.dom;
const ret = [];
while (dom.parentNode !== null && dom.parentNode !== undefined) {
const rawParent = dom.parentNode;
const p = SugarElement.fromDom(rawParent);
ret.push(p);
if (stop(p) === true) {
break;
} else {
dom = rawParent;
}
}
return ret;
};
const offsetParent = element => Optional.from(element.dom.offsetParent).map(SugarElement.fromDom);
const nextSibling = element => Optional.from(element.dom.nextSibling).map(SugarElement.fromDom);
const children = element => map$2(element.dom.childNodes, SugarElement.fromDom);
const child$2 = (element, index) => {
const cs = element.dom.childNodes;
return Optional.from(cs[index]).map(SugarElement.fromDom);
};
const firstChild = element => child$2(element, 0);
const spot = (element, offset) => ({
element,
offset
});
const leaf = (element, offset) => {
const cs = children(element);
return cs.length > 0 && offset < cs.length ? spot(cs[offset], 0) : spot(element, offset);
};
const isShadowRoot = dos => isDocumentFragment(dos) && isNonNullable(dos.dom.host);
const getRootNode = e => SugarElement.fromDom(e.dom.getRootNode());
const getContentContainer = dos => isShadowRoot(dos) ? dos : SugarElement.fromDom(documentOrOwner(dos).dom.body);
const isInShadowRoot = e => getShadowRoot(e).isSome();
const getShadowRoot = e => {
const r = getRootNode(e);
return isShadowRoot(r) ? Optional.some(r) : Optional.none();
};
const getShadowHost = e => SugarElement.fromDom(e.dom.host);
const getOriginalEventTarget = event => {
if (isNonNullable(event.target)) {
const el = SugarElement.fromDom(event.target);
if (isElement$1(el) && isOpenShadowHost(el)) {
if (event.composed && event.composedPath) {
const composedPath = event.composedPath();
if (composedPath) {
return head(composedPath);
}
}
}
}
return Optional.from(event.target);
};
const isOpenShadowHost = element => isNonNullable(element.dom.shadowRoot);
const inBody = element => {
const dom = isText(element) ? element.dom.parentNode : element.dom;
if (dom === undefined || dom === null || dom.ownerDocument === null) {
return false;
}
const doc = dom.ownerDocument;
return getShadowRoot(SugarElement.fromDom(dom)).fold(() => doc.body.contains(dom), compose1(inBody, getShadowHost));
};
const body = () => getBody(SugarElement.fromDom(document));
const getBody = doc => {
const b = doc.dom.body;
if (b === null || b === undefined) {
throw new Error('Body is not available yet');
}
return SugarElement.fromDom(b);
};
const rawSet = (dom, key, value) => {
if (isString(value) || isBoolean(value) || isNumber(value)) {
dom.setAttribute(key, value + '');
} else {
console.error('Invalid call to Attribute.set. Key ', key, ':: Value ', value, ':: Element ', dom);
throw new Error('Attribute value was not simple');
}
};
const set$9 = (element, key, value) => {
rawSet(element.dom, key, value);
};
const setAll$1 = (element, attrs) => {
const dom = element.dom;
each(attrs, (v, k) => {
rawSet(dom, k, v);
});
};
const get$g = (element, key) => {
const v = element.dom.getAttribute(key);
return v === null ? undefined : v;
};
const getOpt = (element, key) => Optional.from(get$g(element, key));
const has$1 = (element, key) => {
const dom = element.dom;
return dom && dom.hasAttribute ? dom.hasAttribute(key) : false;
};
const remove$8 = (element, key) => {
element.dom.removeAttribute(key);
};
const clone$2 = element => foldl(element.dom.attributes, (acc, attr) => {
acc[attr.name] = attr.value;
return acc;
}, {});
const internalSet = (dom, property, value) => {
if (!isString(value)) {
console.error('Invalid call to CSS.set. Property ', property, ':: Value ', value, ':: Element ', dom);
throw new Error('CSS value must be a string: ' + value);
}
if (isSupported(dom)) {
dom.style.setProperty(property, value);
}
};
const internalRemove = (dom, property) => {
if (isSupported(dom)) {
dom.style.removeProperty(property);
}
};
const set$8 = (element, property, value) => {
const dom = element.dom;
internalSet(dom, property, value);
};
const setAll = (element, css) => {
const dom = element.dom;
each(css, (v, k) => {
internalSet(dom, k, v);
});
};
const setOptions = (element, css) => {
const dom = element.dom;
each(css, (v, k) => {
v.fold(() => {
internalRemove(dom, k);
}, value => {
internalSet(dom, k, value);
});
});
};
const get$f = (element, property) => {
const dom = element.dom;
const styles = window.getComputedStyle(dom);
const r = styles.getPropertyValue(property);
return r === '' && !inBody(element) ? getUnsafeProperty(dom, property) : r;
};
const getUnsafeProperty = (dom, property) => isSupported(dom) ? dom.style.getPropertyValue(property) : '';
const getRaw = (element, property) => {
const dom = element.dom;
const raw = getUnsafeProperty(dom, property);
return Optional.from(raw).filter(r => r.length > 0);
};
const getAllRaw = element => {
const css = {};
const dom = element.dom;
if (isSupported(dom)) {
for (let i = 0; i < dom.style.length; i++) {
const ruleName = dom.style.item(i);
css[ruleName] = dom.style[ruleName];
}
}
return css;
};
const isValidValue$1 = (tag, property, value) => {
const element = SugarElement.fromTag(tag);
set$8(element, property, value);
const style = getRaw(element, property);
return style.isSome();
};
const remove$7 = (element, property) => {
const dom = element.dom;
internalRemove(dom, property);
if (is$1(getOpt(element, 'style').map(trim$1), '')) {
remove$8(element, 'style');
}
};
const reflow = e => e.dom.offsetWidth;
const Dimension = (name, getOffset) => {
const set = (element, h) => {
if (!isNumber(h) && !h.match(/^[0-9]+$/)) {
throw new Error(name + '.set accepts only positive integer values. Value was ' + h);
}
const dom = element.dom;
if (isSupported(dom)) {
dom.style[name] = h + 'px';
}
};
const get = element => {
const r = getOffset(element);
if (r <= 0 || r === null) {
const css = get$f(element, name);
return parseFloat(css) || 0;
}
return r;
};
const getOuter = get;
const aggregate = (element, properties) => foldl(properties, (acc, property) => {
const val = get$f(element, property);
const value = val === undefined ? 0 : parseInt(val, 10);
return isNaN(value) ? acc : acc + value;
}, 0);
const max = (element, value, properties) => {
const cumulativeInclusions = aggregate(element, properties);
const absoluteMax = value > cumulativeInclusions ? value - cumulativeInclusions : 0;
return absoluteMax;
};
return {
set,
get,
getOuter,
aggregate,
max
};
};
const api$2 = Dimension('height', element => {
const dom = element.dom;
return inBody(element) ? dom.getBoundingClientRect().height : dom.offsetHeight;
});
const get$e = element => api$2.get(element);
const getOuter$2 = element => api$2.getOuter(element);
const setMax$1 = (element, value) => {
const inclusions = [
'margin-top',
'border-top-width',
'padding-top',
'padding-bottom',
'border-bottom-width',
'margin-bottom'
];
const absMax = api$2.max(element, value, inclusions);
set$8(element, 'max-height', absMax + 'px');
};
const r$1 = (left, top) => {
const translate = (x, y) => r$1(left + x, top + y);
return {
left,
top,
translate
};
};
const SugarPosition = r$1;
const boxPosition = dom => {
const box = dom.getBoundingClientRect();
return SugarPosition(box.left, box.top);
};
const firstDefinedOrZero = (a, b) => {
if (a !== undefined) {
return a;
} else {
return b !== undefined ? b : 0;
}
};
const absolute$3 = element => {
const doc = element.dom.ownerDocument;
const body = doc.body;
const win = doc.defaultView;
const html = doc.documentElement;
if (body === element.dom) {
return SugarPosition(body.offsetLeft, body.offsetTop);
}
const scrollTop = firstDefinedOrZero(win === null || win === void 0 ? void 0 : win.pageYOffset, html.scrollTop);
const scrollLeft = firstDefinedOrZero(win === null || win === void 0 ? void 0 : win.pageXOffset, html.scrollLeft);
const clientTop = firstDefinedOrZero(html.clientTop, body.clientTop);
const clientLeft = firstDefinedOrZero(html.clientLeft, body.clientLeft);
return viewport$1(element).translate(scrollLeft - clientLeft, scrollTop - clientTop);
};
const viewport$1 = element => {
const dom = element.dom;
const doc = dom.ownerDocument;
const body = doc.body;
if (body === dom) {
return SugarPosition(body.offsetLeft, body.offsetTop);
}
if (!inBody(element)) {
return SugarPosition(0, 0);
}
return boxPosition(dom);
};
const api$1 = Dimension('width', element => element.dom.offsetWidth);
const set$7 = (element, h) => api$1.set(element, h);
const get$d = element => api$1.get(element);
const getOuter$1 = element => api$1.getOuter(element);
const setMax = (element, value) => {
const inclusions = [
'margin-left',
'border-left-width',
'padding-left',
'padding-right',
'border-right-width',
'margin-right'
];
const absMax = api$1.max(element, value, inclusions);
set$8(element, 'max-width', absMax + 'px');
};
const cached = f => {
let called = false;
let r;
return (...args) => {
if (!called) {
called = true;
r = f.apply(null, args);
}
return r;
};
};
const DeviceType = (os, browser, userAgent, mediaMatch) => {
const isiPad = os.isiOS() && /ipad/i.test(userAgent) === true;
const isiPhone = os.isiOS() && !isiPad;
const isMobile = os.isiOS() || os.isAndroid();
const isTouch = isMobile || mediaMatch('(pointer:coarse)');
const isTablet = isiPad || !isiPhone && isMobile && mediaMatch('(min-device-width:768px)');
const isPhone = isiPhone || isMobile && !isTablet;
const iOSwebview = browser.isSafari() && os.isiOS() && /safari/i.test(userAgent) === false;
const isDesktop = !isPhone && !isTablet && !iOSwebview;
return {
isiPad: constant$1(isiPad),
isiPhone: constant$1(isiPhone),
isTablet: constant$1(isTablet),
isPhone: constant$1(isPhone),
isTouch: constant$1(isTouch),
isAndroid: os.isAndroid,
isiOS: os.isiOS,
isWebView: constant$1(iOSwebview),
isDesktop: constant$1(isDesktop)
};
};
const firstMatch = (regexes, s) => {
for (let i = 0; i < regexes.length; i++) {
const x = regexes[i];
if (x.test(s)) {
return x;
}
}
return undefined;
};
const find$3 = (regexes, agent) => {
const r = firstMatch(regexes, agent);
if (!r) {
return {
major: 0,
minor: 0
};
}
const group = i => {
return Number(agent.replace(r, '$' + i));
};
return nu$d(group(1), group(2));
};
const detect$4 = (versionRegexes, agent) => {
const cleanedAgent = String(agent).toLowerCase();
if (versionRegexes.length === 0) {
return unknown$3();
}
return find$3(versionRegexes, cleanedAgent);
};
const unknown$3 = () => {
return nu$d(0, 0);
};
const nu$d = (major, minor) => {
return {
major,
minor
};
};
const Version = {
nu: nu$d,
detect: detect$4,
unknown: unknown$3
};
const detectBrowser$1 = (browsers, userAgentData) => {
return findMap(userAgentData.brands, uaBrand => {
const lcBrand = uaBrand.brand.toLowerCase();
return find$5(browsers, browser => {
var _a;
return lcBrand === ((_a = browser.brand) === null || _a === void 0 ? void 0 : _a.toLowerCase());
}).map(info => ({
current: info.name,
version: Version.nu(parseInt(uaBrand.version, 10), 0)
}));
});
};
const detect$3 = (candidates, userAgent) => {
const agent = String(userAgent).toLowerCase();
return find$5(candidates, candidate => {
return candidate.search(agent);
});
};
const detectBrowser = (browsers, userAgent) => {
return detect$3(browsers, userAgent).map(browser => {
const version = Version.detect(browser.versionRegexes, userAgent);
return {
current: browser.name,
version
};
});
};
const detectOs = (oses, userAgent) => {
return detect$3(oses, userAgent).map(os => {
const version = Version.detect(os.versionRegexes, userAgent);
return {
current: os.name,
version
};
});
};
const normalVersionRegex = /.*?version\/\ ?([0-9]+)\.([0-9]+).*/;
const checkContains = target => {
return uastring => {
return contains$1(uastring, target);
};
};
const browsers = [
{
name: 'Edge',
versionRegexes: [/.*?edge\/ ?([0-9]+)\.([0-9]+)$/],
search: uastring => {
return contains$1(uastring, 'edge/') && contains$1(uastring, 'chrome') && contains$1(uastring, 'safari') && contains$1(uastring, 'applewebkit');
}
},
{
name: 'Chromium',
brand: 'Chromium',
versionRegexes: [
/.*?chrome\/([0-9]+)\.([0-9]+).*/,
normalVersionRegex
],
search: uastring => {
return contains$1(uastring, 'chrome') && !contains$1(uastring, 'chromeframe');
}
},
{
name: 'IE',
versionRegexes: [
/.*?msie\ ?([0-9]+)\.([0-9]+).*/,
/.*?rv:([0-9]+)\.([0-9]+).*/
],
search: 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: uastring => {
return (contains$1(uastring, 'safari') || contains$1(uastring, 'mobile/')) && contains$1(uastring, 'applewebkit');
}
}
];
const oses = [
{
name: 'Windows',
search: checkContains('win'),
versionRegexes: [/.*?windows\ nt\ ?([0-9]+)\.([0-9]+).*/]
},
{
name: 'iOS',
search: 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: 'macOS',
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]+).*/]
}
];
const PlatformInfo = {
browsers: constant$1(browsers),
oses: constant$1(oses)
};
const edge = 'Edge';
const chromium = 'Chromium';
const ie = 'IE';
const opera = 'Opera';
const firefox = 'Firefox';
const safari = 'Safari';
const unknown$2 = () => {
return nu$c({
current: undefined,
version: Version.unknown()
});
};
const nu$c = info => {
const current = info.current;
const version = info.version;
const isBrowser = name => () => current === name;
return {
current,
version,
isEdge: isBrowser(edge),
isChromium: isBrowser(chromium),
isIE: isBrowser(ie),
isOpera: isBrowser(opera),
isFirefox: isBrowser(firefox),
isSafari: isBrowser(safari)
};
};
const Browser = {
unknown: unknown$2,
nu: nu$c,
edge: constant$1(edge),
chromium: constant$1(chromium),
ie: constant$1(ie),
opera: constant$1(opera),
firefox: constant$1(firefox),
safari: constant$1(safari)
};
const windows = 'Windows';
const ios = 'iOS';
const android = 'Android';
const linux = 'Linux';
const macos = 'macOS';
const solaris = 'Solaris';
const freebsd = 'FreeBSD';
const chromeos = 'ChromeOS';
const unknown$1 = () => {
return nu$b({
current: undefined,
version: Version.unknown()
});
};
const nu$b = info => {
const current = info.current;
const version = info.version;
const isOS = name => () => current === name;
return {
current,
version,
isWindows: isOS(windows),
isiOS: isOS(ios),
isAndroid: isOS(android),
isMacOS: isOS(macos),
isLinux: isOS(linux),
isSolaris: isOS(solaris),
isFreeBSD: isOS(freebsd),
isChromeOS: isOS(chromeos)
};
};
const OperatingSystem = {
unknown: unknown$1,
nu: nu$b,
windows: constant$1(windows),
ios: constant$1(ios),
android: constant$1(android),
linux: constant$1(linux),
macos: constant$1(macos),
solaris: constant$1(solaris),
freebsd: constant$1(freebsd),
chromeos: constant$1(chromeos)
};
const detect$2 = (userAgent, userAgentDataOpt, mediaMatch) => {
const browsers = PlatformInfo.browsers();
const oses = PlatformInfo.oses();
const browser = userAgentDataOpt.bind(userAgentData => detectBrowser$1(browsers, userAgentData)).orThunk(() => detectBrowser(browsers, userAgent)).fold(Browser.unknown, Browser.nu);
const os = detectOs(oses, userAgent).fold(OperatingSystem.unknown, OperatingSystem.nu);
const deviceType = DeviceType(os, browser, userAgent, mediaMatch);
return {
browser,
os,
deviceType
};
};
const PlatformDetection = { detect: detect$2 };
const mediaMatch = query => window.matchMedia(query).matches;
let platform = cached(() => PlatformDetection.detect(window.navigator.userAgent, Optional.from(window.navigator.userAgentData), mediaMatch));
const detect$1 = () => platform();
const mkEvent = (target, x, y, stop, prevent, kill, raw) => ({
target,
x,
y,
stop,
prevent,
kill,
raw
});
const fromRawEvent$1 = rawEvent => {
const target = SugarElement.fromDom(getOriginalEventTarget(rawEvent).getOr(rawEvent.target));
const stop = () => rawEvent.stopPropagation();
const prevent = () => rawEvent.preventDefault();
const kill = compose(prevent, stop);
return mkEvent(target, rawEvent.clientX, rawEvent.clientY, stop, prevent, kill, rawEvent);
};
const handle = (filter, handler) => rawEvent => {
if (filter(rawEvent)) {
handler(fromRawEvent$1(rawEvent));
}
};
const binder = (element, event, filter, handler, useCapture) => {
const wrapped = handle(filter, handler);
element.dom.addEventListener(event, wrapped, useCapture);
return { unbind: curry(unbind, element, event, wrapped, useCapture) };
};
const bind$2 = (element, event, filter, handler) => binder(element, event, filter, handler, false);
const capture$1 = (element, event, filter, handler) => binder(element, event, filter, handler, true);
const unbind = (element, event, handler, useCapture) => {
element.dom.removeEventListener(event, handler, useCapture);
};
const before$1 = (marker, element) => {
const parent$1 = parent(marker);
parent$1.each(v => {
v.dom.insertBefore(element.dom, marker.dom);
});
};
const after$2 = (marker, element) => {
const sibling = nextSibling(marker);
sibling.fold(() => {
const parent$1 = parent(marker);
parent$1.each(v => {
append$2(v, element);
});
}, v => {
before$1(v, element);
});
};
const prepend$1 = (parent, element) => {
const firstChild$1 = firstChild(parent);
firstChild$1.fold(() => {
append$2(parent, element);
}, v => {
parent.dom.insertBefore(element.dom, v.dom);
});
};
const append$2 = (parent, element) => {
parent.dom.appendChild(element.dom);
};
const appendAt = (parent, element, index) => {
child$2(parent, index).fold(() => {
append$2(parent, element);
}, v => {
before$1(v, element);
});
};
const append$1 = (parent, elements) => {
each$1(elements, x => {
append$2(parent, x);
});
};
const empty = element => {
element.dom.textContent = '';
each$1(children(element), rogue => {
remove$6(rogue);
});
};
const remove$6 = element => {
const dom = element.dom;
if (dom.parentNode !== null) {
dom.parentNode.removeChild(dom);
}
};
const get$c = _DOC => {
const doc = _DOC !== undefined ? _DOC.dom : document;
const x = doc.body.scrollLeft || doc.documentElement.scrollLeft;
const y = doc.body.scrollTop || doc.documentElement.scrollTop;
return SugarPosition(x, y);
};
const to = (x, y, _DOC) => {
const doc = _DOC !== undefined ? _DOC.dom : document;
const win = doc.defaultView;
if (win) {
win.scrollTo(x, y);
}
};
const get$b = _win => {
const win = _win === undefined ? window : _win;
if (detect$1().browser.isFirefox()) {
return Optional.none();
} else {
return Optional.from(win.visualViewport);
}
};
const bounds$1 = (x, y, width, height) => ({
x,
y,
width,
height,
right: x + width,
bottom: y + height
});
const getBounds$3 = _win => {
const win = _win === undefined ? window : _win;
const doc = win.document;
const scroll = get$c(SugarElement.fromDom(doc));
return get$b(win).fold(() => {
const html = win.document.documentElement;
const width = html.clientWidth;
const height = html.clientHeight;
return bounds$1(scroll.left, scroll.top, width, height);
}, visualViewport => bounds$1(Math.max(visualViewport.pageLeft, scroll.left), Math.max(visualViewport.pageTop, scroll.top), visualViewport.width, visualViewport.height));
};
const getDocument = () => SugarElement.fromDom(document);
const walkUp = (navigation, doc) => {
const frame = navigation.view(doc);
return frame.fold(constant$1([]), f => {
const parent = navigation.owner(f);
const rest = walkUp(navigation, parent);
return [f].concat(rest);
});
};
const pathTo = (element, navigation) => {
const d = navigation.owner(element);
const paths = walkUp(navigation, d);
return Optional.some(paths);
};
const view = doc => {
var _a;
const element = doc.dom === document ? Optional.none() : Optional.from((_a = doc.dom.defaultView) === null || _a === void 0 ? void 0 : _a.frameElement);
return element.map(SugarElement.fromDom);
};
const owner$3 = element => owner$4(element);
var Navigation = /*#__PURE__*/Object.freeze({
__proto__: null,
view: view,
owner: owner$3
});
const find$2 = element => {
const doc = getDocument();
const scroll = get$c(doc);
const path = pathTo(element, Navigation);
return path.fold(curry(absolute$3, element), frames => {
const offset = viewport$1(element);
const r = foldr(frames, (b, a) => {
const loc = viewport$1(a);
return {
left: b.left + loc.left,
top: b.top + loc.top
};
}, {
left: 0,
top: 0
});
return SugarPosition(r.left + offset.left + scroll.left, r.top + offset.top + scroll.top);
});
};
const pointed = (point, width, height) => ({
point,
width,
height
});
const rect = (x, y, width, height) => ({
x,
y,
width,
height
});
const bounds = (x, y, width, height) => ({
x,
y,
width,
height,
right: x + width,
bottom: y + height
});
const box$1 = element => {
const xy = absolute$3(element);
const w = getOuter$1(element);
const h = getOuter$2(element);
return bounds(xy.left, xy.top, w, h);
};
const absolute$2 = element => {
const position = find$2(element);
const width = getOuter$1(element);
const height = getOuter$2(element);
return bounds(position.left, position.top, width, height);
};
const constrain = (original, constraint) => {
const left = Math.max(original.x, constraint.x);
const top = Math.max(original.y, constraint.y);
const right = Math.min(original.right, constraint.right);
const bottom = Math.min(original.bottom, constraint.bottom);
const width = right - left;
const height = bottom - top;
return bounds(left, top, width, height);
};
const constrainByMany = (original, constraints) => {
return foldl(constraints, (acc, c) => constrain(acc, c), original);
};
const win = () => getBounds$3(window);
const Cell = initial => {
let value = initial;
const get = () => {
return value;
};
const set = v => {
value = v;
};
return {
get,
set
};
};
const singleton$1 = doRevoke => {
const subject = Cell(Optional.none());
const revoke = () => subject.get().each(doRevoke);
const clear = () => {
revoke();
subject.set(Optional.none());
};
const isSet = () => subject.get().isSome();
const get = () => subject.get();
const set = s => {
revoke();
subject.set(Optional.some(s));
};
return {
clear,
isSet,
get,
set
};
};
const destroyable = () => singleton$1(s => s.destroy());
const unbindable = () => singleton$1(s => s.unbind());
const value$4 = () => {
const subject = singleton$1(noop);
const on = f => subject.get().each(f);
return {
...subject,
on
};
};
var global$a = tinymce.util.Tools.resolve('tinymce.ThemeManager');
const value$3 = value => {
const applyHelper = fn => fn(value);
const constHelper = constant$1(value);
const outputHelper = () => output;
const output = {
tag: true,
inner: value,
fold: (_onError, onValue) => onValue(value),
isValue: always,
isError: never,
map: mapper => Result.value(mapper(value)),
mapError: outputHelper,
bind: applyHelper,
exists: applyHelper,
forall: applyHelper,
getOr: constHelper,
or: outputHelper,
getOrThunk: constHelper,
orThunk: outputHelper,
getOrDie: constHelper,
each: fn => {
fn(value);
},
toOptional: () => Optional.some(value)
};
return output;
};
const error$1 = error => {
const outputHelper = () => output;
const output = {
tag: false,
inner: error,
fold: (onError, _onValue) => onError(error),
isValue: never,
isError: always,
map: outputHelper,
mapError: mapper => Result.error(mapper(error)),
bind: outputHelper,
exists: never,
forall: always,
getOr: identity,
or: identity,
getOrThunk: apply$1,
orThunk: apply$1,
getOrDie: die(String(error)),
each: noop,
toOptional: Optional.none
};
return output;
};
const fromOption = (optional, err) => optional.fold(() => error$1(err), value$3);
const Result = {
value: value$3,
error: error$1,
fromOption
};
var SimpleResultType;
(function (SimpleResultType) {
SimpleResultType[SimpleResultType['Error'] = 0] = 'Error';
SimpleResultType[SimpleResultType['Value'] = 1] = 'Value';
}(SimpleResultType || (SimpleResultType = {})));
const fold$1 = (res, onError, onValue) => res.stype === SimpleResultType.Error ? onError(res.serror) : onValue(res.svalue);
const partition$2 = results => {
const values = [];
const errors = [];
each$1(results, obj => {
fold$1(obj, err => errors.push(err), val => values.push(val));
});
return {
values,
errors
};
};
const mapError = (res, f) => {
if (res.stype === SimpleResultType.Error) {
return {
stype: SimpleResultType.Error,
serror: f(res.serror)
};
} else {
return res;
}
};
const map = (res, f) => {
if (res.stype === SimpleResultType.Value) {
return {
stype: SimpleResultType.Value,
svalue: f(res.svalue)
};
} else {
return res;
}
};
const