You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
54015 lines
2.0 MiB
54015 lines
2.0 MiB
/*
|
|
THIS IS A GENERATED/BUNDLED FILE BY ESBUILD
|
|
if you want to view the source, please visit the github repository of this plugin
|
|
*/
|
|
|
|
var __create = Object.create;
|
|
var __defProp = Object.defineProperty;
|
|
var __defProps = Object.defineProperties;
|
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
var __getProtoOf = Object.getPrototypeOf;
|
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
var __spreadValues = (a3, b3) => {
|
|
for (var prop in b3 || (b3 = {}))
|
|
if (__hasOwnProp.call(b3, prop))
|
|
__defNormalProp(a3, prop, b3[prop]);
|
|
if (__getOwnPropSymbols)
|
|
for (var prop of __getOwnPropSymbols(b3)) {
|
|
if (__propIsEnum.call(b3, prop))
|
|
__defNormalProp(a3, prop, b3[prop]);
|
|
}
|
|
return a3;
|
|
};
|
|
var __spreadProps = (a3, b3) => __defProps(a3, __getOwnPropDescs(b3));
|
|
var __markAsModule = (target) => __defProp(target, "__esModule", { value: true });
|
|
var __commonJS = (cb, mod) => function __require() {
|
|
return mod || (0, cb[Object.keys(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
};
|
|
var __export = (target, all) => {
|
|
__markAsModule(target);
|
|
for (var name in all)
|
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
};
|
|
var __reExport = (target, module2, desc) => {
|
|
if (module2 && typeof module2 === "object" || typeof module2 === "function") {
|
|
for (let key of __getOwnPropNames(module2))
|
|
if (!__hasOwnProp.call(target, key) && key !== "default")
|
|
__defProp(target, key, { get: () => module2[key], enumerable: !(desc = __getOwnPropDesc(module2, key)) || desc.enumerable });
|
|
}
|
|
return target;
|
|
};
|
|
var __toModule = (module2) => {
|
|
return __reExport(__markAsModule(__defProp(module2 != null ? __create(__getProtoOf(module2)) : {}, "default", module2 && module2.__esModule && "default" in module2 ? { get: () => module2.default, enumerable: true } : { value: module2, enumerable: true })), module2);
|
|
};
|
|
var __async = (__this, __arguments, generator) => {
|
|
return new Promise((resolve, reject) => {
|
|
var fulfilled = (value) => {
|
|
try {
|
|
step(generator.next(value));
|
|
} catch (e3) {
|
|
reject(e3);
|
|
}
|
|
};
|
|
var rejected = (value) => {
|
|
try {
|
|
step(generator.throw(value));
|
|
} catch (e3) {
|
|
reject(e3);
|
|
}
|
|
};
|
|
var step = (x3) => x3.done ? resolve(x3.value) : Promise.resolve(x3.value).then(fulfilled, rejected);
|
|
step((generator = generator.apply(__this, __arguments)).next());
|
|
});
|
|
};
|
|
|
|
// node_modules/tslib/tslib.js
|
|
var require_tslib = __commonJS({
|
|
"node_modules/tslib/tslib.js"(exports, module2) {
|
|
var __extends2;
|
|
var __assign2;
|
|
var __rest2;
|
|
var __decorate2;
|
|
var __param2;
|
|
var __metadata2;
|
|
var __awaiter2;
|
|
var __generator2;
|
|
var __exportStar2;
|
|
var __values2;
|
|
var __read2;
|
|
var __spread2;
|
|
var __spreadArrays2;
|
|
var __spreadArray2;
|
|
var __await2;
|
|
var __asyncGenerator2;
|
|
var __asyncDelegator2;
|
|
var __asyncValues2;
|
|
var __makeTemplateObject2;
|
|
var __importStar2;
|
|
var __importDefault2;
|
|
var __classPrivateFieldGet2;
|
|
var __classPrivateFieldSet2;
|
|
var __createBinding2;
|
|
(function(factory) {
|
|
var root = typeof global === "object" ? global : typeof self === "object" ? self : typeof this === "object" ? this : {};
|
|
if (typeof define === "function" && define.amd) {
|
|
define("tslib", ["exports"], function(exports2) {
|
|
factory(createExporter(root, createExporter(exports2)));
|
|
});
|
|
} else if (typeof module2 === "object" && typeof module2.exports === "object") {
|
|
factory(createExporter(root, createExporter(module2.exports)));
|
|
} else {
|
|
factory(createExporter(root));
|
|
}
|
|
function createExporter(exports2, previous) {
|
|
if (exports2 !== root) {
|
|
if (typeof Object.create === "function") {
|
|
Object.defineProperty(exports2, "__esModule", { value: true });
|
|
} else {
|
|
exports2.__esModule = true;
|
|
}
|
|
}
|
|
return function(id, v3) {
|
|
return exports2[id] = previous ? previous(id, v3) : v3;
|
|
};
|
|
}
|
|
})(function(exporter) {
|
|
var extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d3, b3) {
|
|
d3.__proto__ = b3;
|
|
} || function(d3, b3) {
|
|
for (var p3 in b3)
|
|
if (Object.prototype.hasOwnProperty.call(b3, p3))
|
|
d3[p3] = b3[p3];
|
|
};
|
|
__extends2 = function(d3, b3) {
|
|
if (typeof b3 !== "function" && b3 !== null)
|
|
throw new TypeError("Class extends value " + String(b3) + " is not a constructor or null");
|
|
extendStatics(d3, b3);
|
|
function __() {
|
|
this.constructor = d3;
|
|
}
|
|
d3.prototype = b3 === null ? Object.create(b3) : (__.prototype = b3.prototype, new __());
|
|
};
|
|
__assign2 = Object.assign || function(t3) {
|
|
for (var s3, i3 = 1, n2 = arguments.length; i3 < n2; i3++) {
|
|
s3 = arguments[i3];
|
|
for (var p3 in s3)
|
|
if (Object.prototype.hasOwnProperty.call(s3, p3))
|
|
t3[p3] = s3[p3];
|
|
}
|
|
return t3;
|
|
};
|
|
__rest2 = function(s3, e3) {
|
|
var t3 = {};
|
|
for (var p3 in s3)
|
|
if (Object.prototype.hasOwnProperty.call(s3, p3) && e3.indexOf(p3) < 0)
|
|
t3[p3] = s3[p3];
|
|
if (s3 != null && typeof Object.getOwnPropertySymbols === "function")
|
|
for (var i3 = 0, p3 = Object.getOwnPropertySymbols(s3); i3 < p3.length; i3++) {
|
|
if (e3.indexOf(p3[i3]) < 0 && Object.prototype.propertyIsEnumerable.call(s3, p3[i3]))
|
|
t3[p3[i3]] = s3[p3[i3]];
|
|
}
|
|
return t3;
|
|
};
|
|
__decorate2 = function(decorators, target, key, desc) {
|
|
var c3 = arguments.length, r3 = c3 < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d3;
|
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
r3 = Reflect.decorate(decorators, target, key, desc);
|
|
else
|
|
for (var i3 = decorators.length - 1; i3 >= 0; i3--)
|
|
if (d3 = decorators[i3])
|
|
r3 = (c3 < 3 ? d3(r3) : c3 > 3 ? d3(target, key, r3) : d3(target, key)) || r3;
|
|
return c3 > 3 && r3 && Object.defineProperty(target, key, r3), r3;
|
|
};
|
|
__param2 = function(paramIndex, decorator) {
|
|
return function(target, key) {
|
|
decorator(target, key, paramIndex);
|
|
};
|
|
};
|
|
__metadata2 = function(metadataKey, metadataValue) {
|
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
return Reflect.metadata(metadataKey, metadataValue);
|
|
};
|
|
__awaiter2 = function(thisArg, _arguments, P3, generator) {
|
|
function adopt(value) {
|
|
return value instanceof P3 ? value : new P3(function(resolve) {
|
|
resolve(value);
|
|
});
|
|
}
|
|
return new (P3 || (P3 = Promise))(function(resolve, reject) {
|
|
function fulfilled(value) {
|
|
try {
|
|
step(generator.next(value));
|
|
} catch (e3) {
|
|
reject(e3);
|
|
}
|
|
}
|
|
function rejected(value) {
|
|
try {
|
|
step(generator["throw"](value));
|
|
} catch (e3) {
|
|
reject(e3);
|
|
}
|
|
}
|
|
function step(result) {
|
|
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
}
|
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
});
|
|
};
|
|
__generator2 = function(thisArg, body) {
|
|
var _3 = { label: 0, sent: function() {
|
|
if (t3[0] & 1)
|
|
throw t3[1];
|
|
return t3[1];
|
|
}, trys: [], ops: [] }, f3, y3, t3, g3;
|
|
return g3 = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g3[Symbol.iterator] = function() {
|
|
return this;
|
|
}), g3;
|
|
function verb(n2) {
|
|
return function(v3) {
|
|
return step([n2, v3]);
|
|
};
|
|
}
|
|
function step(op) {
|
|
if (f3)
|
|
throw new TypeError("Generator is already executing.");
|
|
while (_3)
|
|
try {
|
|
if (f3 = 1, y3 && (t3 = op[0] & 2 ? y3["return"] : op[0] ? y3["throw"] || ((t3 = y3["return"]) && t3.call(y3), 0) : y3.next) && !(t3 = t3.call(y3, op[1])).done)
|
|
return t3;
|
|
if (y3 = 0, t3)
|
|
op = [op[0] & 2, t3.value];
|
|
switch (op[0]) {
|
|
case 0:
|
|
case 1:
|
|
t3 = op;
|
|
break;
|
|
case 4:
|
|
_3.label++;
|
|
return { value: op[1], done: false };
|
|
case 5:
|
|
_3.label++;
|
|
y3 = op[1];
|
|
op = [0];
|
|
continue;
|
|
case 7:
|
|
op = _3.ops.pop();
|
|
_3.trys.pop();
|
|
continue;
|
|
default:
|
|
if (!(t3 = _3.trys, t3 = t3.length > 0 && t3[t3.length - 1]) && (op[0] === 6 || op[0] === 2)) {
|
|
_3 = 0;
|
|
continue;
|
|
}
|
|
if (op[0] === 3 && (!t3 || op[1] > t3[0] && op[1] < t3[3])) {
|
|
_3.label = op[1];
|
|
break;
|
|
}
|
|
if (op[0] === 6 && _3.label < t3[1]) {
|
|
_3.label = t3[1];
|
|
t3 = op;
|
|
break;
|
|
}
|
|
if (t3 && _3.label < t3[2]) {
|
|
_3.label = t3[2];
|
|
_3.ops.push(op);
|
|
break;
|
|
}
|
|
if (t3[2])
|
|
_3.ops.pop();
|
|
_3.trys.pop();
|
|
continue;
|
|
}
|
|
op = body.call(thisArg, _3);
|
|
} catch (e3) {
|
|
op = [6, e3];
|
|
y3 = 0;
|
|
} finally {
|
|
f3 = t3 = 0;
|
|
}
|
|
if (op[0] & 5)
|
|
throw op[1];
|
|
return { value: op[0] ? op[1] : void 0, done: true };
|
|
}
|
|
};
|
|
__exportStar2 = function(m2, o2) {
|
|
for (var p3 in m2)
|
|
if (p3 !== "default" && !Object.prototype.hasOwnProperty.call(o2, p3))
|
|
__createBinding2(o2, m2, p3);
|
|
};
|
|
__createBinding2 = Object.create ? function(o2, m2, k2, k22) {
|
|
if (k22 === void 0)
|
|
k22 = k2;
|
|
Object.defineProperty(o2, k22, { enumerable: true, get: function() {
|
|
return m2[k2];
|
|
} });
|
|
} : function(o2, m2, k2, k22) {
|
|
if (k22 === void 0)
|
|
k22 = k2;
|
|
o2[k22] = m2[k2];
|
|
};
|
|
__values2 = function(o2) {
|
|
var s3 = typeof Symbol === "function" && Symbol.iterator, m2 = s3 && o2[s3], i3 = 0;
|
|
if (m2)
|
|
return m2.call(o2);
|
|
if (o2 && typeof o2.length === "number")
|
|
return {
|
|
next: function() {
|
|
if (o2 && i3 >= o2.length)
|
|
o2 = void 0;
|
|
return { value: o2 && o2[i3++], done: !o2 };
|
|
}
|
|
};
|
|
throw new TypeError(s3 ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
};
|
|
__read2 = function(o2, n2) {
|
|
var m2 = typeof Symbol === "function" && o2[Symbol.iterator];
|
|
if (!m2)
|
|
return o2;
|
|
var i3 = m2.call(o2), r3, ar = [], e3;
|
|
try {
|
|
while ((n2 === void 0 || n2-- > 0) && !(r3 = i3.next()).done)
|
|
ar.push(r3.value);
|
|
} catch (error) {
|
|
e3 = { error };
|
|
} finally {
|
|
try {
|
|
if (r3 && !r3.done && (m2 = i3["return"]))
|
|
m2.call(i3);
|
|
} finally {
|
|
if (e3)
|
|
throw e3.error;
|
|
}
|
|
}
|
|
return ar;
|
|
};
|
|
__spread2 = function() {
|
|
for (var ar = [], i3 = 0; i3 < arguments.length; i3++)
|
|
ar = ar.concat(__read2(arguments[i3]));
|
|
return ar;
|
|
};
|
|
__spreadArrays2 = function() {
|
|
for (var s3 = 0, i3 = 0, il = arguments.length; i3 < il; i3++)
|
|
s3 += arguments[i3].length;
|
|
for (var r3 = Array(s3), k2 = 0, i3 = 0; i3 < il; i3++)
|
|
for (var a3 = arguments[i3], j4 = 0, jl = a3.length; j4 < jl; j4++, k2++)
|
|
r3[k2] = a3[j4];
|
|
return r3;
|
|
};
|
|
__spreadArray2 = function(to, from, pack) {
|
|
if (pack || arguments.length === 2)
|
|
for (var i3 = 0, l3 = from.length, ar; i3 < l3; i3++) {
|
|
if (ar || !(i3 in from)) {
|
|
if (!ar)
|
|
ar = Array.prototype.slice.call(from, 0, i3);
|
|
ar[i3] = from[i3];
|
|
}
|
|
}
|
|
return to.concat(ar || Array.prototype.slice.call(from));
|
|
};
|
|
__await2 = function(v3) {
|
|
return this instanceof __await2 ? (this.v = v3, this) : new __await2(v3);
|
|
};
|
|
__asyncGenerator2 = function(thisArg, _arguments, generator) {
|
|
if (!Symbol.asyncIterator)
|
|
throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
var g3 = generator.apply(thisArg, _arguments || []), i3, q3 = [];
|
|
return i3 = {}, verb("next"), verb("throw"), verb("return"), i3[Symbol.asyncIterator] = function() {
|
|
return this;
|
|
}, i3;
|
|
function verb(n2) {
|
|
if (g3[n2])
|
|
i3[n2] = function(v3) {
|
|
return new Promise(function(a3, b3) {
|
|
q3.push([n2, v3, a3, b3]) > 1 || resume(n2, v3);
|
|
});
|
|
};
|
|
}
|
|
function resume(n2, v3) {
|
|
try {
|
|
step(g3[n2](v3));
|
|
} catch (e3) {
|
|
settle(q3[0][3], e3);
|
|
}
|
|
}
|
|
function step(r3) {
|
|
r3.value instanceof __await2 ? Promise.resolve(r3.value.v).then(fulfill, reject) : settle(q3[0][2], r3);
|
|
}
|
|
function fulfill(value) {
|
|
resume("next", value);
|
|
}
|
|
function reject(value) {
|
|
resume("throw", value);
|
|
}
|
|
function settle(f3, v3) {
|
|
if (f3(v3), q3.shift(), q3.length)
|
|
resume(q3[0][0], q3[0][1]);
|
|
}
|
|
};
|
|
__asyncDelegator2 = function(o2) {
|
|
var i3, p3;
|
|
return i3 = {}, verb("next"), verb("throw", function(e3) {
|
|
throw e3;
|
|
}), verb("return"), i3[Symbol.iterator] = function() {
|
|
return this;
|
|
}, i3;
|
|
function verb(n2, f3) {
|
|
i3[n2] = o2[n2] ? function(v3) {
|
|
return (p3 = !p3) ? { value: __await2(o2[n2](v3)), done: n2 === "return" } : f3 ? f3(v3) : v3;
|
|
} : f3;
|
|
}
|
|
};
|
|
__asyncValues2 = function(o2) {
|
|
if (!Symbol.asyncIterator)
|
|
throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
var m2 = o2[Symbol.asyncIterator], i3;
|
|
return m2 ? m2.call(o2) : (o2 = typeof __values2 === "function" ? __values2(o2) : o2[Symbol.iterator](), i3 = {}, verb("next"), verb("throw"), verb("return"), i3[Symbol.asyncIterator] = function() {
|
|
return this;
|
|
}, i3);
|
|
function verb(n2) {
|
|
i3[n2] = o2[n2] && function(v3) {
|
|
return new Promise(function(resolve, reject) {
|
|
v3 = o2[n2](v3), settle(resolve, reject, v3.done, v3.value);
|
|
});
|
|
};
|
|
}
|
|
function settle(resolve, reject, d3, v3) {
|
|
Promise.resolve(v3).then(function(v4) {
|
|
resolve({ value: v4, done: d3 });
|
|
}, reject);
|
|
}
|
|
};
|
|
__makeTemplateObject2 = function(cooked, raw) {
|
|
if (Object.defineProperty) {
|
|
Object.defineProperty(cooked, "raw", { value: raw });
|
|
} else {
|
|
cooked.raw = raw;
|
|
}
|
|
return cooked;
|
|
};
|
|
var __setModuleDefault = Object.create ? function(o2, v3) {
|
|
Object.defineProperty(o2, "default", { enumerable: true, value: v3 });
|
|
} : function(o2, v3) {
|
|
o2["default"] = v3;
|
|
};
|
|
__importStar2 = function(mod) {
|
|
if (mod && mod.__esModule)
|
|
return mod;
|
|
var result = {};
|
|
if (mod != null) {
|
|
for (var k2 in mod)
|
|
if (k2 !== "default" && Object.prototype.hasOwnProperty.call(mod, k2))
|
|
__createBinding2(result, mod, k2);
|
|
}
|
|
__setModuleDefault(result, mod);
|
|
return result;
|
|
};
|
|
__importDefault2 = function(mod) {
|
|
return mod && mod.__esModule ? mod : { "default": mod };
|
|
};
|
|
__classPrivateFieldGet2 = function(receiver, state, kind, f3) {
|
|
if (kind === "a" && !f3)
|
|
throw new TypeError("Private accessor was defined without a getter");
|
|
if (typeof state === "function" ? receiver !== state || !f3 : !state.has(receiver))
|
|
throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
return kind === "m" ? f3 : kind === "a" ? f3.call(receiver) : f3 ? f3.value : state.get(receiver);
|
|
};
|
|
__classPrivateFieldSet2 = function(receiver, state, value, kind, f3) {
|
|
if (kind === "m")
|
|
throw new TypeError("Private method is not writable");
|
|
if (kind === "a" && !f3)
|
|
throw new TypeError("Private accessor was defined without a setter");
|
|
if (typeof state === "function" ? receiver !== state || !f3 : !state.has(receiver))
|
|
throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
return kind === "a" ? f3.call(receiver, value) : f3 ? f3.value = value : state.set(receiver, value), value;
|
|
};
|
|
exporter("__extends", __extends2);
|
|
exporter("__assign", __assign2);
|
|
exporter("__rest", __rest2);
|
|
exporter("__decorate", __decorate2);
|
|
exporter("__param", __param2);
|
|
exporter("__metadata", __metadata2);
|
|
exporter("__awaiter", __awaiter2);
|
|
exporter("__generator", __generator2);
|
|
exporter("__exportStar", __exportStar2);
|
|
exporter("__createBinding", __createBinding2);
|
|
exporter("__values", __values2);
|
|
exporter("__read", __read2);
|
|
exporter("__spread", __spread2);
|
|
exporter("__spreadArrays", __spreadArrays2);
|
|
exporter("__spreadArray", __spreadArray2);
|
|
exporter("__await", __await2);
|
|
exporter("__asyncGenerator", __asyncGenerator2);
|
|
exporter("__asyncDelegator", __asyncDelegator2);
|
|
exporter("__asyncValues", __asyncValues2);
|
|
exporter("__makeTemplateObject", __makeTemplateObject2);
|
|
exporter("__importStar", __importStar2);
|
|
exporter("__importDefault", __importDefault2);
|
|
exporter("__classPrivateFieldGet", __classPrivateFieldGet2);
|
|
exporter("__classPrivateFieldSet", __classPrivateFieldSet2);
|
|
});
|
|
}
|
|
});
|
|
|
|
// node_modules/ical.js/build/ical.js
|
|
var require_ical = __commonJS({
|
|
"node_modules/ical.js/build/ical.js"(exports, module2) {
|
|
var ICAL3;
|
|
(function() {
|
|
if (typeof module2 === "object") {
|
|
ICAL3 = module2.exports;
|
|
} else if (typeof HTMLScriptElement !== "undefined" && "noModule" in HTMLScriptElement.prototype) {
|
|
window.ICAL = ICAL3 = {};
|
|
} else if (typeof ICAL3 !== "object") {
|
|
ICAL3 = {};
|
|
}
|
|
})();
|
|
ICAL3.foldLength = 75;
|
|
ICAL3.newLineChar = "\r\n";
|
|
ICAL3.helpers = {
|
|
updateTimezones: function(vcal) {
|
|
var allsubs, properties, vtimezones, reqTzid, i3, tzid;
|
|
if (!vcal || vcal.name !== "vcalendar") {
|
|
return vcal;
|
|
}
|
|
allsubs = vcal.getAllSubcomponents();
|
|
properties = [];
|
|
vtimezones = {};
|
|
for (i3 = 0; i3 < allsubs.length; i3++) {
|
|
if (allsubs[i3].name === "vtimezone") {
|
|
tzid = allsubs[i3].getFirstProperty("tzid").getFirstValue();
|
|
vtimezones[tzid] = allsubs[i3];
|
|
} else {
|
|
properties = properties.concat(allsubs[i3].getAllProperties());
|
|
}
|
|
}
|
|
reqTzid = {};
|
|
for (i3 = 0; i3 < properties.length; i3++) {
|
|
if (tzid = properties[i3].getParameter("tzid")) {
|
|
reqTzid[tzid] = true;
|
|
}
|
|
}
|
|
for (i3 in vtimezones) {
|
|
if (vtimezones.hasOwnProperty(i3) && !reqTzid[i3]) {
|
|
vcal.removeSubcomponent(vtimezones[i3]);
|
|
}
|
|
}
|
|
for (i3 in reqTzid) {
|
|
if (reqTzid.hasOwnProperty(i3) && !vtimezones[i3] && ICAL3.TimezoneService.has(i3)) {
|
|
vcal.addSubcomponent(ICAL3.TimezoneService.get(i3).component);
|
|
}
|
|
}
|
|
return vcal;
|
|
},
|
|
isStrictlyNaN: function(number) {
|
|
return typeof number === "number" && isNaN(number);
|
|
},
|
|
strictParseInt: function(string) {
|
|
var result = parseInt(string, 10);
|
|
if (ICAL3.helpers.isStrictlyNaN(result)) {
|
|
throw new Error('Could not extract integer from "' + string + '"');
|
|
}
|
|
return result;
|
|
},
|
|
formatClassType: function formatClassType(data, type) {
|
|
if (typeof data === "undefined") {
|
|
return void 0;
|
|
}
|
|
if (data instanceof type) {
|
|
return data;
|
|
}
|
|
return new type(data);
|
|
},
|
|
unescapedIndexOf: function(buffer, search, pos) {
|
|
while ((pos = buffer.indexOf(search, pos)) !== -1) {
|
|
if (pos > 0 && buffer[pos - 1] === "\\") {
|
|
pos += 1;
|
|
} else {
|
|
return pos;
|
|
}
|
|
}
|
|
return -1;
|
|
},
|
|
binsearchInsert: function(list, seekVal, cmpfunc) {
|
|
if (!list.length)
|
|
return 0;
|
|
var low = 0, high = list.length - 1, mid, cmpval;
|
|
while (low <= high) {
|
|
mid = low + Math.floor((high - low) / 2);
|
|
cmpval = cmpfunc(seekVal, list[mid]);
|
|
if (cmpval < 0)
|
|
high = mid - 1;
|
|
else if (cmpval > 0)
|
|
low = mid + 1;
|
|
else
|
|
break;
|
|
}
|
|
if (cmpval < 0)
|
|
return mid;
|
|
else if (cmpval > 0)
|
|
return mid + 1;
|
|
else
|
|
return mid;
|
|
},
|
|
dumpn: function() {
|
|
if (!ICAL3.debug) {
|
|
return;
|
|
}
|
|
if (typeof console !== "undefined" && "log" in console) {
|
|
ICAL3.helpers.dumpn = function consoleDumpn(input) {
|
|
console.log(input);
|
|
};
|
|
} else {
|
|
ICAL3.helpers.dumpn = function geckoDumpn(input) {
|
|
dump(input + "\n");
|
|
};
|
|
}
|
|
ICAL3.helpers.dumpn(arguments[0]);
|
|
},
|
|
clone: function(aSrc, aDeep) {
|
|
if (!aSrc || typeof aSrc != "object") {
|
|
return aSrc;
|
|
} else if (aSrc instanceof Date) {
|
|
return new Date(aSrc.getTime());
|
|
} else if ("clone" in aSrc) {
|
|
return aSrc.clone();
|
|
} else if (Array.isArray(aSrc)) {
|
|
var arr = [];
|
|
for (var i3 = 0; i3 < aSrc.length; i3++) {
|
|
arr.push(aDeep ? ICAL3.helpers.clone(aSrc[i3], true) : aSrc[i3]);
|
|
}
|
|
return arr;
|
|
} else {
|
|
var obj = {};
|
|
for (var name in aSrc) {
|
|
if (Object.prototype.hasOwnProperty.call(aSrc, name)) {
|
|
if (aDeep) {
|
|
obj[name] = ICAL3.helpers.clone(aSrc[name], true);
|
|
} else {
|
|
obj[name] = aSrc[name];
|
|
}
|
|
}
|
|
}
|
|
return obj;
|
|
}
|
|
},
|
|
foldline: function foldline(aLine) {
|
|
var result = "";
|
|
var line = aLine || "", pos = 0, line_length = 0;
|
|
while (line.length) {
|
|
var cp = line.codePointAt(pos);
|
|
if (cp < 128)
|
|
++line_length;
|
|
else if (cp < 2048)
|
|
line_length += 2;
|
|
else if (cp < 65536)
|
|
line_length += 3;
|
|
else
|
|
line_length += 4;
|
|
if (line_length < ICAL3.foldLength + 1)
|
|
pos += cp > 65535 ? 2 : 1;
|
|
else {
|
|
result += ICAL3.newLineChar + " " + line.substring(0, pos);
|
|
line = line.substring(pos);
|
|
pos = line_length = 0;
|
|
}
|
|
}
|
|
return result.substr(ICAL3.newLineChar.length + 1);
|
|
},
|
|
pad2: function pad(data) {
|
|
if (typeof data !== "string") {
|
|
if (typeof data === "number") {
|
|
data = parseInt(data);
|
|
}
|
|
data = String(data);
|
|
}
|
|
var len = data.length;
|
|
switch (len) {
|
|
case 0:
|
|
return "00";
|
|
case 1:
|
|
return "0" + data;
|
|
default:
|
|
return data;
|
|
}
|
|
},
|
|
trunc: function trunc(number) {
|
|
return number < 0 ? Math.ceil(number) : Math.floor(number);
|
|
},
|
|
inherits: function(base, child, extra) {
|
|
function F2() {
|
|
}
|
|
F2.prototype = base.prototype;
|
|
child.prototype = new F2();
|
|
if (extra) {
|
|
ICAL3.helpers.extend(extra, child.prototype);
|
|
}
|
|
},
|
|
extend: function(source, target) {
|
|
for (var key in source) {
|
|
var descr = Object.getOwnPropertyDescriptor(source, key);
|
|
if (descr && !Object.getOwnPropertyDescriptor(target, key)) {
|
|
Object.defineProperty(target, key, descr);
|
|
}
|
|
}
|
|
return target;
|
|
}
|
|
};
|
|
ICAL3.design = function() {
|
|
"use strict";
|
|
var FROM_ICAL_NEWLINE = /\\\\|\\;|\\,|\\[Nn]/g;
|
|
var TO_ICAL_NEWLINE = /\\|;|,|\n/g;
|
|
var FROM_VCARD_NEWLINE = /\\\\|\\,|\\[Nn]/g;
|
|
var TO_VCARD_NEWLINE = /\\|,|\n/g;
|
|
function createTextType(fromNewline, toNewline) {
|
|
var result = {
|
|
matches: /.*/,
|
|
fromICAL: function(aValue, structuredEscape) {
|
|
return replaceNewline(aValue, fromNewline, structuredEscape);
|
|
},
|
|
toICAL: function(aValue, structuredEscape) {
|
|
var regEx = toNewline;
|
|
if (structuredEscape)
|
|
regEx = new RegExp(regEx.source + "|" + structuredEscape);
|
|
return aValue.replace(regEx, function(str) {
|
|
switch (str) {
|
|
case "\\":
|
|
return "\\\\";
|
|
case ";":
|
|
return "\\;";
|
|
case ",":
|
|
return "\\,";
|
|
case "\n":
|
|
return "\\n";
|
|
default:
|
|
return str;
|
|
}
|
|
});
|
|
}
|
|
};
|
|
return result;
|
|
}
|
|
var DEFAULT_TYPE_TEXT = { defaultType: "text" };
|
|
var DEFAULT_TYPE_TEXT_MULTI = { defaultType: "text", multiValue: "," };
|
|
var DEFAULT_TYPE_TEXT_STRUCTURED = { defaultType: "text", structuredValue: ";" };
|
|
var DEFAULT_TYPE_INTEGER = { defaultType: "integer" };
|
|
var DEFAULT_TYPE_DATETIME_DATE = { defaultType: "date-time", allowedTypes: ["date-time", "date"] };
|
|
var DEFAULT_TYPE_DATETIME = { defaultType: "date-time" };
|
|
var DEFAULT_TYPE_URI = { defaultType: "uri" };
|
|
var DEFAULT_TYPE_UTCOFFSET = { defaultType: "utc-offset" };
|
|
var DEFAULT_TYPE_RECUR = { defaultType: "recur" };
|
|
var DEFAULT_TYPE_DATE_ANDOR_TIME = { defaultType: "date-and-or-time", allowedTypes: ["date-time", "date", "text"] };
|
|
function replaceNewlineReplace(string) {
|
|
switch (string) {
|
|
case "\\\\":
|
|
return "\\";
|
|
case "\\;":
|
|
return ";";
|
|
case "\\,":
|
|
return ",";
|
|
case "\\n":
|
|
case "\\N":
|
|
return "\n";
|
|
default:
|
|
return string;
|
|
}
|
|
}
|
|
function replaceNewline(value, newline, structuredEscape) {
|
|
if (value.indexOf("\\") === -1) {
|
|
return value;
|
|
}
|
|
if (structuredEscape)
|
|
newline = new RegExp(newline.source + "|\\\\" + structuredEscape);
|
|
return value.replace(newline, replaceNewlineReplace);
|
|
}
|
|
var commonProperties = {
|
|
"categories": DEFAULT_TYPE_TEXT_MULTI,
|
|
"url": DEFAULT_TYPE_URI,
|
|
"version": DEFAULT_TYPE_TEXT,
|
|
"uid": DEFAULT_TYPE_TEXT
|
|
};
|
|
var commonValues = {
|
|
"boolean": {
|
|
values: ["TRUE", "FALSE"],
|
|
fromICAL: function(aValue) {
|
|
switch (aValue) {
|
|
case "TRUE":
|
|
return true;
|
|
case "FALSE":
|
|
return false;
|
|
default:
|
|
return false;
|
|
}
|
|
},
|
|
toICAL: function(aValue) {
|
|
if (aValue) {
|
|
return "TRUE";
|
|
}
|
|
return "FALSE";
|
|
}
|
|
},
|
|
float: {
|
|
matches: /^[+-]?\d+\.\d+$/,
|
|
fromICAL: function(aValue) {
|
|
var parsed = parseFloat(aValue);
|
|
if (ICAL3.helpers.isStrictlyNaN(parsed)) {
|
|
return 0;
|
|
}
|
|
return parsed;
|
|
},
|
|
toICAL: function(aValue) {
|
|
return String(aValue);
|
|
}
|
|
},
|
|
integer: {
|
|
fromICAL: function(aValue) {
|
|
var parsed = parseInt(aValue);
|
|
if (ICAL3.helpers.isStrictlyNaN(parsed)) {
|
|
return 0;
|
|
}
|
|
return parsed;
|
|
},
|
|
toICAL: function(aValue) {
|
|
return String(aValue);
|
|
}
|
|
},
|
|
"utc-offset": {
|
|
toICAL: function(aValue) {
|
|
if (aValue.length < 7) {
|
|
return aValue.substr(0, 3) + aValue.substr(4, 2);
|
|
} else {
|
|
return aValue.substr(0, 3) + aValue.substr(4, 2) + aValue.substr(7, 2);
|
|
}
|
|
},
|
|
fromICAL: function(aValue) {
|
|
if (aValue.length < 6) {
|
|
return aValue.substr(0, 3) + ":" + aValue.substr(3, 2);
|
|
} else {
|
|
return aValue.substr(0, 3) + ":" + aValue.substr(3, 2) + ":" + aValue.substr(5, 2);
|
|
}
|
|
},
|
|
decorate: function(aValue) {
|
|
return ICAL3.UtcOffset.fromString(aValue);
|
|
},
|
|
undecorate: function(aValue) {
|
|
return aValue.toString();
|
|
}
|
|
}
|
|
};
|
|
var icalParams = {
|
|
"cutype": {
|
|
values: ["INDIVIDUAL", "GROUP", "RESOURCE", "ROOM", "UNKNOWN"],
|
|
allowXName: true,
|
|
allowIanaToken: true
|
|
},
|
|
"delegated-from": {
|
|
valueType: "cal-address",
|
|
multiValue: ",",
|
|
multiValueSeparateDQuote: true
|
|
},
|
|
"delegated-to": {
|
|
valueType: "cal-address",
|
|
multiValue: ",",
|
|
multiValueSeparateDQuote: true
|
|
},
|
|
"encoding": {
|
|
values: ["8BIT", "BASE64"]
|
|
},
|
|
"fbtype": {
|
|
values: ["FREE", "BUSY", "BUSY-UNAVAILABLE", "BUSY-TENTATIVE"],
|
|
allowXName: true,
|
|
allowIanaToken: true
|
|
},
|
|
"member": {
|
|
valueType: "cal-address",
|
|
multiValue: ",",
|
|
multiValueSeparateDQuote: true
|
|
},
|
|
"partstat": {
|
|
values: [
|
|
"NEEDS-ACTION",
|
|
"ACCEPTED",
|
|
"DECLINED",
|
|
"TENTATIVE",
|
|
"DELEGATED",
|
|
"COMPLETED",
|
|
"IN-PROCESS"
|
|
],
|
|
allowXName: true,
|
|
allowIanaToken: true
|
|
},
|
|
"range": {
|
|
values: ["THISANDFUTURE"]
|
|
},
|
|
"related": {
|
|
values: ["START", "END"]
|
|
},
|
|
"reltype": {
|
|
values: ["PARENT", "CHILD", "SIBLING"],
|
|
allowXName: true,
|
|
allowIanaToken: true
|
|
},
|
|
"role": {
|
|
values: [
|
|
"REQ-PARTICIPANT",
|
|
"CHAIR",
|
|
"OPT-PARTICIPANT",
|
|
"NON-PARTICIPANT"
|
|
],
|
|
allowXName: true,
|
|
allowIanaToken: true
|
|
},
|
|
"rsvp": {
|
|
values: ["TRUE", "FALSE"]
|
|
},
|
|
"sent-by": {
|
|
valueType: "cal-address"
|
|
},
|
|
"tzid": {
|
|
matches: /^\//
|
|
},
|
|
"value": {
|
|
values: [
|
|
"binary",
|
|
"boolean",
|
|
"cal-address",
|
|
"date",
|
|
"date-time",
|
|
"duration",
|
|
"float",
|
|
"integer",
|
|
"period",
|
|
"recur",
|
|
"text",
|
|
"time",
|
|
"uri",
|
|
"utc-offset"
|
|
],
|
|
allowXName: true,
|
|
allowIanaToken: true
|
|
}
|
|
};
|
|
var icalValues = ICAL3.helpers.extend(commonValues, {
|
|
text: createTextType(FROM_ICAL_NEWLINE, TO_ICAL_NEWLINE),
|
|
uri: {},
|
|
"binary": {
|
|
decorate: function(aString) {
|
|
return ICAL3.Binary.fromString(aString);
|
|
},
|
|
undecorate: function(aBinary) {
|
|
return aBinary.toString();
|
|
}
|
|
},
|
|
"cal-address": {},
|
|
"date": {
|
|
decorate: function(aValue, aProp) {
|
|
if (design.strict) {
|
|
return ICAL3.Time.fromDateString(aValue, aProp);
|
|
} else {
|
|
return ICAL3.Time.fromString(aValue, aProp);
|
|
}
|
|
},
|
|
undecorate: function(aValue) {
|
|
return aValue.toString();
|
|
},
|
|
fromICAL: function(aValue) {
|
|
if (!design.strict && aValue.length >= 15) {
|
|
return icalValues["date-time"].fromICAL(aValue);
|
|
} else {
|
|
return aValue.substr(0, 4) + "-" + aValue.substr(4, 2) + "-" + aValue.substr(6, 2);
|
|
}
|
|
},
|
|
toICAL: function(aValue) {
|
|
var len = aValue.length;
|
|
if (len == 10) {
|
|
return aValue.substr(0, 4) + aValue.substr(5, 2) + aValue.substr(8, 2);
|
|
} else if (len >= 19) {
|
|
return icalValues["date-time"].toICAL(aValue);
|
|
} else {
|
|
return aValue;
|
|
}
|
|
}
|
|
},
|
|
"date-time": {
|
|
fromICAL: function(aValue) {
|
|
if (!design.strict && aValue.length == 8) {
|
|
return icalValues.date.fromICAL(aValue);
|
|
} else {
|
|
var result = aValue.substr(0, 4) + "-" + aValue.substr(4, 2) + "-" + aValue.substr(6, 2) + "T" + aValue.substr(9, 2) + ":" + aValue.substr(11, 2) + ":" + aValue.substr(13, 2);
|
|
if (aValue[15] && aValue[15] === "Z") {
|
|
result += "Z";
|
|
}
|
|
return result;
|
|
}
|
|
},
|
|
toICAL: function(aValue) {
|
|
var len = aValue.length;
|
|
if (len == 10 && !design.strict) {
|
|
return icalValues.date.toICAL(aValue);
|
|
} else if (len >= 19) {
|
|
var result = aValue.substr(0, 4) + aValue.substr(5, 2) + aValue.substr(8, 5) + aValue.substr(14, 2) + aValue.substr(17, 2);
|
|
if (aValue[19] && aValue[19] === "Z") {
|
|
result += "Z";
|
|
}
|
|
return result;
|
|
} else {
|
|
return aValue;
|
|
}
|
|
},
|
|
decorate: function(aValue, aProp) {
|
|
if (design.strict) {
|
|
return ICAL3.Time.fromDateTimeString(aValue, aProp);
|
|
} else {
|
|
return ICAL3.Time.fromString(aValue, aProp);
|
|
}
|
|
},
|
|
undecorate: function(aValue) {
|
|
return aValue.toString();
|
|
}
|
|
},
|
|
duration: {
|
|
decorate: function(aValue) {
|
|
return ICAL3.Duration.fromString(aValue);
|
|
},
|
|
undecorate: function(aValue) {
|
|
return aValue.toString();
|
|
}
|
|
},
|
|
period: {
|
|
fromICAL: function(string) {
|
|
var parts = string.split("/");
|
|
parts[0] = icalValues["date-time"].fromICAL(parts[0]);
|
|
if (!ICAL3.Duration.isValueString(parts[1])) {
|
|
parts[1] = icalValues["date-time"].fromICAL(parts[1]);
|
|
}
|
|
return parts;
|
|
},
|
|
toICAL: function(parts) {
|
|
if (!design.strict && parts[0].length == 10) {
|
|
parts[0] = icalValues.date.toICAL(parts[0]);
|
|
} else {
|
|
parts[0] = icalValues["date-time"].toICAL(parts[0]);
|
|
}
|
|
if (!ICAL3.Duration.isValueString(parts[1])) {
|
|
if (!design.strict && parts[1].length == 10) {
|
|
parts[1] = icalValues.date.toICAL(parts[1]);
|
|
} else {
|
|
parts[1] = icalValues["date-time"].toICAL(parts[1]);
|
|
}
|
|
}
|
|
return parts.join("/");
|
|
},
|
|
decorate: function(aValue, aProp) {
|
|
return ICAL3.Period.fromJSON(aValue, aProp, !design.strict);
|
|
},
|
|
undecorate: function(aValue) {
|
|
return aValue.toJSON();
|
|
}
|
|
},
|
|
recur: {
|
|
fromICAL: function(string) {
|
|
return ICAL3.Recur._stringToData(string, true);
|
|
},
|
|
toICAL: function(data) {
|
|
var str = "";
|
|
for (var k2 in data) {
|
|
if (!Object.prototype.hasOwnProperty.call(data, k2)) {
|
|
continue;
|
|
}
|
|
var val = data[k2];
|
|
if (k2 == "until") {
|
|
if (val.length > 10) {
|
|
val = icalValues["date-time"].toICAL(val);
|
|
} else {
|
|
val = icalValues.date.toICAL(val);
|
|
}
|
|
} else if (k2 == "wkst") {
|
|
if (typeof val === "number") {
|
|
val = ICAL3.Recur.numericDayToIcalDay(val);
|
|
}
|
|
} else if (Array.isArray(val)) {
|
|
val = val.join(",");
|
|
}
|
|
str += k2.toUpperCase() + "=" + val + ";";
|
|
}
|
|
return str.substr(0, str.length - 1);
|
|
},
|
|
decorate: function decorate(aValue) {
|
|
return ICAL3.Recur.fromData(aValue);
|
|
},
|
|
undecorate: function(aRecur) {
|
|
return aRecur.toJSON();
|
|
}
|
|
},
|
|
time: {
|
|
fromICAL: function(aValue) {
|
|
if (aValue.length < 6) {
|
|
return aValue;
|
|
}
|
|
var result = aValue.substr(0, 2) + ":" + aValue.substr(2, 2) + ":" + aValue.substr(4, 2);
|
|
if (aValue[6] === "Z") {
|
|
result += "Z";
|
|
}
|
|
return result;
|
|
},
|
|
toICAL: function(aValue) {
|
|
if (aValue.length < 8) {
|
|
return aValue;
|
|
}
|
|
var result = aValue.substr(0, 2) + aValue.substr(3, 2) + aValue.substr(6, 2);
|
|
if (aValue[8] === "Z") {
|
|
result += "Z";
|
|
}
|
|
return result;
|
|
}
|
|
}
|
|
});
|
|
var icalProperties = ICAL3.helpers.extend(commonProperties, {
|
|
"action": DEFAULT_TYPE_TEXT,
|
|
"attach": { defaultType: "uri" },
|
|
"attendee": { defaultType: "cal-address" },
|
|
"calscale": DEFAULT_TYPE_TEXT,
|
|
"class": DEFAULT_TYPE_TEXT,
|
|
"comment": DEFAULT_TYPE_TEXT,
|
|
"completed": DEFAULT_TYPE_DATETIME,
|
|
"contact": DEFAULT_TYPE_TEXT,
|
|
"created": DEFAULT_TYPE_DATETIME,
|
|
"description": DEFAULT_TYPE_TEXT,
|
|
"dtend": DEFAULT_TYPE_DATETIME_DATE,
|
|
"dtstamp": DEFAULT_TYPE_DATETIME,
|
|
"dtstart": DEFAULT_TYPE_DATETIME_DATE,
|
|
"due": DEFAULT_TYPE_DATETIME_DATE,
|
|
"duration": { defaultType: "duration" },
|
|
"exdate": {
|
|
defaultType: "date-time",
|
|
allowedTypes: ["date-time", "date"],
|
|
multiValue: ","
|
|
},
|
|
"exrule": DEFAULT_TYPE_RECUR,
|
|
"freebusy": { defaultType: "period", multiValue: "," },
|
|
"geo": { defaultType: "float", structuredValue: ";" },
|
|
"last-modified": DEFAULT_TYPE_DATETIME,
|
|
"location": DEFAULT_TYPE_TEXT,
|
|
"method": DEFAULT_TYPE_TEXT,
|
|
"organizer": { defaultType: "cal-address" },
|
|
"percent-complete": DEFAULT_TYPE_INTEGER,
|
|
"priority": DEFAULT_TYPE_INTEGER,
|
|
"prodid": DEFAULT_TYPE_TEXT,
|
|
"related-to": DEFAULT_TYPE_TEXT,
|
|
"repeat": DEFAULT_TYPE_INTEGER,
|
|
"rdate": {
|
|
defaultType: "date-time",
|
|
allowedTypes: ["date-time", "date", "period"],
|
|
multiValue: ",",
|
|
detectType: function(string) {
|
|
if (string.indexOf("/") !== -1) {
|
|
return "period";
|
|
}
|
|
return string.indexOf("T") === -1 ? "date" : "date-time";
|
|
}
|
|
},
|
|
"recurrence-id": DEFAULT_TYPE_DATETIME_DATE,
|
|
"resources": DEFAULT_TYPE_TEXT_MULTI,
|
|
"request-status": DEFAULT_TYPE_TEXT_STRUCTURED,
|
|
"rrule": DEFAULT_TYPE_RECUR,
|
|
"sequence": DEFAULT_TYPE_INTEGER,
|
|
"status": DEFAULT_TYPE_TEXT,
|
|
"summary": DEFAULT_TYPE_TEXT,
|
|
"transp": DEFAULT_TYPE_TEXT,
|
|
"trigger": { defaultType: "duration", allowedTypes: ["duration", "date-time"] },
|
|
"tzoffsetfrom": DEFAULT_TYPE_UTCOFFSET,
|
|
"tzoffsetto": DEFAULT_TYPE_UTCOFFSET,
|
|
"tzurl": DEFAULT_TYPE_URI,
|
|
"tzid": DEFAULT_TYPE_TEXT,
|
|
"tzname": DEFAULT_TYPE_TEXT
|
|
});
|
|
var vcardValues = ICAL3.helpers.extend(commonValues, {
|
|
text: createTextType(FROM_VCARD_NEWLINE, TO_VCARD_NEWLINE),
|
|
uri: createTextType(FROM_VCARD_NEWLINE, TO_VCARD_NEWLINE),
|
|
date: {
|
|
decorate: function(aValue) {
|
|
return ICAL3.VCardTime.fromDateAndOrTimeString(aValue, "date");
|
|
},
|
|
undecorate: function(aValue) {
|
|
return aValue.toString();
|
|
},
|
|
fromICAL: function(aValue) {
|
|
if (aValue.length == 8) {
|
|
return icalValues.date.fromICAL(aValue);
|
|
} else if (aValue[0] == "-" && aValue.length == 6) {
|
|
return aValue.substr(0, 4) + "-" + aValue.substr(4);
|
|
} else {
|
|
return aValue;
|
|
}
|
|
},
|
|
toICAL: function(aValue) {
|
|
if (aValue.length == 10) {
|
|
return icalValues.date.toICAL(aValue);
|
|
} else if (aValue[0] == "-" && aValue.length == 7) {
|
|
return aValue.substr(0, 4) + aValue.substr(5);
|
|
} else {
|
|
return aValue;
|
|
}
|
|
}
|
|
},
|
|
time: {
|
|
decorate: function(aValue) {
|
|
return ICAL3.VCardTime.fromDateAndOrTimeString("T" + aValue, "time");
|
|
},
|
|
undecorate: function(aValue) {
|
|
return aValue.toString();
|
|
},
|
|
fromICAL: function(aValue) {
|
|
var splitzone = vcardValues.time._splitZone(aValue, true);
|
|
var zone = splitzone[0], value = splitzone[1];
|
|
if (value.length == 6) {
|
|
value = value.substr(0, 2) + ":" + value.substr(2, 2) + ":" + value.substr(4, 2);
|
|
} else if (value.length == 4 && value[0] != "-") {
|
|
value = value.substr(0, 2) + ":" + value.substr(2, 2);
|
|
} else if (value.length == 5) {
|
|
value = value.substr(0, 3) + ":" + value.substr(3, 2);
|
|
}
|
|
if (zone.length == 5 && (zone[0] == "-" || zone[0] == "+")) {
|
|
zone = zone.substr(0, 3) + ":" + zone.substr(3);
|
|
}
|
|
return value + zone;
|
|
},
|
|
toICAL: function(aValue) {
|
|
var splitzone = vcardValues.time._splitZone(aValue);
|
|
var zone = splitzone[0], value = splitzone[1];
|
|
if (value.length == 8) {
|
|
value = value.substr(0, 2) + value.substr(3, 2) + value.substr(6, 2);
|
|
} else if (value.length == 5 && value[0] != "-") {
|
|
value = value.substr(0, 2) + value.substr(3, 2);
|
|
} else if (value.length == 6) {
|
|
value = value.substr(0, 3) + value.substr(4, 2);
|
|
}
|
|
if (zone.length == 6 && (zone[0] == "-" || zone[0] == "+")) {
|
|
zone = zone.substr(0, 3) + zone.substr(4);
|
|
}
|
|
return value + zone;
|
|
},
|
|
_splitZone: function(aValue, isFromIcal) {
|
|
var lastChar = aValue.length - 1;
|
|
var signChar = aValue.length - (isFromIcal ? 5 : 6);
|
|
var sign = aValue[signChar];
|
|
var zone, value;
|
|
if (aValue[lastChar] == "Z") {
|
|
zone = aValue[lastChar];
|
|
value = aValue.substr(0, lastChar);
|
|
} else if (aValue.length > 6 && (sign == "-" || sign == "+")) {
|
|
zone = aValue.substr(signChar);
|
|
value = aValue.substr(0, signChar);
|
|
} else {
|
|
zone = "";
|
|
value = aValue;
|
|
}
|
|
return [zone, value];
|
|
}
|
|
},
|
|
"date-time": {
|
|
decorate: function(aValue) {
|
|
return ICAL3.VCardTime.fromDateAndOrTimeString(aValue, "date-time");
|
|
},
|
|
undecorate: function(aValue) {
|
|
return aValue.toString();
|
|
},
|
|
fromICAL: function(aValue) {
|
|
return vcardValues["date-and-or-time"].fromICAL(aValue);
|
|
},
|
|
toICAL: function(aValue) {
|
|
return vcardValues["date-and-or-time"].toICAL(aValue);
|
|
}
|
|
},
|
|
"date-and-or-time": {
|
|
decorate: function(aValue) {
|
|
return ICAL3.VCardTime.fromDateAndOrTimeString(aValue, "date-and-or-time");
|
|
},
|
|
undecorate: function(aValue) {
|
|
return aValue.toString();
|
|
},
|
|
fromICAL: function(aValue) {
|
|
var parts = aValue.split("T");
|
|
return (parts[0] ? vcardValues.date.fromICAL(parts[0]) : "") + (parts[1] ? "T" + vcardValues.time.fromICAL(parts[1]) : "");
|
|
},
|
|
toICAL: function(aValue) {
|
|
var parts = aValue.split("T");
|
|
return vcardValues.date.toICAL(parts[0]) + (parts[1] ? "T" + vcardValues.time.toICAL(parts[1]) : "");
|
|
}
|
|
},
|
|
timestamp: icalValues["date-time"],
|
|
"language-tag": {
|
|
matches: /^[a-zA-Z0-9-]+$/
|
|
}
|
|
});
|
|
var vcardParams = {
|
|
"type": {
|
|
valueType: "text",
|
|
multiValue: ","
|
|
},
|
|
"value": {
|
|
values: [
|
|
"text",
|
|
"uri",
|
|
"date",
|
|
"time",
|
|
"date-time",
|
|
"date-and-or-time",
|
|
"timestamp",
|
|
"boolean",
|
|
"integer",
|
|
"float",
|
|
"utc-offset",
|
|
"language-tag"
|
|
],
|
|
allowXName: true,
|
|
allowIanaToken: true
|
|
}
|
|
};
|
|
var vcardProperties = ICAL3.helpers.extend(commonProperties, {
|
|
"adr": { defaultType: "text", structuredValue: ";", multiValue: "," },
|
|
"anniversary": DEFAULT_TYPE_DATE_ANDOR_TIME,
|
|
"bday": DEFAULT_TYPE_DATE_ANDOR_TIME,
|
|
"caladruri": DEFAULT_TYPE_URI,
|
|
"caluri": DEFAULT_TYPE_URI,
|
|
"clientpidmap": DEFAULT_TYPE_TEXT_STRUCTURED,
|
|
"email": DEFAULT_TYPE_TEXT,
|
|
"fburl": DEFAULT_TYPE_URI,
|
|
"fn": DEFAULT_TYPE_TEXT,
|
|
"gender": DEFAULT_TYPE_TEXT_STRUCTURED,
|
|
"geo": DEFAULT_TYPE_URI,
|
|
"impp": DEFAULT_TYPE_URI,
|
|
"key": DEFAULT_TYPE_URI,
|
|
"kind": DEFAULT_TYPE_TEXT,
|
|
"lang": { defaultType: "language-tag" },
|
|
"logo": DEFAULT_TYPE_URI,
|
|
"member": DEFAULT_TYPE_URI,
|
|
"n": { defaultType: "text", structuredValue: ";", multiValue: "," },
|
|
"nickname": DEFAULT_TYPE_TEXT_MULTI,
|
|
"note": DEFAULT_TYPE_TEXT,
|
|
"org": { defaultType: "text", structuredValue: ";" },
|
|
"photo": DEFAULT_TYPE_URI,
|
|
"related": DEFAULT_TYPE_URI,
|
|
"rev": { defaultType: "timestamp" },
|
|
"role": DEFAULT_TYPE_TEXT,
|
|
"sound": DEFAULT_TYPE_URI,
|
|
"source": DEFAULT_TYPE_URI,
|
|
"tel": { defaultType: "uri", allowedTypes: ["uri", "text"] },
|
|
"title": DEFAULT_TYPE_TEXT,
|
|
"tz": { defaultType: "text", allowedTypes: ["text", "utc-offset", "uri"] },
|
|
"xml": DEFAULT_TYPE_TEXT
|
|
});
|
|
var vcard3Values = ICAL3.helpers.extend(commonValues, {
|
|
binary: icalValues.binary,
|
|
date: vcardValues.date,
|
|
"date-time": vcardValues["date-time"],
|
|
"phone-number": {},
|
|
uri: icalValues.uri,
|
|
text: icalValues.text,
|
|
time: icalValues.time,
|
|
vcard: icalValues.text,
|
|
"utc-offset": {
|
|
toICAL: function(aValue) {
|
|
return aValue.substr(0, 7);
|
|
},
|
|
fromICAL: function(aValue) {
|
|
return aValue.substr(0, 7);
|
|
},
|
|
decorate: function(aValue) {
|
|
return ICAL3.UtcOffset.fromString(aValue);
|
|
},
|
|
undecorate: function(aValue) {
|
|
return aValue.toString();
|
|
}
|
|
}
|
|
});
|
|
var vcard3Params = {
|
|
"type": {
|
|
valueType: "text",
|
|
multiValue: ","
|
|
},
|
|
"value": {
|
|
values: [
|
|
"text",
|
|
"uri",
|
|
"date",
|
|
"date-time",
|
|
"phone-number",
|
|
"time",
|
|
"boolean",
|
|
"integer",
|
|
"float",
|
|
"utc-offset",
|
|
"vcard",
|
|
"binary"
|
|
],
|
|
allowXName: true,
|
|
allowIanaToken: true
|
|
}
|
|
};
|
|
var vcard3Properties = ICAL3.helpers.extend(commonProperties, {
|
|
fn: DEFAULT_TYPE_TEXT,
|
|
n: { defaultType: "text", structuredValue: ";", multiValue: "," },
|
|
nickname: DEFAULT_TYPE_TEXT_MULTI,
|
|
photo: { defaultType: "binary", allowedTypes: ["binary", "uri"] },
|
|
bday: {
|
|
defaultType: "date-time",
|
|
allowedTypes: ["date-time", "date"],
|
|
detectType: function(string) {
|
|
return string.indexOf("T") === -1 ? "date" : "date-time";
|
|
}
|
|
},
|
|
adr: { defaultType: "text", structuredValue: ";", multiValue: "," },
|
|
label: DEFAULT_TYPE_TEXT,
|
|
tel: { defaultType: "phone-number" },
|
|
email: DEFAULT_TYPE_TEXT,
|
|
mailer: DEFAULT_TYPE_TEXT,
|
|
tz: { defaultType: "utc-offset", allowedTypes: ["utc-offset", "text"] },
|
|
geo: { defaultType: "float", structuredValue: ";" },
|
|
title: DEFAULT_TYPE_TEXT,
|
|
role: DEFAULT_TYPE_TEXT,
|
|
logo: { defaultType: "binary", allowedTypes: ["binary", "uri"] },
|
|
agent: { defaultType: "vcard", allowedTypes: ["vcard", "text", "uri"] },
|
|
org: DEFAULT_TYPE_TEXT_STRUCTURED,
|
|
note: DEFAULT_TYPE_TEXT_MULTI,
|
|
prodid: DEFAULT_TYPE_TEXT,
|
|
rev: {
|
|
defaultType: "date-time",
|
|
allowedTypes: ["date-time", "date"],
|
|
detectType: function(string) {
|
|
return string.indexOf("T") === -1 ? "date" : "date-time";
|
|
}
|
|
},
|
|
"sort-string": DEFAULT_TYPE_TEXT,
|
|
sound: { defaultType: "binary", allowedTypes: ["binary", "uri"] },
|
|
class: DEFAULT_TYPE_TEXT,
|
|
key: { defaultType: "binary", allowedTypes: ["binary", "text"] }
|
|
});
|
|
var icalSet = {
|
|
value: icalValues,
|
|
param: icalParams,
|
|
property: icalProperties
|
|
};
|
|
var vcardSet = {
|
|
value: vcardValues,
|
|
param: vcardParams,
|
|
property: vcardProperties
|
|
};
|
|
var vcard3Set = {
|
|
value: vcard3Values,
|
|
param: vcard3Params,
|
|
property: vcard3Properties
|
|
};
|
|
var design = {
|
|
strict: true,
|
|
defaultSet: icalSet,
|
|
defaultType: "unknown",
|
|
components: {
|
|
vcard: vcardSet,
|
|
vcard3: vcard3Set,
|
|
vevent: icalSet,
|
|
vtodo: icalSet,
|
|
vjournal: icalSet,
|
|
valarm: icalSet,
|
|
vtimezone: icalSet,
|
|
daylight: icalSet,
|
|
standard: icalSet
|
|
},
|
|
icalendar: icalSet,
|
|
vcard: vcardSet,
|
|
vcard3: vcard3Set,
|
|
getDesignSet: function(componentName) {
|
|
var isInDesign = componentName && componentName in design.components;
|
|
return isInDesign ? design.components[componentName] : design.defaultSet;
|
|
}
|
|
};
|
|
return design;
|
|
}();
|
|
ICAL3.stringify = function() {
|
|
"use strict";
|
|
var LINE_ENDING = "\r\n";
|
|
var DEFAULT_VALUE_TYPE = "unknown";
|
|
var design = ICAL3.design;
|
|
var helpers = ICAL3.helpers;
|
|
function stringify(jCal) {
|
|
if (typeof jCal[0] == "string") {
|
|
jCal = [jCal];
|
|
}
|
|
var i3 = 0;
|
|
var len = jCal.length;
|
|
var result = "";
|
|
for (; i3 < len; i3++) {
|
|
result += stringify.component(jCal[i3]) + LINE_ENDING;
|
|
}
|
|
return result;
|
|
}
|
|
stringify.component = function(component, designSet) {
|
|
var name = component[0].toUpperCase();
|
|
var result = "BEGIN:" + name + LINE_ENDING;
|
|
var props = component[1];
|
|
var propIdx = 0;
|
|
var propLen = props.length;
|
|
var designSetName = component[0];
|
|
if (designSetName === "vcard" && component[1].length > 0 && !(component[1][0][0] === "version" && component[1][0][3] === "4.0")) {
|
|
designSetName = "vcard3";
|
|
}
|
|
designSet = designSet || design.getDesignSet(designSetName);
|
|
for (; propIdx < propLen; propIdx++) {
|
|
result += stringify.property(props[propIdx], designSet) + LINE_ENDING;
|
|
}
|
|
var comps = component[2] || [];
|
|
var compIdx = 0;
|
|
var compLen = comps.length;
|
|
for (; compIdx < compLen; compIdx++) {
|
|
result += stringify.component(comps[compIdx], designSet) + LINE_ENDING;
|
|
}
|
|
result += "END:" + name;
|
|
return result;
|
|
};
|
|
stringify.property = function(property, designSet, noFold) {
|
|
var name = property[0].toUpperCase();
|
|
var jsName = property[0];
|
|
var params = property[1];
|
|
var line = name;
|
|
var paramName;
|
|
for (paramName in params) {
|
|
var value = params[paramName];
|
|
if (params.hasOwnProperty(paramName)) {
|
|
var multiValue = paramName in designSet.param && designSet.param[paramName].multiValue;
|
|
if (multiValue && Array.isArray(value)) {
|
|
if (designSet.param[paramName].multiValueSeparateDQuote) {
|
|
multiValue = '"' + multiValue + '"';
|
|
}
|
|
value = value.map(stringify._rfc6868Unescape);
|
|
value = stringify.multiValue(value, multiValue, "unknown", null, designSet);
|
|
} else {
|
|
value = stringify._rfc6868Unescape(value);
|
|
}
|
|
line += ";" + paramName.toUpperCase();
|
|
line += "=" + stringify.propertyValue(value);
|
|
}
|
|
}
|
|
if (property.length === 3) {
|
|
return line + ":";
|
|
}
|
|
var valueType = property[2];
|
|
if (!designSet) {
|
|
designSet = design.defaultSet;
|
|
}
|
|
var propDetails;
|
|
var multiValue = false;
|
|
var structuredValue = false;
|
|
var isDefault = false;
|
|
if (jsName in designSet.property) {
|
|
propDetails = designSet.property[jsName];
|
|
if ("multiValue" in propDetails) {
|
|
multiValue = propDetails.multiValue;
|
|
}
|
|
if ("structuredValue" in propDetails && Array.isArray(property[3])) {
|
|
structuredValue = propDetails.structuredValue;
|
|
}
|
|
if ("defaultType" in propDetails) {
|
|
if (valueType === propDetails.defaultType) {
|
|
isDefault = true;
|
|
}
|
|
} else {
|
|
if (valueType === DEFAULT_VALUE_TYPE) {
|
|
isDefault = true;
|
|
}
|
|
}
|
|
} else {
|
|
if (valueType === DEFAULT_VALUE_TYPE) {
|
|
isDefault = true;
|
|
}
|
|
}
|
|
if (!isDefault) {
|
|
line += ";VALUE=" + valueType.toUpperCase();
|
|
}
|
|
line += ":";
|
|
if (multiValue && structuredValue) {
|
|
line += stringify.multiValue(property[3], structuredValue, valueType, multiValue, designSet, structuredValue);
|
|
} else if (multiValue) {
|
|
line += stringify.multiValue(property.slice(3), multiValue, valueType, null, designSet, false);
|
|
} else if (structuredValue) {
|
|
line += stringify.multiValue(property[3], structuredValue, valueType, null, designSet, structuredValue);
|
|
} else {
|
|
line += stringify.value(property[3], valueType, designSet, false);
|
|
}
|
|
return noFold ? line : ICAL3.helpers.foldline(line);
|
|
};
|
|
stringify.propertyValue = function(value) {
|
|
if (helpers.unescapedIndexOf(value, ",") === -1 && helpers.unescapedIndexOf(value, ":") === -1 && helpers.unescapedIndexOf(value, ";") === -1) {
|
|
return value;
|
|
}
|
|
return '"' + value + '"';
|
|
};
|
|
stringify.multiValue = function(values, delim, type, innerMulti, designSet, structuredValue) {
|
|
var result = "";
|
|
var len = values.length;
|
|
var i3 = 0;
|
|
for (; i3 < len; i3++) {
|
|
if (innerMulti && Array.isArray(values[i3])) {
|
|
result += stringify.multiValue(values[i3], innerMulti, type, null, designSet, structuredValue);
|
|
} else {
|
|
result += stringify.value(values[i3], type, designSet, structuredValue);
|
|
}
|
|
if (i3 !== len - 1) {
|
|
result += delim;
|
|
}
|
|
}
|
|
return result;
|
|
};
|
|
stringify.value = function(value, type, designSet, structuredValue) {
|
|
if (type in designSet.value && "toICAL" in designSet.value[type]) {
|
|
return designSet.value[type].toICAL(value, structuredValue);
|
|
}
|
|
return value;
|
|
};
|
|
stringify._rfc6868Unescape = function(val) {
|
|
return val.replace(/[\n^"]/g, function(x3) {
|
|
return RFC6868_REPLACE_MAP[x3];
|
|
});
|
|
};
|
|
var RFC6868_REPLACE_MAP = { '"': "^'", "\n": "^n", "^": "^^" };
|
|
return stringify;
|
|
}();
|
|
ICAL3.parse = function() {
|
|
"use strict";
|
|
var CHAR = /[^ \t]/;
|
|
var MULTIVALUE_DELIMITER = ",";
|
|
var VALUE_DELIMITER = ":";
|
|
var PARAM_DELIMITER = ";";
|
|
var PARAM_NAME_DELIMITER = "=";
|
|
var DEFAULT_VALUE_TYPE = "unknown";
|
|
var DEFAULT_PARAM_TYPE = "text";
|
|
var design = ICAL3.design;
|
|
var helpers = ICAL3.helpers;
|
|
function ParserError(message) {
|
|
this.message = message;
|
|
this.name = "ParserError";
|
|
try {
|
|
throw new Error();
|
|
} catch (e3) {
|
|
if (e3.stack) {
|
|
var split = e3.stack.split("\n");
|
|
split.shift();
|
|
this.stack = split.join("\n");
|
|
}
|
|
}
|
|
}
|
|
ParserError.prototype = Error.prototype;
|
|
function parser(input) {
|
|
var state = {};
|
|
var root = state.component = [];
|
|
state.stack = [root];
|
|
parser._eachLine(input, function(err, line) {
|
|
parser._handleContentLine(line, state);
|
|
});
|
|
if (state.stack.length > 1) {
|
|
throw new ParserError("invalid ical body. component began but did not end");
|
|
}
|
|
state = null;
|
|
return root.length == 1 ? root[0] : root;
|
|
}
|
|
parser.property = function(str, designSet) {
|
|
var state = {
|
|
component: [[], []],
|
|
designSet: designSet || design.defaultSet
|
|
};
|
|
parser._handleContentLine(str, state);
|
|
return state.component[1][0];
|
|
};
|
|
parser.component = function(str) {
|
|
return parser(str);
|
|
};
|
|
parser.ParserError = ParserError;
|
|
parser._handleContentLine = function(line, state) {
|
|
var valuePos = line.indexOf(VALUE_DELIMITER);
|
|
var paramPos = line.indexOf(PARAM_DELIMITER);
|
|
var lastParamIndex;
|
|
var lastValuePos;
|
|
var name;
|
|
var value;
|
|
var params = {};
|
|
if (paramPos !== -1 && valuePos !== -1) {
|
|
if (paramPos > valuePos) {
|
|
paramPos = -1;
|
|
}
|
|
}
|
|
var parsedParams;
|
|
if (paramPos !== -1) {
|
|
name = line.substring(0, paramPos).toLowerCase();
|
|
parsedParams = parser._parseParameters(line.substring(paramPos), 0, state.designSet);
|
|
if (parsedParams[2] == -1) {
|
|
throw new ParserError("Invalid parameters in '" + line + "'");
|
|
}
|
|
params = parsedParams[0];
|
|
lastParamIndex = parsedParams[1].length + parsedParams[2] + paramPos;
|
|
if ((lastValuePos = line.substring(lastParamIndex).indexOf(VALUE_DELIMITER)) !== -1) {
|
|
value = line.substring(lastParamIndex + lastValuePos + 1);
|
|
} else {
|
|
throw new ParserError("Missing parameter value in '" + line + "'");
|
|
}
|
|
} else if (valuePos !== -1) {
|
|
name = line.substring(0, valuePos).toLowerCase();
|
|
value = line.substring(valuePos + 1);
|
|
if (name === "begin") {
|
|
var newComponent = [value.toLowerCase(), [], []];
|
|
if (state.stack.length === 1) {
|
|
state.component.push(newComponent);
|
|
} else {
|
|
state.component[2].push(newComponent);
|
|
}
|
|
state.stack.push(state.component);
|
|
state.component = newComponent;
|
|
if (!state.designSet) {
|
|
state.designSet = design.getDesignSet(state.component[0]);
|
|
}
|
|
return;
|
|
} else if (name === "end") {
|
|
state.component = state.stack.pop();
|
|
return;
|
|
}
|
|
} else {
|
|
throw new ParserError('invalid line (no token ";" or ":") "' + line + '"');
|
|
}
|
|
var valueType;
|
|
var multiValue = false;
|
|
var structuredValue = false;
|
|
var propertyDetails;
|
|
if (name in state.designSet.property) {
|
|
propertyDetails = state.designSet.property[name];
|
|
if ("multiValue" in propertyDetails) {
|
|
multiValue = propertyDetails.multiValue;
|
|
}
|
|
if ("structuredValue" in propertyDetails) {
|
|
structuredValue = propertyDetails.structuredValue;
|
|
}
|
|
if (value && "detectType" in propertyDetails) {
|
|
valueType = propertyDetails.detectType(value);
|
|
}
|
|
}
|
|
if (!valueType) {
|
|
if (!("value" in params)) {
|
|
if (propertyDetails) {
|
|
valueType = propertyDetails.defaultType;
|
|
} else {
|
|
valueType = DEFAULT_VALUE_TYPE;
|
|
}
|
|
} else {
|
|
valueType = params.value.toLowerCase();
|
|
}
|
|
}
|
|
delete params.value;
|
|
var result;
|
|
if (multiValue && structuredValue) {
|
|
value = parser._parseMultiValue(value, structuredValue, valueType, [], multiValue, state.designSet, structuredValue);
|
|
result = [name, params, valueType, value];
|
|
} else if (multiValue) {
|
|
result = [name, params, valueType];
|
|
parser._parseMultiValue(value, multiValue, valueType, result, null, state.designSet, false);
|
|
} else if (structuredValue) {
|
|
value = parser._parseMultiValue(value, structuredValue, valueType, [], null, state.designSet, structuredValue);
|
|
result = [name, params, valueType, value];
|
|
} else {
|
|
value = parser._parseValue(value, valueType, state.designSet, false);
|
|
result = [name, params, valueType, value];
|
|
}
|
|
if (state.component[0] === "vcard" && state.component[1].length === 0 && !(name === "version" && value === "4.0")) {
|
|
state.designSet = design.getDesignSet("vcard3");
|
|
}
|
|
state.component[1].push(result);
|
|
};
|
|
parser._parseValue = function(value, type, designSet, structuredValue) {
|
|
if (type in designSet.value && "fromICAL" in designSet.value[type]) {
|
|
return designSet.value[type].fromICAL(value, structuredValue);
|
|
}
|
|
return value;
|
|
};
|
|
parser._parseParameters = function(line, start, designSet) {
|
|
var lastParam = start;
|
|
var pos = 0;
|
|
var delim = PARAM_NAME_DELIMITER;
|
|
var result = {};
|
|
var name, lcname;
|
|
var value, valuePos = -1;
|
|
var type, multiValue, mvdelim;
|
|
while (pos !== false && (pos = helpers.unescapedIndexOf(line, delim, pos + 1)) !== -1) {
|
|
name = line.substr(lastParam + 1, pos - lastParam - 1);
|
|
if (name.length == 0) {
|
|
throw new ParserError("Empty parameter name in '" + line + "'");
|
|
}
|
|
lcname = name.toLowerCase();
|
|
mvdelim = false;
|
|
multiValue = false;
|
|
if (lcname in designSet.param && designSet.param[lcname].valueType) {
|
|
type = designSet.param[lcname].valueType;
|
|
} else {
|
|
type = DEFAULT_PARAM_TYPE;
|
|
}
|
|
if (lcname in designSet.param) {
|
|
multiValue = designSet.param[lcname].multiValue;
|
|
if (designSet.param[lcname].multiValueSeparateDQuote) {
|
|
mvdelim = parser._rfc6868Escape('"' + multiValue + '"');
|
|
}
|
|
}
|
|
var nextChar = line[pos + 1];
|
|
if (nextChar === '"') {
|
|
valuePos = pos + 2;
|
|
pos = helpers.unescapedIndexOf(line, '"', valuePos);
|
|
if (multiValue && pos != -1) {
|
|
var extendedValue = true;
|
|
while (extendedValue) {
|
|
if (line[pos + 1] == multiValue && line[pos + 2] == '"') {
|
|
pos = helpers.unescapedIndexOf(line, '"', pos + 3);
|
|
} else {
|
|
extendedValue = false;
|
|
}
|
|
}
|
|
}
|
|
if (pos === -1) {
|
|
throw new ParserError('invalid line (no matching double quote) "' + line + '"');
|
|
}
|
|
value = line.substr(valuePos, pos - valuePos);
|
|
lastParam = helpers.unescapedIndexOf(line, PARAM_DELIMITER, pos);
|
|
if (lastParam === -1) {
|
|
pos = false;
|
|
}
|
|
} else {
|
|
valuePos = pos + 1;
|
|
var nextPos = helpers.unescapedIndexOf(line, PARAM_DELIMITER, valuePos);
|
|
var propValuePos = helpers.unescapedIndexOf(line, VALUE_DELIMITER, valuePos);
|
|
if (propValuePos !== -1 && nextPos > propValuePos) {
|
|
nextPos = propValuePos;
|
|
pos = false;
|
|
} else if (nextPos === -1) {
|
|
if (propValuePos === -1) {
|
|
nextPos = line.length;
|
|
} else {
|
|
nextPos = propValuePos;
|
|
}
|
|
pos = false;
|
|
} else {
|
|
lastParam = nextPos;
|
|
pos = nextPos;
|
|
}
|
|
value = line.substr(valuePos, nextPos - valuePos);
|
|
}
|
|
value = parser._rfc6868Escape(value);
|
|
if (multiValue) {
|
|
var delimiter = mvdelim || multiValue;
|
|
value = parser._parseMultiValue(value, delimiter, type, [], null, designSet);
|
|
} else {
|
|
value = parser._parseValue(value, type, designSet);
|
|
}
|
|
if (multiValue && lcname in result) {
|
|
if (Array.isArray(result[lcname])) {
|
|
result[lcname].push(value);
|
|
} else {
|
|
result[lcname] = [
|
|
result[lcname],
|
|
value
|
|
];
|
|
}
|
|
} else {
|
|
result[lcname] = value;
|
|
}
|
|
}
|
|
return [result, value, valuePos];
|
|
};
|
|
parser._rfc6868Escape = function(val) {
|
|
return val.replace(/\^['n^]/g, function(x3) {
|
|
return RFC6868_REPLACE_MAP[x3];
|
|
});
|
|
};
|
|
var RFC6868_REPLACE_MAP = { "^'": '"', "^n": "\n", "^^": "^" };
|
|
parser._parseMultiValue = function(buffer, delim, type, result, innerMulti, designSet, structuredValue) {
|
|
var pos = 0;
|
|
var lastPos = 0;
|
|
var value;
|
|
if (delim.length === 0) {
|
|
return buffer;
|
|
}
|
|
while ((pos = helpers.unescapedIndexOf(buffer, delim, lastPos)) !== -1) {
|
|
value = buffer.substr(lastPos, pos - lastPos);
|
|
if (innerMulti) {
|
|
value = parser._parseMultiValue(value, innerMulti, type, [], null, designSet, structuredValue);
|
|
} else {
|
|
value = parser._parseValue(value, type, designSet, structuredValue);
|
|
}
|
|
result.push(value);
|
|
lastPos = pos + delim.length;
|
|
}
|
|
value = buffer.substr(lastPos);
|
|
if (innerMulti) {
|
|
value = parser._parseMultiValue(value, innerMulti, type, [], null, designSet, structuredValue);
|
|
} else {
|
|
value = parser._parseValue(value, type, designSet, structuredValue);
|
|
}
|
|
result.push(value);
|
|
return result.length == 1 ? result[0] : result;
|
|
};
|
|
parser._eachLine = function(buffer, callback) {
|
|
var len = buffer.length;
|
|
var lastPos = buffer.search(CHAR);
|
|
var pos = lastPos;
|
|
var line;
|
|
var firstChar;
|
|
var newlineOffset;
|
|
do {
|
|
pos = buffer.indexOf("\n", lastPos) + 1;
|
|
if (pos > 1 && buffer[pos - 2] === "\r") {
|
|
newlineOffset = 2;
|
|
} else {
|
|
newlineOffset = 1;
|
|
}
|
|
if (pos === 0) {
|
|
pos = len;
|
|
newlineOffset = 0;
|
|
}
|
|
firstChar = buffer[lastPos];
|
|
if (firstChar === " " || firstChar === " ") {
|
|
line += buffer.substr(lastPos + 1, pos - lastPos - (newlineOffset + 1));
|
|
} else {
|
|
if (line)
|
|
callback(null, line);
|
|
line = buffer.substr(lastPos, pos - lastPos - newlineOffset);
|
|
}
|
|
lastPos = pos;
|
|
} while (pos !== len);
|
|
line = line.trim();
|
|
if (line.length)
|
|
callback(null, line);
|
|
};
|
|
return parser;
|
|
}();
|
|
ICAL3.Component = function() {
|
|
"use strict";
|
|
var PROPERTY_INDEX = 1;
|
|
var COMPONENT_INDEX = 2;
|
|
var NAME_INDEX = 0;
|
|
function Component5(jCal, parent) {
|
|
if (typeof jCal === "string") {
|
|
jCal = [jCal, [], []];
|
|
}
|
|
this.jCal = jCal;
|
|
this.parent = parent || null;
|
|
}
|
|
Component5.prototype = {
|
|
_hydratedPropertyCount: 0,
|
|
_hydratedComponentCount: 0,
|
|
get name() {
|
|
return this.jCal[NAME_INDEX];
|
|
},
|
|
get _designSet() {
|
|
var parentDesign = this.parent && this.parent._designSet;
|
|
return parentDesign || ICAL3.design.getDesignSet(this.name);
|
|
},
|
|
_hydrateComponent: function(index) {
|
|
if (!this._components) {
|
|
this._components = [];
|
|
this._hydratedComponentCount = 0;
|
|
}
|
|
if (this._components[index]) {
|
|
return this._components[index];
|
|
}
|
|
var comp = new Component5(this.jCal[COMPONENT_INDEX][index], this);
|
|
this._hydratedComponentCount++;
|
|
return this._components[index] = comp;
|
|
},
|
|
_hydrateProperty: function(index) {
|
|
if (!this._properties) {
|
|
this._properties = [];
|
|
this._hydratedPropertyCount = 0;
|
|
}
|
|
if (this._properties[index]) {
|
|
return this._properties[index];
|
|
}
|
|
var prop = new ICAL3.Property(this.jCal[PROPERTY_INDEX][index], this);
|
|
this._hydratedPropertyCount++;
|
|
return this._properties[index] = prop;
|
|
},
|
|
getFirstSubcomponent: function(name) {
|
|
if (name) {
|
|
var i3 = 0;
|
|
var comps = this.jCal[COMPONENT_INDEX];
|
|
var len = comps.length;
|
|
for (; i3 < len; i3++) {
|
|
if (comps[i3][NAME_INDEX] === name) {
|
|
var result = this._hydrateComponent(i3);
|
|
return result;
|
|
}
|
|
}
|
|
} else {
|
|
if (this.jCal[COMPONENT_INDEX].length) {
|
|
return this._hydrateComponent(0);
|
|
}
|
|
}
|
|
return null;
|
|
},
|
|
getAllSubcomponents: function(name) {
|
|
var jCalLen = this.jCal[COMPONENT_INDEX].length;
|
|
var i3 = 0;
|
|
if (name) {
|
|
var comps = this.jCal[COMPONENT_INDEX];
|
|
var result = [];
|
|
for (; i3 < jCalLen; i3++) {
|
|
if (name === comps[i3][NAME_INDEX]) {
|
|
result.push(this._hydrateComponent(i3));
|
|
}
|
|
}
|
|
return result;
|
|
} else {
|
|
if (!this._components || this._hydratedComponentCount !== jCalLen) {
|
|
for (; i3 < jCalLen; i3++) {
|
|
this._hydrateComponent(i3);
|
|
}
|
|
}
|
|
return this._components || [];
|
|
}
|
|
},
|
|
hasProperty: function(name) {
|
|
var props = this.jCal[PROPERTY_INDEX];
|
|
var len = props.length;
|
|
var i3 = 0;
|
|
for (; i3 < len; i3++) {
|
|
if (props[i3][NAME_INDEX] === name) {
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
},
|
|
getFirstProperty: function(name) {
|
|
if (name) {
|
|
var i3 = 0;
|
|
var props = this.jCal[PROPERTY_INDEX];
|
|
var len = props.length;
|
|
for (; i3 < len; i3++) {
|
|
if (props[i3][NAME_INDEX] === name) {
|
|
var result = this._hydrateProperty(i3);
|
|
return result;
|
|
}
|
|
}
|
|
} else {
|
|
if (this.jCal[PROPERTY_INDEX].length) {
|
|
return this._hydrateProperty(0);
|
|
}
|
|
}
|
|
return null;
|
|
},
|
|
getFirstPropertyValue: function(name) {
|
|
var prop = this.getFirstProperty(name);
|
|
if (prop) {
|
|
return prop.getFirstValue();
|
|
}
|
|
return null;
|
|
},
|
|
getAllProperties: function(name) {
|
|
var jCalLen = this.jCal[PROPERTY_INDEX].length;
|
|
var i3 = 0;
|
|
if (name) {
|
|
var props = this.jCal[PROPERTY_INDEX];
|
|
var result = [];
|
|
for (; i3 < jCalLen; i3++) {
|
|
if (name === props[i3][NAME_INDEX]) {
|
|
result.push(this._hydrateProperty(i3));
|
|
}
|
|
}
|
|
return result;
|
|
} else {
|
|
if (!this._properties || this._hydratedPropertyCount !== jCalLen) {
|
|
for (; i3 < jCalLen; i3++) {
|
|
this._hydrateProperty(i3);
|
|
}
|
|
}
|
|
return this._properties || [];
|
|
}
|
|
},
|
|
_removeObjectByIndex: function(jCalIndex, cache, index) {
|
|
cache = cache || [];
|
|
if (cache[index]) {
|
|
var obj = cache[index];
|
|
if ("parent" in obj) {
|
|
obj.parent = null;
|
|
}
|
|
}
|
|
cache.splice(index, 1);
|
|
this.jCal[jCalIndex].splice(index, 1);
|
|
},
|
|
_removeObject: function(jCalIndex, cache, nameOrObject) {
|
|
var i3 = 0;
|
|
var objects = this.jCal[jCalIndex];
|
|
var len = objects.length;
|
|
var cached = this[cache];
|
|
if (typeof nameOrObject === "string") {
|
|
for (; i3 < len; i3++) {
|
|
if (objects[i3][NAME_INDEX] === nameOrObject) {
|
|
this._removeObjectByIndex(jCalIndex, cached, i3);
|
|
return true;
|
|
}
|
|
}
|
|
} else if (cached) {
|
|
for (; i3 < len; i3++) {
|
|
if (cached[i3] && cached[i3] === nameOrObject) {
|
|
this._removeObjectByIndex(jCalIndex, cached, i3);
|
|
return true;
|
|
}
|
|
}
|
|
}
|
|
return false;
|
|
},
|
|
_removeAllObjects: function(jCalIndex, cache, name) {
|
|
var cached = this[cache];
|
|
var objects = this.jCal[jCalIndex];
|
|
var i3 = objects.length - 1;
|
|
for (; i3 >= 0; i3--) {
|
|
if (!name || objects[i3][NAME_INDEX] === name) {
|
|
this._removeObjectByIndex(jCalIndex, cached, i3);
|
|
}
|
|
}
|
|
},
|
|
addSubcomponent: function(component) {
|
|
if (!this._components) {
|
|
this._components = [];
|
|
this._hydratedComponentCount = 0;
|
|
}
|
|
if (component.parent) {
|
|
component.parent.removeSubcomponent(component);
|
|
}
|
|
var idx = this.jCal[COMPONENT_INDEX].push(component.jCal);
|
|
this._components[idx - 1] = component;
|
|
this._hydratedComponentCount++;
|
|
component.parent = this;
|
|
return component;
|
|
},
|
|
removeSubcomponent: function(nameOrComp) {
|
|
var removed = this._removeObject(COMPONENT_INDEX, "_components", nameOrComp);
|
|
if (removed) {
|
|
this._hydratedComponentCount--;
|
|
}
|
|
return removed;
|
|
},
|
|
removeAllSubcomponents: function(name) {
|
|
var removed = this._removeAllObjects(COMPONENT_INDEX, "_components", name);
|
|
this._hydratedComponentCount = 0;
|
|
return removed;
|
|
},
|
|
addProperty: function(property) {
|
|
if (!(property instanceof ICAL3.Property)) {
|
|
throw new TypeError("must instance of ICAL.Property");
|
|
}
|
|
if (!this._properties) {
|
|
this._properties = [];
|
|
this._hydratedPropertyCount = 0;
|
|
}
|
|
if (property.parent) {
|
|
property.parent.removeProperty(property);
|
|
}
|
|
var idx = this.jCal[PROPERTY_INDEX].push(property.jCal);
|
|
this._properties[idx - 1] = property;
|
|
this._hydratedPropertyCount++;
|
|
property.parent = this;
|
|
return property;
|
|
},
|
|
addPropertyWithValue: function(name, value) {
|
|
var prop = new ICAL3.Property(name);
|
|
prop.setValue(value);
|
|
this.addProperty(prop);
|
|
return prop;
|
|
},
|
|
updatePropertyWithValue: function(name, value) {
|
|
var prop = this.getFirstProperty(name);
|
|
if (prop) {
|
|
prop.setValue(value);
|
|
} else {
|
|
prop = this.addPropertyWithValue(name, value);
|
|
}
|
|
return prop;
|
|
},
|
|
removeProperty: function(nameOrProp) {
|
|
var removed = this._removeObject(PROPERTY_INDEX, "_properties", nameOrProp);
|
|
if (removed) {
|
|
this._hydratedPropertyCount--;
|
|
}
|
|
return removed;
|
|
},
|
|
removeAllProperties: function(name) {
|
|
var removed = this._removeAllObjects(PROPERTY_INDEX, "_properties", name);
|
|
this._hydratedPropertyCount = 0;
|
|
return removed;
|
|
},
|
|
toJSON: function() {
|
|
return this.jCal;
|
|
},
|
|
toString: function() {
|
|
return ICAL3.stringify.component(this.jCal, this._designSet);
|
|
}
|
|
};
|
|
Component5.fromString = function(str) {
|
|
return new Component5(ICAL3.parse.component(str));
|
|
};
|
|
return Component5;
|
|
}();
|
|
ICAL3.Property = function() {
|
|
"use strict";
|
|
var NAME_INDEX = 0;
|
|
var PROP_INDEX = 1;
|
|
var TYPE_INDEX = 2;
|
|
var VALUE_INDEX = 3;
|
|
var design = ICAL3.design;
|
|
function Property(jCal, parent) {
|
|
this._parent = parent || null;
|
|
if (typeof jCal === "string") {
|
|
this.jCal = [jCal, {}, design.defaultType];
|
|
this.jCal[TYPE_INDEX] = this.getDefaultType();
|
|
} else {
|
|
this.jCal = jCal;
|
|
}
|
|
this._updateType();
|
|
}
|
|
Property.prototype = {
|
|
get type() {
|
|
return this.jCal[TYPE_INDEX];
|
|
},
|
|
get name() {
|
|
return this.jCal[NAME_INDEX];
|
|
},
|
|
get parent() {
|
|
return this._parent;
|
|
},
|
|
set parent(p3) {
|
|
var designSetChanged = !this._parent || p3 && p3._designSet != this._parent._designSet;
|
|
this._parent = p3;
|
|
if (this.type == design.defaultType && designSetChanged) {
|
|
this.jCal[TYPE_INDEX] = this.getDefaultType();
|
|
this._updateType();
|
|
}
|
|
return p3;
|
|
},
|
|
get _designSet() {
|
|
return this.parent ? this.parent._designSet : design.defaultSet;
|
|
},
|
|
_updateType: function() {
|
|
var designSet = this._designSet;
|
|
if (this.type in designSet.value) {
|
|
var designType = designSet.value[this.type];
|
|
if ("decorate" in designSet.value[this.type]) {
|
|
this.isDecorated = true;
|
|
} else {
|
|
this.isDecorated = false;
|
|
}
|
|
if (this.name in designSet.property) {
|
|
this.isMultiValue = "multiValue" in designSet.property[this.name];
|
|
this.isStructuredValue = "structuredValue" in designSet.property[this.name];
|
|
}
|
|
}
|
|
},
|
|
_hydrateValue: function(index) {
|
|
if (this._values && this._values[index]) {
|
|
return this._values[index];
|
|
}
|
|
if (this.jCal.length <= VALUE_INDEX + index) {
|
|
return null;
|
|
}
|
|
if (this.isDecorated) {
|
|
if (!this._values) {
|
|
this._values = [];
|
|
}
|
|
return this._values[index] = this._decorate(this.jCal[VALUE_INDEX + index]);
|
|
} else {
|
|
return this.jCal[VALUE_INDEX + index];
|
|
}
|
|
},
|
|
_decorate: function(value) {
|
|
return this._designSet.value[this.type].decorate(value, this);
|
|
},
|
|
_undecorate: function(value) {
|
|
return this._designSet.value[this.type].undecorate(value, this);
|
|
},
|
|
_setDecoratedValue: function(value, index) {
|
|
if (!this._values) {
|
|
this._values = [];
|
|
}
|
|
if (typeof value === "object" && "icaltype" in value) {
|
|
this.jCal[VALUE_INDEX + index] = this._undecorate(value);
|
|
this._values[index] = value;
|
|
} else {
|
|
this.jCal[VALUE_INDEX + index] = value;
|
|
this._values[index] = this._decorate(value);
|
|
}
|
|
},
|
|
getParameter: function(name) {
|
|
if (name in this.jCal[PROP_INDEX]) {
|
|
return this.jCal[PROP_INDEX][name];
|
|
} else {
|
|
return void 0;
|
|
}
|
|
},
|
|
getFirstParameter: function(name) {
|
|
var parameters = this.getParameter(name);
|
|
if (Array.isArray(parameters)) {
|
|
return parameters[0];
|
|
}
|
|
return parameters;
|
|
},
|
|
setParameter: function(name, value) {
|
|
var lcname = name.toLowerCase();
|
|
if (typeof value === "string" && lcname in this._designSet.param && "multiValue" in this._designSet.param[lcname]) {
|
|
value = [value];
|
|
}
|
|
this.jCal[PROP_INDEX][name] = value;
|
|
},
|
|
removeParameter: function(name) {
|
|
delete this.jCal[PROP_INDEX][name];
|
|
},
|
|
getDefaultType: function() {
|
|
var name = this.jCal[NAME_INDEX];
|
|
var designSet = this._designSet;
|
|
if (name in designSet.property) {
|
|
var details = designSet.property[name];
|
|
if ("defaultType" in details) {
|
|
return details.defaultType;
|
|
}
|
|
}
|
|
return design.defaultType;
|
|
},
|
|
resetType: function(type) {
|
|
this.removeAllValues();
|
|
this.jCal[TYPE_INDEX] = type;
|
|
this._updateType();
|
|
},
|
|
getFirstValue: function() {
|
|
return this._hydrateValue(0);
|
|
},
|
|
getValues: function() {
|
|
var len = this.jCal.length - VALUE_INDEX;
|
|
if (len < 1) {
|
|
return [];
|
|
}
|
|
var i3 = 0;
|
|
var result = [];
|
|
for (; i3 < len; i3++) {
|
|
result[i3] = this._hydrateValue(i3);
|
|
}
|
|
return result;
|
|
},
|
|
removeAllValues: function() {
|
|
if (this._values) {
|
|
this._values.length = 0;
|
|
}
|
|
this.jCal.length = 3;
|
|
},
|
|
setValues: function(values) {
|
|
if (!this.isMultiValue) {
|
|
throw new Error(this.name + ": does not not support mulitValue.\noverride isMultiValue");
|
|
}
|
|
var len = values.length;
|
|
var i3 = 0;
|
|
this.removeAllValues();
|
|
if (len > 0 && typeof values[0] === "object" && "icaltype" in values[0]) {
|
|
this.resetType(values[0].icaltype);
|
|
}
|
|
if (this.isDecorated) {
|
|
for (; i3 < len; i3++) {
|
|
this._setDecoratedValue(values[i3], i3);
|
|
}
|
|
} else {
|
|
for (; i3 < len; i3++) {
|
|
this.jCal[VALUE_INDEX + i3] = values[i3];
|
|
}
|
|
}
|
|
},
|
|
setValue: function(value) {
|
|
this.removeAllValues();
|
|
if (typeof value === "object" && "icaltype" in value) {
|
|
this.resetType(value.icaltype);
|
|
}
|
|
if (this.isDecorated) {
|
|
this._setDecoratedValue(value, 0);
|
|
} else {
|
|
this.jCal[VALUE_INDEX] = value;
|
|
}
|
|
},
|
|
toJSON: function() {
|
|
return this.jCal;
|
|
},
|
|
toICALString: function() {
|
|
return ICAL3.stringify.property(this.jCal, this._designSet, true);
|
|
}
|
|
};
|
|
Property.fromString = function(str, designSet) {
|
|
return new Property(ICAL3.parse.property(str, designSet));
|
|
};
|
|
return Property;
|
|
}();
|
|
ICAL3.UtcOffset = function() {
|
|
function UtcOffset(aData) {
|
|
this.fromData(aData);
|
|
}
|
|
UtcOffset.prototype = {
|
|
hours: 0,
|
|
minutes: 0,
|
|
factor: 1,
|
|
icaltype: "utc-offset",
|
|
clone: function() {
|
|
return ICAL3.UtcOffset.fromSeconds(this.toSeconds());
|
|
},
|
|
fromData: function(aData) {
|
|
if (aData) {
|
|
for (var key in aData) {
|
|
if (aData.hasOwnProperty(key)) {
|
|
this[key] = aData[key];
|
|
}
|
|
}
|
|
}
|
|
this._normalize();
|
|
},
|
|
fromSeconds: function(aSeconds) {
|
|
var secs = Math.abs(aSeconds);
|
|
this.factor = aSeconds < 0 ? -1 : 1;
|
|
this.hours = ICAL3.helpers.trunc(secs / 3600);
|
|
secs -= this.hours * 3600;
|
|
this.minutes = ICAL3.helpers.trunc(secs / 60);
|
|
return this;
|
|
},
|
|
toSeconds: function() {
|
|
return this.factor * (60 * this.minutes + 3600 * this.hours);
|
|
},
|
|
compare: function icaltime_compare(other) {
|
|
var a3 = this.toSeconds();
|
|
var b3 = other.toSeconds();
|
|
return (a3 > b3) - (b3 > a3);
|
|
},
|
|
_normalize: function() {
|
|
var secs = this.toSeconds();
|
|
var factor = this.factor;
|
|
while (secs < -43200) {
|
|
secs += 97200;
|
|
}
|
|
while (secs > 50400) {
|
|
secs -= 97200;
|
|
}
|
|
this.fromSeconds(secs);
|
|
if (secs == 0) {
|
|
this.factor = factor;
|
|
}
|
|
},
|
|
toICALString: function() {
|
|
return ICAL3.design.icalendar.value["utc-offset"].toICAL(this.toString());
|
|
},
|
|
toString: function toString() {
|
|
return (this.factor == 1 ? "+" : "-") + ICAL3.helpers.pad2(this.hours) + ":" + ICAL3.helpers.pad2(this.minutes);
|
|
}
|
|
};
|
|
UtcOffset.fromString = function(aString) {
|
|
var options = {};
|
|
options.factor = aString[0] === "+" ? 1 : -1;
|
|
options.hours = ICAL3.helpers.strictParseInt(aString.substr(1, 2));
|
|
options.minutes = ICAL3.helpers.strictParseInt(aString.substr(4, 2));
|
|
return new ICAL3.UtcOffset(options);
|
|
};
|
|
UtcOffset.fromSeconds = function(aSeconds) {
|
|
var instance = new UtcOffset();
|
|
instance.fromSeconds(aSeconds);
|
|
return instance;
|
|
};
|
|
return UtcOffset;
|
|
}();
|
|
ICAL3.Binary = function() {
|
|
function Binary(aValue) {
|
|
this.value = aValue;
|
|
}
|
|
Binary.prototype = {
|
|
icaltype: "binary",
|
|
decodeValue: function decodeValue() {
|
|
return this._b64_decode(this.value);
|
|
},
|
|
setEncodedValue: function setEncodedValue(aValue) {
|
|
this.value = this._b64_encode(aValue);
|
|
},
|
|
_b64_encode: function base64_encode(data) {
|
|
var b64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
|
|
var o1, o2, o3, h1, h22, h3, h4, bits, i3 = 0, ac = 0, enc = "", tmp_arr = [];
|
|
if (!data) {
|
|
return data;
|
|
}
|
|
do {
|
|
o1 = data.charCodeAt(i3++);
|
|
o2 = data.charCodeAt(i3++);
|
|
o3 = data.charCodeAt(i3++);
|
|
bits = o1 << 16 | o2 << 8 | o3;
|
|
h1 = bits >> 18 & 63;
|
|
h22 = bits >> 12 & 63;
|
|
h3 = bits >> 6 & 63;
|
|
h4 = bits & 63;
|
|
tmp_arr[ac++] = b64.charAt(h1) + b64.charAt(h22) + b64.charAt(h3) + b64.charAt(h4);
|
|
} while (i3 < data.length);
|
|
enc = tmp_arr.join("");
|
|
var r3 = data.length % 3;
|
|
return (r3 ? enc.slice(0, r3 - 3) : enc) + "===".slice(r3 || 3);
|
|
},
|
|
_b64_decode: function base64_decode(data) {
|
|
var b64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
|
|
var o1, o2, o3, h1, h22, h3, h4, bits, i3 = 0, ac = 0, dec = "", tmp_arr = [];
|
|
if (!data) {
|
|
return data;
|
|
}
|
|
data += "";
|
|
do {
|
|
h1 = b64.indexOf(data.charAt(i3++));
|
|
h22 = b64.indexOf(data.charAt(i3++));
|
|
h3 = b64.indexOf(data.charAt(i3++));
|
|
h4 = b64.indexOf(data.charAt(i3++));
|
|
bits = h1 << 18 | h22 << 12 | h3 << 6 | h4;
|
|
o1 = bits >> 16 & 255;
|
|
o2 = bits >> 8 & 255;
|
|
o3 = bits & 255;
|
|
if (h3 == 64) {
|
|
tmp_arr[ac++] = String.fromCharCode(o1);
|
|
} else if (h4 == 64) {
|
|
tmp_arr[ac++] = String.fromCharCode(o1, o2);
|
|
} else {
|
|
tmp_arr[ac++] = String.fromCharCode(o1, o2, o3);
|
|
}
|
|
} while (i3 < data.length);
|
|
dec = tmp_arr.join("");
|
|
return dec;
|
|
},
|
|
toString: function() {
|
|
return this.value;
|
|
}
|
|
};
|
|
Binary.fromString = function(aString) {
|
|
return new Binary(aString);
|
|
};
|
|
return Binary;
|
|
}();
|
|
(function() {
|
|
ICAL3.Period = function icalperiod(aData) {
|
|
this.wrappedJSObject = this;
|
|
if (aData && "start" in aData) {
|
|
if (aData.start && !(aData.start instanceof ICAL3.Time)) {
|
|
throw new TypeError(".start must be an instance of ICAL.Time");
|
|
}
|
|
this.start = aData.start;
|
|
}
|
|
if (aData && aData.end && aData.duration) {
|
|
throw new Error("cannot accept both end and duration");
|
|
}
|
|
if (aData && "end" in aData) {
|
|
if (aData.end && !(aData.end instanceof ICAL3.Time)) {
|
|
throw new TypeError(".end must be an instance of ICAL.Time");
|
|
}
|
|
this.end = aData.end;
|
|
}
|
|
if (aData && "duration" in aData) {
|
|
if (aData.duration && !(aData.duration instanceof ICAL3.Duration)) {
|
|
throw new TypeError(".duration must be an instance of ICAL.Duration");
|
|
}
|
|
this.duration = aData.duration;
|
|
}
|
|
};
|
|
ICAL3.Period.prototype = {
|
|
start: null,
|
|
end: null,
|
|
duration: null,
|
|
icalclass: "icalperiod",
|
|
icaltype: "period",
|
|
clone: function() {
|
|
return ICAL3.Period.fromData({
|
|
start: this.start ? this.start.clone() : null,
|
|
end: this.end ? this.end.clone() : null,
|
|
duration: this.duration ? this.duration.clone() : null
|
|
});
|
|
},
|
|
getDuration: function duration() {
|
|
if (this.duration) {
|
|
return this.duration;
|
|
} else {
|
|
return this.end.subtractDate(this.start);
|
|
}
|
|
},
|
|
getEnd: function() {
|
|
if (this.end) {
|
|
return this.end;
|
|
} else {
|
|
var end = this.start.clone();
|
|
end.addDuration(this.duration);
|
|
return end;
|
|
}
|
|
},
|
|
toString: function toString() {
|
|
return this.start + "/" + (this.end || this.duration);
|
|
},
|
|
toJSON: function() {
|
|
return [this.start.toString(), (this.end || this.duration).toString()];
|
|
},
|
|
toICALString: function() {
|
|
return this.start.toICALString() + "/" + (this.end || this.duration).toICALString();
|
|
}
|
|
};
|
|
ICAL3.Period.fromString = function fromString(str, prop) {
|
|
var parts = str.split("/");
|
|
if (parts.length !== 2) {
|
|
throw new Error('Invalid string value: "' + str + '" must contain a "/" char.');
|
|
}
|
|
var options = {
|
|
start: ICAL3.Time.fromDateTimeString(parts[0], prop)
|
|
};
|
|
var end = parts[1];
|
|
if (ICAL3.Duration.isValueString(end)) {
|
|
options.duration = ICAL3.Duration.fromString(end);
|
|
} else {
|
|
options.end = ICAL3.Time.fromDateTimeString(end, prop);
|
|
}
|
|
return new ICAL3.Period(options);
|
|
};
|
|
ICAL3.Period.fromData = function fromData(aData) {
|
|
return new ICAL3.Period(aData);
|
|
};
|
|
ICAL3.Period.fromJSON = function(aData, aProp, aLenient) {
|
|
function fromDateOrDateTimeString(aValue, aProp2) {
|
|
if (aLenient) {
|
|
return ICAL3.Time.fromString(aValue, aProp2);
|
|
} else {
|
|
return ICAL3.Time.fromDateTimeString(aValue, aProp2);
|
|
}
|
|
}
|
|
if (ICAL3.Duration.isValueString(aData[1])) {
|
|
return ICAL3.Period.fromData({
|
|
start: fromDateOrDateTimeString(aData[0], aProp),
|
|
duration: ICAL3.Duration.fromString(aData[1])
|
|
});
|
|
} else {
|
|
return ICAL3.Period.fromData({
|
|
start: fromDateOrDateTimeString(aData[0], aProp),
|
|
end: fromDateOrDateTimeString(aData[1], aProp)
|
|
});
|
|
}
|
|
};
|
|
})();
|
|
(function() {
|
|
var DURATION_LETTERS = /([PDWHMTS]{1,1})/;
|
|
ICAL3.Duration = function icalduration(data) {
|
|
this.wrappedJSObject = this;
|
|
this.fromData(data);
|
|
};
|
|
ICAL3.Duration.prototype = {
|
|
weeks: 0,
|
|
days: 0,
|
|
hours: 0,
|
|
minutes: 0,
|
|
seconds: 0,
|
|
isNegative: false,
|
|
icalclass: "icalduration",
|
|
icaltype: "duration",
|
|
clone: function clone() {
|
|
return ICAL3.Duration.fromData(this);
|
|
},
|
|
toSeconds: function toSeconds() {
|
|
var seconds = this.seconds + 60 * this.minutes + 3600 * this.hours + 86400 * this.days + 7 * 86400 * this.weeks;
|
|
return this.isNegative ? -seconds : seconds;
|
|
},
|
|
fromSeconds: function fromSeconds(aSeconds) {
|
|
var secs = Math.abs(aSeconds);
|
|
this.isNegative = aSeconds < 0;
|
|
this.days = ICAL3.helpers.trunc(secs / 86400);
|
|
if (this.days % 7 == 0) {
|
|
this.weeks = this.days / 7;
|
|
this.days = 0;
|
|
} else {
|
|
this.weeks = 0;
|
|
}
|
|
secs -= (this.days + 7 * this.weeks) * 86400;
|
|
this.hours = ICAL3.helpers.trunc(secs / 3600);
|
|
secs -= this.hours * 3600;
|
|
this.minutes = ICAL3.helpers.trunc(secs / 60);
|
|
secs -= this.minutes * 60;
|
|
this.seconds = secs;
|
|
return this;
|
|
},
|
|
fromData: function fromData(aData) {
|
|
var propsToCopy = [
|
|
"weeks",
|
|
"days",
|
|
"hours",
|
|
"minutes",
|
|
"seconds",
|
|
"isNegative"
|
|
];
|
|
for (var key in propsToCopy) {
|
|
if (!propsToCopy.hasOwnProperty(key)) {
|
|
continue;
|
|
}
|
|
var prop = propsToCopy[key];
|
|
if (aData && prop in aData) {
|
|
this[prop] = aData[prop];
|
|
} else {
|
|
this[prop] = 0;
|
|
}
|
|
}
|
|
},
|
|
reset: function reset() {
|
|
this.isNegative = false;
|
|
this.weeks = 0;
|
|
this.days = 0;
|
|
this.hours = 0;
|
|
this.minutes = 0;
|
|
this.seconds = 0;
|
|
},
|
|
compare: function compare(aOther) {
|
|
var thisSeconds = this.toSeconds();
|
|
var otherSeconds = aOther.toSeconds();
|
|
return (thisSeconds > otherSeconds) - (thisSeconds < otherSeconds);
|
|
},
|
|
normalize: function normalize() {
|
|
this.fromSeconds(this.toSeconds());
|
|
},
|
|
toString: function toString() {
|
|
if (this.toSeconds() == 0) {
|
|
return "PT0S";
|
|
} else {
|
|
var str = "";
|
|
if (this.isNegative)
|
|
str += "-";
|
|
str += "P";
|
|
if (this.weeks)
|
|
str += this.weeks + "W";
|
|
if (this.days)
|
|
str += this.days + "D";
|
|
if (this.hours || this.minutes || this.seconds) {
|
|
str += "T";
|
|
if (this.hours)
|
|
str += this.hours + "H";
|
|
if (this.minutes)
|
|
str += this.minutes + "M";
|
|
if (this.seconds)
|
|
str += this.seconds + "S";
|
|
}
|
|
return str;
|
|
}
|
|
},
|
|
toICALString: function() {
|
|
return this.toString();
|
|
}
|
|
};
|
|
ICAL3.Duration.fromSeconds = function icalduration_from_seconds(aSeconds) {
|
|
return new ICAL3.Duration().fromSeconds(aSeconds);
|
|
};
|
|
function parseDurationChunk(letter, number, object) {
|
|
var type;
|
|
switch (letter) {
|
|
case "P":
|
|
if (number && number === "-") {
|
|
object.isNegative = true;
|
|
} else {
|
|
object.isNegative = false;
|
|
}
|
|
break;
|
|
case "D":
|
|
type = "days";
|
|
break;
|
|
case "W":
|
|
type = "weeks";
|
|
break;
|
|
case "H":
|
|
type = "hours";
|
|
break;
|
|
case "M":
|
|
type = "minutes";
|
|
break;
|
|
case "S":
|
|
type = "seconds";
|
|
break;
|
|
default:
|
|
return 0;
|
|
}
|
|
if (type) {
|
|
if (!number && number !== 0) {
|
|
throw new Error('invalid duration value: Missing number before "' + letter + '"');
|
|
}
|
|
var num = parseInt(number, 10);
|
|
if (ICAL3.helpers.isStrictlyNaN(num)) {
|
|
throw new Error('invalid duration value: Invalid number "' + number + '" before "' + letter + '"');
|
|
}
|
|
object[type] = num;
|
|
}
|
|
return 1;
|
|
}
|
|
ICAL3.Duration.isValueString = function(string) {
|
|
return string[0] === "P" || string[1] === "P";
|
|
};
|
|
ICAL3.Duration.fromString = function icalduration_from_string(aStr) {
|
|
var pos = 0;
|
|
var dict = Object.create(null);
|
|
var chunks = 0;
|
|
while ((pos = aStr.search(DURATION_LETTERS)) !== -1) {
|
|
var type = aStr[pos];
|
|
var numeric = aStr.substr(0, pos);
|
|
aStr = aStr.substr(pos + 1);
|
|
chunks += parseDurationChunk(type, numeric, dict);
|
|
}
|
|
if (chunks < 2) {
|
|
throw new Error('invalid duration value: Not enough duration components in "' + aStr + '"');
|
|
}
|
|
return new ICAL3.Duration(dict);
|
|
};
|
|
ICAL3.Duration.fromData = function icalduration_from_data(aData) {
|
|
return new ICAL3.Duration(aData);
|
|
};
|
|
})();
|
|
(function() {
|
|
var OPTIONS = [
|
|
"tzid",
|
|
"location",
|
|
"tznames",
|
|
"latitude",
|
|
"longitude"
|
|
];
|
|
ICAL3.Timezone = function icaltimezone(data) {
|
|
this.wrappedJSObject = this;
|
|
this.fromData(data);
|
|
};
|
|
ICAL3.Timezone.prototype = {
|
|
tzid: "",
|
|
location: "",
|
|
tznames: "",
|
|
latitude: 0,
|
|
longitude: 0,
|
|
component: null,
|
|
expandedUntilYear: 0,
|
|
icalclass: "icaltimezone",
|
|
fromData: function fromData(aData) {
|
|
this.expandedUntilYear = 0;
|
|
this.changes = [];
|
|
if (aData instanceof ICAL3.Component) {
|
|
this.component = aData;
|
|
} else {
|
|
if (aData && "component" in aData) {
|
|
if (typeof aData.component == "string") {
|
|
var jCal = ICAL3.parse(aData.component);
|
|
this.component = new ICAL3.Component(jCal);
|
|
} else if (aData.component instanceof ICAL3.Component) {
|
|
this.component = aData.component;
|
|
} else {
|
|
this.component = null;
|
|
}
|
|
}
|
|
for (var key in OPTIONS) {
|
|
if (OPTIONS.hasOwnProperty(key)) {
|
|
var prop = OPTIONS[key];
|
|
if (aData && prop in aData) {
|
|
this[prop] = aData[prop];
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (this.component instanceof ICAL3.Component && !this.tzid) {
|
|
this.tzid = this.component.getFirstPropertyValue("tzid");
|
|
}
|
|
return this;
|
|
},
|
|
utcOffset: function utcOffset(tt) {
|
|
if (this == ICAL3.Timezone.utcTimezone || this == ICAL3.Timezone.localTimezone) {
|
|
return 0;
|
|
}
|
|
this._ensureCoverage(tt.year);
|
|
if (!this.changes.length) {
|
|
return 0;
|
|
}
|
|
var tt_change = {
|
|
year: tt.year,
|
|
month: tt.month,
|
|
day: tt.day,
|
|
hour: tt.hour,
|
|
minute: tt.minute,
|
|
second: tt.second
|
|
};
|
|
var change_num = this._findNearbyChange(tt_change);
|
|
var change_num_to_use = -1;
|
|
var step = 1;
|
|
for (; ; ) {
|
|
var change = ICAL3.helpers.clone(this.changes[change_num], true);
|
|
if (change.utcOffset < change.prevUtcOffset) {
|
|
ICAL3.Timezone.adjust_change(change, 0, 0, 0, change.utcOffset);
|
|
} else {
|
|
ICAL3.Timezone.adjust_change(change, 0, 0, 0, change.prevUtcOffset);
|
|
}
|
|
var cmp = ICAL3.Timezone._compare_change_fn(tt_change, change);
|
|
if (cmp >= 0) {
|
|
change_num_to_use = change_num;
|
|
} else {
|
|
step = -1;
|
|
}
|
|
if (step == -1 && change_num_to_use != -1) {
|
|
break;
|
|
}
|
|
change_num += step;
|
|
if (change_num < 0) {
|
|
return 0;
|
|
}
|
|
if (change_num >= this.changes.length) {
|
|
break;
|
|
}
|
|
}
|
|
var zone_change = this.changes[change_num_to_use];
|
|
var utcOffset_change = zone_change.utcOffset - zone_change.prevUtcOffset;
|
|
if (utcOffset_change < 0 && change_num_to_use > 0) {
|
|
var tmp_change = ICAL3.helpers.clone(zone_change, true);
|
|
ICAL3.Timezone.adjust_change(tmp_change, 0, 0, 0, tmp_change.prevUtcOffset);
|
|
if (ICAL3.Timezone._compare_change_fn(tt_change, tmp_change) < 0) {
|
|
var prev_zone_change = this.changes[change_num_to_use - 1];
|
|
var want_daylight = false;
|
|
if (zone_change.is_daylight != want_daylight && prev_zone_change.is_daylight == want_daylight) {
|
|
zone_change = prev_zone_change;
|
|
}
|
|
}
|
|
}
|
|
return zone_change.utcOffset;
|
|
},
|
|
_findNearbyChange: function icaltimezone_find_nearby_change(change) {
|
|
var idx = ICAL3.helpers.binsearchInsert(this.changes, change, ICAL3.Timezone._compare_change_fn);
|
|
if (idx >= this.changes.length) {
|
|
return this.changes.length - 1;
|
|
}
|
|
return idx;
|
|
},
|
|
_ensureCoverage: function(aYear) {
|
|
if (ICAL3.Timezone._minimumExpansionYear == -1) {
|
|
var today = ICAL3.Time.now();
|
|
ICAL3.Timezone._minimumExpansionYear = today.year;
|
|
}
|
|
var changesEndYear = aYear;
|
|
if (changesEndYear < ICAL3.Timezone._minimumExpansionYear) {
|
|
changesEndYear = ICAL3.Timezone._minimumExpansionYear;
|
|
}
|
|
changesEndYear += ICAL3.Timezone.EXTRA_COVERAGE;
|
|
if (changesEndYear > ICAL3.Timezone.MAX_YEAR) {
|
|
changesEndYear = ICAL3.Timezone.MAX_YEAR;
|
|
}
|
|
if (!this.changes.length || this.expandedUntilYear < aYear) {
|
|
var subcomps = this.component.getAllSubcomponents();
|
|
var compLen = subcomps.length;
|
|
var compIdx = 0;
|
|
for (; compIdx < compLen; compIdx++) {
|
|
this._expandComponent(subcomps[compIdx], changesEndYear, this.changes);
|
|
}
|
|
this.changes.sort(ICAL3.Timezone._compare_change_fn);
|
|
this.expandedUntilYear = changesEndYear;
|
|
}
|
|
},
|
|
_expandComponent: function(aComponent, aYear, changes) {
|
|
if (!aComponent.hasProperty("dtstart") || !aComponent.hasProperty("tzoffsetto") || !aComponent.hasProperty("tzoffsetfrom")) {
|
|
return null;
|
|
}
|
|
var dtstart = aComponent.getFirstProperty("dtstart").getFirstValue();
|
|
var change;
|
|
function convert_tzoffset(offset) {
|
|
return offset.factor * (offset.hours * 3600 + offset.minutes * 60);
|
|
}
|
|
function init_changes() {
|
|
var changebase = {};
|
|
changebase.is_daylight = aComponent.name == "daylight";
|
|
changebase.utcOffset = convert_tzoffset(aComponent.getFirstProperty("tzoffsetto").getFirstValue());
|
|
changebase.prevUtcOffset = convert_tzoffset(aComponent.getFirstProperty("tzoffsetfrom").getFirstValue());
|
|
return changebase;
|
|
}
|
|
if (!aComponent.hasProperty("rrule") && !aComponent.hasProperty("rdate")) {
|
|
change = init_changes();
|
|
change.year = dtstart.year;
|
|
change.month = dtstart.month;
|
|
change.day = dtstart.day;
|
|
change.hour = dtstart.hour;
|
|
change.minute = dtstart.minute;
|
|
change.second = dtstart.second;
|
|
ICAL3.Timezone.adjust_change(change, 0, 0, 0, -change.prevUtcOffset);
|
|
changes.push(change);
|
|
} else {
|
|
var props = aComponent.getAllProperties("rdate");
|
|
for (var rdatekey in props) {
|
|
if (!props.hasOwnProperty(rdatekey)) {
|
|
continue;
|
|
}
|
|
var rdate = props[rdatekey];
|
|
var time = rdate.getFirstValue();
|
|
change = init_changes();
|
|
change.year = time.year;
|
|
change.month = time.month;
|
|
change.day = time.day;
|
|
if (time.isDate) {
|
|
change.hour = dtstart.hour;
|
|
change.minute = dtstart.minute;
|
|
change.second = dtstart.second;
|
|
if (dtstart.zone != ICAL3.Timezone.utcTimezone) {
|
|
ICAL3.Timezone.adjust_change(change, 0, 0, 0, -change.prevUtcOffset);
|
|
}
|
|
} else {
|
|
change.hour = time.hour;
|
|
change.minute = time.minute;
|
|
change.second = time.second;
|
|
if (time.zone != ICAL3.Timezone.utcTimezone) {
|
|
ICAL3.Timezone.adjust_change(change, 0, 0, 0, -change.prevUtcOffset);
|
|
}
|
|
}
|
|
changes.push(change);
|
|
}
|
|
var rrule = aComponent.getFirstProperty("rrule");
|
|
if (rrule) {
|
|
rrule = rrule.getFirstValue();
|
|
change = init_changes();
|
|
if (rrule.until && rrule.until.zone == ICAL3.Timezone.utcTimezone) {
|
|
rrule.until.adjust(0, 0, 0, change.prevUtcOffset);
|
|
rrule.until.zone = ICAL3.Timezone.localTimezone;
|
|
}
|
|
var iterator = rrule.iterator(dtstart);
|
|
var occ;
|
|
while (occ = iterator.next()) {
|
|
change = init_changes();
|
|
if (occ.year > aYear || !occ) {
|
|
break;
|
|
}
|
|
change.year = occ.year;
|
|
change.month = occ.month;
|
|
change.day = occ.day;
|
|
change.hour = occ.hour;
|
|
change.minute = occ.minute;
|
|
change.second = occ.second;
|
|
change.isDate = occ.isDate;
|
|
ICAL3.Timezone.adjust_change(change, 0, 0, 0, -change.prevUtcOffset);
|
|
changes.push(change);
|
|
}
|
|
}
|
|
}
|
|
return changes;
|
|
},
|
|
toString: function toString() {
|
|
return this.tznames ? this.tznames : this.tzid;
|
|
}
|
|
};
|
|
ICAL3.Timezone._compare_change_fn = function icaltimezone_compare_change_fn(a3, b3) {
|
|
if (a3.year < b3.year)
|
|
return -1;
|
|
else if (a3.year > b3.year)
|
|
return 1;
|
|
if (a3.month < b3.month)
|
|
return -1;
|
|
else if (a3.month > b3.month)
|
|
return 1;
|
|
if (a3.day < b3.day)
|
|
return -1;
|
|
else if (a3.day > b3.day)
|
|
return 1;
|
|
if (a3.hour < b3.hour)
|
|
return -1;
|
|
else if (a3.hour > b3.hour)
|
|
return 1;
|
|
if (a3.minute < b3.minute)
|
|
return -1;
|
|
else if (a3.minute > b3.minute)
|
|
return 1;
|
|
if (a3.second < b3.second)
|
|
return -1;
|
|
else if (a3.second > b3.second)
|
|
return 1;
|
|
return 0;
|
|
};
|
|
ICAL3.Timezone.convert_time = function icaltimezone_convert_time(tt, from_zone, to_zone) {
|
|
if (tt.isDate || from_zone.tzid == to_zone.tzid || from_zone == ICAL3.Timezone.localTimezone || to_zone == ICAL3.Timezone.localTimezone) {
|
|
tt.zone = to_zone;
|
|
return tt;
|
|
}
|
|
var utcOffset = from_zone.utcOffset(tt);
|
|
tt.adjust(0, 0, 0, -utcOffset);
|
|
utcOffset = to_zone.utcOffset(tt);
|
|
tt.adjust(0, 0, 0, utcOffset);
|
|
return null;
|
|
};
|
|
ICAL3.Timezone.fromData = function icaltimezone_fromData(aData) {
|
|
var tt = new ICAL3.Timezone();
|
|
return tt.fromData(aData);
|
|
};
|
|
ICAL3.Timezone.utcTimezone = ICAL3.Timezone.fromData({
|
|
tzid: "UTC"
|
|
});
|
|
ICAL3.Timezone.localTimezone = ICAL3.Timezone.fromData({
|
|
tzid: "floating"
|
|
});
|
|
ICAL3.Timezone.adjust_change = function icaltimezone_adjust_change(change, days, hours, minutes, seconds) {
|
|
return ICAL3.Time.prototype.adjust.call(change, days, hours, minutes, seconds, change);
|
|
};
|
|
ICAL3.Timezone._minimumExpansionYear = -1;
|
|
ICAL3.Timezone.MAX_YEAR = 2035;
|
|
ICAL3.Timezone.EXTRA_COVERAGE = 5;
|
|
})();
|
|
ICAL3.TimezoneService = function() {
|
|
var zones;
|
|
var TimezoneService = {
|
|
get count() {
|
|
return Object.keys(zones).length;
|
|
},
|
|
reset: function() {
|
|
zones = Object.create(null);
|
|
var utc = ICAL3.Timezone.utcTimezone;
|
|
zones.Z = utc;
|
|
zones.UTC = utc;
|
|
zones.GMT = utc;
|
|
},
|
|
has: function(tzid) {
|
|
return !!zones[tzid];
|
|
},
|
|
get: function(tzid) {
|
|
return zones[tzid];
|
|
},
|
|
register: function(name, timezone) {
|
|
if (name instanceof ICAL3.Component) {
|
|
if (name.name === "vtimezone") {
|
|
timezone = new ICAL3.Timezone(name);
|
|
name = timezone.tzid;
|
|
}
|
|
}
|
|
if (timezone instanceof ICAL3.Timezone) {
|
|
zones[name] = timezone;
|
|
} else {
|
|
throw new TypeError("timezone must be ICAL.Timezone or ICAL.Component");
|
|
}
|
|
},
|
|
remove: function(tzid) {
|
|
return delete zones[tzid];
|
|
}
|
|
};
|
|
TimezoneService.reset();
|
|
return TimezoneService;
|
|
}();
|
|
(function() {
|
|
ICAL3.Time = function icaltime(data, zone) {
|
|
this.wrappedJSObject = this;
|
|
var time = this._time = Object.create(null);
|
|
time.year = 0;
|
|
time.month = 1;
|
|
time.day = 1;
|
|
time.hour = 0;
|
|
time.minute = 0;
|
|
time.second = 0;
|
|
time.isDate = false;
|
|
this.fromData(data, zone);
|
|
};
|
|
ICAL3.Time._dowCache = {};
|
|
ICAL3.Time._wnCache = {};
|
|
ICAL3.Time.prototype = {
|
|
icalclass: "icaltime",
|
|
_cachedUnixTime: null,
|
|
get icaltype() {
|
|
return this.isDate ? "date" : "date-time";
|
|
},
|
|
zone: null,
|
|
_pendingNormalization: false,
|
|
clone: function() {
|
|
return new ICAL3.Time(this._time, this.zone);
|
|
},
|
|
reset: function icaltime_reset() {
|
|
this.fromData(ICAL3.Time.epochTime);
|
|
this.zone = ICAL3.Timezone.utcTimezone;
|
|
},
|
|
resetTo: function icaltime_resetTo(year, month, day, hour, minute, second, timezone) {
|
|
this.fromData({
|
|
year,
|
|
month,
|
|
day,
|
|
hour,
|
|
minute,
|
|
second,
|
|
zone: timezone
|
|
});
|
|
},
|
|
fromJSDate: function icaltime_fromJSDate(aDate, useUTC) {
|
|
if (!aDate) {
|
|
this.reset();
|
|
} else {
|
|
if (useUTC) {
|
|
this.zone = ICAL3.Timezone.utcTimezone;
|
|
this.year = aDate.getUTCFullYear();
|
|
this.month = aDate.getUTCMonth() + 1;
|
|
this.day = aDate.getUTCDate();
|
|
this.hour = aDate.getUTCHours();
|
|
this.minute = aDate.getUTCMinutes();
|
|
this.second = aDate.getUTCSeconds();
|
|
} else {
|
|
this.zone = ICAL3.Timezone.localTimezone;
|
|
this.year = aDate.getFullYear();
|
|
this.month = aDate.getMonth() + 1;
|
|
this.day = aDate.getDate();
|
|
this.hour = aDate.getHours();
|
|
this.minute = aDate.getMinutes();
|
|
this.second = aDate.getSeconds();
|
|
}
|
|
}
|
|
this._cachedUnixTime = null;
|
|
return this;
|
|
},
|
|
fromData: function fromData(aData, aZone) {
|
|
if (aData) {
|
|
for (var key in aData) {
|
|
if (Object.prototype.hasOwnProperty.call(aData, key)) {
|
|
if (key === "icaltype")
|
|
continue;
|
|
this[key] = aData[key];
|
|
}
|
|
}
|
|
}
|
|
if (aZone) {
|
|
this.zone = aZone;
|
|
}
|
|
if (aData && !("isDate" in aData)) {
|
|
this.isDate = !("hour" in aData);
|
|
} else if (aData && "isDate" in aData) {
|
|
this.isDate = aData.isDate;
|
|
}
|
|
if (aData && "timezone" in aData) {
|
|
var zone = ICAL3.TimezoneService.get(aData.timezone);
|
|
this.zone = zone || ICAL3.Timezone.localTimezone;
|
|
}
|
|
if (aData && "zone" in aData) {
|
|
this.zone = aData.zone;
|
|
}
|
|
if (!this.zone) {
|
|
this.zone = ICAL3.Timezone.localTimezone;
|
|
}
|
|
this._cachedUnixTime = null;
|
|
return this;
|
|
},
|
|
dayOfWeek: function icaltime_dayOfWeek(aWeekStart) {
|
|
var firstDow = aWeekStart || ICAL3.Time.SUNDAY;
|
|
var dowCacheKey = (this.year << 12) + (this.month << 8) + (this.day << 3) + firstDow;
|
|
if (dowCacheKey in ICAL3.Time._dowCache) {
|
|
return ICAL3.Time._dowCache[dowCacheKey];
|
|
}
|
|
var q3 = this.day;
|
|
var m2 = this.month + (this.month < 3 ? 12 : 0);
|
|
var Y2 = this.year - (this.month < 3 ? 1 : 0);
|
|
var h3 = q3 + Y2 + ICAL3.helpers.trunc((m2 + 1) * 26 / 10) + ICAL3.helpers.trunc(Y2 / 4);
|
|
if (true) {
|
|
h3 += ICAL3.helpers.trunc(Y2 / 100) * 6 + ICAL3.helpers.trunc(Y2 / 400);
|
|
} else {
|
|
h3 += 5;
|
|
}
|
|
h3 = (h3 + 7 - firstDow) % 7 + 1;
|
|
ICAL3.Time._dowCache[dowCacheKey] = h3;
|
|
return h3;
|
|
},
|
|
dayOfYear: function dayOfYear() {
|
|
var is_leap = ICAL3.Time.isLeapYear(this.year) ? 1 : 0;
|
|
var diypm = ICAL3.Time.daysInYearPassedMonth;
|
|
return diypm[is_leap][this.month - 1] + this.day;
|
|
},
|
|
startOfWeek: function startOfWeek(aWeekStart) {
|
|
var firstDow = aWeekStart || ICAL3.Time.SUNDAY;
|
|
var result = this.clone();
|
|
result.day -= (this.dayOfWeek() + 7 - firstDow) % 7;
|
|
result.isDate = true;
|
|
result.hour = 0;
|
|
result.minute = 0;
|
|
result.second = 0;
|
|
return result;
|
|
},
|
|
endOfWeek: function endOfWeek(aWeekStart) {
|
|
var firstDow = aWeekStart || ICAL3.Time.SUNDAY;
|
|
var result = this.clone();
|
|
result.day += (7 - this.dayOfWeek() + firstDow - ICAL3.Time.SUNDAY) % 7;
|
|
result.isDate = true;
|
|
result.hour = 0;
|
|
result.minute = 0;
|
|
result.second = 0;
|
|
return result;
|
|
},
|
|
startOfMonth: function startOfMonth() {
|
|
var result = this.clone();
|
|
result.day = 1;
|
|
result.isDate = true;
|
|
result.hour = 0;
|
|
result.minute = 0;
|
|
result.second = 0;
|
|
return result;
|
|
},
|
|
endOfMonth: function endOfMonth() {
|
|
var result = this.clone();
|
|
result.day = ICAL3.Time.daysInMonth(result.month, result.year);
|
|
result.isDate = true;
|
|
result.hour = 0;
|
|
result.minute = 0;
|
|
result.second = 0;
|
|
return result;
|
|
},
|
|
startOfYear: function startOfYear() {
|
|
var result = this.clone();
|
|
result.day = 1;
|
|
result.month = 1;
|
|
result.isDate = true;
|
|
result.hour = 0;
|
|
result.minute = 0;
|
|
result.second = 0;
|
|
return result;
|
|
},
|
|
endOfYear: function endOfYear() {
|
|
var result = this.clone();
|
|
result.day = 31;
|
|
result.month = 12;
|
|
result.isDate = true;
|
|
result.hour = 0;
|
|
result.minute = 0;
|
|
result.second = 0;
|
|
return result;
|
|
},
|
|
startDoyWeek: function startDoyWeek(aFirstDayOfWeek) {
|
|
var firstDow = aFirstDayOfWeek || ICAL3.Time.SUNDAY;
|
|
var delta = this.dayOfWeek() - firstDow;
|
|
if (delta < 0)
|
|
delta += 7;
|
|
return this.dayOfYear() - delta;
|
|
},
|
|
getDominicalLetter: function() {
|
|
return ICAL3.Time.getDominicalLetter(this.year);
|
|
},
|
|
nthWeekDay: function icaltime_nthWeekDay(aDayOfWeek, aPos) {
|
|
var daysInMonth = ICAL3.Time.daysInMonth(this.month, this.year);
|
|
var weekday;
|
|
var pos = aPos;
|
|
var start = 0;
|
|
var otherDay = this.clone();
|
|
if (pos >= 0) {
|
|
otherDay.day = 1;
|
|
if (pos != 0) {
|
|
pos--;
|
|
}
|
|
start = otherDay.day;
|
|
var startDow = otherDay.dayOfWeek();
|
|
var offset = aDayOfWeek - startDow;
|
|
if (offset < 0)
|
|
offset += 7;
|
|
start += offset;
|
|
start -= aDayOfWeek;
|
|
weekday = aDayOfWeek;
|
|
} else {
|
|
otherDay.day = daysInMonth;
|
|
var endDow = otherDay.dayOfWeek();
|
|
pos++;
|
|
weekday = endDow - aDayOfWeek;
|
|
if (weekday < 0) {
|
|
weekday += 7;
|
|
}
|
|
weekday = daysInMonth - weekday;
|
|
}
|
|
weekday += pos * 7;
|
|
return start + weekday;
|
|
},
|
|
isNthWeekDay: function(aDayOfWeek, aPos) {
|
|
var dow = this.dayOfWeek();
|
|
if (aPos === 0 && dow === aDayOfWeek) {
|
|
return true;
|
|
}
|
|
var day = this.nthWeekDay(aDayOfWeek, aPos);
|
|
if (day === this.day) {
|
|
return true;
|
|
}
|
|
return false;
|
|
},
|
|
weekNumber: function weekNumber(aWeekStart) {
|
|
var wnCacheKey = (this.year << 12) + (this.month << 8) + (this.day << 3) + aWeekStart;
|
|
if (wnCacheKey in ICAL3.Time._wnCache) {
|
|
return ICAL3.Time._wnCache[wnCacheKey];
|
|
}
|
|
var week1;
|
|
var dt = this.clone();
|
|
dt.isDate = true;
|
|
var isoyear = this.year;
|
|
if (dt.month == 12 && dt.day > 25) {
|
|
week1 = ICAL3.Time.weekOneStarts(isoyear + 1, aWeekStart);
|
|
if (dt.compare(week1) < 0) {
|
|
week1 = ICAL3.Time.weekOneStarts(isoyear, aWeekStart);
|
|
} else {
|
|
isoyear++;
|
|
}
|
|
} else {
|
|
week1 = ICAL3.Time.weekOneStarts(isoyear, aWeekStart);
|
|
if (dt.compare(week1) < 0) {
|
|
week1 = ICAL3.Time.weekOneStarts(--isoyear, aWeekStart);
|
|
}
|
|
}
|
|
var daysBetween = dt.subtractDate(week1).toSeconds() / 86400;
|
|
var answer = ICAL3.helpers.trunc(daysBetween / 7) + 1;
|
|
ICAL3.Time._wnCache[wnCacheKey] = answer;
|
|
return answer;
|
|
},
|
|
addDuration: function icaltime_add(aDuration) {
|
|
var mult = aDuration.isNegative ? -1 : 1;
|
|
var second = this.second;
|
|
var minute = this.minute;
|
|
var hour = this.hour;
|
|
var day = this.day;
|
|
second += mult * aDuration.seconds;
|
|
minute += mult * aDuration.minutes;
|
|
hour += mult * aDuration.hours;
|
|
day += mult * aDuration.days;
|
|
day += mult * 7 * aDuration.weeks;
|
|
this.second = second;
|
|
this.minute = minute;
|
|
this.hour = hour;
|
|
this.day = day;
|
|
this._cachedUnixTime = null;
|
|
},
|
|
subtractDate: function icaltime_subtract(aDate) {
|
|
var unixTime = this.toUnixTime() + this.utcOffset();
|
|
var other = aDate.toUnixTime() + aDate.utcOffset();
|
|
return ICAL3.Duration.fromSeconds(unixTime - other);
|
|
},
|
|
subtractDateTz: function icaltime_subtract_abs(aDate) {
|
|
var unixTime = this.toUnixTime();
|
|
var other = aDate.toUnixTime();
|
|
return ICAL3.Duration.fromSeconds(unixTime - other);
|
|
},
|
|
compare: function icaltime_compare(other) {
|
|
var a3 = this.toUnixTime();
|
|
var b3 = other.toUnixTime();
|
|
if (a3 > b3)
|
|
return 1;
|
|
if (b3 > a3)
|
|
return -1;
|
|
return 0;
|
|
},
|
|
compareDateOnlyTz: function icaltime_compareDateOnlyTz(other, tz) {
|
|
function cmp(attr) {
|
|
return ICAL3.Time._cmp_attr(a3, b3, attr);
|
|
}
|
|
var a3 = this.convertToZone(tz);
|
|
var b3 = other.convertToZone(tz);
|
|
var rc = 0;
|
|
if ((rc = cmp("year")) != 0)
|
|
return rc;
|
|
if ((rc = cmp("month")) != 0)
|
|
return rc;
|
|
if ((rc = cmp("day")) != 0)
|
|
return rc;
|
|
return rc;
|
|
},
|
|
convertToZone: function convertToZone(zone) {
|
|
var copy = this.clone();
|
|
var zone_equals = this.zone.tzid == zone.tzid;
|
|
if (!this.isDate && !zone_equals) {
|
|
ICAL3.Timezone.convert_time(copy, this.zone, zone);
|
|
}
|
|
copy.zone = zone;
|
|
return copy;
|
|
},
|
|
utcOffset: function utc_offset() {
|
|
if (this.zone == ICAL3.Timezone.localTimezone || this.zone == ICAL3.Timezone.utcTimezone) {
|
|
return 0;
|
|
} else {
|
|
return this.zone.utcOffset(this);
|
|
}
|
|
},
|
|
toICALString: function() {
|
|
var string = this.toString();
|
|
if (string.length > 10) {
|
|
return ICAL3.design.icalendar.value["date-time"].toICAL(string);
|
|
} else {
|
|
return ICAL3.design.icalendar.value.date.toICAL(string);
|
|
}
|
|
},
|
|
toString: function toString() {
|
|
var result = this.year + "-" + ICAL3.helpers.pad2(this.month) + "-" + ICAL3.helpers.pad2(this.day);
|
|
if (!this.isDate) {
|
|
result += "T" + ICAL3.helpers.pad2(this.hour) + ":" + ICAL3.helpers.pad2(this.minute) + ":" + ICAL3.helpers.pad2(this.second);
|
|
if (this.zone === ICAL3.Timezone.utcTimezone) {
|
|
result += "Z";
|
|
}
|
|
}
|
|
return result;
|
|
},
|
|
toJSDate: function toJSDate() {
|
|
if (this.zone == ICAL3.Timezone.localTimezone) {
|
|
if (this.isDate) {
|
|
return new Date(this.year, this.month - 1, this.day);
|
|
} else {
|
|
return new Date(this.year, this.month - 1, this.day, this.hour, this.minute, this.second, 0);
|
|
}
|
|
} else {
|
|
return new Date(this.toUnixTime() * 1e3);
|
|
}
|
|
},
|
|
_normalize: function icaltime_normalize() {
|
|
var isDate = this._time.isDate;
|
|
if (this._time.isDate) {
|
|
this._time.hour = 0;
|
|
this._time.minute = 0;
|
|
this._time.second = 0;
|
|
}
|
|
this.adjust(0, 0, 0, 0);
|
|
return this;
|
|
},
|
|
adjust: function icaltime_adjust(aExtraDays, aExtraHours, aExtraMinutes, aExtraSeconds, aTime) {
|
|
var minutesOverflow, hoursOverflow, daysOverflow = 0, yearsOverflow = 0;
|
|
var second, minute, hour, day;
|
|
var daysInMonth;
|
|
var time = aTime || this._time;
|
|
if (!time.isDate) {
|
|
second = time.second + aExtraSeconds;
|
|
time.second = second % 60;
|
|
minutesOverflow = ICAL3.helpers.trunc(second / 60);
|
|
if (time.second < 0) {
|
|
time.second += 60;
|
|
minutesOverflow--;
|
|
}
|
|
minute = time.minute + aExtraMinutes + minutesOverflow;
|
|
time.minute = minute % 60;
|
|
hoursOverflow = ICAL3.helpers.trunc(minute / 60);
|
|
if (time.minute < 0) {
|
|
time.minute += 60;
|
|
hoursOverflow--;
|
|
}
|
|
hour = time.hour + aExtraHours + hoursOverflow;
|
|
time.hour = hour % 24;
|
|
daysOverflow = ICAL3.helpers.trunc(hour / 24);
|
|
if (time.hour < 0) {
|
|
time.hour += 24;
|
|
daysOverflow--;
|
|
}
|
|
}
|
|
if (time.month > 12) {
|
|
yearsOverflow = ICAL3.helpers.trunc((time.month - 1) / 12);
|
|
} else if (time.month < 1) {
|
|
yearsOverflow = ICAL3.helpers.trunc(time.month / 12) - 1;
|
|
}
|
|
time.year += yearsOverflow;
|
|
time.month -= 12 * yearsOverflow;
|
|
day = time.day + aExtraDays + daysOverflow;
|
|
if (day > 0) {
|
|
for (; ; ) {
|
|
daysInMonth = ICAL3.Time.daysInMonth(time.month, time.year);
|
|
if (day <= daysInMonth) {
|
|
break;
|
|
}
|
|
time.month++;
|
|
if (time.month > 12) {
|
|
time.year++;
|
|
time.month = 1;
|
|
}
|
|
day -= daysInMonth;
|
|
}
|
|
} else {
|
|
while (day <= 0) {
|
|
if (time.month == 1) {
|
|
time.year--;
|
|
time.month = 12;
|
|
} else {
|
|
time.month--;
|
|
}
|
|
day += ICAL3.Time.daysInMonth(time.month, time.year);
|
|
}
|
|
}
|
|
time.day = day;
|
|
this._cachedUnixTime = null;
|
|
return this;
|
|
},
|
|
fromUnixTime: function fromUnixTime(seconds) {
|
|
this.zone = ICAL3.Timezone.utcTimezone;
|
|
var epoch = ICAL3.Time.epochTime.clone();
|
|
epoch.adjust(0, 0, 0, seconds);
|
|
this.year = epoch.year;
|
|
this.month = epoch.month;
|
|
this.day = epoch.day;
|
|
this.hour = epoch.hour;
|
|
this.minute = epoch.minute;
|
|
this.second = Math.floor(epoch.second);
|
|
this._cachedUnixTime = null;
|
|
},
|
|
toUnixTime: function toUnixTime() {
|
|
if (this._cachedUnixTime !== null) {
|
|
return this._cachedUnixTime;
|
|
}
|
|
var offset = this.utcOffset();
|
|
var ms = Date.UTC(this.year, this.month - 1, this.day, this.hour, this.minute, this.second - offset);
|
|
this._cachedUnixTime = ms / 1e3;
|
|
return this._cachedUnixTime;
|
|
},
|
|
toJSON: function() {
|
|
var copy = [
|
|
"year",
|
|
"month",
|
|
"day",
|
|
"hour",
|
|
"minute",
|
|
"second",
|
|
"isDate"
|
|
];
|
|
var result = Object.create(null);
|
|
var i3 = 0;
|
|
var len = copy.length;
|
|
var prop;
|
|
for (; i3 < len; i3++) {
|
|
prop = copy[i3];
|
|
result[prop] = this[prop];
|
|
}
|
|
if (this.zone) {
|
|
result.timezone = this.zone.tzid;
|
|
}
|
|
return result;
|
|
}
|
|
};
|
|
(function setupNormalizeAttributes() {
|
|
function defineAttr(attr) {
|
|
Object.defineProperty(ICAL3.Time.prototype, attr, {
|
|
get: function getTimeAttr() {
|
|
if (this._pendingNormalization) {
|
|
this._normalize();
|
|
this._pendingNormalization = false;
|
|
}
|
|
return this._time[attr];
|
|
},
|
|
set: function setTimeAttr(val) {
|
|
if (attr === "isDate" && val && !this._time.isDate) {
|
|
this.adjust(0, 0, 0, 0);
|
|
}
|
|
this._cachedUnixTime = null;
|
|
this._pendingNormalization = true;
|
|
this._time[attr] = val;
|
|
return val;
|
|
}
|
|
});
|
|
}
|
|
if ("defineProperty" in Object) {
|
|
defineAttr("year");
|
|
defineAttr("month");
|
|
defineAttr("day");
|
|
defineAttr("hour");
|
|
defineAttr("minute");
|
|
defineAttr("second");
|
|
defineAttr("isDate");
|
|
}
|
|
})();
|
|
ICAL3.Time.daysInMonth = function icaltime_daysInMonth(month, year) {
|
|
var _daysInMonth = [0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
|
|
var days = 30;
|
|
if (month < 1 || month > 12)
|
|
return days;
|
|
days = _daysInMonth[month];
|
|
if (month == 2) {
|
|
days += ICAL3.Time.isLeapYear(year);
|
|
}
|
|
return days;
|
|
};
|
|
ICAL3.Time.isLeapYear = function isLeapYear(year) {
|
|
if (year <= 1752) {
|
|
return year % 4 == 0;
|
|
} else {
|
|
return year % 4 == 0 && year % 100 != 0 || year % 400 == 0;
|
|
}
|
|
};
|
|
ICAL3.Time.fromDayOfYear = function icaltime_fromDayOfYear(aDayOfYear, aYear) {
|
|
var year = aYear;
|
|
var doy = aDayOfYear;
|
|
var tt = new ICAL3.Time();
|
|
tt.auto_normalize = false;
|
|
var is_leap = ICAL3.Time.isLeapYear(year) ? 1 : 0;
|
|
if (doy < 1) {
|
|
year--;
|
|
is_leap = ICAL3.Time.isLeapYear(year) ? 1 : 0;
|
|
doy += ICAL3.Time.daysInYearPassedMonth[is_leap][12];
|
|
return ICAL3.Time.fromDayOfYear(doy, year);
|
|
} else if (doy > ICAL3.Time.daysInYearPassedMonth[is_leap][12]) {
|
|
is_leap = ICAL3.Time.isLeapYear(year) ? 1 : 0;
|
|
doy -= ICAL3.Time.daysInYearPassedMonth[is_leap][12];
|
|
year++;
|
|
return ICAL3.Time.fromDayOfYear(doy, year);
|
|
}
|
|
tt.year = year;
|
|
tt.isDate = true;
|
|
for (var month = 11; month >= 0; month--) {
|
|
if (doy > ICAL3.Time.daysInYearPassedMonth[is_leap][month]) {
|
|
tt.month = month + 1;
|
|
tt.day = doy - ICAL3.Time.daysInYearPassedMonth[is_leap][month];
|
|
break;
|
|
}
|
|
}
|
|
tt.auto_normalize = true;
|
|
return tt;
|
|
};
|
|
ICAL3.Time.fromStringv2 = function fromString(str) {
|
|
return new ICAL3.Time({
|
|
year: parseInt(str.substr(0, 4), 10),
|
|
month: parseInt(str.substr(5, 2), 10),
|
|
day: parseInt(str.substr(8, 2), 10),
|
|
isDate: true
|
|
});
|
|
};
|
|
ICAL3.Time.fromDateString = function(aValue) {
|
|
return new ICAL3.Time({
|
|
year: ICAL3.helpers.strictParseInt(aValue.substr(0, 4)),
|
|
month: ICAL3.helpers.strictParseInt(aValue.substr(5, 2)),
|
|
day: ICAL3.helpers.strictParseInt(aValue.substr(8, 2)),
|
|
isDate: true
|
|
});
|
|
};
|
|
ICAL3.Time.fromDateTimeString = function(aValue, prop) {
|
|
if (aValue.length < 19) {
|
|
throw new Error('invalid date-time value: "' + aValue + '"');
|
|
}
|
|
var zone;
|
|
if (aValue[19] && aValue[19] === "Z") {
|
|
zone = "Z";
|
|
} else if (prop) {
|
|
zone = prop.getParameter("tzid");
|
|
}
|
|
var time = new ICAL3.Time({
|
|
year: ICAL3.helpers.strictParseInt(aValue.substr(0, 4)),
|
|
month: ICAL3.helpers.strictParseInt(aValue.substr(5, 2)),
|
|
day: ICAL3.helpers.strictParseInt(aValue.substr(8, 2)),
|
|
hour: ICAL3.helpers.strictParseInt(aValue.substr(11, 2)),
|
|
minute: ICAL3.helpers.strictParseInt(aValue.substr(14, 2)),
|
|
second: ICAL3.helpers.strictParseInt(aValue.substr(17, 2)),
|
|
timezone: zone
|
|
});
|
|
return time;
|
|
};
|
|
ICAL3.Time.fromString = function fromString(aValue, aProperty) {
|
|
if (aValue.length > 10) {
|
|
return ICAL3.Time.fromDateTimeString(aValue, aProperty);
|
|
} else {
|
|
return ICAL3.Time.fromDateString(aValue);
|
|
}
|
|
};
|
|
ICAL3.Time.fromJSDate = function fromJSDate(aDate, useUTC) {
|
|
var tt = new ICAL3.Time();
|
|
return tt.fromJSDate(aDate, useUTC);
|
|
};
|
|
ICAL3.Time.fromData = function fromData(aData, aZone) {
|
|
var t3 = new ICAL3.Time();
|
|
return t3.fromData(aData, aZone);
|
|
};
|
|
ICAL3.Time.now = function icaltime_now() {
|
|
return ICAL3.Time.fromJSDate(new Date(), false);
|
|
};
|
|
ICAL3.Time.weekOneStarts = function weekOneStarts(aYear, aWeekStart) {
|
|
var t3 = ICAL3.Time.fromData({
|
|
year: aYear,
|
|
month: 1,
|
|
day: 1,
|
|
isDate: true
|
|
});
|
|
var dow = t3.dayOfWeek();
|
|
var wkst = aWeekStart || ICAL3.Time.DEFAULT_WEEK_START;
|
|
if (dow > ICAL3.Time.THURSDAY) {
|
|
t3.day += 7;
|
|
}
|
|
if (wkst > ICAL3.Time.THURSDAY) {
|
|
t3.day -= 7;
|
|
}
|
|
t3.day -= dow - wkst;
|
|
return t3;
|
|
};
|
|
ICAL3.Time.getDominicalLetter = function(yr) {
|
|
var LTRS = "GFEDCBA";
|
|
var dom = (yr + (yr / 4 | 0) + (yr / 400 | 0) - (yr / 100 | 0) - 1) % 7;
|
|
var isLeap = ICAL3.Time.isLeapYear(yr);
|
|
if (isLeap) {
|
|
return LTRS[(dom + 6) % 7] + LTRS[dom];
|
|
} else {
|
|
return LTRS[dom];
|
|
}
|
|
};
|
|
ICAL3.Time.epochTime = ICAL3.Time.fromData({
|
|
year: 1970,
|
|
month: 1,
|
|
day: 1,
|
|
hour: 0,
|
|
minute: 0,
|
|
second: 0,
|
|
isDate: false,
|
|
timezone: "Z"
|
|
});
|
|
ICAL3.Time._cmp_attr = function _cmp_attr(a3, b3, attr) {
|
|
if (a3[attr] > b3[attr])
|
|
return 1;
|
|
if (a3[attr] < b3[attr])
|
|
return -1;
|
|
return 0;
|
|
};
|
|
ICAL3.Time.daysInYearPassedMonth = [
|
|
[0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365],
|
|
[0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366]
|
|
];
|
|
ICAL3.Time.SUNDAY = 1;
|
|
ICAL3.Time.MONDAY = 2;
|
|
ICAL3.Time.TUESDAY = 3;
|
|
ICAL3.Time.WEDNESDAY = 4;
|
|
ICAL3.Time.THURSDAY = 5;
|
|
ICAL3.Time.FRIDAY = 6;
|
|
ICAL3.Time.SATURDAY = 7;
|
|
ICAL3.Time.DEFAULT_WEEK_START = ICAL3.Time.MONDAY;
|
|
})();
|
|
(function() {
|
|
ICAL3.VCardTime = function(data, zone, icaltype) {
|
|
this.wrappedJSObject = this;
|
|
var time = this._time = Object.create(null);
|
|
time.year = null;
|
|
time.month = null;
|
|
time.day = null;
|
|
time.hour = null;
|
|
time.minute = null;
|
|
time.second = null;
|
|
this.icaltype = icaltype || "date-and-or-time";
|
|
this.fromData(data, zone);
|
|
};
|
|
ICAL3.helpers.inherits(ICAL3.Time, ICAL3.VCardTime, {
|
|
icalclass: "vcardtime",
|
|
icaltype: "date-and-or-time",
|
|
zone: null,
|
|
clone: function() {
|
|
return new ICAL3.VCardTime(this._time, this.zone, this.icaltype);
|
|
},
|
|
_normalize: function() {
|
|
return this;
|
|
},
|
|
utcOffset: function() {
|
|
if (this.zone instanceof ICAL3.UtcOffset) {
|
|
return this.zone.toSeconds();
|
|
} else {
|
|
return ICAL3.Time.prototype.utcOffset.apply(this, arguments);
|
|
}
|
|
},
|
|
toICALString: function() {
|
|
return ICAL3.design.vcard.value[this.icaltype].toICAL(this.toString());
|
|
},
|
|
toString: function toString() {
|
|
var p22 = ICAL3.helpers.pad2;
|
|
var y3 = this.year, m2 = this.month, d3 = this.day;
|
|
var h3 = this.hour, mm = this.minute, s3 = this.second;
|
|
var hasYear = y3 !== null, hasMonth = m2 !== null, hasDay = d3 !== null;
|
|
var hasHour = h3 !== null, hasMinute = mm !== null, hasSecond = s3 !== null;
|
|
var datepart = (hasYear ? p22(y3) + (hasMonth || hasDay ? "-" : "") : hasMonth || hasDay ? "--" : "") + (hasMonth ? p22(m2) : "") + (hasDay ? "-" + p22(d3) : "");
|
|
var timepart = (hasHour ? p22(h3) : "-") + (hasHour && hasMinute ? ":" : "") + (hasMinute ? p22(mm) : "") + (!hasHour && !hasMinute ? "-" : "") + (hasMinute && hasSecond ? ":" : "") + (hasSecond ? p22(s3) : "");
|
|
var zone;
|
|
if (this.zone === ICAL3.Timezone.utcTimezone) {
|
|
zone = "Z";
|
|
} else if (this.zone instanceof ICAL3.UtcOffset) {
|
|
zone = this.zone.toString();
|
|
} else if (this.zone === ICAL3.Timezone.localTimezone) {
|
|
zone = "";
|
|
} else if (this.zone instanceof ICAL3.Timezone) {
|
|
var offset = ICAL3.UtcOffset.fromSeconds(this.zone.utcOffset(this));
|
|
zone = offset.toString();
|
|
} else {
|
|
zone = "";
|
|
}
|
|
switch (this.icaltype) {
|
|
case "time":
|
|
return timepart + zone;
|
|
case "date-and-or-time":
|
|
case "date-time":
|
|
return datepart + (timepart == "--" ? "" : "T" + timepart + zone);
|
|
case "date":
|
|
return datepart;
|
|
}
|
|
return null;
|
|
}
|
|
});
|
|
ICAL3.VCardTime.fromDateAndOrTimeString = function(aValue, aIcalType) {
|
|
function part(v3, s3, e3) {
|
|
return v3 ? ICAL3.helpers.strictParseInt(v3.substr(s3, e3)) : null;
|
|
}
|
|
var parts = aValue.split("T");
|
|
var dt = parts[0], tmz = parts[1];
|
|
var splitzone = tmz ? ICAL3.design.vcard.value.time._splitZone(tmz) : [];
|
|
var zone = splitzone[0], tm = splitzone[1];
|
|
var stoi = ICAL3.helpers.strictParseInt;
|
|
var dtlen = dt ? dt.length : 0;
|
|
var tmlen = tm ? tm.length : 0;
|
|
var hasDashDate = dt && dt[0] == "-" && dt[1] == "-";
|
|
var hasDashTime = tm && tm[0] == "-";
|
|
var o2 = {
|
|
year: hasDashDate ? null : part(dt, 0, 4),
|
|
month: hasDashDate && (dtlen == 4 || dtlen == 7) ? part(dt, 2, 2) : dtlen == 7 ? part(dt, 5, 2) : dtlen == 10 ? part(dt, 5, 2) : null,
|
|
day: dtlen == 5 ? part(dt, 3, 2) : dtlen == 7 && hasDashDate ? part(dt, 5, 2) : dtlen == 10 ? part(dt, 8, 2) : null,
|
|
hour: hasDashTime ? null : part(tm, 0, 2),
|
|
minute: hasDashTime && tmlen == 3 ? part(tm, 1, 2) : tmlen > 4 ? hasDashTime ? part(tm, 1, 2) : part(tm, 3, 2) : null,
|
|
second: tmlen == 4 ? part(tm, 2, 2) : tmlen == 6 ? part(tm, 4, 2) : tmlen == 8 ? part(tm, 6, 2) : null
|
|
};
|
|
if (zone == "Z") {
|
|
zone = ICAL3.Timezone.utcTimezone;
|
|
} else if (zone && zone[3] == ":") {
|
|
zone = ICAL3.UtcOffset.fromString(zone);
|
|
} else {
|
|
zone = null;
|
|
}
|
|
return new ICAL3.VCardTime(o2, zone, aIcalType);
|
|
};
|
|
})();
|
|
(function() {
|
|
var DOW_MAP = {
|
|
SU: ICAL3.Time.SUNDAY,
|
|
MO: ICAL3.Time.MONDAY,
|
|
TU: ICAL3.Time.TUESDAY,
|
|
WE: ICAL3.Time.WEDNESDAY,
|
|
TH: ICAL3.Time.THURSDAY,
|
|
FR: ICAL3.Time.FRIDAY,
|
|
SA: ICAL3.Time.SATURDAY
|
|
};
|
|
var REVERSE_DOW_MAP = {};
|
|
for (var key in DOW_MAP) {
|
|
if (DOW_MAP.hasOwnProperty(key)) {
|
|
REVERSE_DOW_MAP[DOW_MAP[key]] = key;
|
|
}
|
|
}
|
|
var COPY_PARTS = [
|
|
"BYSECOND",
|
|
"BYMINUTE",
|
|
"BYHOUR",
|
|
"BYDAY",
|
|
"BYMONTHDAY",
|
|
"BYYEARDAY",
|
|
"BYWEEKNO",
|
|
"BYMONTH",
|
|
"BYSETPOS"
|
|
];
|
|
ICAL3.Recur = function icalrecur(data) {
|
|
this.wrappedJSObject = this;
|
|
this.parts = {};
|
|
if (data && typeof data === "object") {
|
|
this.fromData(data);
|
|
}
|
|
};
|
|
ICAL3.Recur.prototype = {
|
|
parts: null,
|
|
interval: 1,
|
|
wkst: ICAL3.Time.MONDAY,
|
|
until: null,
|
|
count: null,
|
|
freq: null,
|
|
icalclass: "icalrecur",
|
|
icaltype: "recur",
|
|
iterator: function(aStart) {
|
|
return new ICAL3.RecurIterator({
|
|
rule: this,
|
|
dtstart: aStart
|
|
});
|
|
},
|
|
clone: function clone() {
|
|
return new ICAL3.Recur(this.toJSON());
|
|
},
|
|
isFinite: function isfinite() {
|
|
return !!(this.count || this.until);
|
|
},
|
|
isByCount: function isbycount() {
|
|
return !!(this.count && !this.until);
|
|
},
|
|
addComponent: function addPart(aType, aValue) {
|
|
var ucname = aType.toUpperCase();
|
|
if (ucname in this.parts) {
|
|
this.parts[ucname].push(aValue);
|
|
} else {
|
|
this.parts[ucname] = [aValue];
|
|
}
|
|
},
|
|
setComponent: function setComponent(aType, aValues) {
|
|
this.parts[aType.toUpperCase()] = aValues.slice();
|
|
},
|
|
getComponent: function getComponent(aType) {
|
|
var ucname = aType.toUpperCase();
|
|
return ucname in this.parts ? this.parts[ucname].slice() : [];
|
|
},
|
|
getNextOccurrence: function getNextOccurrence(aStartTime, aRecurrenceId) {
|
|
var iter = this.iterator(aStartTime);
|
|
var next, cdt;
|
|
do {
|
|
next = iter.next();
|
|
} while (next && next.compare(aRecurrenceId) <= 0);
|
|
if (next && aRecurrenceId.zone) {
|
|
next.zone = aRecurrenceId.zone;
|
|
}
|
|
return next;
|
|
},
|
|
fromData: function(data) {
|
|
for (var key2 in data) {
|
|
var uckey = key2.toUpperCase();
|
|
if (uckey in partDesign) {
|
|
if (Array.isArray(data[key2])) {
|
|
this.parts[uckey] = data[key2];
|
|
} else {
|
|
this.parts[uckey] = [data[key2]];
|
|
}
|
|
} else {
|
|
this[key2] = data[key2];
|
|
}
|
|
}
|
|
if (this.interval && typeof this.interval != "number") {
|
|
optionDesign.INTERVAL(this.interval, this);
|
|
}
|
|
if (this.wkst && typeof this.wkst != "number") {
|
|
this.wkst = ICAL3.Recur.icalDayToNumericDay(this.wkst);
|
|
}
|
|
if (this.until && !(this.until instanceof ICAL3.Time)) {
|
|
this.until = ICAL3.Time.fromString(this.until);
|
|
}
|
|
},
|
|
toJSON: function() {
|
|
var res = Object.create(null);
|
|
res.freq = this.freq;
|
|
if (this.count) {
|
|
res.count = this.count;
|
|
}
|
|
if (this.interval > 1) {
|
|
res.interval = this.interval;
|
|
}
|
|
for (var k2 in this.parts) {
|
|
if (!this.parts.hasOwnProperty(k2)) {
|
|
continue;
|
|
}
|
|
var kparts = this.parts[k2];
|
|
if (Array.isArray(kparts) && kparts.length == 1) {
|
|
res[k2.toLowerCase()] = kparts[0];
|
|
} else {
|
|
res[k2.toLowerCase()] = ICAL3.helpers.clone(this.parts[k2]);
|
|
}
|
|
}
|
|
if (this.until) {
|
|
res.until = this.until.toString();
|
|
}
|
|
if ("wkst" in this && this.wkst !== ICAL3.Time.DEFAULT_WEEK_START) {
|
|
res.wkst = ICAL3.Recur.numericDayToIcalDay(this.wkst);
|
|
}
|
|
return res;
|
|
},
|
|
toString: function icalrecur_toString() {
|
|
var str = "FREQ=" + this.freq;
|
|
if (this.count) {
|
|
str += ";COUNT=" + this.count;
|
|
}
|
|
if (this.interval > 1) {
|
|
str += ";INTERVAL=" + this.interval;
|
|
}
|
|
for (var k2 in this.parts) {
|
|
if (this.parts.hasOwnProperty(k2)) {
|
|
str += ";" + k2 + "=" + this.parts[k2];
|
|
}
|
|
}
|
|
if (this.until) {
|
|
str += ";UNTIL=" + this.until.toICALString();
|
|
}
|
|
if ("wkst" in this && this.wkst !== ICAL3.Time.DEFAULT_WEEK_START) {
|
|
str += ";WKST=" + ICAL3.Recur.numericDayToIcalDay(this.wkst);
|
|
}
|
|
return str;
|
|
}
|
|
};
|
|
function parseNumericValue(type, min, max, value) {
|
|
var result = value;
|
|
if (value[0] === "+") {
|
|
result = value.substr(1);
|
|
}
|
|
result = ICAL3.helpers.strictParseInt(result);
|
|
if (min !== void 0 && value < min) {
|
|
throw new Error(type + ': invalid value "' + value + '" must be > ' + min);
|
|
}
|
|
if (max !== void 0 && value > max) {
|
|
throw new Error(type + ': invalid value "' + value + '" must be < ' + min);
|
|
}
|
|
return result;
|
|
}
|
|
ICAL3.Recur.icalDayToNumericDay = function toNumericDay(string, aWeekStart) {
|
|
var firstDow = aWeekStart || ICAL3.Time.SUNDAY;
|
|
return (DOW_MAP[string] - firstDow + 7) % 7 + 1;
|
|
};
|
|
ICAL3.Recur.numericDayToIcalDay = function toIcalDay(num, aWeekStart) {
|
|
var firstDow = aWeekStart || ICAL3.Time.SUNDAY;
|
|
var dow = num + firstDow - ICAL3.Time.SUNDAY;
|
|
if (dow > 7) {
|
|
dow -= 7;
|
|
}
|
|
return REVERSE_DOW_MAP[dow];
|
|
};
|
|
var VALID_DAY_NAMES = /^(SU|MO|TU|WE|TH|FR|SA)$/;
|
|
var VALID_BYDAY_PART = /^([+-])?(5[0-3]|[1-4][0-9]|[1-9])?(SU|MO|TU|WE|TH|FR|SA)$/;
|
|
var ALLOWED_FREQ = [
|
|
"SECONDLY",
|
|
"MINUTELY",
|
|
"HOURLY",
|
|
"DAILY",
|
|
"WEEKLY",
|
|
"MONTHLY",
|
|
"YEARLY"
|
|
];
|
|
var optionDesign = {
|
|
FREQ: function(value, dict, fmtIcal) {
|
|
if (ALLOWED_FREQ.indexOf(value) !== -1) {
|
|
dict.freq = value;
|
|
} else {
|
|
throw new Error('invalid frequency "' + value + '" expected: "' + ALLOWED_FREQ.join(", ") + '"');
|
|
}
|
|
},
|
|
COUNT: function(value, dict, fmtIcal) {
|
|
dict.count = ICAL3.helpers.strictParseInt(value);
|
|
},
|
|
INTERVAL: function(value, dict, fmtIcal) {
|
|
dict.interval = ICAL3.helpers.strictParseInt(value);
|
|
if (dict.interval < 1) {
|
|
dict.interval = 1;
|
|
}
|
|
},
|
|
UNTIL: function(value, dict, fmtIcal) {
|
|
if (value.length > 10) {
|
|
dict.until = ICAL3.design.icalendar.value["date-time"].fromICAL(value);
|
|
} else {
|
|
dict.until = ICAL3.design.icalendar.value.date.fromICAL(value);
|
|
}
|
|
if (!fmtIcal) {
|
|
dict.until = ICAL3.Time.fromString(dict.until);
|
|
}
|
|
},
|
|
WKST: function(value, dict, fmtIcal) {
|
|
if (VALID_DAY_NAMES.test(value)) {
|
|
dict.wkst = ICAL3.Recur.icalDayToNumericDay(value);
|
|
} else {
|
|
throw new Error('invalid WKST value "' + value + '"');
|
|
}
|
|
}
|
|
};
|
|
var partDesign = {
|
|
BYSECOND: parseNumericValue.bind(this, "BYSECOND", 0, 60),
|
|
BYMINUTE: parseNumericValue.bind(this, "BYMINUTE", 0, 59),
|
|
BYHOUR: parseNumericValue.bind(this, "BYHOUR", 0, 23),
|
|
BYDAY: function(value) {
|
|
if (VALID_BYDAY_PART.test(value)) {
|
|
return value;
|
|
} else {
|
|
throw new Error('invalid BYDAY value "' + value + '"');
|
|
}
|
|
},
|
|
BYMONTHDAY: parseNumericValue.bind(this, "BYMONTHDAY", -31, 31),
|
|
BYYEARDAY: parseNumericValue.bind(this, "BYYEARDAY", -366, 366),
|
|
BYWEEKNO: parseNumericValue.bind(this, "BYWEEKNO", -53, 53),
|
|
BYMONTH: parseNumericValue.bind(this, "BYMONTH", 1, 12),
|
|
BYSETPOS: parseNumericValue.bind(this, "BYSETPOS", -366, 366)
|
|
};
|
|
ICAL3.Recur.fromString = function(string) {
|
|
var data = ICAL3.Recur._stringToData(string, false);
|
|
return new ICAL3.Recur(data);
|
|
};
|
|
ICAL3.Recur.fromData = function(aData) {
|
|
return new ICAL3.Recur(aData);
|
|
};
|
|
ICAL3.Recur._stringToData = function(string, fmtIcal) {
|
|
var dict = Object.create(null);
|
|
var values = string.split(";");
|
|
var len = values.length;
|
|
for (var i3 = 0; i3 < len; i3++) {
|
|
var parts = values[i3].split("=");
|
|
var ucname = parts[0].toUpperCase();
|
|
var lcname = parts[0].toLowerCase();
|
|
var name = fmtIcal ? lcname : ucname;
|
|
var value = parts[1];
|
|
if (ucname in partDesign) {
|
|
var partArr = value.split(",");
|
|
var partArrIdx = 0;
|
|
var partArrLen = partArr.length;
|
|
for (; partArrIdx < partArrLen; partArrIdx++) {
|
|
partArr[partArrIdx] = partDesign[ucname](partArr[partArrIdx]);
|
|
}
|
|
dict[name] = partArr.length == 1 ? partArr[0] : partArr;
|
|
} else if (ucname in optionDesign) {
|
|
optionDesign[ucname](value, dict, fmtIcal);
|
|
} else {
|
|
dict[lcname] = value;
|
|
}
|
|
}
|
|
return dict;
|
|
};
|
|
})();
|
|
ICAL3.RecurIterator = function() {
|
|
function icalrecur_iterator(options) {
|
|
this.fromData(options);
|
|
}
|
|
icalrecur_iterator.prototype = {
|
|
completed: false,
|
|
rule: null,
|
|
dtstart: null,
|
|
last: null,
|
|
occurrence_number: 0,
|
|
by_indices: null,
|
|
initialized: false,
|
|
by_data: null,
|
|
days: null,
|
|
days_index: 0,
|
|
fromData: function(options) {
|
|
this.rule = ICAL3.helpers.formatClassType(options.rule, ICAL3.Recur);
|
|
if (!this.rule) {
|
|
throw new Error("iterator requires a (ICAL.Recur) rule");
|
|
}
|
|
this.dtstart = ICAL3.helpers.formatClassType(options.dtstart, ICAL3.Time);
|
|
if (!this.dtstart) {
|
|
throw new Error("iterator requires a (ICAL.Time) dtstart");
|
|
}
|
|
if (options.by_data) {
|
|
this.by_data = options.by_data;
|
|
} else {
|
|
this.by_data = ICAL3.helpers.clone(this.rule.parts, true);
|
|
}
|
|
if (options.occurrence_number)
|
|
this.occurrence_number = options.occurrence_number;
|
|
this.days = options.days || [];
|
|
if (options.last) {
|
|
this.last = ICAL3.helpers.formatClassType(options.last, ICAL3.Time);
|
|
}
|
|
this.by_indices = options.by_indices;
|
|
if (!this.by_indices) {
|
|
this.by_indices = {
|
|
"BYSECOND": 0,
|
|
"BYMINUTE": 0,
|
|
"BYHOUR": 0,
|
|
"BYDAY": 0,
|
|
"BYMONTH": 0,
|
|
"BYWEEKNO": 0,
|
|
"BYMONTHDAY": 0
|
|
};
|
|
}
|
|
this.initialized = options.initialized || false;
|
|
if (!this.initialized) {
|
|
this.init();
|
|
}
|
|
},
|
|
init: function icalrecur_iterator_init() {
|
|
this.initialized = true;
|
|
this.last = this.dtstart.clone();
|
|
var parts = this.by_data;
|
|
if ("BYDAY" in parts) {
|
|
this.sort_byday_rules(parts.BYDAY);
|
|
}
|
|
if ("BYYEARDAY" in parts) {
|
|
if ("BYMONTH" in parts || "BYWEEKNO" in parts || "BYMONTHDAY" in parts || "BYDAY" in parts) {
|
|
throw new Error("Invalid BYYEARDAY rule");
|
|
}
|
|
}
|
|
if ("BYWEEKNO" in parts && "BYMONTHDAY" in parts) {
|
|
throw new Error("BYWEEKNO does not fit to BYMONTHDAY");
|
|
}
|
|
if (this.rule.freq == "MONTHLY" && ("BYYEARDAY" in parts || "BYWEEKNO" in parts)) {
|
|
throw new Error("For MONTHLY recurrences neither BYYEARDAY nor BYWEEKNO may appear");
|
|
}
|
|
if (this.rule.freq == "WEEKLY" && ("BYYEARDAY" in parts || "BYMONTHDAY" in parts)) {
|
|
throw new Error("For WEEKLY recurrences neither BYMONTHDAY nor BYYEARDAY may appear");
|
|
}
|
|
if (this.rule.freq != "YEARLY" && "BYYEARDAY" in parts) {
|
|
throw new Error("BYYEARDAY may only appear in YEARLY rules");
|
|
}
|
|
this.last.second = this.setup_defaults("BYSECOND", "SECONDLY", this.dtstart.second);
|
|
this.last.minute = this.setup_defaults("BYMINUTE", "MINUTELY", this.dtstart.minute);
|
|
this.last.hour = this.setup_defaults("BYHOUR", "HOURLY", this.dtstart.hour);
|
|
this.last.day = this.setup_defaults("BYMONTHDAY", "DAILY", this.dtstart.day);
|
|
this.last.month = this.setup_defaults("BYMONTH", "MONTHLY", this.dtstart.month);
|
|
if (this.rule.freq == "WEEKLY") {
|
|
if ("BYDAY" in parts) {
|
|
var bydayParts = this.ruleDayOfWeek(parts.BYDAY[0], this.rule.wkst);
|
|
var pos = bydayParts[0];
|
|
var dow = bydayParts[1];
|
|
var wkdy = dow - this.last.dayOfWeek(this.rule.wkst);
|
|
if (this.last.dayOfWeek(this.rule.wkst) < dow && wkdy >= 0 || wkdy < 0) {
|
|
this.last.day += wkdy;
|
|
}
|
|
} else {
|
|
var dayName = ICAL3.Recur.numericDayToIcalDay(this.dtstart.dayOfWeek());
|
|
parts.BYDAY = [dayName];
|
|
}
|
|
}
|
|
if (this.rule.freq == "YEARLY") {
|
|
for (; ; ) {
|
|
this.expand_year_days(this.last.year);
|
|
if (this.days.length > 0) {
|
|
break;
|
|
}
|
|
this.increment_year(this.rule.interval);
|
|
}
|
|
this._nextByYearDay();
|
|
}
|
|
if (this.rule.freq == "MONTHLY" && this.has_by_data("BYDAY")) {
|
|
var tempLast = null;
|
|
var initLast = this.last.clone();
|
|
var daysInMonth = ICAL3.Time.daysInMonth(this.last.month, this.last.year);
|
|
for (var i3 in this.by_data.BYDAY) {
|
|
if (!this.by_data.BYDAY.hasOwnProperty(i3)) {
|
|
continue;
|
|
}
|
|
this.last = initLast.clone();
|
|
var bydayParts = this.ruleDayOfWeek(this.by_data.BYDAY[i3]);
|
|
var pos = bydayParts[0];
|
|
var dow = bydayParts[1];
|
|
var dayOfMonth = this.last.nthWeekDay(dow, pos);
|
|
if (pos >= 6 || pos <= -6) {
|
|
throw new Error("Malformed values in BYDAY part");
|
|
}
|
|
if (dayOfMonth > daysInMonth || dayOfMonth <= 0) {
|
|
if (tempLast && tempLast.month == initLast.month) {
|
|
continue;
|
|
}
|
|
while (dayOfMonth > daysInMonth || dayOfMonth <= 0) {
|
|
this.increment_month();
|
|
daysInMonth = ICAL3.Time.daysInMonth(this.last.month, this.last.year);
|
|
dayOfMonth = this.last.nthWeekDay(dow, pos);
|
|
}
|
|
}
|
|
this.last.day = dayOfMonth;
|
|
if (!tempLast || this.last.compare(tempLast) < 0) {
|
|
tempLast = this.last.clone();
|
|
}
|
|
}
|
|
this.last = tempLast.clone();
|
|
if (this.has_by_data("BYMONTHDAY")) {
|
|
this._byDayAndMonthDay(true);
|
|
}
|
|
if (this.last.day > daysInMonth || this.last.day == 0) {
|
|
throw new Error("Malformed values in BYDAY part");
|
|
}
|
|
} else if (this.has_by_data("BYMONTHDAY")) {
|
|
if (this.last.day < 0) {
|
|
var daysInMonth = ICAL3.Time.daysInMonth(this.last.month, this.last.year);
|
|
this.last.day = daysInMonth + this.last.day + 1;
|
|
}
|
|
}
|
|
},
|
|
next: function icalrecur_iterator_next() {
|
|
var before = this.last ? this.last.clone() : null;
|
|
if (this.rule.count && this.occurrence_number >= this.rule.count || this.rule.until && this.last.compare(this.rule.until) > 0) {
|
|
this.completed = true;
|
|
return null;
|
|
}
|
|
if (this.occurrence_number == 0 && this.last.compare(this.dtstart) >= 0) {
|
|
this.occurrence_number++;
|
|
return this.last;
|
|
}
|
|
var valid;
|
|
do {
|
|
valid = 1;
|
|
switch (this.rule.freq) {
|
|
case "SECONDLY":
|
|
this.next_second();
|
|
break;
|
|
case "MINUTELY":
|
|
this.next_minute();
|
|
break;
|
|
case "HOURLY":
|
|
this.next_hour();
|
|
break;
|
|
case "DAILY":
|
|
this.next_day();
|
|
break;
|
|
case "WEEKLY":
|
|
this.next_week();
|
|
break;
|
|
case "MONTHLY":
|
|
valid = this.next_month();
|
|
break;
|
|
case "YEARLY":
|
|
this.next_year();
|
|
break;
|
|
default:
|
|
return null;
|
|
}
|
|
} while (!this.check_contracting_rules() || this.last.compare(this.dtstart) < 0 || !valid);
|
|
if (this.last.compare(before) == 0) {
|
|
throw new Error("Same occurrence found twice, protecting you from death by recursion");
|
|
}
|
|
if (this.rule.until && this.last.compare(this.rule.until) > 0) {
|
|
this.completed = true;
|
|
return null;
|
|
} else {
|
|
this.occurrence_number++;
|
|
return this.last;
|
|
}
|
|
},
|
|
next_second: function next_second() {
|
|
return this.next_generic("BYSECOND", "SECONDLY", "second", "minute");
|
|
},
|
|
increment_second: function increment_second(inc) {
|
|
return this.increment_generic(inc, "second", 60, "minute");
|
|
},
|
|
next_minute: function next_minute() {
|
|
return this.next_generic("BYMINUTE", "MINUTELY", "minute", "hour", "next_second");
|
|
},
|
|
increment_minute: function increment_minute(inc) {
|
|
return this.increment_generic(inc, "minute", 60, "hour");
|
|
},
|
|
next_hour: function next_hour() {
|
|
return this.next_generic("BYHOUR", "HOURLY", "hour", "monthday", "next_minute");
|
|
},
|
|
increment_hour: function increment_hour(inc) {
|
|
this.increment_generic(inc, "hour", 24, "monthday");
|
|
},
|
|
next_day: function next_day() {
|
|
var has_by_day = "BYDAY" in this.by_data;
|
|
var this_freq = this.rule.freq == "DAILY";
|
|
if (this.next_hour() == 0) {
|
|
return 0;
|
|
}
|
|
if (this_freq) {
|
|
this.increment_monthday(this.rule.interval);
|
|
} else {
|
|
this.increment_monthday(1);
|
|
}
|
|
return 0;
|
|
},
|
|
next_week: function next_week() {
|
|
var end_of_data = 0;
|
|
if (this.next_weekday_by_week() == 0) {
|
|
return end_of_data;
|
|
}
|
|
if (this.has_by_data("BYWEEKNO")) {
|
|
var idx = ++this.by_indices.BYWEEKNO;
|
|
if (this.by_indices.BYWEEKNO == this.by_data.BYWEEKNO.length) {
|
|
this.by_indices.BYWEEKNO = 0;
|
|
end_of_data = 1;
|
|
}
|
|
this.last.month = 1;
|
|
this.last.day = 1;
|
|
var week_no = this.by_data.BYWEEKNO[this.by_indices.BYWEEKNO];
|
|
this.last.day += 7 * week_no;
|
|
if (end_of_data) {
|
|
this.increment_year(1);
|
|
}
|
|
} else {
|
|
this.increment_monthday(7 * this.rule.interval);
|
|
}
|
|
return end_of_data;
|
|
},
|
|
normalizeByMonthDayRules: function(year, month, rules) {
|
|
var daysInMonth = ICAL3.Time.daysInMonth(month, year);
|
|
var newRules = [];
|
|
var ruleIdx = 0;
|
|
var len = rules.length;
|
|
var rule;
|
|
for (; ruleIdx < len; ruleIdx++) {
|
|
rule = rules[ruleIdx];
|
|
if (Math.abs(rule) > daysInMonth) {
|
|
continue;
|
|
}
|
|
if (rule < 0) {
|
|
rule = daysInMonth + (rule + 1);
|
|
} else if (rule === 0) {
|
|
continue;
|
|
}
|
|
if (newRules.indexOf(rule) === -1) {
|
|
newRules.push(rule);
|
|
}
|
|
}
|
|
return newRules.sort(function(a3, b3) {
|
|
return a3 - b3;
|
|
});
|
|
},
|
|
_byDayAndMonthDay: function(isInit) {
|
|
var byMonthDay;
|
|
var byDay = this.by_data.BYDAY;
|
|
var date;
|
|
var dateIdx = 0;
|
|
var dateLen;
|
|
var dayLen = byDay.length;
|
|
var dataIsValid = 0;
|
|
var daysInMonth;
|
|
var self2 = this;
|
|
var lastDay = this.last.day;
|
|
function initMonth() {
|
|
daysInMonth = ICAL3.Time.daysInMonth(self2.last.month, self2.last.year);
|
|
byMonthDay = self2.normalizeByMonthDayRules(self2.last.year, self2.last.month, self2.by_data.BYMONTHDAY);
|
|
dateLen = byMonthDay.length;
|
|
while (byMonthDay[dateIdx] <= lastDay && !(isInit && byMonthDay[dateIdx] == lastDay) && dateIdx < dateLen - 1) {
|
|
dateIdx++;
|
|
}
|
|
}
|
|
function nextMonth() {
|
|
lastDay = 0;
|
|
self2.increment_month();
|
|
dateIdx = 0;
|
|
initMonth();
|
|
}
|
|
initMonth();
|
|
if (isInit) {
|
|
lastDay -= 1;
|
|
}
|
|
var monthsCounter = 48;
|
|
while (!dataIsValid && monthsCounter) {
|
|
monthsCounter--;
|
|
date = lastDay + 1;
|
|
if (date > daysInMonth) {
|
|
nextMonth();
|
|
continue;
|
|
}
|
|
var next = byMonthDay[dateIdx++];
|
|
if (next >= date) {
|
|
lastDay = next;
|
|
} else {
|
|
nextMonth();
|
|
continue;
|
|
}
|
|
for (var dayIdx = 0; dayIdx < dayLen; dayIdx++) {
|
|
var parts = this.ruleDayOfWeek(byDay[dayIdx]);
|
|
var pos = parts[0];
|
|
var dow = parts[1];
|
|
this.last.day = lastDay;
|
|
if (this.last.isNthWeekDay(dow, pos)) {
|
|
dataIsValid = 1;
|
|
break;
|
|
}
|
|
}
|
|
if (!dataIsValid && dateIdx === dateLen) {
|
|
nextMonth();
|
|
continue;
|
|
}
|
|
}
|
|
if (monthsCounter <= 0) {
|
|
throw new Error("Malformed values in BYDAY combined with BYMONTHDAY parts");
|
|
}
|
|
return dataIsValid;
|
|
},
|
|
next_month: function next_month() {
|
|
var this_freq = this.rule.freq == "MONTHLY";
|
|
var data_valid = 1;
|
|
if (this.next_hour() == 0) {
|
|
return data_valid;
|
|
}
|
|
if (this.has_by_data("BYDAY") && this.has_by_data("BYMONTHDAY")) {
|
|
data_valid = this._byDayAndMonthDay();
|
|
} else if (this.has_by_data("BYDAY")) {
|
|
var daysInMonth = ICAL3.Time.daysInMonth(this.last.month, this.last.year);
|
|
var setpos = 0;
|
|
var setpos_total = 0;
|
|
if (this.has_by_data("BYSETPOS")) {
|
|
var last_day = this.last.day;
|
|
for (var day = 1; day <= daysInMonth; day++) {
|
|
this.last.day = day;
|
|
if (this.is_day_in_byday(this.last)) {
|
|
setpos_total++;
|
|
if (day <= last_day) {
|
|
setpos++;
|
|
}
|
|
}
|
|
}
|
|
this.last.day = last_day;
|
|
}
|
|
data_valid = 0;
|
|
for (var day = this.last.day + 1; day <= daysInMonth; day++) {
|
|
this.last.day = day;
|
|
if (this.is_day_in_byday(this.last)) {
|
|
if (!this.has_by_data("BYSETPOS") || this.check_set_position(++setpos) || this.check_set_position(setpos - setpos_total - 1)) {
|
|
data_valid = 1;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
if (day > daysInMonth) {
|
|
this.last.day = 1;
|
|
this.increment_month();
|
|
if (this.is_day_in_byday(this.last)) {
|
|
if (!this.has_by_data("BYSETPOS") || this.check_set_position(1)) {
|
|
data_valid = 1;
|
|
}
|
|
} else {
|
|
data_valid = 0;
|
|
}
|
|
}
|
|
} else if (this.has_by_data("BYMONTHDAY")) {
|
|
this.by_indices.BYMONTHDAY++;
|
|
if (this.by_indices.BYMONTHDAY >= this.by_data.BYMONTHDAY.length) {
|
|
this.by_indices.BYMONTHDAY = 0;
|
|
this.increment_month();
|
|
}
|
|
var daysInMonth = ICAL3.Time.daysInMonth(this.last.month, this.last.year);
|
|
var day = this.by_data.BYMONTHDAY[this.by_indices.BYMONTHDAY];
|
|
if (day < 0) {
|
|
day = daysInMonth + day + 1;
|
|
}
|
|
if (day > daysInMonth) {
|
|
this.last.day = 1;
|
|
data_valid = this.is_day_in_byday(this.last);
|
|
} else {
|
|
this.last.day = day;
|
|
}
|
|
} else {
|
|
this.increment_month();
|
|
var daysInMonth = ICAL3.Time.daysInMonth(this.last.month, this.last.year);
|
|
if (this.by_data.BYMONTHDAY[0] > daysInMonth) {
|
|
data_valid = 0;
|
|
} else {
|
|
this.last.day = this.by_data.BYMONTHDAY[0];
|
|
}
|
|
}
|
|
return data_valid;
|
|
},
|
|
next_weekday_by_week: function next_weekday_by_week() {
|
|
var end_of_data = 0;
|
|
if (this.next_hour() == 0) {
|
|
return end_of_data;
|
|
}
|
|
if (!this.has_by_data("BYDAY")) {
|
|
return 1;
|
|
}
|
|
for (; ; ) {
|
|
var tt = new ICAL3.Time();
|
|
this.by_indices.BYDAY++;
|
|
if (this.by_indices.BYDAY == Object.keys(this.by_data.BYDAY).length) {
|
|
this.by_indices.BYDAY = 0;
|
|
end_of_data = 1;
|
|
}
|
|
var coded_day = this.by_data.BYDAY[this.by_indices.BYDAY];
|
|
var parts = this.ruleDayOfWeek(coded_day);
|
|
var dow = parts[1];
|
|
dow -= this.rule.wkst;
|
|
if (dow < 0) {
|
|
dow += 7;
|
|
}
|
|
tt.year = this.last.year;
|
|
tt.month = this.last.month;
|
|
tt.day = this.last.day;
|
|
var startOfWeek = tt.startDoyWeek(this.rule.wkst);
|
|
if (dow + startOfWeek < 1) {
|
|
if (!end_of_data) {
|
|
continue;
|
|
}
|
|
}
|
|
var next = ICAL3.Time.fromDayOfYear(startOfWeek + dow, this.last.year);
|
|
this.last.year = next.year;
|
|
this.last.month = next.month;
|
|
this.last.day = next.day;
|
|
return end_of_data;
|
|
}
|
|
},
|
|
next_year: function next_year() {
|
|
if (this.next_hour() == 0) {
|
|
return 0;
|
|
}
|
|
if (++this.days_index == this.days.length) {
|
|
this.days_index = 0;
|
|
do {
|
|
this.increment_year(this.rule.interval);
|
|
this.expand_year_days(this.last.year);
|
|
} while (this.days.length == 0);
|
|
}
|
|
this._nextByYearDay();
|
|
return 1;
|
|
},
|
|
_nextByYearDay: function _nextByYearDay() {
|
|
var doy = this.days[this.days_index];
|
|
var year = this.last.year;
|
|
if (doy < 1) {
|
|
doy += 1;
|
|
year += 1;
|
|
}
|
|
var next = ICAL3.Time.fromDayOfYear(doy, year);
|
|
this.last.day = next.day;
|
|
this.last.month = next.month;
|
|
},
|
|
ruleDayOfWeek: function ruleDayOfWeek(dow, aWeekStart) {
|
|
var matches = dow.match(/([+-]?[0-9])?(MO|TU|WE|TH|FR|SA|SU)/);
|
|
if (matches) {
|
|
var pos = parseInt(matches[1] || 0, 10);
|
|
dow = ICAL3.Recur.icalDayToNumericDay(matches[2], aWeekStart);
|
|
return [pos, dow];
|
|
} else {
|
|
return [0, 0];
|
|
}
|
|
},
|
|
next_generic: function next_generic(aRuleType, aInterval, aDateAttr, aFollowingAttr, aPreviousIncr) {
|
|
var has_by_rule = aRuleType in this.by_data;
|
|
var this_freq = this.rule.freq == aInterval;
|
|
var end_of_data = 0;
|
|
if (aPreviousIncr && this[aPreviousIncr]() == 0) {
|
|
return end_of_data;
|
|
}
|
|
if (has_by_rule) {
|
|
this.by_indices[aRuleType]++;
|
|
var idx = this.by_indices[aRuleType];
|
|
var dta = this.by_data[aRuleType];
|
|
if (this.by_indices[aRuleType] == dta.length) {
|
|
this.by_indices[aRuleType] = 0;
|
|
end_of_data = 1;
|
|
}
|
|
this.last[aDateAttr] = dta[this.by_indices[aRuleType]];
|
|
} else if (this_freq) {
|
|
this["increment_" + aDateAttr](this.rule.interval);
|
|
}
|
|
if (has_by_rule && end_of_data && this_freq) {
|
|
this["increment_" + aFollowingAttr](1);
|
|
}
|
|
return end_of_data;
|
|
},
|
|
increment_monthday: function increment_monthday(inc) {
|
|
for (var i3 = 0; i3 < inc; i3++) {
|
|
var daysInMonth = ICAL3.Time.daysInMonth(this.last.month, this.last.year);
|
|
this.last.day++;
|
|
if (this.last.day > daysInMonth) {
|
|
this.last.day -= daysInMonth;
|
|
this.increment_month();
|
|
}
|
|
}
|
|
},
|
|
increment_month: function increment_month() {
|
|
this.last.day = 1;
|
|
if (this.has_by_data("BYMONTH")) {
|
|
this.by_indices.BYMONTH++;
|
|
if (this.by_indices.BYMONTH == this.by_data.BYMONTH.length) {
|
|
this.by_indices.BYMONTH = 0;
|
|
this.increment_year(1);
|
|
}
|
|
this.last.month = this.by_data.BYMONTH[this.by_indices.BYMONTH];
|
|
} else {
|
|
if (this.rule.freq == "MONTHLY") {
|
|
this.last.month += this.rule.interval;
|
|
} else {
|
|
this.last.month++;
|
|
}
|
|
this.last.month--;
|
|
var years = ICAL3.helpers.trunc(this.last.month / 12);
|
|
this.last.month %= 12;
|
|
this.last.month++;
|
|
if (years != 0) {
|
|
this.increment_year(years);
|
|
}
|
|
}
|
|
},
|
|
increment_year: function increment_year(inc) {
|
|
this.last.year += inc;
|
|
},
|
|
increment_generic: function increment_generic(inc, aDateAttr, aFactor, aNextIncrement) {
|
|
this.last[aDateAttr] += inc;
|
|
var nextunit = ICAL3.helpers.trunc(this.last[aDateAttr] / aFactor);
|
|
this.last[aDateAttr] %= aFactor;
|
|
if (nextunit != 0) {
|
|
this["increment_" + aNextIncrement](nextunit);
|
|
}
|
|
},
|
|
has_by_data: function has_by_data(aRuleType) {
|
|
return aRuleType in this.rule.parts;
|
|
},
|
|
expand_year_days: function expand_year_days(aYear) {
|
|
var t3 = new ICAL3.Time();
|
|
this.days = [];
|
|
var parts = {};
|
|
var rules = ["BYDAY", "BYWEEKNO", "BYMONTHDAY", "BYMONTH", "BYYEARDAY"];
|
|
for (var p3 in rules) {
|
|
if (rules.hasOwnProperty(p3)) {
|
|
var part = rules[p3];
|
|
if (part in this.rule.parts) {
|
|
parts[part] = this.rule.parts[part];
|
|
}
|
|
}
|
|
}
|
|
if ("BYMONTH" in parts && "BYWEEKNO" in parts) {
|
|
var valid = 1;
|
|
var validWeeks = {};
|
|
t3.year = aYear;
|
|
t3.isDate = true;
|
|
for (var monthIdx = 0; monthIdx < this.by_data.BYMONTH.length; monthIdx++) {
|
|
var month = this.by_data.BYMONTH[monthIdx];
|
|
t3.month = month;
|
|
t3.day = 1;
|
|
var first_week = t3.weekNumber(this.rule.wkst);
|
|
t3.day = ICAL3.Time.daysInMonth(month, aYear);
|
|
var last_week = t3.weekNumber(this.rule.wkst);
|
|
for (monthIdx = first_week; monthIdx < last_week; monthIdx++) {
|
|
validWeeks[monthIdx] = 1;
|
|
}
|
|
}
|
|
for (var weekIdx = 0; weekIdx < this.by_data.BYWEEKNO.length && valid; weekIdx++) {
|
|
var weekno = this.by_data.BYWEEKNO[weekIdx];
|
|
if (weekno < 52) {
|
|
valid &= validWeeks[weekIdx];
|
|
} else {
|
|
valid = 0;
|
|
}
|
|
}
|
|
if (valid) {
|
|
delete parts.BYMONTH;
|
|
} else {
|
|
delete parts.BYWEEKNO;
|
|
}
|
|
}
|
|
var partCount = Object.keys(parts).length;
|
|
if (partCount == 0) {
|
|
var t1 = this.dtstart.clone();
|
|
t1.year = this.last.year;
|
|
this.days.push(t1.dayOfYear());
|
|
} else if (partCount == 1 && "BYMONTH" in parts) {
|
|
for (var monthkey in this.by_data.BYMONTH) {
|
|
if (!this.by_data.BYMONTH.hasOwnProperty(monthkey)) {
|
|
continue;
|
|
}
|
|
var t22 = this.dtstart.clone();
|
|
t22.year = aYear;
|
|
t22.month = this.by_data.BYMONTH[monthkey];
|
|
t22.isDate = true;
|
|
this.days.push(t22.dayOfYear());
|
|
}
|
|
} else if (partCount == 1 && "BYMONTHDAY" in parts) {
|
|
for (var monthdaykey in this.by_data.BYMONTHDAY) {
|
|
if (!this.by_data.BYMONTHDAY.hasOwnProperty(monthdaykey)) {
|
|
continue;
|
|
}
|
|
var t32 = this.dtstart.clone();
|
|
var day_ = this.by_data.BYMONTHDAY[monthdaykey];
|
|
if (day_ < 0) {
|
|
var daysInMonth = ICAL3.Time.daysInMonth(t32.month, aYear);
|
|
day_ = day_ + daysInMonth + 1;
|
|
}
|
|
t32.day = day_;
|
|
t32.year = aYear;
|
|
t32.isDate = true;
|
|
this.days.push(t32.dayOfYear());
|
|
}
|
|
} else if (partCount == 2 && "BYMONTHDAY" in parts && "BYMONTH" in parts) {
|
|
for (var monthkey in this.by_data.BYMONTH) {
|
|
if (!this.by_data.BYMONTH.hasOwnProperty(monthkey)) {
|
|
continue;
|
|
}
|
|
var month_ = this.by_data.BYMONTH[monthkey];
|
|
var daysInMonth = ICAL3.Time.daysInMonth(month_, aYear);
|
|
for (var monthdaykey in this.by_data.BYMONTHDAY) {
|
|
if (!this.by_data.BYMONTHDAY.hasOwnProperty(monthdaykey)) {
|
|
continue;
|
|
}
|
|
var day_ = this.by_data.BYMONTHDAY[monthdaykey];
|
|
if (day_ < 0) {
|
|
day_ = day_ + daysInMonth + 1;
|
|
}
|
|
t3.day = day_;
|
|
t3.month = month_;
|
|
t3.year = aYear;
|
|
t3.isDate = true;
|
|
this.days.push(t3.dayOfYear());
|
|
}
|
|
}
|
|
} else if (partCount == 1 && "BYWEEKNO" in parts) {
|
|
} else if (partCount == 2 && "BYWEEKNO" in parts && "BYMONTHDAY" in parts) {
|
|
} else if (partCount == 1 && "BYDAY" in parts) {
|
|
this.days = this.days.concat(this.expand_by_day(aYear));
|
|
} else if (partCount == 2 && "BYDAY" in parts && "BYMONTH" in parts) {
|
|
for (var monthkey in this.by_data.BYMONTH) {
|
|
if (!this.by_data.BYMONTH.hasOwnProperty(monthkey)) {
|
|
continue;
|
|
}
|
|
var month = this.by_data.BYMONTH[monthkey];
|
|
var daysInMonth = ICAL3.Time.daysInMonth(month, aYear);
|
|
t3.year = aYear;
|
|
t3.month = this.by_data.BYMONTH[monthkey];
|
|
t3.day = 1;
|
|
t3.isDate = true;
|
|
var first_dow = t3.dayOfWeek();
|
|
var doy_offset = t3.dayOfYear() - 1;
|
|
t3.day = daysInMonth;
|
|
var last_dow = t3.dayOfWeek();
|
|
if (this.has_by_data("BYSETPOS")) {
|
|
var set_pos_counter = 0;
|
|
var by_month_day = [];
|
|
for (var day = 1; day <= daysInMonth; day++) {
|
|
t3.day = day;
|
|
if (this.is_day_in_byday(t3)) {
|
|
by_month_day.push(day);
|
|
}
|
|
}
|
|
for (var spIndex = 0; spIndex < by_month_day.length; spIndex++) {
|
|
if (this.check_set_position(spIndex + 1) || this.check_set_position(spIndex - by_month_day.length)) {
|
|
this.days.push(doy_offset + by_month_day[spIndex]);
|
|
}
|
|
}
|
|
} else {
|
|
for (var daycodedkey in this.by_data.BYDAY) {
|
|
if (!this.by_data.BYDAY.hasOwnProperty(daycodedkey)) {
|
|
continue;
|
|
}
|
|
var coded_day = this.by_data.BYDAY[daycodedkey];
|
|
var bydayParts = this.ruleDayOfWeek(coded_day);
|
|
var pos = bydayParts[0];
|
|
var dow = bydayParts[1];
|
|
var month_day;
|
|
var first_matching_day = (dow + 7 - first_dow) % 7 + 1;
|
|
var last_matching_day = daysInMonth - (last_dow + 7 - dow) % 7;
|
|
if (pos == 0) {
|
|
for (var day = first_matching_day; day <= daysInMonth; day += 7) {
|
|
this.days.push(doy_offset + day);
|
|
}
|
|
} else if (pos > 0) {
|
|
month_day = first_matching_day + (pos - 1) * 7;
|
|
if (month_day <= daysInMonth) {
|
|
this.days.push(doy_offset + month_day);
|
|
}
|
|
} else {
|
|
month_day = last_matching_day + (pos + 1) * 7;
|
|
if (month_day > 0) {
|
|
this.days.push(doy_offset + month_day);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
this.days.sort(function(a3, b3) {
|
|
return a3 - b3;
|
|
});
|
|
} else if (partCount == 2 && "BYDAY" in parts && "BYMONTHDAY" in parts) {
|
|
var expandedDays = this.expand_by_day(aYear);
|
|
for (var daykey in expandedDays) {
|
|
if (!expandedDays.hasOwnProperty(daykey)) {
|
|
continue;
|
|
}
|
|
var day = expandedDays[daykey];
|
|
var tt = ICAL3.Time.fromDayOfYear(day, aYear);
|
|
if (this.by_data.BYMONTHDAY.indexOf(tt.day) >= 0) {
|
|
this.days.push(day);
|
|
}
|
|
}
|
|
} else if (partCount == 3 && "BYDAY" in parts && "BYMONTHDAY" in parts && "BYMONTH" in parts) {
|
|
var expandedDays = this.expand_by_day(aYear);
|
|
for (var daykey in expandedDays) {
|
|
if (!expandedDays.hasOwnProperty(daykey)) {
|
|
continue;
|
|
}
|
|
var day = expandedDays[daykey];
|
|
var tt = ICAL3.Time.fromDayOfYear(day, aYear);
|
|
if (this.by_data.BYMONTH.indexOf(tt.month) >= 0 && this.by_data.BYMONTHDAY.indexOf(tt.day) >= 0) {
|
|
this.days.push(day);
|
|
}
|
|
}
|
|
} else if (partCount == 2 && "BYDAY" in parts && "BYWEEKNO" in parts) {
|
|
var expandedDays = this.expand_by_day(aYear);
|
|
for (var daykey in expandedDays) {
|
|
if (!expandedDays.hasOwnProperty(daykey)) {
|
|
continue;
|
|
}
|
|
var day = expandedDays[daykey];
|
|
var tt = ICAL3.Time.fromDayOfYear(day, aYear);
|
|
var weekno = tt.weekNumber(this.rule.wkst);
|
|
if (this.by_data.BYWEEKNO.indexOf(weekno)) {
|
|
this.days.push(day);
|
|
}
|
|
}
|
|
} else if (partCount == 3 && "BYDAY" in parts && "BYWEEKNO" in parts && "BYMONTHDAY" in parts) {
|
|
} else if (partCount == 1 && "BYYEARDAY" in parts) {
|
|
this.days = this.days.concat(this.by_data.BYYEARDAY);
|
|
} else {
|
|
this.days = [];
|
|
}
|
|
return 0;
|
|
},
|
|
expand_by_day: function expand_by_day(aYear) {
|
|
var days_list = [];
|
|
var tmp = this.last.clone();
|
|
tmp.year = aYear;
|
|
tmp.month = 1;
|
|
tmp.day = 1;
|
|
tmp.isDate = true;
|
|
var start_dow = tmp.dayOfWeek();
|
|
tmp.month = 12;
|
|
tmp.day = 31;
|
|
tmp.isDate = true;
|
|
var end_dow = tmp.dayOfWeek();
|
|
var end_year_day = tmp.dayOfYear();
|
|
for (var daykey in this.by_data.BYDAY) {
|
|
if (!this.by_data.BYDAY.hasOwnProperty(daykey)) {
|
|
continue;
|
|
}
|
|
var day = this.by_data.BYDAY[daykey];
|
|
var parts = this.ruleDayOfWeek(day);
|
|
var pos = parts[0];
|
|
var dow = parts[1];
|
|
if (pos == 0) {
|
|
var tmp_start_doy = (dow + 7 - start_dow) % 7 + 1;
|
|
for (var doy = tmp_start_doy; doy <= end_year_day; doy += 7) {
|
|
days_list.push(doy);
|
|
}
|
|
} else if (pos > 0) {
|
|
var first;
|
|
if (dow >= start_dow) {
|
|
first = dow - start_dow + 1;
|
|
} else {
|
|
first = dow - start_dow + 8;
|
|
}
|
|
days_list.push(first + (pos - 1) * 7);
|
|
} else {
|
|
var last;
|
|
pos = -pos;
|
|
if (dow <= end_dow) {
|
|
last = end_year_day - end_dow + dow;
|
|
} else {
|
|
last = end_year_day - end_dow + dow - 7;
|
|
}
|
|
days_list.push(last - (pos - 1) * 7);
|
|
}
|
|
}
|
|
return days_list;
|
|
},
|
|
is_day_in_byday: function is_day_in_byday(tt) {
|
|
for (var daykey in this.by_data.BYDAY) {
|
|
if (!this.by_data.BYDAY.hasOwnProperty(daykey)) {
|
|
continue;
|
|
}
|
|
var day = this.by_data.BYDAY[daykey];
|
|
var parts = this.ruleDayOfWeek(day);
|
|
var pos = parts[0];
|
|
var dow = parts[1];
|
|
var this_dow = tt.dayOfWeek();
|
|
if (pos == 0 && dow == this_dow || tt.nthWeekDay(dow, pos) == tt.day) {
|
|
return 1;
|
|
}
|
|
}
|
|
return 0;
|
|
},
|
|
check_set_position: function check_set_position(aPos) {
|
|
if (this.has_by_data("BYSETPOS")) {
|
|
var idx = this.by_data.BYSETPOS.indexOf(aPos);
|
|
return idx !== -1;
|
|
}
|
|
return false;
|
|
},
|
|
sort_byday_rules: function icalrecur_sort_byday_rules(aRules) {
|
|
for (var i3 = 0; i3 < aRules.length; i3++) {
|
|
for (var j4 = 0; j4 < i3; j4++) {
|
|
var one = this.ruleDayOfWeek(aRules[j4], this.rule.wkst)[1];
|
|
var two = this.ruleDayOfWeek(aRules[i3], this.rule.wkst)[1];
|
|
if (one > two) {
|
|
var tmp = aRules[i3];
|
|
aRules[i3] = aRules[j4];
|
|
aRules[j4] = tmp;
|
|
}
|
|
}
|
|
}
|
|
},
|
|
check_contract_restriction: function check_contract_restriction(aRuleType, v3) {
|
|
var indexMapValue = icalrecur_iterator._indexMap[aRuleType];
|
|
var ruleMapValue = icalrecur_iterator._expandMap[this.rule.freq][indexMapValue];
|
|
var pass = false;
|
|
if (aRuleType in this.by_data && ruleMapValue == icalrecur_iterator.CONTRACT) {
|
|
var ruleType = this.by_data[aRuleType];
|
|
for (var bydatakey in ruleType) {
|
|
if (ruleType.hasOwnProperty(bydatakey)) {
|
|
if (ruleType[bydatakey] == v3) {
|
|
pass = true;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
} else {
|
|
pass = true;
|
|
}
|
|
return pass;
|
|
},
|
|
check_contracting_rules: function check_contracting_rules() {
|
|
var dow = this.last.dayOfWeek();
|
|
var weekNo = this.last.weekNumber(this.rule.wkst);
|
|
var doy = this.last.dayOfYear();
|
|
return this.check_contract_restriction("BYSECOND", this.last.second) && this.check_contract_restriction("BYMINUTE", this.last.minute) && this.check_contract_restriction("BYHOUR", this.last.hour) && this.check_contract_restriction("BYDAY", ICAL3.Recur.numericDayToIcalDay(dow)) && this.check_contract_restriction("BYWEEKNO", weekNo) && this.check_contract_restriction("BYMONTHDAY", this.last.day) && this.check_contract_restriction("BYMONTH", this.last.month) && this.check_contract_restriction("BYYEARDAY", doy);
|
|
},
|
|
setup_defaults: function setup_defaults(aRuleType, req, deftime) {
|
|
var indexMapValue = icalrecur_iterator._indexMap[aRuleType];
|
|
var ruleMapValue = icalrecur_iterator._expandMap[this.rule.freq][indexMapValue];
|
|
if (ruleMapValue != icalrecur_iterator.CONTRACT) {
|
|
if (!(aRuleType in this.by_data)) {
|
|
this.by_data[aRuleType] = [deftime];
|
|
}
|
|
if (this.rule.freq != req) {
|
|
return this.by_data[aRuleType][0];
|
|
}
|
|
}
|
|
return deftime;
|
|
},
|
|
toJSON: function() {
|
|
var result = Object.create(null);
|
|
result.initialized = this.initialized;
|
|
result.rule = this.rule.toJSON();
|
|
result.dtstart = this.dtstart.toJSON();
|
|
result.by_data = this.by_data;
|
|
result.days = this.days;
|
|
result.last = this.last.toJSON();
|
|
result.by_indices = this.by_indices;
|
|
result.occurrence_number = this.occurrence_number;
|
|
return result;
|
|
}
|
|
};
|
|
icalrecur_iterator._indexMap = {
|
|
"BYSECOND": 0,
|
|
"BYMINUTE": 1,
|
|
"BYHOUR": 2,
|
|
"BYDAY": 3,
|
|
"BYMONTHDAY": 4,
|
|
"BYYEARDAY": 5,
|
|
"BYWEEKNO": 6,
|
|
"BYMONTH": 7,
|
|
"BYSETPOS": 8
|
|
};
|
|
icalrecur_iterator._expandMap = {
|
|
"SECONDLY": [1, 1, 1, 1, 1, 1, 1, 1],
|
|
"MINUTELY": [2, 1, 1, 1, 1, 1, 1, 1],
|
|
"HOURLY": [2, 2, 1, 1, 1, 1, 1, 1],
|
|
"DAILY": [2, 2, 2, 1, 1, 1, 1, 1],
|
|
"WEEKLY": [2, 2, 2, 2, 3, 3, 1, 1],
|
|
"MONTHLY": [2, 2, 2, 2, 2, 3, 3, 1],
|
|
"YEARLY": [2, 2, 2, 2, 2, 2, 2, 2]
|
|
};
|
|
icalrecur_iterator.UNKNOWN = 0;
|
|
icalrecur_iterator.CONTRACT = 1;
|
|
icalrecur_iterator.EXPAND = 2;
|
|
icalrecur_iterator.ILLEGAL = 3;
|
|
return icalrecur_iterator;
|
|
}();
|
|
ICAL3.RecurExpansion = function() {
|
|
function formatTime(item) {
|
|
return ICAL3.helpers.formatClassType(item, ICAL3.Time);
|
|
}
|
|
function compareTime(a3, b3) {
|
|
return a3.compare(b3);
|
|
}
|
|
function isRecurringComponent(comp) {
|
|
return comp.hasProperty("rdate") || comp.hasProperty("rrule") || comp.hasProperty("recurrence-id");
|
|
}
|
|
function RecurExpansion(options) {
|
|
this.ruleDates = [];
|
|
this.exDates = [];
|
|
this.fromData(options);
|
|
}
|
|
RecurExpansion.prototype = {
|
|
complete: false,
|
|
ruleIterators: null,
|
|
ruleDates: null,
|
|
exDates: null,
|
|
ruleDateInc: 0,
|
|
exDateInc: 0,
|
|
exDate: null,
|
|
ruleDate: null,
|
|
dtstart: null,
|
|
last: null,
|
|
fromData: function(options) {
|
|
var start = ICAL3.helpers.formatClassType(options.dtstart, ICAL3.Time);
|
|
if (!start) {
|
|
throw new Error(".dtstart (ICAL.Time) must be given");
|
|
} else {
|
|
this.dtstart = start;
|
|
}
|
|
if (options.component) {
|
|
this._init(options.component);
|
|
} else {
|
|
this.last = formatTime(options.last) || start.clone();
|
|
if (!options.ruleIterators) {
|
|
throw new Error(".ruleIterators or .component must be given");
|
|
}
|
|
this.ruleIterators = options.ruleIterators.map(function(item) {
|
|
return ICAL3.helpers.formatClassType(item, ICAL3.RecurIterator);
|
|
});
|
|
this.ruleDateInc = options.ruleDateInc;
|
|
this.exDateInc = options.exDateInc;
|
|
if (options.ruleDates) {
|
|
this.ruleDates = options.ruleDates.map(formatTime);
|
|
this.ruleDate = this.ruleDates[this.ruleDateInc];
|
|
}
|
|
if (options.exDates) {
|
|
this.exDates = options.exDates.map(formatTime);
|
|
this.exDate = this.exDates[this.exDateInc];
|
|
}
|
|
if (typeof options.complete !== "undefined") {
|
|
this.complete = options.complete;
|
|
}
|
|
}
|
|
},
|
|
next: function() {
|
|
var iter;
|
|
var ruleOfDay;
|
|
var next;
|
|
var compare;
|
|
var maxTries = 500;
|
|
var currentTry = 0;
|
|
while (true) {
|
|
if (currentTry++ > maxTries) {
|
|
throw new Error("max tries have occured, rule may be impossible to forfill.");
|
|
}
|
|
next = this.ruleDate;
|
|
iter = this._nextRecurrenceIter(this.last);
|
|
if (!next && !iter) {
|
|
this.complete = true;
|
|
break;
|
|
}
|
|
if (!next || iter && next.compare(iter.last) > 0) {
|
|
next = iter.last.clone();
|
|
iter.next();
|
|
}
|
|
if (this.ruleDate === next) {
|
|
this._nextRuleDay();
|
|
}
|
|
this.last = next;
|
|
if (this.exDate) {
|
|
compare = this.exDate.compare(this.last);
|
|
if (compare < 0) {
|
|
this._nextExDay();
|
|
}
|
|
if (compare === 0) {
|
|
this._nextExDay();
|
|
continue;
|
|
}
|
|
}
|
|
return this.last;
|
|
}
|
|
},
|
|
toJSON: function() {
|
|
function toJSON(item) {
|
|
return item.toJSON();
|
|
}
|
|
var result = Object.create(null);
|
|
result.ruleIterators = this.ruleIterators.map(toJSON);
|
|
if (this.ruleDates) {
|
|
result.ruleDates = this.ruleDates.map(toJSON);
|
|
}
|
|
if (this.exDates) {
|
|
result.exDates = this.exDates.map(toJSON);
|
|
}
|
|
result.ruleDateInc = this.ruleDateInc;
|
|
result.exDateInc = this.exDateInc;
|
|
result.last = this.last.toJSON();
|
|
result.dtstart = this.dtstart.toJSON();
|
|
result.complete = this.complete;
|
|
return result;
|
|
},
|
|
_extractDates: function(component, propertyName) {
|
|
function handleProp(prop2) {
|
|
idx = ICAL3.helpers.binsearchInsert(result, prop2, compareTime);
|
|
result.splice(idx, 0, prop2);
|
|
}
|
|
var result = [];
|
|
var props = component.getAllProperties(propertyName);
|
|
var len = props.length;
|
|
var i3 = 0;
|
|
var prop;
|
|
var idx;
|
|
for (; i3 < len; i3++) {
|
|
props[i3].getValues().forEach(handleProp);
|
|
}
|
|
return result;
|
|
},
|
|
_init: function(component) {
|
|
this.ruleIterators = [];
|
|
this.last = this.dtstart.clone();
|
|
if (!isRecurringComponent(component)) {
|
|
this.ruleDate = this.last.clone();
|
|
this.complete = true;
|
|
return;
|
|
}
|
|
if (component.hasProperty("rdate")) {
|
|
this.ruleDates = this._extractDates(component, "rdate");
|
|
if (this.ruleDates[0] && this.ruleDates[0].compare(this.dtstart) < 0) {
|
|
this.ruleDateInc = 0;
|
|
this.last = this.ruleDates[0].clone();
|
|
} else {
|
|
this.ruleDateInc = ICAL3.helpers.binsearchInsert(this.ruleDates, this.last, compareTime);
|
|
}
|
|
this.ruleDate = this.ruleDates[this.ruleDateInc];
|
|
}
|
|
if (component.hasProperty("rrule")) {
|
|
var rules = component.getAllProperties("rrule");
|
|
var i3 = 0;
|
|
var len = rules.length;
|
|
var rule;
|
|
var iter;
|
|
for (; i3 < len; i3++) {
|
|
rule = rules[i3].getFirstValue();
|
|
iter = rule.iterator(this.dtstart);
|
|
this.ruleIterators.push(iter);
|
|
iter.next();
|
|
}
|
|
}
|
|
if (component.hasProperty("exdate")) {
|
|
this.exDates = this._extractDates(component, "exdate");
|
|
this.exDateInc = ICAL3.helpers.binsearchInsert(this.exDates, this.last, compareTime);
|
|
this.exDate = this.exDates[this.exDateInc];
|
|
}
|
|
},
|
|
_nextExDay: function() {
|
|
this.exDate = this.exDates[++this.exDateInc];
|
|
},
|
|
_nextRuleDay: function() {
|
|
this.ruleDate = this.ruleDates[++this.ruleDateInc];
|
|
},
|
|
_nextRecurrenceIter: function() {
|
|
var iters = this.ruleIterators;
|
|
if (iters.length === 0) {
|
|
return null;
|
|
}
|
|
var len = iters.length;
|
|
var iter;
|
|
var iterTime;
|
|
var iterIdx = 0;
|
|
var chosenIter;
|
|
for (; iterIdx < len; iterIdx++) {
|
|
iter = iters[iterIdx];
|
|
iterTime = iter.last;
|
|
if (iter.completed) {
|
|
len--;
|
|
if (iterIdx !== 0) {
|
|
iterIdx--;
|
|
}
|
|
iters.splice(iterIdx, 1);
|
|
continue;
|
|
}
|
|
if (!chosenIter || chosenIter.last.compare(iterTime) > 0) {
|
|
chosenIter = iter;
|
|
}
|
|
}
|
|
return chosenIter;
|
|
}
|
|
};
|
|
return RecurExpansion;
|
|
}();
|
|
ICAL3.Event = function() {
|
|
function Event3(component, options) {
|
|
if (!(component instanceof ICAL3.Component)) {
|
|
options = component;
|
|
component = null;
|
|
}
|
|
if (component) {
|
|
this.component = component;
|
|
} else {
|
|
this.component = new ICAL3.Component("vevent");
|
|
}
|
|
this._rangeExceptionCache = Object.create(null);
|
|
this.exceptions = Object.create(null);
|
|
this.rangeExceptions = [];
|
|
if (options && options.strictExceptions) {
|
|
this.strictExceptions = options.strictExceptions;
|
|
}
|
|
if (options && options.exceptions) {
|
|
options.exceptions.forEach(this.relateException, this);
|
|
} else if (this.component.parent && !this.isRecurrenceException()) {
|
|
this.component.parent.getAllSubcomponents("vevent").forEach(function(event) {
|
|
if (event.hasProperty("recurrence-id")) {
|
|
this.relateException(event);
|
|
}
|
|
}, this);
|
|
}
|
|
}
|
|
Event3.prototype = {
|
|
THISANDFUTURE: "THISANDFUTURE",
|
|
exceptions: null,
|
|
strictExceptions: false,
|
|
relateException: function(obj) {
|
|
if (this.isRecurrenceException()) {
|
|
throw new Error("cannot relate exception to exceptions");
|
|
}
|
|
if (obj instanceof ICAL3.Component) {
|
|
obj = new ICAL3.Event(obj);
|
|
}
|
|
if (this.strictExceptions && obj.uid !== this.uid) {
|
|
throw new Error("attempted to relate unrelated exception");
|
|
}
|
|
var id = obj.recurrenceId.toString();
|
|
this.exceptions[id] = obj;
|
|
if (obj.modifiesFuture()) {
|
|
var item = [
|
|
obj.recurrenceId.toUnixTime(),
|
|
id
|
|
];
|
|
var idx = ICAL3.helpers.binsearchInsert(this.rangeExceptions, item, compareRangeException);
|
|
this.rangeExceptions.splice(idx, 0, item);
|
|
}
|
|
},
|
|
modifiesFuture: function() {
|
|
if (!this.component.hasProperty("recurrence-id")) {
|
|
return false;
|
|
}
|
|
var range = this.component.getFirstProperty("recurrence-id").getParameter("range");
|
|
return range === this.THISANDFUTURE;
|
|
},
|
|
findRangeException: function(time) {
|
|
if (!this.rangeExceptions.length) {
|
|
return null;
|
|
}
|
|
var utc = time.toUnixTime();
|
|
var idx = ICAL3.helpers.binsearchInsert(this.rangeExceptions, [utc], compareRangeException);
|
|
idx -= 1;
|
|
if (idx < 0) {
|
|
return null;
|
|
}
|
|
var rangeItem = this.rangeExceptions[idx];
|
|
if (utc < rangeItem[0]) {
|
|
return null;
|
|
}
|
|
return rangeItem[1];
|
|
},
|
|
getOccurrenceDetails: function(occurrence) {
|
|
var id = occurrence.toString();
|
|
var utcId = occurrence.convertToZone(ICAL3.Timezone.utcTimezone).toString();
|
|
var item;
|
|
var result = {
|
|
recurrenceId: occurrence
|
|
};
|
|
if (id in this.exceptions) {
|
|
item = result.item = this.exceptions[id];
|
|
result.startDate = item.startDate;
|
|
result.endDate = item.endDate;
|
|
result.item = item;
|
|
} else if (utcId in this.exceptions) {
|
|
item = this.exceptions[utcId];
|
|
result.startDate = item.startDate;
|
|
result.endDate = item.endDate;
|
|
result.item = item;
|
|
} else {
|
|
var rangeExceptionId = this.findRangeException(occurrence);
|
|
var end;
|
|
if (rangeExceptionId) {
|
|
var exception = this.exceptions[rangeExceptionId];
|
|
result.item = exception;
|
|
var startDiff = this._rangeExceptionCache[rangeExceptionId];
|
|
if (!startDiff) {
|
|
var original = exception.recurrenceId.clone();
|
|
var newStart = exception.startDate.clone();
|
|
original.zone = newStart.zone;
|
|
startDiff = newStart.subtractDate(original);
|
|
this._rangeExceptionCache[rangeExceptionId] = startDiff;
|
|
}
|
|
var start = occurrence.clone();
|
|
start.zone = exception.startDate.zone;
|
|
start.addDuration(startDiff);
|
|
end = start.clone();
|
|
end.addDuration(exception.duration);
|
|
result.startDate = start;
|
|
result.endDate = end;
|
|
} else {
|
|
end = occurrence.clone();
|
|
end.addDuration(this.duration);
|
|
result.endDate = end;
|
|
result.startDate = occurrence;
|
|
result.item = this;
|
|
}
|
|
}
|
|
return result;
|
|
},
|
|
iterator: function(startTime) {
|
|
return new ICAL3.RecurExpansion({
|
|
component: this.component,
|
|
dtstart: startTime || this.startDate
|
|
});
|
|
},
|
|
isRecurring: function() {
|
|
var comp = this.component;
|
|
return comp.hasProperty("rrule") || comp.hasProperty("rdate");
|
|
},
|
|
isRecurrenceException: function() {
|
|
return this.component.hasProperty("recurrence-id");
|
|
},
|
|
getRecurrenceTypes: function() {
|
|
var rules = this.component.getAllProperties("rrule");
|
|
var i3 = 0;
|
|
var len = rules.length;
|
|
var result = Object.create(null);
|
|
for (; i3 < len; i3++) {
|
|
var value = rules[i3].getFirstValue();
|
|
result[value.freq] = true;
|
|
}
|
|
return result;
|
|
},
|
|
get uid() {
|
|
return this._firstProp("uid");
|
|
},
|
|
set uid(value) {
|
|
this._setProp("uid", value);
|
|
},
|
|
get startDate() {
|
|
return this._firstProp("dtstart");
|
|
},
|
|
set startDate(value) {
|
|
this._setTime("dtstart", value);
|
|
},
|
|
get endDate() {
|
|
var endDate = this._firstProp("dtend");
|
|
if (!endDate) {
|
|
var duration = this._firstProp("duration");
|
|
endDate = this.startDate.clone();
|
|
if (duration) {
|
|
endDate.addDuration(duration);
|
|
} else if (endDate.isDate) {
|
|
endDate.day += 1;
|
|
}
|
|
}
|
|
return endDate;
|
|
},
|
|
set endDate(value) {
|
|
if (this.component.hasProperty("duration")) {
|
|
this.component.removeProperty("duration");
|
|
}
|
|
this._setTime("dtend", value);
|
|
},
|
|
get duration() {
|
|
var duration = this._firstProp("duration");
|
|
if (!duration) {
|
|
return this.endDate.subtractDateTz(this.startDate);
|
|
}
|
|
return duration;
|
|
},
|
|
set duration(value) {
|
|
if (this.component.hasProperty("dtend")) {
|
|
this.component.removeProperty("dtend");
|
|
}
|
|
this._setProp("duration", value);
|
|
},
|
|
get location() {
|
|
return this._firstProp("location");
|
|
},
|
|
set location(value) {
|
|
return this._setProp("location", value);
|
|
},
|
|
get attendees() {
|
|
return this.component.getAllProperties("attendee");
|
|
},
|
|
get summary() {
|
|
return this._firstProp("summary");
|
|
},
|
|
set summary(value) {
|
|
this._setProp("summary", value);
|
|
},
|
|
get description() {
|
|
return this._firstProp("description");
|
|
},
|
|
set description(value) {
|
|
this._setProp("description", value);
|
|
},
|
|
get color() {
|
|
return this._firstProp("color");
|
|
},
|
|
set color(value) {
|
|
this._setProp("color", value);
|
|
},
|
|
get organizer() {
|
|
return this._firstProp("organizer");
|
|
},
|
|
set organizer(value) {
|
|
this._setProp("organizer", value);
|
|
},
|
|
get sequence() {
|
|
return this._firstProp("sequence");
|
|
},
|
|
set sequence(value) {
|
|
this._setProp("sequence", value);
|
|
},
|
|
get recurrenceId() {
|
|
return this._firstProp("recurrence-id");
|
|
},
|
|
set recurrenceId(value) {
|
|
this._setTime("recurrence-id", value);
|
|
},
|
|
_setTime: function(propName, time) {
|
|
var prop = this.component.getFirstProperty(propName);
|
|
if (!prop) {
|
|
prop = new ICAL3.Property(propName);
|
|
this.component.addProperty(prop);
|
|
}
|
|
if (time.zone === ICAL3.Timezone.localTimezone || time.zone === ICAL3.Timezone.utcTimezone) {
|
|
prop.removeParameter("tzid");
|
|
} else {
|
|
prop.setParameter("tzid", time.zone.tzid);
|
|
}
|
|
prop.setValue(time);
|
|
},
|
|
_setProp: function(name, value) {
|
|
this.component.updatePropertyWithValue(name, value);
|
|
},
|
|
_firstProp: function(name) {
|
|
return this.component.getFirstPropertyValue(name);
|
|
},
|
|
toString: function() {
|
|
return this.component.toString();
|
|
}
|
|
};
|
|
function compareRangeException(a3, b3) {
|
|
if (a3[0] > b3[0])
|
|
return 1;
|
|
if (b3[0] > a3[0])
|
|
return -1;
|
|
return 0;
|
|
}
|
|
return Event3;
|
|
}();
|
|
ICAL3.ComponentParser = function() {
|
|
function ComponentParser(options) {
|
|
if (typeof options === "undefined") {
|
|
options = {};
|
|
}
|
|
var key;
|
|
for (key in options) {
|
|
if (options.hasOwnProperty(key)) {
|
|
this[key] = options[key];
|
|
}
|
|
}
|
|
}
|
|
ComponentParser.prototype = {
|
|
parseEvent: true,
|
|
parseTimezone: true,
|
|
oncomplete: function() {
|
|
},
|
|
onerror: function(err) {
|
|
},
|
|
ontimezone: function(component) {
|
|
},
|
|
onevent: function(component) {
|
|
},
|
|
process: function(ical) {
|
|
if (typeof ical === "string") {
|
|
ical = ICAL3.parse(ical);
|
|
}
|
|
if (!(ical instanceof ICAL3.Component)) {
|
|
ical = new ICAL3.Component(ical);
|
|
}
|
|
var components = ical.getAllSubcomponents();
|
|
var i3 = 0;
|
|
var len = components.length;
|
|
var component;
|
|
for (; i3 < len; i3++) {
|
|
component = components[i3];
|
|
switch (component.name) {
|
|
case "vtimezone":
|
|
if (this.parseTimezone) {
|
|
var tzid = component.getFirstPropertyValue("tzid");
|
|
if (tzid) {
|
|
this.ontimezone(new ICAL3.Timezone({
|
|
tzid,
|
|
component
|
|
}));
|
|
}
|
|
}
|
|
break;
|
|
case "vevent":
|
|
if (this.parseEvent) {
|
|
this.onevent(new ICAL3.Event(component));
|
|
}
|
|
break;
|
|
default:
|
|
continue;
|
|
}
|
|
}
|
|
this.oncomplete();
|
|
}
|
|
};
|
|
return ComponentParser;
|
|
}();
|
|
}
|
|
});
|
|
|
|
// node_modules/object-assign/index.js
|
|
var require_object_assign = __commonJS({
|
|
"node_modules/object-assign/index.js"(exports, module2) {
|
|
"use strict";
|
|
var getOwnPropertySymbols = Object.getOwnPropertySymbols;
|
|
var hasOwnProperty2 = Object.prototype.hasOwnProperty;
|
|
var propIsEnumerable = Object.prototype.propertyIsEnumerable;
|
|
function toObject(val) {
|
|
if (val === null || val === void 0) {
|
|
throw new TypeError("Object.assign cannot be called with null or undefined");
|
|
}
|
|
return Object(val);
|
|
}
|
|
function shouldUseNative() {
|
|
try {
|
|
if (!Object.assign) {
|
|
return false;
|
|
}
|
|
var test1 = new String("abc");
|
|
test1[5] = "de";
|
|
if (Object.getOwnPropertyNames(test1)[0] === "5") {
|
|
return false;
|
|
}
|
|
var test2 = {};
|
|
for (var i3 = 0; i3 < 10; i3++) {
|
|
test2["_" + String.fromCharCode(i3)] = i3;
|
|
}
|
|
var order2 = Object.getOwnPropertyNames(test2).map(function(n2) {
|
|
return test2[n2];
|
|
});
|
|
if (order2.join("") !== "0123456789") {
|
|
return false;
|
|
}
|
|
var test3 = {};
|
|
"abcdefghijklmnopqrst".split("").forEach(function(letter) {
|
|
test3[letter] = letter;
|
|
});
|
|
if (Object.keys(Object.assign({}, test3)).join("") !== "abcdefghijklmnopqrst") {
|
|
return false;
|
|
}
|
|
return true;
|
|
} catch (err) {
|
|
return false;
|
|
}
|
|
}
|
|
module2.exports = shouldUseNative() ? Object.assign : function(target, source) {
|
|
var from;
|
|
var to = toObject(target);
|
|
var symbols;
|
|
for (var s3 = 1; s3 < arguments.length; s3++) {
|
|
from = Object(arguments[s3]);
|
|
for (var key in from) {
|
|
if (hasOwnProperty2.call(from, key)) {
|
|
to[key] = from[key];
|
|
}
|
|
}
|
|
if (getOwnPropertySymbols) {
|
|
symbols = getOwnPropertySymbols(from);
|
|
for (var i3 = 0; i3 < symbols.length; i3++) {
|
|
if (propIsEnumerable.call(from, symbols[i3])) {
|
|
to[symbols[i3]] = from[symbols[i3]];
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return to;
|
|
};
|
|
}
|
|
});
|
|
|
|
// node_modules/react/cjs/react.development.js
|
|
var require_react_development = __commonJS({
|
|
"node_modules/react/cjs/react.development.js"(exports) {
|
|
"use strict";
|
|
if (true) {
|
|
(function() {
|
|
"use strict";
|
|
var _assign = require_object_assign();
|
|
var ReactVersion = "17.0.2";
|
|
var REACT_ELEMENT_TYPE = 60103;
|
|
var REACT_PORTAL_TYPE = 60106;
|
|
exports.Fragment = 60107;
|
|
exports.StrictMode = 60108;
|
|
exports.Profiler = 60114;
|
|
var REACT_PROVIDER_TYPE = 60109;
|
|
var REACT_CONTEXT_TYPE = 60110;
|
|
var REACT_FORWARD_REF_TYPE = 60112;
|
|
exports.Suspense = 60113;
|
|
var REACT_SUSPENSE_LIST_TYPE = 60120;
|
|
var REACT_MEMO_TYPE = 60115;
|
|
var REACT_LAZY_TYPE = 60116;
|
|
var REACT_BLOCK_TYPE = 60121;
|
|
var REACT_SERVER_BLOCK_TYPE = 60122;
|
|
var REACT_FUNDAMENTAL_TYPE = 60117;
|
|
var REACT_SCOPE_TYPE = 60119;
|
|
var REACT_OPAQUE_ID_TYPE = 60128;
|
|
var REACT_DEBUG_TRACING_MODE_TYPE = 60129;
|
|
var REACT_OFFSCREEN_TYPE = 60130;
|
|
var REACT_LEGACY_HIDDEN_TYPE = 60131;
|
|
if (typeof Symbol === "function" && Symbol.for) {
|
|
var symbolFor = Symbol.for;
|
|
REACT_ELEMENT_TYPE = symbolFor("react.element");
|
|
REACT_PORTAL_TYPE = symbolFor("react.portal");
|
|
exports.Fragment = symbolFor("react.fragment");
|
|
exports.StrictMode = symbolFor("react.strict_mode");
|
|
exports.Profiler = symbolFor("react.profiler");
|
|
REACT_PROVIDER_TYPE = symbolFor("react.provider");
|
|
REACT_CONTEXT_TYPE = symbolFor("react.context");
|
|
REACT_FORWARD_REF_TYPE = symbolFor("react.forward_ref");
|
|
exports.Suspense = symbolFor("react.suspense");
|
|
REACT_SUSPENSE_LIST_TYPE = symbolFor("react.suspense_list");
|
|
REACT_MEMO_TYPE = symbolFor("react.memo");
|
|
REACT_LAZY_TYPE = symbolFor("react.lazy");
|
|
REACT_BLOCK_TYPE = symbolFor("react.block");
|
|
REACT_SERVER_BLOCK_TYPE = symbolFor("react.server.block");
|
|
REACT_FUNDAMENTAL_TYPE = symbolFor("react.fundamental");
|
|
REACT_SCOPE_TYPE = symbolFor("react.scope");
|
|
REACT_OPAQUE_ID_TYPE = symbolFor("react.opaque.id");
|
|
REACT_DEBUG_TRACING_MODE_TYPE = symbolFor("react.debug_trace_mode");
|
|
REACT_OFFSCREEN_TYPE = symbolFor("react.offscreen");
|
|
REACT_LEGACY_HIDDEN_TYPE = symbolFor("react.legacy_hidden");
|
|
}
|
|
var MAYBE_ITERATOR_SYMBOL = typeof Symbol === "function" && Symbol.iterator;
|
|
var FAUX_ITERATOR_SYMBOL = "@@iterator";
|
|
function getIteratorFn(maybeIterable) {
|
|
if (maybeIterable === null || typeof maybeIterable !== "object") {
|
|
return null;
|
|
}
|
|
var maybeIterator = MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL];
|
|
if (typeof maybeIterator === "function") {
|
|
return maybeIterator;
|
|
}
|
|
return null;
|
|
}
|
|
var ReactCurrentDispatcher = {
|
|
current: null
|
|
};
|
|
var ReactCurrentBatchConfig = {
|
|
transition: 0
|
|
};
|
|
var ReactCurrentOwner = {
|
|
current: null
|
|
};
|
|
var ReactDebugCurrentFrame = {};
|
|
var currentExtraStackFrame = null;
|
|
function setExtraStackFrame(stack) {
|
|
{
|
|
currentExtraStackFrame = stack;
|
|
}
|
|
}
|
|
{
|
|
ReactDebugCurrentFrame.setExtraStackFrame = function(stack) {
|
|
{
|
|
currentExtraStackFrame = stack;
|
|
}
|
|
};
|
|
ReactDebugCurrentFrame.getCurrentStack = null;
|
|
ReactDebugCurrentFrame.getStackAddendum = function() {
|
|
var stack = "";
|
|
if (currentExtraStackFrame) {
|
|
stack += currentExtraStackFrame;
|
|
}
|
|
var impl = ReactDebugCurrentFrame.getCurrentStack;
|
|
if (impl) {
|
|
stack += impl() || "";
|
|
}
|
|
return stack;
|
|
};
|
|
}
|
|
var IsSomeRendererActing = {
|
|
current: false
|
|
};
|
|
var ReactSharedInternals = {
|
|
ReactCurrentDispatcher,
|
|
ReactCurrentBatchConfig,
|
|
ReactCurrentOwner,
|
|
IsSomeRendererActing,
|
|
assign: _assign
|
|
};
|
|
{
|
|
ReactSharedInternals.ReactDebugCurrentFrame = ReactDebugCurrentFrame;
|
|
}
|
|
function warn(format) {
|
|
{
|
|
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
args[_key - 1] = arguments[_key];
|
|
}
|
|
printWarning("warn", format, args);
|
|
}
|
|
}
|
|
function error(format) {
|
|
{
|
|
for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
|
args[_key2 - 1] = arguments[_key2];
|
|
}
|
|
printWarning("error", format, args);
|
|
}
|
|
}
|
|
function printWarning(level, format, args) {
|
|
{
|
|
var ReactDebugCurrentFrame2 = ReactSharedInternals.ReactDebugCurrentFrame;
|
|
var stack = ReactDebugCurrentFrame2.getStackAddendum();
|
|
if (stack !== "") {
|
|
format += "%s";
|
|
args = args.concat([stack]);
|
|
}
|
|
var argsWithFormat = args.map(function(item) {
|
|
return "" + item;
|
|
});
|
|
argsWithFormat.unshift("Warning: " + format);
|
|
Function.prototype.apply.call(console[level], console, argsWithFormat);
|
|
}
|
|
}
|
|
var didWarnStateUpdateForUnmountedComponent = {};
|
|
function warnNoop(publicInstance, callerName) {
|
|
{
|
|
var _constructor = publicInstance.constructor;
|
|
var componentName = _constructor && (_constructor.displayName || _constructor.name) || "ReactClass";
|
|
var warningKey = componentName + "." + callerName;
|
|
if (didWarnStateUpdateForUnmountedComponent[warningKey]) {
|
|
return;
|
|
}
|
|
error("Can't call %s on a component that is not yet mounted. This is a no-op, but it might indicate a bug in your application. Instead, assign to `this.state` directly or define a `state = {};` class property with the desired state in the %s component.", callerName, componentName);
|
|
didWarnStateUpdateForUnmountedComponent[warningKey] = true;
|
|
}
|
|
}
|
|
var ReactNoopUpdateQueue = {
|
|
isMounted: function(publicInstance) {
|
|
return false;
|
|
},
|
|
enqueueForceUpdate: function(publicInstance, callback, callerName) {
|
|
warnNoop(publicInstance, "forceUpdate");
|
|
},
|
|
enqueueReplaceState: function(publicInstance, completeState, callback, callerName) {
|
|
warnNoop(publicInstance, "replaceState");
|
|
},
|
|
enqueueSetState: function(publicInstance, partialState, callback, callerName) {
|
|
warnNoop(publicInstance, "setState");
|
|
}
|
|
};
|
|
var emptyObject = {};
|
|
{
|
|
Object.freeze(emptyObject);
|
|
}
|
|
function Component5(props, context, updater) {
|
|
this.props = props;
|
|
this.context = context;
|
|
this.refs = emptyObject;
|
|
this.updater = updater || ReactNoopUpdateQueue;
|
|
}
|
|
Component5.prototype.isReactComponent = {};
|
|
Component5.prototype.setState = function(partialState, callback) {
|
|
if (!(typeof partialState === "object" || typeof partialState === "function" || partialState == null)) {
|
|
{
|
|
throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");
|
|
}
|
|
}
|
|
this.updater.enqueueSetState(this, partialState, callback, "setState");
|
|
};
|
|
Component5.prototype.forceUpdate = function(callback) {
|
|
this.updater.enqueueForceUpdate(this, callback, "forceUpdate");
|
|
};
|
|
{
|
|
var deprecatedAPIs = {
|
|
isMounted: ["isMounted", "Instead, make sure to clean up subscriptions and pending requests in componentWillUnmount to prevent memory leaks."],
|
|
replaceState: ["replaceState", "Refactor your code to use setState instead (see https://github.com/facebook/react/issues/3236)."]
|
|
};
|
|
var defineDeprecationWarning = function(methodName, info) {
|
|
Object.defineProperty(Component5.prototype, methodName, {
|
|
get: function() {
|
|
warn("%s(...) is deprecated in plain JavaScript React classes. %s", info[0], info[1]);
|
|
return void 0;
|
|
}
|
|
});
|
|
};
|
|
for (var fnName in deprecatedAPIs) {
|
|
if (deprecatedAPIs.hasOwnProperty(fnName)) {
|
|
defineDeprecationWarning(fnName, deprecatedAPIs[fnName]);
|
|
}
|
|
}
|
|
}
|
|
function ComponentDummy() {
|
|
}
|
|
ComponentDummy.prototype = Component5.prototype;
|
|
function PureComponent2(props, context, updater) {
|
|
this.props = props;
|
|
this.context = context;
|
|
this.refs = emptyObject;
|
|
this.updater = updater || ReactNoopUpdateQueue;
|
|
}
|
|
var pureComponentPrototype = PureComponent2.prototype = new ComponentDummy();
|
|
pureComponentPrototype.constructor = PureComponent2;
|
|
_assign(pureComponentPrototype, Component5.prototype);
|
|
pureComponentPrototype.isPureReactComponent = true;
|
|
function createRef2() {
|
|
var refObject = {
|
|
current: null
|
|
};
|
|
{
|
|
Object.seal(refObject);
|
|
}
|
|
return refObject;
|
|
}
|
|
function getWrappedName(outerType, innerType, wrapperName) {
|
|
var functionName = innerType.displayName || innerType.name || "";
|
|
return outerType.displayName || (functionName !== "" ? wrapperName + "(" + functionName + ")" : wrapperName);
|
|
}
|
|
function getContextName(type) {
|
|
return type.displayName || "Context";
|
|
}
|
|
function getComponentName(type) {
|
|
if (type == null) {
|
|
return null;
|
|
}
|
|
{
|
|
if (typeof type.tag === "number") {
|
|
error("Received an unexpected object in getComponentName(). This is likely a bug in React. Please file an issue.");
|
|
}
|
|
}
|
|
if (typeof type === "function") {
|
|
return type.displayName || type.name || null;
|
|
}
|
|
if (typeof type === "string") {
|
|
return type;
|
|
}
|
|
switch (type) {
|
|
case exports.Fragment:
|
|
return "Fragment";
|
|
case REACT_PORTAL_TYPE:
|
|
return "Portal";
|
|
case exports.Profiler:
|
|
return "Profiler";
|
|
case exports.StrictMode:
|
|
return "StrictMode";
|
|
case exports.Suspense:
|
|
return "Suspense";
|
|
case REACT_SUSPENSE_LIST_TYPE:
|
|
return "SuspenseList";
|
|
}
|
|
if (typeof type === "object") {
|
|
switch (type.$$typeof) {
|
|
case REACT_CONTEXT_TYPE:
|
|
var context = type;
|
|
return getContextName(context) + ".Consumer";
|
|
case REACT_PROVIDER_TYPE:
|
|
var provider = type;
|
|
return getContextName(provider._context) + ".Provider";
|
|
case REACT_FORWARD_REF_TYPE:
|
|
return getWrappedName(type, type.render, "ForwardRef");
|
|
case REACT_MEMO_TYPE:
|
|
return getComponentName(type.type);
|
|
case REACT_BLOCK_TYPE:
|
|
return getComponentName(type._render);
|
|
case REACT_LAZY_TYPE: {
|
|
var lazyComponent = type;
|
|
var payload = lazyComponent._payload;
|
|
var init = lazyComponent._init;
|
|
try {
|
|
return getComponentName(init(payload));
|
|
} catch (x3) {
|
|
return null;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
var hasOwnProperty2 = Object.prototype.hasOwnProperty;
|
|
var RESERVED_PROPS = {
|
|
key: true,
|
|
ref: true,
|
|
__self: true,
|
|
__source: true
|
|
};
|
|
var specialPropKeyWarningShown, specialPropRefWarningShown, didWarnAboutStringRefs;
|
|
{
|
|
didWarnAboutStringRefs = {};
|
|
}
|
|
function hasValidRef(config2) {
|
|
{
|
|
if (hasOwnProperty2.call(config2, "ref")) {
|
|
var getter = Object.getOwnPropertyDescriptor(config2, "ref").get;
|
|
if (getter && getter.isReactWarning) {
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
return config2.ref !== void 0;
|
|
}
|
|
function hasValidKey(config2) {
|
|
{
|
|
if (hasOwnProperty2.call(config2, "key")) {
|
|
var getter = Object.getOwnPropertyDescriptor(config2, "key").get;
|
|
if (getter && getter.isReactWarning) {
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
return config2.key !== void 0;
|
|
}
|
|
function defineKeyPropWarningGetter(props, displayName) {
|
|
var warnAboutAccessingKey = function() {
|
|
{
|
|
if (!specialPropKeyWarningShown) {
|
|
specialPropKeyWarningShown = true;
|
|
error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", displayName);
|
|
}
|
|
}
|
|
};
|
|
warnAboutAccessingKey.isReactWarning = true;
|
|
Object.defineProperty(props, "key", {
|
|
get: warnAboutAccessingKey,
|
|
configurable: true
|
|
});
|
|
}
|
|
function defineRefPropWarningGetter(props, displayName) {
|
|
var warnAboutAccessingRef = function() {
|
|
{
|
|
if (!specialPropRefWarningShown) {
|
|
specialPropRefWarningShown = true;
|
|
error("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", displayName);
|
|
}
|
|
}
|
|
};
|
|
warnAboutAccessingRef.isReactWarning = true;
|
|
Object.defineProperty(props, "ref", {
|
|
get: warnAboutAccessingRef,
|
|
configurable: true
|
|
});
|
|
}
|
|
function warnIfStringRefCannotBeAutoConverted(config2) {
|
|
{
|
|
if (typeof config2.ref === "string" && ReactCurrentOwner.current && config2.__self && ReactCurrentOwner.current.stateNode !== config2.__self) {
|
|
var componentName = getComponentName(ReactCurrentOwner.current.type);
|
|
if (!didWarnAboutStringRefs[componentName]) {
|
|
error('Component "%s" contains the string ref "%s". Support for string refs will be removed in a future major release. This case cannot be automatically converted to an arrow function. We ask you to manually fix this case by using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref', componentName, config2.ref);
|
|
didWarnAboutStringRefs[componentName] = true;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
var ReactElement = function(type, key, ref, self2, source, owner, props) {
|
|
var element = {
|
|
$$typeof: REACT_ELEMENT_TYPE,
|
|
type,
|
|
key,
|
|
ref,
|
|
props,
|
|
_owner: owner
|
|
};
|
|
{
|
|
element._store = {};
|
|
Object.defineProperty(element._store, "validated", {
|
|
configurable: false,
|
|
enumerable: false,
|
|
writable: true,
|
|
value: false
|
|
});
|
|
Object.defineProperty(element, "_self", {
|
|
configurable: false,
|
|
enumerable: false,
|
|
writable: false,
|
|
value: self2
|
|
});
|
|
Object.defineProperty(element, "_source", {
|
|
configurable: false,
|
|
enumerable: false,
|
|
writable: false,
|
|
value: source
|
|
});
|
|
if (Object.freeze) {
|
|
Object.freeze(element.props);
|
|
Object.freeze(element);
|
|
}
|
|
}
|
|
return element;
|
|
};
|
|
function createElement7(type, config2, children) {
|
|
var propName;
|
|
var props = {};
|
|
var key = null;
|
|
var ref = null;
|
|
var self2 = null;
|
|
var source = null;
|
|
if (config2 != null) {
|
|
if (hasValidRef(config2)) {
|
|
ref = config2.ref;
|
|
{
|
|
warnIfStringRefCannotBeAutoConverted(config2);
|
|
}
|
|
}
|
|
if (hasValidKey(config2)) {
|
|
key = "" + config2.key;
|
|
}
|
|
self2 = config2.__self === void 0 ? null : config2.__self;
|
|
source = config2.__source === void 0 ? null : config2.__source;
|
|
for (propName in config2) {
|
|
if (hasOwnProperty2.call(config2, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) {
|
|
props[propName] = config2[propName];
|
|
}
|
|
}
|
|
}
|
|
var childrenLength = arguments.length - 2;
|
|
if (childrenLength === 1) {
|
|
props.children = children;
|
|
} else if (childrenLength > 1) {
|
|
var childArray = Array(childrenLength);
|
|
for (var i3 = 0; i3 < childrenLength; i3++) {
|
|
childArray[i3] = arguments[i3 + 2];
|
|
}
|
|
{
|
|
if (Object.freeze) {
|
|
Object.freeze(childArray);
|
|
}
|
|
}
|
|
props.children = childArray;
|
|
}
|
|
if (type && type.defaultProps) {
|
|
var defaultProps = type.defaultProps;
|
|
for (propName in defaultProps) {
|
|
if (props[propName] === void 0) {
|
|
props[propName] = defaultProps[propName];
|
|
}
|
|
}
|
|
}
|
|
{
|
|
if (key || ref) {
|
|
var displayName = typeof type === "function" ? type.displayName || type.name || "Unknown" : type;
|
|
if (key) {
|
|
defineKeyPropWarningGetter(props, displayName);
|
|
}
|
|
if (ref) {
|
|
defineRefPropWarningGetter(props, displayName);
|
|
}
|
|
}
|
|
}
|
|
return ReactElement(type, key, ref, self2, source, ReactCurrentOwner.current, props);
|
|
}
|
|
function cloneAndReplaceKey(oldElement, newKey) {
|
|
var newElement = ReactElement(oldElement.type, newKey, oldElement.ref, oldElement._self, oldElement._source, oldElement._owner, oldElement.props);
|
|
return newElement;
|
|
}
|
|
function cloneElement(element, config2, children) {
|
|
if (!!(element === null || element === void 0)) {
|
|
{
|
|
throw Error("React.cloneElement(...): The argument must be a React element, but you passed " + element + ".");
|
|
}
|
|
}
|
|
var propName;
|
|
var props = _assign({}, element.props);
|
|
var key = element.key;
|
|
var ref = element.ref;
|
|
var self2 = element._self;
|
|
var source = element._source;
|
|
var owner = element._owner;
|
|
if (config2 != null) {
|
|
if (hasValidRef(config2)) {
|
|
ref = config2.ref;
|
|
owner = ReactCurrentOwner.current;
|
|
}
|
|
if (hasValidKey(config2)) {
|
|
key = "" + config2.key;
|
|
}
|
|
var defaultProps;
|
|
if (element.type && element.type.defaultProps) {
|
|
defaultProps = element.type.defaultProps;
|
|
}
|
|
for (propName in config2) {
|
|
if (hasOwnProperty2.call(config2, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) {
|
|
if (config2[propName] === void 0 && defaultProps !== void 0) {
|
|
props[propName] = defaultProps[propName];
|
|
} else {
|
|
props[propName] = config2[propName];
|
|
}
|
|
}
|
|
}
|
|
}
|
|
var childrenLength = arguments.length - 2;
|
|
if (childrenLength === 1) {
|
|
props.children = children;
|
|
} else if (childrenLength > 1) {
|
|
var childArray = Array(childrenLength);
|
|
for (var i3 = 0; i3 < childrenLength; i3++) {
|
|
childArray[i3] = arguments[i3 + 2];
|
|
}
|
|
props.children = childArray;
|
|
}
|
|
return ReactElement(element.type, key, ref, self2, source, owner, props);
|
|
}
|
|
function isValidElement(object) {
|
|
return typeof object === "object" && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
|
|
}
|
|
var SEPARATOR = ".";
|
|
var SUBSEPARATOR = ":";
|
|
function escape2(key) {
|
|
var escapeRegex = /[=:]/g;
|
|
var escaperLookup = {
|
|
"=": "=0",
|
|
":": "=2"
|
|
};
|
|
var escapedString = key.replace(escapeRegex, function(match) {
|
|
return escaperLookup[match];
|
|
});
|
|
return "$" + escapedString;
|
|
}
|
|
var didWarnAboutMaps = false;
|
|
var userProvidedKeyEscapeRegex = /\/+/g;
|
|
function escapeUserProvidedKey(text) {
|
|
return text.replace(userProvidedKeyEscapeRegex, "$&/");
|
|
}
|
|
function getElementKey(element, index) {
|
|
if (typeof element === "object" && element !== null && element.key != null) {
|
|
return escape2("" + element.key);
|
|
}
|
|
return index.toString(36);
|
|
}
|
|
function mapIntoArray(children, array, escapedPrefix, nameSoFar, callback) {
|
|
var type = typeof children;
|
|
if (type === "undefined" || type === "boolean") {
|
|
children = null;
|
|
}
|
|
var invokeCallback = false;
|
|
if (children === null) {
|
|
invokeCallback = true;
|
|
} else {
|
|
switch (type) {
|
|
case "string":
|
|
case "number":
|
|
invokeCallback = true;
|
|
break;
|
|
case "object":
|
|
switch (children.$$typeof) {
|
|
case REACT_ELEMENT_TYPE:
|
|
case REACT_PORTAL_TYPE:
|
|
invokeCallback = true;
|
|
}
|
|
}
|
|
}
|
|
if (invokeCallback) {
|
|
var _child = children;
|
|
var mappedChild = callback(_child);
|
|
var childKey = nameSoFar === "" ? SEPARATOR + getElementKey(_child, 0) : nameSoFar;
|
|
if (Array.isArray(mappedChild)) {
|
|
var escapedChildKey = "";
|
|
if (childKey != null) {
|
|
escapedChildKey = escapeUserProvidedKey(childKey) + "/";
|
|
}
|
|
mapIntoArray(mappedChild, array, escapedChildKey, "", function(c3) {
|
|
return c3;
|
|
});
|
|
} else if (mappedChild != null) {
|
|
if (isValidElement(mappedChild)) {
|
|
mappedChild = cloneAndReplaceKey(mappedChild, escapedPrefix + (mappedChild.key && (!_child || _child.key !== mappedChild.key) ? escapeUserProvidedKey("" + mappedChild.key) + "/" : "") + childKey);
|
|
}
|
|
array.push(mappedChild);
|
|
}
|
|
return 1;
|
|
}
|
|
var child;
|
|
var nextName;
|
|
var subtreeCount = 0;
|
|
var nextNamePrefix = nameSoFar === "" ? SEPARATOR : nameSoFar + SUBSEPARATOR;
|
|
if (Array.isArray(children)) {
|
|
for (var i3 = 0; i3 < children.length; i3++) {
|
|
child = children[i3];
|
|
nextName = nextNamePrefix + getElementKey(child, i3);
|
|
subtreeCount += mapIntoArray(child, array, escapedPrefix, nextName, callback);
|
|
}
|
|
} else {
|
|
var iteratorFn = getIteratorFn(children);
|
|
if (typeof iteratorFn === "function") {
|
|
var iterableChildren = children;
|
|
{
|
|
if (iteratorFn === iterableChildren.entries) {
|
|
if (!didWarnAboutMaps) {
|
|
warn("Using Maps as children is not supported. Use an array of keyed ReactElements instead.");
|
|
}
|
|
didWarnAboutMaps = true;
|
|
}
|
|
}
|
|
var iterator = iteratorFn.call(iterableChildren);
|
|
var step;
|
|
var ii = 0;
|
|
while (!(step = iterator.next()).done) {
|
|
child = step.value;
|
|
nextName = nextNamePrefix + getElementKey(child, ii++);
|
|
subtreeCount += mapIntoArray(child, array, escapedPrefix, nextName, callback);
|
|
}
|
|
} else if (type === "object") {
|
|
var childrenString = "" + children;
|
|
{
|
|
{
|
|
throw Error("Objects are not valid as a React child (found: " + (childrenString === "[object Object]" ? "object with keys {" + Object.keys(children).join(", ") + "}" : childrenString) + "). If you meant to render a collection of children, use an array instead.");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return subtreeCount;
|
|
}
|
|
function mapChildren(children, func, context) {
|
|
if (children == null) {
|
|
return children;
|
|
}
|
|
var result = [];
|
|
var count = 0;
|
|
mapIntoArray(children, result, "", "", function(child) {
|
|
return func.call(context, child, count++);
|
|
});
|
|
return result;
|
|
}
|
|
function countChildren(children) {
|
|
var n2 = 0;
|
|
mapChildren(children, function() {
|
|
n2++;
|
|
});
|
|
return n2;
|
|
}
|
|
function forEachChildren(children, forEachFunc, forEachContext) {
|
|
mapChildren(children, function() {
|
|
forEachFunc.apply(this, arguments);
|
|
}, forEachContext);
|
|
}
|
|
function toArray(children) {
|
|
return mapChildren(children, function(child) {
|
|
return child;
|
|
}) || [];
|
|
}
|
|
function onlyChild(children) {
|
|
if (!isValidElement(children)) {
|
|
{
|
|
throw Error("React.Children.only expected to receive a single React element child.");
|
|
}
|
|
}
|
|
return children;
|
|
}
|
|
function createContext3(defaultValue, calculateChangedBits) {
|
|
if (calculateChangedBits === void 0) {
|
|
calculateChangedBits = null;
|
|
} else {
|
|
{
|
|
if (calculateChangedBits !== null && typeof calculateChangedBits !== "function") {
|
|
error("createContext: Expected the optional second argument to be a function. Instead received: %s", calculateChangedBits);
|
|
}
|
|
}
|
|
}
|
|
var context = {
|
|
$$typeof: REACT_CONTEXT_TYPE,
|
|
_calculateChangedBits: calculateChangedBits,
|
|
_currentValue: defaultValue,
|
|
_currentValue2: defaultValue,
|
|
_threadCount: 0,
|
|
Provider: null,
|
|
Consumer: null
|
|
};
|
|
context.Provider = {
|
|
$$typeof: REACT_PROVIDER_TYPE,
|
|
_context: context
|
|
};
|
|
var hasWarnedAboutUsingNestedContextConsumers = false;
|
|
var hasWarnedAboutUsingConsumerProvider = false;
|
|
var hasWarnedAboutDisplayNameOnConsumer = false;
|
|
{
|
|
var Consumer = {
|
|
$$typeof: REACT_CONTEXT_TYPE,
|
|
_context: context,
|
|
_calculateChangedBits: context._calculateChangedBits
|
|
};
|
|
Object.defineProperties(Consumer, {
|
|
Provider: {
|
|
get: function() {
|
|
if (!hasWarnedAboutUsingConsumerProvider) {
|
|
hasWarnedAboutUsingConsumerProvider = true;
|
|
error("Rendering <Context.Consumer.Provider> is not supported and will be removed in a future major release. Did you mean to render <Context.Provider> instead?");
|
|
}
|
|
return context.Provider;
|
|
},
|
|
set: function(_Provider) {
|
|
context.Provider = _Provider;
|
|
}
|
|
},
|
|
_currentValue: {
|
|
get: function() {
|
|
return context._currentValue;
|
|
},
|
|
set: function(_currentValue) {
|
|
context._currentValue = _currentValue;
|
|
}
|
|
},
|
|
_currentValue2: {
|
|
get: function() {
|
|
return context._currentValue2;
|
|
},
|
|
set: function(_currentValue2) {
|
|
context._currentValue2 = _currentValue2;
|
|
}
|
|
},
|
|
_threadCount: {
|
|
get: function() {
|
|
return context._threadCount;
|
|
},
|
|
set: function(_threadCount) {
|
|
context._threadCount = _threadCount;
|
|
}
|
|
},
|
|
Consumer: {
|
|
get: function() {
|
|
if (!hasWarnedAboutUsingNestedContextConsumers) {
|
|
hasWarnedAboutUsingNestedContextConsumers = true;
|
|
error("Rendering <Context.Consumer.Consumer> is not supported and will be removed in a future major release. Did you mean to render <Context.Consumer> instead?");
|
|
}
|
|
return context.Consumer;
|
|
}
|
|
},
|
|
displayName: {
|
|
get: function() {
|
|
return context.displayName;
|
|
},
|
|
set: function(displayName) {
|
|
if (!hasWarnedAboutDisplayNameOnConsumer) {
|
|
warn("Setting `displayName` on Context.Consumer has no effect. You should set it directly on the context with Context.displayName = '%s'.", displayName);
|
|
hasWarnedAboutDisplayNameOnConsumer = true;
|
|
}
|
|
}
|
|
}
|
|
});
|
|
context.Consumer = Consumer;
|
|
}
|
|
{
|
|
context._currentRenderer = null;
|
|
context._currentRenderer2 = null;
|
|
}
|
|
return context;
|
|
}
|
|
var Uninitialized = -1;
|
|
var Pending = 0;
|
|
var Resolved = 1;
|
|
var Rejected = 2;
|
|
function lazyInitializer(payload) {
|
|
if (payload._status === Uninitialized) {
|
|
var ctor = payload._result;
|
|
var thenable = ctor();
|
|
var pending = payload;
|
|
pending._status = Pending;
|
|
pending._result = thenable;
|
|
thenable.then(function(moduleObject) {
|
|
if (payload._status === Pending) {
|
|
var defaultExport = moduleObject.default;
|
|
{
|
|
if (defaultExport === void 0) {
|
|
error("lazy: Expected the result of a dynamic import() call. Instead received: %s\n\nYour code should look like: \n const MyComponent = lazy(() => import('./MyComponent'))", moduleObject);
|
|
}
|
|
}
|
|
var resolved = payload;
|
|
resolved._status = Resolved;
|
|
resolved._result = defaultExport;
|
|
}
|
|
}, function(error2) {
|
|
if (payload._status === Pending) {
|
|
var rejected = payload;
|
|
rejected._status = Rejected;
|
|
rejected._result = error2;
|
|
}
|
|
});
|
|
}
|
|
if (payload._status === Resolved) {
|
|
return payload._result;
|
|
} else {
|
|
throw payload._result;
|
|
}
|
|
}
|
|
function lazy(ctor) {
|
|
var payload = {
|
|
_status: -1,
|
|
_result: ctor
|
|
};
|
|
var lazyType = {
|
|
$$typeof: REACT_LAZY_TYPE,
|
|
_payload: payload,
|
|
_init: lazyInitializer
|
|
};
|
|
{
|
|
var defaultProps;
|
|
var propTypes;
|
|
Object.defineProperties(lazyType, {
|
|
defaultProps: {
|
|
configurable: true,
|
|
get: function() {
|
|
return defaultProps;
|
|
},
|
|
set: function(newDefaultProps) {
|
|
error("React.lazy(...): It is not supported to assign `defaultProps` to a lazy component import. Either specify them where the component is defined, or create a wrapping component around it.");
|
|
defaultProps = newDefaultProps;
|
|
Object.defineProperty(lazyType, "defaultProps", {
|
|
enumerable: true
|
|
});
|
|
}
|
|
},
|
|
propTypes: {
|
|
configurable: true,
|
|
get: function() {
|
|
return propTypes;
|
|
},
|
|
set: function(newPropTypes) {
|
|
error("React.lazy(...): It is not supported to assign `propTypes` to a lazy component import. Either specify them where the component is defined, or create a wrapping component around it.");
|
|
propTypes = newPropTypes;
|
|
Object.defineProperty(lazyType, "propTypes", {
|
|
enumerable: true
|
|
});
|
|
}
|
|
}
|
|
});
|
|
}
|
|
return lazyType;
|
|
}
|
|
function forwardRef(render4) {
|
|
{
|
|
if (render4 != null && render4.$$typeof === REACT_MEMO_TYPE) {
|
|
error("forwardRef requires a render function but received a `memo` component. Instead of forwardRef(memo(...)), use memo(forwardRef(...)).");
|
|
} else if (typeof render4 !== "function") {
|
|
error("forwardRef requires a render function but was given %s.", render4 === null ? "null" : typeof render4);
|
|
} else {
|
|
if (render4.length !== 0 && render4.length !== 2) {
|
|
error("forwardRef render functions accept exactly two parameters: props and ref. %s", render4.length === 1 ? "Did you forget to use the ref parameter?" : "Any additional parameter will be undefined.");
|
|
}
|
|
}
|
|
if (render4 != null) {
|
|
if (render4.defaultProps != null || render4.propTypes != null) {
|
|
error("forwardRef render functions do not support propTypes or defaultProps. Did you accidentally pass a React component?");
|
|
}
|
|
}
|
|
}
|
|
var elementType = {
|
|
$$typeof: REACT_FORWARD_REF_TYPE,
|
|
render: render4
|
|
};
|
|
{
|
|
var ownName;
|
|
Object.defineProperty(elementType, "displayName", {
|
|
enumerable: false,
|
|
configurable: true,
|
|
get: function() {
|
|
return ownName;
|
|
},
|
|
set: function(name) {
|
|
ownName = name;
|
|
if (render4.displayName == null) {
|
|
render4.displayName = name;
|
|
}
|
|
}
|
|
});
|
|
}
|
|
return elementType;
|
|
}
|
|
var enableScopeAPI = false;
|
|
function isValidElementType(type) {
|
|
if (typeof type === "string" || typeof type === "function") {
|
|
return true;
|
|
}
|
|
if (type === exports.Fragment || type === exports.Profiler || type === REACT_DEBUG_TRACING_MODE_TYPE || type === exports.StrictMode || type === exports.Suspense || type === REACT_SUSPENSE_LIST_TYPE || type === REACT_LEGACY_HIDDEN_TYPE || enableScopeAPI) {
|
|
return true;
|
|
}
|
|
if (typeof type === "object" && type !== null) {
|
|
if (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE || type.$$typeof === REACT_FUNDAMENTAL_TYPE || type.$$typeof === REACT_BLOCK_TYPE || type[0] === REACT_SERVER_BLOCK_TYPE) {
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
function memo(type, compare) {
|
|
{
|
|
if (!isValidElementType(type)) {
|
|
error("memo: The first argument must be a component. Instead received: %s", type === null ? "null" : typeof type);
|
|
}
|
|
}
|
|
var elementType = {
|
|
$$typeof: REACT_MEMO_TYPE,
|
|
type,
|
|
compare: compare === void 0 ? null : compare
|
|
};
|
|
{
|
|
var ownName;
|
|
Object.defineProperty(elementType, "displayName", {
|
|
enumerable: false,
|
|
configurable: true,
|
|
get: function() {
|
|
return ownName;
|
|
},
|
|
set: function(name) {
|
|
ownName = name;
|
|
if (type.displayName == null) {
|
|
type.displayName = name;
|
|
}
|
|
}
|
|
});
|
|
}
|
|
return elementType;
|
|
}
|
|
function resolveDispatcher() {
|
|
var dispatcher = ReactCurrentDispatcher.current;
|
|
if (!(dispatcher !== null)) {
|
|
{
|
|
throw Error("Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:\n1. You might have mismatching versions of React and the renderer (such as React DOM)\n2. You might be breaking the Rules of Hooks\n3. You might have more than one copy of React in the same app\nSee https://reactjs.org/link/invalid-hook-call for tips about how to debug and fix this problem.");
|
|
}
|
|
}
|
|
return dispatcher;
|
|
}
|
|
function useContext(Context, unstable_observedBits) {
|
|
var dispatcher = resolveDispatcher();
|
|
{
|
|
if (unstable_observedBits !== void 0) {
|
|
error("useContext() second argument is reserved for future use in React. Passing it is not supported. You passed: %s.%s", unstable_observedBits, typeof unstable_observedBits === "number" && Array.isArray(arguments[2]) ? "\n\nDid you call array.map(useContext)? Calling Hooks inside a loop is not supported. Learn more at https://reactjs.org/link/rules-of-hooks" : "");
|
|
}
|
|
if (Context._context !== void 0) {
|
|
var realContext = Context._context;
|
|
if (realContext.Consumer === Context) {
|
|
error("Calling useContext(Context.Consumer) is not supported, may cause bugs, and will be removed in a future major release. Did you mean to call useContext(Context) instead?");
|
|
} else if (realContext.Provider === Context) {
|
|
error("Calling useContext(Context.Provider) is not supported. Did you mean to call useContext(Context) instead?");
|
|
}
|
|
}
|
|
}
|
|
return dispatcher.useContext(Context, unstable_observedBits);
|
|
}
|
|
function useState4(initialState) {
|
|
var dispatcher = resolveDispatcher();
|
|
return dispatcher.useState(initialState);
|
|
}
|
|
function useReducer(reducer, initialArg, init) {
|
|
var dispatcher = resolveDispatcher();
|
|
return dispatcher.useReducer(reducer, initialArg, init);
|
|
}
|
|
function useRef2(initialValue) {
|
|
var dispatcher = resolveDispatcher();
|
|
return dispatcher.useRef(initialValue);
|
|
}
|
|
function useEffect2(create, deps) {
|
|
var dispatcher = resolveDispatcher();
|
|
return dispatcher.useEffect(create, deps);
|
|
}
|
|
function useLayoutEffect(create, deps) {
|
|
var dispatcher = resolveDispatcher();
|
|
return dispatcher.useLayoutEffect(create, deps);
|
|
}
|
|
function useCallback(callback, deps) {
|
|
var dispatcher = resolveDispatcher();
|
|
return dispatcher.useCallback(callback, deps);
|
|
}
|
|
function useMemo(create, deps) {
|
|
var dispatcher = resolveDispatcher();
|
|
return dispatcher.useMemo(create, deps);
|
|
}
|
|
function useImperativeHandle(ref, create, deps) {
|
|
var dispatcher = resolveDispatcher();
|
|
return dispatcher.useImperativeHandle(ref, create, deps);
|
|
}
|
|
function useDebugValue(value, formatterFn) {
|
|
{
|
|
var dispatcher = resolveDispatcher();
|
|
return dispatcher.useDebugValue(value, formatterFn);
|
|
}
|
|
}
|
|
var disabledDepth = 0;
|
|
var prevLog;
|
|
var prevInfo;
|
|
var prevWarn;
|
|
var prevError;
|
|
var prevGroup;
|
|
var prevGroupCollapsed;
|
|
var prevGroupEnd;
|
|
function disabledLog() {
|
|
}
|
|
disabledLog.__reactDisabledLog = true;
|
|
function disableLogs() {
|
|
{
|
|
if (disabledDepth === 0) {
|
|
prevLog = console.log;
|
|
prevInfo = console.info;
|
|
prevWarn = console.warn;
|
|
prevError = console.error;
|
|
prevGroup = console.group;
|
|
prevGroupCollapsed = console.groupCollapsed;
|
|
prevGroupEnd = console.groupEnd;
|
|
var props = {
|
|
configurable: true,
|
|
enumerable: true,
|
|
value: disabledLog,
|
|
writable: true
|
|
};
|
|
Object.defineProperties(console, {
|
|
info: props,
|
|
log: props,
|
|
warn: props,
|
|
error: props,
|
|
group: props,
|
|
groupCollapsed: props,
|
|
groupEnd: props
|
|
});
|
|
}
|
|
disabledDepth++;
|
|
}
|
|
}
|
|
function reenableLogs() {
|
|
{
|
|
disabledDepth--;
|
|
if (disabledDepth === 0) {
|
|
var props = {
|
|
configurable: true,
|
|
enumerable: true,
|
|
writable: true
|
|
};
|
|
Object.defineProperties(console, {
|
|
log: _assign({}, props, {
|
|
value: prevLog
|
|
}),
|
|
info: _assign({}, props, {
|
|
value: prevInfo
|
|
}),
|
|
warn: _assign({}, props, {
|
|
value: prevWarn
|
|
}),
|
|
error: _assign({}, props, {
|
|
value: prevError
|
|
}),
|
|
group: _assign({}, props, {
|
|
value: prevGroup
|
|
}),
|
|
groupCollapsed: _assign({}, props, {
|
|
value: prevGroupCollapsed
|
|
}),
|
|
groupEnd: _assign({}, props, {
|
|
value: prevGroupEnd
|
|
})
|
|
});
|
|
}
|
|
if (disabledDepth < 0) {
|
|
error("disabledDepth fell below zero. This is a bug in React. Please file an issue.");
|
|
}
|
|
}
|
|
}
|
|
var ReactCurrentDispatcher$1 = ReactSharedInternals.ReactCurrentDispatcher;
|
|
var prefix;
|
|
function describeBuiltInComponentFrame(name, source, ownerFn) {
|
|
{
|
|
if (prefix === void 0) {
|
|
try {
|
|
throw Error();
|
|
} catch (x3) {
|
|
var match = x3.stack.trim().match(/\n( *(at )?)/);
|
|
prefix = match && match[1] || "";
|
|
}
|
|
}
|
|
return "\n" + prefix + name;
|
|
}
|
|
}
|
|
var reentry = false;
|
|
var componentFrameCache;
|
|
{
|
|
var PossiblyWeakMap = typeof WeakMap === "function" ? WeakMap : Map;
|
|
componentFrameCache = new PossiblyWeakMap();
|
|
}
|
|
function describeNativeComponentFrame(fn, construct) {
|
|
if (!fn || reentry) {
|
|
return "";
|
|
}
|
|
{
|
|
var frame = componentFrameCache.get(fn);
|
|
if (frame !== void 0) {
|
|
return frame;
|
|
}
|
|
}
|
|
var control;
|
|
reentry = true;
|
|
var previousPrepareStackTrace = Error.prepareStackTrace;
|
|
Error.prepareStackTrace = void 0;
|
|
var previousDispatcher;
|
|
{
|
|
previousDispatcher = ReactCurrentDispatcher$1.current;
|
|
ReactCurrentDispatcher$1.current = null;
|
|
disableLogs();
|
|
}
|
|
try {
|
|
if (construct) {
|
|
var Fake = function() {
|
|
throw Error();
|
|
};
|
|
Object.defineProperty(Fake.prototype, "props", {
|
|
set: function() {
|
|
throw Error();
|
|
}
|
|
});
|
|
if (typeof Reflect === "object" && Reflect.construct) {
|
|
try {
|
|
Reflect.construct(Fake, []);
|
|
} catch (x3) {
|
|
control = x3;
|
|
}
|
|
Reflect.construct(fn, [], Fake);
|
|
} else {
|
|
try {
|
|
Fake.call();
|
|
} catch (x3) {
|
|
control = x3;
|
|
}
|
|
fn.call(Fake.prototype);
|
|
}
|
|
} else {
|
|
try {
|
|
throw Error();
|
|
} catch (x3) {
|
|
control = x3;
|
|
}
|
|
fn();
|
|
}
|
|
} catch (sample) {
|
|
if (sample && control && typeof sample.stack === "string") {
|
|
var sampleLines = sample.stack.split("\n");
|
|
var controlLines = control.stack.split("\n");
|
|
var s3 = sampleLines.length - 1;
|
|
var c3 = controlLines.length - 1;
|
|
while (s3 >= 1 && c3 >= 0 && sampleLines[s3] !== controlLines[c3]) {
|
|
c3--;
|
|
}
|
|
for (; s3 >= 1 && c3 >= 0; s3--, c3--) {
|
|
if (sampleLines[s3] !== controlLines[c3]) {
|
|
if (s3 !== 1 || c3 !== 1) {
|
|
do {
|
|
s3--;
|
|
c3--;
|
|
if (c3 < 0 || sampleLines[s3] !== controlLines[c3]) {
|
|
var _frame = "\n" + sampleLines[s3].replace(" at new ", " at ");
|
|
{
|
|
if (typeof fn === "function") {
|
|
componentFrameCache.set(fn, _frame);
|
|
}
|
|
}
|
|
return _frame;
|
|
}
|
|
} while (s3 >= 1 && c3 >= 0);
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
} finally {
|
|
reentry = false;
|
|
{
|
|
ReactCurrentDispatcher$1.current = previousDispatcher;
|
|
reenableLogs();
|
|
}
|
|
Error.prepareStackTrace = previousPrepareStackTrace;
|
|
}
|
|
var name = fn ? fn.displayName || fn.name : "";
|
|
var syntheticFrame = name ? describeBuiltInComponentFrame(name) : "";
|
|
{
|
|
if (typeof fn === "function") {
|
|
componentFrameCache.set(fn, syntheticFrame);
|
|
}
|
|
}
|
|
return syntheticFrame;
|
|
}
|
|
function describeFunctionComponentFrame(fn, source, ownerFn) {
|
|
{
|
|
return describeNativeComponentFrame(fn, false);
|
|
}
|
|
}
|
|
function shouldConstruct(Component6) {
|
|
var prototype = Component6.prototype;
|
|
return !!(prototype && prototype.isReactComponent);
|
|
}
|
|
function describeUnknownElementTypeFrameInDEV(type, source, ownerFn) {
|
|
if (type == null) {
|
|
return "";
|
|
}
|
|
if (typeof type === "function") {
|
|
{
|
|
return describeNativeComponentFrame(type, shouldConstruct(type));
|
|
}
|
|
}
|
|
if (typeof type === "string") {
|
|
return describeBuiltInComponentFrame(type);
|
|
}
|
|
switch (type) {
|
|
case exports.Suspense:
|
|
return describeBuiltInComponentFrame("Suspense");
|
|
case REACT_SUSPENSE_LIST_TYPE:
|
|
return describeBuiltInComponentFrame("SuspenseList");
|
|
}
|
|
if (typeof type === "object") {
|
|
switch (type.$$typeof) {
|
|
case REACT_FORWARD_REF_TYPE:
|
|
return describeFunctionComponentFrame(type.render);
|
|
case REACT_MEMO_TYPE:
|
|
return describeUnknownElementTypeFrameInDEV(type.type, source, ownerFn);
|
|
case REACT_BLOCK_TYPE:
|
|
return describeFunctionComponentFrame(type._render);
|
|
case REACT_LAZY_TYPE: {
|
|
var lazyComponent = type;
|
|
var payload = lazyComponent._payload;
|
|
var init = lazyComponent._init;
|
|
try {
|
|
return describeUnknownElementTypeFrameInDEV(init(payload), source, ownerFn);
|
|
} catch (x3) {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return "";
|
|
}
|
|
var loggedTypeFailures = {};
|
|
var ReactDebugCurrentFrame$1 = ReactSharedInternals.ReactDebugCurrentFrame;
|
|
function setCurrentlyValidatingElement(element) {
|
|
{
|
|
if (element) {
|
|
var owner = element._owner;
|
|
var stack = describeUnknownElementTypeFrameInDEV(element.type, element._source, owner ? owner.type : null);
|
|
ReactDebugCurrentFrame$1.setExtraStackFrame(stack);
|
|
} else {
|
|
ReactDebugCurrentFrame$1.setExtraStackFrame(null);
|
|
}
|
|
}
|
|
}
|
|
function checkPropTypes(typeSpecs, values, location, componentName, element) {
|
|
{
|
|
var has = Function.call.bind(Object.prototype.hasOwnProperty);
|
|
for (var typeSpecName in typeSpecs) {
|
|
if (has(typeSpecs, typeSpecName)) {
|
|
var error$1 = void 0;
|
|
try {
|
|
if (typeof typeSpecs[typeSpecName] !== "function") {
|
|
var err = Error((componentName || "React class") + ": " + location + " type `" + typeSpecName + "` is invalid; it must be a function, usually from the `prop-types` package, but received `" + typeof typeSpecs[typeSpecName] + "`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");
|
|
err.name = "Invariant Violation";
|
|
throw err;
|
|
}
|
|
error$1 = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED");
|
|
} catch (ex) {
|
|
error$1 = ex;
|
|
}
|
|
if (error$1 && !(error$1 instanceof Error)) {
|
|
setCurrentlyValidatingElement(element);
|
|
error("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).", componentName || "React class", location, typeSpecName, typeof error$1);
|
|
setCurrentlyValidatingElement(null);
|
|
}
|
|
if (error$1 instanceof Error && !(error$1.message in loggedTypeFailures)) {
|
|
loggedTypeFailures[error$1.message] = true;
|
|
setCurrentlyValidatingElement(element);
|
|
error("Failed %s type: %s", location, error$1.message);
|
|
setCurrentlyValidatingElement(null);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
function setCurrentlyValidatingElement$1(element) {
|
|
{
|
|
if (element) {
|
|
var owner = element._owner;
|
|
var stack = describeUnknownElementTypeFrameInDEV(element.type, element._source, owner ? owner.type : null);
|
|
setExtraStackFrame(stack);
|
|
} else {
|
|
setExtraStackFrame(null);
|
|
}
|
|
}
|
|
}
|
|
var propTypesMisspellWarningShown;
|
|
{
|
|
propTypesMisspellWarningShown = false;
|
|
}
|
|
function getDeclarationErrorAddendum() {
|
|
if (ReactCurrentOwner.current) {
|
|
var name = getComponentName(ReactCurrentOwner.current.type);
|
|
if (name) {
|
|
return "\n\nCheck the render method of `" + name + "`.";
|
|
}
|
|
}
|
|
return "";
|
|
}
|
|
function getSourceInfoErrorAddendum(source) {
|
|
if (source !== void 0) {
|
|
var fileName = source.fileName.replace(/^.*[\\\/]/, "");
|
|
var lineNumber = source.lineNumber;
|
|
return "\n\nCheck your code at " + fileName + ":" + lineNumber + ".";
|
|
}
|
|
return "";
|
|
}
|
|
function getSourceInfoErrorAddendumForProps(elementProps) {
|
|
if (elementProps !== null && elementProps !== void 0) {
|
|
return getSourceInfoErrorAddendum(elementProps.__source);
|
|
}
|
|
return "";
|
|
}
|
|
var ownerHasKeyUseWarning = {};
|
|
function getCurrentComponentErrorInfo(parentType) {
|
|
var info = getDeclarationErrorAddendum();
|
|
if (!info) {
|
|
var parentName = typeof parentType === "string" ? parentType : parentType.displayName || parentType.name;
|
|
if (parentName) {
|
|
info = "\n\nCheck the top-level render call using <" + parentName + ">.";
|
|
}
|
|
}
|
|
return info;
|
|
}
|
|
function validateExplicitKey(element, parentType) {
|
|
if (!element._store || element._store.validated || element.key != null) {
|
|
return;
|
|
}
|
|
element._store.validated = true;
|
|
var currentComponentErrorInfo = getCurrentComponentErrorInfo(parentType);
|
|
if (ownerHasKeyUseWarning[currentComponentErrorInfo]) {
|
|
return;
|
|
}
|
|
ownerHasKeyUseWarning[currentComponentErrorInfo] = true;
|
|
var childOwner = "";
|
|
if (element && element._owner && element._owner !== ReactCurrentOwner.current) {
|
|
childOwner = " It was passed a child from " + getComponentName(element._owner.type) + ".";
|
|
}
|
|
{
|
|
setCurrentlyValidatingElement$1(element);
|
|
error('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.', currentComponentErrorInfo, childOwner);
|
|
setCurrentlyValidatingElement$1(null);
|
|
}
|
|
}
|
|
function validateChildKeys(node, parentType) {
|
|
if (typeof node !== "object") {
|
|
return;
|
|
}
|
|
if (Array.isArray(node)) {
|
|
for (var i3 = 0; i3 < node.length; i3++) {
|
|
var child = node[i3];
|
|
if (isValidElement(child)) {
|
|
validateExplicitKey(child, parentType);
|
|
}
|
|
}
|
|
} else if (isValidElement(node)) {
|
|
if (node._store) {
|
|
node._store.validated = true;
|
|
}
|
|
} else if (node) {
|
|
var iteratorFn = getIteratorFn(node);
|
|
if (typeof iteratorFn === "function") {
|
|
if (iteratorFn !== node.entries) {
|
|
var iterator = iteratorFn.call(node);
|
|
var step;
|
|
while (!(step = iterator.next()).done) {
|
|
if (isValidElement(step.value)) {
|
|
validateExplicitKey(step.value, parentType);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
function validatePropTypes(element) {
|
|
{
|
|
var type = element.type;
|
|
if (type === null || type === void 0 || typeof type === "string") {
|
|
return;
|
|
}
|
|
var propTypes;
|
|
if (typeof type === "function") {
|
|
propTypes = type.propTypes;
|
|
} else if (typeof type === "object" && (type.$$typeof === REACT_FORWARD_REF_TYPE || type.$$typeof === REACT_MEMO_TYPE)) {
|
|
propTypes = type.propTypes;
|
|
} else {
|
|
return;
|
|
}
|
|
if (propTypes) {
|
|
var name = getComponentName(type);
|
|
checkPropTypes(propTypes, element.props, "prop", name, element);
|
|
} else if (type.PropTypes !== void 0 && !propTypesMisspellWarningShown) {
|
|
propTypesMisspellWarningShown = true;
|
|
var _name = getComponentName(type);
|
|
error("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?", _name || "Unknown");
|
|
}
|
|
if (typeof type.getDefaultProps === "function" && !type.getDefaultProps.isReactClassApproved) {
|
|
error("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.");
|
|
}
|
|
}
|
|
}
|
|
function validateFragmentProps(fragment) {
|
|
{
|
|
var keys = Object.keys(fragment.props);
|
|
for (var i3 = 0; i3 < keys.length; i3++) {
|
|
var key = keys[i3];
|
|
if (key !== "children" && key !== "key") {
|
|
setCurrentlyValidatingElement$1(fragment);
|
|
error("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.", key);
|
|
setCurrentlyValidatingElement$1(null);
|
|
break;
|
|
}
|
|
}
|
|
if (fragment.ref !== null) {
|
|
setCurrentlyValidatingElement$1(fragment);
|
|
error("Invalid attribute `ref` supplied to `React.Fragment`.");
|
|
setCurrentlyValidatingElement$1(null);
|
|
}
|
|
}
|
|
}
|
|
function createElementWithValidation(type, props, children) {
|
|
var validType = isValidElementType(type);
|
|
if (!validType) {
|
|
var info = "";
|
|
if (type === void 0 || typeof type === "object" && type !== null && Object.keys(type).length === 0) {
|
|
info += " You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.";
|
|
}
|
|
var sourceInfo = getSourceInfoErrorAddendumForProps(props);
|
|
if (sourceInfo) {
|
|
info += sourceInfo;
|
|
} else {
|
|
info += getDeclarationErrorAddendum();
|
|
}
|
|
var typeString;
|
|
if (type === null) {
|
|
typeString = "null";
|
|
} else if (Array.isArray(type)) {
|
|
typeString = "array";
|
|
} else if (type !== void 0 && type.$$typeof === REACT_ELEMENT_TYPE) {
|
|
typeString = "<" + (getComponentName(type.type) || "Unknown") + " />";
|
|
info = " Did you accidentally export a JSX literal instead of a component?";
|
|
} else {
|
|
typeString = typeof type;
|
|
}
|
|
{
|
|
error("React.createElement: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s", typeString, info);
|
|
}
|
|
}
|
|
var element = createElement7.apply(this, arguments);
|
|
if (element == null) {
|
|
return element;
|
|
}
|
|
if (validType) {
|
|
for (var i3 = 2; i3 < arguments.length; i3++) {
|
|
validateChildKeys(arguments[i3], type);
|
|
}
|
|
}
|
|
if (type === exports.Fragment) {
|
|
validateFragmentProps(element);
|
|
} else {
|
|
validatePropTypes(element);
|
|
}
|
|
return element;
|
|
}
|
|
var didWarnAboutDeprecatedCreateFactory = false;
|
|
function createFactoryWithValidation(type) {
|
|
var validatedFactory = createElementWithValidation.bind(null, type);
|
|
validatedFactory.type = type;
|
|
{
|
|
if (!didWarnAboutDeprecatedCreateFactory) {
|
|
didWarnAboutDeprecatedCreateFactory = true;
|
|
warn("React.createFactory() is deprecated and will be removed in a future major release. Consider using JSX or use React.createElement() directly instead.");
|
|
}
|
|
Object.defineProperty(validatedFactory, "type", {
|
|
enumerable: false,
|
|
get: function() {
|
|
warn("Factory.type is deprecated. Access the class directly before passing it to createFactory.");
|
|
Object.defineProperty(this, "type", {
|
|
value: type
|
|
});
|
|
return type;
|
|
}
|
|
});
|
|
}
|
|
return validatedFactory;
|
|
}
|
|
function cloneElementWithValidation(element, props, children) {
|
|
var newElement = cloneElement.apply(this, arguments);
|
|
for (var i3 = 2; i3 < arguments.length; i3++) {
|
|
validateChildKeys(arguments[i3], newElement.type);
|
|
}
|
|
validatePropTypes(newElement);
|
|
return newElement;
|
|
}
|
|
{
|
|
try {
|
|
var frozenObject = Object.freeze({});
|
|
new Map([[frozenObject, null]]);
|
|
new Set([frozenObject]);
|
|
} catch (e3) {
|
|
}
|
|
}
|
|
var createElement$1 = createElementWithValidation;
|
|
var cloneElement$1 = cloneElementWithValidation;
|
|
var createFactory = createFactoryWithValidation;
|
|
var Children = {
|
|
map: mapChildren,
|
|
forEach: forEachChildren,
|
|
count: countChildren,
|
|
toArray,
|
|
only: onlyChild
|
|
};
|
|
exports.Children = Children;
|
|
exports.Component = Component5;
|
|
exports.PureComponent = PureComponent2;
|
|
exports.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = ReactSharedInternals;
|
|
exports.cloneElement = cloneElement$1;
|
|
exports.createContext = createContext3;
|
|
exports.createElement = createElement$1;
|
|
exports.createFactory = createFactory;
|
|
exports.createRef = createRef2;
|
|
exports.forwardRef = forwardRef;
|
|
exports.isValidElement = isValidElement;
|
|
exports.lazy = lazy;
|
|
exports.memo = memo;
|
|
exports.useCallback = useCallback;
|
|
exports.useContext = useContext;
|
|
exports.useDebugValue = useDebugValue;
|
|
exports.useEffect = useEffect2;
|
|
exports.useImperativeHandle = useImperativeHandle;
|
|
exports.useLayoutEffect = useLayoutEffect;
|
|
exports.useMemo = useMemo;
|
|
exports.useReducer = useReducer;
|
|
exports.useRef = useRef2;
|
|
exports.useState = useState4;
|
|
exports.version = ReactVersion;
|
|
})();
|
|
}
|
|
}
|
|
});
|
|
|
|
// node_modules/react/index.js
|
|
var require_react = __commonJS({
|
|
"node_modules/react/index.js"(exports, module2) {
|
|
"use strict";
|
|
if (false) {
|
|
module2.exports = null;
|
|
} else {
|
|
module2.exports = require_react_development();
|
|
}
|
|
}
|
|
});
|
|
|
|
// node_modules/scheduler/cjs/scheduler.development.js
|
|
var require_scheduler_development = __commonJS({
|
|
"node_modules/scheduler/cjs/scheduler.development.js"(exports) {
|
|
"use strict";
|
|
if (true) {
|
|
(function() {
|
|
"use strict";
|
|
var enableSchedulerDebugging = false;
|
|
var enableProfiling = false;
|
|
var requestHostCallback;
|
|
var requestHostTimeout;
|
|
var cancelHostTimeout;
|
|
var requestPaint;
|
|
var hasPerformanceNow = typeof performance === "object" && typeof performance.now === "function";
|
|
if (hasPerformanceNow) {
|
|
var localPerformance = performance;
|
|
exports.unstable_now = function() {
|
|
return localPerformance.now();
|
|
};
|
|
} else {
|
|
var localDate = Date;
|
|
var initialTime = localDate.now();
|
|
exports.unstable_now = function() {
|
|
return localDate.now() - initialTime;
|
|
};
|
|
}
|
|
if (typeof window === "undefined" || typeof MessageChannel !== "function") {
|
|
var _callback = null;
|
|
var _timeoutID = null;
|
|
var _flushCallback = function() {
|
|
if (_callback !== null) {
|
|
try {
|
|
var currentTime = exports.unstable_now();
|
|
var hasRemainingTime = true;
|
|
_callback(hasRemainingTime, currentTime);
|
|
_callback = null;
|
|
} catch (e3) {
|
|
setTimeout(_flushCallback, 0);
|
|
throw e3;
|
|
}
|
|
}
|
|
};
|
|
requestHostCallback = function(cb) {
|
|
if (_callback !== null) {
|
|
setTimeout(requestHostCallback, 0, cb);
|
|
} else {
|
|
_callback = cb;
|
|
setTimeout(_flushCallback, 0);
|
|
}
|
|
};
|
|
requestHostTimeout = function(cb, ms) {
|
|
_timeoutID = setTimeout(cb, ms);
|
|
};
|
|
cancelHostTimeout = function() {
|
|
clearTimeout(_timeoutID);
|
|
};
|
|
exports.unstable_shouldYield = function() {
|
|
return false;
|
|
};
|
|
requestPaint = exports.unstable_forceFrameRate = function() {
|
|
};
|
|
} else {
|
|
var _setTimeout = window.setTimeout;
|
|
var _clearTimeout = window.clearTimeout;
|
|
if (typeof console !== "undefined") {
|
|
var requestAnimationFrame2 = window.requestAnimationFrame;
|
|
var cancelAnimationFrame2 = window.cancelAnimationFrame;
|
|
if (typeof requestAnimationFrame2 !== "function") {
|
|
console["error"]("This browser doesn't support requestAnimationFrame. Make sure that you load a polyfill in older browsers. https://reactjs.org/link/react-polyfills");
|
|
}
|
|
if (typeof cancelAnimationFrame2 !== "function") {
|
|
console["error"]("This browser doesn't support cancelAnimationFrame. Make sure that you load a polyfill in older browsers. https://reactjs.org/link/react-polyfills");
|
|
}
|
|
}
|
|
var isMessageLoopRunning = false;
|
|
var scheduledHostCallback = null;
|
|
var taskTimeoutID = -1;
|
|
var yieldInterval = 5;
|
|
var deadline = 0;
|
|
{
|
|
exports.unstable_shouldYield = function() {
|
|
return exports.unstable_now() >= deadline;
|
|
};
|
|
requestPaint = function() {
|
|
};
|
|
}
|
|
exports.unstable_forceFrameRate = function(fps) {
|
|
if (fps < 0 || fps > 125) {
|
|
console["error"]("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported");
|
|
return;
|
|
}
|
|
if (fps > 0) {
|
|
yieldInterval = Math.floor(1e3 / fps);
|
|
} else {
|
|
yieldInterval = 5;
|
|
}
|
|
};
|
|
var performWorkUntilDeadline = function() {
|
|
if (scheduledHostCallback !== null) {
|
|
var currentTime = exports.unstable_now();
|
|
deadline = currentTime + yieldInterval;
|
|
var hasTimeRemaining = true;
|
|
try {
|
|
var hasMoreWork = scheduledHostCallback(hasTimeRemaining, currentTime);
|
|
if (!hasMoreWork) {
|
|
isMessageLoopRunning = false;
|
|
scheduledHostCallback = null;
|
|
} else {
|
|
port.postMessage(null);
|
|
}
|
|
} catch (error) {
|
|
port.postMessage(null);
|
|
throw error;
|
|
}
|
|
} else {
|
|
isMessageLoopRunning = false;
|
|
}
|
|
};
|
|
var channel = new MessageChannel();
|
|
var port = channel.port2;
|
|
channel.port1.onmessage = performWorkUntilDeadline;
|
|
requestHostCallback = function(callback) {
|
|
scheduledHostCallback = callback;
|
|
if (!isMessageLoopRunning) {
|
|
isMessageLoopRunning = true;
|
|
port.postMessage(null);
|
|
}
|
|
};
|
|
requestHostTimeout = function(callback, ms) {
|
|
taskTimeoutID = _setTimeout(function() {
|
|
callback(exports.unstable_now());
|
|
}, ms);
|
|
};
|
|
cancelHostTimeout = function() {
|
|
_clearTimeout(taskTimeoutID);
|
|
taskTimeoutID = -1;
|
|
};
|
|
}
|
|
function push(heap, node) {
|
|
var index = heap.length;
|
|
heap.push(node);
|
|
siftUp(heap, node, index);
|
|
}
|
|
function peek(heap) {
|
|
var first = heap[0];
|
|
return first === void 0 ? null : first;
|
|
}
|
|
function pop(heap) {
|
|
var first = heap[0];
|
|
if (first !== void 0) {
|
|
var last = heap.pop();
|
|
if (last !== first) {
|
|
heap[0] = last;
|
|
siftDown(heap, last, 0);
|
|
}
|
|
return first;
|
|
} else {
|
|
return null;
|
|
}
|
|
}
|
|
function siftUp(heap, node, i3) {
|
|
var index = i3;
|
|
while (true) {
|
|
var parentIndex = index - 1 >>> 1;
|
|
var parent = heap[parentIndex];
|
|
if (parent !== void 0 && compare(parent, node) > 0) {
|
|
heap[parentIndex] = node;
|
|
heap[index] = parent;
|
|
index = parentIndex;
|
|
} else {
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
function siftDown(heap, node, i3) {
|
|
var index = i3;
|
|
var length = heap.length;
|
|
while (index < length) {
|
|
var leftIndex = (index + 1) * 2 - 1;
|
|
var left = heap[leftIndex];
|
|
var rightIndex = leftIndex + 1;
|
|
var right = heap[rightIndex];
|
|
if (left !== void 0 && compare(left, node) < 0) {
|
|
if (right !== void 0 && compare(right, left) < 0) {
|
|
heap[index] = right;
|
|
heap[rightIndex] = node;
|
|
index = rightIndex;
|
|
} else {
|
|
heap[index] = left;
|
|
heap[leftIndex] = node;
|
|
index = leftIndex;
|
|
}
|
|
} else if (right !== void 0 && compare(right, node) < 0) {
|
|
heap[index] = right;
|
|
heap[rightIndex] = node;
|
|
index = rightIndex;
|
|
} else {
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
function compare(a3, b3) {
|
|
var diff = a3.sortIndex - b3.sortIndex;
|
|
return diff !== 0 ? diff : a3.id - b3.id;
|
|
}
|
|
var ImmediatePriority = 1;
|
|
var UserBlockingPriority = 2;
|
|
var NormalPriority = 3;
|
|
var LowPriority = 4;
|
|
var IdlePriority = 5;
|
|
function markTaskErrored(task, ms) {
|
|
}
|
|
var maxSigned31BitInt = 1073741823;
|
|
var IMMEDIATE_PRIORITY_TIMEOUT = -1;
|
|
var USER_BLOCKING_PRIORITY_TIMEOUT = 250;
|
|
var NORMAL_PRIORITY_TIMEOUT = 5e3;
|
|
var LOW_PRIORITY_TIMEOUT = 1e4;
|
|
var IDLE_PRIORITY_TIMEOUT = maxSigned31BitInt;
|
|
var taskQueue = [];
|
|
var timerQueue = [];
|
|
var taskIdCounter = 1;
|
|
var currentTask = null;
|
|
var currentPriorityLevel = NormalPriority;
|
|
var isPerformingWork = false;
|
|
var isHostCallbackScheduled = false;
|
|
var isHostTimeoutScheduled = false;
|
|
function advanceTimers(currentTime) {
|
|
var timer = peek(timerQueue);
|
|
while (timer !== null) {
|
|
if (timer.callback === null) {
|
|
pop(timerQueue);
|
|
} else if (timer.startTime <= currentTime) {
|
|
pop(timerQueue);
|
|
timer.sortIndex = timer.expirationTime;
|
|
push(taskQueue, timer);
|
|
} else {
|
|
return;
|
|
}
|
|
timer = peek(timerQueue);
|
|
}
|
|
}
|
|
function handleTimeout(currentTime) {
|
|
isHostTimeoutScheduled = false;
|
|
advanceTimers(currentTime);
|
|
if (!isHostCallbackScheduled) {
|
|
if (peek(taskQueue) !== null) {
|
|
isHostCallbackScheduled = true;
|
|
requestHostCallback(flushWork);
|
|
} else {
|
|
var firstTimer = peek(timerQueue);
|
|
if (firstTimer !== null) {
|
|
requestHostTimeout(handleTimeout, firstTimer.startTime - currentTime);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
function flushWork(hasTimeRemaining, initialTime2) {
|
|
isHostCallbackScheduled = false;
|
|
if (isHostTimeoutScheduled) {
|
|
isHostTimeoutScheduled = false;
|
|
cancelHostTimeout();
|
|
}
|
|
isPerformingWork = true;
|
|
var previousPriorityLevel = currentPriorityLevel;
|
|
try {
|
|
if (enableProfiling) {
|
|
try {
|
|
return workLoop(hasTimeRemaining, initialTime2);
|
|
} catch (error) {
|
|
if (currentTask !== null) {
|
|
var currentTime = exports.unstable_now();
|
|
markTaskErrored(currentTask, currentTime);
|
|
currentTask.isQueued = false;
|
|
}
|
|
throw error;
|
|
}
|
|
} else {
|
|
return workLoop(hasTimeRemaining, initialTime2);
|
|
}
|
|
} finally {
|
|
currentTask = null;
|
|
currentPriorityLevel = previousPriorityLevel;
|
|
isPerformingWork = false;
|
|
}
|
|
}
|
|
function workLoop(hasTimeRemaining, initialTime2) {
|
|
var currentTime = initialTime2;
|
|
advanceTimers(currentTime);
|
|
currentTask = peek(taskQueue);
|
|
while (currentTask !== null && !enableSchedulerDebugging) {
|
|
if (currentTask.expirationTime > currentTime && (!hasTimeRemaining || exports.unstable_shouldYield())) {
|
|
break;
|
|
}
|
|
var callback = currentTask.callback;
|
|
if (typeof callback === "function") {
|
|
currentTask.callback = null;
|
|
currentPriorityLevel = currentTask.priorityLevel;
|
|
var didUserCallbackTimeout = currentTask.expirationTime <= currentTime;
|
|
var continuationCallback = callback(didUserCallbackTimeout);
|
|
currentTime = exports.unstable_now();
|
|
if (typeof continuationCallback === "function") {
|
|
currentTask.callback = continuationCallback;
|
|
} else {
|
|
if (currentTask === peek(taskQueue)) {
|
|
pop(taskQueue);
|
|
}
|
|
}
|
|
advanceTimers(currentTime);
|
|
} else {
|
|
pop(taskQueue);
|
|
}
|
|
currentTask = peek(taskQueue);
|
|
}
|
|
if (currentTask !== null) {
|
|
return true;
|
|
} else {
|
|
var firstTimer = peek(timerQueue);
|
|
if (firstTimer !== null) {
|
|
requestHostTimeout(handleTimeout, firstTimer.startTime - currentTime);
|
|
}
|
|
return false;
|
|
}
|
|
}
|
|
function unstable_runWithPriority(priorityLevel, eventHandler) {
|
|
switch (priorityLevel) {
|
|
case ImmediatePriority:
|
|
case UserBlockingPriority:
|
|
case NormalPriority:
|
|
case LowPriority:
|
|
case IdlePriority:
|
|
break;
|
|
default:
|
|
priorityLevel = NormalPriority;
|
|
}
|
|
var previousPriorityLevel = currentPriorityLevel;
|
|
currentPriorityLevel = priorityLevel;
|
|
try {
|
|
return eventHandler();
|
|
} finally {
|
|
currentPriorityLevel = previousPriorityLevel;
|
|
}
|
|
}
|
|
function unstable_next(eventHandler) {
|
|
var priorityLevel;
|
|
switch (currentPriorityLevel) {
|
|
case ImmediatePriority:
|
|
case UserBlockingPriority:
|
|
case NormalPriority:
|
|
priorityLevel = NormalPriority;
|
|
break;
|
|
default:
|
|
priorityLevel = currentPriorityLevel;
|
|
break;
|
|
}
|
|
var previousPriorityLevel = currentPriorityLevel;
|
|
currentPriorityLevel = priorityLevel;
|
|
try {
|
|
return eventHandler();
|
|
} finally {
|
|
currentPriorityLevel = previousPriorityLevel;
|
|
}
|
|
}
|
|
function unstable_wrapCallback(callback) {
|
|
var parentPriorityLevel = currentPriorityLevel;
|
|
return function() {
|
|
var previousPriorityLevel = currentPriorityLevel;
|
|
currentPriorityLevel = parentPriorityLevel;
|
|
try {
|
|
return callback.apply(this, arguments);
|
|
} finally {
|
|
currentPriorityLevel = previousPriorityLevel;
|
|
}
|
|
};
|
|
}
|
|
function unstable_scheduleCallback(priorityLevel, callback, options) {
|
|
var currentTime = exports.unstable_now();
|
|
var startTime;
|
|
if (typeof options === "object" && options !== null) {
|
|
var delay = options.delay;
|
|
if (typeof delay === "number" && delay > 0) {
|
|
startTime = currentTime + delay;
|
|
} else {
|
|
startTime = currentTime;
|
|
}
|
|
} else {
|
|
startTime = currentTime;
|
|
}
|
|
var timeout;
|
|
switch (priorityLevel) {
|
|
case ImmediatePriority:
|
|
timeout = IMMEDIATE_PRIORITY_TIMEOUT;
|
|
break;
|
|
case UserBlockingPriority:
|
|
timeout = USER_BLOCKING_PRIORITY_TIMEOUT;
|
|
break;
|
|
case IdlePriority:
|
|
timeout = IDLE_PRIORITY_TIMEOUT;
|
|
break;
|
|
case LowPriority:
|
|
timeout = LOW_PRIORITY_TIMEOUT;
|
|
break;
|
|
case NormalPriority:
|
|
default:
|
|
timeout = NORMAL_PRIORITY_TIMEOUT;
|
|
break;
|
|
}
|
|
var expirationTime = startTime + timeout;
|
|
var newTask = {
|
|
id: taskIdCounter++,
|
|
callback,
|
|
priorityLevel,
|
|
startTime,
|
|
expirationTime,
|
|
sortIndex: -1
|
|
};
|
|
if (startTime > currentTime) {
|
|
newTask.sortIndex = startTime;
|
|
push(timerQueue, newTask);
|
|
if (peek(taskQueue) === null && newTask === peek(timerQueue)) {
|
|
if (isHostTimeoutScheduled) {
|
|
cancelHostTimeout();
|
|
} else {
|
|
isHostTimeoutScheduled = true;
|
|
}
|
|
requestHostTimeout(handleTimeout, startTime - currentTime);
|
|
}
|
|
} else {
|
|
newTask.sortIndex = expirationTime;
|
|
push(taskQueue, newTask);
|
|
if (!isHostCallbackScheduled && !isPerformingWork) {
|
|
isHostCallbackScheduled = true;
|
|
requestHostCallback(flushWork);
|
|
}
|
|
}
|
|
return newTask;
|
|
}
|
|
function unstable_pauseExecution() {
|
|
}
|
|
function unstable_continueExecution() {
|
|
if (!isHostCallbackScheduled && !isPerformingWork) {
|
|
isHostCallbackScheduled = true;
|
|
requestHostCallback(flushWork);
|
|
}
|
|
}
|
|
function unstable_getFirstCallbackNode() {
|
|
return peek(taskQueue);
|
|
}
|
|
function unstable_cancelCallback(task) {
|
|
task.callback = null;
|
|
}
|
|
function unstable_getCurrentPriorityLevel() {
|
|
return currentPriorityLevel;
|
|
}
|
|
var unstable_requestPaint = requestPaint;
|
|
var unstable_Profiling = null;
|
|
exports.unstable_IdlePriority = IdlePriority;
|
|
exports.unstable_ImmediatePriority = ImmediatePriority;
|
|
exports.unstable_LowPriority = LowPriority;
|
|
exports.unstable_NormalPriority = NormalPriority;
|
|
exports.unstable_Profiling = unstable_Profiling;
|
|
exports.unstable_UserBlockingPriority = UserBlockingPriority;
|
|
exports.unstable_cancelCallback = unstable_cancelCallback;
|
|
exports.unstable_continueExecution = unstable_continueExecution;
|
|
exports.unstable_getCurrentPriorityLevel = unstable_getCurrentPriorityLevel;
|
|
exports.unstable_getFirstCallbackNode = unstable_getFirstCallbackNode;
|
|
exports.unstable_next = unstable_next;
|
|
exports.unstable_pauseExecution = unstable_pauseExecution;
|
|
exports.unstable_requestPaint = unstable_requestPaint;
|
|
exports.unstable_runWithPriority = unstable_runWithPriority;
|
|
exports.unstable_scheduleCallback = unstable_scheduleCallback;
|
|
exports.unstable_wrapCallback = unstable_wrapCallback;
|
|
})();
|
|
}
|
|
}
|
|
});
|
|
|
|
// node_modules/scheduler/index.js
|
|
var require_scheduler = __commonJS({
|
|
"node_modules/scheduler/index.js"(exports, module2) {
|
|
"use strict";
|
|
if (false) {
|
|
module2.exports = null;
|
|
} else {
|
|
module2.exports = require_scheduler_development();
|
|
}
|
|
}
|
|
});
|
|
|
|
// node_modules/scheduler/cjs/scheduler-tracing.development.js
|
|
var require_scheduler_tracing_development = __commonJS({
|
|
"node_modules/scheduler/cjs/scheduler-tracing.development.js"(exports) {
|
|
"use strict";
|
|
if (true) {
|
|
(function() {
|
|
"use strict";
|
|
var DEFAULT_THREAD_ID = 0;
|
|
var interactionIDCounter = 0;
|
|
var threadIDCounter = 0;
|
|
exports.__interactionsRef = null;
|
|
exports.__subscriberRef = null;
|
|
{
|
|
exports.__interactionsRef = {
|
|
current: new Set()
|
|
};
|
|
exports.__subscriberRef = {
|
|
current: null
|
|
};
|
|
}
|
|
function unstable_clear(callback) {
|
|
var prevInteractions = exports.__interactionsRef.current;
|
|
exports.__interactionsRef.current = new Set();
|
|
try {
|
|
return callback();
|
|
} finally {
|
|
exports.__interactionsRef.current = prevInteractions;
|
|
}
|
|
}
|
|
function unstable_getCurrent() {
|
|
{
|
|
return exports.__interactionsRef.current;
|
|
}
|
|
}
|
|
function unstable_getThreadID() {
|
|
return ++threadIDCounter;
|
|
}
|
|
function unstable_trace(name, timestamp, callback) {
|
|
var threadID = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : DEFAULT_THREAD_ID;
|
|
var interaction = {
|
|
__count: 1,
|
|
id: interactionIDCounter++,
|
|
name,
|
|
timestamp
|
|
};
|
|
var prevInteractions = exports.__interactionsRef.current;
|
|
var interactions = new Set(prevInteractions);
|
|
interactions.add(interaction);
|
|
exports.__interactionsRef.current = interactions;
|
|
var subscriber = exports.__subscriberRef.current;
|
|
var returnValue;
|
|
try {
|
|
if (subscriber !== null) {
|
|
subscriber.onInteractionTraced(interaction);
|
|
}
|
|
} finally {
|
|
try {
|
|
if (subscriber !== null) {
|
|
subscriber.onWorkStarted(interactions, threadID);
|
|
}
|
|
} finally {
|
|
try {
|
|
returnValue = callback();
|
|
} finally {
|
|
exports.__interactionsRef.current = prevInteractions;
|
|
try {
|
|
if (subscriber !== null) {
|
|
subscriber.onWorkStopped(interactions, threadID);
|
|
}
|
|
} finally {
|
|
interaction.__count--;
|
|
if (subscriber !== null && interaction.__count === 0) {
|
|
subscriber.onInteractionScheduledWorkCompleted(interaction);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return returnValue;
|
|
}
|
|
function unstable_wrap(callback) {
|
|
var threadID = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : DEFAULT_THREAD_ID;
|
|
var wrappedInteractions = exports.__interactionsRef.current;
|
|
var subscriber = exports.__subscriberRef.current;
|
|
if (subscriber !== null) {
|
|
subscriber.onWorkScheduled(wrappedInteractions, threadID);
|
|
}
|
|
wrappedInteractions.forEach(function(interaction) {
|
|
interaction.__count++;
|
|
});
|
|
var hasRun = false;
|
|
function wrapped() {
|
|
var prevInteractions = exports.__interactionsRef.current;
|
|
exports.__interactionsRef.current = wrappedInteractions;
|
|
subscriber = exports.__subscriberRef.current;
|
|
try {
|
|
var returnValue;
|
|
try {
|
|
if (subscriber !== null) {
|
|
subscriber.onWorkStarted(wrappedInteractions, threadID);
|
|
}
|
|
} finally {
|
|
try {
|
|
returnValue = callback.apply(void 0, arguments);
|
|
} finally {
|
|
exports.__interactionsRef.current = prevInteractions;
|
|
if (subscriber !== null) {
|
|
subscriber.onWorkStopped(wrappedInteractions, threadID);
|
|
}
|
|
}
|
|
}
|
|
return returnValue;
|
|
} finally {
|
|
if (!hasRun) {
|
|
hasRun = true;
|
|
wrappedInteractions.forEach(function(interaction) {
|
|
interaction.__count--;
|
|
if (subscriber !== null && interaction.__count === 0) {
|
|
subscriber.onInteractionScheduledWorkCompleted(interaction);
|
|
}
|
|
});
|
|
}
|
|
}
|
|
}
|
|
wrapped.cancel = function cancel() {
|
|
subscriber = exports.__subscriberRef.current;
|
|
try {
|
|
if (subscriber !== null) {
|
|
subscriber.onWorkCanceled(wrappedInteractions, threadID);
|
|
}
|
|
} finally {
|
|
wrappedInteractions.forEach(function(interaction) {
|
|
interaction.__count--;
|
|
if (subscriber && interaction.__count === 0) {
|
|
subscriber.onInteractionScheduledWorkCompleted(interaction);
|
|
}
|
|
});
|
|
}
|
|
};
|
|
return wrapped;
|
|
}
|
|
var subscribers = null;
|
|
{
|
|
subscribers = new Set();
|
|
}
|
|
function unstable_subscribe(subscriber) {
|
|
{
|
|
subscribers.add(subscriber);
|
|
if (subscribers.size === 1) {
|
|
exports.__subscriberRef.current = {
|
|
onInteractionScheduledWorkCompleted,
|
|
onInteractionTraced,
|
|
onWorkCanceled,
|
|
onWorkScheduled,
|
|
onWorkStarted,
|
|
onWorkStopped
|
|
};
|
|
}
|
|
}
|
|
}
|
|
function unstable_unsubscribe(subscriber) {
|
|
{
|
|
subscribers.delete(subscriber);
|
|
if (subscribers.size === 0) {
|
|
exports.__subscriberRef.current = null;
|
|
}
|
|
}
|
|
}
|
|
function onInteractionTraced(interaction) {
|
|
var didCatchError = false;
|
|
var caughtError = null;
|
|
subscribers.forEach(function(subscriber) {
|
|
try {
|
|
subscriber.onInteractionTraced(interaction);
|
|
} catch (error) {
|
|
if (!didCatchError) {
|
|
didCatchError = true;
|
|
caughtError = error;
|
|
}
|
|
}
|
|
});
|
|
if (didCatchError) {
|
|
throw caughtError;
|
|
}
|
|
}
|
|
function onInteractionScheduledWorkCompleted(interaction) {
|
|
var didCatchError = false;
|
|
var caughtError = null;
|
|
subscribers.forEach(function(subscriber) {
|
|
try {
|
|
subscriber.onInteractionScheduledWorkCompleted(interaction);
|
|
} catch (error) {
|
|
if (!didCatchError) {
|
|
didCatchError = true;
|
|
caughtError = error;
|
|
}
|
|
}
|
|
});
|
|
if (didCatchError) {
|
|
throw caughtError;
|
|
}
|
|
}
|
|
function onWorkScheduled(interactions, threadID) {
|
|
var didCatchError = false;
|
|
var caughtError = null;
|
|
subscribers.forEach(function(subscriber) {
|
|
try {
|
|
subscriber.onWorkScheduled(interactions, threadID);
|
|
} catch (error) {
|
|
if (!didCatchError) {
|
|
didCatchError = true;
|
|
caughtError = error;
|
|
}
|
|
}
|
|
});
|
|
if (didCatchError) {
|
|
throw caughtError;
|
|
}
|
|
}
|
|
function onWorkStarted(interactions, threadID) {
|
|
var didCatchError = false;
|
|
var caughtError = null;
|
|
subscribers.forEach(function(subscriber) {
|
|
try {
|
|
subscriber.onWorkStarted(interactions, threadID);
|
|
} catch (error) {
|
|
if (!didCatchError) {
|
|
didCatchError = true;
|
|
caughtError = error;
|
|
}
|
|
}
|
|
});
|
|
if (didCatchError) {
|
|
throw caughtError;
|
|
}
|
|
}
|
|
function onWorkStopped(interactions, threadID) {
|
|
var didCatchError = false;
|
|
var caughtError = null;
|
|
subscribers.forEach(function(subscriber) {
|
|
try {
|
|
subscriber.onWorkStopped(interactions, threadID);
|
|
} catch (error) {
|
|
if (!didCatchError) {
|
|
didCatchError = true;
|
|
caughtError = error;
|
|
}
|
|
}
|
|
});
|
|
if (didCatchError) {
|
|
throw caughtError;
|
|
}
|
|
}
|
|
function onWorkCanceled(interactions, threadID) {
|
|
var didCatchError = false;
|
|
var caughtError = null;
|
|
subscribers.forEach(function(subscriber) {
|
|
try {
|
|
subscriber.onWorkCanceled(interactions, threadID);
|
|
} catch (error) {
|
|
if (!didCatchError) {
|
|
didCatchError = true;
|
|
caughtError = error;
|
|
}
|
|
}
|
|
});
|
|
if (didCatchError) {
|
|
throw caughtError;
|
|
}
|
|
}
|
|
exports.unstable_clear = unstable_clear;
|
|
exports.unstable_getCurrent = unstable_getCurrent;
|
|
exports.unstable_getThreadID = unstable_getThreadID;
|
|
exports.unstable_subscribe = unstable_subscribe;
|
|
exports.unstable_trace = unstable_trace;
|
|
exports.unstable_unsubscribe = unstable_unsubscribe;
|
|
exports.unstable_wrap = unstable_wrap;
|
|
})();
|
|
}
|
|
}
|
|
});
|
|
|
|
// node_modules/scheduler/tracing.js
|
|
var require_tracing = __commonJS({
|
|
"node_modules/scheduler/tracing.js"(exports, module2) {
|
|
"use strict";
|
|
if (false) {
|
|
module2.exports = null;
|
|
} else {
|
|
module2.exports = require_scheduler_tracing_development();
|
|
}
|
|
}
|
|
});
|
|
|
|
// node_modules/react-dom/cjs/react-dom.development.js
|
|
var require_react_dom_development = __commonJS({
|
|
"node_modules/react-dom/cjs/react-dom.development.js"(exports) {
|
|
"use strict";
|
|
if (true) {
|
|
(function() {
|
|
"use strict";
|
|
var React5 = require_react();
|
|
var _assign = require_object_assign();
|
|
var Scheduler = require_scheduler();
|
|
var tracing = require_tracing();
|
|
var ReactSharedInternals = React5.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
|
|
function warn(format) {
|
|
{
|
|
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
args[_key - 1] = arguments[_key];
|
|
}
|
|
printWarning("warn", format, args);
|
|
}
|
|
}
|
|
function error(format) {
|
|
{
|
|
for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
|
args[_key2 - 1] = arguments[_key2];
|
|
}
|
|
printWarning("error", format, args);
|
|
}
|
|
}
|
|
function printWarning(level, format, args) {
|
|
{
|
|
var ReactDebugCurrentFrame2 = ReactSharedInternals.ReactDebugCurrentFrame;
|
|
var stack = ReactDebugCurrentFrame2.getStackAddendum();
|
|
if (stack !== "") {
|
|
format += "%s";
|
|
args = args.concat([stack]);
|
|
}
|
|
var argsWithFormat = args.map(function(item) {
|
|
return "" + item;
|
|
});
|
|
argsWithFormat.unshift("Warning: " + format);
|
|
Function.prototype.apply.call(console[level], console, argsWithFormat);
|
|
}
|
|
}
|
|
if (!React5) {
|
|
{
|
|
throw Error("ReactDOM was loaded before React. Make sure you load the React package before loading ReactDOM.");
|
|
}
|
|
}
|
|
var FunctionComponent = 0;
|
|
var ClassComponent = 1;
|
|
var IndeterminateComponent = 2;
|
|
var HostRoot = 3;
|
|
var HostPortal = 4;
|
|
var HostComponent = 5;
|
|
var HostText = 6;
|
|
var Fragment3 = 7;
|
|
var Mode = 8;
|
|
var ContextConsumer = 9;
|
|
var ContextProvider = 10;
|
|
var ForwardRef = 11;
|
|
var Profiler = 12;
|
|
var SuspenseComponent = 13;
|
|
var MemoComponent = 14;
|
|
var SimpleMemoComponent = 15;
|
|
var LazyComponent = 16;
|
|
var IncompleteClassComponent = 17;
|
|
var DehydratedFragment = 18;
|
|
var SuspenseListComponent = 19;
|
|
var FundamentalComponent = 20;
|
|
var ScopeComponent = 21;
|
|
var Block = 22;
|
|
var OffscreenComponent = 23;
|
|
var LegacyHiddenComponent = 24;
|
|
var enableProfilerTimer = true;
|
|
var enableFundamentalAPI = false;
|
|
var enableNewReconciler = false;
|
|
var warnAboutStringRefs = false;
|
|
var allNativeEvents = new Set();
|
|
var registrationNameDependencies = {};
|
|
var possibleRegistrationNames = {};
|
|
function registerTwoPhaseEvent(registrationName, dependencies) {
|
|
registerDirectEvent(registrationName, dependencies);
|
|
registerDirectEvent(registrationName + "Capture", dependencies);
|
|
}
|
|
function registerDirectEvent(registrationName, dependencies) {
|
|
{
|
|
if (registrationNameDependencies[registrationName]) {
|
|
error("EventRegistry: More than one plugin attempted to publish the same registration name, `%s`.", registrationName);
|
|
}
|
|
}
|
|
registrationNameDependencies[registrationName] = dependencies;
|
|
{
|
|
var lowerCasedName = registrationName.toLowerCase();
|
|
possibleRegistrationNames[lowerCasedName] = registrationName;
|
|
if (registrationName === "onDoubleClick") {
|
|
possibleRegistrationNames.ondblclick = registrationName;
|
|
}
|
|
}
|
|
for (var i3 = 0; i3 < dependencies.length; i3++) {
|
|
allNativeEvents.add(dependencies[i3]);
|
|
}
|
|
}
|
|
var canUseDOM = !!(typeof window !== "undefined" && typeof window.document !== "undefined" && typeof window.document.createElement !== "undefined");
|
|
var RESERVED = 0;
|
|
var STRING = 1;
|
|
var BOOLEANISH_STRING = 2;
|
|
var BOOLEAN = 3;
|
|
var OVERLOADED_BOOLEAN = 4;
|
|
var NUMERIC = 5;
|
|
var POSITIVE_NUMERIC = 6;
|
|
var ATTRIBUTE_NAME_START_CHAR = ":A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD";
|
|
var ATTRIBUTE_NAME_CHAR = ATTRIBUTE_NAME_START_CHAR + "\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040";
|
|
var ROOT_ATTRIBUTE_NAME = "data-reactroot";
|
|
var VALID_ATTRIBUTE_NAME_REGEX = new RegExp("^[" + ATTRIBUTE_NAME_START_CHAR + "][" + ATTRIBUTE_NAME_CHAR + "]*$");
|
|
var hasOwnProperty2 = Object.prototype.hasOwnProperty;
|
|
var illegalAttributeNameCache = {};
|
|
var validatedAttributeNameCache = {};
|
|
function isAttributeNameSafe(attributeName) {
|
|
if (hasOwnProperty2.call(validatedAttributeNameCache, attributeName)) {
|
|
return true;
|
|
}
|
|
if (hasOwnProperty2.call(illegalAttributeNameCache, attributeName)) {
|
|
return false;
|
|
}
|
|
if (VALID_ATTRIBUTE_NAME_REGEX.test(attributeName)) {
|
|
validatedAttributeNameCache[attributeName] = true;
|
|
return true;
|
|
}
|
|
illegalAttributeNameCache[attributeName] = true;
|
|
{
|
|
error("Invalid attribute name: `%s`", attributeName);
|
|
}
|
|
return false;
|
|
}
|
|
function shouldIgnoreAttribute(name, propertyInfo, isCustomComponentTag) {
|
|
if (propertyInfo !== null) {
|
|
return propertyInfo.type === RESERVED;
|
|
}
|
|
if (isCustomComponentTag) {
|
|
return false;
|
|
}
|
|
if (name.length > 2 && (name[0] === "o" || name[0] === "O") && (name[1] === "n" || name[1] === "N")) {
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
function shouldRemoveAttributeWithWarning(name, value, propertyInfo, isCustomComponentTag) {
|
|
if (propertyInfo !== null && propertyInfo.type === RESERVED) {
|
|
return false;
|
|
}
|
|
switch (typeof value) {
|
|
case "function":
|
|
case "symbol":
|
|
return true;
|
|
case "boolean": {
|
|
if (isCustomComponentTag) {
|
|
return false;
|
|
}
|
|
if (propertyInfo !== null) {
|
|
return !propertyInfo.acceptsBooleans;
|
|
} else {
|
|
var prefix2 = name.toLowerCase().slice(0, 5);
|
|
return prefix2 !== "data-" && prefix2 !== "aria-";
|
|
}
|
|
}
|
|
default:
|
|
return false;
|
|
}
|
|
}
|
|
function shouldRemoveAttribute(name, value, propertyInfo, isCustomComponentTag) {
|
|
if (value === null || typeof value === "undefined") {
|
|
return true;
|
|
}
|
|
if (shouldRemoveAttributeWithWarning(name, value, propertyInfo, isCustomComponentTag)) {
|
|
return true;
|
|
}
|
|
if (isCustomComponentTag) {
|
|
return false;
|
|
}
|
|
if (propertyInfo !== null) {
|
|
switch (propertyInfo.type) {
|
|
case BOOLEAN:
|
|
return !value;
|
|
case OVERLOADED_BOOLEAN:
|
|
return value === false;
|
|
case NUMERIC:
|
|
return isNaN(value);
|
|
case POSITIVE_NUMERIC:
|
|
return isNaN(value) || value < 1;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
function getPropertyInfo(name) {
|
|
return properties.hasOwnProperty(name) ? properties[name] : null;
|
|
}
|
|
function PropertyInfoRecord(name, type, mustUseProperty, attributeName, attributeNamespace, sanitizeURL2, removeEmptyString) {
|
|
this.acceptsBooleans = type === BOOLEANISH_STRING || type === BOOLEAN || type === OVERLOADED_BOOLEAN;
|
|
this.attributeName = attributeName;
|
|
this.attributeNamespace = attributeNamespace;
|
|
this.mustUseProperty = mustUseProperty;
|
|
this.propertyName = name;
|
|
this.type = type;
|
|
this.sanitizeURL = sanitizeURL2;
|
|
this.removeEmptyString = removeEmptyString;
|
|
}
|
|
var properties = {};
|
|
var reservedProps = [
|
|
"children",
|
|
"dangerouslySetInnerHTML",
|
|
"defaultValue",
|
|
"defaultChecked",
|
|
"innerHTML",
|
|
"suppressContentEditableWarning",
|
|
"suppressHydrationWarning",
|
|
"style"
|
|
];
|
|
reservedProps.forEach(function(name) {
|
|
properties[name] = new PropertyInfoRecord(name, RESERVED, false, name, null, false, false);
|
|
});
|
|
[["acceptCharset", "accept-charset"], ["className", "class"], ["htmlFor", "for"], ["httpEquiv", "http-equiv"]].forEach(function(_ref) {
|
|
var name = _ref[0], attributeName = _ref[1];
|
|
properties[name] = new PropertyInfoRecord(name, STRING, false, attributeName, null, false, false);
|
|
});
|
|
["contentEditable", "draggable", "spellCheck", "value"].forEach(function(name) {
|
|
properties[name] = new PropertyInfoRecord(name, BOOLEANISH_STRING, false, name.toLowerCase(), null, false, false);
|
|
});
|
|
["autoReverse", "externalResourcesRequired", "focusable", "preserveAlpha"].forEach(function(name) {
|
|
properties[name] = new PropertyInfoRecord(name, BOOLEANISH_STRING, false, name, null, false, false);
|
|
});
|
|
[
|
|
"allowFullScreen",
|
|
"async",
|
|
"autoFocus",
|
|
"autoPlay",
|
|
"controls",
|
|
"default",
|
|
"defer",
|
|
"disabled",
|
|
"disablePictureInPicture",
|
|
"disableRemotePlayback",
|
|
"formNoValidate",
|
|
"hidden",
|
|
"loop",
|
|
"noModule",
|
|
"noValidate",
|
|
"open",
|
|
"playsInline",
|
|
"readOnly",
|
|
"required",
|
|
"reversed",
|
|
"scoped",
|
|
"seamless",
|
|
"itemScope"
|
|
].forEach(function(name) {
|
|
properties[name] = new PropertyInfoRecord(name, BOOLEAN, false, name.toLowerCase(), null, false, false);
|
|
});
|
|
[
|
|
"checked",
|
|
"multiple",
|
|
"muted",
|
|
"selected"
|
|
].forEach(function(name) {
|
|
properties[name] = new PropertyInfoRecord(name, BOOLEAN, true, name, null, false, false);
|
|
});
|
|
[
|
|
"capture",
|
|
"download"
|
|
].forEach(function(name) {
|
|
properties[name] = new PropertyInfoRecord(name, OVERLOADED_BOOLEAN, false, name, null, false, false);
|
|
});
|
|
[
|
|
"cols",
|
|
"rows",
|
|
"size",
|
|
"span"
|
|
].forEach(function(name) {
|
|
properties[name] = new PropertyInfoRecord(name, POSITIVE_NUMERIC, false, name, null, false, false);
|
|
});
|
|
["rowSpan", "start"].forEach(function(name) {
|
|
properties[name] = new PropertyInfoRecord(name, NUMERIC, false, name.toLowerCase(), null, false, false);
|
|
});
|
|
var CAMELIZE = /[\-\:]([a-z])/g;
|
|
var capitalize = function(token) {
|
|
return token[1].toUpperCase();
|
|
};
|
|
[
|
|
"accent-height",
|
|
"alignment-baseline",
|
|
"arabic-form",
|
|
"baseline-shift",
|
|
"cap-height",
|
|
"clip-path",
|
|
"clip-rule",
|
|
"color-interpolation",
|
|
"color-interpolation-filters",
|
|
"color-profile",
|
|
"color-rendering",
|
|
"dominant-baseline",
|
|
"enable-background",
|
|
"fill-opacity",
|
|
"fill-rule",
|
|
"flood-color",
|
|
"flood-opacity",
|
|
"font-family",
|
|
"font-size",
|
|
"font-size-adjust",
|
|
"font-stretch",
|
|
"font-style",
|
|
"font-variant",
|
|
"font-weight",
|
|
"glyph-name",
|
|
"glyph-orientation-horizontal",
|
|
"glyph-orientation-vertical",
|
|
"horiz-adv-x",
|
|
"horiz-origin-x",
|
|
"image-rendering",
|
|
"letter-spacing",
|
|
"lighting-color",
|
|
"marker-end",
|
|
"marker-mid",
|
|
"marker-start",
|
|
"overline-position",
|
|
"overline-thickness",
|
|
"paint-order",
|
|
"panose-1",
|
|
"pointer-events",
|
|
"rendering-intent",
|
|
"shape-rendering",
|
|
"stop-color",
|
|
"stop-opacity",
|
|
"strikethrough-position",
|
|
"strikethrough-thickness",
|
|
"stroke-dasharray",
|
|
"stroke-dashoffset",
|
|
"stroke-linecap",
|
|
"stroke-linejoin",
|
|
"stroke-miterlimit",
|
|
"stroke-opacity",
|
|
"stroke-width",
|
|
"text-anchor",
|
|
"text-decoration",
|
|
"text-rendering",
|
|
"underline-position",
|
|
"underline-thickness",
|
|
"unicode-bidi",
|
|
"unicode-range",
|
|
"units-per-em",
|
|
"v-alphabetic",
|
|
"v-hanging",
|
|
"v-ideographic",
|
|
"v-mathematical",
|
|
"vector-effect",
|
|
"vert-adv-y",
|
|
"vert-origin-x",
|
|
"vert-origin-y",
|
|
"word-spacing",
|
|
"writing-mode",
|
|
"xmlns:xlink",
|
|
"x-height"
|
|
].forEach(function(attributeName) {
|
|
var name = attributeName.replace(CAMELIZE, capitalize);
|
|
properties[name] = new PropertyInfoRecord(name, STRING, false, attributeName, null, false, false);
|
|
});
|
|
[
|
|
"xlink:actuate",
|
|
"xlink:arcrole",
|
|
"xlink:role",
|
|
"xlink:show",
|
|
"xlink:title",
|
|
"xlink:type"
|
|
].forEach(function(attributeName) {
|
|
var name = attributeName.replace(CAMELIZE, capitalize);
|
|
properties[name] = new PropertyInfoRecord(name, STRING, false, attributeName, "http://www.w3.org/1999/xlink", false, false);
|
|
});
|
|
[
|
|
"xml:base",
|
|
"xml:lang",
|
|
"xml:space"
|
|
].forEach(function(attributeName) {
|
|
var name = attributeName.replace(CAMELIZE, capitalize);
|
|
properties[name] = new PropertyInfoRecord(name, STRING, false, attributeName, "http://www.w3.org/XML/1998/namespace", false, false);
|
|
});
|
|
["tabIndex", "crossOrigin"].forEach(function(attributeName) {
|
|
properties[attributeName] = new PropertyInfoRecord(attributeName, STRING, false, attributeName.toLowerCase(), null, false, false);
|
|
});
|
|
var xlinkHref = "xlinkHref";
|
|
properties[xlinkHref] = new PropertyInfoRecord("xlinkHref", STRING, false, "xlink:href", "http://www.w3.org/1999/xlink", true, false);
|
|
["src", "href", "action", "formAction"].forEach(function(attributeName) {
|
|
properties[attributeName] = new PropertyInfoRecord(attributeName, STRING, false, attributeName.toLowerCase(), null, true, true);
|
|
});
|
|
var isJavaScriptProtocol = /^[\u0000-\u001F ]*j[\r\n\t]*a[\r\n\t]*v[\r\n\t]*a[\r\n\t]*s[\r\n\t]*c[\r\n\t]*r[\r\n\t]*i[\r\n\t]*p[\r\n\t]*t[\r\n\t]*\:/i;
|
|
var didWarn = false;
|
|
function sanitizeURL(url) {
|
|
{
|
|
if (!didWarn && isJavaScriptProtocol.test(url)) {
|
|
didWarn = true;
|
|
error("A future version of React will block javascript: URLs as a security precaution. Use event handlers instead if you can. If you need to generate unsafe HTML try using dangerouslySetInnerHTML instead. React was passed %s.", JSON.stringify(url));
|
|
}
|
|
}
|
|
}
|
|
function getValueForProperty(node, name, expected, propertyInfo) {
|
|
{
|
|
if (propertyInfo.mustUseProperty) {
|
|
var propertyName = propertyInfo.propertyName;
|
|
return node[propertyName];
|
|
} else {
|
|
if (propertyInfo.sanitizeURL) {
|
|
sanitizeURL("" + expected);
|
|
}
|
|
var attributeName = propertyInfo.attributeName;
|
|
var stringValue = null;
|
|
if (propertyInfo.type === OVERLOADED_BOOLEAN) {
|
|
if (node.hasAttribute(attributeName)) {
|
|
var value = node.getAttribute(attributeName);
|
|
if (value === "") {
|
|
return true;
|
|
}
|
|
if (shouldRemoveAttribute(name, expected, propertyInfo, false)) {
|
|
return value;
|
|
}
|
|
if (value === "" + expected) {
|
|
return expected;
|
|
}
|
|
return value;
|
|
}
|
|
} else if (node.hasAttribute(attributeName)) {
|
|
if (shouldRemoveAttribute(name, expected, propertyInfo, false)) {
|
|
return node.getAttribute(attributeName);
|
|
}
|
|
if (propertyInfo.type === BOOLEAN) {
|
|
return expected;
|
|
}
|
|
stringValue = node.getAttribute(attributeName);
|
|
}
|
|
if (shouldRemoveAttribute(name, expected, propertyInfo, false)) {
|
|
return stringValue === null ? expected : stringValue;
|
|
} else if (stringValue === "" + expected) {
|
|
return expected;
|
|
} else {
|
|
return stringValue;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
function getValueForAttribute(node, name, expected) {
|
|
{
|
|
if (!isAttributeNameSafe(name)) {
|
|
return;
|
|
}
|
|
if (isOpaqueHydratingObject(expected)) {
|
|
return expected;
|
|
}
|
|
if (!node.hasAttribute(name)) {
|
|
return expected === void 0 ? void 0 : null;
|
|
}
|
|
var value = node.getAttribute(name);
|
|
if (value === "" + expected) {
|
|
return expected;
|
|
}
|
|
return value;
|
|
}
|
|
}
|
|
function setValueForProperty(node, name, value, isCustomComponentTag) {
|
|
var propertyInfo = getPropertyInfo(name);
|
|
if (shouldIgnoreAttribute(name, propertyInfo, isCustomComponentTag)) {
|
|
return;
|
|
}
|
|
if (shouldRemoveAttribute(name, value, propertyInfo, isCustomComponentTag)) {
|
|
value = null;
|
|
}
|
|
if (isCustomComponentTag || propertyInfo === null) {
|
|
if (isAttributeNameSafe(name)) {
|
|
var _attributeName = name;
|
|
if (value === null) {
|
|
node.removeAttribute(_attributeName);
|
|
} else {
|
|
node.setAttribute(_attributeName, "" + value);
|
|
}
|
|
}
|
|
return;
|
|
}
|
|
var mustUseProperty = propertyInfo.mustUseProperty;
|
|
if (mustUseProperty) {
|
|
var propertyName = propertyInfo.propertyName;
|
|
if (value === null) {
|
|
var type = propertyInfo.type;
|
|
node[propertyName] = type === BOOLEAN ? false : "";
|
|
} else {
|
|
node[propertyName] = value;
|
|
}
|
|
return;
|
|
}
|
|
var attributeName = propertyInfo.attributeName, attributeNamespace = propertyInfo.attributeNamespace;
|
|
if (value === null) {
|
|
node.removeAttribute(attributeName);
|
|
} else {
|
|
var _type = propertyInfo.type;
|
|
var attributeValue;
|
|
if (_type === BOOLEAN || _type === OVERLOADED_BOOLEAN && value === true) {
|
|
attributeValue = "";
|
|
} else {
|
|
{
|
|
attributeValue = "" + value;
|
|
}
|
|
if (propertyInfo.sanitizeURL) {
|
|
sanitizeURL(attributeValue.toString());
|
|
}
|
|
}
|
|
if (attributeNamespace) {
|
|
node.setAttributeNS(attributeNamespace, attributeName, attributeValue);
|
|
} else {
|
|
node.setAttribute(attributeName, attributeValue);
|
|
}
|
|
}
|
|
}
|
|
var REACT_ELEMENT_TYPE = 60103;
|
|
var REACT_PORTAL_TYPE = 60106;
|
|
var REACT_FRAGMENT_TYPE = 60107;
|
|
var REACT_STRICT_MODE_TYPE = 60108;
|
|
var REACT_PROFILER_TYPE = 60114;
|
|
var REACT_PROVIDER_TYPE = 60109;
|
|
var REACT_CONTEXT_TYPE = 60110;
|
|
var REACT_FORWARD_REF_TYPE = 60112;
|
|
var REACT_SUSPENSE_TYPE = 60113;
|
|
var REACT_SUSPENSE_LIST_TYPE = 60120;
|
|
var REACT_MEMO_TYPE = 60115;
|
|
var REACT_LAZY_TYPE = 60116;
|
|
var REACT_BLOCK_TYPE = 60121;
|
|
var REACT_SERVER_BLOCK_TYPE = 60122;
|
|
var REACT_FUNDAMENTAL_TYPE = 60117;
|
|
var REACT_SCOPE_TYPE = 60119;
|
|
var REACT_OPAQUE_ID_TYPE = 60128;
|
|
var REACT_DEBUG_TRACING_MODE_TYPE = 60129;
|
|
var REACT_OFFSCREEN_TYPE = 60130;
|
|
var REACT_LEGACY_HIDDEN_TYPE = 60131;
|
|
if (typeof Symbol === "function" && Symbol.for) {
|
|
var symbolFor = Symbol.for;
|
|
REACT_ELEMENT_TYPE = symbolFor("react.element");
|
|
REACT_PORTAL_TYPE = symbolFor("react.portal");
|
|
REACT_FRAGMENT_TYPE = symbolFor("react.fragment");
|
|
REACT_STRICT_MODE_TYPE = symbolFor("react.strict_mode");
|
|
REACT_PROFILER_TYPE = symbolFor("react.profiler");
|
|
REACT_PROVIDER_TYPE = symbolFor("react.provider");
|
|
REACT_CONTEXT_TYPE = symbolFor("react.context");
|
|
REACT_FORWARD_REF_TYPE = symbolFor("react.forward_ref");
|
|
REACT_SUSPENSE_TYPE = symbolFor("react.suspense");
|
|
REACT_SUSPENSE_LIST_TYPE = symbolFor("react.suspense_list");
|
|
REACT_MEMO_TYPE = symbolFor("react.memo");
|
|
REACT_LAZY_TYPE = symbolFor("react.lazy");
|
|
REACT_BLOCK_TYPE = symbolFor("react.block");
|
|
REACT_SERVER_BLOCK_TYPE = symbolFor("react.server.block");
|
|
REACT_FUNDAMENTAL_TYPE = symbolFor("react.fundamental");
|
|
REACT_SCOPE_TYPE = symbolFor("react.scope");
|
|
REACT_OPAQUE_ID_TYPE = symbolFor("react.opaque.id");
|
|
REACT_DEBUG_TRACING_MODE_TYPE = symbolFor("react.debug_trace_mode");
|
|
REACT_OFFSCREEN_TYPE = symbolFor("react.offscreen");
|
|
REACT_LEGACY_HIDDEN_TYPE = symbolFor("react.legacy_hidden");
|
|
}
|
|
var MAYBE_ITERATOR_SYMBOL = typeof Symbol === "function" && Symbol.iterator;
|
|
var FAUX_ITERATOR_SYMBOL = "@@iterator";
|
|
function getIteratorFn(maybeIterable) {
|
|
if (maybeIterable === null || typeof maybeIterable !== "object") {
|
|
return null;
|
|
}
|
|
var maybeIterator = MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL];
|
|
if (typeof maybeIterator === "function") {
|
|
return maybeIterator;
|
|
}
|
|
return null;
|
|
}
|
|
var disabledDepth = 0;
|
|
var prevLog;
|
|
var prevInfo;
|
|
var prevWarn;
|
|
var prevError;
|
|
var prevGroup;
|
|
var prevGroupCollapsed;
|
|
var prevGroupEnd;
|
|
function disabledLog() {
|
|
}
|
|
disabledLog.__reactDisabledLog = true;
|
|
function disableLogs() {
|
|
{
|
|
if (disabledDepth === 0) {
|
|
prevLog = console.log;
|
|
prevInfo = console.info;
|
|
prevWarn = console.warn;
|
|
prevError = console.error;
|
|
prevGroup = console.group;
|
|
prevGroupCollapsed = console.groupCollapsed;
|
|
prevGroupEnd = console.groupEnd;
|
|
var props = {
|
|
configurable: true,
|
|
enumerable: true,
|
|
value: disabledLog,
|
|
writable: true
|
|
};
|
|
Object.defineProperties(console, {
|
|
info: props,
|
|
log: props,
|
|
warn: props,
|
|
error: props,
|
|
group: props,
|
|
groupCollapsed: props,
|
|
groupEnd: props
|
|
});
|
|
}
|
|
disabledDepth++;
|
|
}
|
|
}
|
|
function reenableLogs() {
|
|
{
|
|
disabledDepth--;
|
|
if (disabledDepth === 0) {
|
|
var props = {
|
|
configurable: true,
|
|
enumerable: true,
|
|
writable: true
|
|
};
|
|
Object.defineProperties(console, {
|
|
log: _assign({}, props, {
|
|
value: prevLog
|
|
}),
|
|
info: _assign({}, props, {
|
|
value: prevInfo
|
|
}),
|
|
warn: _assign({}, props, {
|
|
value: prevWarn
|
|
}),
|
|
error: _assign({}, props, {
|
|
value: prevError
|
|
}),
|
|
group: _assign({}, props, {
|
|
value: prevGroup
|
|
}),
|
|
groupCollapsed: _assign({}, props, {
|
|
value: prevGroupCollapsed
|
|
}),
|
|
groupEnd: _assign({}, props, {
|
|
value: prevGroupEnd
|
|
})
|
|
});
|
|
}
|
|
if (disabledDepth < 0) {
|
|
error("disabledDepth fell below zero. This is a bug in React. Please file an issue.");
|
|
}
|
|
}
|
|
}
|
|
var ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher;
|
|
var prefix;
|
|
function describeBuiltInComponentFrame(name, source, ownerFn) {
|
|
{
|
|
if (prefix === void 0) {
|
|
try {
|
|
throw Error();
|
|
} catch (x3) {
|
|
var match = x3.stack.trim().match(/\n( *(at )?)/);
|
|
prefix = match && match[1] || "";
|
|
}
|
|
}
|
|
return "\n" + prefix + name;
|
|
}
|
|
}
|
|
var reentry = false;
|
|
var componentFrameCache;
|
|
{
|
|
var PossiblyWeakMap = typeof WeakMap === "function" ? WeakMap : Map;
|
|
componentFrameCache = new PossiblyWeakMap();
|
|
}
|
|
function describeNativeComponentFrame(fn, construct) {
|
|
if (!fn || reentry) {
|
|
return "";
|
|
}
|
|
{
|
|
var frame = componentFrameCache.get(fn);
|
|
if (frame !== void 0) {
|
|
return frame;
|
|
}
|
|
}
|
|
var control;
|
|
reentry = true;
|
|
var previousPrepareStackTrace = Error.prepareStackTrace;
|
|
Error.prepareStackTrace = void 0;
|
|
var previousDispatcher;
|
|
{
|
|
previousDispatcher = ReactCurrentDispatcher.current;
|
|
ReactCurrentDispatcher.current = null;
|
|
disableLogs();
|
|
}
|
|
try {
|
|
if (construct) {
|
|
var Fake = function() {
|
|
throw Error();
|
|
};
|
|
Object.defineProperty(Fake.prototype, "props", {
|
|
set: function() {
|
|
throw Error();
|
|
}
|
|
});
|
|
if (typeof Reflect === "object" && Reflect.construct) {
|
|
try {
|
|
Reflect.construct(Fake, []);
|
|
} catch (x3) {
|
|
control = x3;
|
|
}
|
|
Reflect.construct(fn, [], Fake);
|
|
} else {
|
|
try {
|
|
Fake.call();
|
|
} catch (x3) {
|
|
control = x3;
|
|
}
|
|
fn.call(Fake.prototype);
|
|
}
|
|
} else {
|
|
try {
|
|
throw Error();
|
|
} catch (x3) {
|
|
control = x3;
|
|
}
|
|
fn();
|
|
}
|
|
} catch (sample) {
|
|
if (sample && control && typeof sample.stack === "string") {
|
|
var sampleLines = sample.stack.split("\n");
|
|
var controlLines = control.stack.split("\n");
|
|
var s3 = sampleLines.length - 1;
|
|
var c3 = controlLines.length - 1;
|
|
while (s3 >= 1 && c3 >= 0 && sampleLines[s3] !== controlLines[c3]) {
|
|
c3--;
|
|
}
|
|
for (; s3 >= 1 && c3 >= 0; s3--, c3--) {
|
|
if (sampleLines[s3] !== controlLines[c3]) {
|
|
if (s3 !== 1 || c3 !== 1) {
|
|
do {
|
|
s3--;
|
|
c3--;
|
|
if (c3 < 0 || sampleLines[s3] !== controlLines[c3]) {
|
|
var _frame = "\n" + sampleLines[s3].replace(" at new ", " at ");
|
|
{
|
|
if (typeof fn === "function") {
|
|
componentFrameCache.set(fn, _frame);
|
|
}
|
|
}
|
|
return _frame;
|
|
}
|
|
} while (s3 >= 1 && c3 >= 0);
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
} finally {
|
|
reentry = false;
|
|
{
|
|
ReactCurrentDispatcher.current = previousDispatcher;
|
|
reenableLogs();
|
|
}
|
|
Error.prepareStackTrace = previousPrepareStackTrace;
|
|
}
|
|
var name = fn ? fn.displayName || fn.name : "";
|
|
var syntheticFrame = name ? describeBuiltInComponentFrame(name) : "";
|
|
{
|
|
if (typeof fn === "function") {
|
|
componentFrameCache.set(fn, syntheticFrame);
|
|
}
|
|
}
|
|
return syntheticFrame;
|
|
}
|
|
function describeClassComponentFrame(ctor, source, ownerFn) {
|
|
{
|
|
return describeNativeComponentFrame(ctor, true);
|
|
}
|
|
}
|
|
function describeFunctionComponentFrame(fn, source, ownerFn) {
|
|
{
|
|
return describeNativeComponentFrame(fn, false);
|
|
}
|
|
}
|
|
function shouldConstruct(Component5) {
|
|
var prototype = Component5.prototype;
|
|
return !!(prototype && prototype.isReactComponent);
|
|
}
|
|
function describeUnknownElementTypeFrameInDEV(type, source, ownerFn) {
|
|
if (type == null) {
|
|
return "";
|
|
}
|
|
if (typeof type === "function") {
|
|
{
|
|
return describeNativeComponentFrame(type, shouldConstruct(type));
|
|
}
|
|
}
|
|
if (typeof type === "string") {
|
|
return describeBuiltInComponentFrame(type);
|
|
}
|
|
switch (type) {
|
|
case REACT_SUSPENSE_TYPE:
|
|
return describeBuiltInComponentFrame("Suspense");
|
|
case REACT_SUSPENSE_LIST_TYPE:
|
|
return describeBuiltInComponentFrame("SuspenseList");
|
|
}
|
|
if (typeof type === "object") {
|
|
switch (type.$$typeof) {
|
|
case REACT_FORWARD_REF_TYPE:
|
|
return describeFunctionComponentFrame(type.render);
|
|
case REACT_MEMO_TYPE:
|
|
return describeUnknownElementTypeFrameInDEV(type.type, source, ownerFn);
|
|
case REACT_BLOCK_TYPE:
|
|
return describeFunctionComponentFrame(type._render);
|
|
case REACT_LAZY_TYPE: {
|
|
var lazyComponent = type;
|
|
var payload = lazyComponent._payload;
|
|
var init = lazyComponent._init;
|
|
try {
|
|
return describeUnknownElementTypeFrameInDEV(init(payload), source, ownerFn);
|
|
} catch (x3) {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return "";
|
|
}
|
|
function describeFiber(fiber) {
|
|
var owner = fiber._debugOwner ? fiber._debugOwner.type : null;
|
|
var source = fiber._debugSource;
|
|
switch (fiber.tag) {
|
|
case HostComponent:
|
|
return describeBuiltInComponentFrame(fiber.type);
|
|
case LazyComponent:
|
|
return describeBuiltInComponentFrame("Lazy");
|
|
case SuspenseComponent:
|
|
return describeBuiltInComponentFrame("Suspense");
|
|
case SuspenseListComponent:
|
|
return describeBuiltInComponentFrame("SuspenseList");
|
|
case FunctionComponent:
|
|
case IndeterminateComponent:
|
|
case SimpleMemoComponent:
|
|
return describeFunctionComponentFrame(fiber.type);
|
|
case ForwardRef:
|
|
return describeFunctionComponentFrame(fiber.type.render);
|
|
case Block:
|
|
return describeFunctionComponentFrame(fiber.type._render);
|
|
case ClassComponent:
|
|
return describeClassComponentFrame(fiber.type);
|
|
default:
|
|
return "";
|
|
}
|
|
}
|
|
function getStackByFiberInDevAndProd(workInProgress2) {
|
|
try {
|
|
var info = "";
|
|
var node = workInProgress2;
|
|
do {
|
|
info += describeFiber(node);
|
|
node = node.return;
|
|
} while (node);
|
|
return info;
|
|
} catch (x3) {
|
|
return "\nError generating stack: " + x3.message + "\n" + x3.stack;
|
|
}
|
|
}
|
|
function getWrappedName(outerType, innerType, wrapperName) {
|
|
var functionName = innerType.displayName || innerType.name || "";
|
|
return outerType.displayName || (functionName !== "" ? wrapperName + "(" + functionName + ")" : wrapperName);
|
|
}
|
|
function getContextName(type) {
|
|
return type.displayName || "Context";
|
|
}
|
|
function getComponentName(type) {
|
|
if (type == null) {
|
|
return null;
|
|
}
|
|
{
|
|
if (typeof type.tag === "number") {
|
|
error("Received an unexpected object in getComponentName(). This is likely a bug in React. Please file an issue.");
|
|
}
|
|
}
|
|
if (typeof type === "function") {
|
|
return type.displayName || type.name || null;
|
|
}
|
|
if (typeof type === "string") {
|
|
return type;
|
|
}
|
|
switch (type) {
|
|
case REACT_FRAGMENT_TYPE:
|
|
return "Fragment";
|
|
case REACT_PORTAL_TYPE:
|
|
return "Portal";
|
|
case REACT_PROFILER_TYPE:
|
|
return "Profiler";
|
|
case REACT_STRICT_MODE_TYPE:
|
|
return "StrictMode";
|
|
case REACT_SUSPENSE_TYPE:
|
|
return "Suspense";
|
|
case REACT_SUSPENSE_LIST_TYPE:
|
|
return "SuspenseList";
|
|
}
|
|
if (typeof type === "object") {
|
|
switch (type.$$typeof) {
|
|
case REACT_CONTEXT_TYPE:
|
|
var context = type;
|
|
return getContextName(context) + ".Consumer";
|
|
case REACT_PROVIDER_TYPE:
|
|
var provider = type;
|
|
return getContextName(provider._context) + ".Provider";
|
|
case REACT_FORWARD_REF_TYPE:
|
|
return getWrappedName(type, type.render, "ForwardRef");
|
|
case REACT_MEMO_TYPE:
|
|
return getComponentName(type.type);
|
|
case REACT_BLOCK_TYPE:
|
|
return getComponentName(type._render);
|
|
case REACT_LAZY_TYPE: {
|
|
var lazyComponent = type;
|
|
var payload = lazyComponent._payload;
|
|
var init = lazyComponent._init;
|
|
try {
|
|
return getComponentName(init(payload));
|
|
} catch (x3) {
|
|
return null;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
|
|
var current = null;
|
|
var isRendering = false;
|
|
function getCurrentFiberOwnerNameInDevOrNull() {
|
|
{
|
|
if (current === null) {
|
|
return null;
|
|
}
|
|
var owner = current._debugOwner;
|
|
if (owner !== null && typeof owner !== "undefined") {
|
|
return getComponentName(owner.type);
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
function getCurrentFiberStackInDev() {
|
|
{
|
|
if (current === null) {
|
|
return "";
|
|
}
|
|
return getStackByFiberInDevAndProd(current);
|
|
}
|
|
}
|
|
function resetCurrentFiber() {
|
|
{
|
|
ReactDebugCurrentFrame.getCurrentStack = null;
|
|
current = null;
|
|
isRendering = false;
|
|
}
|
|
}
|
|
function setCurrentFiber(fiber) {
|
|
{
|
|
ReactDebugCurrentFrame.getCurrentStack = getCurrentFiberStackInDev;
|
|
current = fiber;
|
|
isRendering = false;
|
|
}
|
|
}
|
|
function setIsRendering(rendering) {
|
|
{
|
|
isRendering = rendering;
|
|
}
|
|
}
|
|
function getIsRendering() {
|
|
{
|
|
return isRendering;
|
|
}
|
|
}
|
|
function toString(value) {
|
|
return "" + value;
|
|
}
|
|
function getToStringValue(value) {
|
|
switch (typeof value) {
|
|
case "boolean":
|
|
case "number":
|
|
case "object":
|
|
case "string":
|
|
case "undefined":
|
|
return value;
|
|
default:
|
|
return "";
|
|
}
|
|
}
|
|
var hasReadOnlyValue = {
|
|
button: true,
|
|
checkbox: true,
|
|
image: true,
|
|
hidden: true,
|
|
radio: true,
|
|
reset: true,
|
|
submit: true
|
|
};
|
|
function checkControlledValueProps(tagName, props) {
|
|
{
|
|
if (!(hasReadOnlyValue[props.type] || props.onChange || props.onInput || props.readOnly || props.disabled || props.value == null)) {
|
|
error("You provided a `value` prop to a form field without an `onChange` handler. This will render a read-only field. If the field should be mutable use `defaultValue`. Otherwise, set either `onChange` or `readOnly`.");
|
|
}
|
|
if (!(props.onChange || props.readOnly || props.disabled || props.checked == null)) {
|
|
error("You provided a `checked` prop to a form field without an `onChange` handler. This will render a read-only field. If the field should be mutable use `defaultChecked`. Otherwise, set either `onChange` or `readOnly`.");
|
|
}
|
|
}
|
|
}
|
|
function isCheckable(elem) {
|
|
var type = elem.type;
|
|
var nodeName = elem.nodeName;
|
|
return nodeName && nodeName.toLowerCase() === "input" && (type === "checkbox" || type === "radio");
|
|
}
|
|
function getTracker(node) {
|
|
return node._valueTracker;
|
|
}
|
|
function detachTracker(node) {
|
|
node._valueTracker = null;
|
|
}
|
|
function getValueFromNode(node) {
|
|
var value = "";
|
|
if (!node) {
|
|
return value;
|
|
}
|
|
if (isCheckable(node)) {
|
|
value = node.checked ? "true" : "false";
|
|
} else {
|
|
value = node.value;
|
|
}
|
|
return value;
|
|
}
|
|
function trackValueOnNode(node) {
|
|
var valueField = isCheckable(node) ? "checked" : "value";
|
|
var descriptor = Object.getOwnPropertyDescriptor(node.constructor.prototype, valueField);
|
|
var currentValue = "" + node[valueField];
|
|
if (node.hasOwnProperty(valueField) || typeof descriptor === "undefined" || typeof descriptor.get !== "function" || typeof descriptor.set !== "function") {
|
|
return;
|
|
}
|
|
var get2 = descriptor.get, set2 = descriptor.set;
|
|
Object.defineProperty(node, valueField, {
|
|
configurable: true,
|
|
get: function() {
|
|
return get2.call(this);
|
|
},
|
|
set: function(value) {
|
|
currentValue = "" + value;
|
|
set2.call(this, value);
|
|
}
|
|
});
|
|
Object.defineProperty(node, valueField, {
|
|
enumerable: descriptor.enumerable
|
|
});
|
|
var tracker = {
|
|
getValue: function() {
|
|
return currentValue;
|
|
},
|
|
setValue: function(value) {
|
|
currentValue = "" + value;
|
|
},
|
|
stopTracking: function() {
|
|
detachTracker(node);
|
|
delete node[valueField];
|
|
}
|
|
};
|
|
return tracker;
|
|
}
|
|
function track(node) {
|
|
if (getTracker(node)) {
|
|
return;
|
|
}
|
|
node._valueTracker = trackValueOnNode(node);
|
|
}
|
|
function updateValueIfChanged(node) {
|
|
if (!node) {
|
|
return false;
|
|
}
|
|
var tracker = getTracker(node);
|
|
if (!tracker) {
|
|
return true;
|
|
}
|
|
var lastValue = tracker.getValue();
|
|
var nextValue = getValueFromNode(node);
|
|
if (nextValue !== lastValue) {
|
|
tracker.setValue(nextValue);
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
function getActiveElement(doc) {
|
|
doc = doc || (typeof document !== "undefined" ? document : void 0);
|
|
if (typeof doc === "undefined") {
|
|
return null;
|
|
}
|
|
try {
|
|
return doc.activeElement || doc.body;
|
|
} catch (e3) {
|
|
return doc.body;
|
|
}
|
|
}
|
|
var didWarnValueDefaultValue = false;
|
|
var didWarnCheckedDefaultChecked = false;
|
|
var didWarnControlledToUncontrolled = false;
|
|
var didWarnUncontrolledToControlled = false;
|
|
function isControlled(props) {
|
|
var usesChecked = props.type === "checkbox" || props.type === "radio";
|
|
return usesChecked ? props.checked != null : props.value != null;
|
|
}
|
|
function getHostProps(element, props) {
|
|
var node = element;
|
|
var checked = props.checked;
|
|
var hostProps = _assign({}, props, {
|
|
defaultChecked: void 0,
|
|
defaultValue: void 0,
|
|
value: void 0,
|
|
checked: checked != null ? checked : node._wrapperState.initialChecked
|
|
});
|
|
return hostProps;
|
|
}
|
|
function initWrapperState(element, props) {
|
|
{
|
|
checkControlledValueProps("input", props);
|
|
if (props.checked !== void 0 && props.defaultChecked !== void 0 && !didWarnCheckedDefaultChecked) {
|
|
error("%s contains an input of type %s with both checked and defaultChecked props. Input elements must be either controlled or uncontrolled (specify either the checked prop, or the defaultChecked prop, but not both). Decide between using a controlled or uncontrolled input element and remove one of these props. More info: https://reactjs.org/link/controlled-components", getCurrentFiberOwnerNameInDevOrNull() || "A component", props.type);
|
|
didWarnCheckedDefaultChecked = true;
|
|
}
|
|
if (props.value !== void 0 && props.defaultValue !== void 0 && !didWarnValueDefaultValue) {
|
|
error("%s contains an input of type %s with both value and defaultValue props. Input elements must be either controlled or uncontrolled (specify either the value prop, or the defaultValue prop, but not both). Decide between using a controlled or uncontrolled input element and remove one of these props. More info: https://reactjs.org/link/controlled-components", getCurrentFiberOwnerNameInDevOrNull() || "A component", props.type);
|
|
didWarnValueDefaultValue = true;
|
|
}
|
|
}
|
|
var node = element;
|
|
var defaultValue = props.defaultValue == null ? "" : props.defaultValue;
|
|
node._wrapperState = {
|
|
initialChecked: props.checked != null ? props.checked : props.defaultChecked,
|
|
initialValue: getToStringValue(props.value != null ? props.value : defaultValue),
|
|
controlled: isControlled(props)
|
|
};
|
|
}
|
|
function updateChecked(element, props) {
|
|
var node = element;
|
|
var checked = props.checked;
|
|
if (checked != null) {
|
|
setValueForProperty(node, "checked", checked, false);
|
|
}
|
|
}
|
|
function updateWrapper(element, props) {
|
|
var node = element;
|
|
{
|
|
var controlled = isControlled(props);
|
|
if (!node._wrapperState.controlled && controlled && !didWarnUncontrolledToControlled) {
|
|
error("A component is changing an uncontrolled input to be controlled. This is likely caused by the value changing from undefined to a defined value, which should not happen. Decide between using a controlled or uncontrolled input element for the lifetime of the component. More info: https://reactjs.org/link/controlled-components");
|
|
didWarnUncontrolledToControlled = true;
|
|
}
|
|
if (node._wrapperState.controlled && !controlled && !didWarnControlledToUncontrolled) {
|
|
error("A component is changing a controlled input to be uncontrolled. This is likely caused by the value changing from a defined to undefined, which should not happen. Decide between using a controlled or uncontrolled input element for the lifetime of the component. More info: https://reactjs.org/link/controlled-components");
|
|
didWarnControlledToUncontrolled = true;
|
|
}
|
|
}
|
|
updateChecked(element, props);
|
|
var value = getToStringValue(props.value);
|
|
var type = props.type;
|
|
if (value != null) {
|
|
if (type === "number") {
|
|
if (value === 0 && node.value === "" || node.value != value) {
|
|
node.value = toString(value);
|
|
}
|
|
} else if (node.value !== toString(value)) {
|
|
node.value = toString(value);
|
|
}
|
|
} else if (type === "submit" || type === "reset") {
|
|
node.removeAttribute("value");
|
|
return;
|
|
}
|
|
{
|
|
if (props.hasOwnProperty("value")) {
|
|
setDefaultValue(node, props.type, value);
|
|
} else if (props.hasOwnProperty("defaultValue")) {
|
|
setDefaultValue(node, props.type, getToStringValue(props.defaultValue));
|
|
}
|
|
}
|
|
{
|
|
if (props.checked == null && props.defaultChecked != null) {
|
|
node.defaultChecked = !!props.defaultChecked;
|
|
}
|
|
}
|
|
}
|
|
function postMountWrapper(element, props, isHydrating2) {
|
|
var node = element;
|
|
if (props.hasOwnProperty("value") || props.hasOwnProperty("defaultValue")) {
|
|
var type = props.type;
|
|
var isButton = type === "submit" || type === "reset";
|
|
if (isButton && (props.value === void 0 || props.value === null)) {
|
|
return;
|
|
}
|
|
var initialValue = toString(node._wrapperState.initialValue);
|
|
if (!isHydrating2) {
|
|
{
|
|
if (initialValue !== node.value) {
|
|
node.value = initialValue;
|
|
}
|
|
}
|
|
}
|
|
{
|
|
node.defaultValue = initialValue;
|
|
}
|
|
}
|
|
var name = node.name;
|
|
if (name !== "") {
|
|
node.name = "";
|
|
}
|
|
{
|
|
node.defaultChecked = !node.defaultChecked;
|
|
node.defaultChecked = !!node._wrapperState.initialChecked;
|
|
}
|
|
if (name !== "") {
|
|
node.name = name;
|
|
}
|
|
}
|
|
function restoreControlledState(element, props) {
|
|
var node = element;
|
|
updateWrapper(node, props);
|
|
updateNamedCousins(node, props);
|
|
}
|
|
function updateNamedCousins(rootNode, props) {
|
|
var name = props.name;
|
|
if (props.type === "radio" && name != null) {
|
|
var queryRoot = rootNode;
|
|
while (queryRoot.parentNode) {
|
|
queryRoot = queryRoot.parentNode;
|
|
}
|
|
var group = queryRoot.querySelectorAll("input[name=" + JSON.stringify("" + name) + '][type="radio"]');
|
|
for (var i3 = 0; i3 < group.length; i3++) {
|
|
var otherNode = group[i3];
|
|
if (otherNode === rootNode || otherNode.form !== rootNode.form) {
|
|
continue;
|
|
}
|
|
var otherProps = getFiberCurrentPropsFromNode(otherNode);
|
|
if (!otherProps) {
|
|
{
|
|
throw Error("ReactDOMInput: Mixing React and non-React radio inputs with the same `name` is not supported.");
|
|
}
|
|
}
|
|
updateValueIfChanged(otherNode);
|
|
updateWrapper(otherNode, otherProps);
|
|
}
|
|
}
|
|
}
|
|
function setDefaultValue(node, type, value) {
|
|
if (type !== "number" || getActiveElement(node.ownerDocument) !== node) {
|
|
if (value == null) {
|
|
node.defaultValue = toString(node._wrapperState.initialValue);
|
|
} else if (node.defaultValue !== toString(value)) {
|
|
node.defaultValue = toString(value);
|
|
}
|
|
}
|
|
}
|
|
var didWarnSelectedSetOnOption = false;
|
|
var didWarnInvalidChild = false;
|
|
function flattenChildren(children) {
|
|
var content = "";
|
|
React5.Children.forEach(children, function(child) {
|
|
if (child == null) {
|
|
return;
|
|
}
|
|
content += child;
|
|
});
|
|
return content;
|
|
}
|
|
function validateProps(element, props) {
|
|
{
|
|
if (typeof props.children === "object" && props.children !== null) {
|
|
React5.Children.forEach(props.children, function(child) {
|
|
if (child == null) {
|
|
return;
|
|
}
|
|
if (typeof child === "string" || typeof child === "number") {
|
|
return;
|
|
}
|
|
if (typeof child.type !== "string") {
|
|
return;
|
|
}
|
|
if (!didWarnInvalidChild) {
|
|
didWarnInvalidChild = true;
|
|
error("Only strings and numbers are supported as <option> children.");
|
|
}
|
|
});
|
|
}
|
|
if (props.selected != null && !didWarnSelectedSetOnOption) {
|
|
error("Use the `defaultValue` or `value` props on <select> instead of setting `selected` on <option>.");
|
|
didWarnSelectedSetOnOption = true;
|
|
}
|
|
}
|
|
}
|
|
function postMountWrapper$1(element, props) {
|
|
if (props.value != null) {
|
|
element.setAttribute("value", toString(getToStringValue(props.value)));
|
|
}
|
|
}
|
|
function getHostProps$1(element, props) {
|
|
var hostProps = _assign({
|
|
children: void 0
|
|
}, props);
|
|
var content = flattenChildren(props.children);
|
|
if (content) {
|
|
hostProps.children = content;
|
|
}
|
|
return hostProps;
|
|
}
|
|
var didWarnValueDefaultValue$1;
|
|
{
|
|
didWarnValueDefaultValue$1 = false;
|
|
}
|
|
function getDeclarationErrorAddendum() {
|
|
var ownerName = getCurrentFiberOwnerNameInDevOrNull();
|
|
if (ownerName) {
|
|
return "\n\nCheck the render method of `" + ownerName + "`.";
|
|
}
|
|
return "";
|
|
}
|
|
var valuePropNames = ["value", "defaultValue"];
|
|
function checkSelectPropTypes(props) {
|
|
{
|
|
checkControlledValueProps("select", props);
|
|
for (var i3 = 0; i3 < valuePropNames.length; i3++) {
|
|
var propName = valuePropNames[i3];
|
|
if (props[propName] == null) {
|
|
continue;
|
|
}
|
|
var isArray2 = Array.isArray(props[propName]);
|
|
if (props.multiple && !isArray2) {
|
|
error("The `%s` prop supplied to <select> must be an array if `multiple` is true.%s", propName, getDeclarationErrorAddendum());
|
|
} else if (!props.multiple && isArray2) {
|
|
error("The `%s` prop supplied to <select> must be a scalar value if `multiple` is false.%s", propName, getDeclarationErrorAddendum());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
function updateOptions(node, multiple, propValue, setDefaultSelected) {
|
|
var options2 = node.options;
|
|
if (multiple) {
|
|
var selectedValues = propValue;
|
|
var selectedValue = {};
|
|
for (var i3 = 0; i3 < selectedValues.length; i3++) {
|
|
selectedValue["$" + selectedValues[i3]] = true;
|
|
}
|
|
for (var _i = 0; _i < options2.length; _i++) {
|
|
var selected = selectedValue.hasOwnProperty("$" + options2[_i].value);
|
|
if (options2[_i].selected !== selected) {
|
|
options2[_i].selected = selected;
|
|
}
|
|
if (selected && setDefaultSelected) {
|
|
options2[_i].defaultSelected = true;
|
|
}
|
|
}
|
|
} else {
|
|
var _selectedValue = toString(getToStringValue(propValue));
|
|
var defaultSelected = null;
|
|
for (var _i2 = 0; _i2 < options2.length; _i2++) {
|
|
if (options2[_i2].value === _selectedValue) {
|
|
options2[_i2].selected = true;
|
|
if (setDefaultSelected) {
|
|
options2[_i2].defaultSelected = true;
|
|
}
|
|
return;
|
|
}
|
|
if (defaultSelected === null && !options2[_i2].disabled) {
|
|
defaultSelected = options2[_i2];
|
|
}
|
|
}
|
|
if (defaultSelected !== null) {
|
|
defaultSelected.selected = true;
|
|
}
|
|
}
|
|
}
|
|
function getHostProps$2(element, props) {
|
|
return _assign({}, props, {
|
|
value: void 0
|
|
});
|
|
}
|
|
function initWrapperState$1(element, props) {
|
|
var node = element;
|
|
{
|
|
checkSelectPropTypes(props);
|
|
}
|
|
node._wrapperState = {
|
|
wasMultiple: !!props.multiple
|
|
};
|
|
{
|
|
if (props.value !== void 0 && props.defaultValue !== void 0 && !didWarnValueDefaultValue$1) {
|
|
error("Select elements must be either controlled or uncontrolled (specify either the value prop, or the defaultValue prop, but not both). Decide between using a controlled or uncontrolled select element and remove one of these props. More info: https://reactjs.org/link/controlled-components");
|
|
didWarnValueDefaultValue$1 = true;
|
|
}
|
|
}
|
|
}
|
|
function postMountWrapper$2(element, props) {
|
|
var node = element;
|
|
node.multiple = !!props.multiple;
|
|
var value = props.value;
|
|
if (value != null) {
|
|
updateOptions(node, !!props.multiple, value, false);
|
|
} else if (props.defaultValue != null) {
|
|
updateOptions(node, !!props.multiple, props.defaultValue, true);
|
|
}
|
|
}
|
|
function postUpdateWrapper(element, props) {
|
|
var node = element;
|
|
var wasMultiple = node._wrapperState.wasMultiple;
|
|
node._wrapperState.wasMultiple = !!props.multiple;
|
|
var value = props.value;
|
|
if (value != null) {
|
|
updateOptions(node, !!props.multiple, value, false);
|
|
} else if (wasMultiple !== !!props.multiple) {
|
|
if (props.defaultValue != null) {
|
|
updateOptions(node, !!props.multiple, props.defaultValue, true);
|
|
} else {
|
|
updateOptions(node, !!props.multiple, props.multiple ? [] : "", false);
|
|
}
|
|
}
|
|
}
|
|
function restoreControlledState$1(element, props) {
|
|
var node = element;
|
|
var value = props.value;
|
|
if (value != null) {
|
|
updateOptions(node, !!props.multiple, value, false);
|
|
}
|
|
}
|
|
var didWarnValDefaultVal = false;
|
|
function getHostProps$3(element, props) {
|
|
var node = element;
|
|
if (!(props.dangerouslySetInnerHTML == null)) {
|
|
{
|
|
throw Error("`dangerouslySetInnerHTML` does not make sense on <textarea>.");
|
|
}
|
|
}
|
|
var hostProps = _assign({}, props, {
|
|
value: void 0,
|
|
defaultValue: void 0,
|
|
children: toString(node._wrapperState.initialValue)
|
|
});
|
|
return hostProps;
|
|
}
|
|
function initWrapperState$2(element, props) {
|
|
var node = element;
|
|
{
|
|
checkControlledValueProps("textarea", props);
|
|
if (props.value !== void 0 && props.defaultValue !== void 0 && !didWarnValDefaultVal) {
|
|
error("%s contains a textarea with both value and defaultValue props. Textarea elements must be either controlled or uncontrolled (specify either the value prop, or the defaultValue prop, but not both). Decide between using a controlled or uncontrolled textarea and remove one of these props. More info: https://reactjs.org/link/controlled-components", getCurrentFiberOwnerNameInDevOrNull() || "A component");
|
|
didWarnValDefaultVal = true;
|
|
}
|
|
}
|
|
var initialValue = props.value;
|
|
if (initialValue == null) {
|
|
var children = props.children, defaultValue = props.defaultValue;
|
|
if (children != null) {
|
|
{
|
|
error("Use the `defaultValue` or `value` props instead of setting children on <textarea>.");
|
|
}
|
|
{
|
|
if (!(defaultValue == null)) {
|
|
{
|
|
throw Error("If you supply `defaultValue` on a <textarea>, do not pass children.");
|
|
}
|
|
}
|
|
if (Array.isArray(children)) {
|
|
if (!(children.length <= 1)) {
|
|
{
|
|
throw Error("<textarea> can only have at most one child.");
|
|
}
|
|
}
|
|
children = children[0];
|
|
}
|
|
defaultValue = children;
|
|
}
|
|
}
|
|
if (defaultValue == null) {
|
|
defaultValue = "";
|
|
}
|
|
initialValue = defaultValue;
|
|
}
|
|
node._wrapperState = {
|
|
initialValue: getToStringValue(initialValue)
|
|
};
|
|
}
|
|
function updateWrapper$1(element, props) {
|
|
var node = element;
|
|
var value = getToStringValue(props.value);
|
|
var defaultValue = getToStringValue(props.defaultValue);
|
|
if (value != null) {
|
|
var newValue = toString(value);
|
|
if (newValue !== node.value) {
|
|
node.value = newValue;
|
|
}
|
|
if (props.defaultValue == null && node.defaultValue !== newValue) {
|
|
node.defaultValue = newValue;
|
|
}
|
|
}
|
|
if (defaultValue != null) {
|
|
node.defaultValue = toString(defaultValue);
|
|
}
|
|
}
|
|
function postMountWrapper$3(element, props) {
|
|
var node = element;
|
|
var textContent = node.textContent;
|
|
if (textContent === node._wrapperState.initialValue) {
|
|
if (textContent !== "" && textContent !== null) {
|
|
node.value = textContent;
|
|
}
|
|
}
|
|
}
|
|
function restoreControlledState$2(element, props) {
|
|
updateWrapper$1(element, props);
|
|
}
|
|
var HTML_NAMESPACE = "http://www.w3.org/1999/xhtml";
|
|
var MATH_NAMESPACE = "http://www.w3.org/1998/Math/MathML";
|
|
var SVG_NAMESPACE = "http://www.w3.org/2000/svg";
|
|
var Namespaces = {
|
|
html: HTML_NAMESPACE,
|
|
mathml: MATH_NAMESPACE,
|
|
svg: SVG_NAMESPACE
|
|
};
|
|
function getIntrinsicNamespace(type) {
|
|
switch (type) {
|
|
case "svg":
|
|
return SVG_NAMESPACE;
|
|
case "math":
|
|
return MATH_NAMESPACE;
|
|
default:
|
|
return HTML_NAMESPACE;
|
|
}
|
|
}
|
|
function getChildNamespace(parentNamespace, type) {
|
|
if (parentNamespace == null || parentNamespace === HTML_NAMESPACE) {
|
|
return getIntrinsicNamespace(type);
|
|
}
|
|
if (parentNamespace === SVG_NAMESPACE && type === "foreignObject") {
|
|
return HTML_NAMESPACE;
|
|
}
|
|
return parentNamespace;
|
|
}
|
|
var createMicrosoftUnsafeLocalFunction = function(func) {
|
|
if (typeof MSApp !== "undefined" && MSApp.execUnsafeLocalFunction) {
|
|
return function(arg0, arg1, arg2, arg3) {
|
|
MSApp.execUnsafeLocalFunction(function() {
|
|
return func(arg0, arg1, arg2, arg3);
|
|
});
|
|
};
|
|
} else {
|
|
return func;
|
|
}
|
|
};
|
|
var reusableSVGContainer;
|
|
var setInnerHTML = createMicrosoftUnsafeLocalFunction(function(node, html) {
|
|
if (node.namespaceURI === Namespaces.svg) {
|
|
if (!("innerHTML" in node)) {
|
|
reusableSVGContainer = reusableSVGContainer || document.createElement("div");
|
|
reusableSVGContainer.innerHTML = "<svg>" + html.valueOf().toString() + "</svg>";
|
|
var svgNode = reusableSVGContainer.firstChild;
|
|
while (node.firstChild) {
|
|
node.removeChild(node.firstChild);
|
|
}
|
|
while (svgNode.firstChild) {
|
|
node.appendChild(svgNode.firstChild);
|
|
}
|
|
return;
|
|
}
|
|
}
|
|
node.innerHTML = html;
|
|
});
|
|
var ELEMENT_NODE = 1;
|
|
var TEXT_NODE = 3;
|
|
var COMMENT_NODE = 8;
|
|
var DOCUMENT_NODE = 9;
|
|
var DOCUMENT_FRAGMENT_NODE = 11;
|
|
var setTextContent = function(node, text) {
|
|
if (text) {
|
|
var firstChild = node.firstChild;
|
|
if (firstChild && firstChild === node.lastChild && firstChild.nodeType === TEXT_NODE) {
|
|
firstChild.nodeValue = text;
|
|
return;
|
|
}
|
|
}
|
|
node.textContent = text;
|
|
};
|
|
var shorthandToLonghand = {
|
|
animation: ["animationDelay", "animationDirection", "animationDuration", "animationFillMode", "animationIterationCount", "animationName", "animationPlayState", "animationTimingFunction"],
|
|
background: ["backgroundAttachment", "backgroundClip", "backgroundColor", "backgroundImage", "backgroundOrigin", "backgroundPositionX", "backgroundPositionY", "backgroundRepeat", "backgroundSize"],
|
|
backgroundPosition: ["backgroundPositionX", "backgroundPositionY"],
|
|
border: ["borderBottomColor", "borderBottomStyle", "borderBottomWidth", "borderImageOutset", "borderImageRepeat", "borderImageSlice", "borderImageSource", "borderImageWidth", "borderLeftColor", "borderLeftStyle", "borderLeftWidth", "borderRightColor", "borderRightStyle", "borderRightWidth", "borderTopColor", "borderTopStyle", "borderTopWidth"],
|
|
borderBlockEnd: ["borderBlockEndColor", "borderBlockEndStyle", "borderBlockEndWidth"],
|
|
borderBlockStart: ["borderBlockStartColor", "borderBlockStartStyle", "borderBlockStartWidth"],
|
|
borderBottom: ["borderBottomColor", "borderBottomStyle", "borderBottomWidth"],
|
|
borderColor: ["borderBottomColor", "borderLeftColor", "borderRightColor", "borderTopColor"],
|
|
borderImage: ["borderImageOutset", "borderImageRepeat", "borderImageSlice", "borderImageSource", "borderImageWidth"],
|
|
borderInlineEnd: ["borderInlineEndColor", "borderInlineEndStyle", "borderInlineEndWidth"],
|
|
borderInlineStart: ["borderInlineStartColor", "borderInlineStartStyle", "borderInlineStartWidth"],
|
|
borderLeft: ["borderLeftColor", "borderLeftStyle", "borderLeftWidth"],
|
|
borderRadius: ["borderBottomLeftRadius", "borderBottomRightRadius", "borderTopLeftRadius", "borderTopRightRadius"],
|
|
borderRight: ["borderRightColor", "borderRightStyle", "borderRightWidth"],
|
|
borderStyle: ["borderBottomStyle", "borderLeftStyle", "borderRightStyle", "borderTopStyle"],
|
|
borderTop: ["borderTopColor", "borderTopStyle", "borderTopWidth"],
|
|
borderWidth: ["borderBottomWidth", "borderLeftWidth", "borderRightWidth", "borderTopWidth"],
|
|
columnRule: ["columnRuleColor", "columnRuleStyle", "columnRuleWidth"],
|
|
columns: ["columnCount", "columnWidth"],
|
|
flex: ["flexBasis", "flexGrow", "flexShrink"],
|
|
flexFlow: ["flexDirection", "flexWrap"],
|
|
font: ["fontFamily", "fontFeatureSettings", "fontKerning", "fontLanguageOverride", "fontSize", "fontSizeAdjust", "fontStretch", "fontStyle", "fontVariant", "fontVariantAlternates", "fontVariantCaps", "fontVariantEastAsian", "fontVariantLigatures", "fontVariantNumeric", "fontVariantPosition", "fontWeight", "lineHeight"],
|
|
fontVariant: ["fontVariantAlternates", "fontVariantCaps", "fontVariantEastAsian", "fontVariantLigatures", "fontVariantNumeric", "fontVariantPosition"],
|
|
gap: ["columnGap", "rowGap"],
|
|
grid: ["gridAutoColumns", "gridAutoFlow", "gridAutoRows", "gridTemplateAreas", "gridTemplateColumns", "gridTemplateRows"],
|
|
gridArea: ["gridColumnEnd", "gridColumnStart", "gridRowEnd", "gridRowStart"],
|
|
gridColumn: ["gridColumnEnd", "gridColumnStart"],
|
|
gridColumnGap: ["columnGap"],
|
|
gridGap: ["columnGap", "rowGap"],
|
|
gridRow: ["gridRowEnd", "gridRowStart"],
|
|
gridRowGap: ["rowGap"],
|
|
gridTemplate: ["gridTemplateAreas", "gridTemplateColumns", "gridTemplateRows"],
|
|
listStyle: ["listStyleImage", "listStylePosition", "listStyleType"],
|
|
margin: ["marginBottom", "marginLeft", "marginRight", "marginTop"],
|
|
marker: ["markerEnd", "markerMid", "markerStart"],
|
|
mask: ["maskClip", "maskComposite", "maskImage", "maskMode", "maskOrigin", "maskPositionX", "maskPositionY", "maskRepeat", "maskSize"],
|
|
maskPosition: ["maskPositionX", "maskPositionY"],
|
|
outline: ["outlineColor", "outlineStyle", "outlineWidth"],
|
|
overflow: ["overflowX", "overflowY"],
|
|
padding: ["paddingBottom", "paddingLeft", "paddingRight", "paddingTop"],
|
|
placeContent: ["alignContent", "justifyContent"],
|
|
placeItems: ["alignItems", "justifyItems"],
|
|
placeSelf: ["alignSelf", "justifySelf"],
|
|
textDecoration: ["textDecorationColor", "textDecorationLine", "textDecorationStyle"],
|
|
textEmphasis: ["textEmphasisColor", "textEmphasisStyle"],
|
|
transition: ["transitionDelay", "transitionDuration", "transitionProperty", "transitionTimingFunction"],
|
|
wordWrap: ["overflowWrap"]
|
|
};
|
|
var isUnitlessNumber = {
|
|
animationIterationCount: true,
|
|
borderImageOutset: true,
|
|
borderImageSlice: true,
|
|
borderImageWidth: true,
|
|
boxFlex: true,
|
|
boxFlexGroup: true,
|
|
boxOrdinalGroup: true,
|
|
columnCount: true,
|
|
columns: true,
|
|
flex: true,
|
|
flexGrow: true,
|
|
flexPositive: true,
|
|
flexShrink: true,
|
|
flexNegative: true,
|
|
flexOrder: true,
|
|
gridArea: true,
|
|
gridRow: true,
|
|
gridRowEnd: true,
|
|
gridRowSpan: true,
|
|
gridRowStart: true,
|
|
gridColumn: true,
|
|
gridColumnEnd: true,
|
|
gridColumnSpan: true,
|
|
gridColumnStart: true,
|
|
fontWeight: true,
|
|
lineClamp: true,
|
|
lineHeight: true,
|
|
opacity: true,
|
|
order: true,
|
|
orphans: true,
|
|
tabSize: true,
|
|
widows: true,
|
|
zIndex: true,
|
|
zoom: true,
|
|
fillOpacity: true,
|
|
floodOpacity: true,
|
|
stopOpacity: true,
|
|
strokeDasharray: true,
|
|
strokeDashoffset: true,
|
|
strokeMiterlimit: true,
|
|
strokeOpacity: true,
|
|
strokeWidth: true
|
|
};
|
|
function prefixKey(prefix2, key) {
|
|
return prefix2 + key.charAt(0).toUpperCase() + key.substring(1);
|
|
}
|
|
var prefixes = ["Webkit", "ms", "Moz", "O"];
|
|
Object.keys(isUnitlessNumber).forEach(function(prop) {
|
|
prefixes.forEach(function(prefix2) {
|
|
isUnitlessNumber[prefixKey(prefix2, prop)] = isUnitlessNumber[prop];
|
|
});
|
|
});
|
|
function dangerousStyleValue(name, value, isCustomProperty) {
|
|
var isEmpty = value == null || typeof value === "boolean" || value === "";
|
|
if (isEmpty) {
|
|
return "";
|
|
}
|
|
if (!isCustomProperty && typeof value === "number" && value !== 0 && !(isUnitlessNumber.hasOwnProperty(name) && isUnitlessNumber[name])) {
|
|
return value + "px";
|
|
}
|
|
return ("" + value).trim();
|
|
}
|
|
var uppercasePattern = /([A-Z])/g;
|
|
var msPattern = /^ms-/;
|
|
function hyphenateStyleName(name) {
|
|
return name.replace(uppercasePattern, "-$1").toLowerCase().replace(msPattern, "-ms-");
|
|
}
|
|
var warnValidStyle = function() {
|
|
};
|
|
{
|
|
var badVendoredStyleNamePattern = /^(?:webkit|moz|o)[A-Z]/;
|
|
var msPattern$1 = /^-ms-/;
|
|
var hyphenPattern = /-(.)/g;
|
|
var badStyleValueWithSemicolonPattern = /;\s*$/;
|
|
var warnedStyleNames = {};
|
|
var warnedStyleValues = {};
|
|
var warnedForNaNValue = false;
|
|
var warnedForInfinityValue = false;
|
|
var camelize = function(string) {
|
|
return string.replace(hyphenPattern, function(_3, character) {
|
|
return character.toUpperCase();
|
|
});
|
|
};
|
|
var warnHyphenatedStyleName = function(name) {
|
|
if (warnedStyleNames.hasOwnProperty(name) && warnedStyleNames[name]) {
|
|
return;
|
|
}
|
|
warnedStyleNames[name] = true;
|
|
error("Unsupported style property %s. Did you mean %s?", name, camelize(name.replace(msPattern$1, "ms-")));
|
|
};
|
|
var warnBadVendoredStyleName = function(name) {
|
|
if (warnedStyleNames.hasOwnProperty(name) && warnedStyleNames[name]) {
|
|
return;
|
|
}
|
|
warnedStyleNames[name] = true;
|
|
error("Unsupported vendor-prefixed style property %s. Did you mean %s?", name, name.charAt(0).toUpperCase() + name.slice(1));
|
|
};
|
|
var warnStyleValueWithSemicolon = function(name, value) {
|
|
if (warnedStyleValues.hasOwnProperty(value) && warnedStyleValues[value]) {
|
|
return;
|
|
}
|
|
warnedStyleValues[value] = true;
|
|
error(`Style property values shouldn't contain a semicolon. Try "%s: %s" instead.`, name, value.replace(badStyleValueWithSemicolonPattern, ""));
|
|
};
|
|
var warnStyleValueIsNaN = function(name, value) {
|
|
if (warnedForNaNValue) {
|
|
return;
|
|
}
|
|
warnedForNaNValue = true;
|
|
error("`NaN` is an invalid value for the `%s` css style property.", name);
|
|
};
|
|
var warnStyleValueIsInfinity = function(name, value) {
|
|
if (warnedForInfinityValue) {
|
|
return;
|
|
}
|
|
warnedForInfinityValue = true;
|
|
error("`Infinity` is an invalid value for the `%s` css style property.", name);
|
|
};
|
|
warnValidStyle = function(name, value) {
|
|
if (name.indexOf("-") > -1) {
|
|
warnHyphenatedStyleName(name);
|
|
} else if (badVendoredStyleNamePattern.test(name)) {
|
|
warnBadVendoredStyleName(name);
|
|
} else if (badStyleValueWithSemicolonPattern.test(value)) {
|
|
warnStyleValueWithSemicolon(name, value);
|
|
}
|
|
if (typeof value === "number") {
|
|
if (isNaN(value)) {
|
|
warnStyleValueIsNaN(name, value);
|
|
} else if (!isFinite(value)) {
|
|
warnStyleValueIsInfinity(name, value);
|
|
}
|
|
}
|
|
};
|
|
}
|
|
var warnValidStyle$1 = warnValidStyle;
|
|
function createDangerousStringForStyles(styles) {
|
|
{
|
|
var serialized = "";
|
|
var delimiter = "";
|
|
for (var styleName in styles) {
|
|
if (!styles.hasOwnProperty(styleName)) {
|
|
continue;
|
|
}
|
|
var styleValue = styles[styleName];
|
|
if (styleValue != null) {
|
|
var isCustomProperty = styleName.indexOf("--") === 0;
|
|
serialized += delimiter + (isCustomProperty ? styleName : hyphenateStyleName(styleName)) + ":";
|
|
serialized += dangerousStyleValue(styleName, styleValue, isCustomProperty);
|
|
delimiter = ";";
|
|
}
|
|
}
|
|
return serialized || null;
|
|
}
|
|
}
|
|
function setValueForStyles(node, styles) {
|
|
var style2 = node.style;
|
|
for (var styleName in styles) {
|
|
if (!styles.hasOwnProperty(styleName)) {
|
|
continue;
|
|
}
|
|
var isCustomProperty = styleName.indexOf("--") === 0;
|
|
{
|
|
if (!isCustomProperty) {
|
|
warnValidStyle$1(styleName, styles[styleName]);
|
|
}
|
|
}
|
|
var styleValue = dangerousStyleValue(styleName, styles[styleName], isCustomProperty);
|
|
if (styleName === "float") {
|
|
styleName = "cssFloat";
|
|
}
|
|
if (isCustomProperty) {
|
|
style2.setProperty(styleName, styleValue);
|
|
} else {
|
|
style2[styleName] = styleValue;
|
|
}
|
|
}
|
|
}
|
|
function isValueEmpty(value) {
|
|
return value == null || typeof value === "boolean" || value === "";
|
|
}
|
|
function expandShorthandMap(styles) {
|
|
var expanded = {};
|
|
for (var key in styles) {
|
|
var longhands = shorthandToLonghand[key] || [key];
|
|
for (var i3 = 0; i3 < longhands.length; i3++) {
|
|
expanded[longhands[i3]] = key;
|
|
}
|
|
}
|
|
return expanded;
|
|
}
|
|
function validateShorthandPropertyCollisionInDev(styleUpdates, nextStyles) {
|
|
{
|
|
if (!nextStyles) {
|
|
return;
|
|
}
|
|
var expandedUpdates = expandShorthandMap(styleUpdates);
|
|
var expandedStyles = expandShorthandMap(nextStyles);
|
|
var warnedAbout = {};
|
|
for (var key in expandedUpdates) {
|
|
var originalKey = expandedUpdates[key];
|
|
var correctOriginalKey = expandedStyles[key];
|
|
if (correctOriginalKey && originalKey !== correctOriginalKey) {
|
|
var warningKey = originalKey + "," + correctOriginalKey;
|
|
if (warnedAbout[warningKey]) {
|
|
continue;
|
|
}
|
|
warnedAbout[warningKey] = true;
|
|
error("%s a style property during rerender (%s) when a conflicting property is set (%s) can lead to styling bugs. To avoid this, don't mix shorthand and non-shorthand properties for the same value; instead, replace the shorthand with separate values.", isValueEmpty(styleUpdates[originalKey]) ? "Removing" : "Updating", originalKey, correctOriginalKey);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
var omittedCloseTags = {
|
|
area: true,
|
|
base: true,
|
|
br: true,
|
|
col: true,
|
|
embed: true,
|
|
hr: true,
|
|
img: true,
|
|
input: true,
|
|
keygen: true,
|
|
link: true,
|
|
meta: true,
|
|
param: true,
|
|
source: true,
|
|
track: true,
|
|
wbr: true
|
|
};
|
|
var voidElementTags = _assign({
|
|
menuitem: true
|
|
}, omittedCloseTags);
|
|
var HTML = "__html";
|
|
function assertValidProps(tag, props) {
|
|
if (!props) {
|
|
return;
|
|
}
|
|
if (voidElementTags[tag]) {
|
|
if (!(props.children == null && props.dangerouslySetInnerHTML == null)) {
|
|
{
|
|
throw Error(tag + " is a void element tag and must neither have `children` nor use `dangerouslySetInnerHTML`.");
|
|
}
|
|
}
|
|
}
|
|
if (props.dangerouslySetInnerHTML != null) {
|
|
if (!(props.children == null)) {
|
|
{
|
|
throw Error("Can only set one of `children` or `props.dangerouslySetInnerHTML`.");
|
|
}
|
|
}
|
|
if (!(typeof props.dangerouslySetInnerHTML === "object" && HTML in props.dangerouslySetInnerHTML)) {
|
|
{
|
|
throw Error("`props.dangerouslySetInnerHTML` must be in the form `{__html: ...}`. Please visit https://reactjs.org/link/dangerously-set-inner-html for more information.");
|
|
}
|
|
}
|
|
}
|
|
{
|
|
if (!props.suppressContentEditableWarning && props.contentEditable && props.children != null) {
|
|
error("A component is `contentEditable` and contains `children` managed by React. It is now your responsibility to guarantee that none of those nodes are unexpectedly modified or duplicated. This is probably not intentional.");
|
|
}
|
|
}
|
|
if (!(props.style == null || typeof props.style === "object")) {
|
|
{
|
|
throw Error("The `style` prop expects a mapping from style properties to values, not a string. For example, style={{marginRight: spacing + 'em'}} when using JSX.");
|
|
}
|
|
}
|
|
}
|
|
function isCustomComponent(tagName, props) {
|
|
if (tagName.indexOf("-") === -1) {
|
|
return typeof props.is === "string";
|
|
}
|
|
switch (tagName) {
|
|
case "annotation-xml":
|
|
case "color-profile":
|
|
case "font-face":
|
|
case "font-face-src":
|
|
case "font-face-uri":
|
|
case "font-face-format":
|
|
case "font-face-name":
|
|
case "missing-glyph":
|
|
return false;
|
|
default:
|
|
return true;
|
|
}
|
|
}
|
|
var possibleStandardNames = {
|
|
accept: "accept",
|
|
acceptcharset: "acceptCharset",
|
|
"accept-charset": "acceptCharset",
|
|
accesskey: "accessKey",
|
|
action: "action",
|
|
allowfullscreen: "allowFullScreen",
|
|
alt: "alt",
|
|
as: "as",
|
|
async: "async",
|
|
autocapitalize: "autoCapitalize",
|
|
autocomplete: "autoComplete",
|
|
autocorrect: "autoCorrect",
|
|
autofocus: "autoFocus",
|
|
autoplay: "autoPlay",
|
|
autosave: "autoSave",
|
|
capture: "capture",
|
|
cellpadding: "cellPadding",
|
|
cellspacing: "cellSpacing",
|
|
challenge: "challenge",
|
|
charset: "charSet",
|
|
checked: "checked",
|
|
children: "children",
|
|
cite: "cite",
|
|
class: "className",
|
|
classid: "classID",
|
|
classname: "className",
|
|
cols: "cols",
|
|
colspan: "colSpan",
|
|
content: "content",
|
|
contenteditable: "contentEditable",
|
|
contextmenu: "contextMenu",
|
|
controls: "controls",
|
|
controlslist: "controlsList",
|
|
coords: "coords",
|
|
crossorigin: "crossOrigin",
|
|
dangerouslysetinnerhtml: "dangerouslySetInnerHTML",
|
|
data: "data",
|
|
datetime: "dateTime",
|
|
default: "default",
|
|
defaultchecked: "defaultChecked",
|
|
defaultvalue: "defaultValue",
|
|
defer: "defer",
|
|
dir: "dir",
|
|
disabled: "disabled",
|
|
disablepictureinpicture: "disablePictureInPicture",
|
|
disableremoteplayback: "disableRemotePlayback",
|
|
download: "download",
|
|
draggable: "draggable",
|
|
enctype: "encType",
|
|
enterkeyhint: "enterKeyHint",
|
|
for: "htmlFor",
|
|
form: "form",
|
|
formmethod: "formMethod",
|
|
formaction: "formAction",
|
|
formenctype: "formEncType",
|
|
formnovalidate: "formNoValidate",
|
|
formtarget: "formTarget",
|
|
frameborder: "frameBorder",
|
|
headers: "headers",
|
|
height: "height",
|
|
hidden: "hidden",
|
|
high: "high",
|
|
href: "href",
|
|
hreflang: "hrefLang",
|
|
htmlfor: "htmlFor",
|
|
httpequiv: "httpEquiv",
|
|
"http-equiv": "httpEquiv",
|
|
icon: "icon",
|
|
id: "id",
|
|
innerhtml: "innerHTML",
|
|
inputmode: "inputMode",
|
|
integrity: "integrity",
|
|
is: "is",
|
|
itemid: "itemID",
|
|
itemprop: "itemProp",
|
|
itemref: "itemRef",
|
|
itemscope: "itemScope",
|
|
itemtype: "itemType",
|
|
keyparams: "keyParams",
|
|
keytype: "keyType",
|
|
kind: "kind",
|
|
label: "label",
|
|
lang: "lang",
|
|
list: "list",
|
|
loop: "loop",
|
|
low: "low",
|
|
manifest: "manifest",
|
|
marginwidth: "marginWidth",
|
|
marginheight: "marginHeight",
|
|
max: "max",
|
|
maxlength: "maxLength",
|
|
media: "media",
|
|
mediagroup: "mediaGroup",
|
|
method: "method",
|
|
min: "min",
|
|
minlength: "minLength",
|
|
multiple: "multiple",
|
|
muted: "muted",
|
|
name: "name",
|
|
nomodule: "noModule",
|
|
nonce: "nonce",
|
|
novalidate: "noValidate",
|
|
open: "open",
|
|
optimum: "optimum",
|
|
pattern: "pattern",
|
|
placeholder: "placeholder",
|
|
playsinline: "playsInline",
|
|
poster: "poster",
|
|
preload: "preload",
|
|
profile: "profile",
|
|
radiogroup: "radioGroup",
|
|
readonly: "readOnly",
|
|
referrerpolicy: "referrerPolicy",
|
|
rel: "rel",
|
|
required: "required",
|
|
reversed: "reversed",
|
|
role: "role",
|
|
rows: "rows",
|
|
rowspan: "rowSpan",
|
|
sandbox: "sandbox",
|
|
scope: "scope",
|
|
scoped: "scoped",
|
|
scrolling: "scrolling",
|
|
seamless: "seamless",
|
|
selected: "selected",
|
|
shape: "shape",
|
|
size: "size",
|
|
sizes: "sizes",
|
|
span: "span",
|
|
spellcheck: "spellCheck",
|
|
src: "src",
|
|
srcdoc: "srcDoc",
|
|
srclang: "srcLang",
|
|
srcset: "srcSet",
|
|
start: "start",
|
|
step: "step",
|
|
style: "style",
|
|
summary: "summary",
|
|
tabindex: "tabIndex",
|
|
target: "target",
|
|
title: "title",
|
|
type: "type",
|
|
usemap: "useMap",
|
|
value: "value",
|
|
width: "width",
|
|
wmode: "wmode",
|
|
wrap: "wrap",
|
|
about: "about",
|
|
accentheight: "accentHeight",
|
|
"accent-height": "accentHeight",
|
|
accumulate: "accumulate",
|
|
additive: "additive",
|
|
alignmentbaseline: "alignmentBaseline",
|
|
"alignment-baseline": "alignmentBaseline",
|
|
allowreorder: "allowReorder",
|
|
alphabetic: "alphabetic",
|
|
amplitude: "amplitude",
|
|
arabicform: "arabicForm",
|
|
"arabic-form": "arabicForm",
|
|
ascent: "ascent",
|
|
attributename: "attributeName",
|
|
attributetype: "attributeType",
|
|
autoreverse: "autoReverse",
|
|
azimuth: "azimuth",
|
|
basefrequency: "baseFrequency",
|
|
baselineshift: "baselineShift",
|
|
"baseline-shift": "baselineShift",
|
|
baseprofile: "baseProfile",
|
|
bbox: "bbox",
|
|
begin: "begin",
|
|
bias: "bias",
|
|
by: "by",
|
|
calcmode: "calcMode",
|
|
capheight: "capHeight",
|
|
"cap-height": "capHeight",
|
|
clip: "clip",
|
|
clippath: "clipPath",
|
|
"clip-path": "clipPath",
|
|
clippathunits: "clipPathUnits",
|
|
cliprule: "clipRule",
|
|
"clip-rule": "clipRule",
|
|
color: "color",
|
|
colorinterpolation: "colorInterpolation",
|
|
"color-interpolation": "colorInterpolation",
|
|
colorinterpolationfilters: "colorInterpolationFilters",
|
|
"color-interpolation-filters": "colorInterpolationFilters",
|
|
colorprofile: "colorProfile",
|
|
"color-profile": "colorProfile",
|
|
colorrendering: "colorRendering",
|
|
"color-rendering": "colorRendering",
|
|
contentscripttype: "contentScriptType",
|
|
contentstyletype: "contentStyleType",
|
|
cursor: "cursor",
|
|
cx: "cx",
|
|
cy: "cy",
|
|
d: "d",
|
|
datatype: "datatype",
|
|
decelerate: "decelerate",
|
|
descent: "descent",
|
|
diffuseconstant: "diffuseConstant",
|
|
direction: "direction",
|
|
display: "display",
|
|
divisor: "divisor",
|
|
dominantbaseline: "dominantBaseline",
|
|
"dominant-baseline": "dominantBaseline",
|
|
dur: "dur",
|
|
dx: "dx",
|
|
dy: "dy",
|
|
edgemode: "edgeMode",
|
|
elevation: "elevation",
|
|
enablebackground: "enableBackground",
|
|
"enable-background": "enableBackground",
|
|
end: "end",
|
|
exponent: "exponent",
|
|
externalresourcesrequired: "externalResourcesRequired",
|
|
fill: "fill",
|
|
fillopacity: "fillOpacity",
|
|
"fill-opacity": "fillOpacity",
|
|
fillrule: "fillRule",
|
|
"fill-rule": "fillRule",
|
|
filter: "filter",
|
|
filterres: "filterRes",
|
|
filterunits: "filterUnits",
|
|
floodopacity: "floodOpacity",
|
|
"flood-opacity": "floodOpacity",
|
|
floodcolor: "floodColor",
|
|
"flood-color": "floodColor",
|
|
focusable: "focusable",
|
|
fontfamily: "fontFamily",
|
|
"font-family": "fontFamily",
|
|
fontsize: "fontSize",
|
|
"font-size": "fontSize",
|
|
fontsizeadjust: "fontSizeAdjust",
|
|
"font-size-adjust": "fontSizeAdjust",
|
|
fontstretch: "fontStretch",
|
|
"font-stretch": "fontStretch",
|
|
fontstyle: "fontStyle",
|
|
"font-style": "fontStyle",
|
|
fontvariant: "fontVariant",
|
|
"font-variant": "fontVariant",
|
|
fontweight: "fontWeight",
|
|
"font-weight": "fontWeight",
|
|
format: "format",
|
|
from: "from",
|
|
fx: "fx",
|
|
fy: "fy",
|
|
g1: "g1",
|
|
g2: "g2",
|
|
glyphname: "glyphName",
|
|
"glyph-name": "glyphName",
|
|
glyphorientationhorizontal: "glyphOrientationHorizontal",
|
|
"glyph-orientation-horizontal": "glyphOrientationHorizontal",
|
|
glyphorientationvertical: "glyphOrientationVertical",
|
|
"glyph-orientation-vertical": "glyphOrientationVertical",
|
|
glyphref: "glyphRef",
|
|
gradienttransform: "gradientTransform",
|
|
gradientunits: "gradientUnits",
|
|
hanging: "hanging",
|
|
horizadvx: "horizAdvX",
|
|
"horiz-adv-x": "horizAdvX",
|
|
horizoriginx: "horizOriginX",
|
|
"horiz-origin-x": "horizOriginX",
|
|
ideographic: "ideographic",
|
|
imagerendering: "imageRendering",
|
|
"image-rendering": "imageRendering",
|
|
in2: "in2",
|
|
in: "in",
|
|
inlist: "inlist",
|
|
intercept: "intercept",
|
|
k1: "k1",
|
|
k2: "k2",
|
|
k3: "k3",
|
|
k4: "k4",
|
|
k: "k",
|
|
kernelmatrix: "kernelMatrix",
|
|
kernelunitlength: "kernelUnitLength",
|
|
kerning: "kerning",
|
|
keypoints: "keyPoints",
|
|
keysplines: "keySplines",
|
|
keytimes: "keyTimes",
|
|
lengthadjust: "lengthAdjust",
|
|
letterspacing: "letterSpacing",
|
|
"letter-spacing": "letterSpacing",
|
|
lightingcolor: "lightingColor",
|
|
"lighting-color": "lightingColor",
|
|
limitingconeangle: "limitingConeAngle",
|
|
local: "local",
|
|
markerend: "markerEnd",
|
|
"marker-end": "markerEnd",
|
|
markerheight: "markerHeight",
|
|
markermid: "markerMid",
|
|
"marker-mid": "markerMid",
|
|
markerstart: "markerStart",
|
|
"marker-start": "markerStart",
|
|
markerunits: "markerUnits",
|
|
markerwidth: "markerWidth",
|
|
mask: "mask",
|
|
maskcontentunits: "maskContentUnits",
|
|
maskunits: "maskUnits",
|
|
mathematical: "mathematical",
|
|
mode: "mode",
|
|
numoctaves: "numOctaves",
|
|
offset: "offset",
|
|
opacity: "opacity",
|
|
operator: "operator",
|
|
order: "order",
|
|
orient: "orient",
|
|
orientation: "orientation",
|
|
origin: "origin",
|
|
overflow: "overflow",
|
|
overlineposition: "overlinePosition",
|
|
"overline-position": "overlinePosition",
|
|
overlinethickness: "overlineThickness",
|
|
"overline-thickness": "overlineThickness",
|
|
paintorder: "paintOrder",
|
|
"paint-order": "paintOrder",
|
|
panose1: "panose1",
|
|
"panose-1": "panose1",
|
|
pathlength: "pathLength",
|
|
patterncontentunits: "patternContentUnits",
|
|
patterntransform: "patternTransform",
|
|
patternunits: "patternUnits",
|
|
pointerevents: "pointerEvents",
|
|
"pointer-events": "pointerEvents",
|
|
points: "points",
|
|
pointsatx: "pointsAtX",
|
|
pointsaty: "pointsAtY",
|
|
pointsatz: "pointsAtZ",
|
|
prefix: "prefix",
|
|
preservealpha: "preserveAlpha",
|
|
preserveaspectratio: "preserveAspectRatio",
|
|
primitiveunits: "primitiveUnits",
|
|
property: "property",
|
|
r: "r",
|
|
radius: "radius",
|
|
refx: "refX",
|
|
refy: "refY",
|
|
renderingintent: "renderingIntent",
|
|
"rendering-intent": "renderingIntent",
|
|
repeatcount: "repeatCount",
|
|
repeatdur: "repeatDur",
|
|
requiredextensions: "requiredExtensions",
|
|
requiredfeatures: "requiredFeatures",
|
|
resource: "resource",
|
|
restart: "restart",
|
|
result: "result",
|
|
results: "results",
|
|
rotate: "rotate",
|
|
rx: "rx",
|
|
ry: "ry",
|
|
scale: "scale",
|
|
security: "security",
|
|
seed: "seed",
|
|
shaperendering: "shapeRendering",
|
|
"shape-rendering": "shapeRendering",
|
|
slope: "slope",
|
|
spacing: "spacing",
|
|
specularconstant: "specularConstant",
|
|
specularexponent: "specularExponent",
|
|
speed: "speed",
|
|
spreadmethod: "spreadMethod",
|
|
startoffset: "startOffset",
|
|
stddeviation: "stdDeviation",
|
|
stemh: "stemh",
|
|
stemv: "stemv",
|
|
stitchtiles: "stitchTiles",
|
|
stopcolor: "stopColor",
|
|
"stop-color": "stopColor",
|
|
stopopacity: "stopOpacity",
|
|
"stop-opacity": "stopOpacity",
|
|
strikethroughposition: "strikethroughPosition",
|
|
"strikethrough-position": "strikethroughPosition",
|
|
strikethroughthickness: "strikethroughThickness",
|
|
"strikethrough-thickness": "strikethroughThickness",
|
|
string: "string",
|
|
stroke: "stroke",
|
|
strokedasharray: "strokeDasharray",
|
|
"stroke-dasharray": "strokeDasharray",
|
|
strokedashoffset: "strokeDashoffset",
|
|
"stroke-dashoffset": "strokeDashoffset",
|
|
strokelinecap: "strokeLinecap",
|
|
"stroke-linecap": "strokeLinecap",
|
|
strokelinejoin: "strokeLinejoin",
|
|
"stroke-linejoin": "strokeLinejoin",
|
|
strokemiterlimit: "strokeMiterlimit",
|
|
"stroke-miterlimit": "strokeMiterlimit",
|
|
strokewidth: "strokeWidth",
|
|
"stroke-width": "strokeWidth",
|
|
strokeopacity: "strokeOpacity",
|
|
"stroke-opacity": "strokeOpacity",
|
|
suppresscontenteditablewarning: "suppressContentEditableWarning",
|
|
suppresshydrationwarning: "suppressHydrationWarning",
|
|
surfacescale: "surfaceScale",
|
|
systemlanguage: "systemLanguage",
|
|
tablevalues: "tableValues",
|
|
targetx: "targetX",
|
|
targety: "targetY",
|
|
textanchor: "textAnchor",
|
|
"text-anchor": "textAnchor",
|
|
textdecoration: "textDecoration",
|
|
"text-decoration": "textDecoration",
|
|
textlength: "textLength",
|
|
textrendering: "textRendering",
|
|
"text-rendering": "textRendering",
|
|
to: "to",
|
|
transform: "transform",
|
|
typeof: "typeof",
|
|
u1: "u1",
|
|
u2: "u2",
|
|
underlineposition: "underlinePosition",
|
|
"underline-position": "underlinePosition",
|
|
underlinethickness: "underlineThickness",
|
|
"underline-thickness": "underlineThickness",
|
|
unicode: "unicode",
|
|
unicodebidi: "unicodeBidi",
|
|
"unicode-bidi": "unicodeBidi",
|
|
unicoderange: "unicodeRange",
|
|
"unicode-range": "unicodeRange",
|
|
unitsperem: "unitsPerEm",
|
|
"units-per-em": "unitsPerEm",
|
|
unselectable: "unselectable",
|
|
valphabetic: "vAlphabetic",
|
|
"v-alphabetic": "vAlphabetic",
|
|
values: "values",
|
|
vectoreffect: "vectorEffect",
|
|
"vector-effect": "vectorEffect",
|
|
version: "version",
|
|
vertadvy: "vertAdvY",
|
|
"vert-adv-y": "vertAdvY",
|
|
vertoriginx: "vertOriginX",
|
|
"vert-origin-x": "vertOriginX",
|
|
vertoriginy: "vertOriginY",
|
|
"vert-origin-y": "vertOriginY",
|
|
vhanging: "vHanging",
|
|
"v-hanging": "vHanging",
|
|
videographic: "vIdeographic",
|
|
"v-ideographic": "vIdeographic",
|
|
viewbox: "viewBox",
|
|
viewtarget: "viewTarget",
|
|
visibility: "visibility",
|
|
vmathematical: "vMathematical",
|
|
"v-mathematical": "vMathematical",
|
|
vocab: "vocab",
|
|
widths: "widths",
|
|
wordspacing: "wordSpacing",
|
|
"word-spacing": "wordSpacing",
|
|
writingmode: "writingMode",
|
|
"writing-mode": "writingMode",
|
|
x1: "x1",
|
|
x2: "x2",
|
|
x: "x",
|
|
xchannelselector: "xChannelSelector",
|
|
xheight: "xHeight",
|
|
"x-height": "xHeight",
|
|
xlinkactuate: "xlinkActuate",
|
|
"xlink:actuate": "xlinkActuate",
|
|
xlinkarcrole: "xlinkArcrole",
|
|
"xlink:arcrole": "xlinkArcrole",
|
|
xlinkhref: "xlinkHref",
|
|
"xlink:href": "xlinkHref",
|
|
xlinkrole: "xlinkRole",
|
|
"xlink:role": "xlinkRole",
|
|
xlinkshow: "xlinkShow",
|
|
"xlink:show": "xlinkShow",
|
|
xlinktitle: "xlinkTitle",
|
|
"xlink:title": "xlinkTitle",
|
|
xlinktype: "xlinkType",
|
|
"xlink:type": "xlinkType",
|
|
xmlbase: "xmlBase",
|
|
"xml:base": "xmlBase",
|
|
xmllang: "xmlLang",
|
|
"xml:lang": "xmlLang",
|
|
xmlns: "xmlns",
|
|
"xml:space": "xmlSpace",
|
|
xmlnsxlink: "xmlnsXlink",
|
|
"xmlns:xlink": "xmlnsXlink",
|
|
xmlspace: "xmlSpace",
|
|
y1: "y1",
|
|
y2: "y2",
|
|
y: "y",
|
|
ychannelselector: "yChannelSelector",
|
|
z: "z",
|
|
zoomandpan: "zoomAndPan"
|
|
};
|
|
var ariaProperties = {
|
|
"aria-current": 0,
|
|
"aria-details": 0,
|
|
"aria-disabled": 0,
|
|
"aria-hidden": 0,
|
|
"aria-invalid": 0,
|
|
"aria-keyshortcuts": 0,
|
|
"aria-label": 0,
|
|
"aria-roledescription": 0,
|
|
"aria-autocomplete": 0,
|
|
"aria-checked": 0,
|
|
"aria-expanded": 0,
|
|
"aria-haspopup": 0,
|
|
"aria-level": 0,
|
|
"aria-modal": 0,
|
|
"aria-multiline": 0,
|
|
"aria-multiselectable": 0,
|
|
"aria-orientation": 0,
|
|
"aria-placeholder": 0,
|
|
"aria-pressed": 0,
|
|
"aria-readonly": 0,
|
|
"aria-required": 0,
|
|
"aria-selected": 0,
|
|
"aria-sort": 0,
|
|
"aria-valuemax": 0,
|
|
"aria-valuemin": 0,
|
|
"aria-valuenow": 0,
|
|
"aria-valuetext": 0,
|
|
"aria-atomic": 0,
|
|
"aria-busy": 0,
|
|
"aria-live": 0,
|
|
"aria-relevant": 0,
|
|
"aria-dropeffect": 0,
|
|
"aria-grabbed": 0,
|
|
"aria-activedescendant": 0,
|
|
"aria-colcount": 0,
|
|
"aria-colindex": 0,
|
|
"aria-colspan": 0,
|
|
"aria-controls": 0,
|
|
"aria-describedby": 0,
|
|
"aria-errormessage": 0,
|
|
"aria-flowto": 0,
|
|
"aria-labelledby": 0,
|
|
"aria-owns": 0,
|
|
"aria-posinset": 0,
|
|
"aria-rowcount": 0,
|
|
"aria-rowindex": 0,
|
|
"aria-rowspan": 0,
|
|
"aria-setsize": 0
|
|
};
|
|
var warnedProperties = {};
|
|
var rARIA = new RegExp("^(aria)-[" + ATTRIBUTE_NAME_CHAR + "]*$");
|
|
var rARIACamel = new RegExp("^(aria)[A-Z][" + ATTRIBUTE_NAME_CHAR + "]*$");
|
|
var hasOwnProperty$1 = Object.prototype.hasOwnProperty;
|
|
function validateProperty(tagName, name) {
|
|
{
|
|
if (hasOwnProperty$1.call(warnedProperties, name) && warnedProperties[name]) {
|
|
return true;
|
|
}
|
|
if (rARIACamel.test(name)) {
|
|
var ariaName = "aria-" + name.slice(4).toLowerCase();
|
|
var correctName = ariaProperties.hasOwnProperty(ariaName) ? ariaName : null;
|
|
if (correctName == null) {
|
|
error("Invalid ARIA attribute `%s`. ARIA attributes follow the pattern aria-* and must be lowercase.", name);
|
|
warnedProperties[name] = true;
|
|
return true;
|
|
}
|
|
if (name !== correctName) {
|
|
error("Invalid ARIA attribute `%s`. Did you mean `%s`?", name, correctName);
|
|
warnedProperties[name] = true;
|
|
return true;
|
|
}
|
|
}
|
|
if (rARIA.test(name)) {
|
|
var lowerCasedName = name.toLowerCase();
|
|
var standardName = ariaProperties.hasOwnProperty(lowerCasedName) ? lowerCasedName : null;
|
|
if (standardName == null) {
|
|
warnedProperties[name] = true;
|
|
return false;
|
|
}
|
|
if (name !== standardName) {
|
|
error("Unknown ARIA attribute `%s`. Did you mean `%s`?", name, standardName);
|
|
warnedProperties[name] = true;
|
|
return true;
|
|
}
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
function warnInvalidARIAProps(type, props) {
|
|
{
|
|
var invalidProps = [];
|
|
for (var key in props) {
|
|
var isValid = validateProperty(type, key);
|
|
if (!isValid) {
|
|
invalidProps.push(key);
|
|
}
|
|
}
|
|
var unknownPropString = invalidProps.map(function(prop) {
|
|
return "`" + prop + "`";
|
|
}).join(", ");
|
|
if (invalidProps.length === 1) {
|
|
error("Invalid aria prop %s on <%s> tag. For details, see https://reactjs.org/link/invalid-aria-props", unknownPropString, type);
|
|
} else if (invalidProps.length > 1) {
|
|
error("Invalid aria props %s on <%s> tag. For details, see https://reactjs.org/link/invalid-aria-props", unknownPropString, type);
|
|
}
|
|
}
|
|
}
|
|
function validateProperties(type, props) {
|
|
if (isCustomComponent(type, props)) {
|
|
return;
|
|
}
|
|
warnInvalidARIAProps(type, props);
|
|
}
|
|
var didWarnValueNull = false;
|
|
function validateProperties$1(type, props) {
|
|
{
|
|
if (type !== "input" && type !== "textarea" && type !== "select") {
|
|
return;
|
|
}
|
|
if (props != null && props.value === null && !didWarnValueNull) {
|
|
didWarnValueNull = true;
|
|
if (type === "select" && props.multiple) {
|
|
error("`value` prop on `%s` should not be null. Consider using an empty array when `multiple` is set to `true` to clear the component or `undefined` for uncontrolled components.", type);
|
|
} else {
|
|
error("`value` prop on `%s` should not be null. Consider using an empty string to clear the component or `undefined` for uncontrolled components.", type);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
var validateProperty$1 = function() {
|
|
};
|
|
{
|
|
var warnedProperties$1 = {};
|
|
var _hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
var EVENT_NAME_REGEX = /^on./;
|
|
var INVALID_EVENT_NAME_REGEX = /^on[^A-Z]/;
|
|
var rARIA$1 = new RegExp("^(aria)-[" + ATTRIBUTE_NAME_CHAR + "]*$");
|
|
var rARIACamel$1 = new RegExp("^(aria)[A-Z][" + ATTRIBUTE_NAME_CHAR + "]*$");
|
|
validateProperty$1 = function(tagName, name, value, eventRegistry) {
|
|
if (_hasOwnProperty.call(warnedProperties$1, name) && warnedProperties$1[name]) {
|
|
return true;
|
|
}
|
|
var lowerCasedName = name.toLowerCase();
|
|
if (lowerCasedName === "onfocusin" || lowerCasedName === "onfocusout") {
|
|
error("React uses onFocus and onBlur instead of onFocusIn and onFocusOut. All React events are normalized to bubble, so onFocusIn and onFocusOut are not needed/supported by React.");
|
|
warnedProperties$1[name] = true;
|
|
return true;
|
|
}
|
|
if (eventRegistry != null) {
|
|
var registrationNameDependencies2 = eventRegistry.registrationNameDependencies, possibleRegistrationNames2 = eventRegistry.possibleRegistrationNames;
|
|
if (registrationNameDependencies2.hasOwnProperty(name)) {
|
|
return true;
|
|
}
|
|
var registrationName = possibleRegistrationNames2.hasOwnProperty(lowerCasedName) ? possibleRegistrationNames2[lowerCasedName] : null;
|
|
if (registrationName != null) {
|
|
error("Invalid event handler property `%s`. Did you mean `%s`?", name, registrationName);
|
|
warnedProperties$1[name] = true;
|
|
return true;
|
|
}
|
|
if (EVENT_NAME_REGEX.test(name)) {
|
|
error("Unknown event handler property `%s`. It will be ignored.", name);
|
|
warnedProperties$1[name] = true;
|
|
return true;
|
|
}
|
|
} else if (EVENT_NAME_REGEX.test(name)) {
|
|
if (INVALID_EVENT_NAME_REGEX.test(name)) {
|
|
error("Invalid event handler property `%s`. React events use the camelCase naming convention, for example `onClick`.", name);
|
|
}
|
|
warnedProperties$1[name] = true;
|
|
return true;
|
|
}
|
|
if (rARIA$1.test(name) || rARIACamel$1.test(name)) {
|
|
return true;
|
|
}
|
|
if (lowerCasedName === "innerhtml") {
|
|
error("Directly setting property `innerHTML` is not permitted. For more information, lookup documentation on `dangerouslySetInnerHTML`.");
|
|
warnedProperties$1[name] = true;
|
|
return true;
|
|
}
|
|
if (lowerCasedName === "aria") {
|
|
error("The `aria` attribute is reserved for future use in React. Pass individual `aria-` attributes instead.");
|
|
warnedProperties$1[name] = true;
|
|
return true;
|
|
}
|
|
if (lowerCasedName === "is" && value !== null && value !== void 0 && typeof value !== "string") {
|
|
error("Received a `%s` for a string attribute `is`. If this is expected, cast the value to a string.", typeof value);
|
|
warnedProperties$1[name] = true;
|
|
return true;
|
|
}
|
|
if (typeof value === "number" && isNaN(value)) {
|
|
error("Received NaN for the `%s` attribute. If this is expected, cast the value to a string.", name);
|
|
warnedProperties$1[name] = true;
|
|
return true;
|
|
}
|
|
var propertyInfo = getPropertyInfo(name);
|
|
var isReserved = propertyInfo !== null && propertyInfo.type === RESERVED;
|
|
if (possibleStandardNames.hasOwnProperty(lowerCasedName)) {
|
|
var standardName = possibleStandardNames[lowerCasedName];
|
|
if (standardName !== name) {
|
|
error("Invalid DOM property `%s`. Did you mean `%s`?", name, standardName);
|
|
warnedProperties$1[name] = true;
|
|
return true;
|
|
}
|
|
} else if (!isReserved && name !== lowerCasedName) {
|
|
error("React does not recognize the `%s` prop on a DOM element. If you intentionally want it to appear in the DOM as a custom attribute, spell it as lowercase `%s` instead. If you accidentally passed it from a parent component, remove it from the DOM element.", name, lowerCasedName);
|
|
warnedProperties$1[name] = true;
|
|
return true;
|
|
}
|
|
if (typeof value === "boolean" && shouldRemoveAttributeWithWarning(name, value, propertyInfo, false)) {
|
|
if (value) {
|
|
error('Received `%s` for a non-boolean attribute `%s`.\n\nIf you want to write it to the DOM, pass a string instead: %s="%s" or %s={value.toString()}.', value, name, name, value, name);
|
|
} else {
|
|
error('Received `%s` for a non-boolean attribute `%s`.\n\nIf you want to write it to the DOM, pass a string instead: %s="%s" or %s={value.toString()}.\n\nIf you used to conditionally omit it with %s={condition && value}, pass %s={condition ? value : undefined} instead.', value, name, name, value, name, name, name);
|
|
}
|
|
warnedProperties$1[name] = true;
|
|
return true;
|
|
}
|
|
if (isReserved) {
|
|
return true;
|
|
}
|
|
if (shouldRemoveAttributeWithWarning(name, value, propertyInfo, false)) {
|
|
warnedProperties$1[name] = true;
|
|
return false;
|
|
}
|
|
if ((value === "false" || value === "true") && propertyInfo !== null && propertyInfo.type === BOOLEAN) {
|
|
error("Received the string `%s` for the boolean attribute `%s`. %s Did you mean %s={%s}?", value, name, value === "false" ? "The browser will interpret it as a truthy value." : 'Although this works, it will not work as expected if you pass the string "false".', name, value);
|
|
warnedProperties$1[name] = true;
|
|
return true;
|
|
}
|
|
return true;
|
|
};
|
|
}
|
|
var warnUnknownProperties = function(type, props, eventRegistry) {
|
|
{
|
|
var unknownProps = [];
|
|
for (var key in props) {
|
|
var isValid = validateProperty$1(type, key, props[key], eventRegistry);
|
|
if (!isValid) {
|
|
unknownProps.push(key);
|
|
}
|
|
}
|
|
var unknownPropString = unknownProps.map(function(prop) {
|
|
return "`" + prop + "`";
|
|
}).join(", ");
|
|
if (unknownProps.length === 1) {
|
|
error("Invalid value for prop %s on <%s> tag. Either remove it from the element, or pass a string or number value to keep it in the DOM. For details, see https://reactjs.org/link/attribute-behavior ", unknownPropString, type);
|
|
} else if (unknownProps.length > 1) {
|
|
error("Invalid values for props %s on <%s> tag. Either remove them from the element, or pass a string or number value to keep them in the DOM. For details, see https://reactjs.org/link/attribute-behavior ", unknownPropString, type);
|
|
}
|
|
}
|
|
};
|
|
function validateProperties$2(type, props, eventRegistry) {
|
|
if (isCustomComponent(type, props)) {
|
|
return;
|
|
}
|
|
warnUnknownProperties(type, props, eventRegistry);
|
|
}
|
|
var IS_EVENT_HANDLE_NON_MANAGED_NODE = 1;
|
|
var IS_NON_DELEGATED = 1 << 1;
|
|
var IS_CAPTURE_PHASE = 1 << 2;
|
|
var IS_REPLAYED = 1 << 4;
|
|
var SHOULD_NOT_PROCESS_POLYFILL_EVENT_PLUGINS = IS_EVENT_HANDLE_NON_MANAGED_NODE | IS_NON_DELEGATED | IS_CAPTURE_PHASE;
|
|
function getEventTarget(nativeEvent) {
|
|
var target = nativeEvent.target || nativeEvent.srcElement || window;
|
|
if (target.correspondingUseElement) {
|
|
target = target.correspondingUseElement;
|
|
}
|
|
return target.nodeType === TEXT_NODE ? target.parentNode : target;
|
|
}
|
|
var restoreImpl = null;
|
|
var restoreTarget = null;
|
|
var restoreQueue = null;
|
|
function restoreStateOfTarget(target) {
|
|
var internalInstance = getInstanceFromNode(target);
|
|
if (!internalInstance) {
|
|
return;
|
|
}
|
|
if (!(typeof restoreImpl === "function")) {
|
|
{
|
|
throw Error("setRestoreImplementation() needs to be called to handle a target for controlled events. This error is likely caused by a bug in React. Please file an issue.");
|
|
}
|
|
}
|
|
var stateNode = internalInstance.stateNode;
|
|
if (stateNode) {
|
|
var _props = getFiberCurrentPropsFromNode(stateNode);
|
|
restoreImpl(internalInstance.stateNode, internalInstance.type, _props);
|
|
}
|
|
}
|
|
function setRestoreImplementation(impl) {
|
|
restoreImpl = impl;
|
|
}
|
|
function enqueueStateRestore(target) {
|
|
if (restoreTarget) {
|
|
if (restoreQueue) {
|
|
restoreQueue.push(target);
|
|
} else {
|
|
restoreQueue = [target];
|
|
}
|
|
} else {
|
|
restoreTarget = target;
|
|
}
|
|
}
|
|
function needsStateRestore() {
|
|
return restoreTarget !== null || restoreQueue !== null;
|
|
}
|
|
function restoreStateIfNeeded() {
|
|
if (!restoreTarget) {
|
|
return;
|
|
}
|
|
var target = restoreTarget;
|
|
var queuedTargets = restoreQueue;
|
|
restoreTarget = null;
|
|
restoreQueue = null;
|
|
restoreStateOfTarget(target);
|
|
if (queuedTargets) {
|
|
for (var i3 = 0; i3 < queuedTargets.length; i3++) {
|
|
restoreStateOfTarget(queuedTargets[i3]);
|
|
}
|
|
}
|
|
}
|
|
var batchedUpdatesImpl = function(fn, bookkeeping) {
|
|
return fn(bookkeeping);
|
|
};
|
|
var discreteUpdatesImpl = function(fn, a3, b3, c3, d3) {
|
|
return fn(a3, b3, c3, d3);
|
|
};
|
|
var flushDiscreteUpdatesImpl = function() {
|
|
};
|
|
var batchedEventUpdatesImpl = batchedUpdatesImpl;
|
|
var isInsideEventHandler = false;
|
|
var isBatchingEventUpdates = false;
|
|
function finishEventHandler() {
|
|
var controlledComponentsHavePendingUpdates = needsStateRestore();
|
|
if (controlledComponentsHavePendingUpdates) {
|
|
flushDiscreteUpdatesImpl();
|
|
restoreStateIfNeeded();
|
|
}
|
|
}
|
|
function batchedUpdates(fn, bookkeeping) {
|
|
if (isInsideEventHandler) {
|
|
return fn(bookkeeping);
|
|
}
|
|
isInsideEventHandler = true;
|
|
try {
|
|
return batchedUpdatesImpl(fn, bookkeeping);
|
|
} finally {
|
|
isInsideEventHandler = false;
|
|
finishEventHandler();
|
|
}
|
|
}
|
|
function batchedEventUpdates(fn, a3, b3) {
|
|
if (isBatchingEventUpdates) {
|
|
return fn(a3, b3);
|
|
}
|
|
isBatchingEventUpdates = true;
|
|
try {
|
|
return batchedEventUpdatesImpl(fn, a3, b3);
|
|
} finally {
|
|
isBatchingEventUpdates = false;
|
|
finishEventHandler();
|
|
}
|
|
}
|
|
function discreteUpdates(fn, a3, b3, c3, d3) {
|
|
var prevIsInsideEventHandler = isInsideEventHandler;
|
|
isInsideEventHandler = true;
|
|
try {
|
|
return discreteUpdatesImpl(fn, a3, b3, c3, d3);
|
|
} finally {
|
|
isInsideEventHandler = prevIsInsideEventHandler;
|
|
if (!isInsideEventHandler) {
|
|
finishEventHandler();
|
|
}
|
|
}
|
|
}
|
|
function flushDiscreteUpdatesIfNeeded(timeStamp) {
|
|
{
|
|
if (!isInsideEventHandler) {
|
|
flushDiscreteUpdatesImpl();
|
|
}
|
|
}
|
|
}
|
|
function setBatchingImplementation(_batchedUpdatesImpl, _discreteUpdatesImpl, _flushDiscreteUpdatesImpl, _batchedEventUpdatesImpl) {
|
|
batchedUpdatesImpl = _batchedUpdatesImpl;
|
|
discreteUpdatesImpl = _discreteUpdatesImpl;
|
|
flushDiscreteUpdatesImpl = _flushDiscreteUpdatesImpl;
|
|
batchedEventUpdatesImpl = _batchedEventUpdatesImpl;
|
|
}
|
|
function isInteractive(tag) {
|
|
return tag === "button" || tag === "input" || tag === "select" || tag === "textarea";
|
|
}
|
|
function shouldPreventMouseEvent(name, type, props) {
|
|
switch (name) {
|
|
case "onClick":
|
|
case "onClickCapture":
|
|
case "onDoubleClick":
|
|
case "onDoubleClickCapture":
|
|
case "onMouseDown":
|
|
case "onMouseDownCapture":
|
|
case "onMouseMove":
|
|
case "onMouseMoveCapture":
|
|
case "onMouseUp":
|
|
case "onMouseUpCapture":
|
|
case "onMouseEnter":
|
|
return !!(props.disabled && isInteractive(type));
|
|
default:
|
|
return false;
|
|
}
|
|
}
|
|
function getListener(inst, registrationName) {
|
|
var stateNode = inst.stateNode;
|
|
if (stateNode === null) {
|
|
return null;
|
|
}
|
|
var props = getFiberCurrentPropsFromNode(stateNode);
|
|
if (props === null) {
|
|
return null;
|
|
}
|
|
var listener = props[registrationName];
|
|
if (shouldPreventMouseEvent(registrationName, inst.type, props)) {
|
|
return null;
|
|
}
|
|
if (!(!listener || typeof listener === "function")) {
|
|
{
|
|
throw Error("Expected `" + registrationName + "` listener to be a function, instead got a value of `" + typeof listener + "` type.");
|
|
}
|
|
}
|
|
return listener;
|
|
}
|
|
var passiveBrowserEventsSupported = false;
|
|
if (canUseDOM) {
|
|
try {
|
|
var options = {};
|
|
Object.defineProperty(options, "passive", {
|
|
get: function() {
|
|
passiveBrowserEventsSupported = true;
|
|
}
|
|
});
|
|
window.addEventListener("test", options, options);
|
|
window.removeEventListener("test", options, options);
|
|
} catch (e3) {
|
|
passiveBrowserEventsSupported = false;
|
|
}
|
|
}
|
|
function invokeGuardedCallbackProd(name, func, context, a3, b3, c3, d3, e3, f3) {
|
|
var funcArgs = Array.prototype.slice.call(arguments, 3);
|
|
try {
|
|
func.apply(context, funcArgs);
|
|
} catch (error2) {
|
|
this.onError(error2);
|
|
}
|
|
}
|
|
var invokeGuardedCallbackImpl = invokeGuardedCallbackProd;
|
|
{
|
|
if (typeof window !== "undefined" && typeof window.dispatchEvent === "function" && typeof document !== "undefined" && typeof document.createEvent === "function") {
|
|
var fakeNode = document.createElement("react");
|
|
invokeGuardedCallbackImpl = function invokeGuardedCallbackDev(name, func, context, a3, b3, c3, d3, e3, f3) {
|
|
if (!(typeof document !== "undefined")) {
|
|
{
|
|
throw Error("The `document` global was defined when React was initialized, but is not defined anymore. This can happen in a test environment if a component schedules an update from an asynchronous callback, but the test has already finished running. To solve this, you can either unmount the component at the end of your test (and ensure that any asynchronous operations get canceled in `componentWillUnmount`), or you can change the test itself to be asynchronous.");
|
|
}
|
|
}
|
|
var evt = document.createEvent("Event");
|
|
var didCall = false;
|
|
var didError = true;
|
|
var windowEvent = window.event;
|
|
var windowEventDescriptor = Object.getOwnPropertyDescriptor(window, "event");
|
|
function restoreAfterDispatch() {
|
|
fakeNode.removeEventListener(evtType, callCallback2, false);
|
|
if (typeof window.event !== "undefined" && window.hasOwnProperty("event")) {
|
|
window.event = windowEvent;
|
|
}
|
|
}
|
|
var funcArgs = Array.prototype.slice.call(arguments, 3);
|
|
function callCallback2() {
|
|
didCall = true;
|
|
restoreAfterDispatch();
|
|
func.apply(context, funcArgs);
|
|
didError = false;
|
|
}
|
|
var error2;
|
|
var didSetError = false;
|
|
var isCrossOriginError = false;
|
|
function handleWindowError(event) {
|
|
error2 = event.error;
|
|
didSetError = true;
|
|
if (error2 === null && event.colno === 0 && event.lineno === 0) {
|
|
isCrossOriginError = true;
|
|
}
|
|
if (event.defaultPrevented) {
|
|
if (error2 != null && typeof error2 === "object") {
|
|
try {
|
|
error2._suppressLogging = true;
|
|
} catch (inner) {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
var evtType = "react-" + (name ? name : "invokeguardedcallback");
|
|
window.addEventListener("error", handleWindowError);
|
|
fakeNode.addEventListener(evtType, callCallback2, false);
|
|
evt.initEvent(evtType, false, false);
|
|
fakeNode.dispatchEvent(evt);
|
|
if (windowEventDescriptor) {
|
|
Object.defineProperty(window, "event", windowEventDescriptor);
|
|
}
|
|
if (didCall && didError) {
|
|
if (!didSetError) {
|
|
error2 = new Error(`An error was thrown inside one of your components, but React doesn't know what it was. This is likely due to browser flakiness. React does its best to preserve the "Pause on exceptions" behavior of the DevTools, which requires some DEV-mode only tricks. It's possible that these don't work in your browser. Try triggering the error in production mode, or switching to a modern browser. If you suspect that this is actually an issue with React, please file an issue.`);
|
|
} else if (isCrossOriginError) {
|
|
error2 = new Error("A cross-origin error was thrown. React doesn't have access to the actual error object in development. See https://reactjs.org/link/crossorigin-error for more information.");
|
|
}
|
|
this.onError(error2);
|
|
}
|
|
window.removeEventListener("error", handleWindowError);
|
|
if (!didCall) {
|
|
restoreAfterDispatch();
|
|
return invokeGuardedCallbackProd.apply(this, arguments);
|
|
}
|
|
};
|
|
}
|
|
}
|
|
var invokeGuardedCallbackImpl$1 = invokeGuardedCallbackImpl;
|
|
var hasError = false;
|
|
var caughtError = null;
|
|
var hasRethrowError = false;
|
|
var rethrowError = null;
|
|
var reporter = {
|
|
onError: function(error2) {
|
|
hasError = true;
|
|
caughtError = error2;
|
|
}
|
|
};
|
|
function invokeGuardedCallback(name, func, context, a3, b3, c3, d3, e3, f3) {
|
|
hasError = false;
|
|
caughtError = null;
|
|
invokeGuardedCallbackImpl$1.apply(reporter, arguments);
|
|
}
|
|
function invokeGuardedCallbackAndCatchFirstError(name, func, context, a3, b3, c3, d3, e3, f3) {
|
|
invokeGuardedCallback.apply(this, arguments);
|
|
if (hasError) {
|
|
var error2 = clearCaughtError();
|
|
if (!hasRethrowError) {
|
|
hasRethrowError = true;
|
|
rethrowError = error2;
|
|
}
|
|
}
|
|
}
|
|
function rethrowCaughtError() {
|
|
if (hasRethrowError) {
|
|
var error2 = rethrowError;
|
|
hasRethrowError = false;
|
|
rethrowError = null;
|
|
throw error2;
|
|
}
|
|
}
|
|
function hasCaughtError() {
|
|
return hasError;
|
|
}
|
|
function clearCaughtError() {
|
|
if (hasError) {
|
|
var error2 = caughtError;
|
|
hasError = false;
|
|
caughtError = null;
|
|
return error2;
|
|
} else {
|
|
{
|
|
{
|
|
throw Error("clearCaughtError was called but no error was captured. This error is likely caused by a bug in React. Please file an issue.");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
function get(key) {
|
|
return key._reactInternals;
|
|
}
|
|
function has(key) {
|
|
return key._reactInternals !== void 0;
|
|
}
|
|
function set(key, value) {
|
|
key._reactInternals = value;
|
|
}
|
|
var NoFlags = 0;
|
|
var PerformedWork = 1;
|
|
var Placement = 2;
|
|
var Update = 4;
|
|
var PlacementAndUpdate = 6;
|
|
var Deletion = 8;
|
|
var ContentReset = 16;
|
|
var Callback = 32;
|
|
var DidCapture = 64;
|
|
var Ref = 128;
|
|
var Snapshot = 256;
|
|
var Passive = 512;
|
|
var PassiveUnmountPendingDev = 8192;
|
|
var Hydrating = 1024;
|
|
var HydratingAndUpdate = 1028;
|
|
var LifecycleEffectMask = 932;
|
|
var HostEffectMask = 2047;
|
|
var Incomplete = 2048;
|
|
var ShouldCapture = 4096;
|
|
var ForceUpdateForLegacySuspense = 16384;
|
|
var ReactCurrentOwner = ReactSharedInternals.ReactCurrentOwner;
|
|
function getNearestMountedFiber(fiber) {
|
|
var node = fiber;
|
|
var nearestMounted = fiber;
|
|
if (!fiber.alternate) {
|
|
var nextNode = node;
|
|
do {
|
|
node = nextNode;
|
|
if ((node.flags & (Placement | Hydrating)) !== NoFlags) {
|
|
nearestMounted = node.return;
|
|
}
|
|
nextNode = node.return;
|
|
} while (nextNode);
|
|
} else {
|
|
while (node.return) {
|
|
node = node.return;
|
|
}
|
|
}
|
|
if (node.tag === HostRoot) {
|
|
return nearestMounted;
|
|
}
|
|
return null;
|
|
}
|
|
function getSuspenseInstanceFromFiber(fiber) {
|
|
if (fiber.tag === SuspenseComponent) {
|
|
var suspenseState = fiber.memoizedState;
|
|
if (suspenseState === null) {
|
|
var current2 = fiber.alternate;
|
|
if (current2 !== null) {
|
|
suspenseState = current2.memoizedState;
|
|
}
|
|
}
|
|
if (suspenseState !== null) {
|
|
return suspenseState.dehydrated;
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
function getContainerFromFiber(fiber) {
|
|
return fiber.tag === HostRoot ? fiber.stateNode.containerInfo : null;
|
|
}
|
|
function isFiberMounted(fiber) {
|
|
return getNearestMountedFiber(fiber) === fiber;
|
|
}
|
|
function isMounted(component) {
|
|
{
|
|
var owner = ReactCurrentOwner.current;
|
|
if (owner !== null && owner.tag === ClassComponent) {
|
|
var ownerFiber = owner;
|
|
var instance = ownerFiber.stateNode;
|
|
if (!instance._warnedAboutRefsInRender) {
|
|
error("%s is accessing isMounted inside its render() function. render() should be a pure function of props and state. It should never access something that requires stale data from the previous render, such as refs. Move this logic to componentDidMount and componentDidUpdate instead.", getComponentName(ownerFiber.type) || "A component");
|
|
}
|
|
instance._warnedAboutRefsInRender = true;
|
|
}
|
|
}
|
|
var fiber = get(component);
|
|
if (!fiber) {
|
|
return false;
|
|
}
|
|
return getNearestMountedFiber(fiber) === fiber;
|
|
}
|
|
function assertIsMounted(fiber) {
|
|
if (!(getNearestMountedFiber(fiber) === fiber)) {
|
|
{
|
|
throw Error("Unable to find node on an unmounted component.");
|
|
}
|
|
}
|
|
}
|
|
function findCurrentFiberUsingSlowPath(fiber) {
|
|
var alternate = fiber.alternate;
|
|
if (!alternate) {
|
|
var nearestMounted = getNearestMountedFiber(fiber);
|
|
if (!(nearestMounted !== null)) {
|
|
{
|
|
throw Error("Unable to find node on an unmounted component.");
|
|
}
|
|
}
|
|
if (nearestMounted !== fiber) {
|
|
return null;
|
|
}
|
|
return fiber;
|
|
}
|
|
var a3 = fiber;
|
|
var b3 = alternate;
|
|
while (true) {
|
|
var parentA = a3.return;
|
|
if (parentA === null) {
|
|
break;
|
|
}
|
|
var parentB = parentA.alternate;
|
|
if (parentB === null) {
|
|
var nextParent = parentA.return;
|
|
if (nextParent !== null) {
|
|
a3 = b3 = nextParent;
|
|
continue;
|
|
}
|
|
break;
|
|
}
|
|
if (parentA.child === parentB.child) {
|
|
var child = parentA.child;
|
|
while (child) {
|
|
if (child === a3) {
|
|
assertIsMounted(parentA);
|
|
return fiber;
|
|
}
|
|
if (child === b3) {
|
|
assertIsMounted(parentA);
|
|
return alternate;
|
|
}
|
|
child = child.sibling;
|
|
}
|
|
{
|
|
{
|
|
throw Error("Unable to find node on an unmounted component.");
|
|
}
|
|
}
|
|
}
|
|
if (a3.return !== b3.return) {
|
|
a3 = parentA;
|
|
b3 = parentB;
|
|
} else {
|
|
var didFindChild = false;
|
|
var _child = parentA.child;
|
|
while (_child) {
|
|
if (_child === a3) {
|
|
didFindChild = true;
|
|
a3 = parentA;
|
|
b3 = parentB;
|
|
break;
|
|
}
|
|
if (_child === b3) {
|
|
didFindChild = true;
|
|
b3 = parentA;
|
|
a3 = parentB;
|
|
break;
|
|
}
|
|
_child = _child.sibling;
|
|
}
|
|
if (!didFindChild) {
|
|
_child = parentB.child;
|
|
while (_child) {
|
|
if (_child === a3) {
|
|
didFindChild = true;
|
|
a3 = parentB;
|
|
b3 = parentA;
|
|
break;
|
|
}
|
|
if (_child === b3) {
|
|
didFindChild = true;
|
|
b3 = parentB;
|
|
a3 = parentA;
|
|
break;
|
|
}
|
|
_child = _child.sibling;
|
|
}
|
|
if (!didFindChild) {
|
|
{
|
|
throw Error("Child was not found in either parent set. This indicates a bug in React related to the return pointer. Please file an issue.");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (!(a3.alternate === b3)) {
|
|
{
|
|
throw Error("Return fibers should always be each others' alternates. This error is likely caused by a bug in React. Please file an issue.");
|
|
}
|
|
}
|
|
}
|
|
if (!(a3.tag === HostRoot)) {
|
|
{
|
|
throw Error("Unable to find node on an unmounted component.");
|
|
}
|
|
}
|
|
if (a3.stateNode.current === a3) {
|
|
return fiber;
|
|
}
|
|
return alternate;
|
|
}
|
|
function findCurrentHostFiber(parent) {
|
|
var currentParent = findCurrentFiberUsingSlowPath(parent);
|
|
if (!currentParent) {
|
|
return null;
|
|
}
|
|
var node = currentParent;
|
|
while (true) {
|
|
if (node.tag === HostComponent || node.tag === HostText) {
|
|
return node;
|
|
} else if (node.child) {
|
|
node.child.return = node;
|
|
node = node.child;
|
|
continue;
|
|
}
|
|
if (node === currentParent) {
|
|
return null;
|
|
}
|
|
while (!node.sibling) {
|
|
if (!node.return || node.return === currentParent) {
|
|
return null;
|
|
}
|
|
node = node.return;
|
|
}
|
|
node.sibling.return = node.return;
|
|
node = node.sibling;
|
|
}
|
|
return null;
|
|
}
|
|
function findCurrentHostFiberWithNoPortals(parent) {
|
|
var currentParent = findCurrentFiberUsingSlowPath(parent);
|
|
if (!currentParent) {
|
|
return null;
|
|
}
|
|
var node = currentParent;
|
|
while (true) {
|
|
if (node.tag === HostComponent || node.tag === HostText || enableFundamentalAPI) {
|
|
return node;
|
|
} else if (node.child && node.tag !== HostPortal) {
|
|
node.child.return = node;
|
|
node = node.child;
|
|
continue;
|
|
}
|
|
if (node === currentParent) {
|
|
return null;
|
|
}
|
|
while (!node.sibling) {
|
|
if (!node.return || node.return === currentParent) {
|
|
return null;
|
|
}
|
|
node = node.return;
|
|
}
|
|
node.sibling.return = node.return;
|
|
node = node.sibling;
|
|
}
|
|
return null;
|
|
}
|
|
function doesFiberContain(parentFiber, childFiber) {
|
|
var node = childFiber;
|
|
var parentFiberAlternate = parentFiber.alternate;
|
|
while (node !== null) {
|
|
if (node === parentFiber || node === parentFiberAlternate) {
|
|
return true;
|
|
}
|
|
node = node.return;
|
|
}
|
|
return false;
|
|
}
|
|
var attemptUserBlockingHydration;
|
|
function setAttemptUserBlockingHydration(fn) {
|
|
attemptUserBlockingHydration = fn;
|
|
}
|
|
var attemptContinuousHydration;
|
|
function setAttemptContinuousHydration(fn) {
|
|
attemptContinuousHydration = fn;
|
|
}
|
|
var attemptHydrationAtCurrentPriority;
|
|
function setAttemptHydrationAtCurrentPriority(fn) {
|
|
attemptHydrationAtCurrentPriority = fn;
|
|
}
|
|
var attemptHydrationAtPriority;
|
|
function setAttemptHydrationAtPriority(fn) {
|
|
attemptHydrationAtPriority = fn;
|
|
}
|
|
var hasScheduledReplayAttempt = false;
|
|
var queuedDiscreteEvents = [];
|
|
var queuedFocus = null;
|
|
var queuedDrag = null;
|
|
var queuedMouse = null;
|
|
var queuedPointers = new Map();
|
|
var queuedPointerCaptures = new Map();
|
|
var queuedExplicitHydrationTargets = [];
|
|
function hasQueuedDiscreteEvents() {
|
|
return queuedDiscreteEvents.length > 0;
|
|
}
|
|
var discreteReplayableEvents = [
|
|
"mousedown",
|
|
"mouseup",
|
|
"touchcancel",
|
|
"touchend",
|
|
"touchstart",
|
|
"auxclick",
|
|
"dblclick",
|
|
"pointercancel",
|
|
"pointerdown",
|
|
"pointerup",
|
|
"dragend",
|
|
"dragstart",
|
|
"drop",
|
|
"compositionend",
|
|
"compositionstart",
|
|
"keydown",
|
|
"keypress",
|
|
"keyup",
|
|
"input",
|
|
"textInput",
|
|
"copy",
|
|
"cut",
|
|
"paste",
|
|
"click",
|
|
"change",
|
|
"contextmenu",
|
|
"reset",
|
|
"submit"
|
|
];
|
|
function isReplayableDiscreteEvent(eventType) {
|
|
return discreteReplayableEvents.indexOf(eventType) > -1;
|
|
}
|
|
function createQueuedReplayableEvent(blockedOn, domEventName, eventSystemFlags, targetContainer, nativeEvent) {
|
|
return {
|
|
blockedOn,
|
|
domEventName,
|
|
eventSystemFlags: eventSystemFlags | IS_REPLAYED,
|
|
nativeEvent,
|
|
targetContainers: [targetContainer]
|
|
};
|
|
}
|
|
function queueDiscreteEvent(blockedOn, domEventName, eventSystemFlags, targetContainer, nativeEvent) {
|
|
var queuedEvent = createQueuedReplayableEvent(blockedOn, domEventName, eventSystemFlags, targetContainer, nativeEvent);
|
|
queuedDiscreteEvents.push(queuedEvent);
|
|
}
|
|
function clearIfContinuousEvent(domEventName, nativeEvent) {
|
|
switch (domEventName) {
|
|
case "focusin":
|
|
case "focusout":
|
|
queuedFocus = null;
|
|
break;
|
|
case "dragenter":
|
|
case "dragleave":
|
|
queuedDrag = null;
|
|
break;
|
|
case "mouseover":
|
|
case "mouseout":
|
|
queuedMouse = null;
|
|
break;
|
|
case "pointerover":
|
|
case "pointerout": {
|
|
var pointerId = nativeEvent.pointerId;
|
|
queuedPointers.delete(pointerId);
|
|
break;
|
|
}
|
|
case "gotpointercapture":
|
|
case "lostpointercapture": {
|
|
var _pointerId = nativeEvent.pointerId;
|
|
queuedPointerCaptures.delete(_pointerId);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
function accumulateOrCreateContinuousQueuedReplayableEvent(existingQueuedEvent, blockedOn, domEventName, eventSystemFlags, targetContainer, nativeEvent) {
|
|
if (existingQueuedEvent === null || existingQueuedEvent.nativeEvent !== nativeEvent) {
|
|
var queuedEvent = createQueuedReplayableEvent(blockedOn, domEventName, eventSystemFlags, targetContainer, nativeEvent);
|
|
if (blockedOn !== null) {
|
|
var _fiber2 = getInstanceFromNode(blockedOn);
|
|
if (_fiber2 !== null) {
|
|
attemptContinuousHydration(_fiber2);
|
|
}
|
|
}
|
|
return queuedEvent;
|
|
}
|
|
existingQueuedEvent.eventSystemFlags |= eventSystemFlags;
|
|
var targetContainers = existingQueuedEvent.targetContainers;
|
|
if (targetContainer !== null && targetContainers.indexOf(targetContainer) === -1) {
|
|
targetContainers.push(targetContainer);
|
|
}
|
|
return existingQueuedEvent;
|
|
}
|
|
function queueIfContinuousEvent(blockedOn, domEventName, eventSystemFlags, targetContainer, nativeEvent) {
|
|
switch (domEventName) {
|
|
case "focusin": {
|
|
var focusEvent = nativeEvent;
|
|
queuedFocus = accumulateOrCreateContinuousQueuedReplayableEvent(queuedFocus, blockedOn, domEventName, eventSystemFlags, targetContainer, focusEvent);
|
|
return true;
|
|
}
|
|
case "dragenter": {
|
|
var dragEvent = nativeEvent;
|
|
queuedDrag = accumulateOrCreateContinuousQueuedReplayableEvent(queuedDrag, blockedOn, domEventName, eventSystemFlags, targetContainer, dragEvent);
|
|
return true;
|
|
}
|
|
case "mouseover": {
|
|
var mouseEvent = nativeEvent;
|
|
queuedMouse = accumulateOrCreateContinuousQueuedReplayableEvent(queuedMouse, blockedOn, domEventName, eventSystemFlags, targetContainer, mouseEvent);
|
|
return true;
|
|
}
|
|
case "pointerover": {
|
|
var pointerEvent = nativeEvent;
|
|
var pointerId = pointerEvent.pointerId;
|
|
queuedPointers.set(pointerId, accumulateOrCreateContinuousQueuedReplayableEvent(queuedPointers.get(pointerId) || null, blockedOn, domEventName, eventSystemFlags, targetContainer, pointerEvent));
|
|
return true;
|
|
}
|
|
case "gotpointercapture": {
|
|
var _pointerEvent = nativeEvent;
|
|
var _pointerId2 = _pointerEvent.pointerId;
|
|
queuedPointerCaptures.set(_pointerId2, accumulateOrCreateContinuousQueuedReplayableEvent(queuedPointerCaptures.get(_pointerId2) || null, blockedOn, domEventName, eventSystemFlags, targetContainer, _pointerEvent));
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
function attemptExplicitHydrationTarget(queuedTarget) {
|
|
var targetInst = getClosestInstanceFromNode(queuedTarget.target);
|
|
if (targetInst !== null) {
|
|
var nearestMounted = getNearestMountedFiber(targetInst);
|
|
if (nearestMounted !== null) {
|
|
var tag = nearestMounted.tag;
|
|
if (tag === SuspenseComponent) {
|
|
var instance = getSuspenseInstanceFromFiber(nearestMounted);
|
|
if (instance !== null) {
|
|
queuedTarget.blockedOn = instance;
|
|
attemptHydrationAtPriority(queuedTarget.lanePriority, function() {
|
|
Scheduler.unstable_runWithPriority(queuedTarget.priority, function() {
|
|
attemptHydrationAtCurrentPriority(nearestMounted);
|
|
});
|
|
});
|
|
return;
|
|
}
|
|
} else if (tag === HostRoot) {
|
|
var root2 = nearestMounted.stateNode;
|
|
if (root2.hydrate) {
|
|
queuedTarget.blockedOn = getContainerFromFiber(nearestMounted);
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
queuedTarget.blockedOn = null;
|
|
}
|
|
function attemptReplayContinuousQueuedEvent(queuedEvent) {
|
|
if (queuedEvent.blockedOn !== null) {
|
|
return false;
|
|
}
|
|
var targetContainers = queuedEvent.targetContainers;
|
|
while (targetContainers.length > 0) {
|
|
var targetContainer = targetContainers[0];
|
|
var nextBlockedOn = attemptToDispatchEvent(queuedEvent.domEventName, queuedEvent.eventSystemFlags, targetContainer, queuedEvent.nativeEvent);
|
|
if (nextBlockedOn !== null) {
|
|
var _fiber3 = getInstanceFromNode(nextBlockedOn);
|
|
if (_fiber3 !== null) {
|
|
attemptContinuousHydration(_fiber3);
|
|
}
|
|
queuedEvent.blockedOn = nextBlockedOn;
|
|
return false;
|
|
}
|
|
targetContainers.shift();
|
|
}
|
|
return true;
|
|
}
|
|
function attemptReplayContinuousQueuedEventInMap(queuedEvent, key, map) {
|
|
if (attemptReplayContinuousQueuedEvent(queuedEvent)) {
|
|
map.delete(key);
|
|
}
|
|
}
|
|
function replayUnblockedEvents() {
|
|
hasScheduledReplayAttempt = false;
|
|
while (queuedDiscreteEvents.length > 0) {
|
|
var nextDiscreteEvent = queuedDiscreteEvents[0];
|
|
if (nextDiscreteEvent.blockedOn !== null) {
|
|
var _fiber4 = getInstanceFromNode(nextDiscreteEvent.blockedOn);
|
|
if (_fiber4 !== null) {
|
|
attemptUserBlockingHydration(_fiber4);
|
|
}
|
|
break;
|
|
}
|
|
var targetContainers = nextDiscreteEvent.targetContainers;
|
|
while (targetContainers.length > 0) {
|
|
var targetContainer = targetContainers[0];
|
|
var nextBlockedOn = attemptToDispatchEvent(nextDiscreteEvent.domEventName, nextDiscreteEvent.eventSystemFlags, targetContainer, nextDiscreteEvent.nativeEvent);
|
|
if (nextBlockedOn !== null) {
|
|
nextDiscreteEvent.blockedOn = nextBlockedOn;
|
|
break;
|
|
}
|
|
targetContainers.shift();
|
|
}
|
|
if (nextDiscreteEvent.blockedOn === null) {
|
|
queuedDiscreteEvents.shift();
|
|
}
|
|
}
|
|
if (queuedFocus !== null && attemptReplayContinuousQueuedEvent(queuedFocus)) {
|
|
queuedFocus = null;
|
|
}
|
|
if (queuedDrag !== null && attemptReplayContinuousQueuedEvent(queuedDrag)) {
|
|
queuedDrag = null;
|
|
}
|
|
if (queuedMouse !== null && attemptReplayContinuousQueuedEvent(queuedMouse)) {
|
|
queuedMouse = null;
|
|
}
|
|
queuedPointers.forEach(attemptReplayContinuousQueuedEventInMap);
|
|
queuedPointerCaptures.forEach(attemptReplayContinuousQueuedEventInMap);
|
|
}
|
|
function scheduleCallbackIfUnblocked(queuedEvent, unblocked) {
|
|
if (queuedEvent.blockedOn === unblocked) {
|
|
queuedEvent.blockedOn = null;
|
|
if (!hasScheduledReplayAttempt) {
|
|
hasScheduledReplayAttempt = true;
|
|
Scheduler.unstable_scheduleCallback(Scheduler.unstable_NormalPriority, replayUnblockedEvents);
|
|
}
|
|
}
|
|
}
|
|
function retryIfBlockedOn(unblocked) {
|
|
if (queuedDiscreteEvents.length > 0) {
|
|
scheduleCallbackIfUnblocked(queuedDiscreteEvents[0], unblocked);
|
|
for (var i3 = 1; i3 < queuedDiscreteEvents.length; i3++) {
|
|
var queuedEvent = queuedDiscreteEvents[i3];
|
|
if (queuedEvent.blockedOn === unblocked) {
|
|
queuedEvent.blockedOn = null;
|
|
}
|
|
}
|
|
}
|
|
if (queuedFocus !== null) {
|
|
scheduleCallbackIfUnblocked(queuedFocus, unblocked);
|
|
}
|
|
if (queuedDrag !== null) {
|
|
scheduleCallbackIfUnblocked(queuedDrag, unblocked);
|
|
}
|
|
if (queuedMouse !== null) {
|
|
scheduleCallbackIfUnblocked(queuedMouse, unblocked);
|
|
}
|
|
var unblock = function(queuedEvent2) {
|
|
return scheduleCallbackIfUnblocked(queuedEvent2, unblocked);
|
|
};
|
|
queuedPointers.forEach(unblock);
|
|
queuedPointerCaptures.forEach(unblock);
|
|
for (var _i = 0; _i < queuedExplicitHydrationTargets.length; _i++) {
|
|
var queuedTarget = queuedExplicitHydrationTargets[_i];
|
|
if (queuedTarget.blockedOn === unblocked) {
|
|
queuedTarget.blockedOn = null;
|
|
}
|
|
}
|
|
while (queuedExplicitHydrationTargets.length > 0) {
|
|
var nextExplicitTarget = queuedExplicitHydrationTargets[0];
|
|
if (nextExplicitTarget.blockedOn !== null) {
|
|
break;
|
|
} else {
|
|
attemptExplicitHydrationTarget(nextExplicitTarget);
|
|
if (nextExplicitTarget.blockedOn === null) {
|
|
queuedExplicitHydrationTargets.shift();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
var DiscreteEvent = 0;
|
|
var UserBlockingEvent = 1;
|
|
var ContinuousEvent = 2;
|
|
function makePrefixMap(styleProp, eventName) {
|
|
var prefixes2 = {};
|
|
prefixes2[styleProp.toLowerCase()] = eventName.toLowerCase();
|
|
prefixes2["Webkit" + styleProp] = "webkit" + eventName;
|
|
prefixes2["Moz" + styleProp] = "moz" + eventName;
|
|
return prefixes2;
|
|
}
|
|
var vendorPrefixes = {
|
|
animationend: makePrefixMap("Animation", "AnimationEnd"),
|
|
animationiteration: makePrefixMap("Animation", "AnimationIteration"),
|
|
animationstart: makePrefixMap("Animation", "AnimationStart"),
|
|
transitionend: makePrefixMap("Transition", "TransitionEnd")
|
|
};
|
|
var prefixedEventNames = {};
|
|
var style = {};
|
|
if (canUseDOM) {
|
|
style = document.createElement("div").style;
|
|
if (!("AnimationEvent" in window)) {
|
|
delete vendorPrefixes.animationend.animation;
|
|
delete vendorPrefixes.animationiteration.animation;
|
|
delete vendorPrefixes.animationstart.animation;
|
|
}
|
|
if (!("TransitionEvent" in window)) {
|
|
delete vendorPrefixes.transitionend.transition;
|
|
}
|
|
}
|
|
function getVendorPrefixedEventName(eventName) {
|
|
if (prefixedEventNames[eventName]) {
|
|
return prefixedEventNames[eventName];
|
|
} else if (!vendorPrefixes[eventName]) {
|
|
return eventName;
|
|
}
|
|
var prefixMap = vendorPrefixes[eventName];
|
|
for (var styleProp in prefixMap) {
|
|
if (prefixMap.hasOwnProperty(styleProp) && styleProp in style) {
|
|
return prefixedEventNames[eventName] = prefixMap[styleProp];
|
|
}
|
|
}
|
|
return eventName;
|
|
}
|
|
var ANIMATION_END = getVendorPrefixedEventName("animationend");
|
|
var ANIMATION_ITERATION = getVendorPrefixedEventName("animationiteration");
|
|
var ANIMATION_START = getVendorPrefixedEventName("animationstart");
|
|
var TRANSITION_END = getVendorPrefixedEventName("transitionend");
|
|
var topLevelEventsToReactNames = new Map();
|
|
var eventPriorities = new Map();
|
|
var discreteEventPairsForSimpleEventPlugin = [
|
|
"cancel",
|
|
"cancel",
|
|
"click",
|
|
"click",
|
|
"close",
|
|
"close",
|
|
"contextmenu",
|
|
"contextMenu",
|
|
"copy",
|
|
"copy",
|
|
"cut",
|
|
"cut",
|
|
"auxclick",
|
|
"auxClick",
|
|
"dblclick",
|
|
"doubleClick",
|
|
"dragend",
|
|
"dragEnd",
|
|
"dragstart",
|
|
"dragStart",
|
|
"drop",
|
|
"drop",
|
|
"focusin",
|
|
"focus",
|
|
"focusout",
|
|
"blur",
|
|
"input",
|
|
"input",
|
|
"invalid",
|
|
"invalid",
|
|
"keydown",
|
|
"keyDown",
|
|
"keypress",
|
|
"keyPress",
|
|
"keyup",
|
|
"keyUp",
|
|
"mousedown",
|
|
"mouseDown",
|
|
"mouseup",
|
|
"mouseUp",
|
|
"paste",
|
|
"paste",
|
|
"pause",
|
|
"pause",
|
|
"play",
|
|
"play",
|
|
"pointercancel",
|
|
"pointerCancel",
|
|
"pointerdown",
|
|
"pointerDown",
|
|
"pointerup",
|
|
"pointerUp",
|
|
"ratechange",
|
|
"rateChange",
|
|
"reset",
|
|
"reset",
|
|
"seeked",
|
|
"seeked",
|
|
"submit",
|
|
"submit",
|
|
"touchcancel",
|
|
"touchCancel",
|
|
"touchend",
|
|
"touchEnd",
|
|
"touchstart",
|
|
"touchStart",
|
|
"volumechange",
|
|
"volumeChange"
|
|
];
|
|
var otherDiscreteEvents = ["change", "selectionchange", "textInput", "compositionstart", "compositionend", "compositionupdate"];
|
|
var userBlockingPairsForSimpleEventPlugin = ["drag", "drag", "dragenter", "dragEnter", "dragexit", "dragExit", "dragleave", "dragLeave", "dragover", "dragOver", "mousemove", "mouseMove", "mouseout", "mouseOut", "mouseover", "mouseOver", "pointermove", "pointerMove", "pointerout", "pointerOut", "pointerover", "pointerOver", "scroll", "scroll", "toggle", "toggle", "touchmove", "touchMove", "wheel", "wheel"];
|
|
var continuousPairsForSimpleEventPlugin = ["abort", "abort", ANIMATION_END, "animationEnd", ANIMATION_ITERATION, "animationIteration", ANIMATION_START, "animationStart", "canplay", "canPlay", "canplaythrough", "canPlayThrough", "durationchange", "durationChange", "emptied", "emptied", "encrypted", "encrypted", "ended", "ended", "error", "error", "gotpointercapture", "gotPointerCapture", "load", "load", "loadeddata", "loadedData", "loadedmetadata", "loadedMetadata", "loadstart", "loadStart", "lostpointercapture", "lostPointerCapture", "playing", "playing", "progress", "progress", "seeking", "seeking", "stalled", "stalled", "suspend", "suspend", "timeupdate", "timeUpdate", TRANSITION_END, "transitionEnd", "waiting", "waiting"];
|
|
function registerSimplePluginEventsAndSetTheirPriorities(eventTypes, priority) {
|
|
for (var i3 = 0; i3 < eventTypes.length; i3 += 2) {
|
|
var topEvent = eventTypes[i3];
|
|
var event = eventTypes[i3 + 1];
|
|
var capitalizedEvent = event[0].toUpperCase() + event.slice(1);
|
|
var reactName = "on" + capitalizedEvent;
|
|
eventPriorities.set(topEvent, priority);
|
|
topLevelEventsToReactNames.set(topEvent, reactName);
|
|
registerTwoPhaseEvent(reactName, [topEvent]);
|
|
}
|
|
}
|
|
function setEventPriorities(eventTypes, priority) {
|
|
for (var i3 = 0; i3 < eventTypes.length; i3++) {
|
|
eventPriorities.set(eventTypes[i3], priority);
|
|
}
|
|
}
|
|
function getEventPriorityForPluginSystem(domEventName) {
|
|
var priority = eventPriorities.get(domEventName);
|
|
return priority === void 0 ? ContinuousEvent : priority;
|
|
}
|
|
function registerSimpleEvents() {
|
|
registerSimplePluginEventsAndSetTheirPriorities(discreteEventPairsForSimpleEventPlugin, DiscreteEvent);
|
|
registerSimplePluginEventsAndSetTheirPriorities(userBlockingPairsForSimpleEventPlugin, UserBlockingEvent);
|
|
registerSimplePluginEventsAndSetTheirPriorities(continuousPairsForSimpleEventPlugin, ContinuousEvent);
|
|
setEventPriorities(otherDiscreteEvents, DiscreteEvent);
|
|
}
|
|
var Scheduler_now = Scheduler.unstable_now;
|
|
{
|
|
if (!(tracing.__interactionsRef != null && tracing.__interactionsRef.current != null)) {
|
|
{
|
|
throw Error("It is not supported to run the profiling version of a renderer (for example, `react-dom/profiling`) without also replacing the `scheduler/tracing` module with `scheduler/tracing-profiling`. Your bundler might have a setting for aliasing both modules. Learn more at https://reactjs.org/link/profiling");
|
|
}
|
|
}
|
|
}
|
|
var ImmediatePriority = 99;
|
|
var UserBlockingPriority = 98;
|
|
var NormalPriority = 97;
|
|
var LowPriority = 96;
|
|
var IdlePriority = 95;
|
|
var NoPriority = 90;
|
|
var initialTimeMs = Scheduler_now();
|
|
var SyncLanePriority = 15;
|
|
var SyncBatchedLanePriority = 14;
|
|
var InputDiscreteHydrationLanePriority = 13;
|
|
var InputDiscreteLanePriority = 12;
|
|
var InputContinuousHydrationLanePriority = 11;
|
|
var InputContinuousLanePriority = 10;
|
|
var DefaultHydrationLanePriority = 9;
|
|
var DefaultLanePriority = 8;
|
|
var TransitionHydrationPriority = 7;
|
|
var TransitionPriority = 6;
|
|
var RetryLanePriority = 5;
|
|
var SelectiveHydrationLanePriority = 4;
|
|
var IdleHydrationLanePriority = 3;
|
|
var IdleLanePriority = 2;
|
|
var OffscreenLanePriority = 1;
|
|
var NoLanePriority = 0;
|
|
var TotalLanes = 31;
|
|
var NoLanes = 0;
|
|
var NoLane = 0;
|
|
var SyncLane = 1;
|
|
var SyncBatchedLane = 2;
|
|
var InputDiscreteHydrationLane = 4;
|
|
var InputDiscreteLanes = 24;
|
|
var InputContinuousHydrationLane = 32;
|
|
var InputContinuousLanes = 192;
|
|
var DefaultHydrationLane = 256;
|
|
var DefaultLanes = 3584;
|
|
var TransitionHydrationLane = 4096;
|
|
var TransitionLanes = 4186112;
|
|
var RetryLanes = 62914560;
|
|
var SomeRetryLane = 33554432;
|
|
var SelectiveHydrationLane = 67108864;
|
|
var NonIdleLanes = 134217727;
|
|
var IdleHydrationLane = 134217728;
|
|
var IdleLanes = 805306368;
|
|
var OffscreenLane = 1073741824;
|
|
var NoTimestamp = -1;
|
|
function setCurrentUpdateLanePriority(newLanePriority) {
|
|
}
|
|
var return_highestLanePriority = DefaultLanePriority;
|
|
function getHighestPriorityLanes(lanes) {
|
|
if ((SyncLane & lanes) !== NoLanes) {
|
|
return_highestLanePriority = SyncLanePriority;
|
|
return SyncLane;
|
|
}
|
|
if ((SyncBatchedLane & lanes) !== NoLanes) {
|
|
return_highestLanePriority = SyncBatchedLanePriority;
|
|
return SyncBatchedLane;
|
|
}
|
|
if ((InputDiscreteHydrationLane & lanes) !== NoLanes) {
|
|
return_highestLanePriority = InputDiscreteHydrationLanePriority;
|
|
return InputDiscreteHydrationLane;
|
|
}
|
|
var inputDiscreteLanes = InputDiscreteLanes & lanes;
|
|
if (inputDiscreteLanes !== NoLanes) {
|
|
return_highestLanePriority = InputDiscreteLanePriority;
|
|
return inputDiscreteLanes;
|
|
}
|
|
if ((lanes & InputContinuousHydrationLane) !== NoLanes) {
|
|
return_highestLanePriority = InputContinuousHydrationLanePriority;
|
|
return InputContinuousHydrationLane;
|
|
}
|
|
var inputContinuousLanes = InputContinuousLanes & lanes;
|
|
if (inputContinuousLanes !== NoLanes) {
|
|
return_highestLanePriority = InputContinuousLanePriority;
|
|
return inputContinuousLanes;
|
|
}
|
|
if ((lanes & DefaultHydrationLane) !== NoLanes) {
|
|
return_highestLanePriority = DefaultHydrationLanePriority;
|
|
return DefaultHydrationLane;
|
|
}
|
|
var defaultLanes = DefaultLanes & lanes;
|
|
if (defaultLanes !== NoLanes) {
|
|
return_highestLanePriority = DefaultLanePriority;
|
|
return defaultLanes;
|
|
}
|
|
if ((lanes & TransitionHydrationLane) !== NoLanes) {
|
|
return_highestLanePriority = TransitionHydrationPriority;
|
|
return TransitionHydrationLane;
|
|
}
|
|
var transitionLanes = TransitionLanes & lanes;
|
|
if (transitionLanes !== NoLanes) {
|
|
return_highestLanePriority = TransitionPriority;
|
|
return transitionLanes;
|
|
}
|
|
var retryLanes = RetryLanes & lanes;
|
|
if (retryLanes !== NoLanes) {
|
|
return_highestLanePriority = RetryLanePriority;
|
|
return retryLanes;
|
|
}
|
|
if (lanes & SelectiveHydrationLane) {
|
|
return_highestLanePriority = SelectiveHydrationLanePriority;
|
|
return SelectiveHydrationLane;
|
|
}
|
|
if ((lanes & IdleHydrationLane) !== NoLanes) {
|
|
return_highestLanePriority = IdleHydrationLanePriority;
|
|
return IdleHydrationLane;
|
|
}
|
|
var idleLanes = IdleLanes & lanes;
|
|
if (idleLanes !== NoLanes) {
|
|
return_highestLanePriority = IdleLanePriority;
|
|
return idleLanes;
|
|
}
|
|
if ((OffscreenLane & lanes) !== NoLanes) {
|
|
return_highestLanePriority = OffscreenLanePriority;
|
|
return OffscreenLane;
|
|
}
|
|
{
|
|
error("Should have found matching lanes. This is a bug in React.");
|
|
}
|
|
return_highestLanePriority = DefaultLanePriority;
|
|
return lanes;
|
|
}
|
|
function schedulerPriorityToLanePriority(schedulerPriorityLevel) {
|
|
switch (schedulerPriorityLevel) {
|
|
case ImmediatePriority:
|
|
return SyncLanePriority;
|
|
case UserBlockingPriority:
|
|
return InputContinuousLanePriority;
|
|
case NormalPriority:
|
|
case LowPriority:
|
|
return DefaultLanePriority;
|
|
case IdlePriority:
|
|
return IdleLanePriority;
|
|
default:
|
|
return NoLanePriority;
|
|
}
|
|
}
|
|
function lanePriorityToSchedulerPriority(lanePriority) {
|
|
switch (lanePriority) {
|
|
case SyncLanePriority:
|
|
case SyncBatchedLanePriority:
|
|
return ImmediatePriority;
|
|
case InputDiscreteHydrationLanePriority:
|
|
case InputDiscreteLanePriority:
|
|
case InputContinuousHydrationLanePriority:
|
|
case InputContinuousLanePriority:
|
|
return UserBlockingPriority;
|
|
case DefaultHydrationLanePriority:
|
|
case DefaultLanePriority:
|
|
case TransitionHydrationPriority:
|
|
case TransitionPriority:
|
|
case SelectiveHydrationLanePriority:
|
|
case RetryLanePriority:
|
|
return NormalPriority;
|
|
case IdleHydrationLanePriority:
|
|
case IdleLanePriority:
|
|
case OffscreenLanePriority:
|
|
return IdlePriority;
|
|
case NoLanePriority:
|
|
return NoPriority;
|
|
default: {
|
|
{
|
|
throw Error("Invalid update priority: " + lanePriority + ". This is a bug in React.");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
function getNextLanes(root2, wipLanes) {
|
|
var pendingLanes = root2.pendingLanes;
|
|
if (pendingLanes === NoLanes) {
|
|
return_highestLanePriority = NoLanePriority;
|
|
return NoLanes;
|
|
}
|
|
var nextLanes = NoLanes;
|
|
var nextLanePriority = NoLanePriority;
|
|
var expiredLanes = root2.expiredLanes;
|
|
var suspendedLanes = root2.suspendedLanes;
|
|
var pingedLanes = root2.pingedLanes;
|
|
if (expiredLanes !== NoLanes) {
|
|
nextLanes = expiredLanes;
|
|
nextLanePriority = return_highestLanePriority = SyncLanePriority;
|
|
} else {
|
|
var nonIdlePendingLanes = pendingLanes & NonIdleLanes;
|
|
if (nonIdlePendingLanes !== NoLanes) {
|
|
var nonIdleUnblockedLanes = nonIdlePendingLanes & ~suspendedLanes;
|
|
if (nonIdleUnblockedLanes !== NoLanes) {
|
|
nextLanes = getHighestPriorityLanes(nonIdleUnblockedLanes);
|
|
nextLanePriority = return_highestLanePriority;
|
|
} else {
|
|
var nonIdlePingedLanes = nonIdlePendingLanes & pingedLanes;
|
|
if (nonIdlePingedLanes !== NoLanes) {
|
|
nextLanes = getHighestPriorityLanes(nonIdlePingedLanes);
|
|
nextLanePriority = return_highestLanePriority;
|
|
}
|
|
}
|
|
} else {
|
|
var unblockedLanes = pendingLanes & ~suspendedLanes;
|
|
if (unblockedLanes !== NoLanes) {
|
|
nextLanes = getHighestPriorityLanes(unblockedLanes);
|
|
nextLanePriority = return_highestLanePriority;
|
|
} else {
|
|
if (pingedLanes !== NoLanes) {
|
|
nextLanes = getHighestPriorityLanes(pingedLanes);
|
|
nextLanePriority = return_highestLanePriority;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (nextLanes === NoLanes) {
|
|
return NoLanes;
|
|
}
|
|
nextLanes = pendingLanes & getEqualOrHigherPriorityLanes(nextLanes);
|
|
if (wipLanes !== NoLanes && wipLanes !== nextLanes && (wipLanes & suspendedLanes) === NoLanes) {
|
|
getHighestPriorityLanes(wipLanes);
|
|
var wipLanePriority = return_highestLanePriority;
|
|
if (nextLanePriority <= wipLanePriority) {
|
|
return wipLanes;
|
|
} else {
|
|
return_highestLanePriority = nextLanePriority;
|
|
}
|
|
}
|
|
var entangledLanes = root2.entangledLanes;
|
|
if (entangledLanes !== NoLanes) {
|
|
var entanglements = root2.entanglements;
|
|
var lanes = nextLanes & entangledLanes;
|
|
while (lanes > 0) {
|
|
var index2 = pickArbitraryLaneIndex(lanes);
|
|
var lane = 1 << index2;
|
|
nextLanes |= entanglements[index2];
|
|
lanes &= ~lane;
|
|
}
|
|
}
|
|
return nextLanes;
|
|
}
|
|
function getMostRecentEventTime(root2, lanes) {
|
|
var eventTimes = root2.eventTimes;
|
|
var mostRecentEventTime = NoTimestamp;
|
|
while (lanes > 0) {
|
|
var index2 = pickArbitraryLaneIndex(lanes);
|
|
var lane = 1 << index2;
|
|
var eventTime = eventTimes[index2];
|
|
if (eventTime > mostRecentEventTime) {
|
|
mostRecentEventTime = eventTime;
|
|
}
|
|
lanes &= ~lane;
|
|
}
|
|
return mostRecentEventTime;
|
|
}
|
|
function computeExpirationTime(lane, currentTime) {
|
|
getHighestPriorityLanes(lane);
|
|
var priority = return_highestLanePriority;
|
|
if (priority >= InputContinuousLanePriority) {
|
|
return currentTime + 250;
|
|
} else if (priority >= TransitionPriority) {
|
|
return currentTime + 5e3;
|
|
} else {
|
|
return NoTimestamp;
|
|
}
|
|
}
|
|
function markStarvedLanesAsExpired(root2, currentTime) {
|
|
var pendingLanes = root2.pendingLanes;
|
|
var suspendedLanes = root2.suspendedLanes;
|
|
var pingedLanes = root2.pingedLanes;
|
|
var expirationTimes = root2.expirationTimes;
|
|
var lanes = pendingLanes;
|
|
while (lanes > 0) {
|
|
var index2 = pickArbitraryLaneIndex(lanes);
|
|
var lane = 1 << index2;
|
|
var expirationTime = expirationTimes[index2];
|
|
if (expirationTime === NoTimestamp) {
|
|
if ((lane & suspendedLanes) === NoLanes || (lane & pingedLanes) !== NoLanes) {
|
|
expirationTimes[index2] = computeExpirationTime(lane, currentTime);
|
|
}
|
|
} else if (expirationTime <= currentTime) {
|
|
root2.expiredLanes |= lane;
|
|
}
|
|
lanes &= ~lane;
|
|
}
|
|
}
|
|
function getLanesToRetrySynchronouslyOnError(root2) {
|
|
var everythingButOffscreen = root2.pendingLanes & ~OffscreenLane;
|
|
if (everythingButOffscreen !== NoLanes) {
|
|
return everythingButOffscreen;
|
|
}
|
|
if (everythingButOffscreen & OffscreenLane) {
|
|
return OffscreenLane;
|
|
}
|
|
return NoLanes;
|
|
}
|
|
function returnNextLanesPriority() {
|
|
return return_highestLanePriority;
|
|
}
|
|
function includesNonIdleWork(lanes) {
|
|
return (lanes & NonIdleLanes) !== NoLanes;
|
|
}
|
|
function includesOnlyRetries(lanes) {
|
|
return (lanes & RetryLanes) === lanes;
|
|
}
|
|
function includesOnlyTransitions(lanes) {
|
|
return (lanes & TransitionLanes) === lanes;
|
|
}
|
|
function findUpdateLane(lanePriority, wipLanes) {
|
|
switch (lanePriority) {
|
|
case NoLanePriority:
|
|
break;
|
|
case SyncLanePriority:
|
|
return SyncLane;
|
|
case SyncBatchedLanePriority:
|
|
return SyncBatchedLane;
|
|
case InputDiscreteLanePriority: {
|
|
var _lane = pickArbitraryLane(InputDiscreteLanes & ~wipLanes);
|
|
if (_lane === NoLane) {
|
|
return findUpdateLane(InputContinuousLanePriority, wipLanes);
|
|
}
|
|
return _lane;
|
|
}
|
|
case InputContinuousLanePriority: {
|
|
var _lane2 = pickArbitraryLane(InputContinuousLanes & ~wipLanes);
|
|
if (_lane2 === NoLane) {
|
|
return findUpdateLane(DefaultLanePriority, wipLanes);
|
|
}
|
|
return _lane2;
|
|
}
|
|
case DefaultLanePriority: {
|
|
var _lane3 = pickArbitraryLane(DefaultLanes & ~wipLanes);
|
|
if (_lane3 === NoLane) {
|
|
_lane3 = pickArbitraryLane(TransitionLanes & ~wipLanes);
|
|
if (_lane3 === NoLane) {
|
|
_lane3 = pickArbitraryLane(DefaultLanes);
|
|
}
|
|
}
|
|
return _lane3;
|
|
}
|
|
case TransitionPriority:
|
|
case RetryLanePriority:
|
|
break;
|
|
case IdleLanePriority:
|
|
var lane = pickArbitraryLane(IdleLanes & ~wipLanes);
|
|
if (lane === NoLane) {
|
|
lane = pickArbitraryLane(IdleLanes);
|
|
}
|
|
return lane;
|
|
}
|
|
{
|
|
{
|
|
throw Error("Invalid update priority: " + lanePriority + ". This is a bug in React.");
|
|
}
|
|
}
|
|
}
|
|
function findTransitionLane(wipLanes, pendingLanes) {
|
|
var lane = pickArbitraryLane(TransitionLanes & ~pendingLanes);
|
|
if (lane === NoLane) {
|
|
lane = pickArbitraryLane(TransitionLanes & ~wipLanes);
|
|
if (lane === NoLane) {
|
|
lane = pickArbitraryLane(TransitionLanes);
|
|
}
|
|
}
|
|
return lane;
|
|
}
|
|
function findRetryLane(wipLanes) {
|
|
var lane = pickArbitraryLane(RetryLanes & ~wipLanes);
|
|
if (lane === NoLane) {
|
|
lane = pickArbitraryLane(RetryLanes);
|
|
}
|
|
return lane;
|
|
}
|
|
function getHighestPriorityLane(lanes) {
|
|
return lanes & -lanes;
|
|
}
|
|
function getLowestPriorityLane(lanes) {
|
|
var index2 = 31 - clz32(lanes);
|
|
return index2 < 0 ? NoLanes : 1 << index2;
|
|
}
|
|
function getEqualOrHigherPriorityLanes(lanes) {
|
|
return (getLowestPriorityLane(lanes) << 1) - 1;
|
|
}
|
|
function pickArbitraryLane(lanes) {
|
|
return getHighestPriorityLane(lanes);
|
|
}
|
|
function pickArbitraryLaneIndex(lanes) {
|
|
return 31 - clz32(lanes);
|
|
}
|
|
function laneToIndex(lane) {
|
|
return pickArbitraryLaneIndex(lane);
|
|
}
|
|
function includesSomeLane(a3, b3) {
|
|
return (a3 & b3) !== NoLanes;
|
|
}
|
|
function isSubsetOfLanes(set2, subset) {
|
|
return (set2 & subset) === subset;
|
|
}
|
|
function mergeLanes(a3, b3) {
|
|
return a3 | b3;
|
|
}
|
|
function removeLanes(set2, subset) {
|
|
return set2 & ~subset;
|
|
}
|
|
function laneToLanes(lane) {
|
|
return lane;
|
|
}
|
|
function higherPriorityLane(a3, b3) {
|
|
return a3 !== NoLane && a3 < b3 ? a3 : b3;
|
|
}
|
|
function createLaneMap(initial) {
|
|
var laneMap = [];
|
|
for (var i3 = 0; i3 < TotalLanes; i3++) {
|
|
laneMap.push(initial);
|
|
}
|
|
return laneMap;
|
|
}
|
|
function markRootUpdated(root2, updateLane, eventTime) {
|
|
root2.pendingLanes |= updateLane;
|
|
var higherPriorityLanes = updateLane - 1;
|
|
root2.suspendedLanes &= higherPriorityLanes;
|
|
root2.pingedLanes &= higherPriorityLanes;
|
|
var eventTimes = root2.eventTimes;
|
|
var index2 = laneToIndex(updateLane);
|
|
eventTimes[index2] = eventTime;
|
|
}
|
|
function markRootSuspended(root2, suspendedLanes) {
|
|
root2.suspendedLanes |= suspendedLanes;
|
|
root2.pingedLanes &= ~suspendedLanes;
|
|
var expirationTimes = root2.expirationTimes;
|
|
var lanes = suspendedLanes;
|
|
while (lanes > 0) {
|
|
var index2 = pickArbitraryLaneIndex(lanes);
|
|
var lane = 1 << index2;
|
|
expirationTimes[index2] = NoTimestamp;
|
|
lanes &= ~lane;
|
|
}
|
|
}
|
|
function markRootPinged(root2, pingedLanes, eventTime) {
|
|
root2.pingedLanes |= root2.suspendedLanes & pingedLanes;
|
|
}
|
|
function markDiscreteUpdatesExpired(root2) {
|
|
root2.expiredLanes |= InputDiscreteLanes & root2.pendingLanes;
|
|
}
|
|
function hasDiscreteLanes(lanes) {
|
|
return (lanes & InputDiscreteLanes) !== NoLanes;
|
|
}
|
|
function markRootMutableRead(root2, updateLane) {
|
|
root2.mutableReadLanes |= updateLane & root2.pendingLanes;
|
|
}
|
|
function markRootFinished(root2, remainingLanes) {
|
|
var noLongerPendingLanes = root2.pendingLanes & ~remainingLanes;
|
|
root2.pendingLanes = remainingLanes;
|
|
root2.suspendedLanes = 0;
|
|
root2.pingedLanes = 0;
|
|
root2.expiredLanes &= remainingLanes;
|
|
root2.mutableReadLanes &= remainingLanes;
|
|
root2.entangledLanes &= remainingLanes;
|
|
var entanglements = root2.entanglements;
|
|
var eventTimes = root2.eventTimes;
|
|
var expirationTimes = root2.expirationTimes;
|
|
var lanes = noLongerPendingLanes;
|
|
while (lanes > 0) {
|
|
var index2 = pickArbitraryLaneIndex(lanes);
|
|
var lane = 1 << index2;
|
|
entanglements[index2] = NoLanes;
|
|
eventTimes[index2] = NoTimestamp;
|
|
expirationTimes[index2] = NoTimestamp;
|
|
lanes &= ~lane;
|
|
}
|
|
}
|
|
function markRootEntangled(root2, entangledLanes) {
|
|
root2.entangledLanes |= entangledLanes;
|
|
var entanglements = root2.entanglements;
|
|
var lanes = entangledLanes;
|
|
while (lanes > 0) {
|
|
var index2 = pickArbitraryLaneIndex(lanes);
|
|
var lane = 1 << index2;
|
|
entanglements[index2] |= entangledLanes;
|
|
lanes &= ~lane;
|
|
}
|
|
}
|
|
var clz32 = Math.clz32 ? Math.clz32 : clz32Fallback;
|
|
var log = Math.log;
|
|
var LN2 = Math.LN2;
|
|
function clz32Fallback(lanes) {
|
|
if (lanes === 0) {
|
|
return 32;
|
|
}
|
|
return 31 - (log(lanes) / LN2 | 0) | 0;
|
|
}
|
|
var UserBlockingPriority$1 = Scheduler.unstable_UserBlockingPriority, runWithPriority = Scheduler.unstable_runWithPriority;
|
|
var _enabled = true;
|
|
function setEnabled(enabled) {
|
|
_enabled = !!enabled;
|
|
}
|
|
function isEnabled() {
|
|
return _enabled;
|
|
}
|
|
function createEventListenerWrapperWithPriority(targetContainer, domEventName, eventSystemFlags) {
|
|
var eventPriority = getEventPriorityForPluginSystem(domEventName);
|
|
var listenerWrapper;
|
|
switch (eventPriority) {
|
|
case DiscreteEvent:
|
|
listenerWrapper = dispatchDiscreteEvent;
|
|
break;
|
|
case UserBlockingEvent:
|
|
listenerWrapper = dispatchUserBlockingUpdate;
|
|
break;
|
|
case ContinuousEvent:
|
|
default:
|
|
listenerWrapper = dispatchEvent;
|
|
break;
|
|
}
|
|
return listenerWrapper.bind(null, domEventName, eventSystemFlags, targetContainer);
|
|
}
|
|
function dispatchDiscreteEvent(domEventName, eventSystemFlags, container, nativeEvent) {
|
|
{
|
|
flushDiscreteUpdatesIfNeeded(nativeEvent.timeStamp);
|
|
}
|
|
discreteUpdates(dispatchEvent, domEventName, eventSystemFlags, container, nativeEvent);
|
|
}
|
|
function dispatchUserBlockingUpdate(domEventName, eventSystemFlags, container, nativeEvent) {
|
|
{
|
|
runWithPriority(UserBlockingPriority$1, dispatchEvent.bind(null, domEventName, eventSystemFlags, container, nativeEvent));
|
|
}
|
|
}
|
|
function dispatchEvent(domEventName, eventSystemFlags, targetContainer, nativeEvent) {
|
|
if (!_enabled) {
|
|
return;
|
|
}
|
|
var allowReplay = true;
|
|
{
|
|
allowReplay = (eventSystemFlags & IS_CAPTURE_PHASE) === 0;
|
|
}
|
|
if (allowReplay && hasQueuedDiscreteEvents() && isReplayableDiscreteEvent(domEventName)) {
|
|
queueDiscreteEvent(null, domEventName, eventSystemFlags, targetContainer, nativeEvent);
|
|
return;
|
|
}
|
|
var blockedOn = attemptToDispatchEvent(domEventName, eventSystemFlags, targetContainer, nativeEvent);
|
|
if (blockedOn === null) {
|
|
if (allowReplay) {
|
|
clearIfContinuousEvent(domEventName, nativeEvent);
|
|
}
|
|
return;
|
|
}
|
|
if (allowReplay) {
|
|
if (isReplayableDiscreteEvent(domEventName)) {
|
|
queueDiscreteEvent(blockedOn, domEventName, eventSystemFlags, targetContainer, nativeEvent);
|
|
return;
|
|
}
|
|
if (queueIfContinuousEvent(blockedOn, domEventName, eventSystemFlags, targetContainer, nativeEvent)) {
|
|
return;
|
|
}
|
|
clearIfContinuousEvent(domEventName, nativeEvent);
|
|
}
|
|
dispatchEventForPluginEventSystem(domEventName, eventSystemFlags, nativeEvent, null, targetContainer);
|
|
}
|
|
function attemptToDispatchEvent(domEventName, eventSystemFlags, targetContainer, nativeEvent) {
|
|
var nativeEventTarget = getEventTarget(nativeEvent);
|
|
var targetInst = getClosestInstanceFromNode(nativeEventTarget);
|
|
if (targetInst !== null) {
|
|
var nearestMounted = getNearestMountedFiber(targetInst);
|
|
if (nearestMounted === null) {
|
|
targetInst = null;
|
|
} else {
|
|
var tag = nearestMounted.tag;
|
|
if (tag === SuspenseComponent) {
|
|
var instance = getSuspenseInstanceFromFiber(nearestMounted);
|
|
if (instance !== null) {
|
|
return instance;
|
|
}
|
|
targetInst = null;
|
|
} else if (tag === HostRoot) {
|
|
var root2 = nearestMounted.stateNode;
|
|
if (root2.hydrate) {
|
|
return getContainerFromFiber(nearestMounted);
|
|
}
|
|
targetInst = null;
|
|
} else if (nearestMounted !== targetInst) {
|
|
targetInst = null;
|
|
}
|
|
}
|
|
}
|
|
dispatchEventForPluginEventSystem(domEventName, eventSystemFlags, nativeEvent, targetInst, targetContainer);
|
|
return null;
|
|
}
|
|
function addEventBubbleListener(target, eventType, listener) {
|
|
target.addEventListener(eventType, listener, false);
|
|
return listener;
|
|
}
|
|
function addEventCaptureListener(target, eventType, listener) {
|
|
target.addEventListener(eventType, listener, true);
|
|
return listener;
|
|
}
|
|
function addEventCaptureListenerWithPassiveFlag(target, eventType, listener, passive) {
|
|
target.addEventListener(eventType, listener, {
|
|
capture: true,
|
|
passive
|
|
});
|
|
return listener;
|
|
}
|
|
function addEventBubbleListenerWithPassiveFlag(target, eventType, listener, passive) {
|
|
target.addEventListener(eventType, listener, {
|
|
passive
|
|
});
|
|
return listener;
|
|
}
|
|
var root = null;
|
|
var startText = null;
|
|
var fallbackText = null;
|
|
function initialize(nativeEventTarget) {
|
|
root = nativeEventTarget;
|
|
startText = getText();
|
|
return true;
|
|
}
|
|
function reset() {
|
|
root = null;
|
|
startText = null;
|
|
fallbackText = null;
|
|
}
|
|
function getData() {
|
|
if (fallbackText) {
|
|
return fallbackText;
|
|
}
|
|
var start;
|
|
var startValue = startText;
|
|
var startLength = startValue.length;
|
|
var end;
|
|
var endValue = getText();
|
|
var endLength = endValue.length;
|
|
for (start = 0; start < startLength; start++) {
|
|
if (startValue[start] !== endValue[start]) {
|
|
break;
|
|
}
|
|
}
|
|
var minEnd = startLength - start;
|
|
for (end = 1; end <= minEnd; end++) {
|
|
if (startValue[startLength - end] !== endValue[endLength - end]) {
|
|
break;
|
|
}
|
|
}
|
|
var sliceTail = end > 1 ? 1 - end : void 0;
|
|
fallbackText = endValue.slice(start, sliceTail);
|
|
return fallbackText;
|
|
}
|
|
function getText() {
|
|
if ("value" in root) {
|
|
return root.value;
|
|
}
|
|
return root.textContent;
|
|
}
|
|
function getEventCharCode(nativeEvent) {
|
|
var charCode;
|
|
var keyCode = nativeEvent.keyCode;
|
|
if ("charCode" in nativeEvent) {
|
|
charCode = nativeEvent.charCode;
|
|
if (charCode === 0 && keyCode === 13) {
|
|
charCode = 13;
|
|
}
|
|
} else {
|
|
charCode = keyCode;
|
|
}
|
|
if (charCode === 10) {
|
|
charCode = 13;
|
|
}
|
|
if (charCode >= 32 || charCode === 13) {
|
|
return charCode;
|
|
}
|
|
return 0;
|
|
}
|
|
function functionThatReturnsTrue() {
|
|
return true;
|
|
}
|
|
function functionThatReturnsFalse() {
|
|
return false;
|
|
}
|
|
function createSyntheticEvent(Interface) {
|
|
function SyntheticBaseEvent(reactName, reactEventType, targetInst, nativeEvent, nativeEventTarget) {
|
|
this._reactName = reactName;
|
|
this._targetInst = targetInst;
|
|
this.type = reactEventType;
|
|
this.nativeEvent = nativeEvent;
|
|
this.target = nativeEventTarget;
|
|
this.currentTarget = null;
|
|
for (var _propName in Interface) {
|
|
if (!Interface.hasOwnProperty(_propName)) {
|
|
continue;
|
|
}
|
|
var normalize = Interface[_propName];
|
|
if (normalize) {
|
|
this[_propName] = normalize(nativeEvent);
|
|
} else {
|
|
this[_propName] = nativeEvent[_propName];
|
|
}
|
|
}
|
|
var defaultPrevented = nativeEvent.defaultPrevented != null ? nativeEvent.defaultPrevented : nativeEvent.returnValue === false;
|
|
if (defaultPrevented) {
|
|
this.isDefaultPrevented = functionThatReturnsTrue;
|
|
} else {
|
|
this.isDefaultPrevented = functionThatReturnsFalse;
|
|
}
|
|
this.isPropagationStopped = functionThatReturnsFalse;
|
|
return this;
|
|
}
|
|
_assign(SyntheticBaseEvent.prototype, {
|
|
preventDefault: function() {
|
|
this.defaultPrevented = true;
|
|
var event = this.nativeEvent;
|
|
if (!event) {
|
|
return;
|
|
}
|
|
if (event.preventDefault) {
|
|
event.preventDefault();
|
|
} else if (typeof event.returnValue !== "unknown") {
|
|
event.returnValue = false;
|
|
}
|
|
this.isDefaultPrevented = functionThatReturnsTrue;
|
|
},
|
|
stopPropagation: function() {
|
|
var event = this.nativeEvent;
|
|
if (!event) {
|
|
return;
|
|
}
|
|
if (event.stopPropagation) {
|
|
event.stopPropagation();
|
|
} else if (typeof event.cancelBubble !== "unknown") {
|
|
event.cancelBubble = true;
|
|
}
|
|
this.isPropagationStopped = functionThatReturnsTrue;
|
|
},
|
|
persist: function() {
|
|
},
|
|
isPersistent: functionThatReturnsTrue
|
|
});
|
|
return SyntheticBaseEvent;
|
|
}
|
|
var EventInterface = {
|
|
eventPhase: 0,
|
|
bubbles: 0,
|
|
cancelable: 0,
|
|
timeStamp: function(event) {
|
|
return event.timeStamp || Date.now();
|
|
},
|
|
defaultPrevented: 0,
|
|
isTrusted: 0
|
|
};
|
|
var SyntheticEvent = createSyntheticEvent(EventInterface);
|
|
var UIEventInterface = _assign({}, EventInterface, {
|
|
view: 0,
|
|
detail: 0
|
|
});
|
|
var SyntheticUIEvent = createSyntheticEvent(UIEventInterface);
|
|
var lastMovementX;
|
|
var lastMovementY;
|
|
var lastMouseEvent;
|
|
function updateMouseMovementPolyfillState(event) {
|
|
if (event !== lastMouseEvent) {
|
|
if (lastMouseEvent && event.type === "mousemove") {
|
|
lastMovementX = event.screenX - lastMouseEvent.screenX;
|
|
lastMovementY = event.screenY - lastMouseEvent.screenY;
|
|
} else {
|
|
lastMovementX = 0;
|
|
lastMovementY = 0;
|
|
}
|
|
lastMouseEvent = event;
|
|
}
|
|
}
|
|
var MouseEventInterface = _assign({}, UIEventInterface, {
|
|
screenX: 0,
|
|
screenY: 0,
|
|
clientX: 0,
|
|
clientY: 0,
|
|
pageX: 0,
|
|
pageY: 0,
|
|
ctrlKey: 0,
|
|
shiftKey: 0,
|
|
altKey: 0,
|
|
metaKey: 0,
|
|
getModifierState: getEventModifierState,
|
|
button: 0,
|
|
buttons: 0,
|
|
relatedTarget: function(event) {
|
|
if (event.relatedTarget === void 0)
|
|
return event.fromElement === event.srcElement ? event.toElement : event.fromElement;
|
|
return event.relatedTarget;
|
|
},
|
|
movementX: function(event) {
|
|
if ("movementX" in event) {
|
|
return event.movementX;
|
|
}
|
|
updateMouseMovementPolyfillState(event);
|
|
return lastMovementX;
|
|
},
|
|
movementY: function(event) {
|
|
if ("movementY" in event) {
|
|
return event.movementY;
|
|
}
|
|
return lastMovementY;
|
|
}
|
|
});
|
|
var SyntheticMouseEvent = createSyntheticEvent(MouseEventInterface);
|
|
var DragEventInterface = _assign({}, MouseEventInterface, {
|
|
dataTransfer: 0
|
|
});
|
|
var SyntheticDragEvent = createSyntheticEvent(DragEventInterface);
|
|
var FocusEventInterface = _assign({}, UIEventInterface, {
|
|
relatedTarget: 0
|
|
});
|
|
var SyntheticFocusEvent = createSyntheticEvent(FocusEventInterface);
|
|
var AnimationEventInterface = _assign({}, EventInterface, {
|
|
animationName: 0,
|
|
elapsedTime: 0,
|
|
pseudoElement: 0
|
|
});
|
|
var SyntheticAnimationEvent = createSyntheticEvent(AnimationEventInterface);
|
|
var ClipboardEventInterface = _assign({}, EventInterface, {
|
|
clipboardData: function(event) {
|
|
return "clipboardData" in event ? event.clipboardData : window.clipboardData;
|
|
}
|
|
});
|
|
var SyntheticClipboardEvent = createSyntheticEvent(ClipboardEventInterface);
|
|
var CompositionEventInterface = _assign({}, EventInterface, {
|
|
data: 0
|
|
});
|
|
var SyntheticCompositionEvent = createSyntheticEvent(CompositionEventInterface);
|
|
var SyntheticInputEvent = SyntheticCompositionEvent;
|
|
var normalizeKey = {
|
|
Esc: "Escape",
|
|
Spacebar: " ",
|
|
Left: "ArrowLeft",
|
|
Up: "ArrowUp",
|
|
Right: "ArrowRight",
|
|
Down: "ArrowDown",
|
|
Del: "Delete",
|
|
Win: "OS",
|
|
Menu: "ContextMenu",
|
|
Apps: "ContextMenu",
|
|
Scroll: "ScrollLock",
|
|
MozPrintableKey: "Unidentified"
|
|
};
|
|
var translateToKey = {
|
|
"8": "Backspace",
|
|
"9": "Tab",
|
|
"12": "Clear",
|
|
"13": "Enter",
|
|
"16": "Shift",
|
|
"17": "Control",
|
|
"18": "Alt",
|
|
"19": "Pause",
|
|
"20": "CapsLock",
|
|
"27": "Escape",
|
|
"32": " ",
|
|
"33": "PageUp",
|
|
"34": "PageDown",
|
|
"35": "End",
|
|
"36": "Home",
|
|
"37": "ArrowLeft",
|
|
"38": "ArrowUp",
|
|
"39": "ArrowRight",
|
|
"40": "ArrowDown",
|
|
"45": "Insert",
|
|
"46": "Delete",
|
|
"112": "F1",
|
|
"113": "F2",
|
|
"114": "F3",
|
|
"115": "F4",
|
|
"116": "F5",
|
|
"117": "F6",
|
|
"118": "F7",
|
|
"119": "F8",
|
|
"120": "F9",
|
|
"121": "F10",
|
|
"122": "F11",
|
|
"123": "F12",
|
|
"144": "NumLock",
|
|
"145": "ScrollLock",
|
|
"224": "Meta"
|
|
};
|
|
function getEventKey(nativeEvent) {
|
|
if (nativeEvent.key) {
|
|
var key = normalizeKey[nativeEvent.key] || nativeEvent.key;
|
|
if (key !== "Unidentified") {
|
|
return key;
|
|
}
|
|
}
|
|
if (nativeEvent.type === "keypress") {
|
|
var charCode = getEventCharCode(nativeEvent);
|
|
return charCode === 13 ? "Enter" : String.fromCharCode(charCode);
|
|
}
|
|
if (nativeEvent.type === "keydown" || nativeEvent.type === "keyup") {
|
|
return translateToKey[nativeEvent.keyCode] || "Unidentified";
|
|
}
|
|
return "";
|
|
}
|
|
var modifierKeyToProp = {
|
|
Alt: "altKey",
|
|
Control: "ctrlKey",
|
|
Meta: "metaKey",
|
|
Shift: "shiftKey"
|
|
};
|
|
function modifierStateGetter(keyArg) {
|
|
var syntheticEvent = this;
|
|
var nativeEvent = syntheticEvent.nativeEvent;
|
|
if (nativeEvent.getModifierState) {
|
|
return nativeEvent.getModifierState(keyArg);
|
|
}
|
|
var keyProp = modifierKeyToProp[keyArg];
|
|
return keyProp ? !!nativeEvent[keyProp] : false;
|
|
}
|
|
function getEventModifierState(nativeEvent) {
|
|
return modifierStateGetter;
|
|
}
|
|
var KeyboardEventInterface = _assign({}, UIEventInterface, {
|
|
key: getEventKey,
|
|
code: 0,
|
|
location: 0,
|
|
ctrlKey: 0,
|
|
shiftKey: 0,
|
|
altKey: 0,
|
|
metaKey: 0,
|
|
repeat: 0,
|
|
locale: 0,
|
|
getModifierState: getEventModifierState,
|
|
charCode: function(event) {
|
|
if (event.type === "keypress") {
|
|
return getEventCharCode(event);
|
|
}
|
|
return 0;
|
|
},
|
|
keyCode: function(event) {
|
|
if (event.type === "keydown" || event.type === "keyup") {
|
|
return event.keyCode;
|
|
}
|
|
return 0;
|
|
},
|
|
which: function(event) {
|
|
if (event.type === "keypress") {
|
|
return getEventCharCode(event);
|
|
}
|
|
if (event.type === "keydown" || event.type === "keyup") {
|
|
return event.keyCode;
|
|
}
|
|
return 0;
|
|
}
|
|
});
|
|
var SyntheticKeyboardEvent = createSyntheticEvent(KeyboardEventInterface);
|
|
var PointerEventInterface = _assign({}, MouseEventInterface, {
|
|
pointerId: 0,
|
|
width: 0,
|
|
height: 0,
|
|
pressure: 0,
|
|
tangentialPressure: 0,
|
|
tiltX: 0,
|
|
tiltY: 0,
|
|
twist: 0,
|
|
pointerType: 0,
|
|
isPrimary: 0
|
|
});
|
|
var SyntheticPointerEvent = createSyntheticEvent(PointerEventInterface);
|
|
var TouchEventInterface = _assign({}, UIEventInterface, {
|
|
touches: 0,
|
|
targetTouches: 0,
|
|
changedTouches: 0,
|
|
altKey: 0,
|
|
metaKey: 0,
|
|
ctrlKey: 0,
|
|
shiftKey: 0,
|
|
getModifierState: getEventModifierState
|
|
});
|
|
var SyntheticTouchEvent = createSyntheticEvent(TouchEventInterface);
|
|
var TransitionEventInterface = _assign({}, EventInterface, {
|
|
propertyName: 0,
|
|
elapsedTime: 0,
|
|
pseudoElement: 0
|
|
});
|
|
var SyntheticTransitionEvent = createSyntheticEvent(TransitionEventInterface);
|
|
var WheelEventInterface = _assign({}, MouseEventInterface, {
|
|
deltaX: function(event) {
|
|
return "deltaX" in event ? event.deltaX : "wheelDeltaX" in event ? -event.wheelDeltaX : 0;
|
|
},
|
|
deltaY: function(event) {
|
|
return "deltaY" in event ? event.deltaY : "wheelDeltaY" in event ? -event.wheelDeltaY : "wheelDelta" in event ? -event.wheelDelta : 0;
|
|
},
|
|
deltaZ: 0,
|
|
deltaMode: 0
|
|
});
|
|
var SyntheticWheelEvent = createSyntheticEvent(WheelEventInterface);
|
|
var END_KEYCODES = [9, 13, 27, 32];
|
|
var START_KEYCODE = 229;
|
|
var canUseCompositionEvent = canUseDOM && "CompositionEvent" in window;
|
|
var documentMode = null;
|
|
if (canUseDOM && "documentMode" in document) {
|
|
documentMode = document.documentMode;
|
|
}
|
|
var canUseTextInputEvent = canUseDOM && "TextEvent" in window && !documentMode;
|
|
var useFallbackCompositionData = canUseDOM && (!canUseCompositionEvent || documentMode && documentMode > 8 && documentMode <= 11);
|
|
var SPACEBAR_CODE = 32;
|
|
var SPACEBAR_CHAR = String.fromCharCode(SPACEBAR_CODE);
|
|
function registerEvents() {
|
|
registerTwoPhaseEvent("onBeforeInput", ["compositionend", "keypress", "textInput", "paste"]);
|
|
registerTwoPhaseEvent("onCompositionEnd", ["compositionend", "focusout", "keydown", "keypress", "keyup", "mousedown"]);
|
|
registerTwoPhaseEvent("onCompositionStart", ["compositionstart", "focusout", "keydown", "keypress", "keyup", "mousedown"]);
|
|
registerTwoPhaseEvent("onCompositionUpdate", ["compositionupdate", "focusout", "keydown", "keypress", "keyup", "mousedown"]);
|
|
}
|
|
var hasSpaceKeypress = false;
|
|
function isKeypressCommand(nativeEvent) {
|
|
return (nativeEvent.ctrlKey || nativeEvent.altKey || nativeEvent.metaKey) && !(nativeEvent.ctrlKey && nativeEvent.altKey);
|
|
}
|
|
function getCompositionEventType(domEventName) {
|
|
switch (domEventName) {
|
|
case "compositionstart":
|
|
return "onCompositionStart";
|
|
case "compositionend":
|
|
return "onCompositionEnd";
|
|
case "compositionupdate":
|
|
return "onCompositionUpdate";
|
|
}
|
|
}
|
|
function isFallbackCompositionStart(domEventName, nativeEvent) {
|
|
return domEventName === "keydown" && nativeEvent.keyCode === START_KEYCODE;
|
|
}
|
|
function isFallbackCompositionEnd(domEventName, nativeEvent) {
|
|
switch (domEventName) {
|
|
case "keyup":
|
|
return END_KEYCODES.indexOf(nativeEvent.keyCode) !== -1;
|
|
case "keydown":
|
|
return nativeEvent.keyCode !== START_KEYCODE;
|
|
case "keypress":
|
|
case "mousedown":
|
|
case "focusout":
|
|
return true;
|
|
default:
|
|
return false;
|
|
}
|
|
}
|
|
function getDataFromCustomEvent(nativeEvent) {
|
|
var detail = nativeEvent.detail;
|
|
if (typeof detail === "object" && "data" in detail) {
|
|
return detail.data;
|
|
}
|
|
return null;
|
|
}
|
|
function isUsingKoreanIME(nativeEvent) {
|
|
return nativeEvent.locale === "ko";
|
|
}
|
|
var isComposing = false;
|
|
function extractCompositionEvent(dispatchQueue, domEventName, targetInst, nativeEvent, nativeEventTarget) {
|
|
var eventType;
|
|
var fallbackData;
|
|
if (canUseCompositionEvent) {
|
|
eventType = getCompositionEventType(domEventName);
|
|
} else if (!isComposing) {
|
|
if (isFallbackCompositionStart(domEventName, nativeEvent)) {
|
|
eventType = "onCompositionStart";
|
|
}
|
|
} else if (isFallbackCompositionEnd(domEventName, nativeEvent)) {
|
|
eventType = "onCompositionEnd";
|
|
}
|
|
if (!eventType) {
|
|
return null;
|
|
}
|
|
if (useFallbackCompositionData && !isUsingKoreanIME(nativeEvent)) {
|
|
if (!isComposing && eventType === "onCompositionStart") {
|
|
isComposing = initialize(nativeEventTarget);
|
|
} else if (eventType === "onCompositionEnd") {
|
|
if (isComposing) {
|
|
fallbackData = getData();
|
|
}
|
|
}
|
|
}
|
|
var listeners = accumulateTwoPhaseListeners(targetInst, eventType);
|
|
if (listeners.length > 0) {
|
|
var event = new SyntheticCompositionEvent(eventType, domEventName, null, nativeEvent, nativeEventTarget);
|
|
dispatchQueue.push({
|
|
event,
|
|
listeners
|
|
});
|
|
if (fallbackData) {
|
|
event.data = fallbackData;
|
|
} else {
|
|
var customData = getDataFromCustomEvent(nativeEvent);
|
|
if (customData !== null) {
|
|
event.data = customData;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
function getNativeBeforeInputChars(domEventName, nativeEvent) {
|
|
switch (domEventName) {
|
|
case "compositionend":
|
|
return getDataFromCustomEvent(nativeEvent);
|
|
case "keypress":
|
|
var which = nativeEvent.which;
|
|
if (which !== SPACEBAR_CODE) {
|
|
return null;
|
|
}
|
|
hasSpaceKeypress = true;
|
|
return SPACEBAR_CHAR;
|
|
case "textInput":
|
|
var chars = nativeEvent.data;
|
|
if (chars === SPACEBAR_CHAR && hasSpaceKeypress) {
|
|
return null;
|
|
}
|
|
return chars;
|
|
default:
|
|
return null;
|
|
}
|
|
}
|
|
function getFallbackBeforeInputChars(domEventName, nativeEvent) {
|
|
if (isComposing) {
|
|
if (domEventName === "compositionend" || !canUseCompositionEvent && isFallbackCompositionEnd(domEventName, nativeEvent)) {
|
|
var chars = getData();
|
|
reset();
|
|
isComposing = false;
|
|
return chars;
|
|
}
|
|
return null;
|
|
}
|
|
switch (domEventName) {
|
|
case "paste":
|
|
return null;
|
|
case "keypress":
|
|
if (!isKeypressCommand(nativeEvent)) {
|
|
if (nativeEvent.char && nativeEvent.char.length > 1) {
|
|
return nativeEvent.char;
|
|
} else if (nativeEvent.which) {
|
|
return String.fromCharCode(nativeEvent.which);
|
|
}
|
|
}
|
|
return null;
|
|
case "compositionend":
|
|
return useFallbackCompositionData && !isUsingKoreanIME(nativeEvent) ? null : nativeEvent.data;
|
|
default:
|
|
return null;
|
|
}
|
|
}
|
|
function extractBeforeInputEvent(dispatchQueue, domEventName, targetInst, nativeEvent, nativeEventTarget) {
|
|
var chars;
|
|
if (canUseTextInputEvent) {
|
|
chars = getNativeBeforeInputChars(domEventName, nativeEvent);
|
|
} else {
|
|
chars = getFallbackBeforeInputChars(domEventName, nativeEvent);
|
|
}
|
|
if (!chars) {
|
|
return null;
|
|
}
|
|
var listeners = accumulateTwoPhaseListeners(targetInst, "onBeforeInput");
|
|
if (listeners.length > 0) {
|
|
var event = new SyntheticInputEvent("onBeforeInput", "beforeinput", null, nativeEvent, nativeEventTarget);
|
|
dispatchQueue.push({
|
|
event,
|
|
listeners
|
|
});
|
|
event.data = chars;
|
|
}
|
|
}
|
|
function extractEvents(dispatchQueue, domEventName, targetInst, nativeEvent, nativeEventTarget, eventSystemFlags, targetContainer) {
|
|
extractCompositionEvent(dispatchQueue, domEventName, targetInst, nativeEvent, nativeEventTarget);
|
|
extractBeforeInputEvent(dispatchQueue, domEventName, targetInst, nativeEvent, nativeEventTarget);
|
|
}
|
|
var supportedInputTypes = {
|
|
color: true,
|
|
date: true,
|
|
datetime: true,
|
|
"datetime-local": true,
|
|
email: true,
|
|
month: true,
|
|
number: true,
|
|
password: true,
|
|
range: true,
|
|
search: true,
|
|
tel: true,
|
|
text: true,
|
|
time: true,
|
|
url: true,
|
|
week: true
|
|
};
|
|
function isTextInputElement(elem) {
|
|
var nodeName = elem && elem.nodeName && elem.nodeName.toLowerCase();
|
|
if (nodeName === "input") {
|
|
return !!supportedInputTypes[elem.type];
|
|
}
|
|
if (nodeName === "textarea") {
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
function isEventSupported(eventNameSuffix) {
|
|
if (!canUseDOM) {
|
|
return false;
|
|
}
|
|
var eventName = "on" + eventNameSuffix;
|
|
var isSupported = eventName in document;
|
|
if (!isSupported) {
|
|
var element = document.createElement("div");
|
|
element.setAttribute(eventName, "return;");
|
|
isSupported = typeof element[eventName] === "function";
|
|
}
|
|
return isSupported;
|
|
}
|
|
function registerEvents$1() {
|
|
registerTwoPhaseEvent("onChange", ["change", "click", "focusin", "focusout", "input", "keydown", "keyup", "selectionchange"]);
|
|
}
|
|
function createAndAccumulateChangeEvent(dispatchQueue, inst, nativeEvent, target) {
|
|
enqueueStateRestore(target);
|
|
var listeners = accumulateTwoPhaseListeners(inst, "onChange");
|
|
if (listeners.length > 0) {
|
|
var event = new SyntheticEvent("onChange", "change", null, nativeEvent, target);
|
|
dispatchQueue.push({
|
|
event,
|
|
listeners
|
|
});
|
|
}
|
|
}
|
|
var activeElement = null;
|
|
var activeElementInst = null;
|
|
function shouldUseChangeEvent(elem) {
|
|
var nodeName = elem.nodeName && elem.nodeName.toLowerCase();
|
|
return nodeName === "select" || nodeName === "input" && elem.type === "file";
|
|
}
|
|
function manualDispatchChangeEvent(nativeEvent) {
|
|
var dispatchQueue = [];
|
|
createAndAccumulateChangeEvent(dispatchQueue, activeElementInst, nativeEvent, getEventTarget(nativeEvent));
|
|
batchedUpdates(runEventInBatch, dispatchQueue);
|
|
}
|
|
function runEventInBatch(dispatchQueue) {
|
|
processDispatchQueue(dispatchQueue, 0);
|
|
}
|
|
function getInstIfValueChanged(targetInst) {
|
|
var targetNode = getNodeFromInstance(targetInst);
|
|
if (updateValueIfChanged(targetNode)) {
|
|
return targetInst;
|
|
}
|
|
}
|
|
function getTargetInstForChangeEvent(domEventName, targetInst) {
|
|
if (domEventName === "change") {
|
|
return targetInst;
|
|
}
|
|
}
|
|
var isInputEventSupported = false;
|
|
if (canUseDOM) {
|
|
isInputEventSupported = isEventSupported("input") && (!document.documentMode || document.documentMode > 9);
|
|
}
|
|
function startWatchingForValueChange(target, targetInst) {
|
|
activeElement = target;
|
|
activeElementInst = targetInst;
|
|
activeElement.attachEvent("onpropertychange", handlePropertyChange);
|
|
}
|
|
function stopWatchingForValueChange() {
|
|
if (!activeElement) {
|
|
return;
|
|
}
|
|
activeElement.detachEvent("onpropertychange", handlePropertyChange);
|
|
activeElement = null;
|
|
activeElementInst = null;
|
|
}
|
|
function handlePropertyChange(nativeEvent) {
|
|
if (nativeEvent.propertyName !== "value") {
|
|
return;
|
|
}
|
|
if (getInstIfValueChanged(activeElementInst)) {
|
|
manualDispatchChangeEvent(nativeEvent);
|
|
}
|
|
}
|
|
function handleEventsForInputEventPolyfill(domEventName, target, targetInst) {
|
|
if (domEventName === "focusin") {
|
|
stopWatchingForValueChange();
|
|
startWatchingForValueChange(target, targetInst);
|
|
} else if (domEventName === "focusout") {
|
|
stopWatchingForValueChange();
|
|
}
|
|
}
|
|
function getTargetInstForInputEventPolyfill(domEventName, targetInst) {
|
|
if (domEventName === "selectionchange" || domEventName === "keyup" || domEventName === "keydown") {
|
|
return getInstIfValueChanged(activeElementInst);
|
|
}
|
|
}
|
|
function shouldUseClickEvent(elem) {
|
|
var nodeName = elem.nodeName;
|
|
return nodeName && nodeName.toLowerCase() === "input" && (elem.type === "checkbox" || elem.type === "radio");
|
|
}
|
|
function getTargetInstForClickEvent(domEventName, targetInst) {
|
|
if (domEventName === "click") {
|
|
return getInstIfValueChanged(targetInst);
|
|
}
|
|
}
|
|
function getTargetInstForInputOrChangeEvent(domEventName, targetInst) {
|
|
if (domEventName === "input" || domEventName === "change") {
|
|
return getInstIfValueChanged(targetInst);
|
|
}
|
|
}
|
|
function handleControlledInputBlur(node) {
|
|
var state = node._wrapperState;
|
|
if (!state || !state.controlled || node.type !== "number") {
|
|
return;
|
|
}
|
|
{
|
|
setDefaultValue(node, "number", node.value);
|
|
}
|
|
}
|
|
function extractEvents$1(dispatchQueue, domEventName, targetInst, nativeEvent, nativeEventTarget, eventSystemFlags, targetContainer) {
|
|
var targetNode = targetInst ? getNodeFromInstance(targetInst) : window;
|
|
var getTargetInstFunc, handleEventFunc;
|
|
if (shouldUseChangeEvent(targetNode)) {
|
|
getTargetInstFunc = getTargetInstForChangeEvent;
|
|
} else if (isTextInputElement(targetNode)) {
|
|
if (isInputEventSupported) {
|
|
getTargetInstFunc = getTargetInstForInputOrChangeEvent;
|
|
} else {
|
|
getTargetInstFunc = getTargetInstForInputEventPolyfill;
|
|
handleEventFunc = handleEventsForInputEventPolyfill;
|
|
}
|
|
} else if (shouldUseClickEvent(targetNode)) {
|
|
getTargetInstFunc = getTargetInstForClickEvent;
|
|
}
|
|
if (getTargetInstFunc) {
|
|
var inst = getTargetInstFunc(domEventName, targetInst);
|
|
if (inst) {
|
|
createAndAccumulateChangeEvent(dispatchQueue, inst, nativeEvent, nativeEventTarget);
|
|
return;
|
|
}
|
|
}
|
|
if (handleEventFunc) {
|
|
handleEventFunc(domEventName, targetNode, targetInst);
|
|
}
|
|
if (domEventName === "focusout") {
|
|
handleControlledInputBlur(targetNode);
|
|
}
|
|
}
|
|
function registerEvents$2() {
|
|
registerDirectEvent("onMouseEnter", ["mouseout", "mouseover"]);
|
|
registerDirectEvent("onMouseLeave", ["mouseout", "mouseover"]);
|
|
registerDirectEvent("onPointerEnter", ["pointerout", "pointerover"]);
|
|
registerDirectEvent("onPointerLeave", ["pointerout", "pointerover"]);
|
|
}
|
|
function extractEvents$2(dispatchQueue, domEventName, targetInst, nativeEvent, nativeEventTarget, eventSystemFlags, targetContainer) {
|
|
var isOverEvent = domEventName === "mouseover" || domEventName === "pointerover";
|
|
var isOutEvent = domEventName === "mouseout" || domEventName === "pointerout";
|
|
if (isOverEvent && (eventSystemFlags & IS_REPLAYED) === 0) {
|
|
var related = nativeEvent.relatedTarget || nativeEvent.fromElement;
|
|
if (related) {
|
|
if (getClosestInstanceFromNode(related) || isContainerMarkedAsRoot(related)) {
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
if (!isOutEvent && !isOverEvent) {
|
|
return;
|
|
}
|
|
var win;
|
|
if (nativeEventTarget.window === nativeEventTarget) {
|
|
win = nativeEventTarget;
|
|
} else {
|
|
var doc = nativeEventTarget.ownerDocument;
|
|
if (doc) {
|
|
win = doc.defaultView || doc.parentWindow;
|
|
} else {
|
|
win = window;
|
|
}
|
|
}
|
|
var from;
|
|
var to;
|
|
if (isOutEvent) {
|
|
var _related = nativeEvent.relatedTarget || nativeEvent.toElement;
|
|
from = targetInst;
|
|
to = _related ? getClosestInstanceFromNode(_related) : null;
|
|
if (to !== null) {
|
|
var nearestMounted = getNearestMountedFiber(to);
|
|
if (to !== nearestMounted || to.tag !== HostComponent && to.tag !== HostText) {
|
|
to = null;
|
|
}
|
|
}
|
|
} else {
|
|
from = null;
|
|
to = targetInst;
|
|
}
|
|
if (from === to) {
|
|
return;
|
|
}
|
|
var SyntheticEventCtor = SyntheticMouseEvent;
|
|
var leaveEventType = "onMouseLeave";
|
|
var enterEventType = "onMouseEnter";
|
|
var eventTypePrefix = "mouse";
|
|
if (domEventName === "pointerout" || domEventName === "pointerover") {
|
|
SyntheticEventCtor = SyntheticPointerEvent;
|
|
leaveEventType = "onPointerLeave";
|
|
enterEventType = "onPointerEnter";
|
|
eventTypePrefix = "pointer";
|
|
}
|
|
var fromNode = from == null ? win : getNodeFromInstance(from);
|
|
var toNode = to == null ? win : getNodeFromInstance(to);
|
|
var leave = new SyntheticEventCtor(leaveEventType, eventTypePrefix + "leave", from, nativeEvent, nativeEventTarget);
|
|
leave.target = fromNode;
|
|
leave.relatedTarget = toNode;
|
|
var enter = null;
|
|
var nativeTargetInst = getClosestInstanceFromNode(nativeEventTarget);
|
|
if (nativeTargetInst === targetInst) {
|
|
var enterEvent = new SyntheticEventCtor(enterEventType, eventTypePrefix + "enter", to, nativeEvent, nativeEventTarget);
|
|
enterEvent.target = toNode;
|
|
enterEvent.relatedTarget = fromNode;
|
|
enter = enterEvent;
|
|
}
|
|
accumulateEnterLeaveTwoPhaseListeners(dispatchQueue, leave, enter, from, to);
|
|
}
|
|
function is(x3, y3) {
|
|
return x3 === y3 && (x3 !== 0 || 1 / x3 === 1 / y3) || x3 !== x3 && y3 !== y3;
|
|
}
|
|
var objectIs = typeof Object.is === "function" ? Object.is : is;
|
|
var hasOwnProperty$2 = Object.prototype.hasOwnProperty;
|
|
function shallowEqual(objA, objB) {
|
|
if (objectIs(objA, objB)) {
|
|
return true;
|
|
}
|
|
if (typeof objA !== "object" || objA === null || typeof objB !== "object" || objB === null) {
|
|
return false;
|
|
}
|
|
var keysA = Object.keys(objA);
|
|
var keysB = Object.keys(objB);
|
|
if (keysA.length !== keysB.length) {
|
|
return false;
|
|
}
|
|
for (var i3 = 0; i3 < keysA.length; i3++) {
|
|
if (!hasOwnProperty$2.call(objB, keysA[i3]) || !objectIs(objA[keysA[i3]], objB[keysA[i3]])) {
|
|
return false;
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
function getLeafNode(node) {
|
|
while (node && node.firstChild) {
|
|
node = node.firstChild;
|
|
}
|
|
return node;
|
|
}
|
|
function getSiblingNode(node) {
|
|
while (node) {
|
|
if (node.nextSibling) {
|
|
return node.nextSibling;
|
|
}
|
|
node = node.parentNode;
|
|
}
|
|
}
|
|
function getNodeForCharacterOffset(root2, offset) {
|
|
var node = getLeafNode(root2);
|
|
var nodeStart = 0;
|
|
var nodeEnd = 0;
|
|
while (node) {
|
|
if (node.nodeType === TEXT_NODE) {
|
|
nodeEnd = nodeStart + node.textContent.length;
|
|
if (nodeStart <= offset && nodeEnd >= offset) {
|
|
return {
|
|
node,
|
|
offset: offset - nodeStart
|
|
};
|
|
}
|
|
nodeStart = nodeEnd;
|
|
}
|
|
node = getLeafNode(getSiblingNode(node));
|
|
}
|
|
}
|
|
function getOffsets(outerNode) {
|
|
var ownerDocument = outerNode.ownerDocument;
|
|
var win = ownerDocument && ownerDocument.defaultView || window;
|
|
var selection = win.getSelection && win.getSelection();
|
|
if (!selection || selection.rangeCount === 0) {
|
|
return null;
|
|
}
|
|
var anchorNode = selection.anchorNode, anchorOffset = selection.anchorOffset, focusNode = selection.focusNode, focusOffset = selection.focusOffset;
|
|
try {
|
|
anchorNode.nodeType;
|
|
focusNode.nodeType;
|
|
} catch (e3) {
|
|
return null;
|
|
}
|
|
return getModernOffsetsFromPoints(outerNode, anchorNode, anchorOffset, focusNode, focusOffset);
|
|
}
|
|
function getModernOffsetsFromPoints(outerNode, anchorNode, anchorOffset, focusNode, focusOffset) {
|
|
var length = 0;
|
|
var start = -1;
|
|
var end = -1;
|
|
var indexWithinAnchor = 0;
|
|
var indexWithinFocus = 0;
|
|
var node = outerNode;
|
|
var parentNode = null;
|
|
outer:
|
|
while (true) {
|
|
var next = null;
|
|
while (true) {
|
|
if (node === anchorNode && (anchorOffset === 0 || node.nodeType === TEXT_NODE)) {
|
|
start = length + anchorOffset;
|
|
}
|
|
if (node === focusNode && (focusOffset === 0 || node.nodeType === TEXT_NODE)) {
|
|
end = length + focusOffset;
|
|
}
|
|
if (node.nodeType === TEXT_NODE) {
|
|
length += node.nodeValue.length;
|
|
}
|
|
if ((next = node.firstChild) === null) {
|
|
break;
|
|
}
|
|
parentNode = node;
|
|
node = next;
|
|
}
|
|
while (true) {
|
|
if (node === outerNode) {
|
|
break outer;
|
|
}
|
|
if (parentNode === anchorNode && ++indexWithinAnchor === anchorOffset) {
|
|
start = length;
|
|
}
|
|
if (parentNode === focusNode && ++indexWithinFocus === focusOffset) {
|
|
end = length;
|
|
}
|
|
if ((next = node.nextSibling) !== null) {
|
|
break;
|
|
}
|
|
node = parentNode;
|
|
parentNode = node.parentNode;
|
|
}
|
|
node = next;
|
|
}
|
|
if (start === -1 || end === -1) {
|
|
return null;
|
|
}
|
|
return {
|
|
start,
|
|
end
|
|
};
|
|
}
|
|
function setOffsets(node, offsets) {
|
|
var doc = node.ownerDocument || document;
|
|
var win = doc && doc.defaultView || window;
|
|
if (!win.getSelection) {
|
|
return;
|
|
}
|
|
var selection = win.getSelection();
|
|
var length = node.textContent.length;
|
|
var start = Math.min(offsets.start, length);
|
|
var end = offsets.end === void 0 ? start : Math.min(offsets.end, length);
|
|
if (!selection.extend && start > end) {
|
|
var temp = end;
|
|
end = start;
|
|
start = temp;
|
|
}
|
|
var startMarker = getNodeForCharacterOffset(node, start);
|
|
var endMarker = getNodeForCharacterOffset(node, end);
|
|
if (startMarker && endMarker) {
|
|
if (selection.rangeCount === 1 && selection.anchorNode === startMarker.node && selection.anchorOffset === startMarker.offset && selection.focusNode === endMarker.node && selection.focusOffset === endMarker.offset) {
|
|
return;
|
|
}
|
|
var range = doc.createRange();
|
|
range.setStart(startMarker.node, startMarker.offset);
|
|
selection.removeAllRanges();
|
|
if (start > end) {
|
|
selection.addRange(range);
|
|
selection.extend(endMarker.node, endMarker.offset);
|
|
} else {
|
|
range.setEnd(endMarker.node, endMarker.offset);
|
|
selection.addRange(range);
|
|
}
|
|
}
|
|
}
|
|
function isTextNode(node) {
|
|
return node && node.nodeType === TEXT_NODE;
|
|
}
|
|
function containsNode(outerNode, innerNode) {
|
|
if (!outerNode || !innerNode) {
|
|
return false;
|
|
} else if (outerNode === innerNode) {
|
|
return true;
|
|
} else if (isTextNode(outerNode)) {
|
|
return false;
|
|
} else if (isTextNode(innerNode)) {
|
|
return containsNode(outerNode, innerNode.parentNode);
|
|
} else if ("contains" in outerNode) {
|
|
return outerNode.contains(innerNode);
|
|
} else if (outerNode.compareDocumentPosition) {
|
|
return !!(outerNode.compareDocumentPosition(innerNode) & 16);
|
|
} else {
|
|
return false;
|
|
}
|
|
}
|
|
function isInDocument(node) {
|
|
return node && node.ownerDocument && containsNode(node.ownerDocument.documentElement, node);
|
|
}
|
|
function isSameOriginFrame(iframe) {
|
|
try {
|
|
return typeof iframe.contentWindow.location.href === "string";
|
|
} catch (err) {
|
|
return false;
|
|
}
|
|
}
|
|
function getActiveElementDeep() {
|
|
var win = window;
|
|
var element = getActiveElement();
|
|
while (element instanceof win.HTMLIFrameElement) {
|
|
if (isSameOriginFrame(element)) {
|
|
win = element.contentWindow;
|
|
} else {
|
|
return element;
|
|
}
|
|
element = getActiveElement(win.document);
|
|
}
|
|
return element;
|
|
}
|
|
function hasSelectionCapabilities(elem) {
|
|
var nodeName = elem && elem.nodeName && elem.nodeName.toLowerCase();
|
|
return nodeName && (nodeName === "input" && (elem.type === "text" || elem.type === "search" || elem.type === "tel" || elem.type === "url" || elem.type === "password") || nodeName === "textarea" || elem.contentEditable === "true");
|
|
}
|
|
function getSelectionInformation() {
|
|
var focusedElem = getActiveElementDeep();
|
|
return {
|
|
focusedElem,
|
|
selectionRange: hasSelectionCapabilities(focusedElem) ? getSelection(focusedElem) : null
|
|
};
|
|
}
|
|
function restoreSelection(priorSelectionInformation) {
|
|
var curFocusedElem = getActiveElementDeep();
|
|
var priorFocusedElem = priorSelectionInformation.focusedElem;
|
|
var priorSelectionRange = priorSelectionInformation.selectionRange;
|
|
if (curFocusedElem !== priorFocusedElem && isInDocument(priorFocusedElem)) {
|
|
if (priorSelectionRange !== null && hasSelectionCapabilities(priorFocusedElem)) {
|
|
setSelection(priorFocusedElem, priorSelectionRange);
|
|
}
|
|
var ancestors = [];
|
|
var ancestor = priorFocusedElem;
|
|
while (ancestor = ancestor.parentNode) {
|
|
if (ancestor.nodeType === ELEMENT_NODE) {
|
|
ancestors.push({
|
|
element: ancestor,
|
|
left: ancestor.scrollLeft,
|
|
top: ancestor.scrollTop
|
|
});
|
|
}
|
|
}
|
|
if (typeof priorFocusedElem.focus === "function") {
|
|
priorFocusedElem.focus();
|
|
}
|
|
for (var i3 = 0; i3 < ancestors.length; i3++) {
|
|
var info = ancestors[i3];
|
|
info.element.scrollLeft = info.left;
|
|
info.element.scrollTop = info.top;
|
|
}
|
|
}
|
|
}
|
|
function getSelection(input) {
|
|
var selection;
|
|
if ("selectionStart" in input) {
|
|
selection = {
|
|
start: input.selectionStart,
|
|
end: input.selectionEnd
|
|
};
|
|
} else {
|
|
selection = getOffsets(input);
|
|
}
|
|
return selection || {
|
|
start: 0,
|
|
end: 0
|
|
};
|
|
}
|
|
function setSelection(input, offsets) {
|
|
var start = offsets.start;
|
|
var end = offsets.end;
|
|
if (end === void 0) {
|
|
end = start;
|
|
}
|
|
if ("selectionStart" in input) {
|
|
input.selectionStart = start;
|
|
input.selectionEnd = Math.min(end, input.value.length);
|
|
} else {
|
|
setOffsets(input, offsets);
|
|
}
|
|
}
|
|
var skipSelectionChangeEvent = canUseDOM && "documentMode" in document && document.documentMode <= 11;
|
|
function registerEvents$3() {
|
|
registerTwoPhaseEvent("onSelect", ["focusout", "contextmenu", "dragend", "focusin", "keydown", "keyup", "mousedown", "mouseup", "selectionchange"]);
|
|
}
|
|
var activeElement$1 = null;
|
|
var activeElementInst$1 = null;
|
|
var lastSelection = null;
|
|
var mouseDown = false;
|
|
function getSelection$1(node) {
|
|
if ("selectionStart" in node && hasSelectionCapabilities(node)) {
|
|
return {
|
|
start: node.selectionStart,
|
|
end: node.selectionEnd
|
|
};
|
|
} else {
|
|
var win = node.ownerDocument && node.ownerDocument.defaultView || window;
|
|
var selection = win.getSelection();
|
|
return {
|
|
anchorNode: selection.anchorNode,
|
|
anchorOffset: selection.anchorOffset,
|
|
focusNode: selection.focusNode,
|
|
focusOffset: selection.focusOffset
|
|
};
|
|
}
|
|
}
|
|
function getEventTargetDocument(eventTarget) {
|
|
return eventTarget.window === eventTarget ? eventTarget.document : eventTarget.nodeType === DOCUMENT_NODE ? eventTarget : eventTarget.ownerDocument;
|
|
}
|
|
function constructSelectEvent(dispatchQueue, nativeEvent, nativeEventTarget) {
|
|
var doc = getEventTargetDocument(nativeEventTarget);
|
|
if (mouseDown || activeElement$1 == null || activeElement$1 !== getActiveElement(doc)) {
|
|
return;
|
|
}
|
|
var currentSelection = getSelection$1(activeElement$1);
|
|
if (!lastSelection || !shallowEqual(lastSelection, currentSelection)) {
|
|
lastSelection = currentSelection;
|
|
var listeners = accumulateTwoPhaseListeners(activeElementInst$1, "onSelect");
|
|
if (listeners.length > 0) {
|
|
var event = new SyntheticEvent("onSelect", "select", null, nativeEvent, nativeEventTarget);
|
|
dispatchQueue.push({
|
|
event,
|
|
listeners
|
|
});
|
|
event.target = activeElement$1;
|
|
}
|
|
}
|
|
}
|
|
function extractEvents$3(dispatchQueue, domEventName, targetInst, nativeEvent, nativeEventTarget, eventSystemFlags, targetContainer) {
|
|
var targetNode = targetInst ? getNodeFromInstance(targetInst) : window;
|
|
switch (domEventName) {
|
|
case "focusin":
|
|
if (isTextInputElement(targetNode) || targetNode.contentEditable === "true") {
|
|
activeElement$1 = targetNode;
|
|
activeElementInst$1 = targetInst;
|
|
lastSelection = null;
|
|
}
|
|
break;
|
|
case "focusout":
|
|
activeElement$1 = null;
|
|
activeElementInst$1 = null;
|
|
lastSelection = null;
|
|
break;
|
|
case "mousedown":
|
|
mouseDown = true;
|
|
break;
|
|
case "contextmenu":
|
|
case "mouseup":
|
|
case "dragend":
|
|
mouseDown = false;
|
|
constructSelectEvent(dispatchQueue, nativeEvent, nativeEventTarget);
|
|
break;
|
|
case "selectionchange":
|
|
if (skipSelectionChangeEvent) {
|
|
break;
|
|
}
|
|
case "keydown":
|
|
case "keyup":
|
|
constructSelectEvent(dispatchQueue, nativeEvent, nativeEventTarget);
|
|
}
|
|
}
|
|
function extractEvents$4(dispatchQueue, domEventName, targetInst, nativeEvent, nativeEventTarget, eventSystemFlags, targetContainer) {
|
|
var reactName = topLevelEventsToReactNames.get(domEventName);
|
|
if (reactName === void 0) {
|
|
return;
|
|
}
|
|
var SyntheticEventCtor = SyntheticEvent;
|
|
var reactEventType = domEventName;
|
|
switch (domEventName) {
|
|
case "keypress":
|
|
if (getEventCharCode(nativeEvent) === 0) {
|
|
return;
|
|
}
|
|
case "keydown":
|
|
case "keyup":
|
|
SyntheticEventCtor = SyntheticKeyboardEvent;
|
|
break;
|
|
case "focusin":
|
|
reactEventType = "focus";
|
|
SyntheticEventCtor = SyntheticFocusEvent;
|
|
break;
|
|
case "focusout":
|
|
reactEventType = "blur";
|
|
SyntheticEventCtor = SyntheticFocusEvent;
|
|
break;
|
|
case "beforeblur":
|
|
case "afterblur":
|
|
SyntheticEventCtor = SyntheticFocusEvent;
|
|
break;
|
|
case "click":
|
|
if (nativeEvent.button === 2) {
|
|
return;
|
|
}
|
|
case "auxclick":
|
|
case "dblclick":
|
|
case "mousedown":
|
|
case "mousemove":
|
|
case "mouseup":
|
|
case "mouseout":
|
|
case "mouseover":
|
|
case "contextmenu":
|
|
SyntheticEventCtor = SyntheticMouseEvent;
|
|
break;
|
|
case "drag":
|
|
case "dragend":
|
|
case "dragenter":
|
|
case "dragexit":
|
|
case "dragleave":
|
|
case "dragover":
|
|
case "dragstart":
|
|
case "drop":
|
|
SyntheticEventCtor = SyntheticDragEvent;
|
|
break;
|
|
case "touchcancel":
|
|
case "touchend":
|
|
case "touchmove":
|
|
case "touchstart":
|
|
SyntheticEventCtor = SyntheticTouchEvent;
|
|
break;
|
|
case ANIMATION_END:
|
|
case ANIMATION_ITERATION:
|
|
case ANIMATION_START:
|
|
SyntheticEventCtor = SyntheticAnimationEvent;
|
|
break;
|
|
case TRANSITION_END:
|
|
SyntheticEventCtor = SyntheticTransitionEvent;
|
|
break;
|
|
case "scroll":
|
|
SyntheticEventCtor = SyntheticUIEvent;
|
|
break;
|
|
case "wheel":
|
|
SyntheticEventCtor = SyntheticWheelEvent;
|
|
break;
|
|
case "copy":
|
|
case "cut":
|
|
case "paste":
|
|
SyntheticEventCtor = SyntheticClipboardEvent;
|
|
break;
|
|
case "gotpointercapture":
|
|
case "lostpointercapture":
|
|
case "pointercancel":
|
|
case "pointerdown":
|
|
case "pointermove":
|
|
case "pointerout":
|
|
case "pointerover":
|
|
case "pointerup":
|
|
SyntheticEventCtor = SyntheticPointerEvent;
|
|
break;
|
|
}
|
|
var inCapturePhase = (eventSystemFlags & IS_CAPTURE_PHASE) !== 0;
|
|
{
|
|
var accumulateTargetOnly = !inCapturePhase && domEventName === "scroll";
|
|
var _listeners = accumulateSinglePhaseListeners(targetInst, reactName, nativeEvent.type, inCapturePhase, accumulateTargetOnly);
|
|
if (_listeners.length > 0) {
|
|
var _event = new SyntheticEventCtor(reactName, reactEventType, null, nativeEvent, nativeEventTarget);
|
|
dispatchQueue.push({
|
|
event: _event,
|
|
listeners: _listeners
|
|
});
|
|
}
|
|
}
|
|
}
|
|
registerSimpleEvents();
|
|
registerEvents$2();
|
|
registerEvents$1();
|
|
registerEvents$3();
|
|
registerEvents();
|
|
function extractEvents$5(dispatchQueue, domEventName, targetInst, nativeEvent, nativeEventTarget, eventSystemFlags, targetContainer) {
|
|
extractEvents$4(dispatchQueue, domEventName, targetInst, nativeEvent, nativeEventTarget, eventSystemFlags);
|
|
var shouldProcessPolyfillPlugins = (eventSystemFlags & SHOULD_NOT_PROCESS_POLYFILL_EVENT_PLUGINS) === 0;
|
|
if (shouldProcessPolyfillPlugins) {
|
|
extractEvents$2(dispatchQueue, domEventName, targetInst, nativeEvent, nativeEventTarget, eventSystemFlags);
|
|
extractEvents$1(dispatchQueue, domEventName, targetInst, nativeEvent, nativeEventTarget);
|
|
extractEvents$3(dispatchQueue, domEventName, targetInst, nativeEvent, nativeEventTarget);
|
|
extractEvents(dispatchQueue, domEventName, targetInst, nativeEvent, nativeEventTarget);
|
|
}
|
|
}
|
|
var mediaEventTypes = ["abort", "canplay", "canplaythrough", "durationchange", "emptied", "encrypted", "ended", "error", "loadeddata", "loadedmetadata", "loadstart", "pause", "play", "playing", "progress", "ratechange", "seeked", "seeking", "stalled", "suspend", "timeupdate", "volumechange", "waiting"];
|
|
var nonDelegatedEvents = new Set(["cancel", "close", "invalid", "load", "scroll", "toggle"].concat(mediaEventTypes));
|
|
function executeDispatch(event, listener, currentTarget) {
|
|
var type = event.type || "unknown-event";
|
|
event.currentTarget = currentTarget;
|
|
invokeGuardedCallbackAndCatchFirstError(type, listener, void 0, event);
|
|
event.currentTarget = null;
|
|
}
|
|
function processDispatchQueueItemsInOrder(event, dispatchListeners, inCapturePhase) {
|
|
var previousInstance;
|
|
if (inCapturePhase) {
|
|
for (var i3 = dispatchListeners.length - 1; i3 >= 0; i3--) {
|
|
var _dispatchListeners$i = dispatchListeners[i3], instance = _dispatchListeners$i.instance, currentTarget = _dispatchListeners$i.currentTarget, listener = _dispatchListeners$i.listener;
|
|
if (instance !== previousInstance && event.isPropagationStopped()) {
|
|
return;
|
|
}
|
|
executeDispatch(event, listener, currentTarget);
|
|
previousInstance = instance;
|
|
}
|
|
} else {
|
|
for (var _i = 0; _i < dispatchListeners.length; _i++) {
|
|
var _dispatchListeners$_i = dispatchListeners[_i], _instance = _dispatchListeners$_i.instance, _currentTarget = _dispatchListeners$_i.currentTarget, _listener = _dispatchListeners$_i.listener;
|
|
if (_instance !== previousInstance && event.isPropagationStopped()) {
|
|
return;
|
|
}
|
|
executeDispatch(event, _listener, _currentTarget);
|
|
previousInstance = _instance;
|
|
}
|
|
}
|
|
}
|
|
function processDispatchQueue(dispatchQueue, eventSystemFlags) {
|
|
var inCapturePhase = (eventSystemFlags & IS_CAPTURE_PHASE) !== 0;
|
|
for (var i3 = 0; i3 < dispatchQueue.length; i3++) {
|
|
var _dispatchQueue$i = dispatchQueue[i3], event = _dispatchQueue$i.event, listeners = _dispatchQueue$i.listeners;
|
|
processDispatchQueueItemsInOrder(event, listeners, inCapturePhase);
|
|
}
|
|
rethrowCaughtError();
|
|
}
|
|
function dispatchEventsForPlugins(domEventName, eventSystemFlags, nativeEvent, targetInst, targetContainer) {
|
|
var nativeEventTarget = getEventTarget(nativeEvent);
|
|
var dispatchQueue = [];
|
|
extractEvents$5(dispatchQueue, domEventName, targetInst, nativeEvent, nativeEventTarget, eventSystemFlags);
|
|
processDispatchQueue(dispatchQueue, eventSystemFlags);
|
|
}
|
|
function listenToNonDelegatedEvent(domEventName, targetElement) {
|
|
var isCapturePhaseListener = false;
|
|
var listenerSet = getEventListenerSet(targetElement);
|
|
var listenerSetKey = getListenerSetKey(domEventName, isCapturePhaseListener);
|
|
if (!listenerSet.has(listenerSetKey)) {
|
|
addTrappedEventListener(targetElement, domEventName, IS_NON_DELEGATED, isCapturePhaseListener);
|
|
listenerSet.add(listenerSetKey);
|
|
}
|
|
}
|
|
var listeningMarker = "_reactListening" + Math.random().toString(36).slice(2);
|
|
function listenToAllSupportedEvents(rootContainerElement) {
|
|
{
|
|
if (rootContainerElement[listeningMarker]) {
|
|
return;
|
|
}
|
|
rootContainerElement[listeningMarker] = true;
|
|
allNativeEvents.forEach(function(domEventName) {
|
|
if (!nonDelegatedEvents.has(domEventName)) {
|
|
listenToNativeEvent(domEventName, false, rootContainerElement, null);
|
|
}
|
|
listenToNativeEvent(domEventName, true, rootContainerElement, null);
|
|
});
|
|
}
|
|
}
|
|
function listenToNativeEvent(domEventName, isCapturePhaseListener, rootContainerElement, targetElement) {
|
|
var eventSystemFlags = arguments.length > 4 && arguments[4] !== void 0 ? arguments[4] : 0;
|
|
var target = rootContainerElement;
|
|
if (domEventName === "selectionchange" && rootContainerElement.nodeType !== DOCUMENT_NODE) {
|
|
target = rootContainerElement.ownerDocument;
|
|
}
|
|
if (targetElement !== null && !isCapturePhaseListener && nonDelegatedEvents.has(domEventName)) {
|
|
if (domEventName !== "scroll") {
|
|
return;
|
|
}
|
|
eventSystemFlags |= IS_NON_DELEGATED;
|
|
target = targetElement;
|
|
}
|
|
var listenerSet = getEventListenerSet(target);
|
|
var listenerSetKey = getListenerSetKey(domEventName, isCapturePhaseListener);
|
|
if (!listenerSet.has(listenerSetKey)) {
|
|
if (isCapturePhaseListener) {
|
|
eventSystemFlags |= IS_CAPTURE_PHASE;
|
|
}
|
|
addTrappedEventListener(target, domEventName, eventSystemFlags, isCapturePhaseListener);
|
|
listenerSet.add(listenerSetKey);
|
|
}
|
|
}
|
|
function addTrappedEventListener(targetContainer, domEventName, eventSystemFlags, isCapturePhaseListener, isDeferredListenerForLegacyFBSupport) {
|
|
var listener = createEventListenerWrapperWithPriority(targetContainer, domEventName, eventSystemFlags);
|
|
var isPassiveListener = void 0;
|
|
if (passiveBrowserEventsSupported) {
|
|
if (domEventName === "touchstart" || domEventName === "touchmove" || domEventName === "wheel") {
|
|
isPassiveListener = true;
|
|
}
|
|
}
|
|
targetContainer = targetContainer;
|
|
var unsubscribeListener;
|
|
if (isCapturePhaseListener) {
|
|
if (isPassiveListener !== void 0) {
|
|
unsubscribeListener = addEventCaptureListenerWithPassiveFlag(targetContainer, domEventName, listener, isPassiveListener);
|
|
} else {
|
|
unsubscribeListener = addEventCaptureListener(targetContainer, domEventName, listener);
|
|
}
|
|
} else {
|
|
if (isPassiveListener !== void 0) {
|
|
unsubscribeListener = addEventBubbleListenerWithPassiveFlag(targetContainer, domEventName, listener, isPassiveListener);
|
|
} else {
|
|
unsubscribeListener = addEventBubbleListener(targetContainer, domEventName, listener);
|
|
}
|
|
}
|
|
}
|
|
function isMatchingRootContainer(grandContainer, targetContainer) {
|
|
return grandContainer === targetContainer || grandContainer.nodeType === COMMENT_NODE && grandContainer.parentNode === targetContainer;
|
|
}
|
|
function dispatchEventForPluginEventSystem(domEventName, eventSystemFlags, nativeEvent, targetInst, targetContainer) {
|
|
var ancestorInst = targetInst;
|
|
if ((eventSystemFlags & IS_EVENT_HANDLE_NON_MANAGED_NODE) === 0 && (eventSystemFlags & IS_NON_DELEGATED) === 0) {
|
|
var targetContainerNode = targetContainer;
|
|
if (targetInst !== null) {
|
|
var node = targetInst;
|
|
mainLoop:
|
|
while (true) {
|
|
if (node === null) {
|
|
return;
|
|
}
|
|
var nodeTag = node.tag;
|
|
if (nodeTag === HostRoot || nodeTag === HostPortal) {
|
|
var container = node.stateNode.containerInfo;
|
|
if (isMatchingRootContainer(container, targetContainerNode)) {
|
|
break;
|
|
}
|
|
if (nodeTag === HostPortal) {
|
|
var grandNode = node.return;
|
|
while (grandNode !== null) {
|
|
var grandTag = grandNode.tag;
|
|
if (grandTag === HostRoot || grandTag === HostPortal) {
|
|
var grandContainer = grandNode.stateNode.containerInfo;
|
|
if (isMatchingRootContainer(grandContainer, targetContainerNode)) {
|
|
return;
|
|
}
|
|
}
|
|
grandNode = grandNode.return;
|
|
}
|
|
}
|
|
while (container !== null) {
|
|
var parentNode = getClosestInstanceFromNode(container);
|
|
if (parentNode === null) {
|
|
return;
|
|
}
|
|
var parentTag = parentNode.tag;
|
|
if (parentTag === HostComponent || parentTag === HostText) {
|
|
node = ancestorInst = parentNode;
|
|
continue mainLoop;
|
|
}
|
|
container = container.parentNode;
|
|
}
|
|
}
|
|
node = node.return;
|
|
}
|
|
}
|
|
}
|
|
batchedEventUpdates(function() {
|
|
return dispatchEventsForPlugins(domEventName, eventSystemFlags, nativeEvent, ancestorInst);
|
|
});
|
|
}
|
|
function createDispatchListener(instance, listener, currentTarget) {
|
|
return {
|
|
instance,
|
|
listener,
|
|
currentTarget
|
|
};
|
|
}
|
|
function accumulateSinglePhaseListeners(targetFiber, reactName, nativeEventType, inCapturePhase, accumulateTargetOnly) {
|
|
var captureName = reactName !== null ? reactName + "Capture" : null;
|
|
var reactEventName = inCapturePhase ? captureName : reactName;
|
|
var listeners = [];
|
|
var instance = targetFiber;
|
|
var lastHostComponent = null;
|
|
while (instance !== null) {
|
|
var _instance2 = instance, stateNode = _instance2.stateNode, tag = _instance2.tag;
|
|
if (tag === HostComponent && stateNode !== null) {
|
|
lastHostComponent = stateNode;
|
|
if (reactEventName !== null) {
|
|
var listener = getListener(instance, reactEventName);
|
|
if (listener != null) {
|
|
listeners.push(createDispatchListener(instance, listener, lastHostComponent));
|
|
}
|
|
}
|
|
}
|
|
if (accumulateTargetOnly) {
|
|
break;
|
|
}
|
|
instance = instance.return;
|
|
}
|
|
return listeners;
|
|
}
|
|
function accumulateTwoPhaseListeners(targetFiber, reactName) {
|
|
var captureName = reactName + "Capture";
|
|
var listeners = [];
|
|
var instance = targetFiber;
|
|
while (instance !== null) {
|
|
var _instance3 = instance, stateNode = _instance3.stateNode, tag = _instance3.tag;
|
|
if (tag === HostComponent && stateNode !== null) {
|
|
var currentTarget = stateNode;
|
|
var captureListener = getListener(instance, captureName);
|
|
if (captureListener != null) {
|
|
listeners.unshift(createDispatchListener(instance, captureListener, currentTarget));
|
|
}
|
|
var bubbleListener = getListener(instance, reactName);
|
|
if (bubbleListener != null) {
|
|
listeners.push(createDispatchListener(instance, bubbleListener, currentTarget));
|
|
}
|
|
}
|
|
instance = instance.return;
|
|
}
|
|
return listeners;
|
|
}
|
|
function getParent(inst) {
|
|
if (inst === null) {
|
|
return null;
|
|
}
|
|
do {
|
|
inst = inst.return;
|
|
} while (inst && inst.tag !== HostComponent);
|
|
if (inst) {
|
|
return inst;
|
|
}
|
|
return null;
|
|
}
|
|
function getLowestCommonAncestor(instA, instB) {
|
|
var nodeA = instA;
|
|
var nodeB = instB;
|
|
var depthA = 0;
|
|
for (var tempA = nodeA; tempA; tempA = getParent(tempA)) {
|
|
depthA++;
|
|
}
|
|
var depthB = 0;
|
|
for (var tempB = nodeB; tempB; tempB = getParent(tempB)) {
|
|
depthB++;
|
|
}
|
|
while (depthA - depthB > 0) {
|
|
nodeA = getParent(nodeA);
|
|
depthA--;
|
|
}
|
|
while (depthB - depthA > 0) {
|
|
nodeB = getParent(nodeB);
|
|
depthB--;
|
|
}
|
|
var depth = depthA;
|
|
while (depth--) {
|
|
if (nodeA === nodeB || nodeB !== null && nodeA === nodeB.alternate) {
|
|
return nodeA;
|
|
}
|
|
nodeA = getParent(nodeA);
|
|
nodeB = getParent(nodeB);
|
|
}
|
|
return null;
|
|
}
|
|
function accumulateEnterLeaveListenersForEvent(dispatchQueue, event, target, common, inCapturePhase) {
|
|
var registrationName = event._reactName;
|
|
var listeners = [];
|
|
var instance = target;
|
|
while (instance !== null) {
|
|
if (instance === common) {
|
|
break;
|
|
}
|
|
var _instance4 = instance, alternate = _instance4.alternate, stateNode = _instance4.stateNode, tag = _instance4.tag;
|
|
if (alternate !== null && alternate === common) {
|
|
break;
|
|
}
|
|
if (tag === HostComponent && stateNode !== null) {
|
|
var currentTarget = stateNode;
|
|
if (inCapturePhase) {
|
|
var captureListener = getListener(instance, registrationName);
|
|
if (captureListener != null) {
|
|
listeners.unshift(createDispatchListener(instance, captureListener, currentTarget));
|
|
}
|
|
} else if (!inCapturePhase) {
|
|
var bubbleListener = getListener(instance, registrationName);
|
|
if (bubbleListener != null) {
|
|
listeners.push(createDispatchListener(instance, bubbleListener, currentTarget));
|
|
}
|
|
}
|
|
}
|
|
instance = instance.return;
|
|
}
|
|
if (listeners.length !== 0) {
|
|
dispatchQueue.push({
|
|
event,
|
|
listeners
|
|
});
|
|
}
|
|
}
|
|
function accumulateEnterLeaveTwoPhaseListeners(dispatchQueue, leaveEvent, enterEvent, from, to) {
|
|
var common = from && to ? getLowestCommonAncestor(from, to) : null;
|
|
if (from !== null) {
|
|
accumulateEnterLeaveListenersForEvent(dispatchQueue, leaveEvent, from, common, false);
|
|
}
|
|
if (to !== null && enterEvent !== null) {
|
|
accumulateEnterLeaveListenersForEvent(dispatchQueue, enterEvent, to, common, true);
|
|
}
|
|
}
|
|
function getListenerSetKey(domEventName, capture) {
|
|
return domEventName + "__" + (capture ? "capture" : "bubble");
|
|
}
|
|
var didWarnInvalidHydration = false;
|
|
var DANGEROUSLY_SET_INNER_HTML = "dangerouslySetInnerHTML";
|
|
var SUPPRESS_CONTENT_EDITABLE_WARNING = "suppressContentEditableWarning";
|
|
var SUPPRESS_HYDRATION_WARNING = "suppressHydrationWarning";
|
|
var AUTOFOCUS = "autoFocus";
|
|
var CHILDREN = "children";
|
|
var STYLE = "style";
|
|
var HTML$1 = "__html";
|
|
var HTML_NAMESPACE$1 = Namespaces.html;
|
|
var warnedUnknownTags;
|
|
var suppressHydrationWarning;
|
|
var validatePropertiesInDevelopment;
|
|
var warnForTextDifference;
|
|
var warnForPropDifference;
|
|
var warnForExtraAttributes;
|
|
var warnForInvalidEventListener;
|
|
var canDiffStyleForHydrationWarning;
|
|
var normalizeMarkupForTextOrAttribute;
|
|
var normalizeHTML;
|
|
{
|
|
warnedUnknownTags = {
|
|
dialog: true,
|
|
webview: true
|
|
};
|
|
validatePropertiesInDevelopment = function(type, props) {
|
|
validateProperties(type, props);
|
|
validateProperties$1(type, props);
|
|
validateProperties$2(type, props, {
|
|
registrationNameDependencies,
|
|
possibleRegistrationNames
|
|
});
|
|
};
|
|
canDiffStyleForHydrationWarning = canUseDOM && !document.documentMode;
|
|
var NORMALIZE_NEWLINES_REGEX = /\r\n?/g;
|
|
var NORMALIZE_NULL_AND_REPLACEMENT_REGEX = /\u0000|\uFFFD/g;
|
|
normalizeMarkupForTextOrAttribute = function(markup) {
|
|
var markupString = typeof markup === "string" ? markup : "" + markup;
|
|
return markupString.replace(NORMALIZE_NEWLINES_REGEX, "\n").replace(NORMALIZE_NULL_AND_REPLACEMENT_REGEX, "");
|
|
};
|
|
warnForTextDifference = function(serverText, clientText) {
|
|
if (didWarnInvalidHydration) {
|
|
return;
|
|
}
|
|
var normalizedClientText = normalizeMarkupForTextOrAttribute(clientText);
|
|
var normalizedServerText = normalizeMarkupForTextOrAttribute(serverText);
|
|
if (normalizedServerText === normalizedClientText) {
|
|
return;
|
|
}
|
|
didWarnInvalidHydration = true;
|
|
error('Text content did not match. Server: "%s" Client: "%s"', normalizedServerText, normalizedClientText);
|
|
};
|
|
warnForPropDifference = function(propName, serverValue, clientValue) {
|
|
if (didWarnInvalidHydration) {
|
|
return;
|
|
}
|
|
var normalizedClientValue = normalizeMarkupForTextOrAttribute(clientValue);
|
|
var normalizedServerValue = normalizeMarkupForTextOrAttribute(serverValue);
|
|
if (normalizedServerValue === normalizedClientValue) {
|
|
return;
|
|
}
|
|
didWarnInvalidHydration = true;
|
|
error("Prop `%s` did not match. Server: %s Client: %s", propName, JSON.stringify(normalizedServerValue), JSON.stringify(normalizedClientValue));
|
|
};
|
|
warnForExtraAttributes = function(attributeNames) {
|
|
if (didWarnInvalidHydration) {
|
|
return;
|
|
}
|
|
didWarnInvalidHydration = true;
|
|
var names = [];
|
|
attributeNames.forEach(function(name) {
|
|
names.push(name);
|
|
});
|
|
error("Extra attributes from the server: %s", names);
|
|
};
|
|
warnForInvalidEventListener = function(registrationName, listener) {
|
|
if (listener === false) {
|
|
error("Expected `%s` listener to be a function, instead got `false`.\n\nIf you used to conditionally omit it with %s={condition && value}, pass %s={condition ? value : undefined} instead.", registrationName, registrationName, registrationName);
|
|
} else {
|
|
error("Expected `%s` listener to be a function, instead got a value of `%s` type.", registrationName, typeof listener);
|
|
}
|
|
};
|
|
normalizeHTML = function(parent, html) {
|
|
var testElement = parent.namespaceURI === HTML_NAMESPACE$1 ? parent.ownerDocument.createElement(parent.tagName) : parent.ownerDocument.createElementNS(parent.namespaceURI, parent.tagName);
|
|
testElement.innerHTML = html;
|
|
return testElement.innerHTML;
|
|
};
|
|
}
|
|
function getOwnerDocumentFromRootContainer(rootContainerElement) {
|
|
return rootContainerElement.nodeType === DOCUMENT_NODE ? rootContainerElement : rootContainerElement.ownerDocument;
|
|
}
|
|
function noop() {
|
|
}
|
|
function trapClickOnNonInteractiveElement(node) {
|
|
node.onclick = noop;
|
|
}
|
|
function setInitialDOMProperties(tag, domElement, rootContainerElement, nextProps, isCustomComponentTag) {
|
|
for (var propKey in nextProps) {
|
|
if (!nextProps.hasOwnProperty(propKey)) {
|
|
continue;
|
|
}
|
|
var nextProp = nextProps[propKey];
|
|
if (propKey === STYLE) {
|
|
{
|
|
if (nextProp) {
|
|
Object.freeze(nextProp);
|
|
}
|
|
}
|
|
setValueForStyles(domElement, nextProp);
|
|
} else if (propKey === DANGEROUSLY_SET_INNER_HTML) {
|
|
var nextHtml = nextProp ? nextProp[HTML$1] : void 0;
|
|
if (nextHtml != null) {
|
|
setInnerHTML(domElement, nextHtml);
|
|
}
|
|
} else if (propKey === CHILDREN) {
|
|
if (typeof nextProp === "string") {
|
|
var canSetTextContent = tag !== "textarea" || nextProp !== "";
|
|
if (canSetTextContent) {
|
|
setTextContent(domElement, nextProp);
|
|
}
|
|
} else if (typeof nextProp === "number") {
|
|
setTextContent(domElement, "" + nextProp);
|
|
}
|
|
} else if (propKey === SUPPRESS_CONTENT_EDITABLE_WARNING || propKey === SUPPRESS_HYDRATION_WARNING)
|
|
;
|
|
else if (propKey === AUTOFOCUS)
|
|
;
|
|
else if (registrationNameDependencies.hasOwnProperty(propKey)) {
|
|
if (nextProp != null) {
|
|
if (typeof nextProp !== "function") {
|
|
warnForInvalidEventListener(propKey, nextProp);
|
|
}
|
|
if (propKey === "onScroll") {
|
|
listenToNonDelegatedEvent("scroll", domElement);
|
|
}
|
|
}
|
|
} else if (nextProp != null) {
|
|
setValueForProperty(domElement, propKey, nextProp, isCustomComponentTag);
|
|
}
|
|
}
|
|
}
|
|
function updateDOMProperties(domElement, updatePayload, wasCustomComponentTag, isCustomComponentTag) {
|
|
for (var i3 = 0; i3 < updatePayload.length; i3 += 2) {
|
|
var propKey = updatePayload[i3];
|
|
var propValue = updatePayload[i3 + 1];
|
|
if (propKey === STYLE) {
|
|
setValueForStyles(domElement, propValue);
|
|
} else if (propKey === DANGEROUSLY_SET_INNER_HTML) {
|
|
setInnerHTML(domElement, propValue);
|
|
} else if (propKey === CHILDREN) {
|
|
setTextContent(domElement, propValue);
|
|
} else {
|
|
setValueForProperty(domElement, propKey, propValue, isCustomComponentTag);
|
|
}
|
|
}
|
|
}
|
|
function createElement7(type, props, rootContainerElement, parentNamespace) {
|
|
var isCustomComponentTag;
|
|
var ownerDocument = getOwnerDocumentFromRootContainer(rootContainerElement);
|
|
var domElement;
|
|
var namespaceURI = parentNamespace;
|
|
if (namespaceURI === HTML_NAMESPACE$1) {
|
|
namespaceURI = getIntrinsicNamespace(type);
|
|
}
|
|
if (namespaceURI === HTML_NAMESPACE$1) {
|
|
{
|
|
isCustomComponentTag = isCustomComponent(type, props);
|
|
if (!isCustomComponentTag && type !== type.toLowerCase()) {
|
|
error("<%s /> is using incorrect casing. Use PascalCase for React components, or lowercase for HTML elements.", type);
|
|
}
|
|
}
|
|
if (type === "script") {
|
|
var div = ownerDocument.createElement("div");
|
|
div.innerHTML = "<script><\/script>";
|
|
var firstChild = div.firstChild;
|
|
domElement = div.removeChild(firstChild);
|
|
} else if (typeof props.is === "string") {
|
|
domElement = ownerDocument.createElement(type, {
|
|
is: props.is
|
|
});
|
|
} else {
|
|
domElement = ownerDocument.createElement(type);
|
|
if (type === "select") {
|
|
var node = domElement;
|
|
if (props.multiple) {
|
|
node.multiple = true;
|
|
} else if (props.size) {
|
|
node.size = props.size;
|
|
}
|
|
}
|
|
}
|
|
} else {
|
|
domElement = ownerDocument.createElementNS(namespaceURI, type);
|
|
}
|
|
{
|
|
if (namespaceURI === HTML_NAMESPACE$1) {
|
|
if (!isCustomComponentTag && Object.prototype.toString.call(domElement) === "[object HTMLUnknownElement]" && !Object.prototype.hasOwnProperty.call(warnedUnknownTags, type)) {
|
|
warnedUnknownTags[type] = true;
|
|
error("The tag <%s> is unrecognized in this browser. If you meant to render a React component, start its name with an uppercase letter.", type);
|
|
}
|
|
}
|
|
}
|
|
return domElement;
|
|
}
|
|
function createTextNode(text, rootContainerElement) {
|
|
return getOwnerDocumentFromRootContainer(rootContainerElement).createTextNode(text);
|
|
}
|
|
function setInitialProperties(domElement, tag, rawProps, rootContainerElement) {
|
|
var isCustomComponentTag = isCustomComponent(tag, rawProps);
|
|
{
|
|
validatePropertiesInDevelopment(tag, rawProps);
|
|
}
|
|
var props;
|
|
switch (tag) {
|
|
case "dialog":
|
|
listenToNonDelegatedEvent("cancel", domElement);
|
|
listenToNonDelegatedEvent("close", domElement);
|
|
props = rawProps;
|
|
break;
|
|
case "iframe":
|
|
case "object":
|
|
case "embed":
|
|
listenToNonDelegatedEvent("load", domElement);
|
|
props = rawProps;
|
|
break;
|
|
case "video":
|
|
case "audio":
|
|
for (var i3 = 0; i3 < mediaEventTypes.length; i3++) {
|
|
listenToNonDelegatedEvent(mediaEventTypes[i3], domElement);
|
|
}
|
|
props = rawProps;
|
|
break;
|
|
case "source":
|
|
listenToNonDelegatedEvent("error", domElement);
|
|
props = rawProps;
|
|
break;
|
|
case "img":
|
|
case "image":
|
|
case "link":
|
|
listenToNonDelegatedEvent("error", domElement);
|
|
listenToNonDelegatedEvent("load", domElement);
|
|
props = rawProps;
|
|
break;
|
|
case "details":
|
|
listenToNonDelegatedEvent("toggle", domElement);
|
|
props = rawProps;
|
|
break;
|
|
case "input":
|
|
initWrapperState(domElement, rawProps);
|
|
props = getHostProps(domElement, rawProps);
|
|
listenToNonDelegatedEvent("invalid", domElement);
|
|
break;
|
|
case "option":
|
|
validateProps(domElement, rawProps);
|
|
props = getHostProps$1(domElement, rawProps);
|
|
break;
|
|
case "select":
|
|
initWrapperState$1(domElement, rawProps);
|
|
props = getHostProps$2(domElement, rawProps);
|
|
listenToNonDelegatedEvent("invalid", domElement);
|
|
break;
|
|
case "textarea":
|
|
initWrapperState$2(domElement, rawProps);
|
|
props = getHostProps$3(domElement, rawProps);
|
|
listenToNonDelegatedEvent("invalid", domElement);
|
|
break;
|
|
default:
|
|
props = rawProps;
|
|
}
|
|
assertValidProps(tag, props);
|
|
setInitialDOMProperties(tag, domElement, rootContainerElement, props, isCustomComponentTag);
|
|
switch (tag) {
|
|
case "input":
|
|
track(domElement);
|
|
postMountWrapper(domElement, rawProps, false);
|
|
break;
|
|
case "textarea":
|
|
track(domElement);
|
|
postMountWrapper$3(domElement);
|
|
break;
|
|
case "option":
|
|
postMountWrapper$1(domElement, rawProps);
|
|
break;
|
|
case "select":
|
|
postMountWrapper$2(domElement, rawProps);
|
|
break;
|
|
default:
|
|
if (typeof props.onClick === "function") {
|
|
trapClickOnNonInteractiveElement(domElement);
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
function diffProperties(domElement, tag, lastRawProps, nextRawProps, rootContainerElement) {
|
|
{
|
|
validatePropertiesInDevelopment(tag, nextRawProps);
|
|
}
|
|
var updatePayload = null;
|
|
var lastProps;
|
|
var nextProps;
|
|
switch (tag) {
|
|
case "input":
|
|
lastProps = getHostProps(domElement, lastRawProps);
|
|
nextProps = getHostProps(domElement, nextRawProps);
|
|
updatePayload = [];
|
|
break;
|
|
case "option":
|
|
lastProps = getHostProps$1(domElement, lastRawProps);
|
|
nextProps = getHostProps$1(domElement, nextRawProps);
|
|
updatePayload = [];
|
|
break;
|
|
case "select":
|
|
lastProps = getHostProps$2(domElement, lastRawProps);
|
|
nextProps = getHostProps$2(domElement, nextRawProps);
|
|
updatePayload = [];
|
|
break;
|
|
case "textarea":
|
|
lastProps = getHostProps$3(domElement, lastRawProps);
|
|
nextProps = getHostProps$3(domElement, nextRawProps);
|
|
updatePayload = [];
|
|
break;
|
|
default:
|
|
lastProps = lastRawProps;
|
|
nextProps = nextRawProps;
|
|
if (typeof lastProps.onClick !== "function" && typeof nextProps.onClick === "function") {
|
|
trapClickOnNonInteractiveElement(domElement);
|
|
}
|
|
break;
|
|
}
|
|
assertValidProps(tag, nextProps);
|
|
var propKey;
|
|
var styleName;
|
|
var styleUpdates = null;
|
|
for (propKey in lastProps) {
|
|
if (nextProps.hasOwnProperty(propKey) || !lastProps.hasOwnProperty(propKey) || lastProps[propKey] == null) {
|
|
continue;
|
|
}
|
|
if (propKey === STYLE) {
|
|
var lastStyle = lastProps[propKey];
|
|
for (styleName in lastStyle) {
|
|
if (lastStyle.hasOwnProperty(styleName)) {
|
|
if (!styleUpdates) {
|
|
styleUpdates = {};
|
|
}
|
|
styleUpdates[styleName] = "";
|
|
}
|
|
}
|
|
} else if (propKey === DANGEROUSLY_SET_INNER_HTML || propKey === CHILDREN)
|
|
;
|
|
else if (propKey === SUPPRESS_CONTENT_EDITABLE_WARNING || propKey === SUPPRESS_HYDRATION_WARNING)
|
|
;
|
|
else if (propKey === AUTOFOCUS)
|
|
;
|
|
else if (registrationNameDependencies.hasOwnProperty(propKey)) {
|
|
if (!updatePayload) {
|
|
updatePayload = [];
|
|
}
|
|
} else {
|
|
(updatePayload = updatePayload || []).push(propKey, null);
|
|
}
|
|
}
|
|
for (propKey in nextProps) {
|
|
var nextProp = nextProps[propKey];
|
|
var lastProp = lastProps != null ? lastProps[propKey] : void 0;
|
|
if (!nextProps.hasOwnProperty(propKey) || nextProp === lastProp || nextProp == null && lastProp == null) {
|
|
continue;
|
|
}
|
|
if (propKey === STYLE) {
|
|
{
|
|
if (nextProp) {
|
|
Object.freeze(nextProp);
|
|
}
|
|
}
|
|
if (lastProp) {
|
|
for (styleName in lastProp) {
|
|
if (lastProp.hasOwnProperty(styleName) && (!nextProp || !nextProp.hasOwnProperty(styleName))) {
|
|
if (!styleUpdates) {
|
|
styleUpdates = {};
|
|
}
|
|
styleUpdates[styleName] = "";
|
|
}
|
|
}
|
|
for (styleName in nextProp) {
|
|
if (nextProp.hasOwnProperty(styleName) && lastProp[styleName] !== nextProp[styleName]) {
|
|
if (!styleUpdates) {
|
|
styleUpdates = {};
|
|
}
|
|
styleUpdates[styleName] = nextProp[styleName];
|
|
}
|
|
}
|
|
} else {
|
|
if (!styleUpdates) {
|
|
if (!updatePayload) {
|
|
updatePayload = [];
|
|
}
|
|
updatePayload.push(propKey, styleUpdates);
|
|
}
|
|
styleUpdates = nextProp;
|
|
}
|
|
} else if (propKey === DANGEROUSLY_SET_INNER_HTML) {
|
|
var nextHtml = nextProp ? nextProp[HTML$1] : void 0;
|
|
var lastHtml = lastProp ? lastProp[HTML$1] : void 0;
|
|
if (nextHtml != null) {
|
|
if (lastHtml !== nextHtml) {
|
|
(updatePayload = updatePayload || []).push(propKey, nextHtml);
|
|
}
|
|
}
|
|
} else if (propKey === CHILDREN) {
|
|
if (typeof nextProp === "string" || typeof nextProp === "number") {
|
|
(updatePayload = updatePayload || []).push(propKey, "" + nextProp);
|
|
}
|
|
} else if (propKey === SUPPRESS_CONTENT_EDITABLE_WARNING || propKey === SUPPRESS_HYDRATION_WARNING)
|
|
;
|
|
else if (registrationNameDependencies.hasOwnProperty(propKey)) {
|
|
if (nextProp != null) {
|
|
if (typeof nextProp !== "function") {
|
|
warnForInvalidEventListener(propKey, nextProp);
|
|
}
|
|
if (propKey === "onScroll") {
|
|
listenToNonDelegatedEvent("scroll", domElement);
|
|
}
|
|
}
|
|
if (!updatePayload && lastProp !== nextProp) {
|
|
updatePayload = [];
|
|
}
|
|
} else if (typeof nextProp === "object" && nextProp !== null && nextProp.$$typeof === REACT_OPAQUE_ID_TYPE) {
|
|
nextProp.toString();
|
|
} else {
|
|
(updatePayload = updatePayload || []).push(propKey, nextProp);
|
|
}
|
|
}
|
|
if (styleUpdates) {
|
|
{
|
|
validateShorthandPropertyCollisionInDev(styleUpdates, nextProps[STYLE]);
|
|
}
|
|
(updatePayload = updatePayload || []).push(STYLE, styleUpdates);
|
|
}
|
|
return updatePayload;
|
|
}
|
|
function updateProperties(domElement, updatePayload, tag, lastRawProps, nextRawProps) {
|
|
if (tag === "input" && nextRawProps.type === "radio" && nextRawProps.name != null) {
|
|
updateChecked(domElement, nextRawProps);
|
|
}
|
|
var wasCustomComponentTag = isCustomComponent(tag, lastRawProps);
|
|
var isCustomComponentTag = isCustomComponent(tag, nextRawProps);
|
|
updateDOMProperties(domElement, updatePayload, wasCustomComponentTag, isCustomComponentTag);
|
|
switch (tag) {
|
|
case "input":
|
|
updateWrapper(domElement, nextRawProps);
|
|
break;
|
|
case "textarea":
|
|
updateWrapper$1(domElement, nextRawProps);
|
|
break;
|
|
case "select":
|
|
postUpdateWrapper(domElement, nextRawProps);
|
|
break;
|
|
}
|
|
}
|
|
function getPossibleStandardName(propName) {
|
|
{
|
|
var lowerCasedName = propName.toLowerCase();
|
|
if (!possibleStandardNames.hasOwnProperty(lowerCasedName)) {
|
|
return null;
|
|
}
|
|
return possibleStandardNames[lowerCasedName] || null;
|
|
}
|
|
}
|
|
function diffHydratedProperties(domElement, tag, rawProps, parentNamespace, rootContainerElement) {
|
|
var isCustomComponentTag;
|
|
var extraAttributeNames;
|
|
{
|
|
suppressHydrationWarning = rawProps[SUPPRESS_HYDRATION_WARNING] === true;
|
|
isCustomComponentTag = isCustomComponent(tag, rawProps);
|
|
validatePropertiesInDevelopment(tag, rawProps);
|
|
}
|
|
switch (tag) {
|
|
case "dialog":
|
|
listenToNonDelegatedEvent("cancel", domElement);
|
|
listenToNonDelegatedEvent("close", domElement);
|
|
break;
|
|
case "iframe":
|
|
case "object":
|
|
case "embed":
|
|
listenToNonDelegatedEvent("load", domElement);
|
|
break;
|
|
case "video":
|
|
case "audio":
|
|
for (var i3 = 0; i3 < mediaEventTypes.length; i3++) {
|
|
listenToNonDelegatedEvent(mediaEventTypes[i3], domElement);
|
|
}
|
|
break;
|
|
case "source":
|
|
listenToNonDelegatedEvent("error", domElement);
|
|
break;
|
|
case "img":
|
|
case "image":
|
|
case "link":
|
|
listenToNonDelegatedEvent("error", domElement);
|
|
listenToNonDelegatedEvent("load", domElement);
|
|
break;
|
|
case "details":
|
|
listenToNonDelegatedEvent("toggle", domElement);
|
|
break;
|
|
case "input":
|
|
initWrapperState(domElement, rawProps);
|
|
listenToNonDelegatedEvent("invalid", domElement);
|
|
break;
|
|
case "option":
|
|
validateProps(domElement, rawProps);
|
|
break;
|
|
case "select":
|
|
initWrapperState$1(domElement, rawProps);
|
|
listenToNonDelegatedEvent("invalid", domElement);
|
|
break;
|
|
case "textarea":
|
|
initWrapperState$2(domElement, rawProps);
|
|
listenToNonDelegatedEvent("invalid", domElement);
|
|
break;
|
|
}
|
|
assertValidProps(tag, rawProps);
|
|
{
|
|
extraAttributeNames = new Set();
|
|
var attributes = domElement.attributes;
|
|
for (var _i = 0; _i < attributes.length; _i++) {
|
|
var name = attributes[_i].name.toLowerCase();
|
|
switch (name) {
|
|
case "data-reactroot":
|
|
break;
|
|
case "value":
|
|
break;
|
|
case "checked":
|
|
break;
|
|
case "selected":
|
|
break;
|
|
default:
|
|
extraAttributeNames.add(attributes[_i].name);
|
|
}
|
|
}
|
|
}
|
|
var updatePayload = null;
|
|
for (var propKey in rawProps) {
|
|
if (!rawProps.hasOwnProperty(propKey)) {
|
|
continue;
|
|
}
|
|
var nextProp = rawProps[propKey];
|
|
if (propKey === CHILDREN) {
|
|
if (typeof nextProp === "string") {
|
|
if (domElement.textContent !== nextProp) {
|
|
if (!suppressHydrationWarning) {
|
|
warnForTextDifference(domElement.textContent, nextProp);
|
|
}
|
|
updatePayload = [CHILDREN, nextProp];
|
|
}
|
|
} else if (typeof nextProp === "number") {
|
|
if (domElement.textContent !== "" + nextProp) {
|
|
if (!suppressHydrationWarning) {
|
|
warnForTextDifference(domElement.textContent, nextProp);
|
|
}
|
|
updatePayload = [CHILDREN, "" + nextProp];
|
|
}
|
|
}
|
|
} else if (registrationNameDependencies.hasOwnProperty(propKey)) {
|
|
if (nextProp != null) {
|
|
if (typeof nextProp !== "function") {
|
|
warnForInvalidEventListener(propKey, nextProp);
|
|
}
|
|
if (propKey === "onScroll") {
|
|
listenToNonDelegatedEvent("scroll", domElement);
|
|
}
|
|
}
|
|
} else if (typeof isCustomComponentTag === "boolean") {
|
|
var serverValue = void 0;
|
|
var propertyInfo = getPropertyInfo(propKey);
|
|
if (suppressHydrationWarning)
|
|
;
|
|
else if (propKey === SUPPRESS_CONTENT_EDITABLE_WARNING || propKey === SUPPRESS_HYDRATION_WARNING || propKey === "value" || propKey === "checked" || propKey === "selected")
|
|
;
|
|
else if (propKey === DANGEROUSLY_SET_INNER_HTML) {
|
|
var serverHTML = domElement.innerHTML;
|
|
var nextHtml = nextProp ? nextProp[HTML$1] : void 0;
|
|
if (nextHtml != null) {
|
|
var expectedHTML = normalizeHTML(domElement, nextHtml);
|
|
if (expectedHTML !== serverHTML) {
|
|
warnForPropDifference(propKey, serverHTML, expectedHTML);
|
|
}
|
|
}
|
|
} else if (propKey === STYLE) {
|
|
extraAttributeNames.delete(propKey);
|
|
if (canDiffStyleForHydrationWarning) {
|
|
var expectedStyle = createDangerousStringForStyles(nextProp);
|
|
serverValue = domElement.getAttribute("style");
|
|
if (expectedStyle !== serverValue) {
|
|
warnForPropDifference(propKey, serverValue, expectedStyle);
|
|
}
|
|
}
|
|
} else if (isCustomComponentTag) {
|
|
extraAttributeNames.delete(propKey.toLowerCase());
|
|
serverValue = getValueForAttribute(domElement, propKey, nextProp);
|
|
if (nextProp !== serverValue) {
|
|
warnForPropDifference(propKey, serverValue, nextProp);
|
|
}
|
|
} else if (!shouldIgnoreAttribute(propKey, propertyInfo, isCustomComponentTag) && !shouldRemoveAttribute(propKey, nextProp, propertyInfo, isCustomComponentTag)) {
|
|
var isMismatchDueToBadCasing = false;
|
|
if (propertyInfo !== null) {
|
|
extraAttributeNames.delete(propertyInfo.attributeName);
|
|
serverValue = getValueForProperty(domElement, propKey, nextProp, propertyInfo);
|
|
} else {
|
|
var ownNamespace = parentNamespace;
|
|
if (ownNamespace === HTML_NAMESPACE$1) {
|
|
ownNamespace = getIntrinsicNamespace(tag);
|
|
}
|
|
if (ownNamespace === HTML_NAMESPACE$1) {
|
|
extraAttributeNames.delete(propKey.toLowerCase());
|
|
} else {
|
|
var standardName = getPossibleStandardName(propKey);
|
|
if (standardName !== null && standardName !== propKey) {
|
|
isMismatchDueToBadCasing = true;
|
|
extraAttributeNames.delete(standardName);
|
|
}
|
|
extraAttributeNames.delete(propKey);
|
|
}
|
|
serverValue = getValueForAttribute(domElement, propKey, nextProp);
|
|
}
|
|
if (nextProp !== serverValue && !isMismatchDueToBadCasing) {
|
|
warnForPropDifference(propKey, serverValue, nextProp);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
{
|
|
if (extraAttributeNames.size > 0 && !suppressHydrationWarning) {
|
|
warnForExtraAttributes(extraAttributeNames);
|
|
}
|
|
}
|
|
switch (tag) {
|
|
case "input":
|
|
track(domElement);
|
|
postMountWrapper(domElement, rawProps, true);
|
|
break;
|
|
case "textarea":
|
|
track(domElement);
|
|
postMountWrapper$3(domElement);
|
|
break;
|
|
case "select":
|
|
case "option":
|
|
break;
|
|
default:
|
|
if (typeof rawProps.onClick === "function") {
|
|
trapClickOnNonInteractiveElement(domElement);
|
|
}
|
|
break;
|
|
}
|
|
return updatePayload;
|
|
}
|
|
function diffHydratedText(textNode, text) {
|
|
var isDifferent = textNode.nodeValue !== text;
|
|
return isDifferent;
|
|
}
|
|
function warnForUnmatchedText(textNode, text) {
|
|
{
|
|
warnForTextDifference(textNode.nodeValue, text);
|
|
}
|
|
}
|
|
function warnForDeletedHydratableElement(parentNode, child) {
|
|
{
|
|
if (didWarnInvalidHydration) {
|
|
return;
|
|
}
|
|
didWarnInvalidHydration = true;
|
|
error("Did not expect server HTML to contain a <%s> in <%s>.", child.nodeName.toLowerCase(), parentNode.nodeName.toLowerCase());
|
|
}
|
|
}
|
|
function warnForDeletedHydratableText(parentNode, child) {
|
|
{
|
|
if (didWarnInvalidHydration) {
|
|
return;
|
|
}
|
|
didWarnInvalidHydration = true;
|
|
error('Did not expect server HTML to contain the text node "%s" in <%s>.', child.nodeValue, parentNode.nodeName.toLowerCase());
|
|
}
|
|
}
|
|
function warnForInsertedHydratedElement(parentNode, tag, props) {
|
|
{
|
|
if (didWarnInvalidHydration) {
|
|
return;
|
|
}
|
|
didWarnInvalidHydration = true;
|
|
error("Expected server HTML to contain a matching <%s> in <%s>.", tag, parentNode.nodeName.toLowerCase());
|
|
}
|
|
}
|
|
function warnForInsertedHydratedText(parentNode, text) {
|
|
{
|
|
if (text === "") {
|
|
return;
|
|
}
|
|
if (didWarnInvalidHydration) {
|
|
return;
|
|
}
|
|
didWarnInvalidHydration = true;
|
|
error('Expected server HTML to contain a matching text node for "%s" in <%s>.', text, parentNode.nodeName.toLowerCase());
|
|
}
|
|
}
|
|
function restoreControlledState$3(domElement, tag, props) {
|
|
switch (tag) {
|
|
case "input":
|
|
restoreControlledState(domElement, props);
|
|
return;
|
|
case "textarea":
|
|
restoreControlledState$2(domElement, props);
|
|
return;
|
|
case "select":
|
|
restoreControlledState$1(domElement, props);
|
|
return;
|
|
}
|
|
}
|
|
var validateDOMNesting = function() {
|
|
};
|
|
var updatedAncestorInfo = function() {
|
|
};
|
|
{
|
|
var specialTags = ["address", "applet", "area", "article", "aside", "base", "basefont", "bgsound", "blockquote", "body", "br", "button", "caption", "center", "col", "colgroup", "dd", "details", "dir", "div", "dl", "dt", "embed", "fieldset", "figcaption", "figure", "footer", "form", "frame", "frameset", "h1", "h2", "h3", "h4", "h5", "h6", "head", "header", "hgroup", "hr", "html", "iframe", "img", "input", "isindex", "li", "link", "listing", "main", "marquee", "menu", "menuitem", "meta", "nav", "noembed", "noframes", "noscript", "object", "ol", "p", "param", "plaintext", "pre", "script", "section", "select", "source", "style", "summary", "table", "tbody", "td", "template", "textarea", "tfoot", "th", "thead", "title", "tr", "track", "ul", "wbr", "xmp"];
|
|
var inScopeTags = [
|
|
"applet",
|
|
"caption",
|
|
"html",
|
|
"table",
|
|
"td",
|
|
"th",
|
|
"marquee",
|
|
"object",
|
|
"template",
|
|
"foreignObject",
|
|
"desc",
|
|
"title"
|
|
];
|
|
var buttonScopeTags = inScopeTags.concat(["button"]);
|
|
var impliedEndTags = ["dd", "dt", "li", "option", "optgroup", "p", "rp", "rt"];
|
|
var emptyAncestorInfo = {
|
|
current: null,
|
|
formTag: null,
|
|
aTagInScope: null,
|
|
buttonTagInScope: null,
|
|
nobrTagInScope: null,
|
|
pTagInButtonScope: null,
|
|
listItemTagAutoclosing: null,
|
|
dlItemTagAutoclosing: null
|
|
};
|
|
updatedAncestorInfo = function(oldInfo, tag) {
|
|
var ancestorInfo = _assign({}, oldInfo || emptyAncestorInfo);
|
|
var info = {
|
|
tag
|
|
};
|
|
if (inScopeTags.indexOf(tag) !== -1) {
|
|
ancestorInfo.aTagInScope = null;
|
|
ancestorInfo.buttonTagInScope = null;
|
|
ancestorInfo.nobrTagInScope = null;
|
|
}
|
|
if (buttonScopeTags.indexOf(tag) !== -1) {
|
|
ancestorInfo.pTagInButtonScope = null;
|
|
}
|
|
if (specialTags.indexOf(tag) !== -1 && tag !== "address" && tag !== "div" && tag !== "p") {
|
|
ancestorInfo.listItemTagAutoclosing = null;
|
|
ancestorInfo.dlItemTagAutoclosing = null;
|
|
}
|
|
ancestorInfo.current = info;
|
|
if (tag === "form") {
|
|
ancestorInfo.formTag = info;
|
|
}
|
|
if (tag === "a") {
|
|
ancestorInfo.aTagInScope = info;
|
|
}
|
|
if (tag === "button") {
|
|
ancestorInfo.buttonTagInScope = info;
|
|
}
|
|
if (tag === "nobr") {
|
|
ancestorInfo.nobrTagInScope = info;
|
|
}
|
|
if (tag === "p") {
|
|
ancestorInfo.pTagInButtonScope = info;
|
|
}
|
|
if (tag === "li") {
|
|
ancestorInfo.listItemTagAutoclosing = info;
|
|
}
|
|
if (tag === "dd" || tag === "dt") {
|
|
ancestorInfo.dlItemTagAutoclosing = info;
|
|
}
|
|
return ancestorInfo;
|
|
};
|
|
var isTagValidWithParent = function(tag, parentTag) {
|
|
switch (parentTag) {
|
|
case "select":
|
|
return tag === "option" || tag === "optgroup" || tag === "#text";
|
|
case "optgroup":
|
|
return tag === "option" || tag === "#text";
|
|
case "option":
|
|
return tag === "#text";
|
|
case "tr":
|
|
return tag === "th" || tag === "td" || tag === "style" || tag === "script" || tag === "template";
|
|
case "tbody":
|
|
case "thead":
|
|
case "tfoot":
|
|
return tag === "tr" || tag === "style" || tag === "script" || tag === "template";
|
|
case "colgroup":
|
|
return tag === "col" || tag === "template";
|
|
case "table":
|
|
return tag === "caption" || tag === "colgroup" || tag === "tbody" || tag === "tfoot" || tag === "thead" || tag === "style" || tag === "script" || tag === "template";
|
|
case "head":
|
|
return tag === "base" || tag === "basefont" || tag === "bgsound" || tag === "link" || tag === "meta" || tag === "title" || tag === "noscript" || tag === "noframes" || tag === "style" || tag === "script" || tag === "template";
|
|
case "html":
|
|
return tag === "head" || tag === "body" || tag === "frameset";
|
|
case "frameset":
|
|
return tag === "frame";
|
|
case "#document":
|
|
return tag === "html";
|
|
}
|
|
switch (tag) {
|
|
case "h1":
|
|
case "h2":
|
|
case "h3":
|
|
case "h4":
|
|
case "h5":
|
|
case "h6":
|
|
return parentTag !== "h1" && parentTag !== "h2" && parentTag !== "h3" && parentTag !== "h4" && parentTag !== "h5" && parentTag !== "h6";
|
|
case "rp":
|
|
case "rt":
|
|
return impliedEndTags.indexOf(parentTag) === -1;
|
|
case "body":
|
|
case "caption":
|
|
case "col":
|
|
case "colgroup":
|
|
case "frameset":
|
|
case "frame":
|
|
case "head":
|
|
case "html":
|
|
case "tbody":
|
|
case "td":
|
|
case "tfoot":
|
|
case "th":
|
|
case "thead":
|
|
case "tr":
|
|
return parentTag == null;
|
|
}
|
|
return true;
|
|
};
|
|
var findInvalidAncestorForTag = function(tag, ancestorInfo) {
|
|
switch (tag) {
|
|
case "address":
|
|
case "article":
|
|
case "aside":
|
|
case "blockquote":
|
|
case "center":
|
|
case "details":
|
|
case "dialog":
|
|
case "dir":
|
|
case "div":
|
|
case "dl":
|
|
case "fieldset":
|
|
case "figcaption":
|
|
case "figure":
|
|
case "footer":
|
|
case "header":
|
|
case "hgroup":
|
|
case "main":
|
|
case "menu":
|
|
case "nav":
|
|
case "ol":
|
|
case "p":
|
|
case "section":
|
|
case "summary":
|
|
case "ul":
|
|
case "pre":
|
|
case "listing":
|
|
case "table":
|
|
case "hr":
|
|
case "xmp":
|
|
case "h1":
|
|
case "h2":
|
|
case "h3":
|
|
case "h4":
|
|
case "h5":
|
|
case "h6":
|
|
return ancestorInfo.pTagInButtonScope;
|
|
case "form":
|
|
return ancestorInfo.formTag || ancestorInfo.pTagInButtonScope;
|
|
case "li":
|
|
return ancestorInfo.listItemTagAutoclosing;
|
|
case "dd":
|
|
case "dt":
|
|
return ancestorInfo.dlItemTagAutoclosing;
|
|
case "button":
|
|
return ancestorInfo.buttonTagInScope;
|
|
case "a":
|
|
return ancestorInfo.aTagInScope;
|
|
case "nobr":
|
|
return ancestorInfo.nobrTagInScope;
|
|
}
|
|
return null;
|
|
};
|
|
var didWarn$1 = {};
|
|
validateDOMNesting = function(childTag, childText, ancestorInfo) {
|
|
ancestorInfo = ancestorInfo || emptyAncestorInfo;
|
|
var parentInfo = ancestorInfo.current;
|
|
var parentTag = parentInfo && parentInfo.tag;
|
|
if (childText != null) {
|
|
if (childTag != null) {
|
|
error("validateDOMNesting: when childText is passed, childTag should be null");
|
|
}
|
|
childTag = "#text";
|
|
}
|
|
var invalidParent = isTagValidWithParent(childTag, parentTag) ? null : parentInfo;
|
|
var invalidAncestor = invalidParent ? null : findInvalidAncestorForTag(childTag, ancestorInfo);
|
|
var invalidParentOrAncestor = invalidParent || invalidAncestor;
|
|
if (!invalidParentOrAncestor) {
|
|
return;
|
|
}
|
|
var ancestorTag = invalidParentOrAncestor.tag;
|
|
var warnKey = !!invalidParent + "|" + childTag + "|" + ancestorTag;
|
|
if (didWarn$1[warnKey]) {
|
|
return;
|
|
}
|
|
didWarn$1[warnKey] = true;
|
|
var tagDisplayName = childTag;
|
|
var whitespaceInfo = "";
|
|
if (childTag === "#text") {
|
|
if (/\S/.test(childText)) {
|
|
tagDisplayName = "Text nodes";
|
|
} else {
|
|
tagDisplayName = "Whitespace text nodes";
|
|
whitespaceInfo = " Make sure you don't have any extra whitespace between tags on each line of your source code.";
|
|
}
|
|
} else {
|
|
tagDisplayName = "<" + childTag + ">";
|
|
}
|
|
if (invalidParent) {
|
|
var info = "";
|
|
if (ancestorTag === "table" && childTag === "tr") {
|
|
info += " Add a <tbody>, <thead> or <tfoot> to your code to match the DOM tree generated by the browser.";
|
|
}
|
|
error("validateDOMNesting(...): %s cannot appear as a child of <%s>.%s%s", tagDisplayName, ancestorTag, whitespaceInfo, info);
|
|
} else {
|
|
error("validateDOMNesting(...): %s cannot appear as a descendant of <%s>.", tagDisplayName, ancestorTag);
|
|
}
|
|
};
|
|
}
|
|
var SUPPRESS_HYDRATION_WARNING$1;
|
|
{
|
|
SUPPRESS_HYDRATION_WARNING$1 = "suppressHydrationWarning";
|
|
}
|
|
var SUSPENSE_START_DATA = "$";
|
|
var SUSPENSE_END_DATA = "/$";
|
|
var SUSPENSE_PENDING_START_DATA = "$?";
|
|
var SUSPENSE_FALLBACK_START_DATA = "$!";
|
|
var STYLE$1 = "style";
|
|
var eventsEnabled = null;
|
|
var selectionInformation = null;
|
|
function shouldAutoFocusHostComponent(type, props) {
|
|
switch (type) {
|
|
case "button":
|
|
case "input":
|
|
case "select":
|
|
case "textarea":
|
|
return !!props.autoFocus;
|
|
}
|
|
return false;
|
|
}
|
|
function getRootHostContext(rootContainerInstance) {
|
|
var type;
|
|
var namespace;
|
|
var nodeType = rootContainerInstance.nodeType;
|
|
switch (nodeType) {
|
|
case DOCUMENT_NODE:
|
|
case DOCUMENT_FRAGMENT_NODE: {
|
|
type = nodeType === DOCUMENT_NODE ? "#document" : "#fragment";
|
|
var root2 = rootContainerInstance.documentElement;
|
|
namespace = root2 ? root2.namespaceURI : getChildNamespace(null, "");
|
|
break;
|
|
}
|
|
default: {
|
|
var container = nodeType === COMMENT_NODE ? rootContainerInstance.parentNode : rootContainerInstance;
|
|
var ownNamespace = container.namespaceURI || null;
|
|
type = container.tagName;
|
|
namespace = getChildNamespace(ownNamespace, type);
|
|
break;
|
|
}
|
|
}
|
|
{
|
|
var validatedTag = type.toLowerCase();
|
|
var ancestorInfo = updatedAncestorInfo(null, validatedTag);
|
|
return {
|
|
namespace,
|
|
ancestorInfo
|
|
};
|
|
}
|
|
}
|
|
function getChildHostContext(parentHostContext, type, rootContainerInstance) {
|
|
{
|
|
var parentHostContextDev = parentHostContext;
|
|
var namespace = getChildNamespace(parentHostContextDev.namespace, type);
|
|
var ancestorInfo = updatedAncestorInfo(parentHostContextDev.ancestorInfo, type);
|
|
return {
|
|
namespace,
|
|
ancestorInfo
|
|
};
|
|
}
|
|
}
|
|
function getPublicInstance(instance) {
|
|
return instance;
|
|
}
|
|
function prepareForCommit(containerInfo) {
|
|
eventsEnabled = isEnabled();
|
|
selectionInformation = getSelectionInformation();
|
|
var activeInstance = null;
|
|
setEnabled(false);
|
|
return activeInstance;
|
|
}
|
|
function resetAfterCommit(containerInfo) {
|
|
restoreSelection(selectionInformation);
|
|
setEnabled(eventsEnabled);
|
|
eventsEnabled = null;
|
|
selectionInformation = null;
|
|
}
|
|
function createInstance(type, props, rootContainerInstance, hostContext, internalInstanceHandle) {
|
|
var parentNamespace;
|
|
{
|
|
var hostContextDev = hostContext;
|
|
validateDOMNesting(type, null, hostContextDev.ancestorInfo);
|
|
if (typeof props.children === "string" || typeof props.children === "number") {
|
|
var string = "" + props.children;
|
|
var ownAncestorInfo = updatedAncestorInfo(hostContextDev.ancestorInfo, type);
|
|
validateDOMNesting(null, string, ownAncestorInfo);
|
|
}
|
|
parentNamespace = hostContextDev.namespace;
|
|
}
|
|
var domElement = createElement7(type, props, rootContainerInstance, parentNamespace);
|
|
precacheFiberNode(internalInstanceHandle, domElement);
|
|
updateFiberProps(domElement, props);
|
|
return domElement;
|
|
}
|
|
function appendInitialChild(parentInstance, child) {
|
|
parentInstance.appendChild(child);
|
|
}
|
|
function finalizeInitialChildren(domElement, type, props, rootContainerInstance, hostContext) {
|
|
setInitialProperties(domElement, type, props, rootContainerInstance);
|
|
return shouldAutoFocusHostComponent(type, props);
|
|
}
|
|
function prepareUpdate(domElement, type, oldProps, newProps, rootContainerInstance, hostContext) {
|
|
{
|
|
var hostContextDev = hostContext;
|
|
if (typeof newProps.children !== typeof oldProps.children && (typeof newProps.children === "string" || typeof newProps.children === "number")) {
|
|
var string = "" + newProps.children;
|
|
var ownAncestorInfo = updatedAncestorInfo(hostContextDev.ancestorInfo, type);
|
|
validateDOMNesting(null, string, ownAncestorInfo);
|
|
}
|
|
}
|
|
return diffProperties(domElement, type, oldProps, newProps);
|
|
}
|
|
function shouldSetTextContent(type, props) {
|
|
return type === "textarea" || type === "option" || type === "noscript" || typeof props.children === "string" || typeof props.children === "number" || typeof props.dangerouslySetInnerHTML === "object" && props.dangerouslySetInnerHTML !== null && props.dangerouslySetInnerHTML.__html != null;
|
|
}
|
|
function createTextInstance(text, rootContainerInstance, hostContext, internalInstanceHandle) {
|
|
{
|
|
var hostContextDev = hostContext;
|
|
validateDOMNesting(null, text, hostContextDev.ancestorInfo);
|
|
}
|
|
var textNode = createTextNode(text, rootContainerInstance);
|
|
precacheFiberNode(internalInstanceHandle, textNode);
|
|
return textNode;
|
|
}
|
|
var scheduleTimeout = typeof setTimeout === "function" ? setTimeout : void 0;
|
|
var cancelTimeout = typeof clearTimeout === "function" ? clearTimeout : void 0;
|
|
var noTimeout = -1;
|
|
function commitMount(domElement, type, newProps, internalInstanceHandle) {
|
|
if (shouldAutoFocusHostComponent(type, newProps)) {
|
|
domElement.focus();
|
|
}
|
|
}
|
|
function commitUpdate(domElement, updatePayload, type, oldProps, newProps, internalInstanceHandle) {
|
|
updateFiberProps(domElement, newProps);
|
|
updateProperties(domElement, updatePayload, type, oldProps, newProps);
|
|
}
|
|
function resetTextContent(domElement) {
|
|
setTextContent(domElement, "");
|
|
}
|
|
function commitTextUpdate(textInstance, oldText, newText) {
|
|
textInstance.nodeValue = newText;
|
|
}
|
|
function appendChild(parentInstance, child) {
|
|
parentInstance.appendChild(child);
|
|
}
|
|
function appendChildToContainer(container, child) {
|
|
var parentNode;
|
|
if (container.nodeType === COMMENT_NODE) {
|
|
parentNode = container.parentNode;
|
|
parentNode.insertBefore(child, container);
|
|
} else {
|
|
parentNode = container;
|
|
parentNode.appendChild(child);
|
|
}
|
|
var reactRootContainer = container._reactRootContainer;
|
|
if ((reactRootContainer === null || reactRootContainer === void 0) && parentNode.onclick === null) {
|
|
trapClickOnNonInteractiveElement(parentNode);
|
|
}
|
|
}
|
|
function insertBefore(parentInstance, child, beforeChild) {
|
|
parentInstance.insertBefore(child, beforeChild);
|
|
}
|
|
function insertInContainerBefore(container, child, beforeChild) {
|
|
if (container.nodeType === COMMENT_NODE) {
|
|
container.parentNode.insertBefore(child, beforeChild);
|
|
} else {
|
|
container.insertBefore(child, beforeChild);
|
|
}
|
|
}
|
|
function removeChild(parentInstance, child) {
|
|
parentInstance.removeChild(child);
|
|
}
|
|
function removeChildFromContainer(container, child) {
|
|
if (container.nodeType === COMMENT_NODE) {
|
|
container.parentNode.removeChild(child);
|
|
} else {
|
|
container.removeChild(child);
|
|
}
|
|
}
|
|
function hideInstance(instance) {
|
|
instance = instance;
|
|
var style2 = instance.style;
|
|
if (typeof style2.setProperty === "function") {
|
|
style2.setProperty("display", "none", "important");
|
|
} else {
|
|
style2.display = "none";
|
|
}
|
|
}
|
|
function hideTextInstance(textInstance) {
|
|
textInstance.nodeValue = "";
|
|
}
|
|
function unhideInstance(instance, props) {
|
|
instance = instance;
|
|
var styleProp = props[STYLE$1];
|
|
var display = styleProp !== void 0 && styleProp !== null && styleProp.hasOwnProperty("display") ? styleProp.display : null;
|
|
instance.style.display = dangerousStyleValue("display", display);
|
|
}
|
|
function unhideTextInstance(textInstance, text) {
|
|
textInstance.nodeValue = text;
|
|
}
|
|
function clearContainer(container) {
|
|
if (container.nodeType === ELEMENT_NODE) {
|
|
container.textContent = "";
|
|
} else if (container.nodeType === DOCUMENT_NODE) {
|
|
var body = container.body;
|
|
if (body != null) {
|
|
body.textContent = "";
|
|
}
|
|
}
|
|
}
|
|
function canHydrateInstance(instance, type, props) {
|
|
if (instance.nodeType !== ELEMENT_NODE || type.toLowerCase() !== instance.nodeName.toLowerCase()) {
|
|
return null;
|
|
}
|
|
return instance;
|
|
}
|
|
function canHydrateTextInstance(instance, text) {
|
|
if (text === "" || instance.nodeType !== TEXT_NODE) {
|
|
return null;
|
|
}
|
|
return instance;
|
|
}
|
|
function isSuspenseInstancePending(instance) {
|
|
return instance.data === SUSPENSE_PENDING_START_DATA;
|
|
}
|
|
function isSuspenseInstanceFallback(instance) {
|
|
return instance.data === SUSPENSE_FALLBACK_START_DATA;
|
|
}
|
|
function getNextHydratable(node) {
|
|
for (; node != null; node = node.nextSibling) {
|
|
var nodeType = node.nodeType;
|
|
if (nodeType === ELEMENT_NODE || nodeType === TEXT_NODE) {
|
|
break;
|
|
}
|
|
}
|
|
return node;
|
|
}
|
|
function getNextHydratableSibling(instance) {
|
|
return getNextHydratable(instance.nextSibling);
|
|
}
|
|
function getFirstHydratableChild(parentInstance) {
|
|
return getNextHydratable(parentInstance.firstChild);
|
|
}
|
|
function hydrateInstance(instance, type, props, rootContainerInstance, hostContext, internalInstanceHandle) {
|
|
precacheFiberNode(internalInstanceHandle, instance);
|
|
updateFiberProps(instance, props);
|
|
var parentNamespace;
|
|
{
|
|
var hostContextDev = hostContext;
|
|
parentNamespace = hostContextDev.namespace;
|
|
}
|
|
return diffHydratedProperties(instance, type, props, parentNamespace);
|
|
}
|
|
function hydrateTextInstance(textInstance, text, internalInstanceHandle) {
|
|
precacheFiberNode(internalInstanceHandle, textInstance);
|
|
return diffHydratedText(textInstance, text);
|
|
}
|
|
function getNextHydratableInstanceAfterSuspenseInstance(suspenseInstance) {
|
|
var node = suspenseInstance.nextSibling;
|
|
var depth = 0;
|
|
while (node) {
|
|
if (node.nodeType === COMMENT_NODE) {
|
|
var data = node.data;
|
|
if (data === SUSPENSE_END_DATA) {
|
|
if (depth === 0) {
|
|
return getNextHydratableSibling(node);
|
|
} else {
|
|
depth--;
|
|
}
|
|
} else if (data === SUSPENSE_START_DATA || data === SUSPENSE_FALLBACK_START_DATA || data === SUSPENSE_PENDING_START_DATA) {
|
|
depth++;
|
|
}
|
|
}
|
|
node = node.nextSibling;
|
|
}
|
|
return null;
|
|
}
|
|
function getParentSuspenseInstance(targetInstance) {
|
|
var node = targetInstance.previousSibling;
|
|
var depth = 0;
|
|
while (node) {
|
|
if (node.nodeType === COMMENT_NODE) {
|
|
var data = node.data;
|
|
if (data === SUSPENSE_START_DATA || data === SUSPENSE_FALLBACK_START_DATA || data === SUSPENSE_PENDING_START_DATA) {
|
|
if (depth === 0) {
|
|
return node;
|
|
} else {
|
|
depth--;
|
|
}
|
|
} else if (data === SUSPENSE_END_DATA) {
|
|
depth++;
|
|
}
|
|
}
|
|
node = node.previousSibling;
|
|
}
|
|
return null;
|
|
}
|
|
function commitHydratedContainer(container) {
|
|
retryIfBlockedOn(container);
|
|
}
|
|
function commitHydratedSuspenseInstance(suspenseInstance) {
|
|
retryIfBlockedOn(suspenseInstance);
|
|
}
|
|
function didNotMatchHydratedContainerTextInstance(parentContainer, textInstance, text) {
|
|
{
|
|
warnForUnmatchedText(textInstance, text);
|
|
}
|
|
}
|
|
function didNotMatchHydratedTextInstance(parentType, parentProps, parentInstance, textInstance, text) {
|
|
if (parentProps[SUPPRESS_HYDRATION_WARNING$1] !== true) {
|
|
warnForUnmatchedText(textInstance, text);
|
|
}
|
|
}
|
|
function didNotHydrateContainerInstance(parentContainer, instance) {
|
|
{
|
|
if (instance.nodeType === ELEMENT_NODE) {
|
|
warnForDeletedHydratableElement(parentContainer, instance);
|
|
} else if (instance.nodeType === COMMENT_NODE)
|
|
;
|
|
else {
|
|
warnForDeletedHydratableText(parentContainer, instance);
|
|
}
|
|
}
|
|
}
|
|
function didNotHydrateInstance(parentType, parentProps, parentInstance, instance) {
|
|
if (parentProps[SUPPRESS_HYDRATION_WARNING$1] !== true) {
|
|
if (instance.nodeType === ELEMENT_NODE) {
|
|
warnForDeletedHydratableElement(parentInstance, instance);
|
|
} else if (instance.nodeType === COMMENT_NODE)
|
|
;
|
|
else {
|
|
warnForDeletedHydratableText(parentInstance, instance);
|
|
}
|
|
}
|
|
}
|
|
function didNotFindHydratableContainerInstance(parentContainer, type, props) {
|
|
{
|
|
warnForInsertedHydratedElement(parentContainer, type);
|
|
}
|
|
}
|
|
function didNotFindHydratableContainerTextInstance(parentContainer, text) {
|
|
{
|
|
warnForInsertedHydratedText(parentContainer, text);
|
|
}
|
|
}
|
|
function didNotFindHydratableInstance(parentType, parentProps, parentInstance, type, props) {
|
|
if (parentProps[SUPPRESS_HYDRATION_WARNING$1] !== true) {
|
|
warnForInsertedHydratedElement(parentInstance, type);
|
|
}
|
|
}
|
|
function didNotFindHydratableTextInstance(parentType, parentProps, parentInstance, text) {
|
|
if (parentProps[SUPPRESS_HYDRATION_WARNING$1] !== true) {
|
|
warnForInsertedHydratedText(parentInstance, text);
|
|
}
|
|
}
|
|
function didNotFindHydratableSuspenseInstance(parentType, parentProps, parentInstance) {
|
|
if (parentProps[SUPPRESS_HYDRATION_WARNING$1] !== true)
|
|
;
|
|
}
|
|
var clientId = 0;
|
|
function makeClientIdInDEV(warnOnAccessInDEV) {
|
|
var id = "r:" + (clientId++).toString(36);
|
|
return {
|
|
toString: function() {
|
|
warnOnAccessInDEV();
|
|
return id;
|
|
},
|
|
valueOf: function() {
|
|
warnOnAccessInDEV();
|
|
return id;
|
|
}
|
|
};
|
|
}
|
|
function isOpaqueHydratingObject(value) {
|
|
return value !== null && typeof value === "object" && value.$$typeof === REACT_OPAQUE_ID_TYPE;
|
|
}
|
|
function makeOpaqueHydratingObject(attemptToReadValue) {
|
|
return {
|
|
$$typeof: REACT_OPAQUE_ID_TYPE,
|
|
toString: attemptToReadValue,
|
|
valueOf: attemptToReadValue
|
|
};
|
|
}
|
|
function preparePortalMount(portalInstance) {
|
|
{
|
|
listenToAllSupportedEvents(portalInstance);
|
|
}
|
|
}
|
|
var randomKey = Math.random().toString(36).slice(2);
|
|
var internalInstanceKey = "__reactFiber$" + randomKey;
|
|
var internalPropsKey = "__reactProps$" + randomKey;
|
|
var internalContainerInstanceKey = "__reactContainer$" + randomKey;
|
|
var internalEventHandlersKey = "__reactEvents$" + randomKey;
|
|
function precacheFiberNode(hostInst, node) {
|
|
node[internalInstanceKey] = hostInst;
|
|
}
|
|
function markContainerAsRoot(hostRoot, node) {
|
|
node[internalContainerInstanceKey] = hostRoot;
|
|
}
|
|
function unmarkContainerAsRoot(node) {
|
|
node[internalContainerInstanceKey] = null;
|
|
}
|
|
function isContainerMarkedAsRoot(node) {
|
|
return !!node[internalContainerInstanceKey];
|
|
}
|
|
function getClosestInstanceFromNode(targetNode) {
|
|
var targetInst = targetNode[internalInstanceKey];
|
|
if (targetInst) {
|
|
return targetInst;
|
|
}
|
|
var parentNode = targetNode.parentNode;
|
|
while (parentNode) {
|
|
targetInst = parentNode[internalContainerInstanceKey] || parentNode[internalInstanceKey];
|
|
if (targetInst) {
|
|
var alternate = targetInst.alternate;
|
|
if (targetInst.child !== null || alternate !== null && alternate.child !== null) {
|
|
var suspenseInstance = getParentSuspenseInstance(targetNode);
|
|
while (suspenseInstance !== null) {
|
|
var targetSuspenseInst = suspenseInstance[internalInstanceKey];
|
|
if (targetSuspenseInst) {
|
|
return targetSuspenseInst;
|
|
}
|
|
suspenseInstance = getParentSuspenseInstance(suspenseInstance);
|
|
}
|
|
}
|
|
return targetInst;
|
|
}
|
|
targetNode = parentNode;
|
|
parentNode = targetNode.parentNode;
|
|
}
|
|
return null;
|
|
}
|
|
function getInstanceFromNode(node) {
|
|
var inst = node[internalInstanceKey] || node[internalContainerInstanceKey];
|
|
if (inst) {
|
|
if (inst.tag === HostComponent || inst.tag === HostText || inst.tag === SuspenseComponent || inst.tag === HostRoot) {
|
|
return inst;
|
|
} else {
|
|
return null;
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
function getNodeFromInstance(inst) {
|
|
if (inst.tag === HostComponent || inst.tag === HostText) {
|
|
return inst.stateNode;
|
|
}
|
|
{
|
|
{
|
|
throw Error("getNodeFromInstance: Invalid argument.");
|
|
}
|
|
}
|
|
}
|
|
function getFiberCurrentPropsFromNode(node) {
|
|
return node[internalPropsKey] || null;
|
|
}
|
|
function updateFiberProps(node, props) {
|
|
node[internalPropsKey] = props;
|
|
}
|
|
function getEventListenerSet(node) {
|
|
var elementListenerSet = node[internalEventHandlersKey];
|
|
if (elementListenerSet === void 0) {
|
|
elementListenerSet = node[internalEventHandlersKey] = new Set();
|
|
}
|
|
return elementListenerSet;
|
|
}
|
|
var loggedTypeFailures = {};
|
|
var ReactDebugCurrentFrame$1 = ReactSharedInternals.ReactDebugCurrentFrame;
|
|
function setCurrentlyValidatingElement(element) {
|
|
{
|
|
if (element) {
|
|
var owner = element._owner;
|
|
var stack = describeUnknownElementTypeFrameInDEV(element.type, element._source, owner ? owner.type : null);
|
|
ReactDebugCurrentFrame$1.setExtraStackFrame(stack);
|
|
} else {
|
|
ReactDebugCurrentFrame$1.setExtraStackFrame(null);
|
|
}
|
|
}
|
|
}
|
|
function checkPropTypes(typeSpecs, values, location, componentName, element) {
|
|
{
|
|
var has2 = Function.call.bind(Object.prototype.hasOwnProperty);
|
|
for (var typeSpecName in typeSpecs) {
|
|
if (has2(typeSpecs, typeSpecName)) {
|
|
var error$1 = void 0;
|
|
try {
|
|
if (typeof typeSpecs[typeSpecName] !== "function") {
|
|
var err = Error((componentName || "React class") + ": " + location + " type `" + typeSpecName + "` is invalid; it must be a function, usually from the `prop-types` package, but received `" + typeof typeSpecs[typeSpecName] + "`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");
|
|
err.name = "Invariant Violation";
|
|
throw err;
|
|
}
|
|
error$1 = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED");
|
|
} catch (ex) {
|
|
error$1 = ex;
|
|
}
|
|
if (error$1 && !(error$1 instanceof Error)) {
|
|
setCurrentlyValidatingElement(element);
|
|
error("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).", componentName || "React class", location, typeSpecName, typeof error$1);
|
|
setCurrentlyValidatingElement(null);
|
|
}
|
|
if (error$1 instanceof Error && !(error$1.message in loggedTypeFailures)) {
|
|
loggedTypeFailures[error$1.message] = true;
|
|
setCurrentlyValidatingElement(element);
|
|
error("Failed %s type: %s", location, error$1.message);
|
|
setCurrentlyValidatingElement(null);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
var valueStack = [];
|
|
var fiberStack;
|
|
{
|
|
fiberStack = [];
|
|
}
|
|
var index = -1;
|
|
function createCursor(defaultValue) {
|
|
return {
|
|
current: defaultValue
|
|
};
|
|
}
|
|
function pop(cursor, fiber) {
|
|
if (index < 0) {
|
|
{
|
|
error("Unexpected pop.");
|
|
}
|
|
return;
|
|
}
|
|
{
|
|
if (fiber !== fiberStack[index]) {
|
|
error("Unexpected Fiber popped.");
|
|
}
|
|
}
|
|
cursor.current = valueStack[index];
|
|
valueStack[index] = null;
|
|
{
|
|
fiberStack[index] = null;
|
|
}
|
|
index--;
|
|
}
|
|
function push(cursor, value, fiber) {
|
|
index++;
|
|
valueStack[index] = cursor.current;
|
|
{
|
|
fiberStack[index] = fiber;
|
|
}
|
|
cursor.current = value;
|
|
}
|
|
var warnedAboutMissingGetChildContext;
|
|
{
|
|
warnedAboutMissingGetChildContext = {};
|
|
}
|
|
var emptyContextObject = {};
|
|
{
|
|
Object.freeze(emptyContextObject);
|
|
}
|
|
var contextStackCursor = createCursor(emptyContextObject);
|
|
var didPerformWorkStackCursor = createCursor(false);
|
|
var previousContext = emptyContextObject;
|
|
function getUnmaskedContext(workInProgress2, Component5, didPushOwnContextIfProvider) {
|
|
{
|
|
if (didPushOwnContextIfProvider && isContextProvider(Component5)) {
|
|
return previousContext;
|
|
}
|
|
return contextStackCursor.current;
|
|
}
|
|
}
|
|
function cacheContext(workInProgress2, unmaskedContext, maskedContext) {
|
|
{
|
|
var instance = workInProgress2.stateNode;
|
|
instance.__reactInternalMemoizedUnmaskedChildContext = unmaskedContext;
|
|
instance.__reactInternalMemoizedMaskedChildContext = maskedContext;
|
|
}
|
|
}
|
|
function getMaskedContext(workInProgress2, unmaskedContext) {
|
|
{
|
|
var type = workInProgress2.type;
|
|
var contextTypes = type.contextTypes;
|
|
if (!contextTypes) {
|
|
return emptyContextObject;
|
|
}
|
|
var instance = workInProgress2.stateNode;
|
|
if (instance && instance.__reactInternalMemoizedUnmaskedChildContext === unmaskedContext) {
|
|
return instance.__reactInternalMemoizedMaskedChildContext;
|
|
}
|
|
var context = {};
|
|
for (var key in contextTypes) {
|
|
context[key] = unmaskedContext[key];
|
|
}
|
|
{
|
|
var name = getComponentName(type) || "Unknown";
|
|
checkPropTypes(contextTypes, context, "context", name);
|
|
}
|
|
if (instance) {
|
|
cacheContext(workInProgress2, unmaskedContext, context);
|
|
}
|
|
return context;
|
|
}
|
|
}
|
|
function hasContextChanged() {
|
|
{
|
|
return didPerformWorkStackCursor.current;
|
|
}
|
|
}
|
|
function isContextProvider(type) {
|
|
{
|
|
var childContextTypes = type.childContextTypes;
|
|
return childContextTypes !== null && childContextTypes !== void 0;
|
|
}
|
|
}
|
|
function popContext(fiber) {
|
|
{
|
|
pop(didPerformWorkStackCursor, fiber);
|
|
pop(contextStackCursor, fiber);
|
|
}
|
|
}
|
|
function popTopLevelContextObject(fiber) {
|
|
{
|
|
pop(didPerformWorkStackCursor, fiber);
|
|
pop(contextStackCursor, fiber);
|
|
}
|
|
}
|
|
function pushTopLevelContextObject(fiber, context, didChange) {
|
|
{
|
|
if (!(contextStackCursor.current === emptyContextObject)) {
|
|
{
|
|
throw Error("Unexpected context found on stack. This error is likely caused by a bug in React. Please file an issue.");
|
|
}
|
|
}
|
|
push(contextStackCursor, context, fiber);
|
|
push(didPerformWorkStackCursor, didChange, fiber);
|
|
}
|
|
}
|
|
function processChildContext(fiber, type, parentContext) {
|
|
{
|
|
var instance = fiber.stateNode;
|
|
var childContextTypes = type.childContextTypes;
|
|
if (typeof instance.getChildContext !== "function") {
|
|
{
|
|
var componentName = getComponentName(type) || "Unknown";
|
|
if (!warnedAboutMissingGetChildContext[componentName]) {
|
|
warnedAboutMissingGetChildContext[componentName] = true;
|
|
error("%s.childContextTypes is specified but there is no getChildContext() method on the instance. You can either define getChildContext() on %s or remove childContextTypes from it.", componentName, componentName);
|
|
}
|
|
}
|
|
return parentContext;
|
|
}
|
|
var childContext = instance.getChildContext();
|
|
for (var contextKey in childContext) {
|
|
if (!(contextKey in childContextTypes)) {
|
|
{
|
|
throw Error((getComponentName(type) || "Unknown") + '.getChildContext(): key "' + contextKey + '" is not defined in childContextTypes.');
|
|
}
|
|
}
|
|
}
|
|
{
|
|
var name = getComponentName(type) || "Unknown";
|
|
checkPropTypes(childContextTypes, childContext, "child context", name);
|
|
}
|
|
return _assign({}, parentContext, childContext);
|
|
}
|
|
}
|
|
function pushContextProvider(workInProgress2) {
|
|
{
|
|
var instance = workInProgress2.stateNode;
|
|
var memoizedMergedChildContext = instance && instance.__reactInternalMemoizedMergedChildContext || emptyContextObject;
|
|
previousContext = contextStackCursor.current;
|
|
push(contextStackCursor, memoizedMergedChildContext, workInProgress2);
|
|
push(didPerformWorkStackCursor, didPerformWorkStackCursor.current, workInProgress2);
|
|
return true;
|
|
}
|
|
}
|
|
function invalidateContextProvider(workInProgress2, type, didChange) {
|
|
{
|
|
var instance = workInProgress2.stateNode;
|
|
if (!instance) {
|
|
{
|
|
throw Error("Expected to have an instance by this point. This error is likely caused by a bug in React. Please file an issue.");
|
|
}
|
|
}
|
|
if (didChange) {
|
|
var mergedContext = processChildContext(workInProgress2, type, previousContext);
|
|
instance.__reactInternalMemoizedMergedChildContext = mergedContext;
|
|
pop(didPerformWorkStackCursor, workInProgress2);
|
|
pop(contextStackCursor, workInProgress2);
|
|
push(contextStackCursor, mergedContext, workInProgress2);
|
|
push(didPerformWorkStackCursor, didChange, workInProgress2);
|
|
} else {
|
|
pop(didPerformWorkStackCursor, workInProgress2);
|
|
push(didPerformWorkStackCursor, didChange, workInProgress2);
|
|
}
|
|
}
|
|
}
|
|
function findCurrentUnmaskedContext(fiber) {
|
|
{
|
|
if (!(isFiberMounted(fiber) && fiber.tag === ClassComponent)) {
|
|
{
|
|
throw Error("Expected subtree parent to be a mounted class component. This error is likely caused by a bug in React. Please file an issue.");
|
|
}
|
|
}
|
|
var node = fiber;
|
|
do {
|
|
switch (node.tag) {
|
|
case HostRoot:
|
|
return node.stateNode.context;
|
|
case ClassComponent: {
|
|
var Component5 = node.type;
|
|
if (isContextProvider(Component5)) {
|
|
return node.stateNode.__reactInternalMemoizedMergedChildContext;
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
node = node.return;
|
|
} while (node !== null);
|
|
{
|
|
{
|
|
throw Error("Found unexpected detached subtree parent. This error is likely caused by a bug in React. Please file an issue.");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
var LegacyRoot = 0;
|
|
var BlockingRoot = 1;
|
|
var ConcurrentRoot = 2;
|
|
var rendererID = null;
|
|
var injectedHook = null;
|
|
var hasLoggedError = false;
|
|
var isDevToolsPresent = typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== "undefined";
|
|
function injectInternals(internals) {
|
|
if (typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ === "undefined") {
|
|
return false;
|
|
}
|
|
var hook = __REACT_DEVTOOLS_GLOBAL_HOOK__;
|
|
if (hook.isDisabled) {
|
|
return true;
|
|
}
|
|
if (!hook.supportsFiber) {
|
|
{
|
|
error("The installed version of React DevTools is too old and will not work with the current version of React. Please update React DevTools. https://reactjs.org/link/react-devtools");
|
|
}
|
|
return true;
|
|
}
|
|
try {
|
|
rendererID = hook.inject(internals);
|
|
injectedHook = hook;
|
|
} catch (err) {
|
|
{
|
|
error("React instrumentation encountered an error: %s.", err);
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
function onScheduleRoot(root2, children) {
|
|
{
|
|
if (injectedHook && typeof injectedHook.onScheduleFiberRoot === "function") {
|
|
try {
|
|
injectedHook.onScheduleFiberRoot(rendererID, root2, children);
|
|
} catch (err) {
|
|
if (!hasLoggedError) {
|
|
hasLoggedError = true;
|
|
error("React instrumentation encountered an error: %s", err);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
function onCommitRoot(root2, priorityLevel) {
|
|
if (injectedHook && typeof injectedHook.onCommitFiberRoot === "function") {
|
|
try {
|
|
var didError = (root2.current.flags & DidCapture) === DidCapture;
|
|
if (enableProfilerTimer) {
|
|
injectedHook.onCommitFiberRoot(rendererID, root2, priorityLevel, didError);
|
|
} else {
|
|
injectedHook.onCommitFiberRoot(rendererID, root2, void 0, didError);
|
|
}
|
|
} catch (err) {
|
|
{
|
|
if (!hasLoggedError) {
|
|
hasLoggedError = true;
|
|
error("React instrumentation encountered an error: %s", err);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
function onCommitUnmount(fiber) {
|
|
if (injectedHook && typeof injectedHook.onCommitFiberUnmount === "function") {
|
|
try {
|
|
injectedHook.onCommitFiberUnmount(rendererID, fiber);
|
|
} catch (err) {
|
|
{
|
|
if (!hasLoggedError) {
|
|
hasLoggedError = true;
|
|
error("React instrumentation encountered an error: %s", err);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
var Scheduler_runWithPriority = Scheduler.unstable_runWithPriority, Scheduler_scheduleCallback = Scheduler.unstable_scheduleCallback, Scheduler_cancelCallback = Scheduler.unstable_cancelCallback, Scheduler_shouldYield = Scheduler.unstable_shouldYield, Scheduler_requestPaint = Scheduler.unstable_requestPaint, Scheduler_now$1 = Scheduler.unstable_now, Scheduler_getCurrentPriorityLevel = Scheduler.unstable_getCurrentPriorityLevel, Scheduler_ImmediatePriority = Scheduler.unstable_ImmediatePriority, Scheduler_UserBlockingPriority = Scheduler.unstable_UserBlockingPriority, Scheduler_NormalPriority = Scheduler.unstable_NormalPriority, Scheduler_LowPriority = Scheduler.unstable_LowPriority, Scheduler_IdlePriority = Scheduler.unstable_IdlePriority;
|
|
{
|
|
if (!(tracing.__interactionsRef != null && tracing.__interactionsRef.current != null)) {
|
|
{
|
|
throw Error("It is not supported to run the profiling version of a renderer (for example, `react-dom/profiling`) without also replacing the `scheduler/tracing` module with `scheduler/tracing-profiling`. Your bundler might have a setting for aliasing both modules. Learn more at https://reactjs.org/link/profiling");
|
|
}
|
|
}
|
|
}
|
|
var fakeCallbackNode = {};
|
|
var ImmediatePriority$1 = 99;
|
|
var UserBlockingPriority$2 = 98;
|
|
var NormalPriority$1 = 97;
|
|
var LowPriority$1 = 96;
|
|
var IdlePriority$1 = 95;
|
|
var NoPriority$1 = 90;
|
|
var shouldYield = Scheduler_shouldYield;
|
|
var requestPaint = Scheduler_requestPaint !== void 0 ? Scheduler_requestPaint : function() {
|
|
};
|
|
var syncQueue = null;
|
|
var immediateQueueCallbackNode = null;
|
|
var isFlushingSyncQueue = false;
|
|
var initialTimeMs$1 = Scheduler_now$1();
|
|
var now = initialTimeMs$1 < 1e4 ? Scheduler_now$1 : function() {
|
|
return Scheduler_now$1() - initialTimeMs$1;
|
|
};
|
|
function getCurrentPriorityLevel() {
|
|
switch (Scheduler_getCurrentPriorityLevel()) {
|
|
case Scheduler_ImmediatePriority:
|
|
return ImmediatePriority$1;
|
|
case Scheduler_UserBlockingPriority:
|
|
return UserBlockingPriority$2;
|
|
case Scheduler_NormalPriority:
|
|
return NormalPriority$1;
|
|
case Scheduler_LowPriority:
|
|
return LowPriority$1;
|
|
case Scheduler_IdlePriority:
|
|
return IdlePriority$1;
|
|
default: {
|
|
{
|
|
throw Error("Unknown priority level.");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
function reactPriorityToSchedulerPriority(reactPriorityLevel) {
|
|
switch (reactPriorityLevel) {
|
|
case ImmediatePriority$1:
|
|
return Scheduler_ImmediatePriority;
|
|
case UserBlockingPriority$2:
|
|
return Scheduler_UserBlockingPriority;
|
|
case NormalPriority$1:
|
|
return Scheduler_NormalPriority;
|
|
case LowPriority$1:
|
|
return Scheduler_LowPriority;
|
|
case IdlePriority$1:
|
|
return Scheduler_IdlePriority;
|
|
default: {
|
|
{
|
|
throw Error("Unknown priority level.");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
function runWithPriority$1(reactPriorityLevel, fn) {
|
|
var priorityLevel = reactPriorityToSchedulerPriority(reactPriorityLevel);
|
|
return Scheduler_runWithPriority(priorityLevel, fn);
|
|
}
|
|
function scheduleCallback(reactPriorityLevel, callback, options2) {
|
|
var priorityLevel = reactPriorityToSchedulerPriority(reactPriorityLevel);
|
|
return Scheduler_scheduleCallback(priorityLevel, callback, options2);
|
|
}
|
|
function scheduleSyncCallback(callback) {
|
|
if (syncQueue === null) {
|
|
syncQueue = [callback];
|
|
immediateQueueCallbackNode = Scheduler_scheduleCallback(Scheduler_ImmediatePriority, flushSyncCallbackQueueImpl);
|
|
} else {
|
|
syncQueue.push(callback);
|
|
}
|
|
return fakeCallbackNode;
|
|
}
|
|
function cancelCallback(callbackNode) {
|
|
if (callbackNode !== fakeCallbackNode) {
|
|
Scheduler_cancelCallback(callbackNode);
|
|
}
|
|
}
|
|
function flushSyncCallbackQueue() {
|
|
if (immediateQueueCallbackNode !== null) {
|
|
var node = immediateQueueCallbackNode;
|
|
immediateQueueCallbackNode = null;
|
|
Scheduler_cancelCallback(node);
|
|
}
|
|
flushSyncCallbackQueueImpl();
|
|
}
|
|
function flushSyncCallbackQueueImpl() {
|
|
if (!isFlushingSyncQueue && syncQueue !== null) {
|
|
isFlushingSyncQueue = true;
|
|
var i3 = 0;
|
|
{
|
|
try {
|
|
var _isSync2 = true;
|
|
var _queue = syncQueue;
|
|
runWithPriority$1(ImmediatePriority$1, function() {
|
|
for (; i3 < _queue.length; i3++) {
|
|
var callback = _queue[i3];
|
|
do {
|
|
callback = callback(_isSync2);
|
|
} while (callback !== null);
|
|
}
|
|
});
|
|
syncQueue = null;
|
|
} catch (error2) {
|
|
if (syncQueue !== null) {
|
|
syncQueue = syncQueue.slice(i3 + 1);
|
|
}
|
|
Scheduler_scheduleCallback(Scheduler_ImmediatePriority, flushSyncCallbackQueue);
|
|
throw error2;
|
|
} finally {
|
|
isFlushingSyncQueue = false;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
var ReactVersion = "17.0.2";
|
|
var NoMode = 0;
|
|
var StrictMode = 1;
|
|
var BlockingMode = 2;
|
|
var ConcurrentMode = 4;
|
|
var ProfileMode = 8;
|
|
var DebugTracingMode = 16;
|
|
var ReactCurrentBatchConfig = ReactSharedInternals.ReactCurrentBatchConfig;
|
|
var NoTransition = 0;
|
|
function requestCurrentTransition() {
|
|
return ReactCurrentBatchConfig.transition;
|
|
}
|
|
var ReactStrictModeWarnings = {
|
|
recordUnsafeLifecycleWarnings: function(fiber, instance) {
|
|
},
|
|
flushPendingUnsafeLifecycleWarnings: function() {
|
|
},
|
|
recordLegacyContextWarning: function(fiber, instance) {
|
|
},
|
|
flushLegacyContextWarning: function() {
|
|
},
|
|
discardPendingWarnings: function() {
|
|
}
|
|
};
|
|
{
|
|
var findStrictRoot = function(fiber) {
|
|
var maybeStrictRoot = null;
|
|
var node = fiber;
|
|
while (node !== null) {
|
|
if (node.mode & StrictMode) {
|
|
maybeStrictRoot = node;
|
|
}
|
|
node = node.return;
|
|
}
|
|
return maybeStrictRoot;
|
|
};
|
|
var setToSortedString = function(set2) {
|
|
var array = [];
|
|
set2.forEach(function(value) {
|
|
array.push(value);
|
|
});
|
|
return array.sort().join(", ");
|
|
};
|
|
var pendingComponentWillMountWarnings = [];
|
|
var pendingUNSAFE_ComponentWillMountWarnings = [];
|
|
var pendingComponentWillReceivePropsWarnings = [];
|
|
var pendingUNSAFE_ComponentWillReceivePropsWarnings = [];
|
|
var pendingComponentWillUpdateWarnings = [];
|
|
var pendingUNSAFE_ComponentWillUpdateWarnings = [];
|
|
var didWarnAboutUnsafeLifecycles = new Set();
|
|
ReactStrictModeWarnings.recordUnsafeLifecycleWarnings = function(fiber, instance) {
|
|
if (didWarnAboutUnsafeLifecycles.has(fiber.type)) {
|
|
return;
|
|
}
|
|
if (typeof instance.componentWillMount === "function" && instance.componentWillMount.__suppressDeprecationWarning !== true) {
|
|
pendingComponentWillMountWarnings.push(fiber);
|
|
}
|
|
if (fiber.mode & StrictMode && typeof instance.UNSAFE_componentWillMount === "function") {
|
|
pendingUNSAFE_ComponentWillMountWarnings.push(fiber);
|
|
}
|
|
if (typeof instance.componentWillReceiveProps === "function" && instance.componentWillReceiveProps.__suppressDeprecationWarning !== true) {
|
|
pendingComponentWillReceivePropsWarnings.push(fiber);
|
|
}
|
|
if (fiber.mode & StrictMode && typeof instance.UNSAFE_componentWillReceiveProps === "function") {
|
|
pendingUNSAFE_ComponentWillReceivePropsWarnings.push(fiber);
|
|
}
|
|
if (typeof instance.componentWillUpdate === "function" && instance.componentWillUpdate.__suppressDeprecationWarning !== true) {
|
|
pendingComponentWillUpdateWarnings.push(fiber);
|
|
}
|
|
if (fiber.mode & StrictMode && typeof instance.UNSAFE_componentWillUpdate === "function") {
|
|
pendingUNSAFE_ComponentWillUpdateWarnings.push(fiber);
|
|
}
|
|
};
|
|
ReactStrictModeWarnings.flushPendingUnsafeLifecycleWarnings = function() {
|
|
var componentWillMountUniqueNames = new Set();
|
|
if (pendingComponentWillMountWarnings.length > 0) {
|
|
pendingComponentWillMountWarnings.forEach(function(fiber) {
|
|
componentWillMountUniqueNames.add(getComponentName(fiber.type) || "Component");
|
|
didWarnAboutUnsafeLifecycles.add(fiber.type);
|
|
});
|
|
pendingComponentWillMountWarnings = [];
|
|
}
|
|
var UNSAFE_componentWillMountUniqueNames = new Set();
|
|
if (pendingUNSAFE_ComponentWillMountWarnings.length > 0) {
|
|
pendingUNSAFE_ComponentWillMountWarnings.forEach(function(fiber) {
|
|
UNSAFE_componentWillMountUniqueNames.add(getComponentName(fiber.type) || "Component");
|
|
didWarnAboutUnsafeLifecycles.add(fiber.type);
|
|
});
|
|
pendingUNSAFE_ComponentWillMountWarnings = [];
|
|
}
|
|
var componentWillReceivePropsUniqueNames = new Set();
|
|
if (pendingComponentWillReceivePropsWarnings.length > 0) {
|
|
pendingComponentWillReceivePropsWarnings.forEach(function(fiber) {
|
|
componentWillReceivePropsUniqueNames.add(getComponentName(fiber.type) || "Component");
|
|
didWarnAboutUnsafeLifecycles.add(fiber.type);
|
|
});
|
|
pendingComponentWillReceivePropsWarnings = [];
|
|
}
|
|
var UNSAFE_componentWillReceivePropsUniqueNames = new Set();
|
|
if (pendingUNSAFE_ComponentWillReceivePropsWarnings.length > 0) {
|
|
pendingUNSAFE_ComponentWillReceivePropsWarnings.forEach(function(fiber) {
|
|
UNSAFE_componentWillReceivePropsUniqueNames.add(getComponentName(fiber.type) || "Component");
|
|
didWarnAboutUnsafeLifecycles.add(fiber.type);
|
|
});
|
|
pendingUNSAFE_ComponentWillReceivePropsWarnings = [];
|
|
}
|
|
var componentWillUpdateUniqueNames = new Set();
|
|
if (pendingComponentWillUpdateWarnings.length > 0) {
|
|
pendingComponentWillUpdateWarnings.forEach(function(fiber) {
|
|
componentWillUpdateUniqueNames.add(getComponentName(fiber.type) || "Component");
|
|
didWarnAboutUnsafeLifecycles.add(fiber.type);
|
|
});
|
|
pendingComponentWillUpdateWarnings = [];
|
|
}
|
|
var UNSAFE_componentWillUpdateUniqueNames = new Set();
|
|
if (pendingUNSAFE_ComponentWillUpdateWarnings.length > 0) {
|
|
pendingUNSAFE_ComponentWillUpdateWarnings.forEach(function(fiber) {
|
|
UNSAFE_componentWillUpdateUniqueNames.add(getComponentName(fiber.type) || "Component");
|
|
didWarnAboutUnsafeLifecycles.add(fiber.type);
|
|
});
|
|
pendingUNSAFE_ComponentWillUpdateWarnings = [];
|
|
}
|
|
if (UNSAFE_componentWillMountUniqueNames.size > 0) {
|
|
var sortedNames = setToSortedString(UNSAFE_componentWillMountUniqueNames);
|
|
error("Using UNSAFE_componentWillMount in strict mode is not recommended and may indicate bugs in your code. See https://reactjs.org/link/unsafe-component-lifecycles for details.\n\n* Move code with side effects to componentDidMount, and set initial state in the constructor.\n\nPlease update the following components: %s", sortedNames);
|
|
}
|
|
if (UNSAFE_componentWillReceivePropsUniqueNames.size > 0) {
|
|
var _sortedNames = setToSortedString(UNSAFE_componentWillReceivePropsUniqueNames);
|
|
error("Using UNSAFE_componentWillReceiveProps in strict mode is not recommended and may indicate bugs in your code. See https://reactjs.org/link/unsafe-component-lifecycles for details.\n\n* Move data fetching code or side effects to componentDidUpdate.\n* If you're updating state whenever props change, refactor your code to use memoization techniques or move it to static getDerivedStateFromProps. Learn more at: https://reactjs.org/link/derived-state\n\nPlease update the following components: %s", _sortedNames);
|
|
}
|
|
if (UNSAFE_componentWillUpdateUniqueNames.size > 0) {
|
|
var _sortedNames2 = setToSortedString(UNSAFE_componentWillUpdateUniqueNames);
|
|
error("Using UNSAFE_componentWillUpdate in strict mode is not recommended and may indicate bugs in your code. See https://reactjs.org/link/unsafe-component-lifecycles for details.\n\n* Move data fetching code or side effects to componentDidUpdate.\n\nPlease update the following components: %s", _sortedNames2);
|
|
}
|
|
if (componentWillMountUniqueNames.size > 0) {
|
|
var _sortedNames3 = setToSortedString(componentWillMountUniqueNames);
|
|
warn("componentWillMount has been renamed, and is not recommended for use. See https://reactjs.org/link/unsafe-component-lifecycles for details.\n\n* Move code with side effects to componentDidMount, and set initial state in the constructor.\n* Rename componentWillMount to UNSAFE_componentWillMount to suppress this warning in non-strict mode. In React 18.x, only the UNSAFE_ name will work. To rename all deprecated lifecycles to their new names, you can run `npx react-codemod rename-unsafe-lifecycles` in your project source folder.\n\nPlease update the following components: %s", _sortedNames3);
|
|
}
|
|
if (componentWillReceivePropsUniqueNames.size > 0) {
|
|
var _sortedNames4 = setToSortedString(componentWillReceivePropsUniqueNames);
|
|
warn("componentWillReceiveProps has been renamed, and is not recommended for use. See https://reactjs.org/link/unsafe-component-lifecycles for details.\n\n* Move data fetching code or side effects to componentDidUpdate.\n* If you're updating state whenever props change, refactor your code to use memoization techniques or move it to static getDerivedStateFromProps. Learn more at: https://reactjs.org/link/derived-state\n* Rename componentWillReceiveProps to UNSAFE_componentWillReceiveProps to suppress this warning in non-strict mode. In React 18.x, only the UNSAFE_ name will work. To rename all deprecated lifecycles to their new names, you can run `npx react-codemod rename-unsafe-lifecycles` in your project source folder.\n\nPlease update the following components: %s", _sortedNames4);
|
|
}
|
|
if (componentWillUpdateUniqueNames.size > 0) {
|
|
var _sortedNames5 = setToSortedString(componentWillUpdateUniqueNames);
|
|
warn("componentWillUpdate has been renamed, and is not recommended for use. See https://reactjs.org/link/unsafe-component-lifecycles for details.\n\n* Move data fetching code or side effects to componentDidUpdate.\n* Rename componentWillUpdate to UNSAFE_componentWillUpdate to suppress this warning in non-strict mode. In React 18.x, only the UNSAFE_ name will work. To rename all deprecated lifecycles to their new names, you can run `npx react-codemod rename-unsafe-lifecycles` in your project source folder.\n\nPlease update the following components: %s", _sortedNames5);
|
|
}
|
|
};
|
|
var pendingLegacyContextWarning = new Map();
|
|
var didWarnAboutLegacyContext = new Set();
|
|
ReactStrictModeWarnings.recordLegacyContextWarning = function(fiber, instance) {
|
|
var strictRoot = findStrictRoot(fiber);
|
|
if (strictRoot === null) {
|
|
error("Expected to find a StrictMode component in a strict mode tree. This error is likely caused by a bug in React. Please file an issue.");
|
|
return;
|
|
}
|
|
if (didWarnAboutLegacyContext.has(fiber.type)) {
|
|
return;
|
|
}
|
|
var warningsForRoot = pendingLegacyContextWarning.get(strictRoot);
|
|
if (fiber.type.contextTypes != null || fiber.type.childContextTypes != null || instance !== null && typeof instance.getChildContext === "function") {
|
|
if (warningsForRoot === void 0) {
|
|
warningsForRoot = [];
|
|
pendingLegacyContextWarning.set(strictRoot, warningsForRoot);
|
|
}
|
|
warningsForRoot.push(fiber);
|
|
}
|
|
};
|
|
ReactStrictModeWarnings.flushLegacyContextWarning = function() {
|
|
pendingLegacyContextWarning.forEach(function(fiberArray, strictRoot) {
|
|
if (fiberArray.length === 0) {
|
|
return;
|
|
}
|
|
var firstFiber = fiberArray[0];
|
|
var uniqueNames = new Set();
|
|
fiberArray.forEach(function(fiber) {
|
|
uniqueNames.add(getComponentName(fiber.type) || "Component");
|
|
didWarnAboutLegacyContext.add(fiber.type);
|
|
});
|
|
var sortedNames = setToSortedString(uniqueNames);
|
|
try {
|
|
setCurrentFiber(firstFiber);
|
|
error("Legacy context API has been detected within a strict-mode tree.\n\nThe old API will be supported in all 16.x releases, but applications using it should migrate to the new version.\n\nPlease update the following components: %s\n\nLearn more about this warning here: https://reactjs.org/link/legacy-context", sortedNames);
|
|
} finally {
|
|
resetCurrentFiber();
|
|
}
|
|
});
|
|
};
|
|
ReactStrictModeWarnings.discardPendingWarnings = function() {
|
|
pendingComponentWillMountWarnings = [];
|
|
pendingUNSAFE_ComponentWillMountWarnings = [];
|
|
pendingComponentWillReceivePropsWarnings = [];
|
|
pendingUNSAFE_ComponentWillReceivePropsWarnings = [];
|
|
pendingComponentWillUpdateWarnings = [];
|
|
pendingUNSAFE_ComponentWillUpdateWarnings = [];
|
|
pendingLegacyContextWarning = new Map();
|
|
};
|
|
}
|
|
function resolveDefaultProps(Component5, baseProps) {
|
|
if (Component5 && Component5.defaultProps) {
|
|
var props = _assign({}, baseProps);
|
|
var defaultProps = Component5.defaultProps;
|
|
for (var propName in defaultProps) {
|
|
if (props[propName] === void 0) {
|
|
props[propName] = defaultProps[propName];
|
|
}
|
|
}
|
|
return props;
|
|
}
|
|
return baseProps;
|
|
}
|
|
var MAX_SIGNED_31_BIT_INT = 1073741823;
|
|
var valueCursor = createCursor(null);
|
|
var rendererSigil;
|
|
{
|
|
rendererSigil = {};
|
|
}
|
|
var currentlyRenderingFiber = null;
|
|
var lastContextDependency = null;
|
|
var lastContextWithAllBitsObserved = null;
|
|
var isDisallowedContextReadInDEV = false;
|
|
function resetContextDependencies() {
|
|
currentlyRenderingFiber = null;
|
|
lastContextDependency = null;
|
|
lastContextWithAllBitsObserved = null;
|
|
{
|
|
isDisallowedContextReadInDEV = false;
|
|
}
|
|
}
|
|
function enterDisallowedContextReadInDEV() {
|
|
{
|
|
isDisallowedContextReadInDEV = true;
|
|
}
|
|
}
|
|
function exitDisallowedContextReadInDEV() {
|
|
{
|
|
isDisallowedContextReadInDEV = false;
|
|
}
|
|
}
|
|
function pushProvider(providerFiber, nextValue) {
|
|
var context = providerFiber.type._context;
|
|
{
|
|
push(valueCursor, context._currentValue, providerFiber);
|
|
context._currentValue = nextValue;
|
|
{
|
|
if (context._currentRenderer !== void 0 && context._currentRenderer !== null && context._currentRenderer !== rendererSigil) {
|
|
error("Detected multiple renderers concurrently rendering the same context provider. This is currently unsupported.");
|
|
}
|
|
context._currentRenderer = rendererSigil;
|
|
}
|
|
}
|
|
}
|
|
function popProvider(providerFiber) {
|
|
var currentValue = valueCursor.current;
|
|
pop(valueCursor, providerFiber);
|
|
var context = providerFiber.type._context;
|
|
{
|
|
context._currentValue = currentValue;
|
|
}
|
|
}
|
|
function calculateChangedBits(context, newValue, oldValue) {
|
|
if (objectIs(oldValue, newValue)) {
|
|
return 0;
|
|
} else {
|
|
var changedBits = typeof context._calculateChangedBits === "function" ? context._calculateChangedBits(oldValue, newValue) : MAX_SIGNED_31_BIT_INT;
|
|
{
|
|
if ((changedBits & MAX_SIGNED_31_BIT_INT) !== changedBits) {
|
|
error("calculateChangedBits: Expected the return value to be a 31-bit integer. Instead received: %s", changedBits);
|
|
}
|
|
}
|
|
return changedBits | 0;
|
|
}
|
|
}
|
|
function scheduleWorkOnParentPath(parent, renderLanes2) {
|
|
var node = parent;
|
|
while (node !== null) {
|
|
var alternate = node.alternate;
|
|
if (!isSubsetOfLanes(node.childLanes, renderLanes2)) {
|
|
node.childLanes = mergeLanes(node.childLanes, renderLanes2);
|
|
if (alternate !== null) {
|
|
alternate.childLanes = mergeLanes(alternate.childLanes, renderLanes2);
|
|
}
|
|
} else if (alternate !== null && !isSubsetOfLanes(alternate.childLanes, renderLanes2)) {
|
|
alternate.childLanes = mergeLanes(alternate.childLanes, renderLanes2);
|
|
} else {
|
|
break;
|
|
}
|
|
node = node.return;
|
|
}
|
|
}
|
|
function propagateContextChange(workInProgress2, context, changedBits, renderLanes2) {
|
|
var fiber = workInProgress2.child;
|
|
if (fiber !== null) {
|
|
fiber.return = workInProgress2;
|
|
}
|
|
while (fiber !== null) {
|
|
var nextFiber = void 0;
|
|
var list = fiber.dependencies;
|
|
if (list !== null) {
|
|
nextFiber = fiber.child;
|
|
var dependency = list.firstContext;
|
|
while (dependency !== null) {
|
|
if (dependency.context === context && (dependency.observedBits & changedBits) !== 0) {
|
|
if (fiber.tag === ClassComponent) {
|
|
var update = createUpdate(NoTimestamp, pickArbitraryLane(renderLanes2));
|
|
update.tag = ForceUpdate;
|
|
enqueueUpdate(fiber, update);
|
|
}
|
|
fiber.lanes = mergeLanes(fiber.lanes, renderLanes2);
|
|
var alternate = fiber.alternate;
|
|
if (alternate !== null) {
|
|
alternate.lanes = mergeLanes(alternate.lanes, renderLanes2);
|
|
}
|
|
scheduleWorkOnParentPath(fiber.return, renderLanes2);
|
|
list.lanes = mergeLanes(list.lanes, renderLanes2);
|
|
break;
|
|
}
|
|
dependency = dependency.next;
|
|
}
|
|
} else if (fiber.tag === ContextProvider) {
|
|
nextFiber = fiber.type === workInProgress2.type ? null : fiber.child;
|
|
} else {
|
|
nextFiber = fiber.child;
|
|
}
|
|
if (nextFiber !== null) {
|
|
nextFiber.return = fiber;
|
|
} else {
|
|
nextFiber = fiber;
|
|
while (nextFiber !== null) {
|
|
if (nextFiber === workInProgress2) {
|
|
nextFiber = null;
|
|
break;
|
|
}
|
|
var sibling = nextFiber.sibling;
|
|
if (sibling !== null) {
|
|
sibling.return = nextFiber.return;
|
|
nextFiber = sibling;
|
|
break;
|
|
}
|
|
nextFiber = nextFiber.return;
|
|
}
|
|
}
|
|
fiber = nextFiber;
|
|
}
|
|
}
|
|
function prepareToReadContext(workInProgress2, renderLanes2) {
|
|
currentlyRenderingFiber = workInProgress2;
|
|
lastContextDependency = null;
|
|
lastContextWithAllBitsObserved = null;
|
|
var dependencies = workInProgress2.dependencies;
|
|
if (dependencies !== null) {
|
|
var firstContext = dependencies.firstContext;
|
|
if (firstContext !== null) {
|
|
if (includesSomeLane(dependencies.lanes, renderLanes2)) {
|
|
markWorkInProgressReceivedUpdate();
|
|
}
|
|
dependencies.firstContext = null;
|
|
}
|
|
}
|
|
}
|
|
function readContext(context, observedBits) {
|
|
{
|
|
if (isDisallowedContextReadInDEV) {
|
|
error("Context can only be read while React is rendering. In classes, you can read it in the render method or getDerivedStateFromProps. In function components, you can read it directly in the function body, but not inside Hooks like useReducer() or useMemo().");
|
|
}
|
|
}
|
|
if (lastContextWithAllBitsObserved === context)
|
|
;
|
|
else if (observedBits === false || observedBits === 0)
|
|
;
|
|
else {
|
|
var resolvedObservedBits;
|
|
if (typeof observedBits !== "number" || observedBits === MAX_SIGNED_31_BIT_INT) {
|
|
lastContextWithAllBitsObserved = context;
|
|
resolvedObservedBits = MAX_SIGNED_31_BIT_INT;
|
|
} else {
|
|
resolvedObservedBits = observedBits;
|
|
}
|
|
var contextItem = {
|
|
context,
|
|
observedBits: resolvedObservedBits,
|
|
next: null
|
|
};
|
|
if (lastContextDependency === null) {
|
|
if (!(currentlyRenderingFiber !== null)) {
|
|
{
|
|
throw Error("Context can only be read while React is rendering. In classes, you can read it in the render method or getDerivedStateFromProps. In function components, you can read it directly in the function body, but not inside Hooks like useReducer() or useMemo().");
|
|
}
|
|
}
|
|
lastContextDependency = contextItem;
|
|
currentlyRenderingFiber.dependencies = {
|
|
lanes: NoLanes,
|
|
firstContext: contextItem,
|
|
responders: null
|
|
};
|
|
} else {
|
|
lastContextDependency = lastContextDependency.next = contextItem;
|
|
}
|
|
}
|
|
return context._currentValue;
|
|
}
|
|
var UpdateState = 0;
|
|
var ReplaceState = 1;
|
|
var ForceUpdate = 2;
|
|
var CaptureUpdate = 3;
|
|
var hasForceUpdate = false;
|
|
var didWarnUpdateInsideUpdate;
|
|
var currentlyProcessingQueue;
|
|
{
|
|
didWarnUpdateInsideUpdate = false;
|
|
currentlyProcessingQueue = null;
|
|
}
|
|
function initializeUpdateQueue(fiber) {
|
|
var queue = {
|
|
baseState: fiber.memoizedState,
|
|
firstBaseUpdate: null,
|
|
lastBaseUpdate: null,
|
|
shared: {
|
|
pending: null
|
|
},
|
|
effects: null
|
|
};
|
|
fiber.updateQueue = queue;
|
|
}
|
|
function cloneUpdateQueue(current2, workInProgress2) {
|
|
var queue = workInProgress2.updateQueue;
|
|
var currentQueue = current2.updateQueue;
|
|
if (queue === currentQueue) {
|
|
var clone = {
|
|
baseState: currentQueue.baseState,
|
|
firstBaseUpdate: currentQueue.firstBaseUpdate,
|
|
lastBaseUpdate: currentQueue.lastBaseUpdate,
|
|
shared: currentQueue.shared,
|
|
effects: currentQueue.effects
|
|
};
|
|
workInProgress2.updateQueue = clone;
|
|
}
|
|
}
|
|
function createUpdate(eventTime, lane) {
|
|
var update = {
|
|
eventTime,
|
|
lane,
|
|
tag: UpdateState,
|
|
payload: null,
|
|
callback: null,
|
|
next: null
|
|
};
|
|
return update;
|
|
}
|
|
function enqueueUpdate(fiber, update) {
|
|
var updateQueue = fiber.updateQueue;
|
|
if (updateQueue === null) {
|
|
return;
|
|
}
|
|
var sharedQueue = updateQueue.shared;
|
|
var pending = sharedQueue.pending;
|
|
if (pending === null) {
|
|
update.next = update;
|
|
} else {
|
|
update.next = pending.next;
|
|
pending.next = update;
|
|
}
|
|
sharedQueue.pending = update;
|
|
{
|
|
if (currentlyProcessingQueue === sharedQueue && !didWarnUpdateInsideUpdate) {
|
|
error("An update (setState, replaceState, or forceUpdate) was scheduled from inside an update function. Update functions should be pure, with zero side-effects. Consider using componentDidUpdate or a callback.");
|
|
didWarnUpdateInsideUpdate = true;
|
|
}
|
|
}
|
|
}
|
|
function enqueueCapturedUpdate(workInProgress2, capturedUpdate) {
|
|
var queue = workInProgress2.updateQueue;
|
|
var current2 = workInProgress2.alternate;
|
|
if (current2 !== null) {
|
|
var currentQueue = current2.updateQueue;
|
|
if (queue === currentQueue) {
|
|
var newFirst = null;
|
|
var newLast = null;
|
|
var firstBaseUpdate = queue.firstBaseUpdate;
|
|
if (firstBaseUpdate !== null) {
|
|
var update = firstBaseUpdate;
|
|
do {
|
|
var clone = {
|
|
eventTime: update.eventTime,
|
|
lane: update.lane,
|
|
tag: update.tag,
|
|
payload: update.payload,
|
|
callback: update.callback,
|
|
next: null
|
|
};
|
|
if (newLast === null) {
|
|
newFirst = newLast = clone;
|
|
} else {
|
|
newLast.next = clone;
|
|
newLast = clone;
|
|
}
|
|
update = update.next;
|
|
} while (update !== null);
|
|
if (newLast === null) {
|
|
newFirst = newLast = capturedUpdate;
|
|
} else {
|
|
newLast.next = capturedUpdate;
|
|
newLast = capturedUpdate;
|
|
}
|
|
} else {
|
|
newFirst = newLast = capturedUpdate;
|
|
}
|
|
queue = {
|
|
baseState: currentQueue.baseState,
|
|
firstBaseUpdate: newFirst,
|
|
lastBaseUpdate: newLast,
|
|
shared: currentQueue.shared,
|
|
effects: currentQueue.effects
|
|
};
|
|
workInProgress2.updateQueue = queue;
|
|
return;
|
|
}
|
|
}
|
|
var lastBaseUpdate = queue.lastBaseUpdate;
|
|
if (lastBaseUpdate === null) {
|
|
queue.firstBaseUpdate = capturedUpdate;
|
|
} else {
|
|
lastBaseUpdate.next = capturedUpdate;
|
|
}
|
|
queue.lastBaseUpdate = capturedUpdate;
|
|
}
|
|
function getStateFromUpdate(workInProgress2, queue, update, prevState, nextProps, instance) {
|
|
switch (update.tag) {
|
|
case ReplaceState: {
|
|
var payload = update.payload;
|
|
if (typeof payload === "function") {
|
|
{
|
|
enterDisallowedContextReadInDEV();
|
|
}
|
|
var nextState = payload.call(instance, prevState, nextProps);
|
|
{
|
|
if (workInProgress2.mode & StrictMode) {
|
|
disableLogs();
|
|
try {
|
|
payload.call(instance, prevState, nextProps);
|
|
} finally {
|
|
reenableLogs();
|
|
}
|
|
}
|
|
exitDisallowedContextReadInDEV();
|
|
}
|
|
return nextState;
|
|
}
|
|
return payload;
|
|
}
|
|
case CaptureUpdate: {
|
|
workInProgress2.flags = workInProgress2.flags & ~ShouldCapture | DidCapture;
|
|
}
|
|
case UpdateState: {
|
|
var _payload = update.payload;
|
|
var partialState;
|
|
if (typeof _payload === "function") {
|
|
{
|
|
enterDisallowedContextReadInDEV();
|
|
}
|
|
partialState = _payload.call(instance, prevState, nextProps);
|
|
{
|
|
if (workInProgress2.mode & StrictMode) {
|
|
disableLogs();
|
|
try {
|
|
_payload.call(instance, prevState, nextProps);
|
|
} finally {
|
|
reenableLogs();
|
|
}
|
|
}
|
|
exitDisallowedContextReadInDEV();
|
|
}
|
|
} else {
|
|
partialState = _payload;
|
|
}
|
|
if (partialState === null || partialState === void 0) {
|
|
return prevState;
|
|
}
|
|
return _assign({}, prevState, partialState);
|
|
}
|
|
case ForceUpdate: {
|
|
hasForceUpdate = true;
|
|
return prevState;
|
|
}
|
|
}
|
|
return prevState;
|
|
}
|
|
function processUpdateQueue(workInProgress2, props, instance, renderLanes2) {
|
|
var queue = workInProgress2.updateQueue;
|
|
hasForceUpdate = false;
|
|
{
|
|
currentlyProcessingQueue = queue.shared;
|
|
}
|
|
var firstBaseUpdate = queue.firstBaseUpdate;
|
|
var lastBaseUpdate = queue.lastBaseUpdate;
|
|
var pendingQueue = queue.shared.pending;
|
|
if (pendingQueue !== null) {
|
|
queue.shared.pending = null;
|
|
var lastPendingUpdate = pendingQueue;
|
|
var firstPendingUpdate = lastPendingUpdate.next;
|
|
lastPendingUpdate.next = null;
|
|
if (lastBaseUpdate === null) {
|
|
firstBaseUpdate = firstPendingUpdate;
|
|
} else {
|
|
lastBaseUpdate.next = firstPendingUpdate;
|
|
}
|
|
lastBaseUpdate = lastPendingUpdate;
|
|
var current2 = workInProgress2.alternate;
|
|
if (current2 !== null) {
|
|
var currentQueue = current2.updateQueue;
|
|
var currentLastBaseUpdate = currentQueue.lastBaseUpdate;
|
|
if (currentLastBaseUpdate !== lastBaseUpdate) {
|
|
if (currentLastBaseUpdate === null) {
|
|
currentQueue.firstBaseUpdate = firstPendingUpdate;
|
|
} else {
|
|
currentLastBaseUpdate.next = firstPendingUpdate;
|
|
}
|
|
currentQueue.lastBaseUpdate = lastPendingUpdate;
|
|
}
|
|
}
|
|
}
|
|
if (firstBaseUpdate !== null) {
|
|
var newState = queue.baseState;
|
|
var newLanes = NoLanes;
|
|
var newBaseState = null;
|
|
var newFirstBaseUpdate = null;
|
|
var newLastBaseUpdate = null;
|
|
var update = firstBaseUpdate;
|
|
do {
|
|
var updateLane = update.lane;
|
|
var updateEventTime = update.eventTime;
|
|
if (!isSubsetOfLanes(renderLanes2, updateLane)) {
|
|
var clone = {
|
|
eventTime: updateEventTime,
|
|
lane: updateLane,
|
|
tag: update.tag,
|
|
payload: update.payload,
|
|
callback: update.callback,
|
|
next: null
|
|
};
|
|
if (newLastBaseUpdate === null) {
|
|
newFirstBaseUpdate = newLastBaseUpdate = clone;
|
|
newBaseState = newState;
|
|
} else {
|
|
newLastBaseUpdate = newLastBaseUpdate.next = clone;
|
|
}
|
|
newLanes = mergeLanes(newLanes, updateLane);
|
|
} else {
|
|
if (newLastBaseUpdate !== null) {
|
|
var _clone = {
|
|
eventTime: updateEventTime,
|
|
lane: NoLane,
|
|
tag: update.tag,
|
|
payload: update.payload,
|
|
callback: update.callback,
|
|
next: null
|
|
};
|
|
newLastBaseUpdate = newLastBaseUpdate.next = _clone;
|
|
}
|
|
newState = getStateFromUpdate(workInProgress2, queue, update, newState, props, instance);
|
|
var callback = update.callback;
|
|
if (callback !== null) {
|
|
workInProgress2.flags |= Callback;
|
|
var effects = queue.effects;
|
|
if (effects === null) {
|
|
queue.effects = [update];
|
|
} else {
|
|
effects.push(update);
|
|
}
|
|
}
|
|
}
|
|
update = update.next;
|
|
if (update === null) {
|
|
pendingQueue = queue.shared.pending;
|
|
if (pendingQueue === null) {
|
|
break;
|
|
} else {
|
|
var _lastPendingUpdate = pendingQueue;
|
|
var _firstPendingUpdate = _lastPendingUpdate.next;
|
|
_lastPendingUpdate.next = null;
|
|
update = _firstPendingUpdate;
|
|
queue.lastBaseUpdate = _lastPendingUpdate;
|
|
queue.shared.pending = null;
|
|
}
|
|
}
|
|
} while (true);
|
|
if (newLastBaseUpdate === null) {
|
|
newBaseState = newState;
|
|
}
|
|
queue.baseState = newBaseState;
|
|
queue.firstBaseUpdate = newFirstBaseUpdate;
|
|
queue.lastBaseUpdate = newLastBaseUpdate;
|
|
markSkippedUpdateLanes(newLanes);
|
|
workInProgress2.lanes = newLanes;
|
|
workInProgress2.memoizedState = newState;
|
|
}
|
|
{
|
|
currentlyProcessingQueue = null;
|
|
}
|
|
}
|
|
function callCallback(callback, context) {
|
|
if (!(typeof callback === "function")) {
|
|
{
|
|
throw Error("Invalid argument passed as callback. Expected a function. Instead received: " + callback);
|
|
}
|
|
}
|
|
callback.call(context);
|
|
}
|
|
function resetHasForceUpdateBeforeProcessing() {
|
|
hasForceUpdate = false;
|
|
}
|
|
function checkHasForceUpdateAfterProcessing() {
|
|
return hasForceUpdate;
|
|
}
|
|
function commitUpdateQueue(finishedWork, finishedQueue, instance) {
|
|
var effects = finishedQueue.effects;
|
|
finishedQueue.effects = null;
|
|
if (effects !== null) {
|
|
for (var i3 = 0; i3 < effects.length; i3++) {
|
|
var effect = effects[i3];
|
|
var callback = effect.callback;
|
|
if (callback !== null) {
|
|
effect.callback = null;
|
|
callCallback(callback, instance);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
var fakeInternalInstance = {};
|
|
var isArray = Array.isArray;
|
|
var emptyRefsObject = new React5.Component().refs;
|
|
var didWarnAboutStateAssignmentForComponent;
|
|
var didWarnAboutUninitializedState;
|
|
var didWarnAboutGetSnapshotBeforeUpdateWithoutDidUpdate;
|
|
var didWarnAboutLegacyLifecyclesAndDerivedState;
|
|
var didWarnAboutUndefinedDerivedState;
|
|
var warnOnUndefinedDerivedState;
|
|
var warnOnInvalidCallback;
|
|
var didWarnAboutDirectlyAssigningPropsToState;
|
|
var didWarnAboutContextTypeAndContextTypes;
|
|
var didWarnAboutInvalidateContextType;
|
|
{
|
|
didWarnAboutStateAssignmentForComponent = new Set();
|
|
didWarnAboutUninitializedState = new Set();
|
|
didWarnAboutGetSnapshotBeforeUpdateWithoutDidUpdate = new Set();
|
|
didWarnAboutLegacyLifecyclesAndDerivedState = new Set();
|
|
didWarnAboutDirectlyAssigningPropsToState = new Set();
|
|
didWarnAboutUndefinedDerivedState = new Set();
|
|
didWarnAboutContextTypeAndContextTypes = new Set();
|
|
didWarnAboutInvalidateContextType = new Set();
|
|
var didWarnOnInvalidCallback = new Set();
|
|
warnOnInvalidCallback = function(callback, callerName) {
|
|
if (callback === null || typeof callback === "function") {
|
|
return;
|
|
}
|
|
var key = callerName + "_" + callback;
|
|
if (!didWarnOnInvalidCallback.has(key)) {
|
|
didWarnOnInvalidCallback.add(key);
|
|
error("%s(...): Expected the last optional `callback` argument to be a function. Instead received: %s.", callerName, callback);
|
|
}
|
|
};
|
|
warnOnUndefinedDerivedState = function(type, partialState) {
|
|
if (partialState === void 0) {
|
|
var componentName = getComponentName(type) || "Component";
|
|
if (!didWarnAboutUndefinedDerivedState.has(componentName)) {
|
|
didWarnAboutUndefinedDerivedState.add(componentName);
|
|
error("%s.getDerivedStateFromProps(): A valid state object (or null) must be returned. You have returned undefined.", componentName);
|
|
}
|
|
}
|
|
};
|
|
Object.defineProperty(fakeInternalInstance, "_processChildContext", {
|
|
enumerable: false,
|
|
value: function() {
|
|
{
|
|
{
|
|
throw Error("_processChildContext is not available in React 16+. This likely means you have multiple copies of React and are attempting to nest a React 15 tree inside a React 16 tree using unstable_renderSubtreeIntoContainer, which isn't supported. Try to make sure you have only one copy of React (and ideally, switch to ReactDOM.createPortal).");
|
|
}
|
|
}
|
|
}
|
|
});
|
|
Object.freeze(fakeInternalInstance);
|
|
}
|
|
function applyDerivedStateFromProps(workInProgress2, ctor, getDerivedStateFromProps, nextProps) {
|
|
var prevState = workInProgress2.memoizedState;
|
|
{
|
|
if (workInProgress2.mode & StrictMode) {
|
|
disableLogs();
|
|
try {
|
|
getDerivedStateFromProps(nextProps, prevState);
|
|
} finally {
|
|
reenableLogs();
|
|
}
|
|
}
|
|
}
|
|
var partialState = getDerivedStateFromProps(nextProps, prevState);
|
|
{
|
|
warnOnUndefinedDerivedState(ctor, partialState);
|
|
}
|
|
var memoizedState = partialState === null || partialState === void 0 ? prevState : _assign({}, prevState, partialState);
|
|
workInProgress2.memoizedState = memoizedState;
|
|
if (workInProgress2.lanes === NoLanes) {
|
|
var updateQueue = workInProgress2.updateQueue;
|
|
updateQueue.baseState = memoizedState;
|
|
}
|
|
}
|
|
var classComponentUpdater = {
|
|
isMounted,
|
|
enqueueSetState: function(inst, payload, callback) {
|
|
var fiber = get(inst);
|
|
var eventTime = requestEventTime();
|
|
var lane = requestUpdateLane(fiber);
|
|
var update = createUpdate(eventTime, lane);
|
|
update.payload = payload;
|
|
if (callback !== void 0 && callback !== null) {
|
|
{
|
|
warnOnInvalidCallback(callback, "setState");
|
|
}
|
|
update.callback = callback;
|
|
}
|
|
enqueueUpdate(fiber, update);
|
|
scheduleUpdateOnFiber(fiber, lane, eventTime);
|
|
},
|
|
enqueueReplaceState: function(inst, payload, callback) {
|
|
var fiber = get(inst);
|
|
var eventTime = requestEventTime();
|
|
var lane = requestUpdateLane(fiber);
|
|
var update = createUpdate(eventTime, lane);
|
|
update.tag = ReplaceState;
|
|
update.payload = payload;
|
|
if (callback !== void 0 && callback !== null) {
|
|
{
|
|
warnOnInvalidCallback(callback, "replaceState");
|
|
}
|
|
update.callback = callback;
|
|
}
|
|
enqueueUpdate(fiber, update);
|
|
scheduleUpdateOnFiber(fiber, lane, eventTime);
|
|
},
|
|
enqueueForceUpdate: function(inst, callback) {
|
|
var fiber = get(inst);
|
|
var eventTime = requestEventTime();
|
|
var lane = requestUpdateLane(fiber);
|
|
var update = createUpdate(eventTime, lane);
|
|
update.tag = ForceUpdate;
|
|
if (callback !== void 0 && callback !== null) {
|
|
{
|
|
warnOnInvalidCallback(callback, "forceUpdate");
|
|
}
|
|
update.callback = callback;
|
|
}
|
|
enqueueUpdate(fiber, update);
|
|
scheduleUpdateOnFiber(fiber, lane, eventTime);
|
|
}
|
|
};
|
|
function checkShouldComponentUpdate(workInProgress2, ctor, oldProps, newProps, oldState, newState, nextContext) {
|
|
var instance = workInProgress2.stateNode;
|
|
if (typeof instance.shouldComponentUpdate === "function") {
|
|
{
|
|
if (workInProgress2.mode & StrictMode) {
|
|
disableLogs();
|
|
try {
|
|
instance.shouldComponentUpdate(newProps, newState, nextContext);
|
|
} finally {
|
|
reenableLogs();
|
|
}
|
|
}
|
|
}
|
|
var shouldUpdate = instance.shouldComponentUpdate(newProps, newState, nextContext);
|
|
{
|
|
if (shouldUpdate === void 0) {
|
|
error("%s.shouldComponentUpdate(): Returned undefined instead of a boolean value. Make sure to return true or false.", getComponentName(ctor) || "Component");
|
|
}
|
|
}
|
|
return shouldUpdate;
|
|
}
|
|
if (ctor.prototype && ctor.prototype.isPureReactComponent) {
|
|
return !shallowEqual(oldProps, newProps) || !shallowEqual(oldState, newState);
|
|
}
|
|
return true;
|
|
}
|
|
function checkClassInstance(workInProgress2, ctor, newProps) {
|
|
var instance = workInProgress2.stateNode;
|
|
{
|
|
var name = getComponentName(ctor) || "Component";
|
|
var renderPresent = instance.render;
|
|
if (!renderPresent) {
|
|
if (ctor.prototype && typeof ctor.prototype.render === "function") {
|
|
error("%s(...): No `render` method found on the returned component instance: did you accidentally return an object from the constructor?", name);
|
|
} else {
|
|
error("%s(...): No `render` method found on the returned component instance: you may have forgotten to define `render`.", name);
|
|
}
|
|
}
|
|
if (instance.getInitialState && !instance.getInitialState.isReactClassApproved && !instance.state) {
|
|
error("getInitialState was defined on %s, a plain JavaScript class. This is only supported for classes created using React.createClass. Did you mean to define a state property instead?", name);
|
|
}
|
|
if (instance.getDefaultProps && !instance.getDefaultProps.isReactClassApproved) {
|
|
error("getDefaultProps was defined on %s, a plain JavaScript class. This is only supported for classes created using React.createClass. Use a static property to define defaultProps instead.", name);
|
|
}
|
|
if (instance.propTypes) {
|
|
error("propTypes was defined as an instance property on %s. Use a static property to define propTypes instead.", name);
|
|
}
|
|
if (instance.contextType) {
|
|
error("contextType was defined as an instance property on %s. Use a static property to define contextType instead.", name);
|
|
}
|
|
{
|
|
if (instance.contextTypes) {
|
|
error("contextTypes was defined as an instance property on %s. Use a static property to define contextTypes instead.", name);
|
|
}
|
|
if (ctor.contextType && ctor.contextTypes && !didWarnAboutContextTypeAndContextTypes.has(ctor)) {
|
|
didWarnAboutContextTypeAndContextTypes.add(ctor);
|
|
error("%s declares both contextTypes and contextType static properties. The legacy contextTypes property will be ignored.", name);
|
|
}
|
|
}
|
|
if (typeof instance.componentShouldUpdate === "function") {
|
|
error("%s has a method called componentShouldUpdate(). Did you mean shouldComponentUpdate()? The name is phrased as a question because the function is expected to return a value.", name);
|
|
}
|
|
if (ctor.prototype && ctor.prototype.isPureReactComponent && typeof instance.shouldComponentUpdate !== "undefined") {
|
|
error("%s has a method called shouldComponentUpdate(). shouldComponentUpdate should not be used when extending React.PureComponent. Please extend React.Component if shouldComponentUpdate is used.", getComponentName(ctor) || "A pure component");
|
|
}
|
|
if (typeof instance.componentDidUnmount === "function") {
|
|
error("%s has a method called componentDidUnmount(). But there is no such lifecycle method. Did you mean componentWillUnmount()?", name);
|
|
}
|
|
if (typeof instance.componentDidReceiveProps === "function") {
|
|
error("%s has a method called componentDidReceiveProps(). But there is no such lifecycle method. If you meant to update the state in response to changing props, use componentWillReceiveProps(). If you meant to fetch data or run side-effects or mutations after React has updated the UI, use componentDidUpdate().", name);
|
|
}
|
|
if (typeof instance.componentWillRecieveProps === "function") {
|
|
error("%s has a method called componentWillRecieveProps(). Did you mean componentWillReceiveProps()?", name);
|
|
}
|
|
if (typeof instance.UNSAFE_componentWillRecieveProps === "function") {
|
|
error("%s has a method called UNSAFE_componentWillRecieveProps(). Did you mean UNSAFE_componentWillReceiveProps()?", name);
|
|
}
|
|
var hasMutatedProps = instance.props !== newProps;
|
|
if (instance.props !== void 0 && hasMutatedProps) {
|
|
error("%s(...): When calling super() in `%s`, make sure to pass up the same props that your component's constructor was passed.", name, name);
|
|
}
|
|
if (instance.defaultProps) {
|
|
error("Setting defaultProps as an instance property on %s is not supported and will be ignored. Instead, define defaultProps as a static property on %s.", name, name);
|
|
}
|
|
if (typeof instance.getSnapshotBeforeUpdate === "function" && typeof instance.componentDidUpdate !== "function" && !didWarnAboutGetSnapshotBeforeUpdateWithoutDidUpdate.has(ctor)) {
|
|
didWarnAboutGetSnapshotBeforeUpdateWithoutDidUpdate.add(ctor);
|
|
error("%s: getSnapshotBeforeUpdate() should be used with componentDidUpdate(). This component defines getSnapshotBeforeUpdate() only.", getComponentName(ctor));
|
|
}
|
|
if (typeof instance.getDerivedStateFromProps === "function") {
|
|
error("%s: getDerivedStateFromProps() is defined as an instance method and will be ignored. Instead, declare it as a static method.", name);
|
|
}
|
|
if (typeof instance.getDerivedStateFromError === "function") {
|
|
error("%s: getDerivedStateFromError() is defined as an instance method and will be ignored. Instead, declare it as a static method.", name);
|
|
}
|
|
if (typeof ctor.getSnapshotBeforeUpdate === "function") {
|
|
error("%s: getSnapshotBeforeUpdate() is defined as a static method and will be ignored. Instead, declare it as an instance method.", name);
|
|
}
|
|
var _state = instance.state;
|
|
if (_state && (typeof _state !== "object" || isArray(_state))) {
|
|
error("%s.state: must be set to an object or null", name);
|
|
}
|
|
if (typeof instance.getChildContext === "function" && typeof ctor.childContextTypes !== "object") {
|
|
error("%s.getChildContext(): childContextTypes must be defined in order to use getChildContext().", name);
|
|
}
|
|
}
|
|
}
|
|
function adoptClassInstance(workInProgress2, instance) {
|
|
instance.updater = classComponentUpdater;
|
|
workInProgress2.stateNode = instance;
|
|
set(instance, workInProgress2);
|
|
{
|
|
instance._reactInternalInstance = fakeInternalInstance;
|
|
}
|
|
}
|
|
function constructClassInstance(workInProgress2, ctor, props) {
|
|
var isLegacyContextConsumer = false;
|
|
var unmaskedContext = emptyContextObject;
|
|
var context = emptyContextObject;
|
|
var contextType = ctor.contextType;
|
|
{
|
|
if ("contextType" in ctor) {
|
|
var isValid = contextType === null || contextType !== void 0 && contextType.$$typeof === REACT_CONTEXT_TYPE && contextType._context === void 0;
|
|
if (!isValid && !didWarnAboutInvalidateContextType.has(ctor)) {
|
|
didWarnAboutInvalidateContextType.add(ctor);
|
|
var addendum = "";
|
|
if (contextType === void 0) {
|
|
addendum = " However, it is set to undefined. This can be caused by a typo or by mixing up named and default imports. This can also happen due to a circular dependency, so try moving the createContext() call to a separate file.";
|
|
} else if (typeof contextType !== "object") {
|
|
addendum = " However, it is set to a " + typeof contextType + ".";
|
|
} else if (contextType.$$typeof === REACT_PROVIDER_TYPE) {
|
|
addendum = " Did you accidentally pass the Context.Provider instead?";
|
|
} else if (contextType._context !== void 0) {
|
|
addendum = " Did you accidentally pass the Context.Consumer instead?";
|
|
} else {
|
|
addendum = " However, it is set to an object with keys {" + Object.keys(contextType).join(", ") + "}.";
|
|
}
|
|
error("%s defines an invalid contextType. contextType should point to the Context object returned by React.createContext().%s", getComponentName(ctor) || "Component", addendum);
|
|
}
|
|
}
|
|
}
|
|
if (typeof contextType === "object" && contextType !== null) {
|
|
context = readContext(contextType);
|
|
} else {
|
|
unmaskedContext = getUnmaskedContext(workInProgress2, ctor, true);
|
|
var contextTypes = ctor.contextTypes;
|
|
isLegacyContextConsumer = contextTypes !== null && contextTypes !== void 0;
|
|
context = isLegacyContextConsumer ? getMaskedContext(workInProgress2, unmaskedContext) : emptyContextObject;
|
|
}
|
|
{
|
|
if (workInProgress2.mode & StrictMode) {
|
|
disableLogs();
|
|
try {
|
|
new ctor(props, context);
|
|
} finally {
|
|
reenableLogs();
|
|
}
|
|
}
|
|
}
|
|
var instance = new ctor(props, context);
|
|
var state = workInProgress2.memoizedState = instance.state !== null && instance.state !== void 0 ? instance.state : null;
|
|
adoptClassInstance(workInProgress2, instance);
|
|
{
|
|
if (typeof ctor.getDerivedStateFromProps === "function" && state === null) {
|
|
var componentName = getComponentName(ctor) || "Component";
|
|
if (!didWarnAboutUninitializedState.has(componentName)) {
|
|
didWarnAboutUninitializedState.add(componentName);
|
|
error("`%s` uses `getDerivedStateFromProps` but its initial state is %s. This is not recommended. Instead, define the initial state by assigning an object to `this.state` in the constructor of `%s`. This ensures that `getDerivedStateFromProps` arguments have a consistent shape.", componentName, instance.state === null ? "null" : "undefined", componentName);
|
|
}
|
|
}
|
|
if (typeof ctor.getDerivedStateFromProps === "function" || typeof instance.getSnapshotBeforeUpdate === "function") {
|
|
var foundWillMountName = null;
|
|
var foundWillReceivePropsName = null;
|
|
var foundWillUpdateName = null;
|
|
if (typeof instance.componentWillMount === "function" && instance.componentWillMount.__suppressDeprecationWarning !== true) {
|
|
foundWillMountName = "componentWillMount";
|
|
} else if (typeof instance.UNSAFE_componentWillMount === "function") {
|
|
foundWillMountName = "UNSAFE_componentWillMount";
|
|
}
|
|
if (typeof instance.componentWillReceiveProps === "function" && instance.componentWillReceiveProps.__suppressDeprecationWarning !== true) {
|
|
foundWillReceivePropsName = "componentWillReceiveProps";
|
|
} else if (typeof instance.UNSAFE_componentWillReceiveProps === "function") {
|
|
foundWillReceivePropsName = "UNSAFE_componentWillReceiveProps";
|
|
}
|
|
if (typeof instance.componentWillUpdate === "function" && instance.componentWillUpdate.__suppressDeprecationWarning !== true) {
|
|
foundWillUpdateName = "componentWillUpdate";
|
|
} else if (typeof instance.UNSAFE_componentWillUpdate === "function") {
|
|
foundWillUpdateName = "UNSAFE_componentWillUpdate";
|
|
}
|
|
if (foundWillMountName !== null || foundWillReceivePropsName !== null || foundWillUpdateName !== null) {
|
|
var _componentName = getComponentName(ctor) || "Component";
|
|
var newApiName = typeof ctor.getDerivedStateFromProps === "function" ? "getDerivedStateFromProps()" : "getSnapshotBeforeUpdate()";
|
|
if (!didWarnAboutLegacyLifecyclesAndDerivedState.has(_componentName)) {
|
|
didWarnAboutLegacyLifecyclesAndDerivedState.add(_componentName);
|
|
error("Unsafe legacy lifecycles will not be called for components using new component APIs.\n\n%s uses %s but also contains the following legacy lifecycles:%s%s%s\n\nThe above lifecycles should be removed. Learn more about this warning here:\nhttps://reactjs.org/link/unsafe-component-lifecycles", _componentName, newApiName, foundWillMountName !== null ? "\n " + foundWillMountName : "", foundWillReceivePropsName !== null ? "\n " + foundWillReceivePropsName : "", foundWillUpdateName !== null ? "\n " + foundWillUpdateName : "");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (isLegacyContextConsumer) {
|
|
cacheContext(workInProgress2, unmaskedContext, context);
|
|
}
|
|
return instance;
|
|
}
|
|
function callComponentWillMount(workInProgress2, instance) {
|
|
var oldState = instance.state;
|
|
if (typeof instance.componentWillMount === "function") {
|
|
instance.componentWillMount();
|
|
}
|
|
if (typeof instance.UNSAFE_componentWillMount === "function") {
|
|
instance.UNSAFE_componentWillMount();
|
|
}
|
|
if (oldState !== instance.state) {
|
|
{
|
|
error("%s.componentWillMount(): Assigning directly to this.state is deprecated (except inside a component's constructor). Use setState instead.", getComponentName(workInProgress2.type) || "Component");
|
|
}
|
|
classComponentUpdater.enqueueReplaceState(instance, instance.state, null);
|
|
}
|
|
}
|
|
function callComponentWillReceiveProps(workInProgress2, instance, newProps, nextContext) {
|
|
var oldState = instance.state;
|
|
if (typeof instance.componentWillReceiveProps === "function") {
|
|
instance.componentWillReceiveProps(newProps, nextContext);
|
|
}
|
|
if (typeof instance.UNSAFE_componentWillReceiveProps === "function") {
|
|
instance.UNSAFE_componentWillReceiveProps(newProps, nextContext);
|
|
}
|
|
if (instance.state !== oldState) {
|
|
{
|
|
var componentName = getComponentName(workInProgress2.type) || "Component";
|
|
if (!didWarnAboutStateAssignmentForComponent.has(componentName)) {
|
|
didWarnAboutStateAssignmentForComponent.add(componentName);
|
|
error("%s.componentWillReceiveProps(): Assigning directly to this.state is deprecated (except inside a component's constructor). Use setState instead.", componentName);
|
|
}
|
|
}
|
|
classComponentUpdater.enqueueReplaceState(instance, instance.state, null);
|
|
}
|
|
}
|
|
function mountClassInstance(workInProgress2, ctor, newProps, renderLanes2) {
|
|
{
|
|
checkClassInstance(workInProgress2, ctor, newProps);
|
|
}
|
|
var instance = workInProgress2.stateNode;
|
|
instance.props = newProps;
|
|
instance.state = workInProgress2.memoizedState;
|
|
instance.refs = emptyRefsObject;
|
|
initializeUpdateQueue(workInProgress2);
|
|
var contextType = ctor.contextType;
|
|
if (typeof contextType === "object" && contextType !== null) {
|
|
instance.context = readContext(contextType);
|
|
} else {
|
|
var unmaskedContext = getUnmaskedContext(workInProgress2, ctor, true);
|
|
instance.context = getMaskedContext(workInProgress2, unmaskedContext);
|
|
}
|
|
{
|
|
if (instance.state === newProps) {
|
|
var componentName = getComponentName(ctor) || "Component";
|
|
if (!didWarnAboutDirectlyAssigningPropsToState.has(componentName)) {
|
|
didWarnAboutDirectlyAssigningPropsToState.add(componentName);
|
|
error("%s: It is not recommended to assign props directly to state because updates to props won't be reflected in state. In most cases, it is better to use props directly.", componentName);
|
|
}
|
|
}
|
|
if (workInProgress2.mode & StrictMode) {
|
|
ReactStrictModeWarnings.recordLegacyContextWarning(workInProgress2, instance);
|
|
}
|
|
{
|
|
ReactStrictModeWarnings.recordUnsafeLifecycleWarnings(workInProgress2, instance);
|
|
}
|
|
}
|
|
processUpdateQueue(workInProgress2, newProps, instance, renderLanes2);
|
|
instance.state = workInProgress2.memoizedState;
|
|
var getDerivedStateFromProps = ctor.getDerivedStateFromProps;
|
|
if (typeof getDerivedStateFromProps === "function") {
|
|
applyDerivedStateFromProps(workInProgress2, ctor, getDerivedStateFromProps, newProps);
|
|
instance.state = workInProgress2.memoizedState;
|
|
}
|
|
if (typeof ctor.getDerivedStateFromProps !== "function" && typeof instance.getSnapshotBeforeUpdate !== "function" && (typeof instance.UNSAFE_componentWillMount === "function" || typeof instance.componentWillMount === "function")) {
|
|
callComponentWillMount(workInProgress2, instance);
|
|
processUpdateQueue(workInProgress2, newProps, instance, renderLanes2);
|
|
instance.state = workInProgress2.memoizedState;
|
|
}
|
|
if (typeof instance.componentDidMount === "function") {
|
|
workInProgress2.flags |= Update;
|
|
}
|
|
}
|
|
function resumeMountClassInstance(workInProgress2, ctor, newProps, renderLanes2) {
|
|
var instance = workInProgress2.stateNode;
|
|
var oldProps = workInProgress2.memoizedProps;
|
|
instance.props = oldProps;
|
|
var oldContext = instance.context;
|
|
var contextType = ctor.contextType;
|
|
var nextContext = emptyContextObject;
|
|
if (typeof contextType === "object" && contextType !== null) {
|
|
nextContext = readContext(contextType);
|
|
} else {
|
|
var nextLegacyUnmaskedContext = getUnmaskedContext(workInProgress2, ctor, true);
|
|
nextContext = getMaskedContext(workInProgress2, nextLegacyUnmaskedContext);
|
|
}
|
|
var getDerivedStateFromProps = ctor.getDerivedStateFromProps;
|
|
var hasNewLifecycles = typeof getDerivedStateFromProps === "function" || typeof instance.getSnapshotBeforeUpdate === "function";
|
|
if (!hasNewLifecycles && (typeof instance.UNSAFE_componentWillReceiveProps === "function" || typeof instance.componentWillReceiveProps === "function")) {
|
|
if (oldProps !== newProps || oldContext !== nextContext) {
|
|
callComponentWillReceiveProps(workInProgress2, instance, newProps, nextContext);
|
|
}
|
|
}
|
|
resetHasForceUpdateBeforeProcessing();
|
|
var oldState = workInProgress2.memoizedState;
|
|
var newState = instance.state = oldState;
|
|
processUpdateQueue(workInProgress2, newProps, instance, renderLanes2);
|
|
newState = workInProgress2.memoizedState;
|
|
if (oldProps === newProps && oldState === newState && !hasContextChanged() && !checkHasForceUpdateAfterProcessing()) {
|
|
if (typeof instance.componentDidMount === "function") {
|
|
workInProgress2.flags |= Update;
|
|
}
|
|
return false;
|
|
}
|
|
if (typeof getDerivedStateFromProps === "function") {
|
|
applyDerivedStateFromProps(workInProgress2, ctor, getDerivedStateFromProps, newProps);
|
|
newState = workInProgress2.memoizedState;
|
|
}
|
|
var shouldUpdate = checkHasForceUpdateAfterProcessing() || checkShouldComponentUpdate(workInProgress2, ctor, oldProps, newProps, oldState, newState, nextContext);
|
|
if (shouldUpdate) {
|
|
if (!hasNewLifecycles && (typeof instance.UNSAFE_componentWillMount === "function" || typeof instance.componentWillMount === "function")) {
|
|
if (typeof instance.componentWillMount === "function") {
|
|
instance.componentWillMount();
|
|
}
|
|
if (typeof instance.UNSAFE_componentWillMount === "function") {
|
|
instance.UNSAFE_componentWillMount();
|
|
}
|
|
}
|
|
if (typeof instance.componentDidMount === "function") {
|
|
workInProgress2.flags |= Update;
|
|
}
|
|
} else {
|
|
if (typeof instance.componentDidMount === "function") {
|
|
workInProgress2.flags |= Update;
|
|
}
|
|
workInProgress2.memoizedProps = newProps;
|
|
workInProgress2.memoizedState = newState;
|
|
}
|
|
instance.props = newProps;
|
|
instance.state = newState;
|
|
instance.context = nextContext;
|
|
return shouldUpdate;
|
|
}
|
|
function updateClassInstance(current2, workInProgress2, ctor, newProps, renderLanes2) {
|
|
var instance = workInProgress2.stateNode;
|
|
cloneUpdateQueue(current2, workInProgress2);
|
|
var unresolvedOldProps = workInProgress2.memoizedProps;
|
|
var oldProps = workInProgress2.type === workInProgress2.elementType ? unresolvedOldProps : resolveDefaultProps(workInProgress2.type, unresolvedOldProps);
|
|
instance.props = oldProps;
|
|
var unresolvedNewProps = workInProgress2.pendingProps;
|
|
var oldContext = instance.context;
|
|
var contextType = ctor.contextType;
|
|
var nextContext = emptyContextObject;
|
|
if (typeof contextType === "object" && contextType !== null) {
|
|
nextContext = readContext(contextType);
|
|
} else {
|
|
var nextUnmaskedContext = getUnmaskedContext(workInProgress2, ctor, true);
|
|
nextContext = getMaskedContext(workInProgress2, nextUnmaskedContext);
|
|
}
|
|
var getDerivedStateFromProps = ctor.getDerivedStateFromProps;
|
|
var hasNewLifecycles = typeof getDerivedStateFromProps === "function" || typeof instance.getSnapshotBeforeUpdate === "function";
|
|
if (!hasNewLifecycles && (typeof instance.UNSAFE_componentWillReceiveProps === "function" || typeof instance.componentWillReceiveProps === "function")) {
|
|
if (unresolvedOldProps !== unresolvedNewProps || oldContext !== nextContext) {
|
|
callComponentWillReceiveProps(workInProgress2, instance, newProps, nextContext);
|
|
}
|
|
}
|
|
resetHasForceUpdateBeforeProcessing();
|
|
var oldState = workInProgress2.memoizedState;
|
|
var newState = instance.state = oldState;
|
|
processUpdateQueue(workInProgress2, newProps, instance, renderLanes2);
|
|
newState = workInProgress2.memoizedState;
|
|
if (unresolvedOldProps === unresolvedNewProps && oldState === newState && !hasContextChanged() && !checkHasForceUpdateAfterProcessing()) {
|
|
if (typeof instance.componentDidUpdate === "function") {
|
|
if (unresolvedOldProps !== current2.memoizedProps || oldState !== current2.memoizedState) {
|
|
workInProgress2.flags |= Update;
|
|
}
|
|
}
|
|
if (typeof instance.getSnapshotBeforeUpdate === "function") {
|
|
if (unresolvedOldProps !== current2.memoizedProps || oldState !== current2.memoizedState) {
|
|
workInProgress2.flags |= Snapshot;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
if (typeof getDerivedStateFromProps === "function") {
|
|
applyDerivedStateFromProps(workInProgress2, ctor, getDerivedStateFromProps, newProps);
|
|
newState = workInProgress2.memoizedState;
|
|
}
|
|
var shouldUpdate = checkHasForceUpdateAfterProcessing() || checkShouldComponentUpdate(workInProgress2, ctor, oldProps, newProps, oldState, newState, nextContext);
|
|
if (shouldUpdate) {
|
|
if (!hasNewLifecycles && (typeof instance.UNSAFE_componentWillUpdate === "function" || typeof instance.componentWillUpdate === "function")) {
|
|
if (typeof instance.componentWillUpdate === "function") {
|
|
instance.componentWillUpdate(newProps, newState, nextContext);
|
|
}
|
|
if (typeof instance.UNSAFE_componentWillUpdate === "function") {
|
|
instance.UNSAFE_componentWillUpdate(newProps, newState, nextContext);
|
|
}
|
|
}
|
|
if (typeof instance.componentDidUpdate === "function") {
|
|
workInProgress2.flags |= Update;
|
|
}
|
|
if (typeof instance.getSnapshotBeforeUpdate === "function") {
|
|
workInProgress2.flags |= Snapshot;
|
|
}
|
|
} else {
|
|
if (typeof instance.componentDidUpdate === "function") {
|
|
if (unresolvedOldProps !== current2.memoizedProps || oldState !== current2.memoizedState) {
|
|
workInProgress2.flags |= Update;
|
|
}
|
|
}
|
|
if (typeof instance.getSnapshotBeforeUpdate === "function") {
|
|
if (unresolvedOldProps !== current2.memoizedProps || oldState !== current2.memoizedState) {
|
|
workInProgress2.flags |= Snapshot;
|
|
}
|
|
}
|
|
workInProgress2.memoizedProps = newProps;
|
|
workInProgress2.memoizedState = newState;
|
|
}
|
|
instance.props = newProps;
|
|
instance.state = newState;
|
|
instance.context = nextContext;
|
|
return shouldUpdate;
|
|
}
|
|
var didWarnAboutMaps;
|
|
var didWarnAboutGenerators;
|
|
var didWarnAboutStringRefs;
|
|
var ownerHasKeyUseWarning;
|
|
var ownerHasFunctionTypeWarning;
|
|
var warnForMissingKey = function(child, returnFiber) {
|
|
};
|
|
{
|
|
didWarnAboutMaps = false;
|
|
didWarnAboutGenerators = false;
|
|
didWarnAboutStringRefs = {};
|
|
ownerHasKeyUseWarning = {};
|
|
ownerHasFunctionTypeWarning = {};
|
|
warnForMissingKey = function(child, returnFiber) {
|
|
if (child === null || typeof child !== "object") {
|
|
return;
|
|
}
|
|
if (!child._store || child._store.validated || child.key != null) {
|
|
return;
|
|
}
|
|
if (!(typeof child._store === "object")) {
|
|
{
|
|
throw Error("React Component in warnForMissingKey should have a _store. This error is likely caused by a bug in React. Please file an issue.");
|
|
}
|
|
}
|
|
child._store.validated = true;
|
|
var componentName = getComponentName(returnFiber.type) || "Component";
|
|
if (ownerHasKeyUseWarning[componentName]) {
|
|
return;
|
|
}
|
|
ownerHasKeyUseWarning[componentName] = true;
|
|
error('Each child in a list should have a unique "key" prop. See https://reactjs.org/link/warning-keys for more information.');
|
|
};
|
|
}
|
|
var isArray$1 = Array.isArray;
|
|
function coerceRef(returnFiber, current2, element) {
|
|
var mixedRef = element.ref;
|
|
if (mixedRef !== null && typeof mixedRef !== "function" && typeof mixedRef !== "object") {
|
|
{
|
|
if ((returnFiber.mode & StrictMode || warnAboutStringRefs) && !(element._owner && element._self && element._owner.stateNode !== element._self)) {
|
|
var componentName = getComponentName(returnFiber.type) || "Component";
|
|
if (!didWarnAboutStringRefs[componentName]) {
|
|
{
|
|
error('A string ref, "%s", has been found within a strict mode tree. String refs are a source of potential bugs and should be avoided. We recommend using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref', mixedRef);
|
|
}
|
|
didWarnAboutStringRefs[componentName] = true;
|
|
}
|
|
}
|
|
}
|
|
if (element._owner) {
|
|
var owner = element._owner;
|
|
var inst;
|
|
if (owner) {
|
|
var ownerFiber = owner;
|
|
if (!(ownerFiber.tag === ClassComponent)) {
|
|
{
|
|
throw Error("Function components cannot have string refs. We recommend using useRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref");
|
|
}
|
|
}
|
|
inst = ownerFiber.stateNode;
|
|
}
|
|
if (!inst) {
|
|
{
|
|
throw Error("Missing owner for string ref " + mixedRef + ". This error is likely caused by a bug in React. Please file an issue.");
|
|
}
|
|
}
|
|
var stringRef = "" + mixedRef;
|
|
if (current2 !== null && current2.ref !== null && typeof current2.ref === "function" && current2.ref._stringRef === stringRef) {
|
|
return current2.ref;
|
|
}
|
|
var ref = function(value) {
|
|
var refs = inst.refs;
|
|
if (refs === emptyRefsObject) {
|
|
refs = inst.refs = {};
|
|
}
|
|
if (value === null) {
|
|
delete refs[stringRef];
|
|
} else {
|
|
refs[stringRef] = value;
|
|
}
|
|
};
|
|
ref._stringRef = stringRef;
|
|
return ref;
|
|
} else {
|
|
if (!(typeof mixedRef === "string")) {
|
|
{
|
|
throw Error("Expected ref to be a function, a string, an object returned by React.createRef(), or null.");
|
|
}
|
|
}
|
|
if (!element._owner) {
|
|
{
|
|
throw Error("Element ref was specified as a string (" + mixedRef + ") but no owner was set. This could happen for one of the following reasons:\n1. You may be adding a ref to a function component\n2. You may be adding a ref to a component that was not created inside a component's render method\n3. You have multiple copies of React loaded\nSee https://reactjs.org/link/refs-must-have-owner for more information.");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return mixedRef;
|
|
}
|
|
function throwOnInvalidObjectType(returnFiber, newChild) {
|
|
if (returnFiber.type !== "textarea") {
|
|
{
|
|
{
|
|
throw Error("Objects are not valid as a React child (found: " + (Object.prototype.toString.call(newChild) === "[object Object]" ? "object with keys {" + Object.keys(newChild).join(", ") + "}" : newChild) + "). If you meant to render a collection of children, use an array instead.");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
function warnOnFunctionType(returnFiber) {
|
|
{
|
|
var componentName = getComponentName(returnFiber.type) || "Component";
|
|
if (ownerHasFunctionTypeWarning[componentName]) {
|
|
return;
|
|
}
|
|
ownerHasFunctionTypeWarning[componentName] = true;
|
|
error("Functions are not valid as a React child. This may happen if you return a Component instead of <Component /> from render. Or maybe you meant to call this function rather than return it.");
|
|
}
|
|
}
|
|
function ChildReconciler(shouldTrackSideEffects) {
|
|
function deleteChild(returnFiber, childToDelete) {
|
|
if (!shouldTrackSideEffects) {
|
|
return;
|
|
}
|
|
var last = returnFiber.lastEffect;
|
|
if (last !== null) {
|
|
last.nextEffect = childToDelete;
|
|
returnFiber.lastEffect = childToDelete;
|
|
} else {
|
|
returnFiber.firstEffect = returnFiber.lastEffect = childToDelete;
|
|
}
|
|
childToDelete.nextEffect = null;
|
|
childToDelete.flags = Deletion;
|
|
}
|
|
function deleteRemainingChildren(returnFiber, currentFirstChild) {
|
|
if (!shouldTrackSideEffects) {
|
|
return null;
|
|
}
|
|
var childToDelete = currentFirstChild;
|
|
while (childToDelete !== null) {
|
|
deleteChild(returnFiber, childToDelete);
|
|
childToDelete = childToDelete.sibling;
|
|
}
|
|
return null;
|
|
}
|
|
function mapRemainingChildren(returnFiber, currentFirstChild) {
|
|
var existingChildren = new Map();
|
|
var existingChild = currentFirstChild;
|
|
while (existingChild !== null) {
|
|
if (existingChild.key !== null) {
|
|
existingChildren.set(existingChild.key, existingChild);
|
|
} else {
|
|
existingChildren.set(existingChild.index, existingChild);
|
|
}
|
|
existingChild = existingChild.sibling;
|
|
}
|
|
return existingChildren;
|
|
}
|
|
function useFiber(fiber, pendingProps) {
|
|
var clone = createWorkInProgress(fiber, pendingProps);
|
|
clone.index = 0;
|
|
clone.sibling = null;
|
|
return clone;
|
|
}
|
|
function placeChild(newFiber, lastPlacedIndex, newIndex) {
|
|
newFiber.index = newIndex;
|
|
if (!shouldTrackSideEffects) {
|
|
return lastPlacedIndex;
|
|
}
|
|
var current2 = newFiber.alternate;
|
|
if (current2 !== null) {
|
|
var oldIndex = current2.index;
|
|
if (oldIndex < lastPlacedIndex) {
|
|
newFiber.flags = Placement;
|
|
return lastPlacedIndex;
|
|
} else {
|
|
return oldIndex;
|
|
}
|
|
} else {
|
|
newFiber.flags = Placement;
|
|
return lastPlacedIndex;
|
|
}
|
|
}
|
|
function placeSingleChild(newFiber) {
|
|
if (shouldTrackSideEffects && newFiber.alternate === null) {
|
|
newFiber.flags = Placement;
|
|
}
|
|
return newFiber;
|
|
}
|
|
function updateTextNode(returnFiber, current2, textContent, lanes) {
|
|
if (current2 === null || current2.tag !== HostText) {
|
|
var created = createFiberFromText(textContent, returnFiber.mode, lanes);
|
|
created.return = returnFiber;
|
|
return created;
|
|
} else {
|
|
var existing = useFiber(current2, textContent);
|
|
existing.return = returnFiber;
|
|
return existing;
|
|
}
|
|
}
|
|
function updateElement(returnFiber, current2, element, lanes) {
|
|
if (current2 !== null) {
|
|
if (current2.elementType === element.type || isCompatibleFamilyForHotReloading(current2, element)) {
|
|
var existing = useFiber(current2, element.props);
|
|
existing.ref = coerceRef(returnFiber, current2, element);
|
|
existing.return = returnFiber;
|
|
{
|
|
existing._debugSource = element._source;
|
|
existing._debugOwner = element._owner;
|
|
}
|
|
return existing;
|
|
}
|
|
}
|
|
var created = createFiberFromElement(element, returnFiber.mode, lanes);
|
|
created.ref = coerceRef(returnFiber, current2, element);
|
|
created.return = returnFiber;
|
|
return created;
|
|
}
|
|
function updatePortal(returnFiber, current2, portal, lanes) {
|
|
if (current2 === null || current2.tag !== HostPortal || current2.stateNode.containerInfo !== portal.containerInfo || current2.stateNode.implementation !== portal.implementation) {
|
|
var created = createFiberFromPortal(portal, returnFiber.mode, lanes);
|
|
created.return = returnFiber;
|
|
return created;
|
|
} else {
|
|
var existing = useFiber(current2, portal.children || []);
|
|
existing.return = returnFiber;
|
|
return existing;
|
|
}
|
|
}
|
|
function updateFragment2(returnFiber, current2, fragment, lanes, key) {
|
|
if (current2 === null || current2.tag !== Fragment3) {
|
|
var created = createFiberFromFragment(fragment, returnFiber.mode, lanes, key);
|
|
created.return = returnFiber;
|
|
return created;
|
|
} else {
|
|
var existing = useFiber(current2, fragment);
|
|
existing.return = returnFiber;
|
|
return existing;
|
|
}
|
|
}
|
|
function createChild(returnFiber, newChild, lanes) {
|
|
if (typeof newChild === "string" || typeof newChild === "number") {
|
|
var created = createFiberFromText("" + newChild, returnFiber.mode, lanes);
|
|
created.return = returnFiber;
|
|
return created;
|
|
}
|
|
if (typeof newChild === "object" && newChild !== null) {
|
|
switch (newChild.$$typeof) {
|
|
case REACT_ELEMENT_TYPE: {
|
|
var _created = createFiberFromElement(newChild, returnFiber.mode, lanes);
|
|
_created.ref = coerceRef(returnFiber, null, newChild);
|
|
_created.return = returnFiber;
|
|
return _created;
|
|
}
|
|
case REACT_PORTAL_TYPE: {
|
|
var _created2 = createFiberFromPortal(newChild, returnFiber.mode, lanes);
|
|
_created2.return = returnFiber;
|
|
return _created2;
|
|
}
|
|
}
|
|
if (isArray$1(newChild) || getIteratorFn(newChild)) {
|
|
var _created3 = createFiberFromFragment(newChild, returnFiber.mode, lanes, null);
|
|
_created3.return = returnFiber;
|
|
return _created3;
|
|
}
|
|
throwOnInvalidObjectType(returnFiber, newChild);
|
|
}
|
|
{
|
|
if (typeof newChild === "function") {
|
|
warnOnFunctionType(returnFiber);
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
function updateSlot(returnFiber, oldFiber, newChild, lanes) {
|
|
var key = oldFiber !== null ? oldFiber.key : null;
|
|
if (typeof newChild === "string" || typeof newChild === "number") {
|
|
if (key !== null) {
|
|
return null;
|
|
}
|
|
return updateTextNode(returnFiber, oldFiber, "" + newChild, lanes);
|
|
}
|
|
if (typeof newChild === "object" && newChild !== null) {
|
|
switch (newChild.$$typeof) {
|
|
case REACT_ELEMENT_TYPE: {
|
|
if (newChild.key === key) {
|
|
if (newChild.type === REACT_FRAGMENT_TYPE) {
|
|
return updateFragment2(returnFiber, oldFiber, newChild.props.children, lanes, key);
|
|
}
|
|
return updateElement(returnFiber, oldFiber, newChild, lanes);
|
|
} else {
|
|
return null;
|
|
}
|
|
}
|
|
case REACT_PORTAL_TYPE: {
|
|
if (newChild.key === key) {
|
|
return updatePortal(returnFiber, oldFiber, newChild, lanes);
|
|
} else {
|
|
return null;
|
|
}
|
|
}
|
|
}
|
|
if (isArray$1(newChild) || getIteratorFn(newChild)) {
|
|
if (key !== null) {
|
|
return null;
|
|
}
|
|
return updateFragment2(returnFiber, oldFiber, newChild, lanes, null);
|
|
}
|
|
throwOnInvalidObjectType(returnFiber, newChild);
|
|
}
|
|
{
|
|
if (typeof newChild === "function") {
|
|
warnOnFunctionType(returnFiber);
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
function updateFromMap(existingChildren, returnFiber, newIdx, newChild, lanes) {
|
|
if (typeof newChild === "string" || typeof newChild === "number") {
|
|
var matchedFiber = existingChildren.get(newIdx) || null;
|
|
return updateTextNode(returnFiber, matchedFiber, "" + newChild, lanes);
|
|
}
|
|
if (typeof newChild === "object" && newChild !== null) {
|
|
switch (newChild.$$typeof) {
|
|
case REACT_ELEMENT_TYPE: {
|
|
var _matchedFiber = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;
|
|
if (newChild.type === REACT_FRAGMENT_TYPE) {
|
|
return updateFragment2(returnFiber, _matchedFiber, newChild.props.children, lanes, newChild.key);
|
|
}
|
|
return updateElement(returnFiber, _matchedFiber, newChild, lanes);
|
|
}
|
|
case REACT_PORTAL_TYPE: {
|
|
var _matchedFiber2 = existingChildren.get(newChild.key === null ? newIdx : newChild.key) || null;
|
|
return updatePortal(returnFiber, _matchedFiber2, newChild, lanes);
|
|
}
|
|
}
|
|
if (isArray$1(newChild) || getIteratorFn(newChild)) {
|
|
var _matchedFiber3 = existingChildren.get(newIdx) || null;
|
|
return updateFragment2(returnFiber, _matchedFiber3, newChild, lanes, null);
|
|
}
|
|
throwOnInvalidObjectType(returnFiber, newChild);
|
|
}
|
|
{
|
|
if (typeof newChild === "function") {
|
|
warnOnFunctionType(returnFiber);
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
function warnOnInvalidKey(child, knownKeys, returnFiber) {
|
|
{
|
|
if (typeof child !== "object" || child === null) {
|
|
return knownKeys;
|
|
}
|
|
switch (child.$$typeof) {
|
|
case REACT_ELEMENT_TYPE:
|
|
case REACT_PORTAL_TYPE:
|
|
warnForMissingKey(child, returnFiber);
|
|
var key = child.key;
|
|
if (typeof key !== "string") {
|
|
break;
|
|
}
|
|
if (knownKeys === null) {
|
|
knownKeys = new Set();
|
|
knownKeys.add(key);
|
|
break;
|
|
}
|
|
if (!knownKeys.has(key)) {
|
|
knownKeys.add(key);
|
|
break;
|
|
}
|
|
error("Encountered two children with the same key, `%s`. Keys should be unique so that components maintain their identity across updates. Non-unique keys may cause children to be duplicated and/or omitted \u2014 the behavior is unsupported and could change in a future version.", key);
|
|
break;
|
|
}
|
|
}
|
|
return knownKeys;
|
|
}
|
|
function reconcileChildrenArray(returnFiber, currentFirstChild, newChildren, lanes) {
|
|
{
|
|
var knownKeys = null;
|
|
for (var i3 = 0; i3 < newChildren.length; i3++) {
|
|
var child = newChildren[i3];
|
|
knownKeys = warnOnInvalidKey(child, knownKeys, returnFiber);
|
|
}
|
|
}
|
|
var resultingFirstChild = null;
|
|
var previousNewFiber = null;
|
|
var oldFiber = currentFirstChild;
|
|
var lastPlacedIndex = 0;
|
|
var newIdx = 0;
|
|
var nextOldFiber = null;
|
|
for (; oldFiber !== null && newIdx < newChildren.length; newIdx++) {
|
|
if (oldFiber.index > newIdx) {
|
|
nextOldFiber = oldFiber;
|
|
oldFiber = null;
|
|
} else {
|
|
nextOldFiber = oldFiber.sibling;
|
|
}
|
|
var newFiber = updateSlot(returnFiber, oldFiber, newChildren[newIdx], lanes);
|
|
if (newFiber === null) {
|
|
if (oldFiber === null) {
|
|
oldFiber = nextOldFiber;
|
|
}
|
|
break;
|
|
}
|
|
if (shouldTrackSideEffects) {
|
|
if (oldFiber && newFiber.alternate === null) {
|
|
deleteChild(returnFiber, oldFiber);
|
|
}
|
|
}
|
|
lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);
|
|
if (previousNewFiber === null) {
|
|
resultingFirstChild = newFiber;
|
|
} else {
|
|
previousNewFiber.sibling = newFiber;
|
|
}
|
|
previousNewFiber = newFiber;
|
|
oldFiber = nextOldFiber;
|
|
}
|
|
if (newIdx === newChildren.length) {
|
|
deleteRemainingChildren(returnFiber, oldFiber);
|
|
return resultingFirstChild;
|
|
}
|
|
if (oldFiber === null) {
|
|
for (; newIdx < newChildren.length; newIdx++) {
|
|
var _newFiber = createChild(returnFiber, newChildren[newIdx], lanes);
|
|
if (_newFiber === null) {
|
|
continue;
|
|
}
|
|
lastPlacedIndex = placeChild(_newFiber, lastPlacedIndex, newIdx);
|
|
if (previousNewFiber === null) {
|
|
resultingFirstChild = _newFiber;
|
|
} else {
|
|
previousNewFiber.sibling = _newFiber;
|
|
}
|
|
previousNewFiber = _newFiber;
|
|
}
|
|
return resultingFirstChild;
|
|
}
|
|
var existingChildren = mapRemainingChildren(returnFiber, oldFiber);
|
|
for (; newIdx < newChildren.length; newIdx++) {
|
|
var _newFiber2 = updateFromMap(existingChildren, returnFiber, newIdx, newChildren[newIdx], lanes);
|
|
if (_newFiber2 !== null) {
|
|
if (shouldTrackSideEffects) {
|
|
if (_newFiber2.alternate !== null) {
|
|
existingChildren.delete(_newFiber2.key === null ? newIdx : _newFiber2.key);
|
|
}
|
|
}
|
|
lastPlacedIndex = placeChild(_newFiber2, lastPlacedIndex, newIdx);
|
|
if (previousNewFiber === null) {
|
|
resultingFirstChild = _newFiber2;
|
|
} else {
|
|
previousNewFiber.sibling = _newFiber2;
|
|
}
|
|
previousNewFiber = _newFiber2;
|
|
}
|
|
}
|
|
if (shouldTrackSideEffects) {
|
|
existingChildren.forEach(function(child2) {
|
|
return deleteChild(returnFiber, child2);
|
|
});
|
|
}
|
|
return resultingFirstChild;
|
|
}
|
|
function reconcileChildrenIterator(returnFiber, currentFirstChild, newChildrenIterable, lanes) {
|
|
var iteratorFn = getIteratorFn(newChildrenIterable);
|
|
if (!(typeof iteratorFn === "function")) {
|
|
{
|
|
throw Error("An object is not an iterable. This error is likely caused by a bug in React. Please file an issue.");
|
|
}
|
|
}
|
|
{
|
|
if (typeof Symbol === "function" && newChildrenIterable[Symbol.toStringTag] === "Generator") {
|
|
if (!didWarnAboutGenerators) {
|
|
error("Using Generators as children is unsupported and will likely yield unexpected results because enumerating a generator mutates it. You may convert it to an array with `Array.from()` or the `[...spread]` operator before rendering. Keep in mind you might need to polyfill these features for older browsers.");
|
|
}
|
|
didWarnAboutGenerators = true;
|
|
}
|
|
if (newChildrenIterable.entries === iteratorFn) {
|
|
if (!didWarnAboutMaps) {
|
|
error("Using Maps as children is not supported. Use an array of keyed ReactElements instead.");
|
|
}
|
|
didWarnAboutMaps = true;
|
|
}
|
|
var _newChildren = iteratorFn.call(newChildrenIterable);
|
|
if (_newChildren) {
|
|
var knownKeys = null;
|
|
var _step = _newChildren.next();
|
|
for (; !_step.done; _step = _newChildren.next()) {
|
|
var child = _step.value;
|
|
knownKeys = warnOnInvalidKey(child, knownKeys, returnFiber);
|
|
}
|
|
}
|
|
}
|
|
var newChildren = iteratorFn.call(newChildrenIterable);
|
|
if (!(newChildren != null)) {
|
|
{
|
|
throw Error("An iterable object provided no iterator.");
|
|
}
|
|
}
|
|
var resultingFirstChild = null;
|
|
var previousNewFiber = null;
|
|
var oldFiber = currentFirstChild;
|
|
var lastPlacedIndex = 0;
|
|
var newIdx = 0;
|
|
var nextOldFiber = null;
|
|
var step = newChildren.next();
|
|
for (; oldFiber !== null && !step.done; newIdx++, step = newChildren.next()) {
|
|
if (oldFiber.index > newIdx) {
|
|
nextOldFiber = oldFiber;
|
|
oldFiber = null;
|
|
} else {
|
|
nextOldFiber = oldFiber.sibling;
|
|
}
|
|
var newFiber = updateSlot(returnFiber, oldFiber, step.value, lanes);
|
|
if (newFiber === null) {
|
|
if (oldFiber === null) {
|
|
oldFiber = nextOldFiber;
|
|
}
|
|
break;
|
|
}
|
|
if (shouldTrackSideEffects) {
|
|
if (oldFiber && newFiber.alternate === null) {
|
|
deleteChild(returnFiber, oldFiber);
|
|
}
|
|
}
|
|
lastPlacedIndex = placeChild(newFiber, lastPlacedIndex, newIdx);
|
|
if (previousNewFiber === null) {
|
|
resultingFirstChild = newFiber;
|
|
} else {
|
|
previousNewFiber.sibling = newFiber;
|
|
}
|
|
previousNewFiber = newFiber;
|
|
oldFiber = nextOldFiber;
|
|
}
|
|
if (step.done) {
|
|
deleteRemainingChildren(returnFiber, oldFiber);
|
|
return resultingFirstChild;
|
|
}
|
|
if (oldFiber === null) {
|
|
for (; !step.done; newIdx++, step = newChildren.next()) {
|
|
var _newFiber3 = createChild(returnFiber, step.value, lanes);
|
|
if (_newFiber3 === null) {
|
|
continue;
|
|
}
|
|
lastPlacedIndex = placeChild(_newFiber3, lastPlacedIndex, newIdx);
|
|
if (previousNewFiber === null) {
|
|
resultingFirstChild = _newFiber3;
|
|
} else {
|
|
previousNewFiber.sibling = _newFiber3;
|
|
}
|
|
previousNewFiber = _newFiber3;
|
|
}
|
|
return resultingFirstChild;
|
|
}
|
|
var existingChildren = mapRemainingChildren(returnFiber, oldFiber);
|
|
for (; !step.done; newIdx++, step = newChildren.next()) {
|
|
var _newFiber4 = updateFromMap(existingChildren, returnFiber, newIdx, step.value, lanes);
|
|
if (_newFiber4 !== null) {
|
|
if (shouldTrackSideEffects) {
|
|
if (_newFiber4.alternate !== null) {
|
|
existingChildren.delete(_newFiber4.key === null ? newIdx : _newFiber4.key);
|
|
}
|
|
}
|
|
lastPlacedIndex = placeChild(_newFiber4, lastPlacedIndex, newIdx);
|
|
if (previousNewFiber === null) {
|
|
resultingFirstChild = _newFiber4;
|
|
} else {
|
|
previousNewFiber.sibling = _newFiber4;
|
|
}
|
|
previousNewFiber = _newFiber4;
|
|
}
|
|
}
|
|
if (shouldTrackSideEffects) {
|
|
existingChildren.forEach(function(child2) {
|
|
return deleteChild(returnFiber, child2);
|
|
});
|
|
}
|
|
return resultingFirstChild;
|
|
}
|
|
function reconcileSingleTextNode(returnFiber, currentFirstChild, textContent, lanes) {
|
|
if (currentFirstChild !== null && currentFirstChild.tag === HostText) {
|
|
deleteRemainingChildren(returnFiber, currentFirstChild.sibling);
|
|
var existing = useFiber(currentFirstChild, textContent);
|
|
existing.return = returnFiber;
|
|
return existing;
|
|
}
|
|
deleteRemainingChildren(returnFiber, currentFirstChild);
|
|
var created = createFiberFromText(textContent, returnFiber.mode, lanes);
|
|
created.return = returnFiber;
|
|
return created;
|
|
}
|
|
function reconcileSingleElement(returnFiber, currentFirstChild, element, lanes) {
|
|
var key = element.key;
|
|
var child = currentFirstChild;
|
|
while (child !== null) {
|
|
if (child.key === key) {
|
|
switch (child.tag) {
|
|
case Fragment3: {
|
|
if (element.type === REACT_FRAGMENT_TYPE) {
|
|
deleteRemainingChildren(returnFiber, child.sibling);
|
|
var existing = useFiber(child, element.props.children);
|
|
existing.return = returnFiber;
|
|
{
|
|
existing._debugSource = element._source;
|
|
existing._debugOwner = element._owner;
|
|
}
|
|
return existing;
|
|
}
|
|
break;
|
|
}
|
|
case Block:
|
|
default: {
|
|
if (child.elementType === element.type || isCompatibleFamilyForHotReloading(child, element)) {
|
|
deleteRemainingChildren(returnFiber, child.sibling);
|
|
var _existing3 = useFiber(child, element.props);
|
|
_existing3.ref = coerceRef(returnFiber, child, element);
|
|
_existing3.return = returnFiber;
|
|
{
|
|
_existing3._debugSource = element._source;
|
|
_existing3._debugOwner = element._owner;
|
|
}
|
|
return _existing3;
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
deleteRemainingChildren(returnFiber, child);
|
|
break;
|
|
} else {
|
|
deleteChild(returnFiber, child);
|
|
}
|
|
child = child.sibling;
|
|
}
|
|
if (element.type === REACT_FRAGMENT_TYPE) {
|
|
var created = createFiberFromFragment(element.props.children, returnFiber.mode, lanes, element.key);
|
|
created.return = returnFiber;
|
|
return created;
|
|
} else {
|
|
var _created4 = createFiberFromElement(element, returnFiber.mode, lanes);
|
|
_created4.ref = coerceRef(returnFiber, currentFirstChild, element);
|
|
_created4.return = returnFiber;
|
|
return _created4;
|
|
}
|
|
}
|
|
function reconcileSinglePortal(returnFiber, currentFirstChild, portal, lanes) {
|
|
var key = portal.key;
|
|
var child = currentFirstChild;
|
|
while (child !== null) {
|
|
if (child.key === key) {
|
|
if (child.tag === HostPortal && child.stateNode.containerInfo === portal.containerInfo && child.stateNode.implementation === portal.implementation) {
|
|
deleteRemainingChildren(returnFiber, child.sibling);
|
|
var existing = useFiber(child, portal.children || []);
|
|
existing.return = returnFiber;
|
|
return existing;
|
|
} else {
|
|
deleteRemainingChildren(returnFiber, child);
|
|
break;
|
|
}
|
|
} else {
|
|
deleteChild(returnFiber, child);
|
|
}
|
|
child = child.sibling;
|
|
}
|
|
var created = createFiberFromPortal(portal, returnFiber.mode, lanes);
|
|
created.return = returnFiber;
|
|
return created;
|
|
}
|
|
function reconcileChildFibers2(returnFiber, currentFirstChild, newChild, lanes) {
|
|
var isUnkeyedTopLevelFragment = typeof newChild === "object" && newChild !== null && newChild.type === REACT_FRAGMENT_TYPE && newChild.key === null;
|
|
if (isUnkeyedTopLevelFragment) {
|
|
newChild = newChild.props.children;
|
|
}
|
|
var isObject = typeof newChild === "object" && newChild !== null;
|
|
if (isObject) {
|
|
switch (newChild.$$typeof) {
|
|
case REACT_ELEMENT_TYPE:
|
|
return placeSingleChild(reconcileSingleElement(returnFiber, currentFirstChild, newChild, lanes));
|
|
case REACT_PORTAL_TYPE:
|
|
return placeSingleChild(reconcileSinglePortal(returnFiber, currentFirstChild, newChild, lanes));
|
|
}
|
|
}
|
|
if (typeof newChild === "string" || typeof newChild === "number") {
|
|
return placeSingleChild(reconcileSingleTextNode(returnFiber, currentFirstChild, "" + newChild, lanes));
|
|
}
|
|
if (isArray$1(newChild)) {
|
|
return reconcileChildrenArray(returnFiber, currentFirstChild, newChild, lanes);
|
|
}
|
|
if (getIteratorFn(newChild)) {
|
|
return reconcileChildrenIterator(returnFiber, currentFirstChild, newChild, lanes);
|
|
}
|
|
if (isObject) {
|
|
throwOnInvalidObjectType(returnFiber, newChild);
|
|
}
|
|
{
|
|
if (typeof newChild === "function") {
|
|
warnOnFunctionType(returnFiber);
|
|
}
|
|
}
|
|
if (typeof newChild === "undefined" && !isUnkeyedTopLevelFragment) {
|
|
switch (returnFiber.tag) {
|
|
case ClassComponent: {
|
|
{
|
|
var instance = returnFiber.stateNode;
|
|
if (instance.render._isMockFunction) {
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
case Block:
|
|
case FunctionComponent:
|
|
case ForwardRef:
|
|
case SimpleMemoComponent: {
|
|
{
|
|
{
|
|
throw Error((getComponentName(returnFiber.type) || "Component") + "(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null.");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return deleteRemainingChildren(returnFiber, currentFirstChild);
|
|
}
|
|
return reconcileChildFibers2;
|
|
}
|
|
var reconcileChildFibers = ChildReconciler(true);
|
|
var mountChildFibers = ChildReconciler(false);
|
|
function cloneChildFibers(current2, workInProgress2) {
|
|
if (!(current2 === null || workInProgress2.child === current2.child)) {
|
|
{
|
|
throw Error("Resuming work not yet implemented.");
|
|
}
|
|
}
|
|
if (workInProgress2.child === null) {
|
|
return;
|
|
}
|
|
var currentChild = workInProgress2.child;
|
|
var newChild = createWorkInProgress(currentChild, currentChild.pendingProps);
|
|
workInProgress2.child = newChild;
|
|
newChild.return = workInProgress2;
|
|
while (currentChild.sibling !== null) {
|
|
currentChild = currentChild.sibling;
|
|
newChild = newChild.sibling = createWorkInProgress(currentChild, currentChild.pendingProps);
|
|
newChild.return = workInProgress2;
|
|
}
|
|
newChild.sibling = null;
|
|
}
|
|
function resetChildFibers(workInProgress2, lanes) {
|
|
var child = workInProgress2.child;
|
|
while (child !== null) {
|
|
resetWorkInProgress(child, lanes);
|
|
child = child.sibling;
|
|
}
|
|
}
|
|
var NO_CONTEXT = {};
|
|
var contextStackCursor$1 = createCursor(NO_CONTEXT);
|
|
var contextFiberStackCursor = createCursor(NO_CONTEXT);
|
|
var rootInstanceStackCursor = createCursor(NO_CONTEXT);
|
|
function requiredContext(c3) {
|
|
if (!(c3 !== NO_CONTEXT)) {
|
|
{
|
|
throw Error("Expected host context to exist. This error is likely caused by a bug in React. Please file an issue.");
|
|
}
|
|
}
|
|
return c3;
|
|
}
|
|
function getRootHostContainer() {
|
|
var rootInstance = requiredContext(rootInstanceStackCursor.current);
|
|
return rootInstance;
|
|
}
|
|
function pushHostContainer(fiber, nextRootInstance) {
|
|
push(rootInstanceStackCursor, nextRootInstance, fiber);
|
|
push(contextFiberStackCursor, fiber, fiber);
|
|
push(contextStackCursor$1, NO_CONTEXT, fiber);
|
|
var nextRootContext = getRootHostContext(nextRootInstance);
|
|
pop(contextStackCursor$1, fiber);
|
|
push(contextStackCursor$1, nextRootContext, fiber);
|
|
}
|
|
function popHostContainer(fiber) {
|
|
pop(contextStackCursor$1, fiber);
|
|
pop(contextFiberStackCursor, fiber);
|
|
pop(rootInstanceStackCursor, fiber);
|
|
}
|
|
function getHostContext() {
|
|
var context = requiredContext(contextStackCursor$1.current);
|
|
return context;
|
|
}
|
|
function pushHostContext(fiber) {
|
|
var rootInstance = requiredContext(rootInstanceStackCursor.current);
|
|
var context = requiredContext(contextStackCursor$1.current);
|
|
var nextContext = getChildHostContext(context, fiber.type);
|
|
if (context === nextContext) {
|
|
return;
|
|
}
|
|
push(contextFiberStackCursor, fiber, fiber);
|
|
push(contextStackCursor$1, nextContext, fiber);
|
|
}
|
|
function popHostContext(fiber) {
|
|
if (contextFiberStackCursor.current !== fiber) {
|
|
return;
|
|
}
|
|
pop(contextStackCursor$1, fiber);
|
|
pop(contextFiberStackCursor, fiber);
|
|
}
|
|
var DefaultSuspenseContext = 0;
|
|
var SubtreeSuspenseContextMask = 1;
|
|
var InvisibleParentSuspenseContext = 1;
|
|
var ForceSuspenseFallback = 2;
|
|
var suspenseStackCursor = createCursor(DefaultSuspenseContext);
|
|
function hasSuspenseContext(parentContext, flag) {
|
|
return (parentContext & flag) !== 0;
|
|
}
|
|
function setDefaultShallowSuspenseContext(parentContext) {
|
|
return parentContext & SubtreeSuspenseContextMask;
|
|
}
|
|
function setShallowSuspenseContext(parentContext, shallowContext) {
|
|
return parentContext & SubtreeSuspenseContextMask | shallowContext;
|
|
}
|
|
function addSubtreeSuspenseContext(parentContext, subtreeContext) {
|
|
return parentContext | subtreeContext;
|
|
}
|
|
function pushSuspenseContext(fiber, newContext) {
|
|
push(suspenseStackCursor, newContext, fiber);
|
|
}
|
|
function popSuspenseContext(fiber) {
|
|
pop(suspenseStackCursor, fiber);
|
|
}
|
|
function shouldCaptureSuspense(workInProgress2, hasInvisibleParent) {
|
|
var nextState = workInProgress2.memoizedState;
|
|
if (nextState !== null) {
|
|
if (nextState.dehydrated !== null) {
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
var props = workInProgress2.memoizedProps;
|
|
if (props.fallback === void 0) {
|
|
return false;
|
|
}
|
|
if (props.unstable_avoidThisFallback !== true) {
|
|
return true;
|
|
}
|
|
if (hasInvisibleParent) {
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
function findFirstSuspended(row) {
|
|
var node = row;
|
|
while (node !== null) {
|
|
if (node.tag === SuspenseComponent) {
|
|
var state = node.memoizedState;
|
|
if (state !== null) {
|
|
var dehydrated = state.dehydrated;
|
|
if (dehydrated === null || isSuspenseInstancePending(dehydrated) || isSuspenseInstanceFallback(dehydrated)) {
|
|
return node;
|
|
}
|
|
}
|
|
} else if (node.tag === SuspenseListComponent && node.memoizedProps.revealOrder !== void 0) {
|
|
var didSuspend = (node.flags & DidCapture) !== NoFlags;
|
|
if (didSuspend) {
|
|
return node;
|
|
}
|
|
} else if (node.child !== null) {
|
|
node.child.return = node;
|
|
node = node.child;
|
|
continue;
|
|
}
|
|
if (node === row) {
|
|
return null;
|
|
}
|
|
while (node.sibling === null) {
|
|
if (node.return === null || node.return === row) {
|
|
return null;
|
|
}
|
|
node = node.return;
|
|
}
|
|
node.sibling.return = node.return;
|
|
node = node.sibling;
|
|
}
|
|
return null;
|
|
}
|
|
var NoFlags$1 = 0;
|
|
var HasEffect = 1;
|
|
var Layout = 2;
|
|
var Passive$1 = 4;
|
|
var hydrationParentFiber = null;
|
|
var nextHydratableInstance = null;
|
|
var isHydrating = false;
|
|
function enterHydrationState(fiber) {
|
|
var parentInstance = fiber.stateNode.containerInfo;
|
|
nextHydratableInstance = getFirstHydratableChild(parentInstance);
|
|
hydrationParentFiber = fiber;
|
|
isHydrating = true;
|
|
return true;
|
|
}
|
|
function deleteHydratableInstance(returnFiber, instance) {
|
|
{
|
|
switch (returnFiber.tag) {
|
|
case HostRoot:
|
|
didNotHydrateContainerInstance(returnFiber.stateNode.containerInfo, instance);
|
|
break;
|
|
case HostComponent:
|
|
didNotHydrateInstance(returnFiber.type, returnFiber.memoizedProps, returnFiber.stateNode, instance);
|
|
break;
|
|
}
|
|
}
|
|
var childToDelete = createFiberFromHostInstanceForDeletion();
|
|
childToDelete.stateNode = instance;
|
|
childToDelete.return = returnFiber;
|
|
childToDelete.flags = Deletion;
|
|
if (returnFiber.lastEffect !== null) {
|
|
returnFiber.lastEffect.nextEffect = childToDelete;
|
|
returnFiber.lastEffect = childToDelete;
|
|
} else {
|
|
returnFiber.firstEffect = returnFiber.lastEffect = childToDelete;
|
|
}
|
|
}
|
|
function insertNonHydratedInstance(returnFiber, fiber) {
|
|
fiber.flags = fiber.flags & ~Hydrating | Placement;
|
|
{
|
|
switch (returnFiber.tag) {
|
|
case HostRoot: {
|
|
var parentContainer = returnFiber.stateNode.containerInfo;
|
|
switch (fiber.tag) {
|
|
case HostComponent:
|
|
var type = fiber.type;
|
|
var props = fiber.pendingProps;
|
|
didNotFindHydratableContainerInstance(parentContainer, type);
|
|
break;
|
|
case HostText:
|
|
var text = fiber.pendingProps;
|
|
didNotFindHydratableContainerTextInstance(parentContainer, text);
|
|
break;
|
|
}
|
|
break;
|
|
}
|
|
case HostComponent: {
|
|
var parentType = returnFiber.type;
|
|
var parentProps = returnFiber.memoizedProps;
|
|
var parentInstance = returnFiber.stateNode;
|
|
switch (fiber.tag) {
|
|
case HostComponent:
|
|
var _type = fiber.type;
|
|
var _props = fiber.pendingProps;
|
|
didNotFindHydratableInstance(parentType, parentProps, parentInstance, _type);
|
|
break;
|
|
case HostText:
|
|
var _text = fiber.pendingProps;
|
|
didNotFindHydratableTextInstance(parentType, parentProps, parentInstance, _text);
|
|
break;
|
|
case SuspenseComponent:
|
|
didNotFindHydratableSuspenseInstance(parentType, parentProps);
|
|
break;
|
|
}
|
|
break;
|
|
}
|
|
default:
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
function tryHydrate(fiber, nextInstance) {
|
|
switch (fiber.tag) {
|
|
case HostComponent: {
|
|
var type = fiber.type;
|
|
var props = fiber.pendingProps;
|
|
var instance = canHydrateInstance(nextInstance, type);
|
|
if (instance !== null) {
|
|
fiber.stateNode = instance;
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
case HostText: {
|
|
var text = fiber.pendingProps;
|
|
var textInstance = canHydrateTextInstance(nextInstance, text);
|
|
if (textInstance !== null) {
|
|
fiber.stateNode = textInstance;
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
case SuspenseComponent: {
|
|
return false;
|
|
}
|
|
default:
|
|
return false;
|
|
}
|
|
}
|
|
function tryToClaimNextHydratableInstance(fiber) {
|
|
if (!isHydrating) {
|
|
return;
|
|
}
|
|
var nextInstance = nextHydratableInstance;
|
|
if (!nextInstance) {
|
|
insertNonHydratedInstance(hydrationParentFiber, fiber);
|
|
isHydrating = false;
|
|
hydrationParentFiber = fiber;
|
|
return;
|
|
}
|
|
var firstAttemptedInstance = nextInstance;
|
|
if (!tryHydrate(fiber, nextInstance)) {
|
|
nextInstance = getNextHydratableSibling(firstAttemptedInstance);
|
|
if (!nextInstance || !tryHydrate(fiber, nextInstance)) {
|
|
insertNonHydratedInstance(hydrationParentFiber, fiber);
|
|
isHydrating = false;
|
|
hydrationParentFiber = fiber;
|
|
return;
|
|
}
|
|
deleteHydratableInstance(hydrationParentFiber, firstAttemptedInstance);
|
|
}
|
|
hydrationParentFiber = fiber;
|
|
nextHydratableInstance = getFirstHydratableChild(nextInstance);
|
|
}
|
|
function prepareToHydrateHostInstance(fiber, rootContainerInstance, hostContext) {
|
|
var instance = fiber.stateNode;
|
|
var updatePayload = hydrateInstance(instance, fiber.type, fiber.memoizedProps, rootContainerInstance, hostContext, fiber);
|
|
fiber.updateQueue = updatePayload;
|
|
if (updatePayload !== null) {
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
function prepareToHydrateHostTextInstance(fiber) {
|
|
var textInstance = fiber.stateNode;
|
|
var textContent = fiber.memoizedProps;
|
|
var shouldUpdate = hydrateTextInstance(textInstance, textContent, fiber);
|
|
{
|
|
if (shouldUpdate) {
|
|
var returnFiber = hydrationParentFiber;
|
|
if (returnFiber !== null) {
|
|
switch (returnFiber.tag) {
|
|
case HostRoot: {
|
|
var parentContainer = returnFiber.stateNode.containerInfo;
|
|
didNotMatchHydratedContainerTextInstance(parentContainer, textInstance, textContent);
|
|
break;
|
|
}
|
|
case HostComponent: {
|
|
var parentType = returnFiber.type;
|
|
var parentProps = returnFiber.memoizedProps;
|
|
var parentInstance = returnFiber.stateNode;
|
|
didNotMatchHydratedTextInstance(parentType, parentProps, parentInstance, textInstance, textContent);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return shouldUpdate;
|
|
}
|
|
function skipPastDehydratedSuspenseInstance(fiber) {
|
|
var suspenseState = fiber.memoizedState;
|
|
var suspenseInstance = suspenseState !== null ? suspenseState.dehydrated : null;
|
|
if (!suspenseInstance) {
|
|
{
|
|
throw Error("Expected to have a hydrated suspense instance. This error is likely caused by a bug in React. Please file an issue.");
|
|
}
|
|
}
|
|
return getNextHydratableInstanceAfterSuspenseInstance(suspenseInstance);
|
|
}
|
|
function popToNextHostParent(fiber) {
|
|
var parent = fiber.return;
|
|
while (parent !== null && parent.tag !== HostComponent && parent.tag !== HostRoot && parent.tag !== SuspenseComponent) {
|
|
parent = parent.return;
|
|
}
|
|
hydrationParentFiber = parent;
|
|
}
|
|
function popHydrationState(fiber) {
|
|
if (fiber !== hydrationParentFiber) {
|
|
return false;
|
|
}
|
|
if (!isHydrating) {
|
|
popToNextHostParent(fiber);
|
|
isHydrating = true;
|
|
return false;
|
|
}
|
|
var type = fiber.type;
|
|
if (fiber.tag !== HostComponent || type !== "head" && type !== "body" && !shouldSetTextContent(type, fiber.memoizedProps)) {
|
|
var nextInstance = nextHydratableInstance;
|
|
while (nextInstance) {
|
|
deleteHydratableInstance(fiber, nextInstance);
|
|
nextInstance = getNextHydratableSibling(nextInstance);
|
|
}
|
|
}
|
|
popToNextHostParent(fiber);
|
|
if (fiber.tag === SuspenseComponent) {
|
|
nextHydratableInstance = skipPastDehydratedSuspenseInstance(fiber);
|
|
} else {
|
|
nextHydratableInstance = hydrationParentFiber ? getNextHydratableSibling(fiber.stateNode) : null;
|
|
}
|
|
return true;
|
|
}
|
|
function resetHydrationState() {
|
|
hydrationParentFiber = null;
|
|
nextHydratableInstance = null;
|
|
isHydrating = false;
|
|
}
|
|
function getIsHydrating() {
|
|
return isHydrating;
|
|
}
|
|
var workInProgressSources = [];
|
|
var rendererSigil$1;
|
|
{
|
|
rendererSigil$1 = {};
|
|
}
|
|
function markSourceAsDirty(mutableSource) {
|
|
workInProgressSources.push(mutableSource);
|
|
}
|
|
function resetWorkInProgressVersions() {
|
|
for (var i3 = 0; i3 < workInProgressSources.length; i3++) {
|
|
var mutableSource = workInProgressSources[i3];
|
|
{
|
|
mutableSource._workInProgressVersionPrimary = null;
|
|
}
|
|
}
|
|
workInProgressSources.length = 0;
|
|
}
|
|
function getWorkInProgressVersion(mutableSource) {
|
|
{
|
|
return mutableSource._workInProgressVersionPrimary;
|
|
}
|
|
}
|
|
function setWorkInProgressVersion(mutableSource, version) {
|
|
{
|
|
mutableSource._workInProgressVersionPrimary = version;
|
|
}
|
|
workInProgressSources.push(mutableSource);
|
|
}
|
|
function warnAboutMultipleRenderersDEV(mutableSource) {
|
|
{
|
|
{
|
|
if (mutableSource._currentPrimaryRenderer == null) {
|
|
mutableSource._currentPrimaryRenderer = rendererSigil$1;
|
|
} else if (mutableSource._currentPrimaryRenderer !== rendererSigil$1) {
|
|
error("Detected multiple renderers concurrently rendering the same mutable source. This is currently unsupported.");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
var ReactCurrentDispatcher$1 = ReactSharedInternals.ReactCurrentDispatcher, ReactCurrentBatchConfig$1 = ReactSharedInternals.ReactCurrentBatchConfig;
|
|
var didWarnAboutMismatchedHooksForComponent;
|
|
var didWarnAboutUseOpaqueIdentifier;
|
|
{
|
|
didWarnAboutUseOpaqueIdentifier = {};
|
|
didWarnAboutMismatchedHooksForComponent = new Set();
|
|
}
|
|
var renderLanes = NoLanes;
|
|
var currentlyRenderingFiber$1 = null;
|
|
var currentHook = null;
|
|
var workInProgressHook = null;
|
|
var didScheduleRenderPhaseUpdate = false;
|
|
var didScheduleRenderPhaseUpdateDuringThisPass = false;
|
|
var RE_RENDER_LIMIT = 25;
|
|
var currentHookNameInDev = null;
|
|
var hookTypesDev = null;
|
|
var hookTypesUpdateIndexDev = -1;
|
|
var ignorePreviousDependencies = false;
|
|
function mountHookTypesDev() {
|
|
{
|
|
var hookName = currentHookNameInDev;
|
|
if (hookTypesDev === null) {
|
|
hookTypesDev = [hookName];
|
|
} else {
|
|
hookTypesDev.push(hookName);
|
|
}
|
|
}
|
|
}
|
|
function updateHookTypesDev() {
|
|
{
|
|
var hookName = currentHookNameInDev;
|
|
if (hookTypesDev !== null) {
|
|
hookTypesUpdateIndexDev++;
|
|
if (hookTypesDev[hookTypesUpdateIndexDev] !== hookName) {
|
|
warnOnHookMismatchInDev(hookName);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
function checkDepsAreArrayDev(deps) {
|
|
{
|
|
if (deps !== void 0 && deps !== null && !Array.isArray(deps)) {
|
|
error("%s received a final argument that is not an array (instead, received `%s`). When specified, the final argument must be an array.", currentHookNameInDev, typeof deps);
|
|
}
|
|
}
|
|
}
|
|
function warnOnHookMismatchInDev(currentHookName) {
|
|
{
|
|
var componentName = getComponentName(currentlyRenderingFiber$1.type);
|
|
if (!didWarnAboutMismatchedHooksForComponent.has(componentName)) {
|
|
didWarnAboutMismatchedHooksForComponent.add(componentName);
|
|
if (hookTypesDev !== null) {
|
|
var table = "";
|
|
var secondColumnStart = 30;
|
|
for (var i3 = 0; i3 <= hookTypesUpdateIndexDev; i3++) {
|
|
var oldHookName = hookTypesDev[i3];
|
|
var newHookName = i3 === hookTypesUpdateIndexDev ? currentHookName : oldHookName;
|
|
var row = i3 + 1 + ". " + oldHookName;
|
|
while (row.length < secondColumnStart) {
|
|
row += " ";
|
|
}
|
|
row += newHookName + "\n";
|
|
table += row;
|
|
}
|
|
error("React has detected a change in the order of Hooks called by %s. This will lead to bugs and errors if not fixed. For more information, read the Rules of Hooks: https://reactjs.org/link/rules-of-hooks\n\n Previous render Next render\n ------------------------------------------------------\n%s ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", componentName, table);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
function throwInvalidHookError() {
|
|
{
|
|
{
|
|
throw Error("Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:\n1. You might have mismatching versions of React and the renderer (such as React DOM)\n2. You might be breaking the Rules of Hooks\n3. You might have more than one copy of React in the same app\nSee https://reactjs.org/link/invalid-hook-call for tips about how to debug and fix this problem.");
|
|
}
|
|
}
|
|
}
|
|
function areHookInputsEqual(nextDeps, prevDeps) {
|
|
{
|
|
if (ignorePreviousDependencies) {
|
|
return false;
|
|
}
|
|
}
|
|
if (prevDeps === null) {
|
|
{
|
|
error("%s received a final argument during this render, but not during the previous render. Even though the final argument is optional, its type cannot change between renders.", currentHookNameInDev);
|
|
}
|
|
return false;
|
|
}
|
|
{
|
|
if (nextDeps.length !== prevDeps.length) {
|
|
error("The final argument passed to %s changed size between renders. The order and size of this array must remain constant.\n\nPrevious: %s\nIncoming: %s", currentHookNameInDev, "[" + prevDeps.join(", ") + "]", "[" + nextDeps.join(", ") + "]");
|
|
}
|
|
}
|
|
for (var i3 = 0; i3 < prevDeps.length && i3 < nextDeps.length; i3++) {
|
|
if (objectIs(nextDeps[i3], prevDeps[i3])) {
|
|
continue;
|
|
}
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
function renderWithHooks(current2, workInProgress2, Component5, props, secondArg, nextRenderLanes) {
|
|
renderLanes = nextRenderLanes;
|
|
currentlyRenderingFiber$1 = workInProgress2;
|
|
{
|
|
hookTypesDev = current2 !== null ? current2._debugHookTypes : null;
|
|
hookTypesUpdateIndexDev = -1;
|
|
ignorePreviousDependencies = current2 !== null && current2.type !== workInProgress2.type;
|
|
}
|
|
workInProgress2.memoizedState = null;
|
|
workInProgress2.updateQueue = null;
|
|
workInProgress2.lanes = NoLanes;
|
|
{
|
|
if (current2 !== null && current2.memoizedState !== null) {
|
|
ReactCurrentDispatcher$1.current = HooksDispatcherOnUpdateInDEV;
|
|
} else if (hookTypesDev !== null) {
|
|
ReactCurrentDispatcher$1.current = HooksDispatcherOnMountWithHookTypesInDEV;
|
|
} else {
|
|
ReactCurrentDispatcher$1.current = HooksDispatcherOnMountInDEV;
|
|
}
|
|
}
|
|
var children = Component5(props, secondArg);
|
|
if (didScheduleRenderPhaseUpdateDuringThisPass) {
|
|
var numberOfReRenders = 0;
|
|
do {
|
|
didScheduleRenderPhaseUpdateDuringThisPass = false;
|
|
if (!(numberOfReRenders < RE_RENDER_LIMIT)) {
|
|
{
|
|
throw Error("Too many re-renders. React limits the number of renders to prevent an infinite loop.");
|
|
}
|
|
}
|
|
numberOfReRenders += 1;
|
|
{
|
|
ignorePreviousDependencies = false;
|
|
}
|
|
currentHook = null;
|
|
workInProgressHook = null;
|
|
workInProgress2.updateQueue = null;
|
|
{
|
|
hookTypesUpdateIndexDev = -1;
|
|
}
|
|
ReactCurrentDispatcher$1.current = HooksDispatcherOnRerenderInDEV;
|
|
children = Component5(props, secondArg);
|
|
} while (didScheduleRenderPhaseUpdateDuringThisPass);
|
|
}
|
|
ReactCurrentDispatcher$1.current = ContextOnlyDispatcher;
|
|
{
|
|
workInProgress2._debugHookTypes = hookTypesDev;
|
|
}
|
|
var didRenderTooFewHooks = currentHook !== null && currentHook.next !== null;
|
|
renderLanes = NoLanes;
|
|
currentlyRenderingFiber$1 = null;
|
|
currentHook = null;
|
|
workInProgressHook = null;
|
|
{
|
|
currentHookNameInDev = null;
|
|
hookTypesDev = null;
|
|
hookTypesUpdateIndexDev = -1;
|
|
}
|
|
didScheduleRenderPhaseUpdate = false;
|
|
if (!!didRenderTooFewHooks) {
|
|
{
|
|
throw Error("Rendered fewer hooks than expected. This may be caused by an accidental early return statement.");
|
|
}
|
|
}
|
|
return children;
|
|
}
|
|
function bailoutHooks(current2, workInProgress2, lanes) {
|
|
workInProgress2.updateQueue = current2.updateQueue;
|
|
workInProgress2.flags &= ~(Passive | Update);
|
|
current2.lanes = removeLanes(current2.lanes, lanes);
|
|
}
|
|
function resetHooksAfterThrow() {
|
|
ReactCurrentDispatcher$1.current = ContextOnlyDispatcher;
|
|
if (didScheduleRenderPhaseUpdate) {
|
|
var hook = currentlyRenderingFiber$1.memoizedState;
|
|
while (hook !== null) {
|
|
var queue = hook.queue;
|
|
if (queue !== null) {
|
|
queue.pending = null;
|
|
}
|
|
hook = hook.next;
|
|
}
|
|
didScheduleRenderPhaseUpdate = false;
|
|
}
|
|
renderLanes = NoLanes;
|
|
currentlyRenderingFiber$1 = null;
|
|
currentHook = null;
|
|
workInProgressHook = null;
|
|
{
|
|
hookTypesDev = null;
|
|
hookTypesUpdateIndexDev = -1;
|
|
currentHookNameInDev = null;
|
|
isUpdatingOpaqueValueInRenderPhase = false;
|
|
}
|
|
didScheduleRenderPhaseUpdateDuringThisPass = false;
|
|
}
|
|
function mountWorkInProgressHook() {
|
|
var hook = {
|
|
memoizedState: null,
|
|
baseState: null,
|
|
baseQueue: null,
|
|
queue: null,
|
|
next: null
|
|
};
|
|
if (workInProgressHook === null) {
|
|
currentlyRenderingFiber$1.memoizedState = workInProgressHook = hook;
|
|
} else {
|
|
workInProgressHook = workInProgressHook.next = hook;
|
|
}
|
|
return workInProgressHook;
|
|
}
|
|
function updateWorkInProgressHook() {
|
|
var nextCurrentHook;
|
|
if (currentHook === null) {
|
|
var current2 = currentlyRenderingFiber$1.alternate;
|
|
if (current2 !== null) {
|
|
nextCurrentHook = current2.memoizedState;
|
|
} else {
|
|
nextCurrentHook = null;
|
|
}
|
|
} else {
|
|
nextCurrentHook = currentHook.next;
|
|
}
|
|
var nextWorkInProgressHook;
|
|
if (workInProgressHook === null) {
|
|
nextWorkInProgressHook = currentlyRenderingFiber$1.memoizedState;
|
|
} else {
|
|
nextWorkInProgressHook = workInProgressHook.next;
|
|
}
|
|
if (nextWorkInProgressHook !== null) {
|
|
workInProgressHook = nextWorkInProgressHook;
|
|
nextWorkInProgressHook = workInProgressHook.next;
|
|
currentHook = nextCurrentHook;
|
|
} else {
|
|
if (!(nextCurrentHook !== null)) {
|
|
{
|
|
throw Error("Rendered more hooks than during the previous render.");
|
|
}
|
|
}
|
|
currentHook = nextCurrentHook;
|
|
var newHook = {
|
|
memoizedState: currentHook.memoizedState,
|
|
baseState: currentHook.baseState,
|
|
baseQueue: currentHook.baseQueue,
|
|
queue: currentHook.queue,
|
|
next: null
|
|
};
|
|
if (workInProgressHook === null) {
|
|
currentlyRenderingFiber$1.memoizedState = workInProgressHook = newHook;
|
|
} else {
|
|
workInProgressHook = workInProgressHook.next = newHook;
|
|
}
|
|
}
|
|
return workInProgressHook;
|
|
}
|
|
function createFunctionComponentUpdateQueue() {
|
|
return {
|
|
lastEffect: null
|
|
};
|
|
}
|
|
function basicStateReducer(state, action) {
|
|
return typeof action === "function" ? action(state) : action;
|
|
}
|
|
function mountReducer(reducer, initialArg, init) {
|
|
var hook = mountWorkInProgressHook();
|
|
var initialState;
|
|
if (init !== void 0) {
|
|
initialState = init(initialArg);
|
|
} else {
|
|
initialState = initialArg;
|
|
}
|
|
hook.memoizedState = hook.baseState = initialState;
|
|
var queue = hook.queue = {
|
|
pending: null,
|
|
dispatch: null,
|
|
lastRenderedReducer: reducer,
|
|
lastRenderedState: initialState
|
|
};
|
|
var dispatch = queue.dispatch = dispatchAction.bind(null, currentlyRenderingFiber$1, queue);
|
|
return [hook.memoizedState, dispatch];
|
|
}
|
|
function updateReducer(reducer, initialArg, init) {
|
|
var hook = updateWorkInProgressHook();
|
|
var queue = hook.queue;
|
|
if (!(queue !== null)) {
|
|
{
|
|
throw Error("Should have a queue. This is likely a bug in React. Please file an issue.");
|
|
}
|
|
}
|
|
queue.lastRenderedReducer = reducer;
|
|
var current2 = currentHook;
|
|
var baseQueue = current2.baseQueue;
|
|
var pendingQueue = queue.pending;
|
|
if (pendingQueue !== null) {
|
|
if (baseQueue !== null) {
|
|
var baseFirst = baseQueue.next;
|
|
var pendingFirst = pendingQueue.next;
|
|
baseQueue.next = pendingFirst;
|
|
pendingQueue.next = baseFirst;
|
|
}
|
|
{
|
|
if (current2.baseQueue !== baseQueue) {
|
|
error("Internal error: Expected work-in-progress queue to be a clone. This is a bug in React.");
|
|
}
|
|
}
|
|
current2.baseQueue = baseQueue = pendingQueue;
|
|
queue.pending = null;
|
|
}
|
|
if (baseQueue !== null) {
|
|
var first = baseQueue.next;
|
|
var newState = current2.baseState;
|
|
var newBaseState = null;
|
|
var newBaseQueueFirst = null;
|
|
var newBaseQueueLast = null;
|
|
var update = first;
|
|
do {
|
|
var updateLane = update.lane;
|
|
if (!isSubsetOfLanes(renderLanes, updateLane)) {
|
|
var clone = {
|
|
lane: updateLane,
|
|
action: update.action,
|
|
eagerReducer: update.eagerReducer,
|
|
eagerState: update.eagerState,
|
|
next: null
|
|
};
|
|
if (newBaseQueueLast === null) {
|
|
newBaseQueueFirst = newBaseQueueLast = clone;
|
|
newBaseState = newState;
|
|
} else {
|
|
newBaseQueueLast = newBaseQueueLast.next = clone;
|
|
}
|
|
currentlyRenderingFiber$1.lanes = mergeLanes(currentlyRenderingFiber$1.lanes, updateLane);
|
|
markSkippedUpdateLanes(updateLane);
|
|
} else {
|
|
if (newBaseQueueLast !== null) {
|
|
var _clone = {
|
|
lane: NoLane,
|
|
action: update.action,
|
|
eagerReducer: update.eagerReducer,
|
|
eagerState: update.eagerState,
|
|
next: null
|
|
};
|
|
newBaseQueueLast = newBaseQueueLast.next = _clone;
|
|
}
|
|
if (update.eagerReducer === reducer) {
|
|
newState = update.eagerState;
|
|
} else {
|
|
var action = update.action;
|
|
newState = reducer(newState, action);
|
|
}
|
|
}
|
|
update = update.next;
|
|
} while (update !== null && update !== first);
|
|
if (newBaseQueueLast === null) {
|
|
newBaseState = newState;
|
|
} else {
|
|
newBaseQueueLast.next = newBaseQueueFirst;
|
|
}
|
|
if (!objectIs(newState, hook.memoizedState)) {
|
|
markWorkInProgressReceivedUpdate();
|
|
}
|
|
hook.memoizedState = newState;
|
|
hook.baseState = newBaseState;
|
|
hook.baseQueue = newBaseQueueLast;
|
|
queue.lastRenderedState = newState;
|
|
}
|
|
var dispatch = queue.dispatch;
|
|
return [hook.memoizedState, dispatch];
|
|
}
|
|
function rerenderReducer(reducer, initialArg, init) {
|
|
var hook = updateWorkInProgressHook();
|
|
var queue = hook.queue;
|
|
if (!(queue !== null)) {
|
|
{
|
|
throw Error("Should have a queue. This is likely a bug in React. Please file an issue.");
|
|
}
|
|
}
|
|
queue.lastRenderedReducer = reducer;
|
|
var dispatch = queue.dispatch;
|
|
var lastRenderPhaseUpdate = queue.pending;
|
|
var newState = hook.memoizedState;
|
|
if (lastRenderPhaseUpdate !== null) {
|
|
queue.pending = null;
|
|
var firstRenderPhaseUpdate = lastRenderPhaseUpdate.next;
|
|
var update = firstRenderPhaseUpdate;
|
|
do {
|
|
var action = update.action;
|
|
newState = reducer(newState, action);
|
|
update = update.next;
|
|
} while (update !== firstRenderPhaseUpdate);
|
|
if (!objectIs(newState, hook.memoizedState)) {
|
|
markWorkInProgressReceivedUpdate();
|
|
}
|
|
hook.memoizedState = newState;
|
|
if (hook.baseQueue === null) {
|
|
hook.baseState = newState;
|
|
}
|
|
queue.lastRenderedState = newState;
|
|
}
|
|
return [newState, dispatch];
|
|
}
|
|
function readFromUnsubcribedMutableSource(root2, source, getSnapshot) {
|
|
{
|
|
warnAboutMultipleRenderersDEV(source);
|
|
}
|
|
var getVersion = source._getVersion;
|
|
var version = getVersion(source._source);
|
|
var isSafeToReadFromSource = false;
|
|
var currentRenderVersion = getWorkInProgressVersion(source);
|
|
if (currentRenderVersion !== null) {
|
|
isSafeToReadFromSource = currentRenderVersion === version;
|
|
} else {
|
|
isSafeToReadFromSource = isSubsetOfLanes(renderLanes, root2.mutableReadLanes);
|
|
if (isSafeToReadFromSource) {
|
|
setWorkInProgressVersion(source, version);
|
|
}
|
|
}
|
|
if (isSafeToReadFromSource) {
|
|
var snapshot = getSnapshot(source._source);
|
|
{
|
|
if (typeof snapshot === "function") {
|
|
error("Mutable source should not return a function as the snapshot value. Functions may close over mutable values and cause tearing.");
|
|
}
|
|
}
|
|
return snapshot;
|
|
} else {
|
|
markSourceAsDirty(source);
|
|
{
|
|
{
|
|
throw Error("Cannot read from mutable source during the current render without tearing. This is a bug in React. Please file an issue.");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
function useMutableSource(hook, source, getSnapshot, subscribe) {
|
|
var root2 = getWorkInProgressRoot();
|
|
if (!(root2 !== null)) {
|
|
{
|
|
throw Error("Expected a work-in-progress root. This is a bug in React. Please file an issue.");
|
|
}
|
|
}
|
|
var getVersion = source._getVersion;
|
|
var version = getVersion(source._source);
|
|
var dispatcher = ReactCurrentDispatcher$1.current;
|
|
var _dispatcher$useState = dispatcher.useState(function() {
|
|
return readFromUnsubcribedMutableSource(root2, source, getSnapshot);
|
|
}), currentSnapshot = _dispatcher$useState[0], setSnapshot = _dispatcher$useState[1];
|
|
var snapshot = currentSnapshot;
|
|
var stateHook = workInProgressHook;
|
|
var memoizedState = hook.memoizedState;
|
|
var refs = memoizedState.refs;
|
|
var prevGetSnapshot = refs.getSnapshot;
|
|
var prevSource = memoizedState.source;
|
|
var prevSubscribe = memoizedState.subscribe;
|
|
var fiber = currentlyRenderingFiber$1;
|
|
hook.memoizedState = {
|
|
refs,
|
|
source,
|
|
subscribe
|
|
};
|
|
dispatcher.useEffect(function() {
|
|
refs.getSnapshot = getSnapshot;
|
|
refs.setSnapshot = setSnapshot;
|
|
var maybeNewVersion = getVersion(source._source);
|
|
if (!objectIs(version, maybeNewVersion)) {
|
|
var maybeNewSnapshot = getSnapshot(source._source);
|
|
{
|
|
if (typeof maybeNewSnapshot === "function") {
|
|
error("Mutable source should not return a function as the snapshot value. Functions may close over mutable values and cause tearing.");
|
|
}
|
|
}
|
|
if (!objectIs(snapshot, maybeNewSnapshot)) {
|
|
setSnapshot(maybeNewSnapshot);
|
|
var lane = requestUpdateLane(fiber);
|
|
markRootMutableRead(root2, lane);
|
|
}
|
|
markRootEntangled(root2, root2.mutableReadLanes);
|
|
}
|
|
}, [getSnapshot, source, subscribe]);
|
|
dispatcher.useEffect(function() {
|
|
var handleChange = function() {
|
|
var latestGetSnapshot = refs.getSnapshot;
|
|
var latestSetSnapshot = refs.setSnapshot;
|
|
try {
|
|
latestSetSnapshot(latestGetSnapshot(source._source));
|
|
var lane = requestUpdateLane(fiber);
|
|
markRootMutableRead(root2, lane);
|
|
} catch (error2) {
|
|
latestSetSnapshot(function() {
|
|
throw error2;
|
|
});
|
|
}
|
|
};
|
|
var unsubscribe = subscribe(source._source, handleChange);
|
|
{
|
|
if (typeof unsubscribe !== "function") {
|
|
error("Mutable source subscribe function must return an unsubscribe function.");
|
|
}
|
|
}
|
|
return unsubscribe;
|
|
}, [source, subscribe]);
|
|
if (!objectIs(prevGetSnapshot, getSnapshot) || !objectIs(prevSource, source) || !objectIs(prevSubscribe, subscribe)) {
|
|
var newQueue = {
|
|
pending: null,
|
|
dispatch: null,
|
|
lastRenderedReducer: basicStateReducer,
|
|
lastRenderedState: snapshot
|
|
};
|
|
newQueue.dispatch = setSnapshot = dispatchAction.bind(null, currentlyRenderingFiber$1, newQueue);
|
|
stateHook.queue = newQueue;
|
|
stateHook.baseQueue = null;
|
|
snapshot = readFromUnsubcribedMutableSource(root2, source, getSnapshot);
|
|
stateHook.memoizedState = stateHook.baseState = snapshot;
|
|
}
|
|
return snapshot;
|
|
}
|
|
function mountMutableSource(source, getSnapshot, subscribe) {
|
|
var hook = mountWorkInProgressHook();
|
|
hook.memoizedState = {
|
|
refs: {
|
|
getSnapshot,
|
|
setSnapshot: null
|
|
},
|
|
source,
|
|
subscribe
|
|
};
|
|
return useMutableSource(hook, source, getSnapshot, subscribe);
|
|
}
|
|
function updateMutableSource(source, getSnapshot, subscribe) {
|
|
var hook = updateWorkInProgressHook();
|
|
return useMutableSource(hook, source, getSnapshot, subscribe);
|
|
}
|
|
function mountState(initialState) {
|
|
var hook = mountWorkInProgressHook();
|
|
if (typeof initialState === "function") {
|
|
initialState = initialState();
|
|
}
|
|
hook.memoizedState = hook.baseState = initialState;
|
|
var queue = hook.queue = {
|
|
pending: null,
|
|
dispatch: null,
|
|
lastRenderedReducer: basicStateReducer,
|
|
lastRenderedState: initialState
|
|
};
|
|
var dispatch = queue.dispatch = dispatchAction.bind(null, currentlyRenderingFiber$1, queue);
|
|
return [hook.memoizedState, dispatch];
|
|
}
|
|
function updateState(initialState) {
|
|
return updateReducer(basicStateReducer);
|
|
}
|
|
function rerenderState(initialState) {
|
|
return rerenderReducer(basicStateReducer);
|
|
}
|
|
function pushEffect(tag, create, destroy, deps) {
|
|
var effect = {
|
|
tag,
|
|
create,
|
|
destroy,
|
|
deps,
|
|
next: null
|
|
};
|
|
var componentUpdateQueue = currentlyRenderingFiber$1.updateQueue;
|
|
if (componentUpdateQueue === null) {
|
|
componentUpdateQueue = createFunctionComponentUpdateQueue();
|
|
currentlyRenderingFiber$1.updateQueue = componentUpdateQueue;
|
|
componentUpdateQueue.lastEffect = effect.next = effect;
|
|
} else {
|
|
var lastEffect = componentUpdateQueue.lastEffect;
|
|
if (lastEffect === null) {
|
|
componentUpdateQueue.lastEffect = effect.next = effect;
|
|
} else {
|
|
var firstEffect = lastEffect.next;
|
|
lastEffect.next = effect;
|
|
effect.next = firstEffect;
|
|
componentUpdateQueue.lastEffect = effect;
|
|
}
|
|
}
|
|
return effect;
|
|
}
|
|
function mountRef(initialValue) {
|
|
var hook = mountWorkInProgressHook();
|
|
var ref = {
|
|
current: initialValue
|
|
};
|
|
{
|
|
Object.seal(ref);
|
|
}
|
|
hook.memoizedState = ref;
|
|
return ref;
|
|
}
|
|
function updateRef(initialValue) {
|
|
var hook = updateWorkInProgressHook();
|
|
return hook.memoizedState;
|
|
}
|
|
function mountEffectImpl(fiberFlags, hookFlags, create, deps) {
|
|
var hook = mountWorkInProgressHook();
|
|
var nextDeps = deps === void 0 ? null : deps;
|
|
currentlyRenderingFiber$1.flags |= fiberFlags;
|
|
hook.memoizedState = pushEffect(HasEffect | hookFlags, create, void 0, nextDeps);
|
|
}
|
|
function updateEffectImpl(fiberFlags, hookFlags, create, deps) {
|
|
var hook = updateWorkInProgressHook();
|
|
var nextDeps = deps === void 0 ? null : deps;
|
|
var destroy = void 0;
|
|
if (currentHook !== null) {
|
|
var prevEffect = currentHook.memoizedState;
|
|
destroy = prevEffect.destroy;
|
|
if (nextDeps !== null) {
|
|
var prevDeps = prevEffect.deps;
|
|
if (areHookInputsEqual(nextDeps, prevDeps)) {
|
|
pushEffect(hookFlags, create, destroy, nextDeps);
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
currentlyRenderingFiber$1.flags |= fiberFlags;
|
|
hook.memoizedState = pushEffect(HasEffect | hookFlags, create, destroy, nextDeps);
|
|
}
|
|
function mountEffect(create, deps) {
|
|
{
|
|
if (typeof jest !== "undefined") {
|
|
warnIfNotCurrentlyActingEffectsInDEV(currentlyRenderingFiber$1);
|
|
}
|
|
}
|
|
return mountEffectImpl(Update | Passive, Passive$1, create, deps);
|
|
}
|
|
function updateEffect(create, deps) {
|
|
{
|
|
if (typeof jest !== "undefined") {
|
|
warnIfNotCurrentlyActingEffectsInDEV(currentlyRenderingFiber$1);
|
|
}
|
|
}
|
|
return updateEffectImpl(Update | Passive, Passive$1, create, deps);
|
|
}
|
|
function mountLayoutEffect(create, deps) {
|
|
return mountEffectImpl(Update, Layout, create, deps);
|
|
}
|
|
function updateLayoutEffect(create, deps) {
|
|
return updateEffectImpl(Update, Layout, create, deps);
|
|
}
|
|
function imperativeHandleEffect(create, ref) {
|
|
if (typeof ref === "function") {
|
|
var refCallback = ref;
|
|
var _inst = create();
|
|
refCallback(_inst);
|
|
return function() {
|
|
refCallback(null);
|
|
};
|
|
} else if (ref !== null && ref !== void 0) {
|
|
var refObject = ref;
|
|
{
|
|
if (!refObject.hasOwnProperty("current")) {
|
|
error("Expected useImperativeHandle() first argument to either be a ref callback or React.createRef() object. Instead received: %s.", "an object with keys {" + Object.keys(refObject).join(", ") + "}");
|
|
}
|
|
}
|
|
var _inst2 = create();
|
|
refObject.current = _inst2;
|
|
return function() {
|
|
refObject.current = null;
|
|
};
|
|
}
|
|
}
|
|
function mountImperativeHandle(ref, create, deps) {
|
|
{
|
|
if (typeof create !== "function") {
|
|
error("Expected useImperativeHandle() second argument to be a function that creates a handle. Instead received: %s.", create !== null ? typeof create : "null");
|
|
}
|
|
}
|
|
var effectDeps = deps !== null && deps !== void 0 ? deps.concat([ref]) : null;
|
|
return mountEffectImpl(Update, Layout, imperativeHandleEffect.bind(null, create, ref), effectDeps);
|
|
}
|
|
function updateImperativeHandle(ref, create, deps) {
|
|
{
|
|
if (typeof create !== "function") {
|
|
error("Expected useImperativeHandle() second argument to be a function that creates a handle. Instead received: %s.", create !== null ? typeof create : "null");
|
|
}
|
|
}
|
|
var effectDeps = deps !== null && deps !== void 0 ? deps.concat([ref]) : null;
|
|
return updateEffectImpl(Update, Layout, imperativeHandleEffect.bind(null, create, ref), effectDeps);
|
|
}
|
|
function mountDebugValue(value, formatterFn) {
|
|
}
|
|
var updateDebugValue = mountDebugValue;
|
|
function mountCallback(callback, deps) {
|
|
var hook = mountWorkInProgressHook();
|
|
var nextDeps = deps === void 0 ? null : deps;
|
|
hook.memoizedState = [callback, nextDeps];
|
|
return callback;
|
|
}
|
|
function updateCallback(callback, deps) {
|
|
var hook = updateWorkInProgressHook();
|
|
var nextDeps = deps === void 0 ? null : deps;
|
|
var prevState = hook.memoizedState;
|
|
if (prevState !== null) {
|
|
if (nextDeps !== null) {
|
|
var prevDeps = prevState[1];
|
|
if (areHookInputsEqual(nextDeps, prevDeps)) {
|
|
return prevState[0];
|
|
}
|
|
}
|
|
}
|
|
hook.memoizedState = [callback, nextDeps];
|
|
return callback;
|
|
}
|
|
function mountMemo(nextCreate, deps) {
|
|
var hook = mountWorkInProgressHook();
|
|
var nextDeps = deps === void 0 ? null : deps;
|
|
var nextValue = nextCreate();
|
|
hook.memoizedState = [nextValue, nextDeps];
|
|
return nextValue;
|
|
}
|
|
function updateMemo(nextCreate, deps) {
|
|
var hook = updateWorkInProgressHook();
|
|
var nextDeps = deps === void 0 ? null : deps;
|
|
var prevState = hook.memoizedState;
|
|
if (prevState !== null) {
|
|
if (nextDeps !== null) {
|
|
var prevDeps = prevState[1];
|
|
if (areHookInputsEqual(nextDeps, prevDeps)) {
|
|
return prevState[0];
|
|
}
|
|
}
|
|
}
|
|
var nextValue = nextCreate();
|
|
hook.memoizedState = [nextValue, nextDeps];
|
|
return nextValue;
|
|
}
|
|
function mountDeferredValue(value) {
|
|
var _mountState = mountState(value), prevValue = _mountState[0], setValue = _mountState[1];
|
|
mountEffect(function() {
|
|
var prevTransition = ReactCurrentBatchConfig$1.transition;
|
|
ReactCurrentBatchConfig$1.transition = 1;
|
|
try {
|
|
setValue(value);
|
|
} finally {
|
|
ReactCurrentBatchConfig$1.transition = prevTransition;
|
|
}
|
|
}, [value]);
|
|
return prevValue;
|
|
}
|
|
function updateDeferredValue(value) {
|
|
var _updateState = updateState(), prevValue = _updateState[0], setValue = _updateState[1];
|
|
updateEffect(function() {
|
|
var prevTransition = ReactCurrentBatchConfig$1.transition;
|
|
ReactCurrentBatchConfig$1.transition = 1;
|
|
try {
|
|
setValue(value);
|
|
} finally {
|
|
ReactCurrentBatchConfig$1.transition = prevTransition;
|
|
}
|
|
}, [value]);
|
|
return prevValue;
|
|
}
|
|
function rerenderDeferredValue(value) {
|
|
var _rerenderState = rerenderState(), prevValue = _rerenderState[0], setValue = _rerenderState[1];
|
|
updateEffect(function() {
|
|
var prevTransition = ReactCurrentBatchConfig$1.transition;
|
|
ReactCurrentBatchConfig$1.transition = 1;
|
|
try {
|
|
setValue(value);
|
|
} finally {
|
|
ReactCurrentBatchConfig$1.transition = prevTransition;
|
|
}
|
|
}, [value]);
|
|
return prevValue;
|
|
}
|
|
function startTransition(setPending, callback) {
|
|
var priorityLevel = getCurrentPriorityLevel();
|
|
{
|
|
runWithPriority$1(priorityLevel < UserBlockingPriority$2 ? UserBlockingPriority$2 : priorityLevel, function() {
|
|
setPending(true);
|
|
});
|
|
runWithPriority$1(priorityLevel > NormalPriority$1 ? NormalPriority$1 : priorityLevel, function() {
|
|
var prevTransition = ReactCurrentBatchConfig$1.transition;
|
|
ReactCurrentBatchConfig$1.transition = 1;
|
|
try {
|
|
setPending(false);
|
|
callback();
|
|
} finally {
|
|
ReactCurrentBatchConfig$1.transition = prevTransition;
|
|
}
|
|
});
|
|
}
|
|
}
|
|
function mountTransition() {
|
|
var _mountState2 = mountState(false), isPending = _mountState2[0], setPending = _mountState2[1];
|
|
var start = startTransition.bind(null, setPending);
|
|
mountRef(start);
|
|
return [start, isPending];
|
|
}
|
|
function updateTransition() {
|
|
var _updateState2 = updateState(), isPending = _updateState2[0];
|
|
var startRef = updateRef();
|
|
var start = startRef.current;
|
|
return [start, isPending];
|
|
}
|
|
function rerenderTransition() {
|
|
var _rerenderState2 = rerenderState(), isPending = _rerenderState2[0];
|
|
var startRef = updateRef();
|
|
var start = startRef.current;
|
|
return [start, isPending];
|
|
}
|
|
var isUpdatingOpaqueValueInRenderPhase = false;
|
|
function getIsUpdatingOpaqueValueInRenderPhaseInDEV() {
|
|
{
|
|
return isUpdatingOpaqueValueInRenderPhase;
|
|
}
|
|
}
|
|
function warnOnOpaqueIdentifierAccessInDEV(fiber) {
|
|
{
|
|
var name = getComponentName(fiber.type) || "Unknown";
|
|
if (getIsRendering() && !didWarnAboutUseOpaqueIdentifier[name]) {
|
|
error("The object passed back from useOpaqueIdentifier is meant to be passed through to attributes only. Do not read the value directly.");
|
|
didWarnAboutUseOpaqueIdentifier[name] = true;
|
|
}
|
|
}
|
|
}
|
|
function mountOpaqueIdentifier() {
|
|
var makeId = makeClientIdInDEV.bind(null, warnOnOpaqueIdentifierAccessInDEV.bind(null, currentlyRenderingFiber$1));
|
|
if (getIsHydrating()) {
|
|
var didUpgrade = false;
|
|
var fiber = currentlyRenderingFiber$1;
|
|
var readValue = function() {
|
|
if (!didUpgrade) {
|
|
didUpgrade = true;
|
|
{
|
|
isUpdatingOpaqueValueInRenderPhase = true;
|
|
setId(makeId());
|
|
isUpdatingOpaqueValueInRenderPhase = false;
|
|
warnOnOpaqueIdentifierAccessInDEV(fiber);
|
|
}
|
|
}
|
|
{
|
|
{
|
|
throw Error("The object passed back from useOpaqueIdentifier is meant to be passed through to attributes only. Do not read the value directly.");
|
|
}
|
|
}
|
|
};
|
|
var id = makeOpaqueHydratingObject(readValue);
|
|
var setId = mountState(id)[1];
|
|
if ((currentlyRenderingFiber$1.mode & BlockingMode) === NoMode) {
|
|
currentlyRenderingFiber$1.flags |= Update | Passive;
|
|
pushEffect(HasEffect | Passive$1, function() {
|
|
setId(makeId());
|
|
}, void 0, null);
|
|
}
|
|
return id;
|
|
} else {
|
|
var _id = makeId();
|
|
mountState(_id);
|
|
return _id;
|
|
}
|
|
}
|
|
function updateOpaqueIdentifier() {
|
|
var id = updateState()[0];
|
|
return id;
|
|
}
|
|
function rerenderOpaqueIdentifier() {
|
|
var id = rerenderState()[0];
|
|
return id;
|
|
}
|
|
function dispatchAction(fiber, queue, action) {
|
|
{
|
|
if (typeof arguments[3] === "function") {
|
|
error("State updates from the useState() and useReducer() Hooks don't support the second callback argument. To execute a side effect after rendering, declare it in the component body with useEffect().");
|
|
}
|
|
}
|
|
var eventTime = requestEventTime();
|
|
var lane = requestUpdateLane(fiber);
|
|
var update = {
|
|
lane,
|
|
action,
|
|
eagerReducer: null,
|
|
eagerState: null,
|
|
next: null
|
|
};
|
|
var pending = queue.pending;
|
|
if (pending === null) {
|
|
update.next = update;
|
|
} else {
|
|
update.next = pending.next;
|
|
pending.next = update;
|
|
}
|
|
queue.pending = update;
|
|
var alternate = fiber.alternate;
|
|
if (fiber === currentlyRenderingFiber$1 || alternate !== null && alternate === currentlyRenderingFiber$1) {
|
|
didScheduleRenderPhaseUpdateDuringThisPass = didScheduleRenderPhaseUpdate = true;
|
|
} else {
|
|
if (fiber.lanes === NoLanes && (alternate === null || alternate.lanes === NoLanes)) {
|
|
var lastRenderedReducer = queue.lastRenderedReducer;
|
|
if (lastRenderedReducer !== null) {
|
|
var prevDispatcher;
|
|
{
|
|
prevDispatcher = ReactCurrentDispatcher$1.current;
|
|
ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
|
|
}
|
|
try {
|
|
var currentState = queue.lastRenderedState;
|
|
var eagerState = lastRenderedReducer(currentState, action);
|
|
update.eagerReducer = lastRenderedReducer;
|
|
update.eagerState = eagerState;
|
|
if (objectIs(eagerState, currentState)) {
|
|
return;
|
|
}
|
|
} catch (error2) {
|
|
} finally {
|
|
{
|
|
ReactCurrentDispatcher$1.current = prevDispatcher;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
{
|
|
if (typeof jest !== "undefined") {
|
|
warnIfNotScopedWithMatchingAct(fiber);
|
|
warnIfNotCurrentlyActingUpdatesInDev(fiber);
|
|
}
|
|
}
|
|
scheduleUpdateOnFiber(fiber, lane, eventTime);
|
|
}
|
|
}
|
|
var ContextOnlyDispatcher = {
|
|
readContext,
|
|
useCallback: throwInvalidHookError,
|
|
useContext: throwInvalidHookError,
|
|
useEffect: throwInvalidHookError,
|
|
useImperativeHandle: throwInvalidHookError,
|
|
useLayoutEffect: throwInvalidHookError,
|
|
useMemo: throwInvalidHookError,
|
|
useReducer: throwInvalidHookError,
|
|
useRef: throwInvalidHookError,
|
|
useState: throwInvalidHookError,
|
|
useDebugValue: throwInvalidHookError,
|
|
useDeferredValue: throwInvalidHookError,
|
|
useTransition: throwInvalidHookError,
|
|
useMutableSource: throwInvalidHookError,
|
|
useOpaqueIdentifier: throwInvalidHookError,
|
|
unstable_isNewReconciler: enableNewReconciler
|
|
};
|
|
var HooksDispatcherOnMountInDEV = null;
|
|
var HooksDispatcherOnMountWithHookTypesInDEV = null;
|
|
var HooksDispatcherOnUpdateInDEV = null;
|
|
var HooksDispatcherOnRerenderInDEV = null;
|
|
var InvalidNestedHooksDispatcherOnMountInDEV = null;
|
|
var InvalidNestedHooksDispatcherOnUpdateInDEV = null;
|
|
var InvalidNestedHooksDispatcherOnRerenderInDEV = null;
|
|
{
|
|
var warnInvalidContextAccess = function() {
|
|
error("Context can only be read while React is rendering. In classes, you can read it in the render method or getDerivedStateFromProps. In function components, you can read it directly in the function body, but not inside Hooks like useReducer() or useMemo().");
|
|
};
|
|
var warnInvalidHookAccess = function() {
|
|
error("Do not call Hooks inside useEffect(...), useMemo(...), or other built-in Hooks. You can only call Hooks at the top level of your React function. For more information, see https://reactjs.org/link/rules-of-hooks");
|
|
};
|
|
HooksDispatcherOnMountInDEV = {
|
|
readContext: function(context, observedBits) {
|
|
return readContext(context, observedBits);
|
|
},
|
|
useCallback: function(callback, deps) {
|
|
currentHookNameInDev = "useCallback";
|
|
mountHookTypesDev();
|
|
checkDepsAreArrayDev(deps);
|
|
return mountCallback(callback, deps);
|
|
},
|
|
useContext: function(context, observedBits) {
|
|
currentHookNameInDev = "useContext";
|
|
mountHookTypesDev();
|
|
return readContext(context, observedBits);
|
|
},
|
|
useEffect: function(create, deps) {
|
|
currentHookNameInDev = "useEffect";
|
|
mountHookTypesDev();
|
|
checkDepsAreArrayDev(deps);
|
|
return mountEffect(create, deps);
|
|
},
|
|
useImperativeHandle: function(ref, create, deps) {
|
|
currentHookNameInDev = "useImperativeHandle";
|
|
mountHookTypesDev();
|
|
checkDepsAreArrayDev(deps);
|
|
return mountImperativeHandle(ref, create, deps);
|
|
},
|
|
useLayoutEffect: function(create, deps) {
|
|
currentHookNameInDev = "useLayoutEffect";
|
|
mountHookTypesDev();
|
|
checkDepsAreArrayDev(deps);
|
|
return mountLayoutEffect(create, deps);
|
|
},
|
|
useMemo: function(create, deps) {
|
|
currentHookNameInDev = "useMemo";
|
|
mountHookTypesDev();
|
|
checkDepsAreArrayDev(deps);
|
|
var prevDispatcher = ReactCurrentDispatcher$1.current;
|
|
ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
|
|
try {
|
|
return mountMemo(create, deps);
|
|
} finally {
|
|
ReactCurrentDispatcher$1.current = prevDispatcher;
|
|
}
|
|
},
|
|
useReducer: function(reducer, initialArg, init) {
|
|
currentHookNameInDev = "useReducer";
|
|
mountHookTypesDev();
|
|
var prevDispatcher = ReactCurrentDispatcher$1.current;
|
|
ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
|
|
try {
|
|
return mountReducer(reducer, initialArg, init);
|
|
} finally {
|
|
ReactCurrentDispatcher$1.current = prevDispatcher;
|
|
}
|
|
},
|
|
useRef: function(initialValue) {
|
|
currentHookNameInDev = "useRef";
|
|
mountHookTypesDev();
|
|
return mountRef(initialValue);
|
|
},
|
|
useState: function(initialState) {
|
|
currentHookNameInDev = "useState";
|
|
mountHookTypesDev();
|
|
var prevDispatcher = ReactCurrentDispatcher$1.current;
|
|
ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
|
|
try {
|
|
return mountState(initialState);
|
|
} finally {
|
|
ReactCurrentDispatcher$1.current = prevDispatcher;
|
|
}
|
|
},
|
|
useDebugValue: function(value, formatterFn) {
|
|
currentHookNameInDev = "useDebugValue";
|
|
mountHookTypesDev();
|
|
return mountDebugValue();
|
|
},
|
|
useDeferredValue: function(value) {
|
|
currentHookNameInDev = "useDeferredValue";
|
|
mountHookTypesDev();
|
|
return mountDeferredValue(value);
|
|
},
|
|
useTransition: function() {
|
|
currentHookNameInDev = "useTransition";
|
|
mountHookTypesDev();
|
|
return mountTransition();
|
|
},
|
|
useMutableSource: function(source, getSnapshot, subscribe) {
|
|
currentHookNameInDev = "useMutableSource";
|
|
mountHookTypesDev();
|
|
return mountMutableSource(source, getSnapshot, subscribe);
|
|
},
|
|
useOpaqueIdentifier: function() {
|
|
currentHookNameInDev = "useOpaqueIdentifier";
|
|
mountHookTypesDev();
|
|
return mountOpaqueIdentifier();
|
|
},
|
|
unstable_isNewReconciler: enableNewReconciler
|
|
};
|
|
HooksDispatcherOnMountWithHookTypesInDEV = {
|
|
readContext: function(context, observedBits) {
|
|
return readContext(context, observedBits);
|
|
},
|
|
useCallback: function(callback, deps) {
|
|
currentHookNameInDev = "useCallback";
|
|
updateHookTypesDev();
|
|
return mountCallback(callback, deps);
|
|
},
|
|
useContext: function(context, observedBits) {
|
|
currentHookNameInDev = "useContext";
|
|
updateHookTypesDev();
|
|
return readContext(context, observedBits);
|
|
},
|
|
useEffect: function(create, deps) {
|
|
currentHookNameInDev = "useEffect";
|
|
updateHookTypesDev();
|
|
return mountEffect(create, deps);
|
|
},
|
|
useImperativeHandle: function(ref, create, deps) {
|
|
currentHookNameInDev = "useImperativeHandle";
|
|
updateHookTypesDev();
|
|
return mountImperativeHandle(ref, create, deps);
|
|
},
|
|
useLayoutEffect: function(create, deps) {
|
|
currentHookNameInDev = "useLayoutEffect";
|
|
updateHookTypesDev();
|
|
return mountLayoutEffect(create, deps);
|
|
},
|
|
useMemo: function(create, deps) {
|
|
currentHookNameInDev = "useMemo";
|
|
updateHookTypesDev();
|
|
var prevDispatcher = ReactCurrentDispatcher$1.current;
|
|
ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
|
|
try {
|
|
return mountMemo(create, deps);
|
|
} finally {
|
|
ReactCurrentDispatcher$1.current = prevDispatcher;
|
|
}
|
|
},
|
|
useReducer: function(reducer, initialArg, init) {
|
|
currentHookNameInDev = "useReducer";
|
|
updateHookTypesDev();
|
|
var prevDispatcher = ReactCurrentDispatcher$1.current;
|
|
ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
|
|
try {
|
|
return mountReducer(reducer, initialArg, init);
|
|
} finally {
|
|
ReactCurrentDispatcher$1.current = prevDispatcher;
|
|
}
|
|
},
|
|
useRef: function(initialValue) {
|
|
currentHookNameInDev = "useRef";
|
|
updateHookTypesDev();
|
|
return mountRef(initialValue);
|
|
},
|
|
useState: function(initialState) {
|
|
currentHookNameInDev = "useState";
|
|
updateHookTypesDev();
|
|
var prevDispatcher = ReactCurrentDispatcher$1.current;
|
|
ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
|
|
try {
|
|
return mountState(initialState);
|
|
} finally {
|
|
ReactCurrentDispatcher$1.current = prevDispatcher;
|
|
}
|
|
},
|
|
useDebugValue: function(value, formatterFn) {
|
|
currentHookNameInDev = "useDebugValue";
|
|
updateHookTypesDev();
|
|
return mountDebugValue();
|
|
},
|
|
useDeferredValue: function(value) {
|
|
currentHookNameInDev = "useDeferredValue";
|
|
updateHookTypesDev();
|
|
return mountDeferredValue(value);
|
|
},
|
|
useTransition: function() {
|
|
currentHookNameInDev = "useTransition";
|
|
updateHookTypesDev();
|
|
return mountTransition();
|
|
},
|
|
useMutableSource: function(source, getSnapshot, subscribe) {
|
|
currentHookNameInDev = "useMutableSource";
|
|
updateHookTypesDev();
|
|
return mountMutableSource(source, getSnapshot, subscribe);
|
|
},
|
|
useOpaqueIdentifier: function() {
|
|
currentHookNameInDev = "useOpaqueIdentifier";
|
|
updateHookTypesDev();
|
|
return mountOpaqueIdentifier();
|
|
},
|
|
unstable_isNewReconciler: enableNewReconciler
|
|
};
|
|
HooksDispatcherOnUpdateInDEV = {
|
|
readContext: function(context, observedBits) {
|
|
return readContext(context, observedBits);
|
|
},
|
|
useCallback: function(callback, deps) {
|
|
currentHookNameInDev = "useCallback";
|
|
updateHookTypesDev();
|
|
return updateCallback(callback, deps);
|
|
},
|
|
useContext: function(context, observedBits) {
|
|
currentHookNameInDev = "useContext";
|
|
updateHookTypesDev();
|
|
return readContext(context, observedBits);
|
|
},
|
|
useEffect: function(create, deps) {
|
|
currentHookNameInDev = "useEffect";
|
|
updateHookTypesDev();
|
|
return updateEffect(create, deps);
|
|
},
|
|
useImperativeHandle: function(ref, create, deps) {
|
|
currentHookNameInDev = "useImperativeHandle";
|
|
updateHookTypesDev();
|
|
return updateImperativeHandle(ref, create, deps);
|
|
},
|
|
useLayoutEffect: function(create, deps) {
|
|
currentHookNameInDev = "useLayoutEffect";
|
|
updateHookTypesDev();
|
|
return updateLayoutEffect(create, deps);
|
|
},
|
|
useMemo: function(create, deps) {
|
|
currentHookNameInDev = "useMemo";
|
|
updateHookTypesDev();
|
|
var prevDispatcher = ReactCurrentDispatcher$1.current;
|
|
ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
|
|
try {
|
|
return updateMemo(create, deps);
|
|
} finally {
|
|
ReactCurrentDispatcher$1.current = prevDispatcher;
|
|
}
|
|
},
|
|
useReducer: function(reducer, initialArg, init) {
|
|
currentHookNameInDev = "useReducer";
|
|
updateHookTypesDev();
|
|
var prevDispatcher = ReactCurrentDispatcher$1.current;
|
|
ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
|
|
try {
|
|
return updateReducer(reducer, initialArg, init);
|
|
} finally {
|
|
ReactCurrentDispatcher$1.current = prevDispatcher;
|
|
}
|
|
},
|
|
useRef: function(initialValue) {
|
|
currentHookNameInDev = "useRef";
|
|
updateHookTypesDev();
|
|
return updateRef();
|
|
},
|
|
useState: function(initialState) {
|
|
currentHookNameInDev = "useState";
|
|
updateHookTypesDev();
|
|
var prevDispatcher = ReactCurrentDispatcher$1.current;
|
|
ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
|
|
try {
|
|
return updateState(initialState);
|
|
} finally {
|
|
ReactCurrentDispatcher$1.current = prevDispatcher;
|
|
}
|
|
},
|
|
useDebugValue: function(value, formatterFn) {
|
|
currentHookNameInDev = "useDebugValue";
|
|
updateHookTypesDev();
|
|
return updateDebugValue();
|
|
},
|
|
useDeferredValue: function(value) {
|
|
currentHookNameInDev = "useDeferredValue";
|
|
updateHookTypesDev();
|
|
return updateDeferredValue(value);
|
|
},
|
|
useTransition: function() {
|
|
currentHookNameInDev = "useTransition";
|
|
updateHookTypesDev();
|
|
return updateTransition();
|
|
},
|
|
useMutableSource: function(source, getSnapshot, subscribe) {
|
|
currentHookNameInDev = "useMutableSource";
|
|
updateHookTypesDev();
|
|
return updateMutableSource(source, getSnapshot, subscribe);
|
|
},
|
|
useOpaqueIdentifier: function() {
|
|
currentHookNameInDev = "useOpaqueIdentifier";
|
|
updateHookTypesDev();
|
|
return updateOpaqueIdentifier();
|
|
},
|
|
unstable_isNewReconciler: enableNewReconciler
|
|
};
|
|
HooksDispatcherOnRerenderInDEV = {
|
|
readContext: function(context, observedBits) {
|
|
return readContext(context, observedBits);
|
|
},
|
|
useCallback: function(callback, deps) {
|
|
currentHookNameInDev = "useCallback";
|
|
updateHookTypesDev();
|
|
return updateCallback(callback, deps);
|
|
},
|
|
useContext: function(context, observedBits) {
|
|
currentHookNameInDev = "useContext";
|
|
updateHookTypesDev();
|
|
return readContext(context, observedBits);
|
|
},
|
|
useEffect: function(create, deps) {
|
|
currentHookNameInDev = "useEffect";
|
|
updateHookTypesDev();
|
|
return updateEffect(create, deps);
|
|
},
|
|
useImperativeHandle: function(ref, create, deps) {
|
|
currentHookNameInDev = "useImperativeHandle";
|
|
updateHookTypesDev();
|
|
return updateImperativeHandle(ref, create, deps);
|
|
},
|
|
useLayoutEffect: function(create, deps) {
|
|
currentHookNameInDev = "useLayoutEffect";
|
|
updateHookTypesDev();
|
|
return updateLayoutEffect(create, deps);
|
|
},
|
|
useMemo: function(create, deps) {
|
|
currentHookNameInDev = "useMemo";
|
|
updateHookTypesDev();
|
|
var prevDispatcher = ReactCurrentDispatcher$1.current;
|
|
ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnRerenderInDEV;
|
|
try {
|
|
return updateMemo(create, deps);
|
|
} finally {
|
|
ReactCurrentDispatcher$1.current = prevDispatcher;
|
|
}
|
|
},
|
|
useReducer: function(reducer, initialArg, init) {
|
|
currentHookNameInDev = "useReducer";
|
|
updateHookTypesDev();
|
|
var prevDispatcher = ReactCurrentDispatcher$1.current;
|
|
ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnRerenderInDEV;
|
|
try {
|
|
return rerenderReducer(reducer, initialArg, init);
|
|
} finally {
|
|
ReactCurrentDispatcher$1.current = prevDispatcher;
|
|
}
|
|
},
|
|
useRef: function(initialValue) {
|
|
currentHookNameInDev = "useRef";
|
|
updateHookTypesDev();
|
|
return updateRef();
|
|
},
|
|
useState: function(initialState) {
|
|
currentHookNameInDev = "useState";
|
|
updateHookTypesDev();
|
|
var prevDispatcher = ReactCurrentDispatcher$1.current;
|
|
ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnRerenderInDEV;
|
|
try {
|
|
return rerenderState(initialState);
|
|
} finally {
|
|
ReactCurrentDispatcher$1.current = prevDispatcher;
|
|
}
|
|
},
|
|
useDebugValue: function(value, formatterFn) {
|
|
currentHookNameInDev = "useDebugValue";
|
|
updateHookTypesDev();
|
|
return updateDebugValue();
|
|
},
|
|
useDeferredValue: function(value) {
|
|
currentHookNameInDev = "useDeferredValue";
|
|
updateHookTypesDev();
|
|
return rerenderDeferredValue(value);
|
|
},
|
|
useTransition: function() {
|
|
currentHookNameInDev = "useTransition";
|
|
updateHookTypesDev();
|
|
return rerenderTransition();
|
|
},
|
|
useMutableSource: function(source, getSnapshot, subscribe) {
|
|
currentHookNameInDev = "useMutableSource";
|
|
updateHookTypesDev();
|
|
return updateMutableSource(source, getSnapshot, subscribe);
|
|
},
|
|
useOpaqueIdentifier: function() {
|
|
currentHookNameInDev = "useOpaqueIdentifier";
|
|
updateHookTypesDev();
|
|
return rerenderOpaqueIdentifier();
|
|
},
|
|
unstable_isNewReconciler: enableNewReconciler
|
|
};
|
|
InvalidNestedHooksDispatcherOnMountInDEV = {
|
|
readContext: function(context, observedBits) {
|
|
warnInvalidContextAccess();
|
|
return readContext(context, observedBits);
|
|
},
|
|
useCallback: function(callback, deps) {
|
|
currentHookNameInDev = "useCallback";
|
|
warnInvalidHookAccess();
|
|
mountHookTypesDev();
|
|
return mountCallback(callback, deps);
|
|
},
|
|
useContext: function(context, observedBits) {
|
|
currentHookNameInDev = "useContext";
|
|
warnInvalidHookAccess();
|
|
mountHookTypesDev();
|
|
return readContext(context, observedBits);
|
|
},
|
|
useEffect: function(create, deps) {
|
|
currentHookNameInDev = "useEffect";
|
|
warnInvalidHookAccess();
|
|
mountHookTypesDev();
|
|
return mountEffect(create, deps);
|
|
},
|
|
useImperativeHandle: function(ref, create, deps) {
|
|
currentHookNameInDev = "useImperativeHandle";
|
|
warnInvalidHookAccess();
|
|
mountHookTypesDev();
|
|
return mountImperativeHandle(ref, create, deps);
|
|
},
|
|
useLayoutEffect: function(create, deps) {
|
|
currentHookNameInDev = "useLayoutEffect";
|
|
warnInvalidHookAccess();
|
|
mountHookTypesDev();
|
|
return mountLayoutEffect(create, deps);
|
|
},
|
|
useMemo: function(create, deps) {
|
|
currentHookNameInDev = "useMemo";
|
|
warnInvalidHookAccess();
|
|
mountHookTypesDev();
|
|
var prevDispatcher = ReactCurrentDispatcher$1.current;
|
|
ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
|
|
try {
|
|
return mountMemo(create, deps);
|
|
} finally {
|
|
ReactCurrentDispatcher$1.current = prevDispatcher;
|
|
}
|
|
},
|
|
useReducer: function(reducer, initialArg, init) {
|
|
currentHookNameInDev = "useReducer";
|
|
warnInvalidHookAccess();
|
|
mountHookTypesDev();
|
|
var prevDispatcher = ReactCurrentDispatcher$1.current;
|
|
ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
|
|
try {
|
|
return mountReducer(reducer, initialArg, init);
|
|
} finally {
|
|
ReactCurrentDispatcher$1.current = prevDispatcher;
|
|
}
|
|
},
|
|
useRef: function(initialValue) {
|
|
currentHookNameInDev = "useRef";
|
|
warnInvalidHookAccess();
|
|
mountHookTypesDev();
|
|
return mountRef(initialValue);
|
|
},
|
|
useState: function(initialState) {
|
|
currentHookNameInDev = "useState";
|
|
warnInvalidHookAccess();
|
|
mountHookTypesDev();
|
|
var prevDispatcher = ReactCurrentDispatcher$1.current;
|
|
ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV;
|
|
try {
|
|
return mountState(initialState);
|
|
} finally {
|
|
ReactCurrentDispatcher$1.current = prevDispatcher;
|
|
}
|
|
},
|
|
useDebugValue: function(value, formatterFn) {
|
|
currentHookNameInDev = "useDebugValue";
|
|
warnInvalidHookAccess();
|
|
mountHookTypesDev();
|
|
return mountDebugValue();
|
|
},
|
|
useDeferredValue: function(value) {
|
|
currentHookNameInDev = "useDeferredValue";
|
|
warnInvalidHookAccess();
|
|
mountHookTypesDev();
|
|
return mountDeferredValue(value);
|
|
},
|
|
useTransition: function() {
|
|
currentHookNameInDev = "useTransition";
|
|
warnInvalidHookAccess();
|
|
mountHookTypesDev();
|
|
return mountTransition();
|
|
},
|
|
useMutableSource: function(source, getSnapshot, subscribe) {
|
|
currentHookNameInDev = "useMutableSource";
|
|
warnInvalidHookAccess();
|
|
mountHookTypesDev();
|
|
return mountMutableSource(source, getSnapshot, subscribe);
|
|
},
|
|
useOpaqueIdentifier: function() {
|
|
currentHookNameInDev = "useOpaqueIdentifier";
|
|
warnInvalidHookAccess();
|
|
mountHookTypesDev();
|
|
return mountOpaqueIdentifier();
|
|
},
|
|
unstable_isNewReconciler: enableNewReconciler
|
|
};
|
|
InvalidNestedHooksDispatcherOnUpdateInDEV = {
|
|
readContext: function(context, observedBits) {
|
|
warnInvalidContextAccess();
|
|
return readContext(context, observedBits);
|
|
},
|
|
useCallback: function(callback, deps) {
|
|
currentHookNameInDev = "useCallback";
|
|
warnInvalidHookAccess();
|
|
updateHookTypesDev();
|
|
return updateCallback(callback, deps);
|
|
},
|
|
useContext: function(context, observedBits) {
|
|
currentHookNameInDev = "useContext";
|
|
warnInvalidHookAccess();
|
|
updateHookTypesDev();
|
|
return readContext(context, observedBits);
|
|
},
|
|
useEffect: function(create, deps) {
|
|
currentHookNameInDev = "useEffect";
|
|
warnInvalidHookAccess();
|
|
updateHookTypesDev();
|
|
return updateEffect(create, deps);
|
|
},
|
|
useImperativeHandle: function(ref, create, deps) {
|
|
currentHookNameInDev = "useImperativeHandle";
|
|
warnInvalidHookAccess();
|
|
updateHookTypesDev();
|
|
return updateImperativeHandle(ref, create, deps);
|
|
},
|
|
useLayoutEffect: function(create, deps) {
|
|
currentHookNameInDev = "useLayoutEffect";
|
|
warnInvalidHookAccess();
|
|
updateHookTypesDev();
|
|
return updateLayoutEffect(create, deps);
|
|
},
|
|
useMemo: function(create, deps) {
|
|
currentHookNameInDev = "useMemo";
|
|
warnInvalidHookAccess();
|
|
updateHookTypesDev();
|
|
var prevDispatcher = ReactCurrentDispatcher$1.current;
|
|
ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
|
|
try {
|
|
return updateMemo(create, deps);
|
|
} finally {
|
|
ReactCurrentDispatcher$1.current = prevDispatcher;
|
|
}
|
|
},
|
|
useReducer: function(reducer, initialArg, init) {
|
|
currentHookNameInDev = "useReducer";
|
|
warnInvalidHookAccess();
|
|
updateHookTypesDev();
|
|
var prevDispatcher = ReactCurrentDispatcher$1.current;
|
|
ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
|
|
try {
|
|
return updateReducer(reducer, initialArg, init);
|
|
} finally {
|
|
ReactCurrentDispatcher$1.current = prevDispatcher;
|
|
}
|
|
},
|
|
useRef: function(initialValue) {
|
|
currentHookNameInDev = "useRef";
|
|
warnInvalidHookAccess();
|
|
updateHookTypesDev();
|
|
return updateRef();
|
|
},
|
|
useState: function(initialState) {
|
|
currentHookNameInDev = "useState";
|
|
warnInvalidHookAccess();
|
|
updateHookTypesDev();
|
|
var prevDispatcher = ReactCurrentDispatcher$1.current;
|
|
ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
|
|
try {
|
|
return updateState(initialState);
|
|
} finally {
|
|
ReactCurrentDispatcher$1.current = prevDispatcher;
|
|
}
|
|
},
|
|
useDebugValue: function(value, formatterFn) {
|
|
currentHookNameInDev = "useDebugValue";
|
|
warnInvalidHookAccess();
|
|
updateHookTypesDev();
|
|
return updateDebugValue();
|
|
},
|
|
useDeferredValue: function(value) {
|
|
currentHookNameInDev = "useDeferredValue";
|
|
warnInvalidHookAccess();
|
|
updateHookTypesDev();
|
|
return updateDeferredValue(value);
|
|
},
|
|
useTransition: function() {
|
|
currentHookNameInDev = "useTransition";
|
|
warnInvalidHookAccess();
|
|
updateHookTypesDev();
|
|
return updateTransition();
|
|
},
|
|
useMutableSource: function(source, getSnapshot, subscribe) {
|
|
currentHookNameInDev = "useMutableSource";
|
|
warnInvalidHookAccess();
|
|
updateHookTypesDev();
|
|
return updateMutableSource(source, getSnapshot, subscribe);
|
|
},
|
|
useOpaqueIdentifier: function() {
|
|
currentHookNameInDev = "useOpaqueIdentifier";
|
|
warnInvalidHookAccess();
|
|
updateHookTypesDev();
|
|
return updateOpaqueIdentifier();
|
|
},
|
|
unstable_isNewReconciler: enableNewReconciler
|
|
};
|
|
InvalidNestedHooksDispatcherOnRerenderInDEV = {
|
|
readContext: function(context, observedBits) {
|
|
warnInvalidContextAccess();
|
|
return readContext(context, observedBits);
|
|
},
|
|
useCallback: function(callback, deps) {
|
|
currentHookNameInDev = "useCallback";
|
|
warnInvalidHookAccess();
|
|
updateHookTypesDev();
|
|
return updateCallback(callback, deps);
|
|
},
|
|
useContext: function(context, observedBits) {
|
|
currentHookNameInDev = "useContext";
|
|
warnInvalidHookAccess();
|
|
updateHookTypesDev();
|
|
return readContext(context, observedBits);
|
|
},
|
|
useEffect: function(create, deps) {
|
|
currentHookNameInDev = "useEffect";
|
|
warnInvalidHookAccess();
|
|
updateHookTypesDev();
|
|
return updateEffect(create, deps);
|
|
},
|
|
useImperativeHandle: function(ref, create, deps) {
|
|
currentHookNameInDev = "useImperativeHandle";
|
|
warnInvalidHookAccess();
|
|
updateHookTypesDev();
|
|
return updateImperativeHandle(ref, create, deps);
|
|
},
|
|
useLayoutEffect: function(create, deps) {
|
|
currentHookNameInDev = "useLayoutEffect";
|
|
warnInvalidHookAccess();
|
|
updateHookTypesDev();
|
|
return updateLayoutEffect(create, deps);
|
|
},
|
|
useMemo: function(create, deps) {
|
|
currentHookNameInDev = "useMemo";
|
|
warnInvalidHookAccess();
|
|
updateHookTypesDev();
|
|
var prevDispatcher = ReactCurrentDispatcher$1.current;
|
|
ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
|
|
try {
|
|
return updateMemo(create, deps);
|
|
} finally {
|
|
ReactCurrentDispatcher$1.current = prevDispatcher;
|
|
}
|
|
},
|
|
useReducer: function(reducer, initialArg, init) {
|
|
currentHookNameInDev = "useReducer";
|
|
warnInvalidHookAccess();
|
|
updateHookTypesDev();
|
|
var prevDispatcher = ReactCurrentDispatcher$1.current;
|
|
ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
|
|
try {
|
|
return rerenderReducer(reducer, initialArg, init);
|
|
} finally {
|
|
ReactCurrentDispatcher$1.current = prevDispatcher;
|
|
}
|
|
},
|
|
useRef: function(initialValue) {
|
|
currentHookNameInDev = "useRef";
|
|
warnInvalidHookAccess();
|
|
updateHookTypesDev();
|
|
return updateRef();
|
|
},
|
|
useState: function(initialState) {
|
|
currentHookNameInDev = "useState";
|
|
warnInvalidHookAccess();
|
|
updateHookTypesDev();
|
|
var prevDispatcher = ReactCurrentDispatcher$1.current;
|
|
ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV;
|
|
try {
|
|
return rerenderState(initialState);
|
|
} finally {
|
|
ReactCurrentDispatcher$1.current = prevDispatcher;
|
|
}
|
|
},
|
|
useDebugValue: function(value, formatterFn) {
|
|
currentHookNameInDev = "useDebugValue";
|
|
warnInvalidHookAccess();
|
|
updateHookTypesDev();
|
|
return updateDebugValue();
|
|
},
|
|
useDeferredValue: function(value) {
|
|
currentHookNameInDev = "useDeferredValue";
|
|
warnInvalidHookAccess();
|
|
updateHookTypesDev();
|
|
return rerenderDeferredValue(value);
|
|
},
|
|
useTransition: function() {
|
|
currentHookNameInDev = "useTransition";
|
|
warnInvalidHookAccess();
|
|
updateHookTypesDev();
|
|
return rerenderTransition();
|
|
},
|
|
useMutableSource: function(source, getSnapshot, subscribe) {
|
|
currentHookNameInDev = "useMutableSource";
|
|
warnInvalidHookAccess();
|
|
updateHookTypesDev();
|
|
return updateMutableSource(source, getSnapshot, subscribe);
|
|
},
|
|
useOpaqueIdentifier: function() {
|
|
currentHookNameInDev = "useOpaqueIdentifier";
|
|
warnInvalidHookAccess();
|
|
updateHookTypesDev();
|
|
return rerenderOpaqueIdentifier();
|
|
},
|
|
unstable_isNewReconciler: enableNewReconciler
|
|
};
|
|
}
|
|
var now$1 = Scheduler.unstable_now;
|
|
var commitTime = 0;
|
|
var profilerStartTime = -1;
|
|
function getCommitTime() {
|
|
return commitTime;
|
|
}
|
|
function recordCommitTime() {
|
|
commitTime = now$1();
|
|
}
|
|
function startProfilerTimer(fiber) {
|
|
profilerStartTime = now$1();
|
|
if (fiber.actualStartTime < 0) {
|
|
fiber.actualStartTime = now$1();
|
|
}
|
|
}
|
|
function stopProfilerTimerIfRunning(fiber) {
|
|
profilerStartTime = -1;
|
|
}
|
|
function stopProfilerTimerIfRunningAndRecordDelta(fiber, overrideBaseTime) {
|
|
if (profilerStartTime >= 0) {
|
|
var elapsedTime = now$1() - profilerStartTime;
|
|
fiber.actualDuration += elapsedTime;
|
|
if (overrideBaseTime) {
|
|
fiber.selfBaseDuration = elapsedTime;
|
|
}
|
|
profilerStartTime = -1;
|
|
}
|
|
}
|
|
function transferActualDuration(fiber) {
|
|
var child = fiber.child;
|
|
while (child) {
|
|
fiber.actualDuration += child.actualDuration;
|
|
child = child.sibling;
|
|
}
|
|
}
|
|
var ReactCurrentOwner$1 = ReactSharedInternals.ReactCurrentOwner;
|
|
var didReceiveUpdate = false;
|
|
var didWarnAboutBadClass;
|
|
var didWarnAboutModulePatternComponent;
|
|
var didWarnAboutContextTypeOnFunctionComponent;
|
|
var didWarnAboutGetDerivedStateOnFunctionComponent;
|
|
var didWarnAboutFunctionRefs;
|
|
var didWarnAboutReassigningProps;
|
|
var didWarnAboutRevealOrder;
|
|
var didWarnAboutTailOptions;
|
|
{
|
|
didWarnAboutBadClass = {};
|
|
didWarnAboutModulePatternComponent = {};
|
|
didWarnAboutContextTypeOnFunctionComponent = {};
|
|
didWarnAboutGetDerivedStateOnFunctionComponent = {};
|
|
didWarnAboutFunctionRefs = {};
|
|
didWarnAboutReassigningProps = false;
|
|
didWarnAboutRevealOrder = {};
|
|
didWarnAboutTailOptions = {};
|
|
}
|
|
function reconcileChildren(current2, workInProgress2, nextChildren, renderLanes2) {
|
|
if (current2 === null) {
|
|
workInProgress2.child = mountChildFibers(workInProgress2, null, nextChildren, renderLanes2);
|
|
} else {
|
|
workInProgress2.child = reconcileChildFibers(workInProgress2, current2.child, nextChildren, renderLanes2);
|
|
}
|
|
}
|
|
function forceUnmountCurrentAndReconcile(current2, workInProgress2, nextChildren, renderLanes2) {
|
|
workInProgress2.child = reconcileChildFibers(workInProgress2, current2.child, null, renderLanes2);
|
|
workInProgress2.child = reconcileChildFibers(workInProgress2, null, nextChildren, renderLanes2);
|
|
}
|
|
function updateForwardRef(current2, workInProgress2, Component5, nextProps, renderLanes2) {
|
|
{
|
|
if (workInProgress2.type !== workInProgress2.elementType) {
|
|
var innerPropTypes = Component5.propTypes;
|
|
if (innerPropTypes) {
|
|
checkPropTypes(innerPropTypes, nextProps, "prop", getComponentName(Component5));
|
|
}
|
|
}
|
|
}
|
|
var render5 = Component5.render;
|
|
var ref = workInProgress2.ref;
|
|
var nextChildren;
|
|
prepareToReadContext(workInProgress2, renderLanes2);
|
|
{
|
|
ReactCurrentOwner$1.current = workInProgress2;
|
|
setIsRendering(true);
|
|
nextChildren = renderWithHooks(current2, workInProgress2, render5, nextProps, ref, renderLanes2);
|
|
if (workInProgress2.mode & StrictMode) {
|
|
disableLogs();
|
|
try {
|
|
nextChildren = renderWithHooks(current2, workInProgress2, render5, nextProps, ref, renderLanes2);
|
|
} finally {
|
|
reenableLogs();
|
|
}
|
|
}
|
|
setIsRendering(false);
|
|
}
|
|
if (current2 !== null && !didReceiveUpdate) {
|
|
bailoutHooks(current2, workInProgress2, renderLanes2);
|
|
return bailoutOnAlreadyFinishedWork(current2, workInProgress2, renderLanes2);
|
|
}
|
|
workInProgress2.flags |= PerformedWork;
|
|
reconcileChildren(current2, workInProgress2, nextChildren, renderLanes2);
|
|
return workInProgress2.child;
|
|
}
|
|
function updateMemoComponent(current2, workInProgress2, Component5, nextProps, updateLanes, renderLanes2) {
|
|
if (current2 === null) {
|
|
var type = Component5.type;
|
|
if (isSimpleFunctionComponent(type) && Component5.compare === null && Component5.defaultProps === void 0) {
|
|
var resolvedType = type;
|
|
{
|
|
resolvedType = resolveFunctionForHotReloading(type);
|
|
}
|
|
workInProgress2.tag = SimpleMemoComponent;
|
|
workInProgress2.type = resolvedType;
|
|
{
|
|
validateFunctionComponentInDev(workInProgress2, type);
|
|
}
|
|
return updateSimpleMemoComponent(current2, workInProgress2, resolvedType, nextProps, updateLanes, renderLanes2);
|
|
}
|
|
{
|
|
var innerPropTypes = type.propTypes;
|
|
if (innerPropTypes) {
|
|
checkPropTypes(innerPropTypes, nextProps, "prop", getComponentName(type));
|
|
}
|
|
}
|
|
var child = createFiberFromTypeAndProps(Component5.type, null, nextProps, workInProgress2, workInProgress2.mode, renderLanes2);
|
|
child.ref = workInProgress2.ref;
|
|
child.return = workInProgress2;
|
|
workInProgress2.child = child;
|
|
return child;
|
|
}
|
|
{
|
|
var _type = Component5.type;
|
|
var _innerPropTypes = _type.propTypes;
|
|
if (_innerPropTypes) {
|
|
checkPropTypes(_innerPropTypes, nextProps, "prop", getComponentName(_type));
|
|
}
|
|
}
|
|
var currentChild = current2.child;
|
|
if (!includesSomeLane(updateLanes, renderLanes2)) {
|
|
var prevProps = currentChild.memoizedProps;
|
|
var compare = Component5.compare;
|
|
compare = compare !== null ? compare : shallowEqual;
|
|
if (compare(prevProps, nextProps) && current2.ref === workInProgress2.ref) {
|
|
return bailoutOnAlreadyFinishedWork(current2, workInProgress2, renderLanes2);
|
|
}
|
|
}
|
|
workInProgress2.flags |= PerformedWork;
|
|
var newChild = createWorkInProgress(currentChild, nextProps);
|
|
newChild.ref = workInProgress2.ref;
|
|
newChild.return = workInProgress2;
|
|
workInProgress2.child = newChild;
|
|
return newChild;
|
|
}
|
|
function updateSimpleMemoComponent(current2, workInProgress2, Component5, nextProps, updateLanes, renderLanes2) {
|
|
{
|
|
if (workInProgress2.type !== workInProgress2.elementType) {
|
|
var outerMemoType = workInProgress2.elementType;
|
|
if (outerMemoType.$$typeof === REACT_LAZY_TYPE) {
|
|
var lazyComponent = outerMemoType;
|
|
var payload = lazyComponent._payload;
|
|
var init = lazyComponent._init;
|
|
try {
|
|
outerMemoType = init(payload);
|
|
} catch (x3) {
|
|
outerMemoType = null;
|
|
}
|
|
var outerPropTypes = outerMemoType && outerMemoType.propTypes;
|
|
if (outerPropTypes) {
|
|
checkPropTypes(outerPropTypes, nextProps, "prop", getComponentName(outerMemoType));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (current2 !== null) {
|
|
var prevProps = current2.memoizedProps;
|
|
if (shallowEqual(prevProps, nextProps) && current2.ref === workInProgress2.ref && workInProgress2.type === current2.type) {
|
|
didReceiveUpdate = false;
|
|
if (!includesSomeLane(renderLanes2, updateLanes)) {
|
|
workInProgress2.lanes = current2.lanes;
|
|
return bailoutOnAlreadyFinishedWork(current2, workInProgress2, renderLanes2);
|
|
} else if ((current2.flags & ForceUpdateForLegacySuspense) !== NoFlags) {
|
|
didReceiveUpdate = true;
|
|
}
|
|
}
|
|
}
|
|
return updateFunctionComponent(current2, workInProgress2, Component5, nextProps, renderLanes2);
|
|
}
|
|
function updateOffscreenComponent(current2, workInProgress2, renderLanes2) {
|
|
var nextProps = workInProgress2.pendingProps;
|
|
var nextChildren = nextProps.children;
|
|
var prevState = current2 !== null ? current2.memoizedState : null;
|
|
if (nextProps.mode === "hidden" || nextProps.mode === "unstable-defer-without-hiding") {
|
|
if ((workInProgress2.mode & ConcurrentMode) === NoMode) {
|
|
var nextState = {
|
|
baseLanes: NoLanes
|
|
};
|
|
workInProgress2.memoizedState = nextState;
|
|
pushRenderLanes(workInProgress2, renderLanes2);
|
|
} else if (!includesSomeLane(renderLanes2, OffscreenLane)) {
|
|
var nextBaseLanes;
|
|
if (prevState !== null) {
|
|
var prevBaseLanes = prevState.baseLanes;
|
|
nextBaseLanes = mergeLanes(prevBaseLanes, renderLanes2);
|
|
} else {
|
|
nextBaseLanes = renderLanes2;
|
|
}
|
|
{
|
|
markSpawnedWork(OffscreenLane);
|
|
}
|
|
workInProgress2.lanes = workInProgress2.childLanes = laneToLanes(OffscreenLane);
|
|
var _nextState = {
|
|
baseLanes: nextBaseLanes
|
|
};
|
|
workInProgress2.memoizedState = _nextState;
|
|
pushRenderLanes(workInProgress2, nextBaseLanes);
|
|
return null;
|
|
} else {
|
|
var _nextState2 = {
|
|
baseLanes: NoLanes
|
|
};
|
|
workInProgress2.memoizedState = _nextState2;
|
|
var subtreeRenderLanes2 = prevState !== null ? prevState.baseLanes : renderLanes2;
|
|
pushRenderLanes(workInProgress2, subtreeRenderLanes2);
|
|
}
|
|
} else {
|
|
var _subtreeRenderLanes;
|
|
if (prevState !== null) {
|
|
_subtreeRenderLanes = mergeLanes(prevState.baseLanes, renderLanes2);
|
|
workInProgress2.memoizedState = null;
|
|
} else {
|
|
_subtreeRenderLanes = renderLanes2;
|
|
}
|
|
pushRenderLanes(workInProgress2, _subtreeRenderLanes);
|
|
}
|
|
reconcileChildren(current2, workInProgress2, nextChildren, renderLanes2);
|
|
return workInProgress2.child;
|
|
}
|
|
var updateLegacyHiddenComponent = updateOffscreenComponent;
|
|
function updateFragment(current2, workInProgress2, renderLanes2) {
|
|
var nextChildren = workInProgress2.pendingProps;
|
|
reconcileChildren(current2, workInProgress2, nextChildren, renderLanes2);
|
|
return workInProgress2.child;
|
|
}
|
|
function updateMode(current2, workInProgress2, renderLanes2) {
|
|
var nextChildren = workInProgress2.pendingProps.children;
|
|
reconcileChildren(current2, workInProgress2, nextChildren, renderLanes2);
|
|
return workInProgress2.child;
|
|
}
|
|
function updateProfiler(current2, workInProgress2, renderLanes2) {
|
|
{
|
|
workInProgress2.flags |= Update;
|
|
var stateNode = workInProgress2.stateNode;
|
|
stateNode.effectDuration = 0;
|
|
stateNode.passiveEffectDuration = 0;
|
|
}
|
|
var nextProps = workInProgress2.pendingProps;
|
|
var nextChildren = nextProps.children;
|
|
reconcileChildren(current2, workInProgress2, nextChildren, renderLanes2);
|
|
return workInProgress2.child;
|
|
}
|
|
function markRef(current2, workInProgress2) {
|
|
var ref = workInProgress2.ref;
|
|
if (current2 === null && ref !== null || current2 !== null && current2.ref !== ref) {
|
|
workInProgress2.flags |= Ref;
|
|
}
|
|
}
|
|
function updateFunctionComponent(current2, workInProgress2, Component5, nextProps, renderLanes2) {
|
|
{
|
|
if (workInProgress2.type !== workInProgress2.elementType) {
|
|
var innerPropTypes = Component5.propTypes;
|
|
if (innerPropTypes) {
|
|
checkPropTypes(innerPropTypes, nextProps, "prop", getComponentName(Component5));
|
|
}
|
|
}
|
|
}
|
|
var context;
|
|
{
|
|
var unmaskedContext = getUnmaskedContext(workInProgress2, Component5, true);
|
|
context = getMaskedContext(workInProgress2, unmaskedContext);
|
|
}
|
|
var nextChildren;
|
|
prepareToReadContext(workInProgress2, renderLanes2);
|
|
{
|
|
ReactCurrentOwner$1.current = workInProgress2;
|
|
setIsRendering(true);
|
|
nextChildren = renderWithHooks(current2, workInProgress2, Component5, nextProps, context, renderLanes2);
|
|
if (workInProgress2.mode & StrictMode) {
|
|
disableLogs();
|
|
try {
|
|
nextChildren = renderWithHooks(current2, workInProgress2, Component5, nextProps, context, renderLanes2);
|
|
} finally {
|
|
reenableLogs();
|
|
}
|
|
}
|
|
setIsRendering(false);
|
|
}
|
|
if (current2 !== null && !didReceiveUpdate) {
|
|
bailoutHooks(current2, workInProgress2, renderLanes2);
|
|
return bailoutOnAlreadyFinishedWork(current2, workInProgress2, renderLanes2);
|
|
}
|
|
workInProgress2.flags |= PerformedWork;
|
|
reconcileChildren(current2, workInProgress2, nextChildren, renderLanes2);
|
|
return workInProgress2.child;
|
|
}
|
|
function updateClassComponent(current2, workInProgress2, Component5, nextProps, renderLanes2) {
|
|
{
|
|
if (workInProgress2.type !== workInProgress2.elementType) {
|
|
var innerPropTypes = Component5.propTypes;
|
|
if (innerPropTypes) {
|
|
checkPropTypes(innerPropTypes, nextProps, "prop", getComponentName(Component5));
|
|
}
|
|
}
|
|
}
|
|
var hasContext;
|
|
if (isContextProvider(Component5)) {
|
|
hasContext = true;
|
|
pushContextProvider(workInProgress2);
|
|
} else {
|
|
hasContext = false;
|
|
}
|
|
prepareToReadContext(workInProgress2, renderLanes2);
|
|
var instance = workInProgress2.stateNode;
|
|
var shouldUpdate;
|
|
if (instance === null) {
|
|
if (current2 !== null) {
|
|
current2.alternate = null;
|
|
workInProgress2.alternate = null;
|
|
workInProgress2.flags |= Placement;
|
|
}
|
|
constructClassInstance(workInProgress2, Component5, nextProps);
|
|
mountClassInstance(workInProgress2, Component5, nextProps, renderLanes2);
|
|
shouldUpdate = true;
|
|
} else if (current2 === null) {
|
|
shouldUpdate = resumeMountClassInstance(workInProgress2, Component5, nextProps, renderLanes2);
|
|
} else {
|
|
shouldUpdate = updateClassInstance(current2, workInProgress2, Component5, nextProps, renderLanes2);
|
|
}
|
|
var nextUnitOfWork = finishClassComponent(current2, workInProgress2, Component5, shouldUpdate, hasContext, renderLanes2);
|
|
{
|
|
var inst = workInProgress2.stateNode;
|
|
if (shouldUpdate && inst.props !== nextProps) {
|
|
if (!didWarnAboutReassigningProps) {
|
|
error("It looks like %s is reassigning its own `this.props` while rendering. This is not supported and can lead to confusing bugs.", getComponentName(workInProgress2.type) || "a component");
|
|
}
|
|
didWarnAboutReassigningProps = true;
|
|
}
|
|
}
|
|
return nextUnitOfWork;
|
|
}
|
|
function finishClassComponent(current2, workInProgress2, Component5, shouldUpdate, hasContext, renderLanes2) {
|
|
markRef(current2, workInProgress2);
|
|
var didCaptureError = (workInProgress2.flags & DidCapture) !== NoFlags;
|
|
if (!shouldUpdate && !didCaptureError) {
|
|
if (hasContext) {
|
|
invalidateContextProvider(workInProgress2, Component5, false);
|
|
}
|
|
return bailoutOnAlreadyFinishedWork(current2, workInProgress2, renderLanes2);
|
|
}
|
|
var instance = workInProgress2.stateNode;
|
|
ReactCurrentOwner$1.current = workInProgress2;
|
|
var nextChildren;
|
|
if (didCaptureError && typeof Component5.getDerivedStateFromError !== "function") {
|
|
nextChildren = null;
|
|
{
|
|
stopProfilerTimerIfRunning();
|
|
}
|
|
} else {
|
|
{
|
|
setIsRendering(true);
|
|
nextChildren = instance.render();
|
|
if (workInProgress2.mode & StrictMode) {
|
|
disableLogs();
|
|
try {
|
|
instance.render();
|
|
} finally {
|
|
reenableLogs();
|
|
}
|
|
}
|
|
setIsRendering(false);
|
|
}
|
|
}
|
|
workInProgress2.flags |= PerformedWork;
|
|
if (current2 !== null && didCaptureError) {
|
|
forceUnmountCurrentAndReconcile(current2, workInProgress2, nextChildren, renderLanes2);
|
|
} else {
|
|
reconcileChildren(current2, workInProgress2, nextChildren, renderLanes2);
|
|
}
|
|
workInProgress2.memoizedState = instance.state;
|
|
if (hasContext) {
|
|
invalidateContextProvider(workInProgress2, Component5, true);
|
|
}
|
|
return workInProgress2.child;
|
|
}
|
|
function pushHostRootContext(workInProgress2) {
|
|
var root2 = workInProgress2.stateNode;
|
|
if (root2.pendingContext) {
|
|
pushTopLevelContextObject(workInProgress2, root2.pendingContext, root2.pendingContext !== root2.context);
|
|
} else if (root2.context) {
|
|
pushTopLevelContextObject(workInProgress2, root2.context, false);
|
|
}
|
|
pushHostContainer(workInProgress2, root2.containerInfo);
|
|
}
|
|
function updateHostRoot(current2, workInProgress2, renderLanes2) {
|
|
pushHostRootContext(workInProgress2);
|
|
var updateQueue = workInProgress2.updateQueue;
|
|
if (!(current2 !== null && updateQueue !== null)) {
|
|
{
|
|
throw Error("If the root does not have an updateQueue, we should have already bailed out. This error is likely caused by a bug in React. Please file an issue.");
|
|
}
|
|
}
|
|
var nextProps = workInProgress2.pendingProps;
|
|
var prevState = workInProgress2.memoizedState;
|
|
var prevChildren = prevState !== null ? prevState.element : null;
|
|
cloneUpdateQueue(current2, workInProgress2);
|
|
processUpdateQueue(workInProgress2, nextProps, null, renderLanes2);
|
|
var nextState = workInProgress2.memoizedState;
|
|
var nextChildren = nextState.element;
|
|
if (nextChildren === prevChildren) {
|
|
resetHydrationState();
|
|
return bailoutOnAlreadyFinishedWork(current2, workInProgress2, renderLanes2);
|
|
}
|
|
var root2 = workInProgress2.stateNode;
|
|
if (root2.hydrate && enterHydrationState(workInProgress2)) {
|
|
{
|
|
var mutableSourceEagerHydrationData = root2.mutableSourceEagerHydrationData;
|
|
if (mutableSourceEagerHydrationData != null) {
|
|
for (var i3 = 0; i3 < mutableSourceEagerHydrationData.length; i3 += 2) {
|
|
var mutableSource = mutableSourceEagerHydrationData[i3];
|
|
var version = mutableSourceEagerHydrationData[i3 + 1];
|
|
setWorkInProgressVersion(mutableSource, version);
|
|
}
|
|
}
|
|
}
|
|
var child = mountChildFibers(workInProgress2, null, nextChildren, renderLanes2);
|
|
workInProgress2.child = child;
|
|
var node = child;
|
|
while (node) {
|
|
node.flags = node.flags & ~Placement | Hydrating;
|
|
node = node.sibling;
|
|
}
|
|
} else {
|
|
reconcileChildren(current2, workInProgress2, nextChildren, renderLanes2);
|
|
resetHydrationState();
|
|
}
|
|
return workInProgress2.child;
|
|
}
|
|
function updateHostComponent(current2, workInProgress2, renderLanes2) {
|
|
pushHostContext(workInProgress2);
|
|
if (current2 === null) {
|
|
tryToClaimNextHydratableInstance(workInProgress2);
|
|
}
|
|
var type = workInProgress2.type;
|
|
var nextProps = workInProgress2.pendingProps;
|
|
var prevProps = current2 !== null ? current2.memoizedProps : null;
|
|
var nextChildren = nextProps.children;
|
|
var isDirectTextChild = shouldSetTextContent(type, nextProps);
|
|
if (isDirectTextChild) {
|
|
nextChildren = null;
|
|
} else if (prevProps !== null && shouldSetTextContent(type, prevProps)) {
|
|
workInProgress2.flags |= ContentReset;
|
|
}
|
|
markRef(current2, workInProgress2);
|
|
reconcileChildren(current2, workInProgress2, nextChildren, renderLanes2);
|
|
return workInProgress2.child;
|
|
}
|
|
function updateHostText(current2, workInProgress2) {
|
|
if (current2 === null) {
|
|
tryToClaimNextHydratableInstance(workInProgress2);
|
|
}
|
|
return null;
|
|
}
|
|
function mountLazyComponent(_current, workInProgress2, elementType, updateLanes, renderLanes2) {
|
|
if (_current !== null) {
|
|
_current.alternate = null;
|
|
workInProgress2.alternate = null;
|
|
workInProgress2.flags |= Placement;
|
|
}
|
|
var props = workInProgress2.pendingProps;
|
|
var lazyComponent = elementType;
|
|
var payload = lazyComponent._payload;
|
|
var init = lazyComponent._init;
|
|
var Component5 = init(payload);
|
|
workInProgress2.type = Component5;
|
|
var resolvedTag = workInProgress2.tag = resolveLazyComponentTag(Component5);
|
|
var resolvedProps = resolveDefaultProps(Component5, props);
|
|
var child;
|
|
switch (resolvedTag) {
|
|
case FunctionComponent: {
|
|
{
|
|
validateFunctionComponentInDev(workInProgress2, Component5);
|
|
workInProgress2.type = Component5 = resolveFunctionForHotReloading(Component5);
|
|
}
|
|
child = updateFunctionComponent(null, workInProgress2, Component5, resolvedProps, renderLanes2);
|
|
return child;
|
|
}
|
|
case ClassComponent: {
|
|
{
|
|
workInProgress2.type = Component5 = resolveClassForHotReloading(Component5);
|
|
}
|
|
child = updateClassComponent(null, workInProgress2, Component5, resolvedProps, renderLanes2);
|
|
return child;
|
|
}
|
|
case ForwardRef: {
|
|
{
|
|
workInProgress2.type = Component5 = resolveForwardRefForHotReloading(Component5);
|
|
}
|
|
child = updateForwardRef(null, workInProgress2, Component5, resolvedProps, renderLanes2);
|
|
return child;
|
|
}
|
|
case MemoComponent: {
|
|
{
|
|
if (workInProgress2.type !== workInProgress2.elementType) {
|
|
var outerPropTypes = Component5.propTypes;
|
|
if (outerPropTypes) {
|
|
checkPropTypes(outerPropTypes, resolvedProps, "prop", getComponentName(Component5));
|
|
}
|
|
}
|
|
}
|
|
child = updateMemoComponent(null, workInProgress2, Component5, resolveDefaultProps(Component5.type, resolvedProps), updateLanes, renderLanes2);
|
|
return child;
|
|
}
|
|
}
|
|
var hint = "";
|
|
{
|
|
if (Component5 !== null && typeof Component5 === "object" && Component5.$$typeof === REACT_LAZY_TYPE) {
|
|
hint = " Did you wrap a component in React.lazy() more than once?";
|
|
}
|
|
}
|
|
{
|
|
{
|
|
throw Error("Element type is invalid. Received a promise that resolves to: " + Component5 + ". Lazy element type must resolve to a class or function." + hint);
|
|
}
|
|
}
|
|
}
|
|
function mountIncompleteClassComponent(_current, workInProgress2, Component5, nextProps, renderLanes2) {
|
|
if (_current !== null) {
|
|
_current.alternate = null;
|
|
workInProgress2.alternate = null;
|
|
workInProgress2.flags |= Placement;
|
|
}
|
|
workInProgress2.tag = ClassComponent;
|
|
var hasContext;
|
|
if (isContextProvider(Component5)) {
|
|
hasContext = true;
|
|
pushContextProvider(workInProgress2);
|
|
} else {
|
|
hasContext = false;
|
|
}
|
|
prepareToReadContext(workInProgress2, renderLanes2);
|
|
constructClassInstance(workInProgress2, Component5, nextProps);
|
|
mountClassInstance(workInProgress2, Component5, nextProps, renderLanes2);
|
|
return finishClassComponent(null, workInProgress2, Component5, true, hasContext, renderLanes2);
|
|
}
|
|
function mountIndeterminateComponent(_current, workInProgress2, Component5, renderLanes2) {
|
|
if (_current !== null) {
|
|
_current.alternate = null;
|
|
workInProgress2.alternate = null;
|
|
workInProgress2.flags |= Placement;
|
|
}
|
|
var props = workInProgress2.pendingProps;
|
|
var context;
|
|
{
|
|
var unmaskedContext = getUnmaskedContext(workInProgress2, Component5, false);
|
|
context = getMaskedContext(workInProgress2, unmaskedContext);
|
|
}
|
|
prepareToReadContext(workInProgress2, renderLanes2);
|
|
var value;
|
|
{
|
|
if (Component5.prototype && typeof Component5.prototype.render === "function") {
|
|
var componentName = getComponentName(Component5) || "Unknown";
|
|
if (!didWarnAboutBadClass[componentName]) {
|
|
error("The <%s /> component appears to have a render method, but doesn't extend React.Component. This is likely to cause errors. Change %s to extend React.Component instead.", componentName, componentName);
|
|
didWarnAboutBadClass[componentName] = true;
|
|
}
|
|
}
|
|
if (workInProgress2.mode & StrictMode) {
|
|
ReactStrictModeWarnings.recordLegacyContextWarning(workInProgress2, null);
|
|
}
|
|
setIsRendering(true);
|
|
ReactCurrentOwner$1.current = workInProgress2;
|
|
value = renderWithHooks(null, workInProgress2, Component5, props, context, renderLanes2);
|
|
setIsRendering(false);
|
|
}
|
|
workInProgress2.flags |= PerformedWork;
|
|
{
|
|
if (typeof value === "object" && value !== null && typeof value.render === "function" && value.$$typeof === void 0) {
|
|
var _componentName = getComponentName(Component5) || "Unknown";
|
|
if (!didWarnAboutModulePatternComponent[_componentName]) {
|
|
error("The <%s /> component appears to be a function component that returns a class instance. Change %s to a class that extends React.Component instead. If you can't use a class try assigning the prototype on the function as a workaround. `%s.prototype = React.Component.prototype`. Don't use an arrow function since it cannot be called with `new` by React.", _componentName, _componentName, _componentName);
|
|
didWarnAboutModulePatternComponent[_componentName] = true;
|
|
}
|
|
}
|
|
}
|
|
if (typeof value === "object" && value !== null && typeof value.render === "function" && value.$$typeof === void 0) {
|
|
{
|
|
var _componentName2 = getComponentName(Component5) || "Unknown";
|
|
if (!didWarnAboutModulePatternComponent[_componentName2]) {
|
|
error("The <%s /> component appears to be a function component that returns a class instance. Change %s to a class that extends React.Component instead. If you can't use a class try assigning the prototype on the function as a workaround. `%s.prototype = React.Component.prototype`. Don't use an arrow function since it cannot be called with `new` by React.", _componentName2, _componentName2, _componentName2);
|
|
didWarnAboutModulePatternComponent[_componentName2] = true;
|
|
}
|
|
}
|
|
workInProgress2.tag = ClassComponent;
|
|
workInProgress2.memoizedState = null;
|
|
workInProgress2.updateQueue = null;
|
|
var hasContext = false;
|
|
if (isContextProvider(Component5)) {
|
|
hasContext = true;
|
|
pushContextProvider(workInProgress2);
|
|
} else {
|
|
hasContext = false;
|
|
}
|
|
workInProgress2.memoizedState = value.state !== null && value.state !== void 0 ? value.state : null;
|
|
initializeUpdateQueue(workInProgress2);
|
|
var getDerivedStateFromProps = Component5.getDerivedStateFromProps;
|
|
if (typeof getDerivedStateFromProps === "function") {
|
|
applyDerivedStateFromProps(workInProgress2, Component5, getDerivedStateFromProps, props);
|
|
}
|
|
adoptClassInstance(workInProgress2, value);
|
|
mountClassInstance(workInProgress2, Component5, props, renderLanes2);
|
|
return finishClassComponent(null, workInProgress2, Component5, true, hasContext, renderLanes2);
|
|
} else {
|
|
workInProgress2.tag = FunctionComponent;
|
|
{
|
|
if (workInProgress2.mode & StrictMode) {
|
|
disableLogs();
|
|
try {
|
|
value = renderWithHooks(null, workInProgress2, Component5, props, context, renderLanes2);
|
|
} finally {
|
|
reenableLogs();
|
|
}
|
|
}
|
|
}
|
|
reconcileChildren(null, workInProgress2, value, renderLanes2);
|
|
{
|
|
validateFunctionComponentInDev(workInProgress2, Component5);
|
|
}
|
|
return workInProgress2.child;
|
|
}
|
|
}
|
|
function validateFunctionComponentInDev(workInProgress2, Component5) {
|
|
{
|
|
if (Component5) {
|
|
if (Component5.childContextTypes) {
|
|
error("%s(...): childContextTypes cannot be defined on a function component.", Component5.displayName || Component5.name || "Component");
|
|
}
|
|
}
|
|
if (workInProgress2.ref !== null) {
|
|
var info = "";
|
|
var ownerName = getCurrentFiberOwnerNameInDevOrNull();
|
|
if (ownerName) {
|
|
info += "\n\nCheck the render method of `" + ownerName + "`.";
|
|
}
|
|
var warningKey = ownerName || workInProgress2._debugID || "";
|
|
var debugSource = workInProgress2._debugSource;
|
|
if (debugSource) {
|
|
warningKey = debugSource.fileName + ":" + debugSource.lineNumber;
|
|
}
|
|
if (!didWarnAboutFunctionRefs[warningKey]) {
|
|
didWarnAboutFunctionRefs[warningKey] = true;
|
|
error("Function components cannot be given refs. Attempts to access this ref will fail. Did you mean to use React.forwardRef()?%s", info);
|
|
}
|
|
}
|
|
if (typeof Component5.getDerivedStateFromProps === "function") {
|
|
var _componentName3 = getComponentName(Component5) || "Unknown";
|
|
if (!didWarnAboutGetDerivedStateOnFunctionComponent[_componentName3]) {
|
|
error("%s: Function components do not support getDerivedStateFromProps.", _componentName3);
|
|
didWarnAboutGetDerivedStateOnFunctionComponent[_componentName3] = true;
|
|
}
|
|
}
|
|
if (typeof Component5.contextType === "object" && Component5.contextType !== null) {
|
|
var _componentName4 = getComponentName(Component5) || "Unknown";
|
|
if (!didWarnAboutContextTypeOnFunctionComponent[_componentName4]) {
|
|
error("%s: Function components do not support contextType.", _componentName4);
|
|
didWarnAboutContextTypeOnFunctionComponent[_componentName4] = true;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
var SUSPENDED_MARKER = {
|
|
dehydrated: null,
|
|
retryLane: NoLane
|
|
};
|
|
function mountSuspenseOffscreenState(renderLanes2) {
|
|
return {
|
|
baseLanes: renderLanes2
|
|
};
|
|
}
|
|
function updateSuspenseOffscreenState(prevOffscreenState, renderLanes2) {
|
|
return {
|
|
baseLanes: mergeLanes(prevOffscreenState.baseLanes, renderLanes2)
|
|
};
|
|
}
|
|
function shouldRemainOnFallback(suspenseContext, current2, workInProgress2, renderLanes2) {
|
|
if (current2 !== null) {
|
|
var suspenseState = current2.memoizedState;
|
|
if (suspenseState === null) {
|
|
return false;
|
|
}
|
|
}
|
|
return hasSuspenseContext(suspenseContext, ForceSuspenseFallback);
|
|
}
|
|
function getRemainingWorkInPrimaryTree(current2, renderLanes2) {
|
|
return removeLanes(current2.childLanes, renderLanes2);
|
|
}
|
|
function updateSuspenseComponent(current2, workInProgress2, renderLanes2) {
|
|
var nextProps = workInProgress2.pendingProps;
|
|
{
|
|
if (shouldSuspend(workInProgress2)) {
|
|
workInProgress2.flags |= DidCapture;
|
|
}
|
|
}
|
|
var suspenseContext = suspenseStackCursor.current;
|
|
var showFallback = false;
|
|
var didSuspend = (workInProgress2.flags & DidCapture) !== NoFlags;
|
|
if (didSuspend || shouldRemainOnFallback(suspenseContext, current2)) {
|
|
showFallback = true;
|
|
workInProgress2.flags &= ~DidCapture;
|
|
} else {
|
|
if (current2 === null || current2.memoizedState !== null) {
|
|
if (nextProps.fallback !== void 0 && nextProps.unstable_avoidThisFallback !== true) {
|
|
suspenseContext = addSubtreeSuspenseContext(suspenseContext, InvisibleParentSuspenseContext);
|
|
}
|
|
}
|
|
}
|
|
suspenseContext = setDefaultShallowSuspenseContext(suspenseContext);
|
|
pushSuspenseContext(workInProgress2, suspenseContext);
|
|
if (current2 === null) {
|
|
if (nextProps.fallback !== void 0) {
|
|
tryToClaimNextHydratableInstance(workInProgress2);
|
|
}
|
|
var nextPrimaryChildren = nextProps.children;
|
|
var nextFallbackChildren = nextProps.fallback;
|
|
if (showFallback) {
|
|
var fallbackFragment = mountSuspenseFallbackChildren(workInProgress2, nextPrimaryChildren, nextFallbackChildren, renderLanes2);
|
|
var primaryChildFragment = workInProgress2.child;
|
|
primaryChildFragment.memoizedState = mountSuspenseOffscreenState(renderLanes2);
|
|
workInProgress2.memoizedState = SUSPENDED_MARKER;
|
|
return fallbackFragment;
|
|
} else if (typeof nextProps.unstable_expectedLoadTime === "number") {
|
|
var _fallbackFragment = mountSuspenseFallbackChildren(workInProgress2, nextPrimaryChildren, nextFallbackChildren, renderLanes2);
|
|
var _primaryChildFragment = workInProgress2.child;
|
|
_primaryChildFragment.memoizedState = mountSuspenseOffscreenState(renderLanes2);
|
|
workInProgress2.memoizedState = SUSPENDED_MARKER;
|
|
workInProgress2.lanes = SomeRetryLane;
|
|
{
|
|
markSpawnedWork(SomeRetryLane);
|
|
}
|
|
return _fallbackFragment;
|
|
} else {
|
|
return mountSuspensePrimaryChildren(workInProgress2, nextPrimaryChildren, renderLanes2);
|
|
}
|
|
} else {
|
|
var prevState = current2.memoizedState;
|
|
if (prevState !== null) {
|
|
if (showFallback) {
|
|
var _nextFallbackChildren2 = nextProps.fallback;
|
|
var _nextPrimaryChildren2 = nextProps.children;
|
|
var _fallbackChildFragment = updateSuspenseFallbackChildren(current2, workInProgress2, _nextPrimaryChildren2, _nextFallbackChildren2, renderLanes2);
|
|
var _primaryChildFragment3 = workInProgress2.child;
|
|
var prevOffscreenState = current2.child.memoizedState;
|
|
_primaryChildFragment3.memoizedState = prevOffscreenState === null ? mountSuspenseOffscreenState(renderLanes2) : updateSuspenseOffscreenState(prevOffscreenState, renderLanes2);
|
|
_primaryChildFragment3.childLanes = getRemainingWorkInPrimaryTree(current2, renderLanes2);
|
|
workInProgress2.memoizedState = SUSPENDED_MARKER;
|
|
return _fallbackChildFragment;
|
|
} else {
|
|
var _nextPrimaryChildren3 = nextProps.children;
|
|
var _primaryChildFragment4 = updateSuspensePrimaryChildren(current2, workInProgress2, _nextPrimaryChildren3, renderLanes2);
|
|
workInProgress2.memoizedState = null;
|
|
return _primaryChildFragment4;
|
|
}
|
|
} else {
|
|
if (showFallback) {
|
|
var _nextFallbackChildren3 = nextProps.fallback;
|
|
var _nextPrimaryChildren4 = nextProps.children;
|
|
var _fallbackChildFragment2 = updateSuspenseFallbackChildren(current2, workInProgress2, _nextPrimaryChildren4, _nextFallbackChildren3, renderLanes2);
|
|
var _primaryChildFragment5 = workInProgress2.child;
|
|
var _prevOffscreenState = current2.child.memoizedState;
|
|
_primaryChildFragment5.memoizedState = _prevOffscreenState === null ? mountSuspenseOffscreenState(renderLanes2) : updateSuspenseOffscreenState(_prevOffscreenState, renderLanes2);
|
|
_primaryChildFragment5.childLanes = getRemainingWorkInPrimaryTree(current2, renderLanes2);
|
|
workInProgress2.memoizedState = SUSPENDED_MARKER;
|
|
return _fallbackChildFragment2;
|
|
} else {
|
|
var _nextPrimaryChildren5 = nextProps.children;
|
|
var _primaryChildFragment6 = updateSuspensePrimaryChildren(current2, workInProgress2, _nextPrimaryChildren5, renderLanes2);
|
|
workInProgress2.memoizedState = null;
|
|
return _primaryChildFragment6;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
function mountSuspensePrimaryChildren(workInProgress2, primaryChildren, renderLanes2) {
|
|
var mode = workInProgress2.mode;
|
|
var primaryChildProps = {
|
|
mode: "visible",
|
|
children: primaryChildren
|
|
};
|
|
var primaryChildFragment = createFiberFromOffscreen(primaryChildProps, mode, renderLanes2, null);
|
|
primaryChildFragment.return = workInProgress2;
|
|
workInProgress2.child = primaryChildFragment;
|
|
return primaryChildFragment;
|
|
}
|
|
function mountSuspenseFallbackChildren(workInProgress2, primaryChildren, fallbackChildren, renderLanes2) {
|
|
var mode = workInProgress2.mode;
|
|
var progressedPrimaryFragment = workInProgress2.child;
|
|
var primaryChildProps = {
|
|
mode: "hidden",
|
|
children: primaryChildren
|
|
};
|
|
var primaryChildFragment;
|
|
var fallbackChildFragment;
|
|
if ((mode & BlockingMode) === NoMode && progressedPrimaryFragment !== null) {
|
|
primaryChildFragment = progressedPrimaryFragment;
|
|
primaryChildFragment.childLanes = NoLanes;
|
|
primaryChildFragment.pendingProps = primaryChildProps;
|
|
if (workInProgress2.mode & ProfileMode) {
|
|
primaryChildFragment.actualDuration = 0;
|
|
primaryChildFragment.actualStartTime = -1;
|
|
primaryChildFragment.selfBaseDuration = 0;
|
|
primaryChildFragment.treeBaseDuration = 0;
|
|
}
|
|
fallbackChildFragment = createFiberFromFragment(fallbackChildren, mode, renderLanes2, null);
|
|
} else {
|
|
primaryChildFragment = createFiberFromOffscreen(primaryChildProps, mode, NoLanes, null);
|
|
fallbackChildFragment = createFiberFromFragment(fallbackChildren, mode, renderLanes2, null);
|
|
}
|
|
primaryChildFragment.return = workInProgress2;
|
|
fallbackChildFragment.return = workInProgress2;
|
|
primaryChildFragment.sibling = fallbackChildFragment;
|
|
workInProgress2.child = primaryChildFragment;
|
|
return fallbackChildFragment;
|
|
}
|
|
function createWorkInProgressOffscreenFiber(current2, offscreenProps) {
|
|
return createWorkInProgress(current2, offscreenProps);
|
|
}
|
|
function updateSuspensePrimaryChildren(current2, workInProgress2, primaryChildren, renderLanes2) {
|
|
var currentPrimaryChildFragment = current2.child;
|
|
var currentFallbackChildFragment = currentPrimaryChildFragment.sibling;
|
|
var primaryChildFragment = createWorkInProgressOffscreenFiber(currentPrimaryChildFragment, {
|
|
mode: "visible",
|
|
children: primaryChildren
|
|
});
|
|
if ((workInProgress2.mode & BlockingMode) === NoMode) {
|
|
primaryChildFragment.lanes = renderLanes2;
|
|
}
|
|
primaryChildFragment.return = workInProgress2;
|
|
primaryChildFragment.sibling = null;
|
|
if (currentFallbackChildFragment !== null) {
|
|
currentFallbackChildFragment.nextEffect = null;
|
|
currentFallbackChildFragment.flags = Deletion;
|
|
workInProgress2.firstEffect = workInProgress2.lastEffect = currentFallbackChildFragment;
|
|
}
|
|
workInProgress2.child = primaryChildFragment;
|
|
return primaryChildFragment;
|
|
}
|
|
function updateSuspenseFallbackChildren(current2, workInProgress2, primaryChildren, fallbackChildren, renderLanes2) {
|
|
var mode = workInProgress2.mode;
|
|
var currentPrimaryChildFragment = current2.child;
|
|
var currentFallbackChildFragment = currentPrimaryChildFragment.sibling;
|
|
var primaryChildProps = {
|
|
mode: "hidden",
|
|
children: primaryChildren
|
|
};
|
|
var primaryChildFragment;
|
|
if ((mode & BlockingMode) === NoMode && workInProgress2.child !== currentPrimaryChildFragment) {
|
|
var progressedPrimaryFragment = workInProgress2.child;
|
|
primaryChildFragment = progressedPrimaryFragment;
|
|
primaryChildFragment.childLanes = NoLanes;
|
|
primaryChildFragment.pendingProps = primaryChildProps;
|
|
if (workInProgress2.mode & ProfileMode) {
|
|
primaryChildFragment.actualDuration = 0;
|
|
primaryChildFragment.actualStartTime = -1;
|
|
primaryChildFragment.selfBaseDuration = currentPrimaryChildFragment.selfBaseDuration;
|
|
primaryChildFragment.treeBaseDuration = currentPrimaryChildFragment.treeBaseDuration;
|
|
}
|
|
var progressedLastEffect = primaryChildFragment.lastEffect;
|
|
if (progressedLastEffect !== null) {
|
|
workInProgress2.firstEffect = primaryChildFragment.firstEffect;
|
|
workInProgress2.lastEffect = progressedLastEffect;
|
|
progressedLastEffect.nextEffect = null;
|
|
} else {
|
|
workInProgress2.firstEffect = workInProgress2.lastEffect = null;
|
|
}
|
|
} else {
|
|
primaryChildFragment = createWorkInProgressOffscreenFiber(currentPrimaryChildFragment, primaryChildProps);
|
|
}
|
|
var fallbackChildFragment;
|
|
if (currentFallbackChildFragment !== null) {
|
|
fallbackChildFragment = createWorkInProgress(currentFallbackChildFragment, fallbackChildren);
|
|
} else {
|
|
fallbackChildFragment = createFiberFromFragment(fallbackChildren, mode, renderLanes2, null);
|
|
fallbackChildFragment.flags |= Placement;
|
|
}
|
|
fallbackChildFragment.return = workInProgress2;
|
|
primaryChildFragment.return = workInProgress2;
|
|
primaryChildFragment.sibling = fallbackChildFragment;
|
|
workInProgress2.child = primaryChildFragment;
|
|
return fallbackChildFragment;
|
|
}
|
|
function scheduleWorkOnFiber(fiber, renderLanes2) {
|
|
fiber.lanes = mergeLanes(fiber.lanes, renderLanes2);
|
|
var alternate = fiber.alternate;
|
|
if (alternate !== null) {
|
|
alternate.lanes = mergeLanes(alternate.lanes, renderLanes2);
|
|
}
|
|
scheduleWorkOnParentPath(fiber.return, renderLanes2);
|
|
}
|
|
function propagateSuspenseContextChange(workInProgress2, firstChild, renderLanes2) {
|
|
var node = firstChild;
|
|
while (node !== null) {
|
|
if (node.tag === SuspenseComponent) {
|
|
var state = node.memoizedState;
|
|
if (state !== null) {
|
|
scheduleWorkOnFiber(node, renderLanes2);
|
|
}
|
|
} else if (node.tag === SuspenseListComponent) {
|
|
scheduleWorkOnFiber(node, renderLanes2);
|
|
} else if (node.child !== null) {
|
|
node.child.return = node;
|
|
node = node.child;
|
|
continue;
|
|
}
|
|
if (node === workInProgress2) {
|
|
return;
|
|
}
|
|
while (node.sibling === null) {
|
|
if (node.return === null || node.return === workInProgress2) {
|
|
return;
|
|
}
|
|
node = node.return;
|
|
}
|
|
node.sibling.return = node.return;
|
|
node = node.sibling;
|
|
}
|
|
}
|
|
function findLastContentRow(firstChild) {
|
|
var row = firstChild;
|
|
var lastContentRow = null;
|
|
while (row !== null) {
|
|
var currentRow = row.alternate;
|
|
if (currentRow !== null && findFirstSuspended(currentRow) === null) {
|
|
lastContentRow = row;
|
|
}
|
|
row = row.sibling;
|
|
}
|
|
return lastContentRow;
|
|
}
|
|
function validateRevealOrder(revealOrder) {
|
|
{
|
|
if (revealOrder !== void 0 && revealOrder !== "forwards" && revealOrder !== "backwards" && revealOrder !== "together" && !didWarnAboutRevealOrder[revealOrder]) {
|
|
didWarnAboutRevealOrder[revealOrder] = true;
|
|
if (typeof revealOrder === "string") {
|
|
switch (revealOrder.toLowerCase()) {
|
|
case "together":
|
|
case "forwards":
|
|
case "backwards": {
|
|
error('"%s" is not a valid value for revealOrder on <SuspenseList />. Use lowercase "%s" instead.', revealOrder, revealOrder.toLowerCase());
|
|
break;
|
|
}
|
|
case "forward":
|
|
case "backward": {
|
|
error('"%s" is not a valid value for revealOrder on <SuspenseList />. React uses the -s suffix in the spelling. Use "%ss" instead.', revealOrder, revealOrder.toLowerCase());
|
|
break;
|
|
}
|
|
default:
|
|
error('"%s" is not a supported revealOrder on <SuspenseList />. Did you mean "together", "forwards" or "backwards"?', revealOrder);
|
|
break;
|
|
}
|
|
} else {
|
|
error('%s is not a supported value for revealOrder on <SuspenseList />. Did you mean "together", "forwards" or "backwards"?', revealOrder);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
function validateTailOptions(tailMode, revealOrder) {
|
|
{
|
|
if (tailMode !== void 0 && !didWarnAboutTailOptions[tailMode]) {
|
|
if (tailMode !== "collapsed" && tailMode !== "hidden") {
|
|
didWarnAboutTailOptions[tailMode] = true;
|
|
error('"%s" is not a supported value for tail on <SuspenseList />. Did you mean "collapsed" or "hidden"?', tailMode);
|
|
} else if (revealOrder !== "forwards" && revealOrder !== "backwards") {
|
|
didWarnAboutTailOptions[tailMode] = true;
|
|
error('<SuspenseList tail="%s" /> is only valid if revealOrder is "forwards" or "backwards". Did you mean to specify revealOrder="forwards"?', tailMode);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
function validateSuspenseListNestedChild(childSlot, index2) {
|
|
{
|
|
var isArray2 = Array.isArray(childSlot);
|
|
var isIterable = !isArray2 && typeof getIteratorFn(childSlot) === "function";
|
|
if (isArray2 || isIterable) {
|
|
var type = isArray2 ? "array" : "iterable";
|
|
error("A nested %s was passed to row #%s in <SuspenseList />. Wrap it in an additional SuspenseList to configure its revealOrder: <SuspenseList revealOrder=...> ... <SuspenseList revealOrder=...>{%s}</SuspenseList> ... </SuspenseList>", type, index2, type);
|
|
return false;
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
function validateSuspenseListChildren(children, revealOrder) {
|
|
{
|
|
if ((revealOrder === "forwards" || revealOrder === "backwards") && children !== void 0 && children !== null && children !== false) {
|
|
if (Array.isArray(children)) {
|
|
for (var i3 = 0; i3 < children.length; i3++) {
|
|
if (!validateSuspenseListNestedChild(children[i3], i3)) {
|
|
return;
|
|
}
|
|
}
|
|
} else {
|
|
var iteratorFn = getIteratorFn(children);
|
|
if (typeof iteratorFn === "function") {
|
|
var childrenIterator = iteratorFn.call(children);
|
|
if (childrenIterator) {
|
|
var step = childrenIterator.next();
|
|
var _i = 0;
|
|
for (; !step.done; step = childrenIterator.next()) {
|
|
if (!validateSuspenseListNestedChild(step.value, _i)) {
|
|
return;
|
|
}
|
|
_i++;
|
|
}
|
|
}
|
|
} else {
|
|
error('A single row was passed to a <SuspenseList revealOrder="%s" />. This is not useful since it needs multiple rows. Did you mean to pass multiple children or an array?', revealOrder);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
function initSuspenseListRenderState(workInProgress2, isBackwards, tail, lastContentRow, tailMode, lastEffectBeforeRendering) {
|
|
var renderState = workInProgress2.memoizedState;
|
|
if (renderState === null) {
|
|
workInProgress2.memoizedState = {
|
|
isBackwards,
|
|
rendering: null,
|
|
renderingStartTime: 0,
|
|
last: lastContentRow,
|
|
tail,
|
|
tailMode,
|
|
lastEffect: lastEffectBeforeRendering
|
|
};
|
|
} else {
|
|
renderState.isBackwards = isBackwards;
|
|
renderState.rendering = null;
|
|
renderState.renderingStartTime = 0;
|
|
renderState.last = lastContentRow;
|
|
renderState.tail = tail;
|
|
renderState.tailMode = tailMode;
|
|
renderState.lastEffect = lastEffectBeforeRendering;
|
|
}
|
|
}
|
|
function updateSuspenseListComponent(current2, workInProgress2, renderLanes2) {
|
|
var nextProps = workInProgress2.pendingProps;
|
|
var revealOrder = nextProps.revealOrder;
|
|
var tailMode = nextProps.tail;
|
|
var newChildren = nextProps.children;
|
|
validateRevealOrder(revealOrder);
|
|
validateTailOptions(tailMode, revealOrder);
|
|
validateSuspenseListChildren(newChildren, revealOrder);
|
|
reconcileChildren(current2, workInProgress2, newChildren, renderLanes2);
|
|
var suspenseContext = suspenseStackCursor.current;
|
|
var shouldForceFallback = hasSuspenseContext(suspenseContext, ForceSuspenseFallback);
|
|
if (shouldForceFallback) {
|
|
suspenseContext = setShallowSuspenseContext(suspenseContext, ForceSuspenseFallback);
|
|
workInProgress2.flags |= DidCapture;
|
|
} else {
|
|
var didSuspendBefore = current2 !== null && (current2.flags & DidCapture) !== NoFlags;
|
|
if (didSuspendBefore) {
|
|
propagateSuspenseContextChange(workInProgress2, workInProgress2.child, renderLanes2);
|
|
}
|
|
suspenseContext = setDefaultShallowSuspenseContext(suspenseContext);
|
|
}
|
|
pushSuspenseContext(workInProgress2, suspenseContext);
|
|
if ((workInProgress2.mode & BlockingMode) === NoMode) {
|
|
workInProgress2.memoizedState = null;
|
|
} else {
|
|
switch (revealOrder) {
|
|
case "forwards": {
|
|
var lastContentRow = findLastContentRow(workInProgress2.child);
|
|
var tail;
|
|
if (lastContentRow === null) {
|
|
tail = workInProgress2.child;
|
|
workInProgress2.child = null;
|
|
} else {
|
|
tail = lastContentRow.sibling;
|
|
lastContentRow.sibling = null;
|
|
}
|
|
initSuspenseListRenderState(workInProgress2, false, tail, lastContentRow, tailMode, workInProgress2.lastEffect);
|
|
break;
|
|
}
|
|
case "backwards": {
|
|
var _tail = null;
|
|
var row = workInProgress2.child;
|
|
workInProgress2.child = null;
|
|
while (row !== null) {
|
|
var currentRow = row.alternate;
|
|
if (currentRow !== null && findFirstSuspended(currentRow) === null) {
|
|
workInProgress2.child = row;
|
|
break;
|
|
}
|
|
var nextRow = row.sibling;
|
|
row.sibling = _tail;
|
|
_tail = row;
|
|
row = nextRow;
|
|
}
|
|
initSuspenseListRenderState(workInProgress2, true, _tail, null, tailMode, workInProgress2.lastEffect);
|
|
break;
|
|
}
|
|
case "together": {
|
|
initSuspenseListRenderState(workInProgress2, false, null, null, void 0, workInProgress2.lastEffect);
|
|
break;
|
|
}
|
|
default: {
|
|
workInProgress2.memoizedState = null;
|
|
}
|
|
}
|
|
}
|
|
return workInProgress2.child;
|
|
}
|
|
function updatePortalComponent(current2, workInProgress2, renderLanes2) {
|
|
pushHostContainer(workInProgress2, workInProgress2.stateNode.containerInfo);
|
|
var nextChildren = workInProgress2.pendingProps;
|
|
if (current2 === null) {
|
|
workInProgress2.child = reconcileChildFibers(workInProgress2, null, nextChildren, renderLanes2);
|
|
} else {
|
|
reconcileChildren(current2, workInProgress2, nextChildren, renderLanes2);
|
|
}
|
|
return workInProgress2.child;
|
|
}
|
|
var hasWarnedAboutUsingNoValuePropOnContextProvider = false;
|
|
function updateContextProvider(current2, workInProgress2, renderLanes2) {
|
|
var providerType = workInProgress2.type;
|
|
var context = providerType._context;
|
|
var newProps = workInProgress2.pendingProps;
|
|
var oldProps = workInProgress2.memoizedProps;
|
|
var newValue = newProps.value;
|
|
{
|
|
if (!("value" in newProps)) {
|
|
if (!hasWarnedAboutUsingNoValuePropOnContextProvider) {
|
|
hasWarnedAboutUsingNoValuePropOnContextProvider = true;
|
|
error("The `value` prop is required for the `<Context.Provider>`. Did you misspell it or forget to pass it?");
|
|
}
|
|
}
|
|
var providerPropTypes = workInProgress2.type.propTypes;
|
|
if (providerPropTypes) {
|
|
checkPropTypes(providerPropTypes, newProps, "prop", "Context.Provider");
|
|
}
|
|
}
|
|
pushProvider(workInProgress2, newValue);
|
|
if (oldProps !== null) {
|
|
var oldValue = oldProps.value;
|
|
var changedBits = calculateChangedBits(context, newValue, oldValue);
|
|
if (changedBits === 0) {
|
|
if (oldProps.children === newProps.children && !hasContextChanged()) {
|
|
return bailoutOnAlreadyFinishedWork(current2, workInProgress2, renderLanes2);
|
|
}
|
|
} else {
|
|
propagateContextChange(workInProgress2, context, changedBits, renderLanes2);
|
|
}
|
|
}
|
|
var newChildren = newProps.children;
|
|
reconcileChildren(current2, workInProgress2, newChildren, renderLanes2);
|
|
return workInProgress2.child;
|
|
}
|
|
var hasWarnedAboutUsingContextAsConsumer = false;
|
|
function updateContextConsumer(current2, workInProgress2, renderLanes2) {
|
|
var context = workInProgress2.type;
|
|
{
|
|
if (context._context === void 0) {
|
|
if (context !== context.Consumer) {
|
|
if (!hasWarnedAboutUsingContextAsConsumer) {
|
|
hasWarnedAboutUsingContextAsConsumer = true;
|
|
error("Rendering <Context> directly is not supported and will be removed in a future major release. Did you mean to render <Context.Consumer> instead?");
|
|
}
|
|
}
|
|
} else {
|
|
context = context._context;
|
|
}
|
|
}
|
|
var newProps = workInProgress2.pendingProps;
|
|
var render5 = newProps.children;
|
|
{
|
|
if (typeof render5 !== "function") {
|
|
error("A context consumer was rendered with multiple children, or a child that isn't a function. A context consumer expects a single child that is a function. If you did pass a function, make sure there is no trailing or leading whitespace around it.");
|
|
}
|
|
}
|
|
prepareToReadContext(workInProgress2, renderLanes2);
|
|
var newValue = readContext(context, newProps.unstable_observedBits);
|
|
var newChildren;
|
|
{
|
|
ReactCurrentOwner$1.current = workInProgress2;
|
|
setIsRendering(true);
|
|
newChildren = render5(newValue);
|
|
setIsRendering(false);
|
|
}
|
|
workInProgress2.flags |= PerformedWork;
|
|
reconcileChildren(current2, workInProgress2, newChildren, renderLanes2);
|
|
return workInProgress2.child;
|
|
}
|
|
function markWorkInProgressReceivedUpdate() {
|
|
didReceiveUpdate = true;
|
|
}
|
|
function bailoutOnAlreadyFinishedWork(current2, workInProgress2, renderLanes2) {
|
|
if (current2 !== null) {
|
|
workInProgress2.dependencies = current2.dependencies;
|
|
}
|
|
{
|
|
stopProfilerTimerIfRunning();
|
|
}
|
|
markSkippedUpdateLanes(workInProgress2.lanes);
|
|
if (!includesSomeLane(renderLanes2, workInProgress2.childLanes)) {
|
|
return null;
|
|
} else {
|
|
cloneChildFibers(current2, workInProgress2);
|
|
return workInProgress2.child;
|
|
}
|
|
}
|
|
function remountFiber(current2, oldWorkInProgress, newWorkInProgress) {
|
|
{
|
|
var returnFiber = oldWorkInProgress.return;
|
|
if (returnFiber === null) {
|
|
throw new Error("Cannot swap the root fiber.");
|
|
}
|
|
current2.alternate = null;
|
|
oldWorkInProgress.alternate = null;
|
|
newWorkInProgress.index = oldWorkInProgress.index;
|
|
newWorkInProgress.sibling = oldWorkInProgress.sibling;
|
|
newWorkInProgress.return = oldWorkInProgress.return;
|
|
newWorkInProgress.ref = oldWorkInProgress.ref;
|
|
if (oldWorkInProgress === returnFiber.child) {
|
|
returnFiber.child = newWorkInProgress;
|
|
} else {
|
|
var prevSibling = returnFiber.child;
|
|
if (prevSibling === null) {
|
|
throw new Error("Expected parent to have a child.");
|
|
}
|
|
while (prevSibling.sibling !== oldWorkInProgress) {
|
|
prevSibling = prevSibling.sibling;
|
|
if (prevSibling === null) {
|
|
throw new Error("Expected to find the previous sibling.");
|
|
}
|
|
}
|
|
prevSibling.sibling = newWorkInProgress;
|
|
}
|
|
var last = returnFiber.lastEffect;
|
|
if (last !== null) {
|
|
last.nextEffect = current2;
|
|
returnFiber.lastEffect = current2;
|
|
} else {
|
|
returnFiber.firstEffect = returnFiber.lastEffect = current2;
|
|
}
|
|
current2.nextEffect = null;
|
|
current2.flags = Deletion;
|
|
newWorkInProgress.flags |= Placement;
|
|
return newWorkInProgress;
|
|
}
|
|
}
|
|
function beginWork(current2, workInProgress2, renderLanes2) {
|
|
var updateLanes = workInProgress2.lanes;
|
|
{
|
|
if (workInProgress2._debugNeedsRemount && current2 !== null) {
|
|
return remountFiber(current2, workInProgress2, createFiberFromTypeAndProps(workInProgress2.type, workInProgress2.key, workInProgress2.pendingProps, workInProgress2._debugOwner || null, workInProgress2.mode, workInProgress2.lanes));
|
|
}
|
|
}
|
|
if (current2 !== null) {
|
|
var oldProps = current2.memoizedProps;
|
|
var newProps = workInProgress2.pendingProps;
|
|
if (oldProps !== newProps || hasContextChanged() || workInProgress2.type !== current2.type) {
|
|
didReceiveUpdate = true;
|
|
} else if (!includesSomeLane(renderLanes2, updateLanes)) {
|
|
didReceiveUpdate = false;
|
|
switch (workInProgress2.tag) {
|
|
case HostRoot:
|
|
pushHostRootContext(workInProgress2);
|
|
resetHydrationState();
|
|
break;
|
|
case HostComponent:
|
|
pushHostContext(workInProgress2);
|
|
break;
|
|
case ClassComponent: {
|
|
var Component5 = workInProgress2.type;
|
|
if (isContextProvider(Component5)) {
|
|
pushContextProvider(workInProgress2);
|
|
}
|
|
break;
|
|
}
|
|
case HostPortal:
|
|
pushHostContainer(workInProgress2, workInProgress2.stateNode.containerInfo);
|
|
break;
|
|
case ContextProvider: {
|
|
var newValue = workInProgress2.memoizedProps.value;
|
|
pushProvider(workInProgress2, newValue);
|
|
break;
|
|
}
|
|
case Profiler:
|
|
{
|
|
var hasChildWork = includesSomeLane(renderLanes2, workInProgress2.childLanes);
|
|
if (hasChildWork) {
|
|
workInProgress2.flags |= Update;
|
|
}
|
|
var stateNode = workInProgress2.stateNode;
|
|
stateNode.effectDuration = 0;
|
|
stateNode.passiveEffectDuration = 0;
|
|
}
|
|
break;
|
|
case SuspenseComponent: {
|
|
var state = workInProgress2.memoizedState;
|
|
if (state !== null) {
|
|
var primaryChildFragment = workInProgress2.child;
|
|
var primaryChildLanes = primaryChildFragment.childLanes;
|
|
if (includesSomeLane(renderLanes2, primaryChildLanes)) {
|
|
return updateSuspenseComponent(current2, workInProgress2, renderLanes2);
|
|
} else {
|
|
pushSuspenseContext(workInProgress2, setDefaultShallowSuspenseContext(suspenseStackCursor.current));
|
|
var child = bailoutOnAlreadyFinishedWork(current2, workInProgress2, renderLanes2);
|
|
if (child !== null) {
|
|
return child.sibling;
|
|
} else {
|
|
return null;
|
|
}
|
|
}
|
|
} else {
|
|
pushSuspenseContext(workInProgress2, setDefaultShallowSuspenseContext(suspenseStackCursor.current));
|
|
}
|
|
break;
|
|
}
|
|
case SuspenseListComponent: {
|
|
var didSuspendBefore = (current2.flags & DidCapture) !== NoFlags;
|
|
var _hasChildWork = includesSomeLane(renderLanes2, workInProgress2.childLanes);
|
|
if (didSuspendBefore) {
|
|
if (_hasChildWork) {
|
|
return updateSuspenseListComponent(current2, workInProgress2, renderLanes2);
|
|
}
|
|
workInProgress2.flags |= DidCapture;
|
|
}
|
|
var renderState = workInProgress2.memoizedState;
|
|
if (renderState !== null) {
|
|
renderState.rendering = null;
|
|
renderState.tail = null;
|
|
renderState.lastEffect = null;
|
|
}
|
|
pushSuspenseContext(workInProgress2, suspenseStackCursor.current);
|
|
if (_hasChildWork) {
|
|
break;
|
|
} else {
|
|
return null;
|
|
}
|
|
}
|
|
case OffscreenComponent:
|
|
case LegacyHiddenComponent: {
|
|
workInProgress2.lanes = NoLanes;
|
|
return updateOffscreenComponent(current2, workInProgress2, renderLanes2);
|
|
}
|
|
}
|
|
return bailoutOnAlreadyFinishedWork(current2, workInProgress2, renderLanes2);
|
|
} else {
|
|
if ((current2.flags & ForceUpdateForLegacySuspense) !== NoFlags) {
|
|
didReceiveUpdate = true;
|
|
} else {
|
|
didReceiveUpdate = false;
|
|
}
|
|
}
|
|
} else {
|
|
didReceiveUpdate = false;
|
|
}
|
|
workInProgress2.lanes = NoLanes;
|
|
switch (workInProgress2.tag) {
|
|
case IndeterminateComponent: {
|
|
return mountIndeterminateComponent(current2, workInProgress2, workInProgress2.type, renderLanes2);
|
|
}
|
|
case LazyComponent: {
|
|
var elementType = workInProgress2.elementType;
|
|
return mountLazyComponent(current2, workInProgress2, elementType, updateLanes, renderLanes2);
|
|
}
|
|
case FunctionComponent: {
|
|
var _Component = workInProgress2.type;
|
|
var unresolvedProps = workInProgress2.pendingProps;
|
|
var resolvedProps = workInProgress2.elementType === _Component ? unresolvedProps : resolveDefaultProps(_Component, unresolvedProps);
|
|
return updateFunctionComponent(current2, workInProgress2, _Component, resolvedProps, renderLanes2);
|
|
}
|
|
case ClassComponent: {
|
|
var _Component2 = workInProgress2.type;
|
|
var _unresolvedProps = workInProgress2.pendingProps;
|
|
var _resolvedProps = workInProgress2.elementType === _Component2 ? _unresolvedProps : resolveDefaultProps(_Component2, _unresolvedProps);
|
|
return updateClassComponent(current2, workInProgress2, _Component2, _resolvedProps, renderLanes2);
|
|
}
|
|
case HostRoot:
|
|
return updateHostRoot(current2, workInProgress2, renderLanes2);
|
|
case HostComponent:
|
|
return updateHostComponent(current2, workInProgress2, renderLanes2);
|
|
case HostText:
|
|
return updateHostText(current2, workInProgress2);
|
|
case SuspenseComponent:
|
|
return updateSuspenseComponent(current2, workInProgress2, renderLanes2);
|
|
case HostPortal:
|
|
return updatePortalComponent(current2, workInProgress2, renderLanes2);
|
|
case ForwardRef: {
|
|
var type = workInProgress2.type;
|
|
var _unresolvedProps2 = workInProgress2.pendingProps;
|
|
var _resolvedProps2 = workInProgress2.elementType === type ? _unresolvedProps2 : resolveDefaultProps(type, _unresolvedProps2);
|
|
return updateForwardRef(current2, workInProgress2, type, _resolvedProps2, renderLanes2);
|
|
}
|
|
case Fragment3:
|
|
return updateFragment(current2, workInProgress2, renderLanes2);
|
|
case Mode:
|
|
return updateMode(current2, workInProgress2, renderLanes2);
|
|
case Profiler:
|
|
return updateProfiler(current2, workInProgress2, renderLanes2);
|
|
case ContextProvider:
|
|
return updateContextProvider(current2, workInProgress2, renderLanes2);
|
|
case ContextConsumer:
|
|
return updateContextConsumer(current2, workInProgress2, renderLanes2);
|
|
case MemoComponent: {
|
|
var _type2 = workInProgress2.type;
|
|
var _unresolvedProps3 = workInProgress2.pendingProps;
|
|
var _resolvedProps3 = resolveDefaultProps(_type2, _unresolvedProps3);
|
|
{
|
|
if (workInProgress2.type !== workInProgress2.elementType) {
|
|
var outerPropTypes = _type2.propTypes;
|
|
if (outerPropTypes) {
|
|
checkPropTypes(outerPropTypes, _resolvedProps3, "prop", getComponentName(_type2));
|
|
}
|
|
}
|
|
}
|
|
_resolvedProps3 = resolveDefaultProps(_type2.type, _resolvedProps3);
|
|
return updateMemoComponent(current2, workInProgress2, _type2, _resolvedProps3, updateLanes, renderLanes2);
|
|
}
|
|
case SimpleMemoComponent: {
|
|
return updateSimpleMemoComponent(current2, workInProgress2, workInProgress2.type, workInProgress2.pendingProps, updateLanes, renderLanes2);
|
|
}
|
|
case IncompleteClassComponent: {
|
|
var _Component3 = workInProgress2.type;
|
|
var _unresolvedProps4 = workInProgress2.pendingProps;
|
|
var _resolvedProps4 = workInProgress2.elementType === _Component3 ? _unresolvedProps4 : resolveDefaultProps(_Component3, _unresolvedProps4);
|
|
return mountIncompleteClassComponent(current2, workInProgress2, _Component3, _resolvedProps4, renderLanes2);
|
|
}
|
|
case SuspenseListComponent: {
|
|
return updateSuspenseListComponent(current2, workInProgress2, renderLanes2);
|
|
}
|
|
case FundamentalComponent: {
|
|
break;
|
|
}
|
|
case ScopeComponent: {
|
|
break;
|
|
}
|
|
case Block: {
|
|
break;
|
|
}
|
|
case OffscreenComponent: {
|
|
return updateOffscreenComponent(current2, workInProgress2, renderLanes2);
|
|
}
|
|
case LegacyHiddenComponent: {
|
|
return updateLegacyHiddenComponent(current2, workInProgress2, renderLanes2);
|
|
}
|
|
}
|
|
{
|
|
{
|
|
throw Error("Unknown unit of work tag (" + workInProgress2.tag + "). This error is likely caused by a bug in React. Please file an issue.");
|
|
}
|
|
}
|
|
}
|
|
function markUpdate(workInProgress2) {
|
|
workInProgress2.flags |= Update;
|
|
}
|
|
function markRef$1(workInProgress2) {
|
|
workInProgress2.flags |= Ref;
|
|
}
|
|
var appendAllChildren;
|
|
var updateHostContainer;
|
|
var updateHostComponent$1;
|
|
var updateHostText$1;
|
|
{
|
|
appendAllChildren = function(parent, workInProgress2, needsVisibilityToggle, isHidden) {
|
|
var node = workInProgress2.child;
|
|
while (node !== null) {
|
|
if (node.tag === HostComponent || node.tag === HostText) {
|
|
appendInitialChild(parent, node.stateNode);
|
|
} else if (node.tag === HostPortal)
|
|
;
|
|
else if (node.child !== null) {
|
|
node.child.return = node;
|
|
node = node.child;
|
|
continue;
|
|
}
|
|
if (node === workInProgress2) {
|
|
return;
|
|
}
|
|
while (node.sibling === null) {
|
|
if (node.return === null || node.return === workInProgress2) {
|
|
return;
|
|
}
|
|
node = node.return;
|
|
}
|
|
node.sibling.return = node.return;
|
|
node = node.sibling;
|
|
}
|
|
};
|
|
updateHostContainer = function(workInProgress2) {
|
|
};
|
|
updateHostComponent$1 = function(current2, workInProgress2, type, newProps, rootContainerInstance) {
|
|
var oldProps = current2.memoizedProps;
|
|
if (oldProps === newProps) {
|
|
return;
|
|
}
|
|
var instance = workInProgress2.stateNode;
|
|
var currentHostContext = getHostContext();
|
|
var updatePayload = prepareUpdate(instance, type, oldProps, newProps, rootContainerInstance, currentHostContext);
|
|
workInProgress2.updateQueue = updatePayload;
|
|
if (updatePayload) {
|
|
markUpdate(workInProgress2);
|
|
}
|
|
};
|
|
updateHostText$1 = function(current2, workInProgress2, oldText, newText) {
|
|
if (oldText !== newText) {
|
|
markUpdate(workInProgress2);
|
|
}
|
|
};
|
|
}
|
|
function cutOffTailIfNeeded(renderState, hasRenderedATailFallback) {
|
|
if (getIsHydrating()) {
|
|
return;
|
|
}
|
|
switch (renderState.tailMode) {
|
|
case "hidden": {
|
|
var tailNode = renderState.tail;
|
|
var lastTailNode = null;
|
|
while (tailNode !== null) {
|
|
if (tailNode.alternate !== null) {
|
|
lastTailNode = tailNode;
|
|
}
|
|
tailNode = tailNode.sibling;
|
|
}
|
|
if (lastTailNode === null) {
|
|
renderState.tail = null;
|
|
} else {
|
|
lastTailNode.sibling = null;
|
|
}
|
|
break;
|
|
}
|
|
case "collapsed": {
|
|
var _tailNode = renderState.tail;
|
|
var _lastTailNode = null;
|
|
while (_tailNode !== null) {
|
|
if (_tailNode.alternate !== null) {
|
|
_lastTailNode = _tailNode;
|
|
}
|
|
_tailNode = _tailNode.sibling;
|
|
}
|
|
if (_lastTailNode === null) {
|
|
if (!hasRenderedATailFallback && renderState.tail !== null) {
|
|
renderState.tail.sibling = null;
|
|
} else {
|
|
renderState.tail = null;
|
|
}
|
|
} else {
|
|
_lastTailNode.sibling = null;
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
function completeWork(current2, workInProgress2, renderLanes2) {
|
|
var newProps = workInProgress2.pendingProps;
|
|
switch (workInProgress2.tag) {
|
|
case IndeterminateComponent:
|
|
case LazyComponent:
|
|
case SimpleMemoComponent:
|
|
case FunctionComponent:
|
|
case ForwardRef:
|
|
case Fragment3:
|
|
case Mode:
|
|
case Profiler:
|
|
case ContextConsumer:
|
|
case MemoComponent:
|
|
return null;
|
|
case ClassComponent: {
|
|
var Component5 = workInProgress2.type;
|
|
if (isContextProvider(Component5)) {
|
|
popContext(workInProgress2);
|
|
}
|
|
return null;
|
|
}
|
|
case HostRoot: {
|
|
popHostContainer(workInProgress2);
|
|
popTopLevelContextObject(workInProgress2);
|
|
resetWorkInProgressVersions();
|
|
var fiberRoot = workInProgress2.stateNode;
|
|
if (fiberRoot.pendingContext) {
|
|
fiberRoot.context = fiberRoot.pendingContext;
|
|
fiberRoot.pendingContext = null;
|
|
}
|
|
if (current2 === null || current2.child === null) {
|
|
var wasHydrated = popHydrationState(workInProgress2);
|
|
if (wasHydrated) {
|
|
markUpdate(workInProgress2);
|
|
} else if (!fiberRoot.hydrate) {
|
|
workInProgress2.flags |= Snapshot;
|
|
}
|
|
}
|
|
updateHostContainer(workInProgress2);
|
|
return null;
|
|
}
|
|
case HostComponent: {
|
|
popHostContext(workInProgress2);
|
|
var rootContainerInstance = getRootHostContainer();
|
|
var type = workInProgress2.type;
|
|
if (current2 !== null && workInProgress2.stateNode != null) {
|
|
updateHostComponent$1(current2, workInProgress2, type, newProps, rootContainerInstance);
|
|
if (current2.ref !== workInProgress2.ref) {
|
|
markRef$1(workInProgress2);
|
|
}
|
|
} else {
|
|
if (!newProps) {
|
|
if (!(workInProgress2.stateNode !== null)) {
|
|
{
|
|
throw Error("We must have new props for new mounts. This error is likely caused by a bug in React. Please file an issue.");
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
var currentHostContext = getHostContext();
|
|
var _wasHydrated = popHydrationState(workInProgress2);
|
|
if (_wasHydrated) {
|
|
if (prepareToHydrateHostInstance(workInProgress2, rootContainerInstance, currentHostContext)) {
|
|
markUpdate(workInProgress2);
|
|
}
|
|
} else {
|
|
var instance = createInstance(type, newProps, rootContainerInstance, currentHostContext, workInProgress2);
|
|
appendAllChildren(instance, workInProgress2, false, false);
|
|
workInProgress2.stateNode = instance;
|
|
if (finalizeInitialChildren(instance, type, newProps, rootContainerInstance)) {
|
|
markUpdate(workInProgress2);
|
|
}
|
|
}
|
|
if (workInProgress2.ref !== null) {
|
|
markRef$1(workInProgress2);
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
case HostText: {
|
|
var newText = newProps;
|
|
if (current2 && workInProgress2.stateNode != null) {
|
|
var oldText = current2.memoizedProps;
|
|
updateHostText$1(current2, workInProgress2, oldText, newText);
|
|
} else {
|
|
if (typeof newText !== "string") {
|
|
if (!(workInProgress2.stateNode !== null)) {
|
|
{
|
|
throw Error("We must have new props for new mounts. This error is likely caused by a bug in React. Please file an issue.");
|
|
}
|
|
}
|
|
}
|
|
var _rootContainerInstance = getRootHostContainer();
|
|
var _currentHostContext = getHostContext();
|
|
var _wasHydrated2 = popHydrationState(workInProgress2);
|
|
if (_wasHydrated2) {
|
|
if (prepareToHydrateHostTextInstance(workInProgress2)) {
|
|
markUpdate(workInProgress2);
|
|
}
|
|
} else {
|
|
workInProgress2.stateNode = createTextInstance(newText, _rootContainerInstance, _currentHostContext, workInProgress2);
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
case SuspenseComponent: {
|
|
popSuspenseContext(workInProgress2);
|
|
var nextState = workInProgress2.memoizedState;
|
|
if ((workInProgress2.flags & DidCapture) !== NoFlags) {
|
|
workInProgress2.lanes = renderLanes2;
|
|
if ((workInProgress2.mode & ProfileMode) !== NoMode) {
|
|
transferActualDuration(workInProgress2);
|
|
}
|
|
return workInProgress2;
|
|
}
|
|
var nextDidTimeout = nextState !== null;
|
|
var prevDidTimeout = false;
|
|
if (current2 === null) {
|
|
if (workInProgress2.memoizedProps.fallback !== void 0) {
|
|
popHydrationState(workInProgress2);
|
|
}
|
|
} else {
|
|
var prevState = current2.memoizedState;
|
|
prevDidTimeout = prevState !== null;
|
|
}
|
|
if (nextDidTimeout && !prevDidTimeout) {
|
|
if ((workInProgress2.mode & BlockingMode) !== NoMode) {
|
|
var hasInvisibleChildContext = current2 === null && workInProgress2.memoizedProps.unstable_avoidThisFallback !== true;
|
|
if (hasInvisibleChildContext || hasSuspenseContext(suspenseStackCursor.current, InvisibleParentSuspenseContext)) {
|
|
renderDidSuspend();
|
|
} else {
|
|
renderDidSuspendDelayIfPossible();
|
|
}
|
|
}
|
|
}
|
|
{
|
|
if (nextDidTimeout || prevDidTimeout) {
|
|
workInProgress2.flags |= Update;
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
case HostPortal:
|
|
popHostContainer(workInProgress2);
|
|
updateHostContainer(workInProgress2);
|
|
if (current2 === null) {
|
|
preparePortalMount(workInProgress2.stateNode.containerInfo);
|
|
}
|
|
return null;
|
|
case ContextProvider:
|
|
popProvider(workInProgress2);
|
|
return null;
|
|
case IncompleteClassComponent: {
|
|
var _Component = workInProgress2.type;
|
|
if (isContextProvider(_Component)) {
|
|
popContext(workInProgress2);
|
|
}
|
|
return null;
|
|
}
|
|
case SuspenseListComponent: {
|
|
popSuspenseContext(workInProgress2);
|
|
var renderState = workInProgress2.memoizedState;
|
|
if (renderState === null) {
|
|
return null;
|
|
}
|
|
var didSuspendAlready = (workInProgress2.flags & DidCapture) !== NoFlags;
|
|
var renderedTail = renderState.rendering;
|
|
if (renderedTail === null) {
|
|
if (!didSuspendAlready) {
|
|
var cannotBeSuspended = renderHasNotSuspendedYet() && (current2 === null || (current2.flags & DidCapture) === NoFlags);
|
|
if (!cannotBeSuspended) {
|
|
var row = workInProgress2.child;
|
|
while (row !== null) {
|
|
var suspended = findFirstSuspended(row);
|
|
if (suspended !== null) {
|
|
didSuspendAlready = true;
|
|
workInProgress2.flags |= DidCapture;
|
|
cutOffTailIfNeeded(renderState, false);
|
|
var newThennables = suspended.updateQueue;
|
|
if (newThennables !== null) {
|
|
workInProgress2.updateQueue = newThennables;
|
|
workInProgress2.flags |= Update;
|
|
}
|
|
if (renderState.lastEffect === null) {
|
|
workInProgress2.firstEffect = null;
|
|
}
|
|
workInProgress2.lastEffect = renderState.lastEffect;
|
|
resetChildFibers(workInProgress2, renderLanes2);
|
|
pushSuspenseContext(workInProgress2, setShallowSuspenseContext(suspenseStackCursor.current, ForceSuspenseFallback));
|
|
return workInProgress2.child;
|
|
}
|
|
row = row.sibling;
|
|
}
|
|
}
|
|
if (renderState.tail !== null && now() > getRenderTargetTime()) {
|
|
workInProgress2.flags |= DidCapture;
|
|
didSuspendAlready = true;
|
|
cutOffTailIfNeeded(renderState, false);
|
|
workInProgress2.lanes = SomeRetryLane;
|
|
{
|
|
markSpawnedWork(SomeRetryLane);
|
|
}
|
|
}
|
|
} else {
|
|
cutOffTailIfNeeded(renderState, false);
|
|
}
|
|
} else {
|
|
if (!didSuspendAlready) {
|
|
var _suspended = findFirstSuspended(renderedTail);
|
|
if (_suspended !== null) {
|
|
workInProgress2.flags |= DidCapture;
|
|
didSuspendAlready = true;
|
|
var _newThennables = _suspended.updateQueue;
|
|
if (_newThennables !== null) {
|
|
workInProgress2.updateQueue = _newThennables;
|
|
workInProgress2.flags |= Update;
|
|
}
|
|
cutOffTailIfNeeded(renderState, true);
|
|
if (renderState.tail === null && renderState.tailMode === "hidden" && !renderedTail.alternate && !getIsHydrating()) {
|
|
var lastEffect = workInProgress2.lastEffect = renderState.lastEffect;
|
|
if (lastEffect !== null) {
|
|
lastEffect.nextEffect = null;
|
|
}
|
|
return null;
|
|
}
|
|
} else if (now() * 2 - renderState.renderingStartTime > getRenderTargetTime() && renderLanes2 !== OffscreenLane) {
|
|
workInProgress2.flags |= DidCapture;
|
|
didSuspendAlready = true;
|
|
cutOffTailIfNeeded(renderState, false);
|
|
workInProgress2.lanes = SomeRetryLane;
|
|
{
|
|
markSpawnedWork(SomeRetryLane);
|
|
}
|
|
}
|
|
}
|
|
if (renderState.isBackwards) {
|
|
renderedTail.sibling = workInProgress2.child;
|
|
workInProgress2.child = renderedTail;
|
|
} else {
|
|
var previousSibling = renderState.last;
|
|
if (previousSibling !== null) {
|
|
previousSibling.sibling = renderedTail;
|
|
} else {
|
|
workInProgress2.child = renderedTail;
|
|
}
|
|
renderState.last = renderedTail;
|
|
}
|
|
}
|
|
if (renderState.tail !== null) {
|
|
var next = renderState.tail;
|
|
renderState.rendering = next;
|
|
renderState.tail = next.sibling;
|
|
renderState.lastEffect = workInProgress2.lastEffect;
|
|
renderState.renderingStartTime = now();
|
|
next.sibling = null;
|
|
var suspenseContext = suspenseStackCursor.current;
|
|
if (didSuspendAlready) {
|
|
suspenseContext = setShallowSuspenseContext(suspenseContext, ForceSuspenseFallback);
|
|
} else {
|
|
suspenseContext = setDefaultShallowSuspenseContext(suspenseContext);
|
|
}
|
|
pushSuspenseContext(workInProgress2, suspenseContext);
|
|
return next;
|
|
}
|
|
return null;
|
|
}
|
|
case FundamentalComponent: {
|
|
break;
|
|
}
|
|
case ScopeComponent: {
|
|
break;
|
|
}
|
|
case Block:
|
|
break;
|
|
case OffscreenComponent:
|
|
case LegacyHiddenComponent: {
|
|
popRenderLanes(workInProgress2);
|
|
if (current2 !== null) {
|
|
var _nextState = workInProgress2.memoizedState;
|
|
var _prevState = current2.memoizedState;
|
|
var prevIsHidden = _prevState !== null;
|
|
var nextIsHidden = _nextState !== null;
|
|
if (prevIsHidden !== nextIsHidden && newProps.mode !== "unstable-defer-without-hiding") {
|
|
workInProgress2.flags |= Update;
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
}
|
|
{
|
|
{
|
|
throw Error("Unknown unit of work tag (" + workInProgress2.tag + "). This error is likely caused by a bug in React. Please file an issue.");
|
|
}
|
|
}
|
|
}
|
|
function unwindWork(workInProgress2, renderLanes2) {
|
|
switch (workInProgress2.tag) {
|
|
case ClassComponent: {
|
|
var Component5 = workInProgress2.type;
|
|
if (isContextProvider(Component5)) {
|
|
popContext(workInProgress2);
|
|
}
|
|
var flags = workInProgress2.flags;
|
|
if (flags & ShouldCapture) {
|
|
workInProgress2.flags = flags & ~ShouldCapture | DidCapture;
|
|
if ((workInProgress2.mode & ProfileMode) !== NoMode) {
|
|
transferActualDuration(workInProgress2);
|
|
}
|
|
return workInProgress2;
|
|
}
|
|
return null;
|
|
}
|
|
case HostRoot: {
|
|
popHostContainer(workInProgress2);
|
|
popTopLevelContextObject(workInProgress2);
|
|
resetWorkInProgressVersions();
|
|
var _flags = workInProgress2.flags;
|
|
if (!((_flags & DidCapture) === NoFlags)) {
|
|
{
|
|
throw Error("The root failed to unmount after an error. This is likely a bug in React. Please file an issue.");
|
|
}
|
|
}
|
|
workInProgress2.flags = _flags & ~ShouldCapture | DidCapture;
|
|
return workInProgress2;
|
|
}
|
|
case HostComponent: {
|
|
popHostContext(workInProgress2);
|
|
return null;
|
|
}
|
|
case SuspenseComponent: {
|
|
popSuspenseContext(workInProgress2);
|
|
var _flags2 = workInProgress2.flags;
|
|
if (_flags2 & ShouldCapture) {
|
|
workInProgress2.flags = _flags2 & ~ShouldCapture | DidCapture;
|
|
if ((workInProgress2.mode & ProfileMode) !== NoMode) {
|
|
transferActualDuration(workInProgress2);
|
|
}
|
|
return workInProgress2;
|
|
}
|
|
return null;
|
|
}
|
|
case SuspenseListComponent: {
|
|
popSuspenseContext(workInProgress2);
|
|
return null;
|
|
}
|
|
case HostPortal:
|
|
popHostContainer(workInProgress2);
|
|
return null;
|
|
case ContextProvider:
|
|
popProvider(workInProgress2);
|
|
return null;
|
|
case OffscreenComponent:
|
|
case LegacyHiddenComponent:
|
|
popRenderLanes(workInProgress2);
|
|
return null;
|
|
default:
|
|
return null;
|
|
}
|
|
}
|
|
function unwindInterruptedWork(interruptedWork) {
|
|
switch (interruptedWork.tag) {
|
|
case ClassComponent: {
|
|
var childContextTypes = interruptedWork.type.childContextTypes;
|
|
if (childContextTypes !== null && childContextTypes !== void 0) {
|
|
popContext(interruptedWork);
|
|
}
|
|
break;
|
|
}
|
|
case HostRoot: {
|
|
popHostContainer(interruptedWork);
|
|
popTopLevelContextObject(interruptedWork);
|
|
resetWorkInProgressVersions();
|
|
break;
|
|
}
|
|
case HostComponent: {
|
|
popHostContext(interruptedWork);
|
|
break;
|
|
}
|
|
case HostPortal:
|
|
popHostContainer(interruptedWork);
|
|
break;
|
|
case SuspenseComponent:
|
|
popSuspenseContext(interruptedWork);
|
|
break;
|
|
case SuspenseListComponent:
|
|
popSuspenseContext(interruptedWork);
|
|
break;
|
|
case ContextProvider:
|
|
popProvider(interruptedWork);
|
|
break;
|
|
case OffscreenComponent:
|
|
case LegacyHiddenComponent:
|
|
popRenderLanes(interruptedWork);
|
|
break;
|
|
}
|
|
}
|
|
function createCapturedValue(value, source) {
|
|
return {
|
|
value,
|
|
source,
|
|
stack: getStackByFiberInDevAndProd(source)
|
|
};
|
|
}
|
|
function showErrorDialog(boundary, errorInfo) {
|
|
return true;
|
|
}
|
|
function logCapturedError(boundary, errorInfo) {
|
|
try {
|
|
var logError = showErrorDialog(boundary, errorInfo);
|
|
if (logError === false) {
|
|
return;
|
|
}
|
|
var error2 = errorInfo.value;
|
|
if (true) {
|
|
var source = errorInfo.source;
|
|
var stack = errorInfo.stack;
|
|
var componentStack = stack !== null ? stack : "";
|
|
if (error2 != null && error2._suppressLogging) {
|
|
if (boundary.tag === ClassComponent) {
|
|
return;
|
|
}
|
|
console["error"](error2);
|
|
}
|
|
var componentName = source ? getComponentName(source.type) : null;
|
|
var componentNameMessage = componentName ? "The above error occurred in the <" + componentName + "> component:" : "The above error occurred in one of your React components:";
|
|
var errorBoundaryMessage;
|
|
var errorBoundaryName = getComponentName(boundary.type);
|
|
if (errorBoundaryName) {
|
|
errorBoundaryMessage = "React will try to recreate this component tree from scratch " + ("using the error boundary you provided, " + errorBoundaryName + ".");
|
|
} else {
|
|
errorBoundaryMessage = "Consider adding an error boundary to your tree to customize error handling behavior.\nVisit https://reactjs.org/link/error-boundaries to learn more about error boundaries.";
|
|
}
|
|
var combinedMessage = componentNameMessage + "\n" + componentStack + "\n\n" + ("" + errorBoundaryMessage);
|
|
console["error"](combinedMessage);
|
|
} else {
|
|
console["error"](error2);
|
|
}
|
|
} catch (e3) {
|
|
setTimeout(function() {
|
|
throw e3;
|
|
});
|
|
}
|
|
}
|
|
var PossiblyWeakMap$1 = typeof WeakMap === "function" ? WeakMap : Map;
|
|
function createRootErrorUpdate(fiber, errorInfo, lane) {
|
|
var update = createUpdate(NoTimestamp, lane);
|
|
update.tag = CaptureUpdate;
|
|
update.payload = {
|
|
element: null
|
|
};
|
|
var error2 = errorInfo.value;
|
|
update.callback = function() {
|
|
onUncaughtError(error2);
|
|
logCapturedError(fiber, errorInfo);
|
|
};
|
|
return update;
|
|
}
|
|
function createClassErrorUpdate(fiber, errorInfo, lane) {
|
|
var update = createUpdate(NoTimestamp, lane);
|
|
update.tag = CaptureUpdate;
|
|
var getDerivedStateFromError = fiber.type.getDerivedStateFromError;
|
|
if (typeof getDerivedStateFromError === "function") {
|
|
var error$1 = errorInfo.value;
|
|
update.payload = function() {
|
|
logCapturedError(fiber, errorInfo);
|
|
return getDerivedStateFromError(error$1);
|
|
};
|
|
}
|
|
var inst = fiber.stateNode;
|
|
if (inst !== null && typeof inst.componentDidCatch === "function") {
|
|
update.callback = function callback() {
|
|
{
|
|
markFailedErrorBoundaryForHotReloading(fiber);
|
|
}
|
|
if (typeof getDerivedStateFromError !== "function") {
|
|
markLegacyErrorBoundaryAsFailed(this);
|
|
logCapturedError(fiber, errorInfo);
|
|
}
|
|
var error$12 = errorInfo.value;
|
|
var stack = errorInfo.stack;
|
|
this.componentDidCatch(error$12, {
|
|
componentStack: stack !== null ? stack : ""
|
|
});
|
|
{
|
|
if (typeof getDerivedStateFromError !== "function") {
|
|
if (!includesSomeLane(fiber.lanes, SyncLane)) {
|
|
error("%s: Error boundaries should implement getDerivedStateFromError(). In that method, return a state update to display an error message or fallback UI.", getComponentName(fiber.type) || "Unknown");
|
|
}
|
|
}
|
|
}
|
|
};
|
|
} else {
|
|
update.callback = function() {
|
|
markFailedErrorBoundaryForHotReloading(fiber);
|
|
};
|
|
}
|
|
return update;
|
|
}
|
|
function attachPingListener(root2, wakeable, lanes) {
|
|
var pingCache = root2.pingCache;
|
|
var threadIDs;
|
|
if (pingCache === null) {
|
|
pingCache = root2.pingCache = new PossiblyWeakMap$1();
|
|
threadIDs = new Set();
|
|
pingCache.set(wakeable, threadIDs);
|
|
} else {
|
|
threadIDs = pingCache.get(wakeable);
|
|
if (threadIDs === void 0) {
|
|
threadIDs = new Set();
|
|
pingCache.set(wakeable, threadIDs);
|
|
}
|
|
}
|
|
if (!threadIDs.has(lanes)) {
|
|
threadIDs.add(lanes);
|
|
var ping = pingSuspendedRoot.bind(null, root2, wakeable, lanes);
|
|
wakeable.then(ping, ping);
|
|
}
|
|
}
|
|
function throwException(root2, returnFiber, sourceFiber, value, rootRenderLanes) {
|
|
sourceFiber.flags |= Incomplete;
|
|
sourceFiber.firstEffect = sourceFiber.lastEffect = null;
|
|
if (value !== null && typeof value === "object" && typeof value.then === "function") {
|
|
var wakeable = value;
|
|
if ((sourceFiber.mode & BlockingMode) === NoMode) {
|
|
var currentSource = sourceFiber.alternate;
|
|
if (currentSource) {
|
|
sourceFiber.updateQueue = currentSource.updateQueue;
|
|
sourceFiber.memoizedState = currentSource.memoizedState;
|
|
sourceFiber.lanes = currentSource.lanes;
|
|
} else {
|
|
sourceFiber.updateQueue = null;
|
|
sourceFiber.memoizedState = null;
|
|
}
|
|
}
|
|
var hasInvisibleParentBoundary = hasSuspenseContext(suspenseStackCursor.current, InvisibleParentSuspenseContext);
|
|
var _workInProgress = returnFiber;
|
|
do {
|
|
if (_workInProgress.tag === SuspenseComponent && shouldCaptureSuspense(_workInProgress, hasInvisibleParentBoundary)) {
|
|
var wakeables = _workInProgress.updateQueue;
|
|
if (wakeables === null) {
|
|
var updateQueue = new Set();
|
|
updateQueue.add(wakeable);
|
|
_workInProgress.updateQueue = updateQueue;
|
|
} else {
|
|
wakeables.add(wakeable);
|
|
}
|
|
if ((_workInProgress.mode & BlockingMode) === NoMode) {
|
|
_workInProgress.flags |= DidCapture;
|
|
sourceFiber.flags |= ForceUpdateForLegacySuspense;
|
|
sourceFiber.flags &= ~(LifecycleEffectMask | Incomplete);
|
|
if (sourceFiber.tag === ClassComponent) {
|
|
var currentSourceFiber = sourceFiber.alternate;
|
|
if (currentSourceFiber === null) {
|
|
sourceFiber.tag = IncompleteClassComponent;
|
|
} else {
|
|
var update = createUpdate(NoTimestamp, SyncLane);
|
|
update.tag = ForceUpdate;
|
|
enqueueUpdate(sourceFiber, update);
|
|
}
|
|
}
|
|
sourceFiber.lanes = mergeLanes(sourceFiber.lanes, SyncLane);
|
|
return;
|
|
}
|
|
attachPingListener(root2, wakeable, rootRenderLanes);
|
|
_workInProgress.flags |= ShouldCapture;
|
|
_workInProgress.lanes = rootRenderLanes;
|
|
return;
|
|
}
|
|
_workInProgress = _workInProgress.return;
|
|
} while (_workInProgress !== null);
|
|
value = new Error((getComponentName(sourceFiber.type) || "A React component") + " suspended while rendering, but no fallback UI was specified.\n\nAdd a <Suspense fallback=...> component higher in the tree to provide a loading indicator or placeholder to display.");
|
|
}
|
|
renderDidError();
|
|
value = createCapturedValue(value, sourceFiber);
|
|
var workInProgress2 = returnFiber;
|
|
do {
|
|
switch (workInProgress2.tag) {
|
|
case HostRoot: {
|
|
var _errorInfo = value;
|
|
workInProgress2.flags |= ShouldCapture;
|
|
var lane = pickArbitraryLane(rootRenderLanes);
|
|
workInProgress2.lanes = mergeLanes(workInProgress2.lanes, lane);
|
|
var _update = createRootErrorUpdate(workInProgress2, _errorInfo, lane);
|
|
enqueueCapturedUpdate(workInProgress2, _update);
|
|
return;
|
|
}
|
|
case ClassComponent:
|
|
var errorInfo = value;
|
|
var ctor = workInProgress2.type;
|
|
var instance = workInProgress2.stateNode;
|
|
if ((workInProgress2.flags & DidCapture) === NoFlags && (typeof ctor.getDerivedStateFromError === "function" || instance !== null && typeof instance.componentDidCatch === "function" && !isAlreadyFailedLegacyErrorBoundary(instance))) {
|
|
workInProgress2.flags |= ShouldCapture;
|
|
var _lane = pickArbitraryLane(rootRenderLanes);
|
|
workInProgress2.lanes = mergeLanes(workInProgress2.lanes, _lane);
|
|
var _update2 = createClassErrorUpdate(workInProgress2, errorInfo, _lane);
|
|
enqueueCapturedUpdate(workInProgress2, _update2);
|
|
return;
|
|
}
|
|
break;
|
|
}
|
|
workInProgress2 = workInProgress2.return;
|
|
} while (workInProgress2 !== null);
|
|
}
|
|
var didWarnAboutUndefinedSnapshotBeforeUpdate = null;
|
|
{
|
|
didWarnAboutUndefinedSnapshotBeforeUpdate = new Set();
|
|
}
|
|
var PossiblyWeakSet = typeof WeakSet === "function" ? WeakSet : Set;
|
|
var callComponentWillUnmountWithTimer = function(current2, instance) {
|
|
instance.props = current2.memoizedProps;
|
|
instance.state = current2.memoizedState;
|
|
{
|
|
instance.componentWillUnmount();
|
|
}
|
|
};
|
|
function safelyCallComponentWillUnmount(current2, instance) {
|
|
{
|
|
invokeGuardedCallback(null, callComponentWillUnmountWithTimer, null, current2, instance);
|
|
if (hasCaughtError()) {
|
|
var unmountError = clearCaughtError();
|
|
captureCommitPhaseError(current2, unmountError);
|
|
}
|
|
}
|
|
}
|
|
function safelyDetachRef(current2) {
|
|
var ref = current2.ref;
|
|
if (ref !== null) {
|
|
if (typeof ref === "function") {
|
|
{
|
|
invokeGuardedCallback(null, ref, null, null);
|
|
if (hasCaughtError()) {
|
|
var refError = clearCaughtError();
|
|
captureCommitPhaseError(current2, refError);
|
|
}
|
|
}
|
|
} else {
|
|
ref.current = null;
|
|
}
|
|
}
|
|
}
|
|
function safelyCallDestroy(current2, destroy) {
|
|
{
|
|
invokeGuardedCallback(null, destroy, null);
|
|
if (hasCaughtError()) {
|
|
var error2 = clearCaughtError();
|
|
captureCommitPhaseError(current2, error2);
|
|
}
|
|
}
|
|
}
|
|
function commitBeforeMutationLifeCycles(current2, finishedWork) {
|
|
switch (finishedWork.tag) {
|
|
case FunctionComponent:
|
|
case ForwardRef:
|
|
case SimpleMemoComponent:
|
|
case Block: {
|
|
return;
|
|
}
|
|
case ClassComponent: {
|
|
if (finishedWork.flags & Snapshot) {
|
|
if (current2 !== null) {
|
|
var prevProps = current2.memoizedProps;
|
|
var prevState = current2.memoizedState;
|
|
var instance = finishedWork.stateNode;
|
|
{
|
|
if (finishedWork.type === finishedWork.elementType && !didWarnAboutReassigningProps) {
|
|
if (instance.props !== finishedWork.memoizedProps) {
|
|
error("Expected %s props to match memoized props before getSnapshotBeforeUpdate. This might either be because of a bug in React, or because a component reassigns its own `this.props`. Please file an issue.", getComponentName(finishedWork.type) || "instance");
|
|
}
|
|
if (instance.state !== finishedWork.memoizedState) {
|
|
error("Expected %s state to match memoized state before getSnapshotBeforeUpdate. This might either be because of a bug in React, or because a component reassigns its own `this.state`. Please file an issue.", getComponentName(finishedWork.type) || "instance");
|
|
}
|
|
}
|
|
}
|
|
var snapshot = instance.getSnapshotBeforeUpdate(finishedWork.elementType === finishedWork.type ? prevProps : resolveDefaultProps(finishedWork.type, prevProps), prevState);
|
|
{
|
|
var didWarnSet = didWarnAboutUndefinedSnapshotBeforeUpdate;
|
|
if (snapshot === void 0 && !didWarnSet.has(finishedWork.type)) {
|
|
didWarnSet.add(finishedWork.type);
|
|
error("%s.getSnapshotBeforeUpdate(): A snapshot value (or null) must be returned. You have returned undefined.", getComponentName(finishedWork.type));
|
|
}
|
|
}
|
|
instance.__reactInternalSnapshotBeforeUpdate = snapshot;
|
|
}
|
|
}
|
|
return;
|
|
}
|
|
case HostRoot: {
|
|
{
|
|
if (finishedWork.flags & Snapshot) {
|
|
var root2 = finishedWork.stateNode;
|
|
clearContainer(root2.containerInfo);
|
|
}
|
|
}
|
|
return;
|
|
}
|
|
case HostComponent:
|
|
case HostText:
|
|
case HostPortal:
|
|
case IncompleteClassComponent:
|
|
return;
|
|
}
|
|
{
|
|
{
|
|
throw Error("This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue.");
|
|
}
|
|
}
|
|
}
|
|
function commitHookEffectListUnmount(tag, finishedWork) {
|
|
var updateQueue = finishedWork.updateQueue;
|
|
var lastEffect = updateQueue !== null ? updateQueue.lastEffect : null;
|
|
if (lastEffect !== null) {
|
|
var firstEffect = lastEffect.next;
|
|
var effect = firstEffect;
|
|
do {
|
|
if ((effect.tag & tag) === tag) {
|
|
var destroy = effect.destroy;
|
|
effect.destroy = void 0;
|
|
if (destroy !== void 0) {
|
|
destroy();
|
|
}
|
|
}
|
|
effect = effect.next;
|
|
} while (effect !== firstEffect);
|
|
}
|
|
}
|
|
function commitHookEffectListMount(tag, finishedWork) {
|
|
var updateQueue = finishedWork.updateQueue;
|
|
var lastEffect = updateQueue !== null ? updateQueue.lastEffect : null;
|
|
if (lastEffect !== null) {
|
|
var firstEffect = lastEffect.next;
|
|
var effect = firstEffect;
|
|
do {
|
|
if ((effect.tag & tag) === tag) {
|
|
var create = effect.create;
|
|
effect.destroy = create();
|
|
{
|
|
var destroy = effect.destroy;
|
|
if (destroy !== void 0 && typeof destroy !== "function") {
|
|
var addendum = void 0;
|
|
if (destroy === null) {
|
|
addendum = " You returned null. If your effect does not require clean up, return undefined (or nothing).";
|
|
} else if (typeof destroy.then === "function") {
|
|
addendum = "\n\nIt looks like you wrote useEffect(async () => ...) or returned a Promise. Instead, write the async function inside your effect and call it immediately:\n\nuseEffect(() => {\n async function fetchData() {\n // You can await here\n const response = await MyAPI.getData(someId);\n // ...\n }\n fetchData();\n}, [someId]); // Or [] if effect doesn't need props or state\n\nLearn more about data fetching with Hooks: https://reactjs.org/link/hooks-data-fetching";
|
|
} else {
|
|
addendum = " You returned: " + destroy;
|
|
}
|
|
error("An effect function must not return anything besides a function, which is used for clean-up.%s", addendum);
|
|
}
|
|
}
|
|
}
|
|
effect = effect.next;
|
|
} while (effect !== firstEffect);
|
|
}
|
|
}
|
|
function schedulePassiveEffects(finishedWork) {
|
|
var updateQueue = finishedWork.updateQueue;
|
|
var lastEffect = updateQueue !== null ? updateQueue.lastEffect : null;
|
|
if (lastEffect !== null) {
|
|
var firstEffect = lastEffect.next;
|
|
var effect = firstEffect;
|
|
do {
|
|
var _effect = effect, next = _effect.next, tag = _effect.tag;
|
|
if ((tag & Passive$1) !== NoFlags$1 && (tag & HasEffect) !== NoFlags$1) {
|
|
enqueuePendingPassiveHookEffectUnmount(finishedWork, effect);
|
|
enqueuePendingPassiveHookEffectMount(finishedWork, effect);
|
|
}
|
|
effect = next;
|
|
} while (effect !== firstEffect);
|
|
}
|
|
}
|
|
function commitLifeCycles(finishedRoot, current2, finishedWork, committedLanes) {
|
|
switch (finishedWork.tag) {
|
|
case FunctionComponent:
|
|
case ForwardRef:
|
|
case SimpleMemoComponent:
|
|
case Block: {
|
|
{
|
|
commitHookEffectListMount(Layout | HasEffect, finishedWork);
|
|
}
|
|
schedulePassiveEffects(finishedWork);
|
|
return;
|
|
}
|
|
case ClassComponent: {
|
|
var instance = finishedWork.stateNode;
|
|
if (finishedWork.flags & Update) {
|
|
if (current2 === null) {
|
|
{
|
|
if (finishedWork.type === finishedWork.elementType && !didWarnAboutReassigningProps) {
|
|
if (instance.props !== finishedWork.memoizedProps) {
|
|
error("Expected %s props to match memoized props before componentDidMount. This might either be because of a bug in React, or because a component reassigns its own `this.props`. Please file an issue.", getComponentName(finishedWork.type) || "instance");
|
|
}
|
|
if (instance.state !== finishedWork.memoizedState) {
|
|
error("Expected %s state to match memoized state before componentDidMount. This might either be because of a bug in React, or because a component reassigns its own `this.state`. Please file an issue.", getComponentName(finishedWork.type) || "instance");
|
|
}
|
|
}
|
|
}
|
|
{
|
|
instance.componentDidMount();
|
|
}
|
|
} else {
|
|
var prevProps = finishedWork.elementType === finishedWork.type ? current2.memoizedProps : resolveDefaultProps(finishedWork.type, current2.memoizedProps);
|
|
var prevState = current2.memoizedState;
|
|
{
|
|
if (finishedWork.type === finishedWork.elementType && !didWarnAboutReassigningProps) {
|
|
if (instance.props !== finishedWork.memoizedProps) {
|
|
error("Expected %s props to match memoized props before componentDidUpdate. This might either be because of a bug in React, or because a component reassigns its own `this.props`. Please file an issue.", getComponentName(finishedWork.type) || "instance");
|
|
}
|
|
if (instance.state !== finishedWork.memoizedState) {
|
|
error("Expected %s state to match memoized state before componentDidUpdate. This might either be because of a bug in React, or because a component reassigns its own `this.state`. Please file an issue.", getComponentName(finishedWork.type) || "instance");
|
|
}
|
|
}
|
|
}
|
|
{
|
|
instance.componentDidUpdate(prevProps, prevState, instance.__reactInternalSnapshotBeforeUpdate);
|
|
}
|
|
}
|
|
}
|
|
var updateQueue = finishedWork.updateQueue;
|
|
if (updateQueue !== null) {
|
|
{
|
|
if (finishedWork.type === finishedWork.elementType && !didWarnAboutReassigningProps) {
|
|
if (instance.props !== finishedWork.memoizedProps) {
|
|
error("Expected %s props to match memoized props before processing the update queue. This might either be because of a bug in React, or because a component reassigns its own `this.props`. Please file an issue.", getComponentName(finishedWork.type) || "instance");
|
|
}
|
|
if (instance.state !== finishedWork.memoizedState) {
|
|
error("Expected %s state to match memoized state before processing the update queue. This might either be because of a bug in React, or because a component reassigns its own `this.state`. Please file an issue.", getComponentName(finishedWork.type) || "instance");
|
|
}
|
|
}
|
|
}
|
|
commitUpdateQueue(finishedWork, updateQueue, instance);
|
|
}
|
|
return;
|
|
}
|
|
case HostRoot: {
|
|
var _updateQueue = finishedWork.updateQueue;
|
|
if (_updateQueue !== null) {
|
|
var _instance = null;
|
|
if (finishedWork.child !== null) {
|
|
switch (finishedWork.child.tag) {
|
|
case HostComponent:
|
|
_instance = getPublicInstance(finishedWork.child.stateNode);
|
|
break;
|
|
case ClassComponent:
|
|
_instance = finishedWork.child.stateNode;
|
|
break;
|
|
}
|
|
}
|
|
commitUpdateQueue(finishedWork, _updateQueue, _instance);
|
|
}
|
|
return;
|
|
}
|
|
case HostComponent: {
|
|
var _instance2 = finishedWork.stateNode;
|
|
if (current2 === null && finishedWork.flags & Update) {
|
|
var type = finishedWork.type;
|
|
var props = finishedWork.memoizedProps;
|
|
commitMount(_instance2, type, props);
|
|
}
|
|
return;
|
|
}
|
|
case HostText: {
|
|
return;
|
|
}
|
|
case HostPortal: {
|
|
return;
|
|
}
|
|
case Profiler: {
|
|
{
|
|
var _finishedWork$memoize2 = finishedWork.memoizedProps, onCommit = _finishedWork$memoize2.onCommit, onRender = _finishedWork$memoize2.onRender;
|
|
var effectDuration = finishedWork.stateNode.effectDuration;
|
|
var commitTime2 = getCommitTime();
|
|
if (typeof onRender === "function") {
|
|
{
|
|
onRender(finishedWork.memoizedProps.id, current2 === null ? "mount" : "update", finishedWork.actualDuration, finishedWork.treeBaseDuration, finishedWork.actualStartTime, commitTime2, finishedRoot.memoizedInteractions);
|
|
}
|
|
}
|
|
}
|
|
return;
|
|
}
|
|
case SuspenseComponent: {
|
|
commitSuspenseHydrationCallbacks(finishedRoot, finishedWork);
|
|
return;
|
|
}
|
|
case SuspenseListComponent:
|
|
case IncompleteClassComponent:
|
|
case FundamentalComponent:
|
|
case ScopeComponent:
|
|
case OffscreenComponent:
|
|
case LegacyHiddenComponent:
|
|
return;
|
|
}
|
|
{
|
|
{
|
|
throw Error("This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue.");
|
|
}
|
|
}
|
|
}
|
|
function hideOrUnhideAllChildren(finishedWork, isHidden) {
|
|
{
|
|
var node = finishedWork;
|
|
while (true) {
|
|
if (node.tag === HostComponent) {
|
|
var instance = node.stateNode;
|
|
if (isHidden) {
|
|
hideInstance(instance);
|
|
} else {
|
|
unhideInstance(node.stateNode, node.memoizedProps);
|
|
}
|
|
} else if (node.tag === HostText) {
|
|
var _instance3 = node.stateNode;
|
|
if (isHidden) {
|
|
hideTextInstance(_instance3);
|
|
} else {
|
|
unhideTextInstance(_instance3, node.memoizedProps);
|
|
}
|
|
} else if ((node.tag === OffscreenComponent || node.tag === LegacyHiddenComponent) && node.memoizedState !== null && node !== finishedWork)
|
|
;
|
|
else if (node.child !== null) {
|
|
node.child.return = node;
|
|
node = node.child;
|
|
continue;
|
|
}
|
|
if (node === finishedWork) {
|
|
return;
|
|
}
|
|
while (node.sibling === null) {
|
|
if (node.return === null || node.return === finishedWork) {
|
|
return;
|
|
}
|
|
node = node.return;
|
|
}
|
|
node.sibling.return = node.return;
|
|
node = node.sibling;
|
|
}
|
|
}
|
|
}
|
|
function commitAttachRef(finishedWork) {
|
|
var ref = finishedWork.ref;
|
|
if (ref !== null) {
|
|
var instance = finishedWork.stateNode;
|
|
var instanceToUse;
|
|
switch (finishedWork.tag) {
|
|
case HostComponent:
|
|
instanceToUse = getPublicInstance(instance);
|
|
break;
|
|
default:
|
|
instanceToUse = instance;
|
|
}
|
|
if (typeof ref === "function") {
|
|
ref(instanceToUse);
|
|
} else {
|
|
{
|
|
if (!ref.hasOwnProperty("current")) {
|
|
error("Unexpected ref object provided for %s. Use either a ref-setter function or React.createRef().", getComponentName(finishedWork.type));
|
|
}
|
|
}
|
|
ref.current = instanceToUse;
|
|
}
|
|
}
|
|
}
|
|
function commitDetachRef(current2) {
|
|
var currentRef = current2.ref;
|
|
if (currentRef !== null) {
|
|
if (typeof currentRef === "function") {
|
|
currentRef(null);
|
|
} else {
|
|
currentRef.current = null;
|
|
}
|
|
}
|
|
}
|
|
function commitUnmount(finishedRoot, current2, renderPriorityLevel) {
|
|
onCommitUnmount(current2);
|
|
switch (current2.tag) {
|
|
case FunctionComponent:
|
|
case ForwardRef:
|
|
case MemoComponent:
|
|
case SimpleMemoComponent:
|
|
case Block: {
|
|
var updateQueue = current2.updateQueue;
|
|
if (updateQueue !== null) {
|
|
var lastEffect = updateQueue.lastEffect;
|
|
if (lastEffect !== null) {
|
|
var firstEffect = lastEffect.next;
|
|
var effect = firstEffect;
|
|
do {
|
|
var _effect2 = effect, destroy = _effect2.destroy, tag = _effect2.tag;
|
|
if (destroy !== void 0) {
|
|
if ((tag & Passive$1) !== NoFlags$1) {
|
|
enqueuePendingPassiveHookEffectUnmount(current2, effect);
|
|
} else {
|
|
{
|
|
safelyCallDestroy(current2, destroy);
|
|
}
|
|
}
|
|
}
|
|
effect = effect.next;
|
|
} while (effect !== firstEffect);
|
|
}
|
|
}
|
|
return;
|
|
}
|
|
case ClassComponent: {
|
|
safelyDetachRef(current2);
|
|
var instance = current2.stateNode;
|
|
if (typeof instance.componentWillUnmount === "function") {
|
|
safelyCallComponentWillUnmount(current2, instance);
|
|
}
|
|
return;
|
|
}
|
|
case HostComponent: {
|
|
safelyDetachRef(current2);
|
|
return;
|
|
}
|
|
case HostPortal: {
|
|
{
|
|
unmountHostComponents(finishedRoot, current2);
|
|
}
|
|
return;
|
|
}
|
|
case FundamentalComponent: {
|
|
return;
|
|
}
|
|
case DehydratedFragment: {
|
|
return;
|
|
}
|
|
case ScopeComponent: {
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
function commitNestedUnmounts(finishedRoot, root2, renderPriorityLevel) {
|
|
var node = root2;
|
|
while (true) {
|
|
commitUnmount(finishedRoot, node);
|
|
if (node.child !== null && node.tag !== HostPortal) {
|
|
node.child.return = node;
|
|
node = node.child;
|
|
continue;
|
|
}
|
|
if (node === root2) {
|
|
return;
|
|
}
|
|
while (node.sibling === null) {
|
|
if (node.return === null || node.return === root2) {
|
|
return;
|
|
}
|
|
node = node.return;
|
|
}
|
|
node.sibling.return = node.return;
|
|
node = node.sibling;
|
|
}
|
|
}
|
|
function detachFiberMutation(fiber) {
|
|
fiber.alternate = null;
|
|
fiber.child = null;
|
|
fiber.dependencies = null;
|
|
fiber.firstEffect = null;
|
|
fiber.lastEffect = null;
|
|
fiber.memoizedProps = null;
|
|
fiber.memoizedState = null;
|
|
fiber.pendingProps = null;
|
|
fiber.return = null;
|
|
fiber.updateQueue = null;
|
|
{
|
|
fiber._debugOwner = null;
|
|
}
|
|
}
|
|
function getHostParentFiber(fiber) {
|
|
var parent = fiber.return;
|
|
while (parent !== null) {
|
|
if (isHostParent(parent)) {
|
|
return parent;
|
|
}
|
|
parent = parent.return;
|
|
}
|
|
{
|
|
{
|
|
throw Error("Expected to find a host parent. This error is likely caused by a bug in React. Please file an issue.");
|
|
}
|
|
}
|
|
}
|
|
function isHostParent(fiber) {
|
|
return fiber.tag === HostComponent || fiber.tag === HostRoot || fiber.tag === HostPortal;
|
|
}
|
|
function getHostSibling(fiber) {
|
|
var node = fiber;
|
|
siblings:
|
|
while (true) {
|
|
while (node.sibling === null) {
|
|
if (node.return === null || isHostParent(node.return)) {
|
|
return null;
|
|
}
|
|
node = node.return;
|
|
}
|
|
node.sibling.return = node.return;
|
|
node = node.sibling;
|
|
while (node.tag !== HostComponent && node.tag !== HostText && node.tag !== DehydratedFragment) {
|
|
if (node.flags & Placement) {
|
|
continue siblings;
|
|
}
|
|
if (node.child === null || node.tag === HostPortal) {
|
|
continue siblings;
|
|
} else {
|
|
node.child.return = node;
|
|
node = node.child;
|
|
}
|
|
}
|
|
if (!(node.flags & Placement)) {
|
|
return node.stateNode;
|
|
}
|
|
}
|
|
}
|
|
function commitPlacement(finishedWork) {
|
|
var parentFiber = getHostParentFiber(finishedWork);
|
|
var parent;
|
|
var isContainer;
|
|
var parentStateNode = parentFiber.stateNode;
|
|
switch (parentFiber.tag) {
|
|
case HostComponent:
|
|
parent = parentStateNode;
|
|
isContainer = false;
|
|
break;
|
|
case HostRoot:
|
|
parent = parentStateNode.containerInfo;
|
|
isContainer = true;
|
|
break;
|
|
case HostPortal:
|
|
parent = parentStateNode.containerInfo;
|
|
isContainer = true;
|
|
break;
|
|
case FundamentalComponent:
|
|
default: {
|
|
{
|
|
throw Error("Invalid host parent fiber. This error is likely caused by a bug in React. Please file an issue.");
|
|
}
|
|
}
|
|
}
|
|
if (parentFiber.flags & ContentReset) {
|
|
resetTextContent(parent);
|
|
parentFiber.flags &= ~ContentReset;
|
|
}
|
|
var before = getHostSibling(finishedWork);
|
|
if (isContainer) {
|
|
insertOrAppendPlacementNodeIntoContainer(finishedWork, before, parent);
|
|
} else {
|
|
insertOrAppendPlacementNode(finishedWork, before, parent);
|
|
}
|
|
}
|
|
function insertOrAppendPlacementNodeIntoContainer(node, before, parent) {
|
|
var tag = node.tag;
|
|
var isHost = tag === HostComponent || tag === HostText;
|
|
if (isHost || enableFundamentalAPI) {
|
|
var stateNode = isHost ? node.stateNode : node.stateNode.instance;
|
|
if (before) {
|
|
insertInContainerBefore(parent, stateNode, before);
|
|
} else {
|
|
appendChildToContainer(parent, stateNode);
|
|
}
|
|
} else if (tag === HostPortal)
|
|
;
|
|
else {
|
|
var child = node.child;
|
|
if (child !== null) {
|
|
insertOrAppendPlacementNodeIntoContainer(child, before, parent);
|
|
var sibling = child.sibling;
|
|
while (sibling !== null) {
|
|
insertOrAppendPlacementNodeIntoContainer(sibling, before, parent);
|
|
sibling = sibling.sibling;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
function insertOrAppendPlacementNode(node, before, parent) {
|
|
var tag = node.tag;
|
|
var isHost = tag === HostComponent || tag === HostText;
|
|
if (isHost || enableFundamentalAPI) {
|
|
var stateNode = isHost ? node.stateNode : node.stateNode.instance;
|
|
if (before) {
|
|
insertBefore(parent, stateNode, before);
|
|
} else {
|
|
appendChild(parent, stateNode);
|
|
}
|
|
} else if (tag === HostPortal)
|
|
;
|
|
else {
|
|
var child = node.child;
|
|
if (child !== null) {
|
|
insertOrAppendPlacementNode(child, before, parent);
|
|
var sibling = child.sibling;
|
|
while (sibling !== null) {
|
|
insertOrAppendPlacementNode(sibling, before, parent);
|
|
sibling = sibling.sibling;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
function unmountHostComponents(finishedRoot, current2, renderPriorityLevel) {
|
|
var node = current2;
|
|
var currentParentIsValid = false;
|
|
var currentParent;
|
|
var currentParentIsContainer;
|
|
while (true) {
|
|
if (!currentParentIsValid) {
|
|
var parent = node.return;
|
|
findParent:
|
|
while (true) {
|
|
if (!(parent !== null)) {
|
|
{
|
|
throw Error("Expected to find a host parent. This error is likely caused by a bug in React. Please file an issue.");
|
|
}
|
|
}
|
|
var parentStateNode = parent.stateNode;
|
|
switch (parent.tag) {
|
|
case HostComponent:
|
|
currentParent = parentStateNode;
|
|
currentParentIsContainer = false;
|
|
break findParent;
|
|
case HostRoot:
|
|
currentParent = parentStateNode.containerInfo;
|
|
currentParentIsContainer = true;
|
|
break findParent;
|
|
case HostPortal:
|
|
currentParent = parentStateNode.containerInfo;
|
|
currentParentIsContainer = true;
|
|
break findParent;
|
|
}
|
|
parent = parent.return;
|
|
}
|
|
currentParentIsValid = true;
|
|
}
|
|
if (node.tag === HostComponent || node.tag === HostText) {
|
|
commitNestedUnmounts(finishedRoot, node);
|
|
if (currentParentIsContainer) {
|
|
removeChildFromContainer(currentParent, node.stateNode);
|
|
} else {
|
|
removeChild(currentParent, node.stateNode);
|
|
}
|
|
} else if (node.tag === HostPortal) {
|
|
if (node.child !== null) {
|
|
currentParent = node.stateNode.containerInfo;
|
|
currentParentIsContainer = true;
|
|
node.child.return = node;
|
|
node = node.child;
|
|
continue;
|
|
}
|
|
} else {
|
|
commitUnmount(finishedRoot, node);
|
|
if (node.child !== null) {
|
|
node.child.return = node;
|
|
node = node.child;
|
|
continue;
|
|
}
|
|
}
|
|
if (node === current2) {
|
|
return;
|
|
}
|
|
while (node.sibling === null) {
|
|
if (node.return === null || node.return === current2) {
|
|
return;
|
|
}
|
|
node = node.return;
|
|
if (node.tag === HostPortal) {
|
|
currentParentIsValid = false;
|
|
}
|
|
}
|
|
node.sibling.return = node.return;
|
|
node = node.sibling;
|
|
}
|
|
}
|
|
function commitDeletion(finishedRoot, current2, renderPriorityLevel) {
|
|
{
|
|
unmountHostComponents(finishedRoot, current2);
|
|
}
|
|
var alternate = current2.alternate;
|
|
detachFiberMutation(current2);
|
|
if (alternate !== null) {
|
|
detachFiberMutation(alternate);
|
|
}
|
|
}
|
|
function commitWork(current2, finishedWork) {
|
|
switch (finishedWork.tag) {
|
|
case FunctionComponent:
|
|
case ForwardRef:
|
|
case MemoComponent:
|
|
case SimpleMemoComponent:
|
|
case Block: {
|
|
{
|
|
commitHookEffectListUnmount(Layout | HasEffect, finishedWork);
|
|
}
|
|
return;
|
|
}
|
|
case ClassComponent: {
|
|
return;
|
|
}
|
|
case HostComponent: {
|
|
var instance = finishedWork.stateNode;
|
|
if (instance != null) {
|
|
var newProps = finishedWork.memoizedProps;
|
|
var oldProps = current2 !== null ? current2.memoizedProps : newProps;
|
|
var type = finishedWork.type;
|
|
var updatePayload = finishedWork.updateQueue;
|
|
finishedWork.updateQueue = null;
|
|
if (updatePayload !== null) {
|
|
commitUpdate(instance, updatePayload, type, oldProps, newProps);
|
|
}
|
|
}
|
|
return;
|
|
}
|
|
case HostText: {
|
|
if (!(finishedWork.stateNode !== null)) {
|
|
{
|
|
throw Error("This should have a text node initialized. This error is likely caused by a bug in React. Please file an issue.");
|
|
}
|
|
}
|
|
var textInstance = finishedWork.stateNode;
|
|
var newText = finishedWork.memoizedProps;
|
|
var oldText = current2 !== null ? current2.memoizedProps : newText;
|
|
commitTextUpdate(textInstance, oldText, newText);
|
|
return;
|
|
}
|
|
case HostRoot: {
|
|
{
|
|
var _root = finishedWork.stateNode;
|
|
if (_root.hydrate) {
|
|
_root.hydrate = false;
|
|
commitHydratedContainer(_root.containerInfo);
|
|
}
|
|
}
|
|
return;
|
|
}
|
|
case Profiler: {
|
|
return;
|
|
}
|
|
case SuspenseComponent: {
|
|
commitSuspenseComponent(finishedWork);
|
|
attachSuspenseRetryListeners(finishedWork);
|
|
return;
|
|
}
|
|
case SuspenseListComponent: {
|
|
attachSuspenseRetryListeners(finishedWork);
|
|
return;
|
|
}
|
|
case IncompleteClassComponent: {
|
|
return;
|
|
}
|
|
case FundamentalComponent: {
|
|
break;
|
|
}
|
|
case ScopeComponent: {
|
|
break;
|
|
}
|
|
case OffscreenComponent:
|
|
case LegacyHiddenComponent: {
|
|
var newState = finishedWork.memoizedState;
|
|
var isHidden = newState !== null;
|
|
hideOrUnhideAllChildren(finishedWork, isHidden);
|
|
return;
|
|
}
|
|
}
|
|
{
|
|
{
|
|
throw Error("This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue.");
|
|
}
|
|
}
|
|
}
|
|
function commitSuspenseComponent(finishedWork) {
|
|
var newState = finishedWork.memoizedState;
|
|
if (newState !== null) {
|
|
markCommitTimeOfFallback();
|
|
{
|
|
var primaryChildParent = finishedWork.child;
|
|
hideOrUnhideAllChildren(primaryChildParent, true);
|
|
}
|
|
}
|
|
}
|
|
function commitSuspenseHydrationCallbacks(finishedRoot, finishedWork) {
|
|
var newState = finishedWork.memoizedState;
|
|
if (newState === null) {
|
|
var current2 = finishedWork.alternate;
|
|
if (current2 !== null) {
|
|
var prevState = current2.memoizedState;
|
|
if (prevState !== null) {
|
|
var suspenseInstance = prevState.dehydrated;
|
|
if (suspenseInstance !== null) {
|
|
commitHydratedSuspenseInstance(suspenseInstance);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
function attachSuspenseRetryListeners(finishedWork) {
|
|
var wakeables = finishedWork.updateQueue;
|
|
if (wakeables !== null) {
|
|
finishedWork.updateQueue = null;
|
|
var retryCache = finishedWork.stateNode;
|
|
if (retryCache === null) {
|
|
retryCache = finishedWork.stateNode = new PossiblyWeakSet();
|
|
}
|
|
wakeables.forEach(function(wakeable) {
|
|
var retry = resolveRetryWakeable.bind(null, finishedWork, wakeable);
|
|
if (!retryCache.has(wakeable)) {
|
|
{
|
|
if (wakeable.__reactDoNotTraceInteractions !== true) {
|
|
retry = tracing.unstable_wrap(retry);
|
|
}
|
|
}
|
|
retryCache.add(wakeable);
|
|
wakeable.then(retry, retry);
|
|
}
|
|
});
|
|
}
|
|
}
|
|
function isSuspenseBoundaryBeingHidden(current2, finishedWork) {
|
|
if (current2 !== null) {
|
|
var oldState = current2.memoizedState;
|
|
if (oldState === null || oldState.dehydrated !== null) {
|
|
var newState = finishedWork.memoizedState;
|
|
return newState !== null && newState.dehydrated === null;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
function commitResetTextContent(current2) {
|
|
resetTextContent(current2.stateNode);
|
|
}
|
|
var COMPONENT_TYPE = 0;
|
|
var HAS_PSEUDO_CLASS_TYPE = 1;
|
|
var ROLE_TYPE = 2;
|
|
var TEST_NAME_TYPE = 3;
|
|
var TEXT_TYPE = 4;
|
|
if (typeof Symbol === "function" && Symbol.for) {
|
|
var symbolFor$1 = Symbol.for;
|
|
COMPONENT_TYPE = symbolFor$1("selector.component");
|
|
HAS_PSEUDO_CLASS_TYPE = symbolFor$1("selector.has_pseudo_class");
|
|
ROLE_TYPE = symbolFor$1("selector.role");
|
|
TEST_NAME_TYPE = symbolFor$1("selector.test_id");
|
|
TEXT_TYPE = symbolFor$1("selector.text");
|
|
}
|
|
var commitHooks = [];
|
|
function onCommitRoot$1() {
|
|
{
|
|
commitHooks.forEach(function(commitHook) {
|
|
return commitHook();
|
|
});
|
|
}
|
|
}
|
|
var ceil = Math.ceil;
|
|
var ReactCurrentDispatcher$2 = ReactSharedInternals.ReactCurrentDispatcher, ReactCurrentOwner$2 = ReactSharedInternals.ReactCurrentOwner, IsSomeRendererActing = ReactSharedInternals.IsSomeRendererActing;
|
|
var NoContext = 0;
|
|
var BatchedContext = 1;
|
|
var EventContext = 2;
|
|
var DiscreteEventContext = 4;
|
|
var LegacyUnbatchedContext = 8;
|
|
var RenderContext = 16;
|
|
var CommitContext = 32;
|
|
var RetryAfterError = 64;
|
|
var RootIncomplete = 0;
|
|
var RootFatalErrored = 1;
|
|
var RootErrored = 2;
|
|
var RootSuspended = 3;
|
|
var RootSuspendedWithDelay = 4;
|
|
var RootCompleted = 5;
|
|
var executionContext = NoContext;
|
|
var workInProgressRoot = null;
|
|
var workInProgress = null;
|
|
var workInProgressRootRenderLanes = NoLanes;
|
|
var subtreeRenderLanes = NoLanes;
|
|
var subtreeRenderLanesCursor = createCursor(NoLanes);
|
|
var workInProgressRootExitStatus = RootIncomplete;
|
|
var workInProgressRootFatalError = null;
|
|
var workInProgressRootIncludedLanes = NoLanes;
|
|
var workInProgressRootSkippedLanes = NoLanes;
|
|
var workInProgressRootUpdatedLanes = NoLanes;
|
|
var workInProgressRootPingedLanes = NoLanes;
|
|
var mostRecentlyUpdatedRoot = null;
|
|
var globalMostRecentFallbackTime = 0;
|
|
var FALLBACK_THROTTLE_MS = 500;
|
|
var workInProgressRootRenderTargetTime = Infinity;
|
|
var RENDER_TIMEOUT_MS = 500;
|
|
function resetRenderTimer() {
|
|
workInProgressRootRenderTargetTime = now() + RENDER_TIMEOUT_MS;
|
|
}
|
|
function getRenderTargetTime() {
|
|
return workInProgressRootRenderTargetTime;
|
|
}
|
|
var nextEffect = null;
|
|
var hasUncaughtError = false;
|
|
var firstUncaughtError = null;
|
|
var legacyErrorBoundariesThatAlreadyFailed = null;
|
|
var rootDoesHavePassiveEffects = false;
|
|
var rootWithPendingPassiveEffects = null;
|
|
var pendingPassiveEffectsRenderPriority = NoPriority$1;
|
|
var pendingPassiveEffectsLanes = NoLanes;
|
|
var pendingPassiveHookEffectsMount = [];
|
|
var pendingPassiveHookEffectsUnmount = [];
|
|
var rootsWithPendingDiscreteUpdates = null;
|
|
var NESTED_UPDATE_LIMIT = 50;
|
|
var nestedUpdateCount = 0;
|
|
var rootWithNestedUpdates = null;
|
|
var NESTED_PASSIVE_UPDATE_LIMIT = 50;
|
|
var nestedPassiveUpdateCount = 0;
|
|
var spawnedWorkDuringRender = null;
|
|
var currentEventTime = NoTimestamp;
|
|
var currentEventWipLanes = NoLanes;
|
|
var currentEventPendingLanes = NoLanes;
|
|
var isFlushingPassiveEffects = false;
|
|
var focusedInstanceHandle = null;
|
|
var shouldFireAfterActiveInstanceBlur = false;
|
|
function getWorkInProgressRoot() {
|
|
return workInProgressRoot;
|
|
}
|
|
function requestEventTime() {
|
|
if ((executionContext & (RenderContext | CommitContext)) !== NoContext) {
|
|
return now();
|
|
}
|
|
if (currentEventTime !== NoTimestamp) {
|
|
return currentEventTime;
|
|
}
|
|
currentEventTime = now();
|
|
return currentEventTime;
|
|
}
|
|
function requestUpdateLane(fiber) {
|
|
var mode = fiber.mode;
|
|
if ((mode & BlockingMode) === NoMode) {
|
|
return SyncLane;
|
|
} else if ((mode & ConcurrentMode) === NoMode) {
|
|
return getCurrentPriorityLevel() === ImmediatePriority$1 ? SyncLane : SyncBatchedLane;
|
|
}
|
|
if (currentEventWipLanes === NoLanes) {
|
|
currentEventWipLanes = workInProgressRootIncludedLanes;
|
|
}
|
|
var isTransition = requestCurrentTransition() !== NoTransition;
|
|
if (isTransition) {
|
|
if (currentEventPendingLanes !== NoLanes) {
|
|
currentEventPendingLanes = mostRecentlyUpdatedRoot !== null ? mostRecentlyUpdatedRoot.pendingLanes : NoLanes;
|
|
}
|
|
return findTransitionLane(currentEventWipLanes, currentEventPendingLanes);
|
|
}
|
|
var schedulerPriority = getCurrentPriorityLevel();
|
|
var lane;
|
|
if ((executionContext & DiscreteEventContext) !== NoContext && schedulerPriority === UserBlockingPriority$2) {
|
|
lane = findUpdateLane(InputDiscreteLanePriority, currentEventWipLanes);
|
|
} else {
|
|
var schedulerLanePriority = schedulerPriorityToLanePriority(schedulerPriority);
|
|
lane = findUpdateLane(schedulerLanePriority, currentEventWipLanes);
|
|
}
|
|
return lane;
|
|
}
|
|
function requestRetryLane(fiber) {
|
|
var mode = fiber.mode;
|
|
if ((mode & BlockingMode) === NoMode) {
|
|
return SyncLane;
|
|
} else if ((mode & ConcurrentMode) === NoMode) {
|
|
return getCurrentPriorityLevel() === ImmediatePriority$1 ? SyncLane : SyncBatchedLane;
|
|
}
|
|
if (currentEventWipLanes === NoLanes) {
|
|
currentEventWipLanes = workInProgressRootIncludedLanes;
|
|
}
|
|
return findRetryLane(currentEventWipLanes);
|
|
}
|
|
function scheduleUpdateOnFiber(fiber, lane, eventTime) {
|
|
checkForNestedUpdates();
|
|
warnAboutRenderPhaseUpdatesInDEV(fiber);
|
|
var root2 = markUpdateLaneFromFiberToRoot(fiber, lane);
|
|
if (root2 === null) {
|
|
warnAboutUpdateOnUnmountedFiberInDEV(fiber);
|
|
return null;
|
|
}
|
|
markRootUpdated(root2, lane, eventTime);
|
|
if (root2 === workInProgressRoot) {
|
|
{
|
|
workInProgressRootUpdatedLanes = mergeLanes(workInProgressRootUpdatedLanes, lane);
|
|
}
|
|
if (workInProgressRootExitStatus === RootSuspendedWithDelay) {
|
|
markRootSuspended$1(root2, workInProgressRootRenderLanes);
|
|
}
|
|
}
|
|
var priorityLevel = getCurrentPriorityLevel();
|
|
if (lane === SyncLane) {
|
|
if ((executionContext & LegacyUnbatchedContext) !== NoContext && (executionContext & (RenderContext | CommitContext)) === NoContext) {
|
|
schedulePendingInteractions(root2, lane);
|
|
performSyncWorkOnRoot(root2);
|
|
} else {
|
|
ensureRootIsScheduled(root2, eventTime);
|
|
schedulePendingInteractions(root2, lane);
|
|
if (executionContext === NoContext) {
|
|
resetRenderTimer();
|
|
flushSyncCallbackQueue();
|
|
}
|
|
}
|
|
} else {
|
|
if ((executionContext & DiscreteEventContext) !== NoContext && (priorityLevel === UserBlockingPriority$2 || priorityLevel === ImmediatePriority$1)) {
|
|
if (rootsWithPendingDiscreteUpdates === null) {
|
|
rootsWithPendingDiscreteUpdates = new Set([root2]);
|
|
} else {
|
|
rootsWithPendingDiscreteUpdates.add(root2);
|
|
}
|
|
}
|
|
ensureRootIsScheduled(root2, eventTime);
|
|
schedulePendingInteractions(root2, lane);
|
|
}
|
|
mostRecentlyUpdatedRoot = root2;
|
|
}
|
|
function markUpdateLaneFromFiberToRoot(sourceFiber, lane) {
|
|
sourceFiber.lanes = mergeLanes(sourceFiber.lanes, lane);
|
|
var alternate = sourceFiber.alternate;
|
|
if (alternate !== null) {
|
|
alternate.lanes = mergeLanes(alternate.lanes, lane);
|
|
}
|
|
{
|
|
if (alternate === null && (sourceFiber.flags & (Placement | Hydrating)) !== NoFlags) {
|
|
warnAboutUpdateOnNotYetMountedFiberInDEV(sourceFiber);
|
|
}
|
|
}
|
|
var node = sourceFiber;
|
|
var parent = sourceFiber.return;
|
|
while (parent !== null) {
|
|
parent.childLanes = mergeLanes(parent.childLanes, lane);
|
|
alternate = parent.alternate;
|
|
if (alternate !== null) {
|
|
alternate.childLanes = mergeLanes(alternate.childLanes, lane);
|
|
} else {
|
|
{
|
|
if ((parent.flags & (Placement | Hydrating)) !== NoFlags) {
|
|
warnAboutUpdateOnNotYetMountedFiberInDEV(sourceFiber);
|
|
}
|
|
}
|
|
}
|
|
node = parent;
|
|
parent = parent.return;
|
|
}
|
|
if (node.tag === HostRoot) {
|
|
var root2 = node.stateNode;
|
|
return root2;
|
|
} else {
|
|
return null;
|
|
}
|
|
}
|
|
function ensureRootIsScheduled(root2, currentTime) {
|
|
var existingCallbackNode = root2.callbackNode;
|
|
markStarvedLanesAsExpired(root2, currentTime);
|
|
var nextLanes = getNextLanes(root2, root2 === workInProgressRoot ? workInProgressRootRenderLanes : NoLanes);
|
|
var newCallbackPriority = returnNextLanesPriority();
|
|
if (nextLanes === NoLanes) {
|
|
if (existingCallbackNode !== null) {
|
|
cancelCallback(existingCallbackNode);
|
|
root2.callbackNode = null;
|
|
root2.callbackPriority = NoLanePriority;
|
|
}
|
|
return;
|
|
}
|
|
if (existingCallbackNode !== null) {
|
|
var existingCallbackPriority = root2.callbackPriority;
|
|
if (existingCallbackPriority === newCallbackPriority) {
|
|
return;
|
|
}
|
|
cancelCallback(existingCallbackNode);
|
|
}
|
|
var newCallbackNode;
|
|
if (newCallbackPriority === SyncLanePriority) {
|
|
newCallbackNode = scheduleSyncCallback(performSyncWorkOnRoot.bind(null, root2));
|
|
} else if (newCallbackPriority === SyncBatchedLanePriority) {
|
|
newCallbackNode = scheduleCallback(ImmediatePriority$1, performSyncWorkOnRoot.bind(null, root2));
|
|
} else {
|
|
var schedulerPriorityLevel = lanePriorityToSchedulerPriority(newCallbackPriority);
|
|
newCallbackNode = scheduleCallback(schedulerPriorityLevel, performConcurrentWorkOnRoot.bind(null, root2));
|
|
}
|
|
root2.callbackPriority = newCallbackPriority;
|
|
root2.callbackNode = newCallbackNode;
|
|
}
|
|
function performConcurrentWorkOnRoot(root2) {
|
|
currentEventTime = NoTimestamp;
|
|
currentEventWipLanes = NoLanes;
|
|
currentEventPendingLanes = NoLanes;
|
|
if (!((executionContext & (RenderContext | CommitContext)) === NoContext)) {
|
|
{
|
|
throw Error("Should not already be working.");
|
|
}
|
|
}
|
|
var originalCallbackNode = root2.callbackNode;
|
|
var didFlushPassiveEffects = flushPassiveEffects();
|
|
if (didFlushPassiveEffects) {
|
|
if (root2.callbackNode !== originalCallbackNode) {
|
|
return null;
|
|
}
|
|
}
|
|
var lanes = getNextLanes(root2, root2 === workInProgressRoot ? workInProgressRootRenderLanes : NoLanes);
|
|
if (lanes === NoLanes) {
|
|
return null;
|
|
}
|
|
var exitStatus = renderRootConcurrent(root2, lanes);
|
|
if (includesSomeLane(workInProgressRootIncludedLanes, workInProgressRootUpdatedLanes)) {
|
|
prepareFreshStack(root2, NoLanes);
|
|
} else if (exitStatus !== RootIncomplete) {
|
|
if (exitStatus === RootErrored) {
|
|
executionContext |= RetryAfterError;
|
|
if (root2.hydrate) {
|
|
root2.hydrate = false;
|
|
clearContainer(root2.containerInfo);
|
|
}
|
|
lanes = getLanesToRetrySynchronouslyOnError(root2);
|
|
if (lanes !== NoLanes) {
|
|
exitStatus = renderRootSync(root2, lanes);
|
|
}
|
|
}
|
|
if (exitStatus === RootFatalErrored) {
|
|
var fatalError = workInProgressRootFatalError;
|
|
prepareFreshStack(root2, NoLanes);
|
|
markRootSuspended$1(root2, lanes);
|
|
ensureRootIsScheduled(root2, now());
|
|
throw fatalError;
|
|
}
|
|
var finishedWork = root2.current.alternate;
|
|
root2.finishedWork = finishedWork;
|
|
root2.finishedLanes = lanes;
|
|
finishConcurrentRender(root2, exitStatus, lanes);
|
|
}
|
|
ensureRootIsScheduled(root2, now());
|
|
if (root2.callbackNode === originalCallbackNode) {
|
|
return performConcurrentWorkOnRoot.bind(null, root2);
|
|
}
|
|
return null;
|
|
}
|
|
function finishConcurrentRender(root2, exitStatus, lanes) {
|
|
switch (exitStatus) {
|
|
case RootIncomplete:
|
|
case RootFatalErrored: {
|
|
{
|
|
{
|
|
throw Error("Root did not complete. This is a bug in React.");
|
|
}
|
|
}
|
|
}
|
|
case RootErrored: {
|
|
commitRoot(root2);
|
|
break;
|
|
}
|
|
case RootSuspended: {
|
|
markRootSuspended$1(root2, lanes);
|
|
if (includesOnlyRetries(lanes) && !shouldForceFlushFallbacksInDEV()) {
|
|
var msUntilTimeout = globalMostRecentFallbackTime + FALLBACK_THROTTLE_MS - now();
|
|
if (msUntilTimeout > 10) {
|
|
var nextLanes = getNextLanes(root2, NoLanes);
|
|
if (nextLanes !== NoLanes) {
|
|
break;
|
|
}
|
|
var suspendedLanes = root2.suspendedLanes;
|
|
if (!isSubsetOfLanes(suspendedLanes, lanes)) {
|
|
var eventTime = requestEventTime();
|
|
markRootPinged(root2, suspendedLanes);
|
|
break;
|
|
}
|
|
root2.timeoutHandle = scheduleTimeout(commitRoot.bind(null, root2), msUntilTimeout);
|
|
break;
|
|
}
|
|
}
|
|
commitRoot(root2);
|
|
break;
|
|
}
|
|
case RootSuspendedWithDelay: {
|
|
markRootSuspended$1(root2, lanes);
|
|
if (includesOnlyTransitions(lanes)) {
|
|
break;
|
|
}
|
|
if (!shouldForceFlushFallbacksInDEV()) {
|
|
var mostRecentEventTime = getMostRecentEventTime(root2, lanes);
|
|
var eventTimeMs = mostRecentEventTime;
|
|
var timeElapsedMs = now() - eventTimeMs;
|
|
var _msUntilTimeout = jnd(timeElapsedMs) - timeElapsedMs;
|
|
if (_msUntilTimeout > 10) {
|
|
root2.timeoutHandle = scheduleTimeout(commitRoot.bind(null, root2), _msUntilTimeout);
|
|
break;
|
|
}
|
|
}
|
|
commitRoot(root2);
|
|
break;
|
|
}
|
|
case RootCompleted: {
|
|
commitRoot(root2);
|
|
break;
|
|
}
|
|
default: {
|
|
{
|
|
{
|
|
throw Error("Unknown root exit status.");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
function markRootSuspended$1(root2, suspendedLanes) {
|
|
suspendedLanes = removeLanes(suspendedLanes, workInProgressRootPingedLanes);
|
|
suspendedLanes = removeLanes(suspendedLanes, workInProgressRootUpdatedLanes);
|
|
markRootSuspended(root2, suspendedLanes);
|
|
}
|
|
function performSyncWorkOnRoot(root2) {
|
|
if (!((executionContext & (RenderContext | CommitContext)) === NoContext)) {
|
|
{
|
|
throw Error("Should not already be working.");
|
|
}
|
|
}
|
|
flushPassiveEffects();
|
|
var lanes;
|
|
var exitStatus;
|
|
if (root2 === workInProgressRoot && includesSomeLane(root2.expiredLanes, workInProgressRootRenderLanes)) {
|
|
lanes = workInProgressRootRenderLanes;
|
|
exitStatus = renderRootSync(root2, lanes);
|
|
if (includesSomeLane(workInProgressRootIncludedLanes, workInProgressRootUpdatedLanes)) {
|
|
lanes = getNextLanes(root2, lanes);
|
|
exitStatus = renderRootSync(root2, lanes);
|
|
}
|
|
} else {
|
|
lanes = getNextLanes(root2, NoLanes);
|
|
exitStatus = renderRootSync(root2, lanes);
|
|
}
|
|
if (root2.tag !== LegacyRoot && exitStatus === RootErrored) {
|
|
executionContext |= RetryAfterError;
|
|
if (root2.hydrate) {
|
|
root2.hydrate = false;
|
|
clearContainer(root2.containerInfo);
|
|
}
|
|
lanes = getLanesToRetrySynchronouslyOnError(root2);
|
|
if (lanes !== NoLanes) {
|
|
exitStatus = renderRootSync(root2, lanes);
|
|
}
|
|
}
|
|
if (exitStatus === RootFatalErrored) {
|
|
var fatalError = workInProgressRootFatalError;
|
|
prepareFreshStack(root2, NoLanes);
|
|
markRootSuspended$1(root2, lanes);
|
|
ensureRootIsScheduled(root2, now());
|
|
throw fatalError;
|
|
}
|
|
var finishedWork = root2.current.alternate;
|
|
root2.finishedWork = finishedWork;
|
|
root2.finishedLanes = lanes;
|
|
commitRoot(root2);
|
|
ensureRootIsScheduled(root2, now());
|
|
return null;
|
|
}
|
|
function flushDiscreteUpdates() {
|
|
if ((executionContext & (BatchedContext | RenderContext | CommitContext)) !== NoContext) {
|
|
{
|
|
if ((executionContext & RenderContext) !== NoContext) {
|
|
error("unstable_flushDiscreteUpdates: Cannot flush updates when React is already rendering.");
|
|
}
|
|
}
|
|
return;
|
|
}
|
|
flushPendingDiscreteUpdates();
|
|
flushPassiveEffects();
|
|
}
|
|
function flushPendingDiscreteUpdates() {
|
|
if (rootsWithPendingDiscreteUpdates !== null) {
|
|
var roots = rootsWithPendingDiscreteUpdates;
|
|
rootsWithPendingDiscreteUpdates = null;
|
|
roots.forEach(function(root2) {
|
|
markDiscreteUpdatesExpired(root2);
|
|
ensureRootIsScheduled(root2, now());
|
|
});
|
|
}
|
|
flushSyncCallbackQueue();
|
|
}
|
|
function batchedUpdates$1(fn, a3) {
|
|
var prevExecutionContext = executionContext;
|
|
executionContext |= BatchedContext;
|
|
try {
|
|
return fn(a3);
|
|
} finally {
|
|
executionContext = prevExecutionContext;
|
|
if (executionContext === NoContext) {
|
|
resetRenderTimer();
|
|
flushSyncCallbackQueue();
|
|
}
|
|
}
|
|
}
|
|
function batchedEventUpdates$1(fn, a3) {
|
|
var prevExecutionContext = executionContext;
|
|
executionContext |= EventContext;
|
|
try {
|
|
return fn(a3);
|
|
} finally {
|
|
executionContext = prevExecutionContext;
|
|
if (executionContext === NoContext) {
|
|
resetRenderTimer();
|
|
flushSyncCallbackQueue();
|
|
}
|
|
}
|
|
}
|
|
function discreteUpdates$1(fn, a3, b3, c3, d3) {
|
|
var prevExecutionContext = executionContext;
|
|
executionContext |= DiscreteEventContext;
|
|
{
|
|
try {
|
|
return runWithPriority$1(UserBlockingPriority$2, fn.bind(null, a3, b3, c3, d3));
|
|
} finally {
|
|
executionContext = prevExecutionContext;
|
|
if (executionContext === NoContext) {
|
|
resetRenderTimer();
|
|
flushSyncCallbackQueue();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
function unbatchedUpdates(fn, a3) {
|
|
var prevExecutionContext = executionContext;
|
|
executionContext &= ~BatchedContext;
|
|
executionContext |= LegacyUnbatchedContext;
|
|
try {
|
|
return fn(a3);
|
|
} finally {
|
|
executionContext = prevExecutionContext;
|
|
if (executionContext === NoContext) {
|
|
resetRenderTimer();
|
|
flushSyncCallbackQueue();
|
|
}
|
|
}
|
|
}
|
|
function flushSync(fn, a3) {
|
|
var prevExecutionContext = executionContext;
|
|
if ((prevExecutionContext & (RenderContext | CommitContext)) !== NoContext) {
|
|
{
|
|
error("flushSync was called from inside a lifecycle method. React cannot flush when React is already rendering. Consider moving this call to a scheduler task or micro task.");
|
|
}
|
|
return fn(a3);
|
|
}
|
|
executionContext |= BatchedContext;
|
|
{
|
|
try {
|
|
if (fn) {
|
|
return runWithPriority$1(ImmediatePriority$1, fn.bind(null, a3));
|
|
} else {
|
|
return void 0;
|
|
}
|
|
} finally {
|
|
executionContext = prevExecutionContext;
|
|
flushSyncCallbackQueue();
|
|
}
|
|
}
|
|
}
|
|
function pushRenderLanes(fiber, lanes) {
|
|
push(subtreeRenderLanesCursor, subtreeRenderLanes, fiber);
|
|
subtreeRenderLanes = mergeLanes(subtreeRenderLanes, lanes);
|
|
workInProgressRootIncludedLanes = mergeLanes(workInProgressRootIncludedLanes, lanes);
|
|
}
|
|
function popRenderLanes(fiber) {
|
|
subtreeRenderLanes = subtreeRenderLanesCursor.current;
|
|
pop(subtreeRenderLanesCursor, fiber);
|
|
}
|
|
function prepareFreshStack(root2, lanes) {
|
|
root2.finishedWork = null;
|
|
root2.finishedLanes = NoLanes;
|
|
var timeoutHandle = root2.timeoutHandle;
|
|
if (timeoutHandle !== noTimeout) {
|
|
root2.timeoutHandle = noTimeout;
|
|
cancelTimeout(timeoutHandle);
|
|
}
|
|
if (workInProgress !== null) {
|
|
var interruptedWork = workInProgress.return;
|
|
while (interruptedWork !== null) {
|
|
unwindInterruptedWork(interruptedWork);
|
|
interruptedWork = interruptedWork.return;
|
|
}
|
|
}
|
|
workInProgressRoot = root2;
|
|
workInProgress = createWorkInProgress(root2.current, null);
|
|
workInProgressRootRenderLanes = subtreeRenderLanes = workInProgressRootIncludedLanes = lanes;
|
|
workInProgressRootExitStatus = RootIncomplete;
|
|
workInProgressRootFatalError = null;
|
|
workInProgressRootSkippedLanes = NoLanes;
|
|
workInProgressRootUpdatedLanes = NoLanes;
|
|
workInProgressRootPingedLanes = NoLanes;
|
|
{
|
|
spawnedWorkDuringRender = null;
|
|
}
|
|
{
|
|
ReactStrictModeWarnings.discardPendingWarnings();
|
|
}
|
|
}
|
|
function handleError(root2, thrownValue) {
|
|
do {
|
|
var erroredWork = workInProgress;
|
|
try {
|
|
resetContextDependencies();
|
|
resetHooksAfterThrow();
|
|
resetCurrentFiber();
|
|
ReactCurrentOwner$2.current = null;
|
|
if (erroredWork === null || erroredWork.return === null) {
|
|
workInProgressRootExitStatus = RootFatalErrored;
|
|
workInProgressRootFatalError = thrownValue;
|
|
workInProgress = null;
|
|
return;
|
|
}
|
|
if (enableProfilerTimer && erroredWork.mode & ProfileMode) {
|
|
stopProfilerTimerIfRunningAndRecordDelta(erroredWork, true);
|
|
}
|
|
throwException(root2, erroredWork.return, erroredWork, thrownValue, workInProgressRootRenderLanes);
|
|
completeUnitOfWork(erroredWork);
|
|
} catch (yetAnotherThrownValue) {
|
|
thrownValue = yetAnotherThrownValue;
|
|
if (workInProgress === erroredWork && erroredWork !== null) {
|
|
erroredWork = erroredWork.return;
|
|
workInProgress = erroredWork;
|
|
} else {
|
|
erroredWork = workInProgress;
|
|
}
|
|
continue;
|
|
}
|
|
return;
|
|
} while (true);
|
|
}
|
|
function pushDispatcher() {
|
|
var prevDispatcher = ReactCurrentDispatcher$2.current;
|
|
ReactCurrentDispatcher$2.current = ContextOnlyDispatcher;
|
|
if (prevDispatcher === null) {
|
|
return ContextOnlyDispatcher;
|
|
} else {
|
|
return prevDispatcher;
|
|
}
|
|
}
|
|
function popDispatcher(prevDispatcher) {
|
|
ReactCurrentDispatcher$2.current = prevDispatcher;
|
|
}
|
|
function pushInteractions(root2) {
|
|
{
|
|
var prevInteractions = tracing.__interactionsRef.current;
|
|
tracing.__interactionsRef.current = root2.memoizedInteractions;
|
|
return prevInteractions;
|
|
}
|
|
}
|
|
function popInteractions(prevInteractions) {
|
|
{
|
|
tracing.__interactionsRef.current = prevInteractions;
|
|
}
|
|
}
|
|
function markCommitTimeOfFallback() {
|
|
globalMostRecentFallbackTime = now();
|
|
}
|
|
function markSkippedUpdateLanes(lane) {
|
|
workInProgressRootSkippedLanes = mergeLanes(lane, workInProgressRootSkippedLanes);
|
|
}
|
|
function renderDidSuspend() {
|
|
if (workInProgressRootExitStatus === RootIncomplete) {
|
|
workInProgressRootExitStatus = RootSuspended;
|
|
}
|
|
}
|
|
function renderDidSuspendDelayIfPossible() {
|
|
if (workInProgressRootExitStatus === RootIncomplete || workInProgressRootExitStatus === RootSuspended) {
|
|
workInProgressRootExitStatus = RootSuspendedWithDelay;
|
|
}
|
|
if (workInProgressRoot !== null && (includesNonIdleWork(workInProgressRootSkippedLanes) || includesNonIdleWork(workInProgressRootUpdatedLanes))) {
|
|
markRootSuspended$1(workInProgressRoot, workInProgressRootRenderLanes);
|
|
}
|
|
}
|
|
function renderDidError() {
|
|
if (workInProgressRootExitStatus !== RootCompleted) {
|
|
workInProgressRootExitStatus = RootErrored;
|
|
}
|
|
}
|
|
function renderHasNotSuspendedYet() {
|
|
return workInProgressRootExitStatus === RootIncomplete;
|
|
}
|
|
function renderRootSync(root2, lanes) {
|
|
var prevExecutionContext = executionContext;
|
|
executionContext |= RenderContext;
|
|
var prevDispatcher = pushDispatcher();
|
|
if (workInProgressRoot !== root2 || workInProgressRootRenderLanes !== lanes) {
|
|
prepareFreshStack(root2, lanes);
|
|
startWorkOnPendingInteractions(root2, lanes);
|
|
}
|
|
var prevInteractions = pushInteractions(root2);
|
|
do {
|
|
try {
|
|
workLoopSync();
|
|
break;
|
|
} catch (thrownValue) {
|
|
handleError(root2, thrownValue);
|
|
}
|
|
} while (true);
|
|
resetContextDependencies();
|
|
{
|
|
popInteractions(prevInteractions);
|
|
}
|
|
executionContext = prevExecutionContext;
|
|
popDispatcher(prevDispatcher);
|
|
if (workInProgress !== null) {
|
|
{
|
|
{
|
|
throw Error("Cannot commit an incomplete root. This error is likely caused by a bug in React. Please file an issue.");
|
|
}
|
|
}
|
|
}
|
|
workInProgressRoot = null;
|
|
workInProgressRootRenderLanes = NoLanes;
|
|
return workInProgressRootExitStatus;
|
|
}
|
|
function workLoopSync() {
|
|
while (workInProgress !== null) {
|
|
performUnitOfWork(workInProgress);
|
|
}
|
|
}
|
|
function renderRootConcurrent(root2, lanes) {
|
|
var prevExecutionContext = executionContext;
|
|
executionContext |= RenderContext;
|
|
var prevDispatcher = pushDispatcher();
|
|
if (workInProgressRoot !== root2 || workInProgressRootRenderLanes !== lanes) {
|
|
resetRenderTimer();
|
|
prepareFreshStack(root2, lanes);
|
|
startWorkOnPendingInteractions(root2, lanes);
|
|
}
|
|
var prevInteractions = pushInteractions(root2);
|
|
do {
|
|
try {
|
|
workLoopConcurrent();
|
|
break;
|
|
} catch (thrownValue) {
|
|
handleError(root2, thrownValue);
|
|
}
|
|
} while (true);
|
|
resetContextDependencies();
|
|
{
|
|
popInteractions(prevInteractions);
|
|
}
|
|
popDispatcher(prevDispatcher);
|
|
executionContext = prevExecutionContext;
|
|
if (workInProgress !== null) {
|
|
return RootIncomplete;
|
|
} else {
|
|
workInProgressRoot = null;
|
|
workInProgressRootRenderLanes = NoLanes;
|
|
return workInProgressRootExitStatus;
|
|
}
|
|
}
|
|
function workLoopConcurrent() {
|
|
while (workInProgress !== null && !shouldYield()) {
|
|
performUnitOfWork(workInProgress);
|
|
}
|
|
}
|
|
function performUnitOfWork(unitOfWork) {
|
|
var current2 = unitOfWork.alternate;
|
|
setCurrentFiber(unitOfWork);
|
|
var next;
|
|
if ((unitOfWork.mode & ProfileMode) !== NoMode) {
|
|
startProfilerTimer(unitOfWork);
|
|
next = beginWork$1(current2, unitOfWork, subtreeRenderLanes);
|
|
stopProfilerTimerIfRunningAndRecordDelta(unitOfWork, true);
|
|
} else {
|
|
next = beginWork$1(current2, unitOfWork, subtreeRenderLanes);
|
|
}
|
|
resetCurrentFiber();
|
|
unitOfWork.memoizedProps = unitOfWork.pendingProps;
|
|
if (next === null) {
|
|
completeUnitOfWork(unitOfWork);
|
|
} else {
|
|
workInProgress = next;
|
|
}
|
|
ReactCurrentOwner$2.current = null;
|
|
}
|
|
function completeUnitOfWork(unitOfWork) {
|
|
var completedWork = unitOfWork;
|
|
do {
|
|
var current2 = completedWork.alternate;
|
|
var returnFiber = completedWork.return;
|
|
if ((completedWork.flags & Incomplete) === NoFlags) {
|
|
setCurrentFiber(completedWork);
|
|
var next = void 0;
|
|
if ((completedWork.mode & ProfileMode) === NoMode) {
|
|
next = completeWork(current2, completedWork, subtreeRenderLanes);
|
|
} else {
|
|
startProfilerTimer(completedWork);
|
|
next = completeWork(current2, completedWork, subtreeRenderLanes);
|
|
stopProfilerTimerIfRunningAndRecordDelta(completedWork, false);
|
|
}
|
|
resetCurrentFiber();
|
|
if (next !== null) {
|
|
workInProgress = next;
|
|
return;
|
|
}
|
|
resetChildLanes(completedWork);
|
|
if (returnFiber !== null && (returnFiber.flags & Incomplete) === NoFlags) {
|
|
if (returnFiber.firstEffect === null) {
|
|
returnFiber.firstEffect = completedWork.firstEffect;
|
|
}
|
|
if (completedWork.lastEffect !== null) {
|
|
if (returnFiber.lastEffect !== null) {
|
|
returnFiber.lastEffect.nextEffect = completedWork.firstEffect;
|
|
}
|
|
returnFiber.lastEffect = completedWork.lastEffect;
|
|
}
|
|
var flags = completedWork.flags;
|
|
if (flags > PerformedWork) {
|
|
if (returnFiber.lastEffect !== null) {
|
|
returnFiber.lastEffect.nextEffect = completedWork;
|
|
} else {
|
|
returnFiber.firstEffect = completedWork;
|
|
}
|
|
returnFiber.lastEffect = completedWork;
|
|
}
|
|
}
|
|
} else {
|
|
var _next = unwindWork(completedWork);
|
|
if (_next !== null) {
|
|
_next.flags &= HostEffectMask;
|
|
workInProgress = _next;
|
|
return;
|
|
}
|
|
if ((completedWork.mode & ProfileMode) !== NoMode) {
|
|
stopProfilerTimerIfRunningAndRecordDelta(completedWork, false);
|
|
var actualDuration = completedWork.actualDuration;
|
|
var child = completedWork.child;
|
|
while (child !== null) {
|
|
actualDuration += child.actualDuration;
|
|
child = child.sibling;
|
|
}
|
|
completedWork.actualDuration = actualDuration;
|
|
}
|
|
if (returnFiber !== null) {
|
|
returnFiber.firstEffect = returnFiber.lastEffect = null;
|
|
returnFiber.flags |= Incomplete;
|
|
}
|
|
}
|
|
var siblingFiber = completedWork.sibling;
|
|
if (siblingFiber !== null) {
|
|
workInProgress = siblingFiber;
|
|
return;
|
|
}
|
|
completedWork = returnFiber;
|
|
workInProgress = completedWork;
|
|
} while (completedWork !== null);
|
|
if (workInProgressRootExitStatus === RootIncomplete) {
|
|
workInProgressRootExitStatus = RootCompleted;
|
|
}
|
|
}
|
|
function resetChildLanes(completedWork) {
|
|
if ((completedWork.tag === LegacyHiddenComponent || completedWork.tag === OffscreenComponent) && completedWork.memoizedState !== null && !includesSomeLane(subtreeRenderLanes, OffscreenLane) && (completedWork.mode & ConcurrentMode) !== NoLanes) {
|
|
return;
|
|
}
|
|
var newChildLanes = NoLanes;
|
|
if ((completedWork.mode & ProfileMode) !== NoMode) {
|
|
var actualDuration = completedWork.actualDuration;
|
|
var treeBaseDuration = completedWork.selfBaseDuration;
|
|
var shouldBubbleActualDurations = completedWork.alternate === null || completedWork.child !== completedWork.alternate.child;
|
|
var child = completedWork.child;
|
|
while (child !== null) {
|
|
newChildLanes = mergeLanes(newChildLanes, mergeLanes(child.lanes, child.childLanes));
|
|
if (shouldBubbleActualDurations) {
|
|
actualDuration += child.actualDuration;
|
|
}
|
|
treeBaseDuration += child.treeBaseDuration;
|
|
child = child.sibling;
|
|
}
|
|
var isTimedOutSuspense = completedWork.tag === SuspenseComponent && completedWork.memoizedState !== null;
|
|
if (isTimedOutSuspense) {
|
|
var primaryChildFragment = completedWork.child;
|
|
if (primaryChildFragment !== null) {
|
|
treeBaseDuration -= primaryChildFragment.treeBaseDuration;
|
|
}
|
|
}
|
|
completedWork.actualDuration = actualDuration;
|
|
completedWork.treeBaseDuration = treeBaseDuration;
|
|
} else {
|
|
var _child = completedWork.child;
|
|
while (_child !== null) {
|
|
newChildLanes = mergeLanes(newChildLanes, mergeLanes(_child.lanes, _child.childLanes));
|
|
_child = _child.sibling;
|
|
}
|
|
}
|
|
completedWork.childLanes = newChildLanes;
|
|
}
|
|
function commitRoot(root2) {
|
|
var renderPriorityLevel = getCurrentPriorityLevel();
|
|
runWithPriority$1(ImmediatePriority$1, commitRootImpl.bind(null, root2, renderPriorityLevel));
|
|
return null;
|
|
}
|
|
function commitRootImpl(root2, renderPriorityLevel) {
|
|
do {
|
|
flushPassiveEffects();
|
|
} while (rootWithPendingPassiveEffects !== null);
|
|
flushRenderPhaseStrictModeWarningsInDEV();
|
|
if (!((executionContext & (RenderContext | CommitContext)) === NoContext)) {
|
|
{
|
|
throw Error("Should not already be working.");
|
|
}
|
|
}
|
|
var finishedWork = root2.finishedWork;
|
|
var lanes = root2.finishedLanes;
|
|
if (finishedWork === null) {
|
|
return null;
|
|
}
|
|
root2.finishedWork = null;
|
|
root2.finishedLanes = NoLanes;
|
|
if (!(finishedWork !== root2.current)) {
|
|
{
|
|
throw Error("Cannot commit the same tree as before. This error is likely caused by a bug in React. Please file an issue.");
|
|
}
|
|
}
|
|
root2.callbackNode = null;
|
|
var remainingLanes = mergeLanes(finishedWork.lanes, finishedWork.childLanes);
|
|
markRootFinished(root2, remainingLanes);
|
|
if (rootsWithPendingDiscreteUpdates !== null) {
|
|
if (!hasDiscreteLanes(remainingLanes) && rootsWithPendingDiscreteUpdates.has(root2)) {
|
|
rootsWithPendingDiscreteUpdates.delete(root2);
|
|
}
|
|
}
|
|
if (root2 === workInProgressRoot) {
|
|
workInProgressRoot = null;
|
|
workInProgress = null;
|
|
workInProgressRootRenderLanes = NoLanes;
|
|
}
|
|
var firstEffect;
|
|
if (finishedWork.flags > PerformedWork) {
|
|
if (finishedWork.lastEffect !== null) {
|
|
finishedWork.lastEffect.nextEffect = finishedWork;
|
|
firstEffect = finishedWork.firstEffect;
|
|
} else {
|
|
firstEffect = finishedWork;
|
|
}
|
|
} else {
|
|
firstEffect = finishedWork.firstEffect;
|
|
}
|
|
if (firstEffect !== null) {
|
|
var prevExecutionContext = executionContext;
|
|
executionContext |= CommitContext;
|
|
var prevInteractions = pushInteractions(root2);
|
|
ReactCurrentOwner$2.current = null;
|
|
focusedInstanceHandle = prepareForCommit(root2.containerInfo);
|
|
shouldFireAfterActiveInstanceBlur = false;
|
|
nextEffect = firstEffect;
|
|
do {
|
|
{
|
|
invokeGuardedCallback(null, commitBeforeMutationEffects, null);
|
|
if (hasCaughtError()) {
|
|
if (!(nextEffect !== null)) {
|
|
{
|
|
throw Error("Should be working on an effect.");
|
|
}
|
|
}
|
|
var error2 = clearCaughtError();
|
|
captureCommitPhaseError(nextEffect, error2);
|
|
nextEffect = nextEffect.nextEffect;
|
|
}
|
|
}
|
|
} while (nextEffect !== null);
|
|
focusedInstanceHandle = null;
|
|
{
|
|
recordCommitTime();
|
|
}
|
|
nextEffect = firstEffect;
|
|
do {
|
|
{
|
|
invokeGuardedCallback(null, commitMutationEffects, null, root2, renderPriorityLevel);
|
|
if (hasCaughtError()) {
|
|
if (!(nextEffect !== null)) {
|
|
{
|
|
throw Error("Should be working on an effect.");
|
|
}
|
|
}
|
|
var _error = clearCaughtError();
|
|
captureCommitPhaseError(nextEffect, _error);
|
|
nextEffect = nextEffect.nextEffect;
|
|
}
|
|
}
|
|
} while (nextEffect !== null);
|
|
resetAfterCommit(root2.containerInfo);
|
|
root2.current = finishedWork;
|
|
nextEffect = firstEffect;
|
|
do {
|
|
{
|
|
invokeGuardedCallback(null, commitLayoutEffects, null, root2, lanes);
|
|
if (hasCaughtError()) {
|
|
if (!(nextEffect !== null)) {
|
|
{
|
|
throw Error("Should be working on an effect.");
|
|
}
|
|
}
|
|
var _error2 = clearCaughtError();
|
|
captureCommitPhaseError(nextEffect, _error2);
|
|
nextEffect = nextEffect.nextEffect;
|
|
}
|
|
}
|
|
} while (nextEffect !== null);
|
|
nextEffect = null;
|
|
requestPaint();
|
|
{
|
|
popInteractions(prevInteractions);
|
|
}
|
|
executionContext = prevExecutionContext;
|
|
} else {
|
|
root2.current = finishedWork;
|
|
{
|
|
recordCommitTime();
|
|
}
|
|
}
|
|
var rootDidHavePassiveEffects = rootDoesHavePassiveEffects;
|
|
if (rootDoesHavePassiveEffects) {
|
|
rootDoesHavePassiveEffects = false;
|
|
rootWithPendingPassiveEffects = root2;
|
|
pendingPassiveEffectsLanes = lanes;
|
|
pendingPassiveEffectsRenderPriority = renderPriorityLevel;
|
|
} else {
|
|
nextEffect = firstEffect;
|
|
while (nextEffect !== null) {
|
|
var nextNextEffect = nextEffect.nextEffect;
|
|
nextEffect.nextEffect = null;
|
|
if (nextEffect.flags & Deletion) {
|
|
detachFiberAfterEffects(nextEffect);
|
|
}
|
|
nextEffect = nextNextEffect;
|
|
}
|
|
}
|
|
remainingLanes = root2.pendingLanes;
|
|
if (remainingLanes !== NoLanes) {
|
|
{
|
|
if (spawnedWorkDuringRender !== null) {
|
|
var expirationTimes = spawnedWorkDuringRender;
|
|
spawnedWorkDuringRender = null;
|
|
for (var i3 = 0; i3 < expirationTimes.length; i3++) {
|
|
scheduleInteractions(root2, expirationTimes[i3], root2.memoizedInteractions);
|
|
}
|
|
}
|
|
schedulePendingInteractions(root2, remainingLanes);
|
|
}
|
|
} else {
|
|
legacyErrorBoundariesThatAlreadyFailed = null;
|
|
}
|
|
{
|
|
if (!rootDidHavePassiveEffects) {
|
|
finishPendingInteractions(root2, lanes);
|
|
}
|
|
}
|
|
if (remainingLanes === SyncLane) {
|
|
if (root2 === rootWithNestedUpdates) {
|
|
nestedUpdateCount++;
|
|
} else {
|
|
nestedUpdateCount = 0;
|
|
rootWithNestedUpdates = root2;
|
|
}
|
|
} else {
|
|
nestedUpdateCount = 0;
|
|
}
|
|
onCommitRoot(finishedWork.stateNode, renderPriorityLevel);
|
|
{
|
|
onCommitRoot$1();
|
|
}
|
|
ensureRootIsScheduled(root2, now());
|
|
if (hasUncaughtError) {
|
|
hasUncaughtError = false;
|
|
var _error3 = firstUncaughtError;
|
|
firstUncaughtError = null;
|
|
throw _error3;
|
|
}
|
|
if ((executionContext & LegacyUnbatchedContext) !== NoContext) {
|
|
return null;
|
|
}
|
|
flushSyncCallbackQueue();
|
|
return null;
|
|
}
|
|
function commitBeforeMutationEffects() {
|
|
while (nextEffect !== null) {
|
|
var current2 = nextEffect.alternate;
|
|
if (!shouldFireAfterActiveInstanceBlur && focusedInstanceHandle !== null) {
|
|
if ((nextEffect.flags & Deletion) !== NoFlags) {
|
|
if (doesFiberContain(nextEffect, focusedInstanceHandle)) {
|
|
shouldFireAfterActiveInstanceBlur = true;
|
|
}
|
|
} else {
|
|
if (nextEffect.tag === SuspenseComponent && isSuspenseBoundaryBeingHidden(current2, nextEffect) && doesFiberContain(nextEffect, focusedInstanceHandle)) {
|
|
shouldFireAfterActiveInstanceBlur = true;
|
|
}
|
|
}
|
|
}
|
|
var flags = nextEffect.flags;
|
|
if ((flags & Snapshot) !== NoFlags) {
|
|
setCurrentFiber(nextEffect);
|
|
commitBeforeMutationLifeCycles(current2, nextEffect);
|
|
resetCurrentFiber();
|
|
}
|
|
if ((flags & Passive) !== NoFlags) {
|
|
if (!rootDoesHavePassiveEffects) {
|
|
rootDoesHavePassiveEffects = true;
|
|
scheduleCallback(NormalPriority$1, function() {
|
|
flushPassiveEffects();
|
|
return null;
|
|
});
|
|
}
|
|
}
|
|
nextEffect = nextEffect.nextEffect;
|
|
}
|
|
}
|
|
function commitMutationEffects(root2, renderPriorityLevel) {
|
|
while (nextEffect !== null) {
|
|
setCurrentFiber(nextEffect);
|
|
var flags = nextEffect.flags;
|
|
if (flags & ContentReset) {
|
|
commitResetTextContent(nextEffect);
|
|
}
|
|
if (flags & Ref) {
|
|
var current2 = nextEffect.alternate;
|
|
if (current2 !== null) {
|
|
commitDetachRef(current2);
|
|
}
|
|
}
|
|
var primaryFlags = flags & (Placement | Update | Deletion | Hydrating);
|
|
switch (primaryFlags) {
|
|
case Placement: {
|
|
commitPlacement(nextEffect);
|
|
nextEffect.flags &= ~Placement;
|
|
break;
|
|
}
|
|
case PlacementAndUpdate: {
|
|
commitPlacement(nextEffect);
|
|
nextEffect.flags &= ~Placement;
|
|
var _current = nextEffect.alternate;
|
|
commitWork(_current, nextEffect);
|
|
break;
|
|
}
|
|
case Hydrating: {
|
|
nextEffect.flags &= ~Hydrating;
|
|
break;
|
|
}
|
|
case HydratingAndUpdate: {
|
|
nextEffect.flags &= ~Hydrating;
|
|
var _current2 = nextEffect.alternate;
|
|
commitWork(_current2, nextEffect);
|
|
break;
|
|
}
|
|
case Update: {
|
|
var _current3 = nextEffect.alternate;
|
|
commitWork(_current3, nextEffect);
|
|
break;
|
|
}
|
|
case Deletion: {
|
|
commitDeletion(root2, nextEffect);
|
|
break;
|
|
}
|
|
}
|
|
resetCurrentFiber();
|
|
nextEffect = nextEffect.nextEffect;
|
|
}
|
|
}
|
|
function commitLayoutEffects(root2, committedLanes) {
|
|
while (nextEffect !== null) {
|
|
setCurrentFiber(nextEffect);
|
|
var flags = nextEffect.flags;
|
|
if (flags & (Update | Callback)) {
|
|
var current2 = nextEffect.alternate;
|
|
commitLifeCycles(root2, current2, nextEffect);
|
|
}
|
|
{
|
|
if (flags & Ref) {
|
|
commitAttachRef(nextEffect);
|
|
}
|
|
}
|
|
resetCurrentFiber();
|
|
nextEffect = nextEffect.nextEffect;
|
|
}
|
|
}
|
|
function flushPassiveEffects() {
|
|
if (pendingPassiveEffectsRenderPriority !== NoPriority$1) {
|
|
var priorityLevel = pendingPassiveEffectsRenderPriority > NormalPriority$1 ? NormalPriority$1 : pendingPassiveEffectsRenderPriority;
|
|
pendingPassiveEffectsRenderPriority = NoPriority$1;
|
|
{
|
|
return runWithPriority$1(priorityLevel, flushPassiveEffectsImpl);
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
function enqueuePendingPassiveHookEffectMount(fiber, effect) {
|
|
pendingPassiveHookEffectsMount.push(effect, fiber);
|
|
if (!rootDoesHavePassiveEffects) {
|
|
rootDoesHavePassiveEffects = true;
|
|
scheduleCallback(NormalPriority$1, function() {
|
|
flushPassiveEffects();
|
|
return null;
|
|
});
|
|
}
|
|
}
|
|
function enqueuePendingPassiveHookEffectUnmount(fiber, effect) {
|
|
pendingPassiveHookEffectsUnmount.push(effect, fiber);
|
|
{
|
|
fiber.flags |= PassiveUnmountPendingDev;
|
|
var alternate = fiber.alternate;
|
|
if (alternate !== null) {
|
|
alternate.flags |= PassiveUnmountPendingDev;
|
|
}
|
|
}
|
|
if (!rootDoesHavePassiveEffects) {
|
|
rootDoesHavePassiveEffects = true;
|
|
scheduleCallback(NormalPriority$1, function() {
|
|
flushPassiveEffects();
|
|
return null;
|
|
});
|
|
}
|
|
}
|
|
function invokePassiveEffectCreate(effect) {
|
|
var create = effect.create;
|
|
effect.destroy = create();
|
|
}
|
|
function flushPassiveEffectsImpl() {
|
|
if (rootWithPendingPassiveEffects === null) {
|
|
return false;
|
|
}
|
|
var root2 = rootWithPendingPassiveEffects;
|
|
var lanes = pendingPassiveEffectsLanes;
|
|
rootWithPendingPassiveEffects = null;
|
|
pendingPassiveEffectsLanes = NoLanes;
|
|
if (!((executionContext & (RenderContext | CommitContext)) === NoContext)) {
|
|
{
|
|
throw Error("Cannot flush passive effects while already rendering.");
|
|
}
|
|
}
|
|
{
|
|
isFlushingPassiveEffects = true;
|
|
}
|
|
var prevExecutionContext = executionContext;
|
|
executionContext |= CommitContext;
|
|
var prevInteractions = pushInteractions(root2);
|
|
var unmountEffects = pendingPassiveHookEffectsUnmount;
|
|
pendingPassiveHookEffectsUnmount = [];
|
|
for (var i3 = 0; i3 < unmountEffects.length; i3 += 2) {
|
|
var _effect = unmountEffects[i3];
|
|
var fiber = unmountEffects[i3 + 1];
|
|
var destroy = _effect.destroy;
|
|
_effect.destroy = void 0;
|
|
{
|
|
fiber.flags &= ~PassiveUnmountPendingDev;
|
|
var alternate = fiber.alternate;
|
|
if (alternate !== null) {
|
|
alternate.flags &= ~PassiveUnmountPendingDev;
|
|
}
|
|
}
|
|
if (typeof destroy === "function") {
|
|
{
|
|
setCurrentFiber(fiber);
|
|
{
|
|
invokeGuardedCallback(null, destroy, null);
|
|
}
|
|
if (hasCaughtError()) {
|
|
if (!(fiber !== null)) {
|
|
{
|
|
throw Error("Should be working on an effect.");
|
|
}
|
|
}
|
|
var error2 = clearCaughtError();
|
|
captureCommitPhaseError(fiber, error2);
|
|
}
|
|
resetCurrentFiber();
|
|
}
|
|
}
|
|
}
|
|
var mountEffects = pendingPassiveHookEffectsMount;
|
|
pendingPassiveHookEffectsMount = [];
|
|
for (var _i = 0; _i < mountEffects.length; _i += 2) {
|
|
var _effect2 = mountEffects[_i];
|
|
var _fiber = mountEffects[_i + 1];
|
|
{
|
|
setCurrentFiber(_fiber);
|
|
{
|
|
invokeGuardedCallback(null, invokePassiveEffectCreate, null, _effect2);
|
|
}
|
|
if (hasCaughtError()) {
|
|
if (!(_fiber !== null)) {
|
|
{
|
|
throw Error("Should be working on an effect.");
|
|
}
|
|
}
|
|
var _error4 = clearCaughtError();
|
|
captureCommitPhaseError(_fiber, _error4);
|
|
}
|
|
resetCurrentFiber();
|
|
}
|
|
}
|
|
var effect = root2.current.firstEffect;
|
|
while (effect !== null) {
|
|
var nextNextEffect = effect.nextEffect;
|
|
effect.nextEffect = null;
|
|
if (effect.flags & Deletion) {
|
|
detachFiberAfterEffects(effect);
|
|
}
|
|
effect = nextNextEffect;
|
|
}
|
|
{
|
|
popInteractions(prevInteractions);
|
|
finishPendingInteractions(root2, lanes);
|
|
}
|
|
{
|
|
isFlushingPassiveEffects = false;
|
|
}
|
|
executionContext = prevExecutionContext;
|
|
flushSyncCallbackQueue();
|
|
nestedPassiveUpdateCount = rootWithPendingPassiveEffects === null ? 0 : nestedPassiveUpdateCount + 1;
|
|
return true;
|
|
}
|
|
function isAlreadyFailedLegacyErrorBoundary(instance) {
|
|
return legacyErrorBoundariesThatAlreadyFailed !== null && legacyErrorBoundariesThatAlreadyFailed.has(instance);
|
|
}
|
|
function markLegacyErrorBoundaryAsFailed(instance) {
|
|
if (legacyErrorBoundariesThatAlreadyFailed === null) {
|
|
legacyErrorBoundariesThatAlreadyFailed = new Set([instance]);
|
|
} else {
|
|
legacyErrorBoundariesThatAlreadyFailed.add(instance);
|
|
}
|
|
}
|
|
function prepareToThrowUncaughtError(error2) {
|
|
if (!hasUncaughtError) {
|
|
hasUncaughtError = true;
|
|
firstUncaughtError = error2;
|
|
}
|
|
}
|
|
var onUncaughtError = prepareToThrowUncaughtError;
|
|
function captureCommitPhaseErrorOnRoot(rootFiber, sourceFiber, error2) {
|
|
var errorInfo = createCapturedValue(error2, sourceFiber);
|
|
var update = createRootErrorUpdate(rootFiber, errorInfo, SyncLane);
|
|
enqueueUpdate(rootFiber, update);
|
|
var eventTime = requestEventTime();
|
|
var root2 = markUpdateLaneFromFiberToRoot(rootFiber, SyncLane);
|
|
if (root2 !== null) {
|
|
markRootUpdated(root2, SyncLane, eventTime);
|
|
ensureRootIsScheduled(root2, eventTime);
|
|
schedulePendingInteractions(root2, SyncLane);
|
|
}
|
|
}
|
|
function captureCommitPhaseError(sourceFiber, error2) {
|
|
if (sourceFiber.tag === HostRoot) {
|
|
captureCommitPhaseErrorOnRoot(sourceFiber, sourceFiber, error2);
|
|
return;
|
|
}
|
|
var fiber = sourceFiber.return;
|
|
while (fiber !== null) {
|
|
if (fiber.tag === HostRoot) {
|
|
captureCommitPhaseErrorOnRoot(fiber, sourceFiber, error2);
|
|
return;
|
|
} else if (fiber.tag === ClassComponent) {
|
|
var ctor = fiber.type;
|
|
var instance = fiber.stateNode;
|
|
if (typeof ctor.getDerivedStateFromError === "function" || typeof instance.componentDidCatch === "function" && !isAlreadyFailedLegacyErrorBoundary(instance)) {
|
|
var errorInfo = createCapturedValue(error2, sourceFiber);
|
|
var update = createClassErrorUpdate(fiber, errorInfo, SyncLane);
|
|
enqueueUpdate(fiber, update);
|
|
var eventTime = requestEventTime();
|
|
var root2 = markUpdateLaneFromFiberToRoot(fiber, SyncLane);
|
|
if (root2 !== null) {
|
|
markRootUpdated(root2, SyncLane, eventTime);
|
|
ensureRootIsScheduled(root2, eventTime);
|
|
schedulePendingInteractions(root2, SyncLane);
|
|
} else {
|
|
if (typeof instance.componentDidCatch === "function" && !isAlreadyFailedLegacyErrorBoundary(instance)) {
|
|
try {
|
|
instance.componentDidCatch(error2, errorInfo);
|
|
} catch (errorToIgnore) {
|
|
}
|
|
}
|
|
}
|
|
return;
|
|
}
|
|
}
|
|
fiber = fiber.return;
|
|
}
|
|
}
|
|
function pingSuspendedRoot(root2, wakeable, pingedLanes) {
|
|
var pingCache = root2.pingCache;
|
|
if (pingCache !== null) {
|
|
pingCache.delete(wakeable);
|
|
}
|
|
var eventTime = requestEventTime();
|
|
markRootPinged(root2, pingedLanes);
|
|
if (workInProgressRoot === root2 && isSubsetOfLanes(workInProgressRootRenderLanes, pingedLanes)) {
|
|
if (workInProgressRootExitStatus === RootSuspendedWithDelay || workInProgressRootExitStatus === RootSuspended && includesOnlyRetries(workInProgressRootRenderLanes) && now() - globalMostRecentFallbackTime < FALLBACK_THROTTLE_MS) {
|
|
prepareFreshStack(root2, NoLanes);
|
|
} else {
|
|
workInProgressRootPingedLanes = mergeLanes(workInProgressRootPingedLanes, pingedLanes);
|
|
}
|
|
}
|
|
ensureRootIsScheduled(root2, eventTime);
|
|
schedulePendingInteractions(root2, pingedLanes);
|
|
}
|
|
function retryTimedOutBoundary(boundaryFiber, retryLane) {
|
|
if (retryLane === NoLane) {
|
|
retryLane = requestRetryLane(boundaryFiber);
|
|
}
|
|
var eventTime = requestEventTime();
|
|
var root2 = markUpdateLaneFromFiberToRoot(boundaryFiber, retryLane);
|
|
if (root2 !== null) {
|
|
markRootUpdated(root2, retryLane, eventTime);
|
|
ensureRootIsScheduled(root2, eventTime);
|
|
schedulePendingInteractions(root2, retryLane);
|
|
}
|
|
}
|
|
function resolveRetryWakeable(boundaryFiber, wakeable) {
|
|
var retryLane = NoLane;
|
|
var retryCache;
|
|
{
|
|
retryCache = boundaryFiber.stateNode;
|
|
}
|
|
if (retryCache !== null) {
|
|
retryCache.delete(wakeable);
|
|
}
|
|
retryTimedOutBoundary(boundaryFiber, retryLane);
|
|
}
|
|
function jnd(timeElapsed) {
|
|
return timeElapsed < 120 ? 120 : timeElapsed < 480 ? 480 : timeElapsed < 1080 ? 1080 : timeElapsed < 1920 ? 1920 : timeElapsed < 3e3 ? 3e3 : timeElapsed < 4320 ? 4320 : ceil(timeElapsed / 1960) * 1960;
|
|
}
|
|
function checkForNestedUpdates() {
|
|
if (nestedUpdateCount > NESTED_UPDATE_LIMIT) {
|
|
nestedUpdateCount = 0;
|
|
rootWithNestedUpdates = null;
|
|
{
|
|
{
|
|
throw Error("Maximum update depth exceeded. This can happen when a component repeatedly calls setState inside componentWillUpdate or componentDidUpdate. React limits the number of nested updates to prevent infinite loops.");
|
|
}
|
|
}
|
|
}
|
|
{
|
|
if (nestedPassiveUpdateCount > NESTED_PASSIVE_UPDATE_LIMIT) {
|
|
nestedPassiveUpdateCount = 0;
|
|
error("Maximum update depth exceeded. This can happen when a component calls setState inside useEffect, but useEffect either doesn't have a dependency array, or one of the dependencies changes on every render.");
|
|
}
|
|
}
|
|
}
|
|
function flushRenderPhaseStrictModeWarningsInDEV() {
|
|
{
|
|
ReactStrictModeWarnings.flushLegacyContextWarning();
|
|
{
|
|
ReactStrictModeWarnings.flushPendingUnsafeLifecycleWarnings();
|
|
}
|
|
}
|
|
}
|
|
var didWarnStateUpdateForNotYetMountedComponent = null;
|
|
function warnAboutUpdateOnNotYetMountedFiberInDEV(fiber) {
|
|
{
|
|
if ((executionContext & RenderContext) !== NoContext) {
|
|
return;
|
|
}
|
|
if (!(fiber.mode & (BlockingMode | ConcurrentMode))) {
|
|
return;
|
|
}
|
|
var tag = fiber.tag;
|
|
if (tag !== IndeterminateComponent && tag !== HostRoot && tag !== ClassComponent && tag !== FunctionComponent && tag !== ForwardRef && tag !== MemoComponent && tag !== SimpleMemoComponent && tag !== Block) {
|
|
return;
|
|
}
|
|
var componentName = getComponentName(fiber.type) || "ReactComponent";
|
|
if (didWarnStateUpdateForNotYetMountedComponent !== null) {
|
|
if (didWarnStateUpdateForNotYetMountedComponent.has(componentName)) {
|
|
return;
|
|
}
|
|
didWarnStateUpdateForNotYetMountedComponent.add(componentName);
|
|
} else {
|
|
didWarnStateUpdateForNotYetMountedComponent = new Set([componentName]);
|
|
}
|
|
var previousFiber = current;
|
|
try {
|
|
setCurrentFiber(fiber);
|
|
error("Can't perform a React state update on a component that hasn't mounted yet. This indicates that you have a side-effect in your render function that asynchronously later calls tries to update the component. Move this work to useEffect instead.");
|
|
} finally {
|
|
if (previousFiber) {
|
|
setCurrentFiber(fiber);
|
|
} else {
|
|
resetCurrentFiber();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
var didWarnStateUpdateForUnmountedComponent = null;
|
|
function warnAboutUpdateOnUnmountedFiberInDEV(fiber) {
|
|
{
|
|
var tag = fiber.tag;
|
|
if (tag !== HostRoot && tag !== ClassComponent && tag !== FunctionComponent && tag !== ForwardRef && tag !== MemoComponent && tag !== SimpleMemoComponent && tag !== Block) {
|
|
return;
|
|
}
|
|
if ((fiber.flags & PassiveUnmountPendingDev) !== NoFlags) {
|
|
return;
|
|
}
|
|
var componentName = getComponentName(fiber.type) || "ReactComponent";
|
|
if (didWarnStateUpdateForUnmountedComponent !== null) {
|
|
if (didWarnStateUpdateForUnmountedComponent.has(componentName)) {
|
|
return;
|
|
}
|
|
didWarnStateUpdateForUnmountedComponent.add(componentName);
|
|
} else {
|
|
didWarnStateUpdateForUnmountedComponent = new Set([componentName]);
|
|
}
|
|
if (isFlushingPassiveEffects)
|
|
;
|
|
else {
|
|
var previousFiber = current;
|
|
try {
|
|
setCurrentFiber(fiber);
|
|
error("Can't perform a React state update on an unmounted component. This is a no-op, but it indicates a memory leak in your application. To fix, cancel all subscriptions and asynchronous tasks in %s.", tag === ClassComponent ? "the componentWillUnmount method" : "a useEffect cleanup function");
|
|
} finally {
|
|
if (previousFiber) {
|
|
setCurrentFiber(fiber);
|
|
} else {
|
|
resetCurrentFiber();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
var beginWork$1;
|
|
{
|
|
var dummyFiber = null;
|
|
beginWork$1 = function(current2, unitOfWork, lanes) {
|
|
var originalWorkInProgressCopy = assignFiberPropertiesInDEV(dummyFiber, unitOfWork);
|
|
try {
|
|
return beginWork(current2, unitOfWork, lanes);
|
|
} catch (originalError) {
|
|
if (originalError !== null && typeof originalError === "object" && typeof originalError.then === "function") {
|
|
throw originalError;
|
|
}
|
|
resetContextDependencies();
|
|
resetHooksAfterThrow();
|
|
unwindInterruptedWork(unitOfWork);
|
|
assignFiberPropertiesInDEV(unitOfWork, originalWorkInProgressCopy);
|
|
if (unitOfWork.mode & ProfileMode) {
|
|
startProfilerTimer(unitOfWork);
|
|
}
|
|
invokeGuardedCallback(null, beginWork, null, current2, unitOfWork, lanes);
|
|
if (hasCaughtError()) {
|
|
var replayError = clearCaughtError();
|
|
throw replayError;
|
|
} else {
|
|
throw originalError;
|
|
}
|
|
}
|
|
};
|
|
}
|
|
var didWarnAboutUpdateInRender = false;
|
|
var didWarnAboutUpdateInRenderForAnotherComponent;
|
|
{
|
|
didWarnAboutUpdateInRenderForAnotherComponent = new Set();
|
|
}
|
|
function warnAboutRenderPhaseUpdatesInDEV(fiber) {
|
|
{
|
|
if (isRendering && (executionContext & RenderContext) !== NoContext && !getIsUpdatingOpaqueValueInRenderPhaseInDEV()) {
|
|
switch (fiber.tag) {
|
|
case FunctionComponent:
|
|
case ForwardRef:
|
|
case SimpleMemoComponent: {
|
|
var renderingComponentName = workInProgress && getComponentName(workInProgress.type) || "Unknown";
|
|
var dedupeKey = renderingComponentName;
|
|
if (!didWarnAboutUpdateInRenderForAnotherComponent.has(dedupeKey)) {
|
|
didWarnAboutUpdateInRenderForAnotherComponent.add(dedupeKey);
|
|
var setStateComponentName = getComponentName(fiber.type) || "Unknown";
|
|
error("Cannot update a component (`%s`) while rendering a different component (`%s`). To locate the bad setState() call inside `%s`, follow the stack trace as described in https://reactjs.org/link/setstate-in-render", setStateComponentName, renderingComponentName, renderingComponentName);
|
|
}
|
|
break;
|
|
}
|
|
case ClassComponent: {
|
|
if (!didWarnAboutUpdateInRender) {
|
|
error("Cannot update during an existing state transition (such as within `render`). Render methods should be a pure function of props and state.");
|
|
didWarnAboutUpdateInRender = true;
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
var IsThisRendererActing = {
|
|
current: false
|
|
};
|
|
function warnIfNotScopedWithMatchingAct(fiber) {
|
|
{
|
|
if (IsSomeRendererActing.current === true && IsThisRendererActing.current !== true) {
|
|
var previousFiber = current;
|
|
try {
|
|
setCurrentFiber(fiber);
|
|
error("It looks like you're using the wrong act() around your test interactions.\nBe sure to use the matching version of act() corresponding to your renderer:\n\n// for react-dom:\nimport {act} from 'react-dom/test-utils';\n// ...\nact(() => ...);\n\n// for react-test-renderer:\nimport TestRenderer from react-test-renderer';\nconst {act} = TestRenderer;\n// ...\nact(() => ...);");
|
|
} finally {
|
|
if (previousFiber) {
|
|
setCurrentFiber(fiber);
|
|
} else {
|
|
resetCurrentFiber();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
function warnIfNotCurrentlyActingEffectsInDEV(fiber) {
|
|
{
|
|
if ((fiber.mode & StrictMode) !== NoMode && IsSomeRendererActing.current === false && IsThisRendererActing.current === false) {
|
|
error("An update to %s ran an effect, but was not wrapped in act(...).\n\nWhen testing, code that causes React state updates should be wrapped into act(...):\n\nact(() => {\n /* fire events that update state */\n});\n/* assert on the output */\n\nThis ensures that you're testing the behavior the user would see in the browser. Learn more at https://reactjs.org/link/wrap-tests-with-act", getComponentName(fiber.type));
|
|
}
|
|
}
|
|
}
|
|
function warnIfNotCurrentlyActingUpdatesInDEV(fiber) {
|
|
{
|
|
if (executionContext === NoContext && IsSomeRendererActing.current === false && IsThisRendererActing.current === false) {
|
|
var previousFiber = current;
|
|
try {
|
|
setCurrentFiber(fiber);
|
|
error("An update to %s inside a test was not wrapped in act(...).\n\nWhen testing, code that causes React state updates should be wrapped into act(...):\n\nact(() => {\n /* fire events that update state */\n});\n/* assert on the output */\n\nThis ensures that you're testing the behavior the user would see in the browser. Learn more at https://reactjs.org/link/wrap-tests-with-act", getComponentName(fiber.type));
|
|
} finally {
|
|
if (previousFiber) {
|
|
setCurrentFiber(fiber);
|
|
} else {
|
|
resetCurrentFiber();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
var warnIfNotCurrentlyActingUpdatesInDev = warnIfNotCurrentlyActingUpdatesInDEV;
|
|
var didWarnAboutUnmockedScheduler = false;
|
|
function warnIfUnmockedScheduler(fiber) {
|
|
{
|
|
if (didWarnAboutUnmockedScheduler === false && Scheduler.unstable_flushAllWithoutAsserting === void 0) {
|
|
if (fiber.mode & BlockingMode || fiber.mode & ConcurrentMode) {
|
|
didWarnAboutUnmockedScheduler = true;
|
|
error(`In Concurrent or Sync modes, the "scheduler" module needs to be mocked to guarantee consistent behaviour across tests and browsers. For example, with jest:
|
|
jest.mock('scheduler', () => require('scheduler/unstable_mock'));
|
|
|
|
For more info, visit https://reactjs.org/link/mock-scheduler`);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
function computeThreadID(root2, lane) {
|
|
return lane * 1e3 + root2.interactionThreadID;
|
|
}
|
|
function markSpawnedWork(lane) {
|
|
if (spawnedWorkDuringRender === null) {
|
|
spawnedWorkDuringRender = [lane];
|
|
} else {
|
|
spawnedWorkDuringRender.push(lane);
|
|
}
|
|
}
|
|
function scheduleInteractions(root2, lane, interactions) {
|
|
if (interactions.size > 0) {
|
|
var pendingInteractionMap = root2.pendingInteractionMap;
|
|
var pendingInteractions = pendingInteractionMap.get(lane);
|
|
if (pendingInteractions != null) {
|
|
interactions.forEach(function(interaction) {
|
|
if (!pendingInteractions.has(interaction)) {
|
|
interaction.__count++;
|
|
}
|
|
pendingInteractions.add(interaction);
|
|
});
|
|
} else {
|
|
pendingInteractionMap.set(lane, new Set(interactions));
|
|
interactions.forEach(function(interaction) {
|
|
interaction.__count++;
|
|
});
|
|
}
|
|
var subscriber = tracing.__subscriberRef.current;
|
|
if (subscriber !== null) {
|
|
var threadID = computeThreadID(root2, lane);
|
|
subscriber.onWorkScheduled(interactions, threadID);
|
|
}
|
|
}
|
|
}
|
|
function schedulePendingInteractions(root2, lane) {
|
|
scheduleInteractions(root2, lane, tracing.__interactionsRef.current);
|
|
}
|
|
function startWorkOnPendingInteractions(root2, lanes) {
|
|
var interactions = new Set();
|
|
root2.pendingInteractionMap.forEach(function(scheduledInteractions, scheduledLane) {
|
|
if (includesSomeLane(lanes, scheduledLane)) {
|
|
scheduledInteractions.forEach(function(interaction) {
|
|
return interactions.add(interaction);
|
|
});
|
|
}
|
|
});
|
|
root2.memoizedInteractions = interactions;
|
|
if (interactions.size > 0) {
|
|
var subscriber = tracing.__subscriberRef.current;
|
|
if (subscriber !== null) {
|
|
var threadID = computeThreadID(root2, lanes);
|
|
try {
|
|
subscriber.onWorkStarted(interactions, threadID);
|
|
} catch (error2) {
|
|
scheduleCallback(ImmediatePriority$1, function() {
|
|
throw error2;
|
|
});
|
|
}
|
|
}
|
|
}
|
|
}
|
|
function finishPendingInteractions(root2, committedLanes) {
|
|
var remainingLanesAfterCommit = root2.pendingLanes;
|
|
var subscriber;
|
|
try {
|
|
subscriber = tracing.__subscriberRef.current;
|
|
if (subscriber !== null && root2.memoizedInteractions.size > 0) {
|
|
var threadID = computeThreadID(root2, committedLanes);
|
|
subscriber.onWorkStopped(root2.memoizedInteractions, threadID);
|
|
}
|
|
} catch (error2) {
|
|
scheduleCallback(ImmediatePriority$1, function() {
|
|
throw error2;
|
|
});
|
|
} finally {
|
|
var pendingInteractionMap = root2.pendingInteractionMap;
|
|
pendingInteractionMap.forEach(function(scheduledInteractions, lane) {
|
|
if (!includesSomeLane(remainingLanesAfterCommit, lane)) {
|
|
pendingInteractionMap.delete(lane);
|
|
scheduledInteractions.forEach(function(interaction) {
|
|
interaction.__count--;
|
|
if (subscriber !== null && interaction.__count === 0) {
|
|
try {
|
|
subscriber.onInteractionScheduledWorkCompleted(interaction);
|
|
} catch (error2) {
|
|
scheduleCallback(ImmediatePriority$1, function() {
|
|
throw error2;
|
|
});
|
|
}
|
|
}
|
|
});
|
|
}
|
|
});
|
|
}
|
|
}
|
|
function shouldForceFlushFallbacksInDEV() {
|
|
return actingUpdatesScopeDepth > 0;
|
|
}
|
|
var actingUpdatesScopeDepth = 0;
|
|
function detachFiberAfterEffects(fiber) {
|
|
fiber.sibling = null;
|
|
fiber.stateNode = null;
|
|
}
|
|
var resolveFamily = null;
|
|
var failedBoundaries = null;
|
|
var setRefreshHandler = function(handler) {
|
|
{
|
|
resolveFamily = handler;
|
|
}
|
|
};
|
|
function resolveFunctionForHotReloading(type) {
|
|
{
|
|
if (resolveFamily === null) {
|
|
return type;
|
|
}
|
|
var family = resolveFamily(type);
|
|
if (family === void 0) {
|
|
return type;
|
|
}
|
|
return family.current;
|
|
}
|
|
}
|
|
function resolveClassForHotReloading(type) {
|
|
return resolveFunctionForHotReloading(type);
|
|
}
|
|
function resolveForwardRefForHotReloading(type) {
|
|
{
|
|
if (resolveFamily === null) {
|
|
return type;
|
|
}
|
|
var family = resolveFamily(type);
|
|
if (family === void 0) {
|
|
if (type !== null && type !== void 0 && typeof type.render === "function") {
|
|
var currentRender = resolveFunctionForHotReloading(type.render);
|
|
if (type.render !== currentRender) {
|
|
var syntheticType = {
|
|
$$typeof: REACT_FORWARD_REF_TYPE,
|
|
render: currentRender
|
|
};
|
|
if (type.displayName !== void 0) {
|
|
syntheticType.displayName = type.displayName;
|
|
}
|
|
return syntheticType;
|
|
}
|
|
}
|
|
return type;
|
|
}
|
|
return family.current;
|
|
}
|
|
}
|
|
function isCompatibleFamilyForHotReloading(fiber, element) {
|
|
{
|
|
if (resolveFamily === null) {
|
|
return false;
|
|
}
|
|
var prevType = fiber.elementType;
|
|
var nextType = element.type;
|
|
var needsCompareFamilies = false;
|
|
var $$typeofNextType = typeof nextType === "object" && nextType !== null ? nextType.$$typeof : null;
|
|
switch (fiber.tag) {
|
|
case ClassComponent: {
|
|
if (typeof nextType === "function") {
|
|
needsCompareFamilies = true;
|
|
}
|
|
break;
|
|
}
|
|
case FunctionComponent: {
|
|
if (typeof nextType === "function") {
|
|
needsCompareFamilies = true;
|
|
} else if ($$typeofNextType === REACT_LAZY_TYPE) {
|
|
needsCompareFamilies = true;
|
|
}
|
|
break;
|
|
}
|
|
case ForwardRef: {
|
|
if ($$typeofNextType === REACT_FORWARD_REF_TYPE) {
|
|
needsCompareFamilies = true;
|
|
} else if ($$typeofNextType === REACT_LAZY_TYPE) {
|
|
needsCompareFamilies = true;
|
|
}
|
|
break;
|
|
}
|
|
case MemoComponent:
|
|
case SimpleMemoComponent: {
|
|
if ($$typeofNextType === REACT_MEMO_TYPE) {
|
|
needsCompareFamilies = true;
|
|
} else if ($$typeofNextType === REACT_LAZY_TYPE) {
|
|
needsCompareFamilies = true;
|
|
}
|
|
break;
|
|
}
|
|
default:
|
|
return false;
|
|
}
|
|
if (needsCompareFamilies) {
|
|
var prevFamily = resolveFamily(prevType);
|
|
if (prevFamily !== void 0 && prevFamily === resolveFamily(nextType)) {
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
}
|
|
function markFailedErrorBoundaryForHotReloading(fiber) {
|
|
{
|
|
if (resolveFamily === null) {
|
|
return;
|
|
}
|
|
if (typeof WeakSet !== "function") {
|
|
return;
|
|
}
|
|
if (failedBoundaries === null) {
|
|
failedBoundaries = new WeakSet();
|
|
}
|
|
failedBoundaries.add(fiber);
|
|
}
|
|
}
|
|
var scheduleRefresh = function(root2, update) {
|
|
{
|
|
if (resolveFamily === null) {
|
|
return;
|
|
}
|
|
var staleFamilies = update.staleFamilies, updatedFamilies = update.updatedFamilies;
|
|
flushPassiveEffects();
|
|
flushSync(function() {
|
|
scheduleFibersWithFamiliesRecursively(root2.current, updatedFamilies, staleFamilies);
|
|
});
|
|
}
|
|
};
|
|
var scheduleRoot = function(root2, element) {
|
|
{
|
|
if (root2.context !== emptyContextObject) {
|
|
return;
|
|
}
|
|
flushPassiveEffects();
|
|
flushSync(function() {
|
|
updateContainer(element, root2, null, null);
|
|
});
|
|
}
|
|
};
|
|
function scheduleFibersWithFamiliesRecursively(fiber, updatedFamilies, staleFamilies) {
|
|
{
|
|
var alternate = fiber.alternate, child = fiber.child, sibling = fiber.sibling, tag = fiber.tag, type = fiber.type;
|
|
var candidateType = null;
|
|
switch (tag) {
|
|
case FunctionComponent:
|
|
case SimpleMemoComponent:
|
|
case ClassComponent:
|
|
candidateType = type;
|
|
break;
|
|
case ForwardRef:
|
|
candidateType = type.render;
|
|
break;
|
|
}
|
|
if (resolveFamily === null) {
|
|
throw new Error("Expected resolveFamily to be set during hot reload.");
|
|
}
|
|
var needsRender = false;
|
|
var needsRemount = false;
|
|
if (candidateType !== null) {
|
|
var family = resolveFamily(candidateType);
|
|
if (family !== void 0) {
|
|
if (staleFamilies.has(family)) {
|
|
needsRemount = true;
|
|
} else if (updatedFamilies.has(family)) {
|
|
if (tag === ClassComponent) {
|
|
needsRemount = true;
|
|
} else {
|
|
needsRender = true;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (failedBoundaries !== null) {
|
|
if (failedBoundaries.has(fiber) || alternate !== null && failedBoundaries.has(alternate)) {
|
|
needsRemount = true;
|
|
}
|
|
}
|
|
if (needsRemount) {
|
|
fiber._debugNeedsRemount = true;
|
|
}
|
|
if (needsRemount || needsRender) {
|
|
scheduleUpdateOnFiber(fiber, SyncLane, NoTimestamp);
|
|
}
|
|
if (child !== null && !needsRemount) {
|
|
scheduleFibersWithFamiliesRecursively(child, updatedFamilies, staleFamilies);
|
|
}
|
|
if (sibling !== null) {
|
|
scheduleFibersWithFamiliesRecursively(sibling, updatedFamilies, staleFamilies);
|
|
}
|
|
}
|
|
}
|
|
var findHostInstancesForRefresh = function(root2, families) {
|
|
{
|
|
var hostInstances = new Set();
|
|
var types = new Set(families.map(function(family) {
|
|
return family.current;
|
|
}));
|
|
findHostInstancesForMatchingFibersRecursively(root2.current, types, hostInstances);
|
|
return hostInstances;
|
|
}
|
|
};
|
|
function findHostInstancesForMatchingFibersRecursively(fiber, types, hostInstances) {
|
|
{
|
|
var child = fiber.child, sibling = fiber.sibling, tag = fiber.tag, type = fiber.type;
|
|
var candidateType = null;
|
|
switch (tag) {
|
|
case FunctionComponent:
|
|
case SimpleMemoComponent:
|
|
case ClassComponent:
|
|
candidateType = type;
|
|
break;
|
|
case ForwardRef:
|
|
candidateType = type.render;
|
|
break;
|
|
}
|
|
var didMatch = false;
|
|
if (candidateType !== null) {
|
|
if (types.has(candidateType)) {
|
|
didMatch = true;
|
|
}
|
|
}
|
|
if (didMatch) {
|
|
findHostInstancesForFiberShallowly(fiber, hostInstances);
|
|
} else {
|
|
if (child !== null) {
|
|
findHostInstancesForMatchingFibersRecursively(child, types, hostInstances);
|
|
}
|
|
}
|
|
if (sibling !== null) {
|
|
findHostInstancesForMatchingFibersRecursively(sibling, types, hostInstances);
|
|
}
|
|
}
|
|
}
|
|
function findHostInstancesForFiberShallowly(fiber, hostInstances) {
|
|
{
|
|
var foundHostInstances = findChildHostInstancesForFiberShallowly(fiber, hostInstances);
|
|
if (foundHostInstances) {
|
|
return;
|
|
}
|
|
var node = fiber;
|
|
while (true) {
|
|
switch (node.tag) {
|
|
case HostComponent:
|
|
hostInstances.add(node.stateNode);
|
|
return;
|
|
case HostPortal:
|
|
hostInstances.add(node.stateNode.containerInfo);
|
|
return;
|
|
case HostRoot:
|
|
hostInstances.add(node.stateNode.containerInfo);
|
|
return;
|
|
}
|
|
if (node.return === null) {
|
|
throw new Error("Expected to reach root first.");
|
|
}
|
|
node = node.return;
|
|
}
|
|
}
|
|
}
|
|
function findChildHostInstancesForFiberShallowly(fiber, hostInstances) {
|
|
{
|
|
var node = fiber;
|
|
var foundHostInstances = false;
|
|
while (true) {
|
|
if (node.tag === HostComponent) {
|
|
foundHostInstances = true;
|
|
hostInstances.add(node.stateNode);
|
|
} else if (node.child !== null) {
|
|
node.child.return = node;
|
|
node = node.child;
|
|
continue;
|
|
}
|
|
if (node === fiber) {
|
|
return foundHostInstances;
|
|
}
|
|
while (node.sibling === null) {
|
|
if (node.return === null || node.return === fiber) {
|
|
return foundHostInstances;
|
|
}
|
|
node = node.return;
|
|
}
|
|
node.sibling.return = node.return;
|
|
node = node.sibling;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
var hasBadMapPolyfill;
|
|
{
|
|
hasBadMapPolyfill = false;
|
|
try {
|
|
var nonExtensibleObject = Object.preventExtensions({});
|
|
new Map([[nonExtensibleObject, null]]);
|
|
new Set([nonExtensibleObject]);
|
|
} catch (e3) {
|
|
hasBadMapPolyfill = true;
|
|
}
|
|
}
|
|
var debugCounter = 1;
|
|
function FiberNode(tag, pendingProps, key, mode) {
|
|
this.tag = tag;
|
|
this.key = key;
|
|
this.elementType = null;
|
|
this.type = null;
|
|
this.stateNode = null;
|
|
this.return = null;
|
|
this.child = null;
|
|
this.sibling = null;
|
|
this.index = 0;
|
|
this.ref = null;
|
|
this.pendingProps = pendingProps;
|
|
this.memoizedProps = null;
|
|
this.updateQueue = null;
|
|
this.memoizedState = null;
|
|
this.dependencies = null;
|
|
this.mode = mode;
|
|
this.flags = NoFlags;
|
|
this.nextEffect = null;
|
|
this.firstEffect = null;
|
|
this.lastEffect = null;
|
|
this.lanes = NoLanes;
|
|
this.childLanes = NoLanes;
|
|
this.alternate = null;
|
|
{
|
|
this.actualDuration = Number.NaN;
|
|
this.actualStartTime = Number.NaN;
|
|
this.selfBaseDuration = Number.NaN;
|
|
this.treeBaseDuration = Number.NaN;
|
|
this.actualDuration = 0;
|
|
this.actualStartTime = -1;
|
|
this.selfBaseDuration = 0;
|
|
this.treeBaseDuration = 0;
|
|
}
|
|
{
|
|
this._debugID = debugCounter++;
|
|
this._debugSource = null;
|
|
this._debugOwner = null;
|
|
this._debugNeedsRemount = false;
|
|
this._debugHookTypes = null;
|
|
if (!hasBadMapPolyfill && typeof Object.preventExtensions === "function") {
|
|
Object.preventExtensions(this);
|
|
}
|
|
}
|
|
}
|
|
var createFiber = function(tag, pendingProps, key, mode) {
|
|
return new FiberNode(tag, pendingProps, key, mode);
|
|
};
|
|
function shouldConstruct$1(Component5) {
|
|
var prototype = Component5.prototype;
|
|
return !!(prototype && prototype.isReactComponent);
|
|
}
|
|
function isSimpleFunctionComponent(type) {
|
|
return typeof type === "function" && !shouldConstruct$1(type) && type.defaultProps === void 0;
|
|
}
|
|
function resolveLazyComponentTag(Component5) {
|
|
if (typeof Component5 === "function") {
|
|
return shouldConstruct$1(Component5) ? ClassComponent : FunctionComponent;
|
|
} else if (Component5 !== void 0 && Component5 !== null) {
|
|
var $$typeof = Component5.$$typeof;
|
|
if ($$typeof === REACT_FORWARD_REF_TYPE) {
|
|
return ForwardRef;
|
|
}
|
|
if ($$typeof === REACT_MEMO_TYPE) {
|
|
return MemoComponent;
|
|
}
|
|
}
|
|
return IndeterminateComponent;
|
|
}
|
|
function createWorkInProgress(current2, pendingProps) {
|
|
var workInProgress2 = current2.alternate;
|
|
if (workInProgress2 === null) {
|
|
workInProgress2 = createFiber(current2.tag, pendingProps, current2.key, current2.mode);
|
|
workInProgress2.elementType = current2.elementType;
|
|
workInProgress2.type = current2.type;
|
|
workInProgress2.stateNode = current2.stateNode;
|
|
{
|
|
workInProgress2._debugID = current2._debugID;
|
|
workInProgress2._debugSource = current2._debugSource;
|
|
workInProgress2._debugOwner = current2._debugOwner;
|
|
workInProgress2._debugHookTypes = current2._debugHookTypes;
|
|
}
|
|
workInProgress2.alternate = current2;
|
|
current2.alternate = workInProgress2;
|
|
} else {
|
|
workInProgress2.pendingProps = pendingProps;
|
|
workInProgress2.type = current2.type;
|
|
workInProgress2.flags = NoFlags;
|
|
workInProgress2.nextEffect = null;
|
|
workInProgress2.firstEffect = null;
|
|
workInProgress2.lastEffect = null;
|
|
{
|
|
workInProgress2.actualDuration = 0;
|
|
workInProgress2.actualStartTime = -1;
|
|
}
|
|
}
|
|
workInProgress2.childLanes = current2.childLanes;
|
|
workInProgress2.lanes = current2.lanes;
|
|
workInProgress2.child = current2.child;
|
|
workInProgress2.memoizedProps = current2.memoizedProps;
|
|
workInProgress2.memoizedState = current2.memoizedState;
|
|
workInProgress2.updateQueue = current2.updateQueue;
|
|
var currentDependencies = current2.dependencies;
|
|
workInProgress2.dependencies = currentDependencies === null ? null : {
|
|
lanes: currentDependencies.lanes,
|
|
firstContext: currentDependencies.firstContext
|
|
};
|
|
workInProgress2.sibling = current2.sibling;
|
|
workInProgress2.index = current2.index;
|
|
workInProgress2.ref = current2.ref;
|
|
{
|
|
workInProgress2.selfBaseDuration = current2.selfBaseDuration;
|
|
workInProgress2.treeBaseDuration = current2.treeBaseDuration;
|
|
}
|
|
{
|
|
workInProgress2._debugNeedsRemount = current2._debugNeedsRemount;
|
|
switch (workInProgress2.tag) {
|
|
case IndeterminateComponent:
|
|
case FunctionComponent:
|
|
case SimpleMemoComponent:
|
|
workInProgress2.type = resolveFunctionForHotReloading(current2.type);
|
|
break;
|
|
case ClassComponent:
|
|
workInProgress2.type = resolveClassForHotReloading(current2.type);
|
|
break;
|
|
case ForwardRef:
|
|
workInProgress2.type = resolveForwardRefForHotReloading(current2.type);
|
|
break;
|
|
}
|
|
}
|
|
return workInProgress2;
|
|
}
|
|
function resetWorkInProgress(workInProgress2, renderLanes2) {
|
|
workInProgress2.flags &= Placement;
|
|
workInProgress2.nextEffect = null;
|
|
workInProgress2.firstEffect = null;
|
|
workInProgress2.lastEffect = null;
|
|
var current2 = workInProgress2.alternate;
|
|
if (current2 === null) {
|
|
workInProgress2.childLanes = NoLanes;
|
|
workInProgress2.lanes = renderLanes2;
|
|
workInProgress2.child = null;
|
|
workInProgress2.memoizedProps = null;
|
|
workInProgress2.memoizedState = null;
|
|
workInProgress2.updateQueue = null;
|
|
workInProgress2.dependencies = null;
|
|
workInProgress2.stateNode = null;
|
|
{
|
|
workInProgress2.selfBaseDuration = 0;
|
|
workInProgress2.treeBaseDuration = 0;
|
|
}
|
|
} else {
|
|
workInProgress2.childLanes = current2.childLanes;
|
|
workInProgress2.lanes = current2.lanes;
|
|
workInProgress2.child = current2.child;
|
|
workInProgress2.memoizedProps = current2.memoizedProps;
|
|
workInProgress2.memoizedState = current2.memoizedState;
|
|
workInProgress2.updateQueue = current2.updateQueue;
|
|
workInProgress2.type = current2.type;
|
|
var currentDependencies = current2.dependencies;
|
|
workInProgress2.dependencies = currentDependencies === null ? null : {
|
|
lanes: currentDependencies.lanes,
|
|
firstContext: currentDependencies.firstContext
|
|
};
|
|
{
|
|
workInProgress2.selfBaseDuration = current2.selfBaseDuration;
|
|
workInProgress2.treeBaseDuration = current2.treeBaseDuration;
|
|
}
|
|
}
|
|
return workInProgress2;
|
|
}
|
|
function createHostRootFiber(tag) {
|
|
var mode;
|
|
if (tag === ConcurrentRoot) {
|
|
mode = ConcurrentMode | BlockingMode | StrictMode;
|
|
} else if (tag === BlockingRoot) {
|
|
mode = BlockingMode | StrictMode;
|
|
} else {
|
|
mode = NoMode;
|
|
}
|
|
if (isDevToolsPresent) {
|
|
mode |= ProfileMode;
|
|
}
|
|
return createFiber(HostRoot, null, null, mode);
|
|
}
|
|
function createFiberFromTypeAndProps(type, key, pendingProps, owner, mode, lanes) {
|
|
var fiberTag = IndeterminateComponent;
|
|
var resolvedType = type;
|
|
if (typeof type === "function") {
|
|
if (shouldConstruct$1(type)) {
|
|
fiberTag = ClassComponent;
|
|
{
|
|
resolvedType = resolveClassForHotReloading(resolvedType);
|
|
}
|
|
} else {
|
|
{
|
|
resolvedType = resolveFunctionForHotReloading(resolvedType);
|
|
}
|
|
}
|
|
} else if (typeof type === "string") {
|
|
fiberTag = HostComponent;
|
|
} else {
|
|
getTag:
|
|
switch (type) {
|
|
case REACT_FRAGMENT_TYPE:
|
|
return createFiberFromFragment(pendingProps.children, mode, lanes, key);
|
|
case REACT_DEBUG_TRACING_MODE_TYPE:
|
|
fiberTag = Mode;
|
|
mode |= DebugTracingMode;
|
|
break;
|
|
case REACT_STRICT_MODE_TYPE:
|
|
fiberTag = Mode;
|
|
mode |= StrictMode;
|
|
break;
|
|
case REACT_PROFILER_TYPE:
|
|
return createFiberFromProfiler(pendingProps, mode, lanes, key);
|
|
case REACT_SUSPENSE_TYPE:
|
|
return createFiberFromSuspense(pendingProps, mode, lanes, key);
|
|
case REACT_SUSPENSE_LIST_TYPE:
|
|
return createFiberFromSuspenseList(pendingProps, mode, lanes, key);
|
|
case REACT_OFFSCREEN_TYPE:
|
|
return createFiberFromOffscreen(pendingProps, mode, lanes, key);
|
|
case REACT_LEGACY_HIDDEN_TYPE:
|
|
return createFiberFromLegacyHidden(pendingProps, mode, lanes, key);
|
|
case REACT_SCOPE_TYPE:
|
|
default: {
|
|
if (typeof type === "object" && type !== null) {
|
|
switch (type.$$typeof) {
|
|
case REACT_PROVIDER_TYPE:
|
|
fiberTag = ContextProvider;
|
|
break getTag;
|
|
case REACT_CONTEXT_TYPE:
|
|
fiberTag = ContextConsumer;
|
|
break getTag;
|
|
case REACT_FORWARD_REF_TYPE:
|
|
fiberTag = ForwardRef;
|
|
{
|
|
resolvedType = resolveForwardRefForHotReloading(resolvedType);
|
|
}
|
|
break getTag;
|
|
case REACT_MEMO_TYPE:
|
|
fiberTag = MemoComponent;
|
|
break getTag;
|
|
case REACT_LAZY_TYPE:
|
|
fiberTag = LazyComponent;
|
|
resolvedType = null;
|
|
break getTag;
|
|
case REACT_BLOCK_TYPE:
|
|
fiberTag = Block;
|
|
break getTag;
|
|
}
|
|
}
|
|
var info = "";
|
|
{
|
|
if (type === void 0 || typeof type === "object" && type !== null && Object.keys(type).length === 0) {
|
|
info += " You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.";
|
|
}
|
|
var ownerName = owner ? getComponentName(owner.type) : null;
|
|
if (ownerName) {
|
|
info += "\n\nCheck the render method of `" + ownerName + "`.";
|
|
}
|
|
}
|
|
{
|
|
{
|
|
throw Error("Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: " + (type == null ? type : typeof type) + "." + info);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
var fiber = createFiber(fiberTag, pendingProps, key, mode);
|
|
fiber.elementType = type;
|
|
fiber.type = resolvedType;
|
|
fiber.lanes = lanes;
|
|
{
|
|
fiber._debugOwner = owner;
|
|
}
|
|
return fiber;
|
|
}
|
|
function createFiberFromElement(element, mode, lanes) {
|
|
var owner = null;
|
|
{
|
|
owner = element._owner;
|
|
}
|
|
var type = element.type;
|
|
var key = element.key;
|
|
var pendingProps = element.props;
|
|
var fiber = createFiberFromTypeAndProps(type, key, pendingProps, owner, mode, lanes);
|
|
{
|
|
fiber._debugSource = element._source;
|
|
fiber._debugOwner = element._owner;
|
|
}
|
|
return fiber;
|
|
}
|
|
function createFiberFromFragment(elements, mode, lanes, key) {
|
|
var fiber = createFiber(Fragment3, elements, key, mode);
|
|
fiber.lanes = lanes;
|
|
return fiber;
|
|
}
|
|
function createFiberFromProfiler(pendingProps, mode, lanes, key) {
|
|
{
|
|
if (typeof pendingProps.id !== "string") {
|
|
error('Profiler must specify an "id" as a prop');
|
|
}
|
|
}
|
|
var fiber = createFiber(Profiler, pendingProps, key, mode | ProfileMode);
|
|
fiber.elementType = REACT_PROFILER_TYPE;
|
|
fiber.type = REACT_PROFILER_TYPE;
|
|
fiber.lanes = lanes;
|
|
{
|
|
fiber.stateNode = {
|
|
effectDuration: 0,
|
|
passiveEffectDuration: 0
|
|
};
|
|
}
|
|
return fiber;
|
|
}
|
|
function createFiberFromSuspense(pendingProps, mode, lanes, key) {
|
|
var fiber = createFiber(SuspenseComponent, pendingProps, key, mode);
|
|
fiber.type = REACT_SUSPENSE_TYPE;
|
|
fiber.elementType = REACT_SUSPENSE_TYPE;
|
|
fiber.lanes = lanes;
|
|
return fiber;
|
|
}
|
|
function createFiberFromSuspenseList(pendingProps, mode, lanes, key) {
|
|
var fiber = createFiber(SuspenseListComponent, pendingProps, key, mode);
|
|
{
|
|
fiber.type = REACT_SUSPENSE_LIST_TYPE;
|
|
}
|
|
fiber.elementType = REACT_SUSPENSE_LIST_TYPE;
|
|
fiber.lanes = lanes;
|
|
return fiber;
|
|
}
|
|
function createFiberFromOffscreen(pendingProps, mode, lanes, key) {
|
|
var fiber = createFiber(OffscreenComponent, pendingProps, key, mode);
|
|
{
|
|
fiber.type = REACT_OFFSCREEN_TYPE;
|
|
}
|
|
fiber.elementType = REACT_OFFSCREEN_TYPE;
|
|
fiber.lanes = lanes;
|
|
return fiber;
|
|
}
|
|
function createFiberFromLegacyHidden(pendingProps, mode, lanes, key) {
|
|
var fiber = createFiber(LegacyHiddenComponent, pendingProps, key, mode);
|
|
{
|
|
fiber.type = REACT_LEGACY_HIDDEN_TYPE;
|
|
}
|
|
fiber.elementType = REACT_LEGACY_HIDDEN_TYPE;
|
|
fiber.lanes = lanes;
|
|
return fiber;
|
|
}
|
|
function createFiberFromText(content, mode, lanes) {
|
|
var fiber = createFiber(HostText, content, null, mode);
|
|
fiber.lanes = lanes;
|
|
return fiber;
|
|
}
|
|
function createFiberFromHostInstanceForDeletion() {
|
|
var fiber = createFiber(HostComponent, null, null, NoMode);
|
|
fiber.elementType = "DELETED";
|
|
fiber.type = "DELETED";
|
|
return fiber;
|
|
}
|
|
function createFiberFromPortal(portal, mode, lanes) {
|
|
var pendingProps = portal.children !== null ? portal.children : [];
|
|
var fiber = createFiber(HostPortal, pendingProps, portal.key, mode);
|
|
fiber.lanes = lanes;
|
|
fiber.stateNode = {
|
|
containerInfo: portal.containerInfo,
|
|
pendingChildren: null,
|
|
implementation: portal.implementation
|
|
};
|
|
return fiber;
|
|
}
|
|
function assignFiberPropertiesInDEV(target, source) {
|
|
if (target === null) {
|
|
target = createFiber(IndeterminateComponent, null, null, NoMode);
|
|
}
|
|
target.tag = source.tag;
|
|
target.key = source.key;
|
|
target.elementType = source.elementType;
|
|
target.type = source.type;
|
|
target.stateNode = source.stateNode;
|
|
target.return = source.return;
|
|
target.child = source.child;
|
|
target.sibling = source.sibling;
|
|
target.index = source.index;
|
|
target.ref = source.ref;
|
|
target.pendingProps = source.pendingProps;
|
|
target.memoizedProps = source.memoizedProps;
|
|
target.updateQueue = source.updateQueue;
|
|
target.memoizedState = source.memoizedState;
|
|
target.dependencies = source.dependencies;
|
|
target.mode = source.mode;
|
|
target.flags = source.flags;
|
|
target.nextEffect = source.nextEffect;
|
|
target.firstEffect = source.firstEffect;
|
|
target.lastEffect = source.lastEffect;
|
|
target.lanes = source.lanes;
|
|
target.childLanes = source.childLanes;
|
|
target.alternate = source.alternate;
|
|
{
|
|
target.actualDuration = source.actualDuration;
|
|
target.actualStartTime = source.actualStartTime;
|
|
target.selfBaseDuration = source.selfBaseDuration;
|
|
target.treeBaseDuration = source.treeBaseDuration;
|
|
}
|
|
target._debugID = source._debugID;
|
|
target._debugSource = source._debugSource;
|
|
target._debugOwner = source._debugOwner;
|
|
target._debugNeedsRemount = source._debugNeedsRemount;
|
|
target._debugHookTypes = source._debugHookTypes;
|
|
return target;
|
|
}
|
|
function FiberRootNode(containerInfo, tag, hydrate2) {
|
|
this.tag = tag;
|
|
this.containerInfo = containerInfo;
|
|
this.pendingChildren = null;
|
|
this.current = null;
|
|
this.pingCache = null;
|
|
this.finishedWork = null;
|
|
this.timeoutHandle = noTimeout;
|
|
this.context = null;
|
|
this.pendingContext = null;
|
|
this.hydrate = hydrate2;
|
|
this.callbackNode = null;
|
|
this.callbackPriority = NoLanePriority;
|
|
this.eventTimes = createLaneMap(NoLanes);
|
|
this.expirationTimes = createLaneMap(NoTimestamp);
|
|
this.pendingLanes = NoLanes;
|
|
this.suspendedLanes = NoLanes;
|
|
this.pingedLanes = NoLanes;
|
|
this.expiredLanes = NoLanes;
|
|
this.mutableReadLanes = NoLanes;
|
|
this.finishedLanes = NoLanes;
|
|
this.entangledLanes = NoLanes;
|
|
this.entanglements = createLaneMap(NoLanes);
|
|
{
|
|
this.mutableSourceEagerHydrationData = null;
|
|
}
|
|
{
|
|
this.interactionThreadID = tracing.unstable_getThreadID();
|
|
this.memoizedInteractions = new Set();
|
|
this.pendingInteractionMap = new Map();
|
|
}
|
|
{
|
|
switch (tag) {
|
|
case BlockingRoot:
|
|
this._debugRootType = "createBlockingRoot()";
|
|
break;
|
|
case ConcurrentRoot:
|
|
this._debugRootType = "createRoot()";
|
|
break;
|
|
case LegacyRoot:
|
|
this._debugRootType = "createLegacyRoot()";
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
function createFiberRoot(containerInfo, tag, hydrate2, hydrationCallbacks) {
|
|
var root2 = new FiberRootNode(containerInfo, tag, hydrate2);
|
|
var uninitializedFiber = createHostRootFiber(tag);
|
|
root2.current = uninitializedFiber;
|
|
uninitializedFiber.stateNode = root2;
|
|
initializeUpdateQueue(uninitializedFiber);
|
|
return root2;
|
|
}
|
|
function registerMutableSourceForHydration(root2, mutableSource) {
|
|
var getVersion = mutableSource._getVersion;
|
|
var version = getVersion(mutableSource._source);
|
|
if (root2.mutableSourceEagerHydrationData == null) {
|
|
root2.mutableSourceEagerHydrationData = [mutableSource, version];
|
|
} else {
|
|
root2.mutableSourceEagerHydrationData.push(mutableSource, version);
|
|
}
|
|
}
|
|
function createPortal2(children, containerInfo, implementation) {
|
|
var key = arguments.length > 3 && arguments[3] !== void 0 ? arguments[3] : null;
|
|
return {
|
|
$$typeof: REACT_PORTAL_TYPE,
|
|
key: key == null ? null : "" + key,
|
|
children,
|
|
containerInfo,
|
|
implementation
|
|
};
|
|
}
|
|
var didWarnAboutNestedUpdates;
|
|
var didWarnAboutFindNodeInStrictMode;
|
|
{
|
|
didWarnAboutNestedUpdates = false;
|
|
didWarnAboutFindNodeInStrictMode = {};
|
|
}
|
|
function getContextForSubtree(parentComponent) {
|
|
if (!parentComponent) {
|
|
return emptyContextObject;
|
|
}
|
|
var fiber = get(parentComponent);
|
|
var parentContext = findCurrentUnmaskedContext(fiber);
|
|
if (fiber.tag === ClassComponent) {
|
|
var Component5 = fiber.type;
|
|
if (isContextProvider(Component5)) {
|
|
return processChildContext(fiber, Component5, parentContext);
|
|
}
|
|
}
|
|
return parentContext;
|
|
}
|
|
function findHostInstanceWithWarning(component, methodName) {
|
|
{
|
|
var fiber = get(component);
|
|
if (fiber === void 0) {
|
|
if (typeof component.render === "function") {
|
|
{
|
|
{
|
|
throw Error("Unable to find node on an unmounted component.");
|
|
}
|
|
}
|
|
} else {
|
|
{
|
|
{
|
|
throw Error("Argument appears to not be a ReactComponent. Keys: " + Object.keys(component));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
var hostFiber = findCurrentHostFiber(fiber);
|
|
if (hostFiber === null) {
|
|
return null;
|
|
}
|
|
if (hostFiber.mode & StrictMode) {
|
|
var componentName = getComponentName(fiber.type) || "Component";
|
|
if (!didWarnAboutFindNodeInStrictMode[componentName]) {
|
|
didWarnAboutFindNodeInStrictMode[componentName] = true;
|
|
var previousFiber = current;
|
|
try {
|
|
setCurrentFiber(hostFiber);
|
|
if (fiber.mode & StrictMode) {
|
|
error("%s is deprecated in StrictMode. %s was passed an instance of %s which is inside StrictMode. Instead, add a ref directly to the element you want to reference. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-find-node", methodName, methodName, componentName);
|
|
} else {
|
|
error("%s is deprecated in StrictMode. %s was passed an instance of %s which renders StrictMode children. Instead, add a ref directly to the element you want to reference. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-find-node", methodName, methodName, componentName);
|
|
}
|
|
} finally {
|
|
if (previousFiber) {
|
|
setCurrentFiber(previousFiber);
|
|
} else {
|
|
resetCurrentFiber();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return hostFiber.stateNode;
|
|
}
|
|
}
|
|
function createContainer(containerInfo, tag, hydrate2, hydrationCallbacks) {
|
|
return createFiberRoot(containerInfo, tag, hydrate2);
|
|
}
|
|
function updateContainer(element, container, parentComponent, callback) {
|
|
{
|
|
onScheduleRoot(container, element);
|
|
}
|
|
var current$1 = container.current;
|
|
var eventTime = requestEventTime();
|
|
{
|
|
if (typeof jest !== "undefined") {
|
|
warnIfUnmockedScheduler(current$1);
|
|
warnIfNotScopedWithMatchingAct(current$1);
|
|
}
|
|
}
|
|
var lane = requestUpdateLane(current$1);
|
|
var context = getContextForSubtree(parentComponent);
|
|
if (container.context === null) {
|
|
container.context = context;
|
|
} else {
|
|
container.pendingContext = context;
|
|
}
|
|
{
|
|
if (isRendering && current !== null && !didWarnAboutNestedUpdates) {
|
|
didWarnAboutNestedUpdates = true;
|
|
error("Render methods should be a pure function of props and state; triggering nested component updates from render is not allowed. If necessary, trigger nested updates in componentDidUpdate.\n\nCheck the render method of %s.", getComponentName(current.type) || "Unknown");
|
|
}
|
|
}
|
|
var update = createUpdate(eventTime, lane);
|
|
update.payload = {
|
|
element
|
|
};
|
|
callback = callback === void 0 ? null : callback;
|
|
if (callback !== null) {
|
|
{
|
|
if (typeof callback !== "function") {
|
|
error("render(...): Expected the last optional `callback` argument to be a function. Instead received: %s.", callback);
|
|
}
|
|
}
|
|
update.callback = callback;
|
|
}
|
|
enqueueUpdate(current$1, update);
|
|
scheduleUpdateOnFiber(current$1, lane, eventTime);
|
|
return lane;
|
|
}
|
|
function getPublicRootInstance(container) {
|
|
var containerFiber = container.current;
|
|
if (!containerFiber.child) {
|
|
return null;
|
|
}
|
|
switch (containerFiber.child.tag) {
|
|
case HostComponent:
|
|
return getPublicInstance(containerFiber.child.stateNode);
|
|
default:
|
|
return containerFiber.child.stateNode;
|
|
}
|
|
}
|
|
function markRetryLaneImpl(fiber, retryLane) {
|
|
var suspenseState = fiber.memoizedState;
|
|
if (suspenseState !== null && suspenseState.dehydrated !== null) {
|
|
suspenseState.retryLane = higherPriorityLane(suspenseState.retryLane, retryLane);
|
|
}
|
|
}
|
|
function markRetryLaneIfNotHydrated(fiber, retryLane) {
|
|
markRetryLaneImpl(fiber, retryLane);
|
|
var alternate = fiber.alternate;
|
|
if (alternate) {
|
|
markRetryLaneImpl(alternate, retryLane);
|
|
}
|
|
}
|
|
function attemptUserBlockingHydration$1(fiber) {
|
|
if (fiber.tag !== SuspenseComponent) {
|
|
return;
|
|
}
|
|
var eventTime = requestEventTime();
|
|
var lane = InputDiscreteHydrationLane;
|
|
scheduleUpdateOnFiber(fiber, lane, eventTime);
|
|
markRetryLaneIfNotHydrated(fiber, lane);
|
|
}
|
|
function attemptContinuousHydration$1(fiber) {
|
|
if (fiber.tag !== SuspenseComponent) {
|
|
return;
|
|
}
|
|
var eventTime = requestEventTime();
|
|
var lane = SelectiveHydrationLane;
|
|
scheduleUpdateOnFiber(fiber, lane, eventTime);
|
|
markRetryLaneIfNotHydrated(fiber, lane);
|
|
}
|
|
function attemptHydrationAtCurrentPriority$1(fiber) {
|
|
if (fiber.tag !== SuspenseComponent) {
|
|
return;
|
|
}
|
|
var eventTime = requestEventTime();
|
|
var lane = requestUpdateLane(fiber);
|
|
scheduleUpdateOnFiber(fiber, lane, eventTime);
|
|
markRetryLaneIfNotHydrated(fiber, lane);
|
|
}
|
|
function runWithPriority$2(priority, fn) {
|
|
try {
|
|
setCurrentUpdateLanePriority(priority);
|
|
return fn();
|
|
} finally {
|
|
}
|
|
}
|
|
function findHostInstanceWithNoPortals(fiber) {
|
|
var hostFiber = findCurrentHostFiberWithNoPortals(fiber);
|
|
if (hostFiber === null) {
|
|
return null;
|
|
}
|
|
if (hostFiber.tag === FundamentalComponent) {
|
|
return hostFiber.stateNode.instance;
|
|
}
|
|
return hostFiber.stateNode;
|
|
}
|
|
var shouldSuspendImpl = function(fiber) {
|
|
return false;
|
|
};
|
|
function shouldSuspend(fiber) {
|
|
return shouldSuspendImpl(fiber);
|
|
}
|
|
var overrideHookState = null;
|
|
var overrideHookStateDeletePath = null;
|
|
var overrideHookStateRenamePath = null;
|
|
var overrideProps = null;
|
|
var overridePropsDeletePath = null;
|
|
var overridePropsRenamePath = null;
|
|
var scheduleUpdate = null;
|
|
var setSuspenseHandler = null;
|
|
{
|
|
var copyWithDeleteImpl = function(obj, path, index2) {
|
|
var key = path[index2];
|
|
var updated = Array.isArray(obj) ? obj.slice() : _assign({}, obj);
|
|
if (index2 + 1 === path.length) {
|
|
if (Array.isArray(updated)) {
|
|
updated.splice(key, 1);
|
|
} else {
|
|
delete updated[key];
|
|
}
|
|
return updated;
|
|
}
|
|
updated[key] = copyWithDeleteImpl(obj[key], path, index2 + 1);
|
|
return updated;
|
|
};
|
|
var copyWithDelete = function(obj, path) {
|
|
return copyWithDeleteImpl(obj, path, 0);
|
|
};
|
|
var copyWithRenameImpl = function(obj, oldPath, newPath, index2) {
|
|
var oldKey = oldPath[index2];
|
|
var updated = Array.isArray(obj) ? obj.slice() : _assign({}, obj);
|
|
if (index2 + 1 === oldPath.length) {
|
|
var newKey = newPath[index2];
|
|
updated[newKey] = updated[oldKey];
|
|
if (Array.isArray(updated)) {
|
|
updated.splice(oldKey, 1);
|
|
} else {
|
|
delete updated[oldKey];
|
|
}
|
|
} else {
|
|
updated[oldKey] = copyWithRenameImpl(obj[oldKey], oldPath, newPath, index2 + 1);
|
|
}
|
|
return updated;
|
|
};
|
|
var copyWithRename = function(obj, oldPath, newPath) {
|
|
if (oldPath.length !== newPath.length) {
|
|
warn("copyWithRename() expects paths of the same length");
|
|
return;
|
|
} else {
|
|
for (var i3 = 0; i3 < newPath.length - 1; i3++) {
|
|
if (oldPath[i3] !== newPath[i3]) {
|
|
warn("copyWithRename() expects paths to be the same except for the deepest key");
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
return copyWithRenameImpl(obj, oldPath, newPath, 0);
|
|
};
|
|
var copyWithSetImpl = function(obj, path, index2, value) {
|
|
if (index2 >= path.length) {
|
|
return value;
|
|
}
|
|
var key = path[index2];
|
|
var updated = Array.isArray(obj) ? obj.slice() : _assign({}, obj);
|
|
updated[key] = copyWithSetImpl(obj[key], path, index2 + 1, value);
|
|
return updated;
|
|
};
|
|
var copyWithSet = function(obj, path, value) {
|
|
return copyWithSetImpl(obj, path, 0, value);
|
|
};
|
|
var findHook = function(fiber, id) {
|
|
var currentHook2 = fiber.memoizedState;
|
|
while (currentHook2 !== null && id > 0) {
|
|
currentHook2 = currentHook2.next;
|
|
id--;
|
|
}
|
|
return currentHook2;
|
|
};
|
|
overrideHookState = function(fiber, id, path, value) {
|
|
var hook = findHook(fiber, id);
|
|
if (hook !== null) {
|
|
var newState = copyWithSet(hook.memoizedState, path, value);
|
|
hook.memoizedState = newState;
|
|
hook.baseState = newState;
|
|
fiber.memoizedProps = _assign({}, fiber.memoizedProps);
|
|
scheduleUpdateOnFiber(fiber, SyncLane, NoTimestamp);
|
|
}
|
|
};
|
|
overrideHookStateDeletePath = function(fiber, id, path) {
|
|
var hook = findHook(fiber, id);
|
|
if (hook !== null) {
|
|
var newState = copyWithDelete(hook.memoizedState, path);
|
|
hook.memoizedState = newState;
|
|
hook.baseState = newState;
|
|
fiber.memoizedProps = _assign({}, fiber.memoizedProps);
|
|
scheduleUpdateOnFiber(fiber, SyncLane, NoTimestamp);
|
|
}
|
|
};
|
|
overrideHookStateRenamePath = function(fiber, id, oldPath, newPath) {
|
|
var hook = findHook(fiber, id);
|
|
if (hook !== null) {
|
|
var newState = copyWithRename(hook.memoizedState, oldPath, newPath);
|
|
hook.memoizedState = newState;
|
|
hook.baseState = newState;
|
|
fiber.memoizedProps = _assign({}, fiber.memoizedProps);
|
|
scheduleUpdateOnFiber(fiber, SyncLane, NoTimestamp);
|
|
}
|
|
};
|
|
overrideProps = function(fiber, path, value) {
|
|
fiber.pendingProps = copyWithSet(fiber.memoizedProps, path, value);
|
|
if (fiber.alternate) {
|
|
fiber.alternate.pendingProps = fiber.pendingProps;
|
|
}
|
|
scheduleUpdateOnFiber(fiber, SyncLane, NoTimestamp);
|
|
};
|
|
overridePropsDeletePath = function(fiber, path) {
|
|
fiber.pendingProps = copyWithDelete(fiber.memoizedProps, path);
|
|
if (fiber.alternate) {
|
|
fiber.alternate.pendingProps = fiber.pendingProps;
|
|
}
|
|
scheduleUpdateOnFiber(fiber, SyncLane, NoTimestamp);
|
|
};
|
|
overridePropsRenamePath = function(fiber, oldPath, newPath) {
|
|
fiber.pendingProps = copyWithRename(fiber.memoizedProps, oldPath, newPath);
|
|
if (fiber.alternate) {
|
|
fiber.alternate.pendingProps = fiber.pendingProps;
|
|
}
|
|
scheduleUpdateOnFiber(fiber, SyncLane, NoTimestamp);
|
|
};
|
|
scheduleUpdate = function(fiber) {
|
|
scheduleUpdateOnFiber(fiber, SyncLane, NoTimestamp);
|
|
};
|
|
setSuspenseHandler = function(newShouldSuspendImpl) {
|
|
shouldSuspendImpl = newShouldSuspendImpl;
|
|
};
|
|
}
|
|
function findHostInstanceByFiber(fiber) {
|
|
var hostFiber = findCurrentHostFiber(fiber);
|
|
if (hostFiber === null) {
|
|
return null;
|
|
}
|
|
return hostFiber.stateNode;
|
|
}
|
|
function emptyFindFiberByHostInstance(instance) {
|
|
return null;
|
|
}
|
|
function getCurrentFiberForDevTools() {
|
|
return current;
|
|
}
|
|
function injectIntoDevTools(devToolsConfig) {
|
|
var findFiberByHostInstance = devToolsConfig.findFiberByHostInstance;
|
|
var ReactCurrentDispatcher2 = ReactSharedInternals.ReactCurrentDispatcher;
|
|
return injectInternals({
|
|
bundleType: devToolsConfig.bundleType,
|
|
version: devToolsConfig.version,
|
|
rendererPackageName: devToolsConfig.rendererPackageName,
|
|
rendererConfig: devToolsConfig.rendererConfig,
|
|
overrideHookState,
|
|
overrideHookStateDeletePath,
|
|
overrideHookStateRenamePath,
|
|
overrideProps,
|
|
overridePropsDeletePath,
|
|
overridePropsRenamePath,
|
|
setSuspenseHandler,
|
|
scheduleUpdate,
|
|
currentDispatcherRef: ReactCurrentDispatcher2,
|
|
findHostInstanceByFiber,
|
|
findFiberByHostInstance: findFiberByHostInstance || emptyFindFiberByHostInstance,
|
|
findHostInstancesForRefresh,
|
|
scheduleRefresh,
|
|
scheduleRoot,
|
|
setRefreshHandler,
|
|
getCurrentFiber: getCurrentFiberForDevTools
|
|
});
|
|
}
|
|
function ReactDOMRoot(container, options2) {
|
|
this._internalRoot = createRootImpl(container, ConcurrentRoot, options2);
|
|
}
|
|
function ReactDOMBlockingRoot(container, tag, options2) {
|
|
this._internalRoot = createRootImpl(container, tag, options2);
|
|
}
|
|
ReactDOMRoot.prototype.render = ReactDOMBlockingRoot.prototype.render = function(children) {
|
|
var root2 = this._internalRoot;
|
|
{
|
|
if (typeof arguments[1] === "function") {
|
|
error("render(...): does not support the second callback argument. To execute a side effect after rendering, declare it in a component body with useEffect().");
|
|
}
|
|
var container = root2.containerInfo;
|
|
if (container.nodeType !== COMMENT_NODE) {
|
|
var hostInstance = findHostInstanceWithNoPortals(root2.current);
|
|
if (hostInstance) {
|
|
if (hostInstance.parentNode !== container) {
|
|
error("render(...): It looks like the React-rendered content of the root container was removed without using React. This is not supported and will cause errors. Instead, call root.unmount() to empty a root's container.");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
updateContainer(children, root2, null, null);
|
|
};
|
|
ReactDOMRoot.prototype.unmount = ReactDOMBlockingRoot.prototype.unmount = function() {
|
|
{
|
|
if (typeof arguments[0] === "function") {
|
|
error("unmount(...): does not support a callback argument. To execute a side effect after rendering, declare it in a component body with useEffect().");
|
|
}
|
|
}
|
|
var root2 = this._internalRoot;
|
|
var container = root2.containerInfo;
|
|
updateContainer(null, root2, null, function() {
|
|
unmarkContainerAsRoot(container);
|
|
});
|
|
};
|
|
function createRootImpl(container, tag, options2) {
|
|
var hydrate2 = options2 != null && options2.hydrate === true;
|
|
var hydrationCallbacks = options2 != null && options2.hydrationOptions || null;
|
|
var mutableSources = options2 != null && options2.hydrationOptions != null && options2.hydrationOptions.mutableSources || null;
|
|
var root2 = createContainer(container, tag, hydrate2);
|
|
markContainerAsRoot(root2.current, container);
|
|
var containerNodeType = container.nodeType;
|
|
{
|
|
var rootContainerElement = container.nodeType === COMMENT_NODE ? container.parentNode : container;
|
|
listenToAllSupportedEvents(rootContainerElement);
|
|
}
|
|
if (mutableSources) {
|
|
for (var i3 = 0; i3 < mutableSources.length; i3++) {
|
|
var mutableSource = mutableSources[i3];
|
|
registerMutableSourceForHydration(root2, mutableSource);
|
|
}
|
|
}
|
|
return root2;
|
|
}
|
|
function createLegacyRoot(container, options2) {
|
|
return new ReactDOMBlockingRoot(container, LegacyRoot, options2);
|
|
}
|
|
function isValidContainer(node) {
|
|
return !!(node && (node.nodeType === ELEMENT_NODE || node.nodeType === DOCUMENT_NODE || node.nodeType === DOCUMENT_FRAGMENT_NODE || node.nodeType === COMMENT_NODE && node.nodeValue === " react-mount-point-unstable "));
|
|
}
|
|
var ReactCurrentOwner$3 = ReactSharedInternals.ReactCurrentOwner;
|
|
var topLevelUpdateWarnings;
|
|
var warnedAboutHydrateAPI = false;
|
|
{
|
|
topLevelUpdateWarnings = function(container) {
|
|
if (container._reactRootContainer && container.nodeType !== COMMENT_NODE) {
|
|
var hostInstance = findHostInstanceWithNoPortals(container._reactRootContainer._internalRoot.current);
|
|
if (hostInstance) {
|
|
if (hostInstance.parentNode !== container) {
|
|
error("render(...): It looks like the React-rendered content of this container was removed without using React. This is not supported and will cause errors. Instead, call ReactDOM.unmountComponentAtNode to empty a container.");
|
|
}
|
|
}
|
|
}
|
|
var isRootRenderedBySomeReact = !!container._reactRootContainer;
|
|
var rootEl = getReactRootElementInContainer(container);
|
|
var hasNonRootReactChild = !!(rootEl && getInstanceFromNode(rootEl));
|
|
if (hasNonRootReactChild && !isRootRenderedBySomeReact) {
|
|
error("render(...): Replacing React-rendered children with a new root component. If you intended to update the children of this node, you should instead have the existing children update their state and render the new components instead of calling ReactDOM.render.");
|
|
}
|
|
if (container.nodeType === ELEMENT_NODE && container.tagName && container.tagName.toUpperCase() === "BODY") {
|
|
error("render(): Rendering components directly into document.body is discouraged, since its children are often manipulated by third-party scripts and browser extensions. This may lead to subtle reconciliation issues. Try rendering into a container element created for your app.");
|
|
}
|
|
};
|
|
}
|
|
function getReactRootElementInContainer(container) {
|
|
if (!container) {
|
|
return null;
|
|
}
|
|
if (container.nodeType === DOCUMENT_NODE) {
|
|
return container.documentElement;
|
|
} else {
|
|
return container.firstChild;
|
|
}
|
|
}
|
|
function shouldHydrateDueToLegacyHeuristic(container) {
|
|
var rootElement = getReactRootElementInContainer(container);
|
|
return !!(rootElement && rootElement.nodeType === ELEMENT_NODE && rootElement.hasAttribute(ROOT_ATTRIBUTE_NAME));
|
|
}
|
|
function legacyCreateRootFromDOMContainer(container, forceHydrate) {
|
|
var shouldHydrate = forceHydrate || shouldHydrateDueToLegacyHeuristic(container);
|
|
if (!shouldHydrate) {
|
|
var warned = false;
|
|
var rootSibling;
|
|
while (rootSibling = container.lastChild) {
|
|
{
|
|
if (!warned && rootSibling.nodeType === ELEMENT_NODE && rootSibling.hasAttribute(ROOT_ATTRIBUTE_NAME)) {
|
|
warned = true;
|
|
error("render(): Target node has markup rendered by React, but there are unrelated nodes as well. This is most commonly caused by white-space inserted around server-rendered markup.");
|
|
}
|
|
}
|
|
container.removeChild(rootSibling);
|
|
}
|
|
}
|
|
{
|
|
if (shouldHydrate && !forceHydrate && !warnedAboutHydrateAPI) {
|
|
warnedAboutHydrateAPI = true;
|
|
warn("render(): Calling ReactDOM.render() to hydrate server-rendered markup will stop working in React v18. Replace the ReactDOM.render() call with ReactDOM.hydrate() if you want React to attach to the server HTML.");
|
|
}
|
|
}
|
|
return createLegacyRoot(container, shouldHydrate ? {
|
|
hydrate: true
|
|
} : void 0);
|
|
}
|
|
function warnOnInvalidCallback$1(callback, callerName) {
|
|
{
|
|
if (callback !== null && typeof callback !== "function") {
|
|
error("%s(...): Expected the last optional `callback` argument to be a function. Instead received: %s.", callerName, callback);
|
|
}
|
|
}
|
|
}
|
|
function legacyRenderSubtreeIntoContainer(parentComponent, children, container, forceHydrate, callback) {
|
|
{
|
|
topLevelUpdateWarnings(container);
|
|
warnOnInvalidCallback$1(callback === void 0 ? null : callback, "render");
|
|
}
|
|
var root2 = container._reactRootContainer;
|
|
var fiberRoot;
|
|
if (!root2) {
|
|
root2 = container._reactRootContainer = legacyCreateRootFromDOMContainer(container, forceHydrate);
|
|
fiberRoot = root2._internalRoot;
|
|
if (typeof callback === "function") {
|
|
var originalCallback = callback;
|
|
callback = function() {
|
|
var instance = getPublicRootInstance(fiberRoot);
|
|
originalCallback.call(instance);
|
|
};
|
|
}
|
|
unbatchedUpdates(function() {
|
|
updateContainer(children, fiberRoot, parentComponent, callback);
|
|
});
|
|
} else {
|
|
fiberRoot = root2._internalRoot;
|
|
if (typeof callback === "function") {
|
|
var _originalCallback = callback;
|
|
callback = function() {
|
|
var instance = getPublicRootInstance(fiberRoot);
|
|
_originalCallback.call(instance);
|
|
};
|
|
}
|
|
updateContainer(children, fiberRoot, parentComponent, callback);
|
|
}
|
|
return getPublicRootInstance(fiberRoot);
|
|
}
|
|
function findDOMNode(componentOrElement) {
|
|
{
|
|
var owner = ReactCurrentOwner$3.current;
|
|
if (owner !== null && owner.stateNode !== null) {
|
|
var warnedAboutRefsInRender = owner.stateNode._warnedAboutRefsInRender;
|
|
if (!warnedAboutRefsInRender) {
|
|
error("%s is accessing findDOMNode inside its render(). render() should be a pure function of props and state. It should never access something that requires stale data from the previous render, such as refs. Move this logic to componentDidMount and componentDidUpdate instead.", getComponentName(owner.type) || "A component");
|
|
}
|
|
owner.stateNode._warnedAboutRefsInRender = true;
|
|
}
|
|
}
|
|
if (componentOrElement == null) {
|
|
return null;
|
|
}
|
|
if (componentOrElement.nodeType === ELEMENT_NODE) {
|
|
return componentOrElement;
|
|
}
|
|
{
|
|
return findHostInstanceWithWarning(componentOrElement, "findDOMNode");
|
|
}
|
|
}
|
|
function hydrate(element, container, callback) {
|
|
if (!isValidContainer(container)) {
|
|
{
|
|
throw Error("Target container is not a DOM element.");
|
|
}
|
|
}
|
|
{
|
|
var isModernRoot = isContainerMarkedAsRoot(container) && container._reactRootContainer === void 0;
|
|
if (isModernRoot) {
|
|
error("You are calling ReactDOM.hydrate() on a container that was previously passed to ReactDOM.createRoot(). This is not supported. Did you mean to call createRoot(container, {hydrate: true}).render(element)?");
|
|
}
|
|
}
|
|
return legacyRenderSubtreeIntoContainer(null, element, container, true, callback);
|
|
}
|
|
function render4(element, container, callback) {
|
|
if (!isValidContainer(container)) {
|
|
{
|
|
throw Error("Target container is not a DOM element.");
|
|
}
|
|
}
|
|
{
|
|
var isModernRoot = isContainerMarkedAsRoot(container) && container._reactRootContainer === void 0;
|
|
if (isModernRoot) {
|
|
error("You are calling ReactDOM.render() on a container that was previously passed to ReactDOM.createRoot(). This is not supported. Did you mean to call root.render(element)?");
|
|
}
|
|
}
|
|
return legacyRenderSubtreeIntoContainer(null, element, container, false, callback);
|
|
}
|
|
function unstable_renderSubtreeIntoContainer(parentComponent, element, containerNode, callback) {
|
|
if (!isValidContainer(containerNode)) {
|
|
{
|
|
throw Error("Target container is not a DOM element.");
|
|
}
|
|
}
|
|
if (!(parentComponent != null && has(parentComponent))) {
|
|
{
|
|
throw Error("parentComponent must be a valid React Component");
|
|
}
|
|
}
|
|
return legacyRenderSubtreeIntoContainer(parentComponent, element, containerNode, false, callback);
|
|
}
|
|
function unmountComponentAtNode4(container) {
|
|
if (!isValidContainer(container)) {
|
|
{
|
|
throw Error("unmountComponentAtNode(...): Target container is not a DOM element.");
|
|
}
|
|
}
|
|
{
|
|
var isModernRoot = isContainerMarkedAsRoot(container) && container._reactRootContainer === void 0;
|
|
if (isModernRoot) {
|
|
error("You are calling ReactDOM.unmountComponentAtNode() on a container that was previously passed to ReactDOM.createRoot(). This is not supported. Did you mean to call root.unmount()?");
|
|
}
|
|
}
|
|
if (container._reactRootContainer) {
|
|
{
|
|
var rootEl = getReactRootElementInContainer(container);
|
|
var renderedByDifferentReact = rootEl && !getInstanceFromNode(rootEl);
|
|
if (renderedByDifferentReact) {
|
|
error("unmountComponentAtNode(): The node you're attempting to unmount was rendered by another copy of React.");
|
|
}
|
|
}
|
|
unbatchedUpdates(function() {
|
|
legacyRenderSubtreeIntoContainer(null, null, container, false, function() {
|
|
container._reactRootContainer = null;
|
|
unmarkContainerAsRoot(container);
|
|
});
|
|
});
|
|
return true;
|
|
} else {
|
|
{
|
|
var _rootEl = getReactRootElementInContainer(container);
|
|
var hasNonRootReactChild = !!(_rootEl && getInstanceFromNode(_rootEl));
|
|
var isContainerReactRoot = container.nodeType === ELEMENT_NODE && isValidContainer(container.parentNode) && !!container.parentNode._reactRootContainer;
|
|
if (hasNonRootReactChild) {
|
|
error("unmountComponentAtNode(): The node you're attempting to unmount was rendered by React and is not a top-level container. %s", isContainerReactRoot ? "You may have accidentally passed in a React root node instead of its container." : "Instead, have the parent component update its state and rerender in order to remove this component.");
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
}
|
|
setAttemptUserBlockingHydration(attemptUserBlockingHydration$1);
|
|
setAttemptContinuousHydration(attemptContinuousHydration$1);
|
|
setAttemptHydrationAtCurrentPriority(attemptHydrationAtCurrentPriority$1);
|
|
setAttemptHydrationAtPriority(runWithPriority$2);
|
|
var didWarnAboutUnstableCreatePortal = false;
|
|
{
|
|
if (typeof Map !== "function" || Map.prototype == null || typeof Map.prototype.forEach !== "function" || typeof Set !== "function" || Set.prototype == null || typeof Set.prototype.clear !== "function" || typeof Set.prototype.forEach !== "function") {
|
|
error("React depends on Map and Set built-in types. Make sure that you load a polyfill in older browsers. https://reactjs.org/link/react-polyfills");
|
|
}
|
|
}
|
|
setRestoreImplementation(restoreControlledState$3);
|
|
setBatchingImplementation(batchedUpdates$1, discreteUpdates$1, flushDiscreteUpdates, batchedEventUpdates$1);
|
|
function createPortal$1(children, container) {
|
|
var key = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : null;
|
|
if (!isValidContainer(container)) {
|
|
{
|
|
throw Error("Target container is not a DOM element.");
|
|
}
|
|
}
|
|
return createPortal2(children, container, null, key);
|
|
}
|
|
function renderSubtreeIntoContainer(parentComponent, element, containerNode, callback) {
|
|
return unstable_renderSubtreeIntoContainer(parentComponent, element, containerNode, callback);
|
|
}
|
|
function unstable_createPortal(children, container) {
|
|
var key = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : null;
|
|
{
|
|
if (!didWarnAboutUnstableCreatePortal) {
|
|
didWarnAboutUnstableCreatePortal = true;
|
|
warn('The ReactDOM.unstable_createPortal() alias has been deprecated, and will be removed in React 18+. Update your code to use ReactDOM.createPortal() instead. It has the exact same API, but without the "unstable_" prefix.');
|
|
}
|
|
}
|
|
return createPortal$1(children, container, key);
|
|
}
|
|
var Internals = {
|
|
Events: [
|
|
getInstanceFromNode,
|
|
getNodeFromInstance,
|
|
getFiberCurrentPropsFromNode,
|
|
enqueueStateRestore,
|
|
restoreStateIfNeeded,
|
|
flushPassiveEffects,
|
|
IsThisRendererActing
|
|
]
|
|
};
|
|
var foundDevTools = injectIntoDevTools({
|
|
findFiberByHostInstance: getClosestInstanceFromNode,
|
|
bundleType: 1,
|
|
version: ReactVersion,
|
|
rendererPackageName: "react-dom"
|
|
});
|
|
{
|
|
if (!foundDevTools && canUseDOM && window.top === window.self) {
|
|
if (navigator.userAgent.indexOf("Chrome") > -1 && navigator.userAgent.indexOf("Edge") === -1 || navigator.userAgent.indexOf("Firefox") > -1) {
|
|
var protocol = window.location.protocol;
|
|
if (/^(https?|file):$/.test(protocol)) {
|
|
console.info("%cDownload the React DevTools for a better development experience: https://reactjs.org/link/react-devtools" + (protocol === "file:" ? "\nYou might need to use a local HTTP server (instead of file://): https://reactjs.org/link/react-devtools-faq" : ""), "font-weight:bold");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
exports.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = Internals;
|
|
exports.createPortal = createPortal$1;
|
|
exports.findDOMNode = findDOMNode;
|
|
exports.flushSync = flushSync;
|
|
exports.hydrate = hydrate;
|
|
exports.render = render4;
|
|
exports.unmountComponentAtNode = unmountComponentAtNode4;
|
|
exports.unstable_batchedUpdates = batchedUpdates$1;
|
|
exports.unstable_createPortal = unstable_createPortal;
|
|
exports.unstable_renderSubtreeIntoContainer = renderSubtreeIntoContainer;
|
|
exports.version = ReactVersion;
|
|
})();
|
|
}
|
|
}
|
|
});
|
|
|
|
// node_modules/react-dom/index.js
|
|
var require_react_dom = __commonJS({
|
|
"node_modules/react-dom/index.js"(exports, module2) {
|
|
"use strict";
|
|
if (false) {
|
|
checkDCE();
|
|
module2.exports = null;
|
|
} else {
|
|
module2.exports = require_react_dom_development();
|
|
}
|
|
}
|
|
});
|
|
|
|
// node_modules/luxon/build/cjs-browser/luxon.js
|
|
var require_luxon = __commonJS({
|
|
"node_modules/luxon/build/cjs-browser/luxon.js"(exports) {
|
|
"use strict";
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
function _defineProperties(target, props) {
|
|
for (var i3 = 0; i3 < props.length; i3++) {
|
|
var descriptor = props[i3];
|
|
descriptor.enumerable = descriptor.enumerable || false;
|
|
descriptor.configurable = true;
|
|
if ("value" in descriptor)
|
|
descriptor.writable = true;
|
|
Object.defineProperty(target, descriptor.key, descriptor);
|
|
}
|
|
}
|
|
function _createClass(Constructor, protoProps, staticProps) {
|
|
if (protoProps)
|
|
_defineProperties(Constructor.prototype, protoProps);
|
|
if (staticProps)
|
|
_defineProperties(Constructor, staticProps);
|
|
return Constructor;
|
|
}
|
|
function _extends() {
|
|
_extends = Object.assign || function(target) {
|
|
for (var i3 = 1; i3 < arguments.length; i3++) {
|
|
var source = arguments[i3];
|
|
for (var key in source) {
|
|
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
target[key] = source[key];
|
|
}
|
|
}
|
|
}
|
|
return target;
|
|
};
|
|
return _extends.apply(this, arguments);
|
|
}
|
|
function _inheritsLoose(subClass, superClass) {
|
|
subClass.prototype = Object.create(superClass.prototype);
|
|
subClass.prototype.constructor = subClass;
|
|
_setPrototypeOf(subClass, superClass);
|
|
}
|
|
function _getPrototypeOf(o2) {
|
|
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf2(o3) {
|
|
return o3.__proto__ || Object.getPrototypeOf(o3);
|
|
};
|
|
return _getPrototypeOf(o2);
|
|
}
|
|
function _setPrototypeOf(o2, p3) {
|
|
_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf2(o3, p4) {
|
|
o3.__proto__ = p4;
|
|
return o3;
|
|
};
|
|
return _setPrototypeOf(o2, p3);
|
|
}
|
|
function _isNativeReflectConstruct() {
|
|
if (typeof Reflect === "undefined" || !Reflect.construct)
|
|
return false;
|
|
if (Reflect.construct.sham)
|
|
return false;
|
|
if (typeof Proxy === "function")
|
|
return true;
|
|
try {
|
|
Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function() {
|
|
}));
|
|
return true;
|
|
} catch (e3) {
|
|
return false;
|
|
}
|
|
}
|
|
function _construct(Parent, args, Class) {
|
|
if (_isNativeReflectConstruct()) {
|
|
_construct = Reflect.construct;
|
|
} else {
|
|
_construct = function _construct2(Parent2, args2, Class2) {
|
|
var a3 = [null];
|
|
a3.push.apply(a3, args2);
|
|
var Constructor = Function.bind.apply(Parent2, a3);
|
|
var instance = new Constructor();
|
|
if (Class2)
|
|
_setPrototypeOf(instance, Class2.prototype);
|
|
return instance;
|
|
};
|
|
}
|
|
return _construct.apply(null, arguments);
|
|
}
|
|
function _isNativeFunction(fn) {
|
|
return Function.toString.call(fn).indexOf("[native code]") !== -1;
|
|
}
|
|
function _wrapNativeSuper(Class) {
|
|
var _cache = typeof Map === "function" ? new Map() : void 0;
|
|
_wrapNativeSuper = function _wrapNativeSuper2(Class2) {
|
|
if (Class2 === null || !_isNativeFunction(Class2))
|
|
return Class2;
|
|
if (typeof Class2 !== "function") {
|
|
throw new TypeError("Super expression must either be null or a function");
|
|
}
|
|
if (typeof _cache !== "undefined") {
|
|
if (_cache.has(Class2))
|
|
return _cache.get(Class2);
|
|
_cache.set(Class2, Wrapper);
|
|
}
|
|
function Wrapper() {
|
|
return _construct(Class2, arguments, _getPrototypeOf(this).constructor);
|
|
}
|
|
Wrapper.prototype = Object.create(Class2.prototype, {
|
|
constructor: {
|
|
value: Wrapper,
|
|
enumerable: false,
|
|
writable: true,
|
|
configurable: true
|
|
}
|
|
});
|
|
return _setPrototypeOf(Wrapper, Class2);
|
|
};
|
|
return _wrapNativeSuper(Class);
|
|
}
|
|
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
if (source == null)
|
|
return {};
|
|
var target = {};
|
|
var sourceKeys = Object.keys(source);
|
|
var key, i3;
|
|
for (i3 = 0; i3 < sourceKeys.length; i3++) {
|
|
key = sourceKeys[i3];
|
|
if (excluded.indexOf(key) >= 0)
|
|
continue;
|
|
target[key] = source[key];
|
|
}
|
|
return target;
|
|
}
|
|
function _unsupportedIterableToArray(o2, minLen) {
|
|
if (!o2)
|
|
return;
|
|
if (typeof o2 === "string")
|
|
return _arrayLikeToArray(o2, minLen);
|
|
var n3 = Object.prototype.toString.call(o2).slice(8, -1);
|
|
if (n3 === "Object" && o2.constructor)
|
|
n3 = o2.constructor.name;
|
|
if (n3 === "Map" || n3 === "Set")
|
|
return Array.from(o2);
|
|
if (n3 === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n3))
|
|
return _arrayLikeToArray(o2, minLen);
|
|
}
|
|
function _arrayLikeToArray(arr, len) {
|
|
if (len == null || len > arr.length)
|
|
len = arr.length;
|
|
for (var i3 = 0, arr2 = new Array(len); i3 < len; i3++)
|
|
arr2[i3] = arr[i3];
|
|
return arr2;
|
|
}
|
|
function _createForOfIteratorHelperLoose(o2, allowArrayLike) {
|
|
var it = typeof Symbol !== "undefined" && o2[Symbol.iterator] || o2["@@iterator"];
|
|
if (it)
|
|
return (it = it.call(o2)).next.bind(it);
|
|
if (Array.isArray(o2) || (it = _unsupportedIterableToArray(o2)) || allowArrayLike && o2 && typeof o2.length === "number") {
|
|
if (it)
|
|
o2 = it;
|
|
var i3 = 0;
|
|
return function() {
|
|
if (i3 >= o2.length)
|
|
return {
|
|
done: true
|
|
};
|
|
return {
|
|
done: false,
|
|
value: o2[i3++]
|
|
};
|
|
};
|
|
}
|
|
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
}
|
|
var LuxonError = /* @__PURE__ */ function(_Error) {
|
|
_inheritsLoose(LuxonError2, _Error);
|
|
function LuxonError2() {
|
|
return _Error.apply(this, arguments) || this;
|
|
}
|
|
return LuxonError2;
|
|
}(/* @__PURE__ */ _wrapNativeSuper(Error));
|
|
var InvalidDateTimeError = /* @__PURE__ */ function(_LuxonError) {
|
|
_inheritsLoose(InvalidDateTimeError2, _LuxonError);
|
|
function InvalidDateTimeError2(reason) {
|
|
return _LuxonError.call(this, "Invalid DateTime: " + reason.toMessage()) || this;
|
|
}
|
|
return InvalidDateTimeError2;
|
|
}(LuxonError);
|
|
var InvalidIntervalError = /* @__PURE__ */ function(_LuxonError2) {
|
|
_inheritsLoose(InvalidIntervalError2, _LuxonError2);
|
|
function InvalidIntervalError2(reason) {
|
|
return _LuxonError2.call(this, "Invalid Interval: " + reason.toMessage()) || this;
|
|
}
|
|
return InvalidIntervalError2;
|
|
}(LuxonError);
|
|
var InvalidDurationError = /* @__PURE__ */ function(_LuxonError3) {
|
|
_inheritsLoose(InvalidDurationError2, _LuxonError3);
|
|
function InvalidDurationError2(reason) {
|
|
return _LuxonError3.call(this, "Invalid Duration: " + reason.toMessage()) || this;
|
|
}
|
|
return InvalidDurationError2;
|
|
}(LuxonError);
|
|
var ConflictingSpecificationError = /* @__PURE__ */ function(_LuxonError4) {
|
|
_inheritsLoose(ConflictingSpecificationError2, _LuxonError4);
|
|
function ConflictingSpecificationError2() {
|
|
return _LuxonError4.apply(this, arguments) || this;
|
|
}
|
|
return ConflictingSpecificationError2;
|
|
}(LuxonError);
|
|
var InvalidUnitError = /* @__PURE__ */ function(_LuxonError5) {
|
|
_inheritsLoose(InvalidUnitError2, _LuxonError5);
|
|
function InvalidUnitError2(unit) {
|
|
return _LuxonError5.call(this, "Invalid unit " + unit) || this;
|
|
}
|
|
return InvalidUnitError2;
|
|
}(LuxonError);
|
|
var InvalidArgumentError = /* @__PURE__ */ function(_LuxonError6) {
|
|
_inheritsLoose(InvalidArgumentError2, _LuxonError6);
|
|
function InvalidArgumentError2() {
|
|
return _LuxonError6.apply(this, arguments) || this;
|
|
}
|
|
return InvalidArgumentError2;
|
|
}(LuxonError);
|
|
var ZoneIsAbstractError = /* @__PURE__ */ function(_LuxonError7) {
|
|
_inheritsLoose(ZoneIsAbstractError2, _LuxonError7);
|
|
function ZoneIsAbstractError2() {
|
|
return _LuxonError7.call(this, "Zone is an abstract class") || this;
|
|
}
|
|
return ZoneIsAbstractError2;
|
|
}(LuxonError);
|
|
var n2 = "numeric";
|
|
var s3 = "short";
|
|
var l3 = "long";
|
|
var DATE_SHORT = {
|
|
year: n2,
|
|
month: n2,
|
|
day: n2
|
|
};
|
|
var DATE_MED = {
|
|
year: n2,
|
|
month: s3,
|
|
day: n2
|
|
};
|
|
var DATE_MED_WITH_WEEKDAY = {
|
|
year: n2,
|
|
month: s3,
|
|
day: n2,
|
|
weekday: s3
|
|
};
|
|
var DATE_FULL = {
|
|
year: n2,
|
|
month: l3,
|
|
day: n2
|
|
};
|
|
var DATE_HUGE = {
|
|
year: n2,
|
|
month: l3,
|
|
day: n2,
|
|
weekday: l3
|
|
};
|
|
var TIME_SIMPLE = {
|
|
hour: n2,
|
|
minute: n2
|
|
};
|
|
var TIME_WITH_SECONDS = {
|
|
hour: n2,
|
|
minute: n2,
|
|
second: n2
|
|
};
|
|
var TIME_WITH_SHORT_OFFSET = {
|
|
hour: n2,
|
|
minute: n2,
|
|
second: n2,
|
|
timeZoneName: s3
|
|
};
|
|
var TIME_WITH_LONG_OFFSET = {
|
|
hour: n2,
|
|
minute: n2,
|
|
second: n2,
|
|
timeZoneName: l3
|
|
};
|
|
var TIME_24_SIMPLE = {
|
|
hour: n2,
|
|
minute: n2,
|
|
hourCycle: "h23"
|
|
};
|
|
var TIME_24_WITH_SECONDS = {
|
|
hour: n2,
|
|
minute: n2,
|
|
second: n2,
|
|
hourCycle: "h23"
|
|
};
|
|
var TIME_24_WITH_SHORT_OFFSET = {
|
|
hour: n2,
|
|
minute: n2,
|
|
second: n2,
|
|
hourCycle: "h23",
|
|
timeZoneName: s3
|
|
};
|
|
var TIME_24_WITH_LONG_OFFSET = {
|
|
hour: n2,
|
|
minute: n2,
|
|
second: n2,
|
|
hourCycle: "h23",
|
|
timeZoneName: l3
|
|
};
|
|
var DATETIME_SHORT = {
|
|
year: n2,
|
|
month: n2,
|
|
day: n2,
|
|
hour: n2,
|
|
minute: n2
|
|
};
|
|
var DATETIME_SHORT_WITH_SECONDS = {
|
|
year: n2,
|
|
month: n2,
|
|
day: n2,
|
|
hour: n2,
|
|
minute: n2,
|
|
second: n2
|
|
};
|
|
var DATETIME_MED = {
|
|
year: n2,
|
|
month: s3,
|
|
day: n2,
|
|
hour: n2,
|
|
minute: n2
|
|
};
|
|
var DATETIME_MED_WITH_SECONDS = {
|
|
year: n2,
|
|
month: s3,
|
|
day: n2,
|
|
hour: n2,
|
|
minute: n2,
|
|
second: n2
|
|
};
|
|
var DATETIME_MED_WITH_WEEKDAY = {
|
|
year: n2,
|
|
month: s3,
|
|
day: n2,
|
|
weekday: s3,
|
|
hour: n2,
|
|
minute: n2
|
|
};
|
|
var DATETIME_FULL = {
|
|
year: n2,
|
|
month: l3,
|
|
day: n2,
|
|
hour: n2,
|
|
minute: n2,
|
|
timeZoneName: s3
|
|
};
|
|
var DATETIME_FULL_WITH_SECONDS = {
|
|
year: n2,
|
|
month: l3,
|
|
day: n2,
|
|
hour: n2,
|
|
minute: n2,
|
|
second: n2,
|
|
timeZoneName: s3
|
|
};
|
|
var DATETIME_HUGE = {
|
|
year: n2,
|
|
month: l3,
|
|
day: n2,
|
|
weekday: l3,
|
|
hour: n2,
|
|
minute: n2,
|
|
timeZoneName: l3
|
|
};
|
|
var DATETIME_HUGE_WITH_SECONDS = {
|
|
year: n2,
|
|
month: l3,
|
|
day: n2,
|
|
weekday: l3,
|
|
hour: n2,
|
|
minute: n2,
|
|
second: n2,
|
|
timeZoneName: l3
|
|
};
|
|
function isUndefined(o2) {
|
|
return typeof o2 === "undefined";
|
|
}
|
|
function isNumber(o2) {
|
|
return typeof o2 === "number";
|
|
}
|
|
function isInteger(o2) {
|
|
return typeof o2 === "number" && o2 % 1 === 0;
|
|
}
|
|
function isString(o2) {
|
|
return typeof o2 === "string";
|
|
}
|
|
function isDate(o2) {
|
|
return Object.prototype.toString.call(o2) === "[object Date]";
|
|
}
|
|
function hasRelative() {
|
|
try {
|
|
return typeof Intl !== "undefined" && !!Intl.RelativeTimeFormat;
|
|
} catch (e3) {
|
|
return false;
|
|
}
|
|
}
|
|
function maybeArray(thing) {
|
|
return Array.isArray(thing) ? thing : [thing];
|
|
}
|
|
function bestBy(arr, by, compare) {
|
|
if (arr.length === 0) {
|
|
return void 0;
|
|
}
|
|
return arr.reduce(function(best, next) {
|
|
var pair = [by(next), next];
|
|
if (!best) {
|
|
return pair;
|
|
} else if (compare(best[0], pair[0]) === best[0]) {
|
|
return best;
|
|
} else {
|
|
return pair;
|
|
}
|
|
}, null)[1];
|
|
}
|
|
function pick(obj, keys) {
|
|
return keys.reduce(function(a3, k2) {
|
|
a3[k2] = obj[k2];
|
|
return a3;
|
|
}, {});
|
|
}
|
|
function hasOwnProperty2(obj, prop) {
|
|
return Object.prototype.hasOwnProperty.call(obj, prop);
|
|
}
|
|
function integerBetween(thing, bottom, top) {
|
|
return isInteger(thing) && thing >= bottom && thing <= top;
|
|
}
|
|
function floorMod(x3, n3) {
|
|
return x3 - n3 * Math.floor(x3 / n3);
|
|
}
|
|
function padStart2(input, n3) {
|
|
if (n3 === void 0) {
|
|
n3 = 2;
|
|
}
|
|
var isNeg = input < 0;
|
|
var padded;
|
|
if (isNeg) {
|
|
padded = "-" + ("" + -input).padStart(n3, "0");
|
|
} else {
|
|
padded = ("" + input).padStart(n3, "0");
|
|
}
|
|
return padded;
|
|
}
|
|
function parseInteger(string) {
|
|
if (isUndefined(string) || string === null || string === "") {
|
|
return void 0;
|
|
} else {
|
|
return parseInt(string, 10);
|
|
}
|
|
}
|
|
function parseFloating(string) {
|
|
if (isUndefined(string) || string === null || string === "") {
|
|
return void 0;
|
|
} else {
|
|
return parseFloat(string);
|
|
}
|
|
}
|
|
function parseMillis(fraction) {
|
|
if (isUndefined(fraction) || fraction === null || fraction === "") {
|
|
return void 0;
|
|
} else {
|
|
var f3 = parseFloat("0." + fraction) * 1e3;
|
|
return Math.floor(f3);
|
|
}
|
|
}
|
|
function roundTo(number, digits, towardZero) {
|
|
if (towardZero === void 0) {
|
|
towardZero = false;
|
|
}
|
|
var factor = Math.pow(10, digits), rounder = towardZero ? Math.trunc : Math.round;
|
|
return rounder(number * factor) / factor;
|
|
}
|
|
function isLeapYear(year) {
|
|
return year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0);
|
|
}
|
|
function daysInYear(year) {
|
|
return isLeapYear(year) ? 366 : 365;
|
|
}
|
|
function daysInMonth(year, month) {
|
|
var modMonth = floorMod(month - 1, 12) + 1, modYear = year + (month - modMonth) / 12;
|
|
if (modMonth === 2) {
|
|
return isLeapYear(modYear) ? 29 : 28;
|
|
} else {
|
|
return [31, null, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][modMonth - 1];
|
|
}
|
|
}
|
|
function objToLocalTS(obj) {
|
|
var d3 = Date.UTC(obj.year, obj.month - 1, obj.day, obj.hour, obj.minute, obj.second, obj.millisecond);
|
|
if (obj.year < 100 && obj.year >= 0) {
|
|
d3 = new Date(d3);
|
|
d3.setUTCFullYear(d3.getUTCFullYear() - 1900);
|
|
}
|
|
return +d3;
|
|
}
|
|
function weeksInWeekYear(weekYear) {
|
|
var p1 = (weekYear + Math.floor(weekYear / 4) - Math.floor(weekYear / 100) + Math.floor(weekYear / 400)) % 7, last = weekYear - 1, p22 = (last + Math.floor(last / 4) - Math.floor(last / 100) + Math.floor(last / 400)) % 7;
|
|
return p1 === 4 || p22 === 3 ? 53 : 52;
|
|
}
|
|
function untruncateYear(year) {
|
|
if (year > 99) {
|
|
return year;
|
|
} else
|
|
return year > 60 ? 1900 + year : 2e3 + year;
|
|
}
|
|
function parseZoneInfo(ts, offsetFormat, locale, timeZone) {
|
|
if (timeZone === void 0) {
|
|
timeZone = null;
|
|
}
|
|
var date = new Date(ts), intlOpts = {
|
|
hourCycle: "h23",
|
|
year: "numeric",
|
|
month: "2-digit",
|
|
day: "2-digit",
|
|
hour: "2-digit",
|
|
minute: "2-digit"
|
|
};
|
|
if (timeZone) {
|
|
intlOpts.timeZone = timeZone;
|
|
}
|
|
var modified = _extends({
|
|
timeZoneName: offsetFormat
|
|
}, intlOpts);
|
|
var parsed = new Intl.DateTimeFormat(locale, modified).formatToParts(date).find(function(m2) {
|
|
return m2.type.toLowerCase() === "timezonename";
|
|
});
|
|
return parsed ? parsed.value : null;
|
|
}
|
|
function signedOffset(offHourStr, offMinuteStr) {
|
|
var offHour = parseInt(offHourStr, 10);
|
|
if (Number.isNaN(offHour)) {
|
|
offHour = 0;
|
|
}
|
|
var offMin = parseInt(offMinuteStr, 10) || 0, offMinSigned = offHour < 0 || Object.is(offHour, -0) ? -offMin : offMin;
|
|
return offHour * 60 + offMinSigned;
|
|
}
|
|
function asNumber(value) {
|
|
var numericValue = Number(value);
|
|
if (typeof value === "boolean" || value === "" || Number.isNaN(numericValue))
|
|
throw new InvalidArgumentError("Invalid unit value " + value);
|
|
return numericValue;
|
|
}
|
|
function normalizeObject(obj, normalizer) {
|
|
var normalized = {};
|
|
for (var u3 in obj) {
|
|
if (hasOwnProperty2(obj, u3)) {
|
|
var v3 = obj[u3];
|
|
if (v3 === void 0 || v3 === null)
|
|
continue;
|
|
normalized[normalizer(u3)] = asNumber(v3);
|
|
}
|
|
}
|
|
return normalized;
|
|
}
|
|
function formatOffset(offset2, format) {
|
|
var hours = Math.trunc(Math.abs(offset2 / 60)), minutes = Math.trunc(Math.abs(offset2 % 60)), sign = offset2 >= 0 ? "+" : "-";
|
|
switch (format) {
|
|
case "short":
|
|
return "" + sign + padStart2(hours, 2) + ":" + padStart2(minutes, 2);
|
|
case "narrow":
|
|
return "" + sign + hours + (minutes > 0 ? ":" + minutes : "");
|
|
case "techie":
|
|
return "" + sign + padStart2(hours, 2) + padStart2(minutes, 2);
|
|
default:
|
|
throw new RangeError("Value format " + format + " is out of range for property format");
|
|
}
|
|
}
|
|
function timeObject(obj) {
|
|
return pick(obj, ["hour", "minute", "second", "millisecond"]);
|
|
}
|
|
var ianaRegex = /[A-Za-z_+-]{1,256}(:?\/[A-Za-z0-9_+-]{1,256}(\/[A-Za-z0-9_+-]{1,256})?)?/;
|
|
var monthsLong = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
|
|
var monthsShort = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
|
|
var monthsNarrow = ["J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"];
|
|
function months(length) {
|
|
switch (length) {
|
|
case "narrow":
|
|
return [].concat(monthsNarrow);
|
|
case "short":
|
|
return [].concat(monthsShort);
|
|
case "long":
|
|
return [].concat(monthsLong);
|
|
case "numeric":
|
|
return ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"];
|
|
case "2-digit":
|
|
return ["01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12"];
|
|
default:
|
|
return null;
|
|
}
|
|
}
|
|
var weekdaysLong = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"];
|
|
var weekdaysShort = ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"];
|
|
var weekdaysNarrow = ["M", "T", "W", "T", "F", "S", "S"];
|
|
function weekdays(length) {
|
|
switch (length) {
|
|
case "narrow":
|
|
return [].concat(weekdaysNarrow);
|
|
case "short":
|
|
return [].concat(weekdaysShort);
|
|
case "long":
|
|
return [].concat(weekdaysLong);
|
|
case "numeric":
|
|
return ["1", "2", "3", "4", "5", "6", "7"];
|
|
default:
|
|
return null;
|
|
}
|
|
}
|
|
var meridiems = ["AM", "PM"];
|
|
var erasLong = ["Before Christ", "Anno Domini"];
|
|
var erasShort = ["BC", "AD"];
|
|
var erasNarrow = ["B", "A"];
|
|
function eras(length) {
|
|
switch (length) {
|
|
case "narrow":
|
|
return [].concat(erasNarrow);
|
|
case "short":
|
|
return [].concat(erasShort);
|
|
case "long":
|
|
return [].concat(erasLong);
|
|
default:
|
|
return null;
|
|
}
|
|
}
|
|
function meridiemForDateTime(dt) {
|
|
return meridiems[dt.hour < 12 ? 0 : 1];
|
|
}
|
|
function weekdayForDateTime(dt, length) {
|
|
return weekdays(length)[dt.weekday - 1];
|
|
}
|
|
function monthForDateTime(dt, length) {
|
|
return months(length)[dt.month - 1];
|
|
}
|
|
function eraForDateTime(dt, length) {
|
|
return eras(length)[dt.year < 0 ? 0 : 1];
|
|
}
|
|
function formatRelativeTime(unit, count, numeric, narrow) {
|
|
if (numeric === void 0) {
|
|
numeric = "always";
|
|
}
|
|
if (narrow === void 0) {
|
|
narrow = false;
|
|
}
|
|
var units = {
|
|
years: ["year", "yr."],
|
|
quarters: ["quarter", "qtr."],
|
|
months: ["month", "mo."],
|
|
weeks: ["week", "wk."],
|
|
days: ["day", "day", "days"],
|
|
hours: ["hour", "hr."],
|
|
minutes: ["minute", "min."],
|
|
seconds: ["second", "sec."]
|
|
};
|
|
var lastable = ["hours", "minutes", "seconds"].indexOf(unit) === -1;
|
|
if (numeric === "auto" && lastable) {
|
|
var isDay = unit === "days";
|
|
switch (count) {
|
|
case 1:
|
|
return isDay ? "tomorrow" : "next " + units[unit][0];
|
|
case -1:
|
|
return isDay ? "yesterday" : "last " + units[unit][0];
|
|
case 0:
|
|
return isDay ? "today" : "this " + units[unit][0];
|
|
}
|
|
}
|
|
var isInPast = Object.is(count, -0) || count < 0, fmtValue = Math.abs(count), singular = fmtValue === 1, lilUnits = units[unit], fmtUnit = narrow ? singular ? lilUnits[1] : lilUnits[2] || lilUnits[1] : singular ? units[unit][0] : unit;
|
|
return isInPast ? fmtValue + " " + fmtUnit + " ago" : "in " + fmtValue + " " + fmtUnit;
|
|
}
|
|
function stringifyTokens(splits, tokenToString) {
|
|
var s4 = "";
|
|
for (var _iterator = _createForOfIteratorHelperLoose(splits), _step; !(_step = _iterator()).done; ) {
|
|
var token = _step.value;
|
|
if (token.literal) {
|
|
s4 += token.val;
|
|
} else {
|
|
s4 += tokenToString(token.val);
|
|
}
|
|
}
|
|
return s4;
|
|
}
|
|
var _macroTokenToFormatOpts = {
|
|
D: DATE_SHORT,
|
|
DD: DATE_MED,
|
|
DDD: DATE_FULL,
|
|
DDDD: DATE_HUGE,
|
|
t: TIME_SIMPLE,
|
|
tt: TIME_WITH_SECONDS,
|
|
ttt: TIME_WITH_SHORT_OFFSET,
|
|
tttt: TIME_WITH_LONG_OFFSET,
|
|
T: TIME_24_SIMPLE,
|
|
TT: TIME_24_WITH_SECONDS,
|
|
TTT: TIME_24_WITH_SHORT_OFFSET,
|
|
TTTT: TIME_24_WITH_LONG_OFFSET,
|
|
f: DATETIME_SHORT,
|
|
ff: DATETIME_MED,
|
|
fff: DATETIME_FULL,
|
|
ffff: DATETIME_HUGE,
|
|
F: DATETIME_SHORT_WITH_SECONDS,
|
|
FF: DATETIME_MED_WITH_SECONDS,
|
|
FFF: DATETIME_FULL_WITH_SECONDS,
|
|
FFFF: DATETIME_HUGE_WITH_SECONDS
|
|
};
|
|
var Formatter = /* @__PURE__ */ function() {
|
|
Formatter2.create = function create(locale, opts) {
|
|
if (opts === void 0) {
|
|
opts = {};
|
|
}
|
|
return new Formatter2(locale, opts);
|
|
};
|
|
Formatter2.parseFormat = function parseFormat(fmt) {
|
|
var current = null, currentFull = "", bracketed = false;
|
|
var splits = [];
|
|
for (var i3 = 0; i3 < fmt.length; i3++) {
|
|
var c3 = fmt.charAt(i3);
|
|
if (c3 === "'") {
|
|
if (currentFull.length > 0) {
|
|
splits.push({
|
|
literal: bracketed,
|
|
val: currentFull
|
|
});
|
|
}
|
|
current = null;
|
|
currentFull = "";
|
|
bracketed = !bracketed;
|
|
} else if (bracketed) {
|
|
currentFull += c3;
|
|
} else if (c3 === current) {
|
|
currentFull += c3;
|
|
} else {
|
|
if (currentFull.length > 0) {
|
|
splits.push({
|
|
literal: false,
|
|
val: currentFull
|
|
});
|
|
}
|
|
currentFull = c3;
|
|
current = c3;
|
|
}
|
|
}
|
|
if (currentFull.length > 0) {
|
|
splits.push({
|
|
literal: bracketed,
|
|
val: currentFull
|
|
});
|
|
}
|
|
return splits;
|
|
};
|
|
Formatter2.macroTokenToFormatOpts = function macroTokenToFormatOpts(token) {
|
|
return _macroTokenToFormatOpts[token];
|
|
};
|
|
function Formatter2(locale, formatOpts) {
|
|
this.opts = formatOpts;
|
|
this.loc = locale;
|
|
this.systemLoc = null;
|
|
}
|
|
var _proto = Formatter2.prototype;
|
|
_proto.formatWithSystemDefault = function formatWithSystemDefault(dt, opts) {
|
|
if (this.systemLoc === null) {
|
|
this.systemLoc = this.loc.redefaultToSystem();
|
|
}
|
|
var df = this.systemLoc.dtFormatter(dt, _extends({}, this.opts, opts));
|
|
return df.format();
|
|
};
|
|
_proto.formatDateTime = function formatDateTime(dt, opts) {
|
|
if (opts === void 0) {
|
|
opts = {};
|
|
}
|
|
var df = this.loc.dtFormatter(dt, _extends({}, this.opts, opts));
|
|
return df.format();
|
|
};
|
|
_proto.formatDateTimeParts = function formatDateTimeParts(dt, opts) {
|
|
if (opts === void 0) {
|
|
opts = {};
|
|
}
|
|
var df = this.loc.dtFormatter(dt, _extends({}, this.opts, opts));
|
|
return df.formatToParts();
|
|
};
|
|
_proto.resolvedOptions = function resolvedOptions(dt, opts) {
|
|
if (opts === void 0) {
|
|
opts = {};
|
|
}
|
|
var df = this.loc.dtFormatter(dt, _extends({}, this.opts, opts));
|
|
return df.resolvedOptions();
|
|
};
|
|
_proto.num = function num(n3, p3) {
|
|
if (p3 === void 0) {
|
|
p3 = 0;
|
|
}
|
|
if (this.opts.forceSimple) {
|
|
return padStart2(n3, p3);
|
|
}
|
|
var opts = _extends({}, this.opts);
|
|
if (p3 > 0) {
|
|
opts.padTo = p3;
|
|
}
|
|
return this.loc.numberFormatter(opts).format(n3);
|
|
};
|
|
_proto.formatDateTimeFromString = function formatDateTimeFromString(dt, fmt) {
|
|
var _this = this;
|
|
var knownEnglish = this.loc.listingMode() === "en", useDateTimeFormatter = this.loc.outputCalendar && this.loc.outputCalendar !== "gregory", string = function string2(opts, extract) {
|
|
return _this.loc.extract(dt, opts, extract);
|
|
}, formatOffset2 = function formatOffset3(opts) {
|
|
if (dt.isOffsetFixed && dt.offset === 0 && opts.allowZ) {
|
|
return "Z";
|
|
}
|
|
return dt.isValid ? dt.zone.formatOffset(dt.ts, opts.format) : "";
|
|
}, meridiem = function meridiem2() {
|
|
return knownEnglish ? meridiemForDateTime(dt) : string({
|
|
hour: "numeric",
|
|
hourCycle: "h12"
|
|
}, "dayperiod");
|
|
}, month = function month2(length, standalone) {
|
|
return knownEnglish ? monthForDateTime(dt, length) : string(standalone ? {
|
|
month: length
|
|
} : {
|
|
month: length,
|
|
day: "numeric"
|
|
}, "month");
|
|
}, weekday = function weekday2(length, standalone) {
|
|
return knownEnglish ? weekdayForDateTime(dt, length) : string(standalone ? {
|
|
weekday: length
|
|
} : {
|
|
weekday: length,
|
|
month: "long",
|
|
day: "numeric"
|
|
}, "weekday");
|
|
}, maybeMacro = function maybeMacro2(token) {
|
|
var formatOpts = Formatter2.macroTokenToFormatOpts(token);
|
|
if (formatOpts) {
|
|
return _this.formatWithSystemDefault(dt, formatOpts);
|
|
} else {
|
|
return token;
|
|
}
|
|
}, era = function era2(length) {
|
|
return knownEnglish ? eraForDateTime(dt, length) : string({
|
|
era: length
|
|
}, "era");
|
|
}, tokenToString = function tokenToString2(token) {
|
|
switch (token) {
|
|
case "S":
|
|
return _this.num(dt.millisecond);
|
|
case "u":
|
|
case "SSS":
|
|
return _this.num(dt.millisecond, 3);
|
|
case "s":
|
|
return _this.num(dt.second);
|
|
case "ss":
|
|
return _this.num(dt.second, 2);
|
|
case "uu":
|
|
return _this.num(Math.floor(dt.millisecond / 10), 2);
|
|
case "uuu":
|
|
return _this.num(Math.floor(dt.millisecond / 100));
|
|
case "m":
|
|
return _this.num(dt.minute);
|
|
case "mm":
|
|
return _this.num(dt.minute, 2);
|
|
case "h":
|
|
return _this.num(dt.hour % 12 === 0 ? 12 : dt.hour % 12);
|
|
case "hh":
|
|
return _this.num(dt.hour % 12 === 0 ? 12 : dt.hour % 12, 2);
|
|
case "H":
|
|
return _this.num(dt.hour);
|
|
case "HH":
|
|
return _this.num(dt.hour, 2);
|
|
case "Z":
|
|
return formatOffset2({
|
|
format: "narrow",
|
|
allowZ: _this.opts.allowZ
|
|
});
|
|
case "ZZ":
|
|
return formatOffset2({
|
|
format: "short",
|
|
allowZ: _this.opts.allowZ
|
|
});
|
|
case "ZZZ":
|
|
return formatOffset2({
|
|
format: "techie",
|
|
allowZ: _this.opts.allowZ
|
|
});
|
|
case "ZZZZ":
|
|
return dt.zone.offsetName(dt.ts, {
|
|
format: "short",
|
|
locale: _this.loc.locale
|
|
});
|
|
case "ZZZZZ":
|
|
return dt.zone.offsetName(dt.ts, {
|
|
format: "long",
|
|
locale: _this.loc.locale
|
|
});
|
|
case "z":
|
|
return dt.zoneName;
|
|
case "a":
|
|
return meridiem();
|
|
case "d":
|
|
return useDateTimeFormatter ? string({
|
|
day: "numeric"
|
|
}, "day") : _this.num(dt.day);
|
|
case "dd":
|
|
return useDateTimeFormatter ? string({
|
|
day: "2-digit"
|
|
}, "day") : _this.num(dt.day, 2);
|
|
case "c":
|
|
return _this.num(dt.weekday);
|
|
case "ccc":
|
|
return weekday("short", true);
|
|
case "cccc":
|
|
return weekday("long", true);
|
|
case "ccccc":
|
|
return weekday("narrow", true);
|
|
case "E":
|
|
return _this.num(dt.weekday);
|
|
case "EEE":
|
|
return weekday("short", false);
|
|
case "EEEE":
|
|
return weekday("long", false);
|
|
case "EEEEE":
|
|
return weekday("narrow", false);
|
|
case "L":
|
|
return useDateTimeFormatter ? string({
|
|
month: "numeric",
|
|
day: "numeric"
|
|
}, "month") : _this.num(dt.month);
|
|
case "LL":
|
|
return useDateTimeFormatter ? string({
|
|
month: "2-digit",
|
|
day: "numeric"
|
|
}, "month") : _this.num(dt.month, 2);
|
|
case "LLL":
|
|
return month("short", true);
|
|
case "LLLL":
|
|
return month("long", true);
|
|
case "LLLLL":
|
|
return month("narrow", true);
|
|
case "M":
|
|
return useDateTimeFormatter ? string({
|
|
month: "numeric"
|
|
}, "month") : _this.num(dt.month);
|
|
case "MM":
|
|
return useDateTimeFormatter ? string({
|
|
month: "2-digit"
|
|
}, "month") : _this.num(dt.month, 2);
|
|
case "MMM":
|
|
return month("short", false);
|
|
case "MMMM":
|
|
return month("long", false);
|
|
case "MMMMM":
|
|
return month("narrow", false);
|
|
case "y":
|
|
return useDateTimeFormatter ? string({
|
|
year: "numeric"
|
|
}, "year") : _this.num(dt.year);
|
|
case "yy":
|
|
return useDateTimeFormatter ? string({
|
|
year: "2-digit"
|
|
}, "year") : _this.num(dt.year.toString().slice(-2), 2);
|
|
case "yyyy":
|
|
return useDateTimeFormatter ? string({
|
|
year: "numeric"
|
|
}, "year") : _this.num(dt.year, 4);
|
|
case "yyyyyy":
|
|
return useDateTimeFormatter ? string({
|
|
year: "numeric"
|
|
}, "year") : _this.num(dt.year, 6);
|
|
case "G":
|
|
return era("short");
|
|
case "GG":
|
|
return era("long");
|
|
case "GGGGG":
|
|
return era("narrow");
|
|
case "kk":
|
|
return _this.num(dt.weekYear.toString().slice(-2), 2);
|
|
case "kkkk":
|
|
return _this.num(dt.weekYear, 4);
|
|
case "W":
|
|
return _this.num(dt.weekNumber);
|
|
case "WW":
|
|
return _this.num(dt.weekNumber, 2);
|
|
case "o":
|
|
return _this.num(dt.ordinal);
|
|
case "ooo":
|
|
return _this.num(dt.ordinal, 3);
|
|
case "q":
|
|
return _this.num(dt.quarter);
|
|
case "qq":
|
|
return _this.num(dt.quarter, 2);
|
|
case "X":
|
|
return _this.num(Math.floor(dt.ts / 1e3));
|
|
case "x":
|
|
return _this.num(dt.ts);
|
|
default:
|
|
return maybeMacro(token);
|
|
}
|
|
};
|
|
return stringifyTokens(Formatter2.parseFormat(fmt), tokenToString);
|
|
};
|
|
_proto.formatDurationFromString = function formatDurationFromString(dur, fmt) {
|
|
var _this2 = this;
|
|
var tokenToField = function tokenToField2(token) {
|
|
switch (token[0]) {
|
|
case "S":
|
|
return "millisecond";
|
|
case "s":
|
|
return "second";
|
|
case "m":
|
|
return "minute";
|
|
case "h":
|
|
return "hour";
|
|
case "d":
|
|
return "day";
|
|
case "M":
|
|
return "month";
|
|
case "y":
|
|
return "year";
|
|
default:
|
|
return null;
|
|
}
|
|
}, tokenToString = function tokenToString2(lildur) {
|
|
return function(token) {
|
|
var mapped = tokenToField(token);
|
|
if (mapped) {
|
|
return _this2.num(lildur.get(mapped), token.length);
|
|
} else {
|
|
return token;
|
|
}
|
|
};
|
|
}, tokens = Formatter2.parseFormat(fmt), realTokens = tokens.reduce(function(found, _ref) {
|
|
var literal = _ref.literal, val = _ref.val;
|
|
return literal ? found : found.concat(val);
|
|
}, []), collapsed = dur.shiftTo.apply(dur, realTokens.map(tokenToField).filter(function(t3) {
|
|
return t3;
|
|
}));
|
|
return stringifyTokens(tokens, tokenToString(collapsed));
|
|
};
|
|
return Formatter2;
|
|
}();
|
|
var Invalid = /* @__PURE__ */ function() {
|
|
function Invalid2(reason, explanation) {
|
|
this.reason = reason;
|
|
this.explanation = explanation;
|
|
}
|
|
var _proto = Invalid2.prototype;
|
|
_proto.toMessage = function toMessage() {
|
|
if (this.explanation) {
|
|
return this.reason + ": " + this.explanation;
|
|
} else {
|
|
return this.reason;
|
|
}
|
|
};
|
|
return Invalid2;
|
|
}();
|
|
var Zone = /* @__PURE__ */ function() {
|
|
function Zone2() {
|
|
}
|
|
var _proto = Zone2.prototype;
|
|
_proto.offsetName = function offsetName(ts, opts) {
|
|
throw new ZoneIsAbstractError();
|
|
};
|
|
_proto.formatOffset = function formatOffset2(ts, format) {
|
|
throw new ZoneIsAbstractError();
|
|
};
|
|
_proto.offset = function offset2(ts) {
|
|
throw new ZoneIsAbstractError();
|
|
};
|
|
_proto.equals = function equals(otherZone) {
|
|
throw new ZoneIsAbstractError();
|
|
};
|
|
_createClass(Zone2, [{
|
|
key: "type",
|
|
get: function get() {
|
|
throw new ZoneIsAbstractError();
|
|
}
|
|
}, {
|
|
key: "name",
|
|
get: function get() {
|
|
throw new ZoneIsAbstractError();
|
|
}
|
|
}, {
|
|
key: "isUniversal",
|
|
get: function get() {
|
|
throw new ZoneIsAbstractError();
|
|
}
|
|
}, {
|
|
key: "isValid",
|
|
get: function get() {
|
|
throw new ZoneIsAbstractError();
|
|
}
|
|
}]);
|
|
return Zone2;
|
|
}();
|
|
var singleton$1 = null;
|
|
var SystemZone = /* @__PURE__ */ function(_Zone) {
|
|
_inheritsLoose(SystemZone2, _Zone);
|
|
function SystemZone2() {
|
|
return _Zone.apply(this, arguments) || this;
|
|
}
|
|
var _proto = SystemZone2.prototype;
|
|
_proto.offsetName = function offsetName(ts, _ref) {
|
|
var format = _ref.format, locale = _ref.locale;
|
|
return parseZoneInfo(ts, format, locale);
|
|
};
|
|
_proto.formatOffset = function formatOffset$1(ts, format) {
|
|
return formatOffset(this.offset(ts), format);
|
|
};
|
|
_proto.offset = function offset2(ts) {
|
|
return -new Date(ts).getTimezoneOffset();
|
|
};
|
|
_proto.equals = function equals(otherZone) {
|
|
return otherZone.type === "system";
|
|
};
|
|
_createClass(SystemZone2, [{
|
|
key: "type",
|
|
get: function get() {
|
|
return "system";
|
|
}
|
|
}, {
|
|
key: "name",
|
|
get: function get() {
|
|
return new Intl.DateTimeFormat().resolvedOptions().timeZone;
|
|
}
|
|
}, {
|
|
key: "isUniversal",
|
|
get: function get() {
|
|
return false;
|
|
}
|
|
}, {
|
|
key: "isValid",
|
|
get: function get() {
|
|
return true;
|
|
}
|
|
}], [{
|
|
key: "instance",
|
|
get: function get() {
|
|
if (singleton$1 === null) {
|
|
singleton$1 = new SystemZone2();
|
|
}
|
|
return singleton$1;
|
|
}
|
|
}]);
|
|
return SystemZone2;
|
|
}(Zone);
|
|
RegExp("^" + ianaRegex.source + "$");
|
|
var dtfCache = {};
|
|
function makeDTF(zone) {
|
|
if (!dtfCache[zone]) {
|
|
dtfCache[zone] = new Intl.DateTimeFormat("en-US", {
|
|
hour12: false,
|
|
timeZone: zone,
|
|
year: "numeric",
|
|
month: "2-digit",
|
|
day: "2-digit",
|
|
hour: "2-digit",
|
|
minute: "2-digit",
|
|
second: "2-digit"
|
|
});
|
|
}
|
|
return dtfCache[zone];
|
|
}
|
|
var typeToPos = {
|
|
year: 0,
|
|
month: 1,
|
|
day: 2,
|
|
hour: 3,
|
|
minute: 4,
|
|
second: 5
|
|
};
|
|
function hackyOffset(dtf, date) {
|
|
var formatted = dtf.format(date).replace(/\u200E/g, ""), parsed = /(\d+)\/(\d+)\/(\d+),? (\d+):(\d+):(\d+)/.exec(formatted), fMonth = parsed[1], fDay = parsed[2], fYear = parsed[3], fHour = parsed[4], fMinute = parsed[5], fSecond = parsed[6];
|
|
return [fYear, fMonth, fDay, fHour, fMinute, fSecond];
|
|
}
|
|
function partsOffset(dtf, date) {
|
|
var formatted = dtf.formatToParts(date), filled = [];
|
|
for (var i3 = 0; i3 < formatted.length; i3++) {
|
|
var _formatted$i = formatted[i3], type = _formatted$i.type, value = _formatted$i.value, pos = typeToPos[type];
|
|
if (!isUndefined(pos)) {
|
|
filled[pos] = parseInt(value, 10);
|
|
}
|
|
}
|
|
return filled;
|
|
}
|
|
var ianaZoneCache = {};
|
|
var IANAZone = /* @__PURE__ */ function(_Zone) {
|
|
_inheritsLoose(IANAZone2, _Zone);
|
|
IANAZone2.create = function create(name) {
|
|
if (!ianaZoneCache[name]) {
|
|
ianaZoneCache[name] = new IANAZone2(name);
|
|
}
|
|
return ianaZoneCache[name];
|
|
};
|
|
IANAZone2.resetCache = function resetCache() {
|
|
ianaZoneCache = {};
|
|
dtfCache = {};
|
|
};
|
|
IANAZone2.isValidSpecifier = function isValidSpecifier(s4) {
|
|
return this.isValidZone(s4);
|
|
};
|
|
IANAZone2.isValidZone = function isValidZone(zone) {
|
|
if (!zone) {
|
|
return false;
|
|
}
|
|
try {
|
|
new Intl.DateTimeFormat("en-US", {
|
|
timeZone: zone
|
|
}).format();
|
|
return true;
|
|
} catch (e3) {
|
|
return false;
|
|
}
|
|
};
|
|
function IANAZone2(name) {
|
|
var _this;
|
|
_this = _Zone.call(this) || this;
|
|
_this.zoneName = name;
|
|
_this.valid = IANAZone2.isValidZone(name);
|
|
return _this;
|
|
}
|
|
var _proto = IANAZone2.prototype;
|
|
_proto.offsetName = function offsetName(ts, _ref) {
|
|
var format = _ref.format, locale = _ref.locale;
|
|
return parseZoneInfo(ts, format, locale, this.name);
|
|
};
|
|
_proto.formatOffset = function formatOffset$1(ts, format) {
|
|
return formatOffset(this.offset(ts), format);
|
|
};
|
|
_proto.offset = function offset2(ts) {
|
|
var date = new Date(ts);
|
|
if (isNaN(date))
|
|
return NaN;
|
|
var dtf = makeDTF(this.name), _ref2 = dtf.formatToParts ? partsOffset(dtf, date) : hackyOffset(dtf, date), year = _ref2[0], month = _ref2[1], day = _ref2[2], hour = _ref2[3], minute = _ref2[4], second = _ref2[5];
|
|
var adjustedHour = hour === 24 ? 0 : hour;
|
|
var asUTC = objToLocalTS({
|
|
year,
|
|
month,
|
|
day,
|
|
hour: adjustedHour,
|
|
minute,
|
|
second,
|
|
millisecond: 0
|
|
});
|
|
var asTS = +date;
|
|
var over = asTS % 1e3;
|
|
asTS -= over >= 0 ? over : 1e3 + over;
|
|
return (asUTC - asTS) / (60 * 1e3);
|
|
};
|
|
_proto.equals = function equals(otherZone) {
|
|
return otherZone.type === "iana" && otherZone.name === this.name;
|
|
};
|
|
_createClass(IANAZone2, [{
|
|
key: "type",
|
|
get: function get() {
|
|
return "iana";
|
|
}
|
|
}, {
|
|
key: "name",
|
|
get: function get() {
|
|
return this.zoneName;
|
|
}
|
|
}, {
|
|
key: "isUniversal",
|
|
get: function get() {
|
|
return false;
|
|
}
|
|
}, {
|
|
key: "isValid",
|
|
get: function get() {
|
|
return this.valid;
|
|
}
|
|
}]);
|
|
return IANAZone2;
|
|
}(Zone);
|
|
var singleton = null;
|
|
var FixedOffsetZone = /* @__PURE__ */ function(_Zone) {
|
|
_inheritsLoose(FixedOffsetZone2, _Zone);
|
|
FixedOffsetZone2.instance = function instance(offset2) {
|
|
return offset2 === 0 ? FixedOffsetZone2.utcInstance : new FixedOffsetZone2(offset2);
|
|
};
|
|
FixedOffsetZone2.parseSpecifier = function parseSpecifier(s4) {
|
|
if (s4) {
|
|
var r3 = s4.match(/^utc(?:([+-]\d{1,2})(?::(\d{2}))?)?$/i);
|
|
if (r3) {
|
|
return new FixedOffsetZone2(signedOffset(r3[1], r3[2]));
|
|
}
|
|
}
|
|
return null;
|
|
};
|
|
function FixedOffsetZone2(offset2) {
|
|
var _this;
|
|
_this = _Zone.call(this) || this;
|
|
_this.fixed = offset2;
|
|
return _this;
|
|
}
|
|
var _proto = FixedOffsetZone2.prototype;
|
|
_proto.offsetName = function offsetName() {
|
|
return this.name;
|
|
};
|
|
_proto.formatOffset = function formatOffset$1(ts, format) {
|
|
return formatOffset(this.fixed, format);
|
|
};
|
|
_proto.offset = function offset2() {
|
|
return this.fixed;
|
|
};
|
|
_proto.equals = function equals(otherZone) {
|
|
return otherZone.type === "fixed" && otherZone.fixed === this.fixed;
|
|
};
|
|
_createClass(FixedOffsetZone2, [{
|
|
key: "type",
|
|
get: function get() {
|
|
return "fixed";
|
|
}
|
|
}, {
|
|
key: "name",
|
|
get: function get() {
|
|
return this.fixed === 0 ? "UTC" : "UTC" + formatOffset(this.fixed, "narrow");
|
|
}
|
|
}, {
|
|
key: "isUniversal",
|
|
get: function get() {
|
|
return true;
|
|
}
|
|
}, {
|
|
key: "isValid",
|
|
get: function get() {
|
|
return true;
|
|
}
|
|
}], [{
|
|
key: "utcInstance",
|
|
get: function get() {
|
|
if (singleton === null) {
|
|
singleton = new FixedOffsetZone2(0);
|
|
}
|
|
return singleton;
|
|
}
|
|
}]);
|
|
return FixedOffsetZone2;
|
|
}(Zone);
|
|
var InvalidZone = /* @__PURE__ */ function(_Zone) {
|
|
_inheritsLoose(InvalidZone2, _Zone);
|
|
function InvalidZone2(zoneName) {
|
|
var _this;
|
|
_this = _Zone.call(this) || this;
|
|
_this.zoneName = zoneName;
|
|
return _this;
|
|
}
|
|
var _proto = InvalidZone2.prototype;
|
|
_proto.offsetName = function offsetName() {
|
|
return null;
|
|
};
|
|
_proto.formatOffset = function formatOffset2() {
|
|
return "";
|
|
};
|
|
_proto.offset = function offset2() {
|
|
return NaN;
|
|
};
|
|
_proto.equals = function equals() {
|
|
return false;
|
|
};
|
|
_createClass(InvalidZone2, [{
|
|
key: "type",
|
|
get: function get() {
|
|
return "invalid";
|
|
}
|
|
}, {
|
|
key: "name",
|
|
get: function get() {
|
|
return this.zoneName;
|
|
}
|
|
}, {
|
|
key: "isUniversal",
|
|
get: function get() {
|
|
return false;
|
|
}
|
|
}, {
|
|
key: "isValid",
|
|
get: function get() {
|
|
return false;
|
|
}
|
|
}]);
|
|
return InvalidZone2;
|
|
}(Zone);
|
|
function normalizeZone(input, defaultZone2) {
|
|
if (isUndefined(input) || input === null) {
|
|
return defaultZone2;
|
|
} else if (input instanceof Zone) {
|
|
return input;
|
|
} else if (isString(input)) {
|
|
var lowered = input.toLowerCase();
|
|
if (lowered === "local" || lowered === "system")
|
|
return defaultZone2;
|
|
else if (lowered === "utc" || lowered === "gmt")
|
|
return FixedOffsetZone.utcInstance;
|
|
else
|
|
return FixedOffsetZone.parseSpecifier(lowered) || IANAZone.create(input);
|
|
} else if (isNumber(input)) {
|
|
return FixedOffsetZone.instance(input);
|
|
} else if (typeof input === "object" && input.offset && typeof input.offset === "number") {
|
|
return input;
|
|
} else {
|
|
return new InvalidZone(input);
|
|
}
|
|
}
|
|
var now = function now2() {
|
|
return Date.now();
|
|
};
|
|
var defaultZone = "system";
|
|
var defaultLocale = null;
|
|
var defaultNumberingSystem = null;
|
|
var defaultOutputCalendar = null;
|
|
var throwOnInvalid;
|
|
var Settings = /* @__PURE__ */ function() {
|
|
function Settings2() {
|
|
}
|
|
Settings2.resetCaches = function resetCaches() {
|
|
Locale.resetCache();
|
|
IANAZone.resetCache();
|
|
};
|
|
_createClass(Settings2, null, [{
|
|
key: "now",
|
|
get: function get() {
|
|
return now;
|
|
},
|
|
set: function set(n3) {
|
|
now = n3;
|
|
}
|
|
}, {
|
|
key: "defaultZone",
|
|
get: function get() {
|
|
return normalizeZone(defaultZone, SystemZone.instance);
|
|
},
|
|
set: function set(zone) {
|
|
defaultZone = zone;
|
|
}
|
|
}, {
|
|
key: "defaultLocale",
|
|
get: function get() {
|
|
return defaultLocale;
|
|
},
|
|
set: function set(locale) {
|
|
defaultLocale = locale;
|
|
}
|
|
}, {
|
|
key: "defaultNumberingSystem",
|
|
get: function get() {
|
|
return defaultNumberingSystem;
|
|
},
|
|
set: function set(numberingSystem) {
|
|
defaultNumberingSystem = numberingSystem;
|
|
}
|
|
}, {
|
|
key: "defaultOutputCalendar",
|
|
get: function get() {
|
|
return defaultOutputCalendar;
|
|
},
|
|
set: function set(outputCalendar) {
|
|
defaultOutputCalendar = outputCalendar;
|
|
}
|
|
}, {
|
|
key: "throwOnInvalid",
|
|
get: function get() {
|
|
return throwOnInvalid;
|
|
},
|
|
set: function set(t3) {
|
|
throwOnInvalid = t3;
|
|
}
|
|
}]);
|
|
return Settings2;
|
|
}();
|
|
var _excluded = ["base"];
|
|
var _excluded2 = ["padTo", "floor"];
|
|
var intlLFCache = {};
|
|
function getCachedLF(locString, opts) {
|
|
if (opts === void 0) {
|
|
opts = {};
|
|
}
|
|
var key = JSON.stringify([locString, opts]);
|
|
var dtf = intlLFCache[key];
|
|
if (!dtf) {
|
|
dtf = new Intl.ListFormat(locString, opts);
|
|
intlLFCache[key] = dtf;
|
|
}
|
|
return dtf;
|
|
}
|
|
var intlDTCache = {};
|
|
function getCachedDTF(locString, opts) {
|
|
if (opts === void 0) {
|
|
opts = {};
|
|
}
|
|
var key = JSON.stringify([locString, opts]);
|
|
var dtf = intlDTCache[key];
|
|
if (!dtf) {
|
|
dtf = new Intl.DateTimeFormat(locString, opts);
|
|
intlDTCache[key] = dtf;
|
|
}
|
|
return dtf;
|
|
}
|
|
var intlNumCache = {};
|
|
function getCachedINF(locString, opts) {
|
|
if (opts === void 0) {
|
|
opts = {};
|
|
}
|
|
var key = JSON.stringify([locString, opts]);
|
|
var inf = intlNumCache[key];
|
|
if (!inf) {
|
|
inf = new Intl.NumberFormat(locString, opts);
|
|
intlNumCache[key] = inf;
|
|
}
|
|
return inf;
|
|
}
|
|
var intlRelCache = {};
|
|
function getCachedRTF(locString, opts) {
|
|
if (opts === void 0) {
|
|
opts = {};
|
|
}
|
|
var _opts = opts;
|
|
_opts.base;
|
|
var cacheKeyOpts = _objectWithoutPropertiesLoose(_opts, _excluded);
|
|
var key = JSON.stringify([locString, cacheKeyOpts]);
|
|
var inf = intlRelCache[key];
|
|
if (!inf) {
|
|
inf = new Intl.RelativeTimeFormat(locString, opts);
|
|
intlRelCache[key] = inf;
|
|
}
|
|
return inf;
|
|
}
|
|
var sysLocaleCache = null;
|
|
function systemLocale() {
|
|
if (sysLocaleCache) {
|
|
return sysLocaleCache;
|
|
} else {
|
|
sysLocaleCache = new Intl.DateTimeFormat().resolvedOptions().locale;
|
|
return sysLocaleCache;
|
|
}
|
|
}
|
|
function parseLocaleString(localeStr) {
|
|
var uIndex = localeStr.indexOf("-u-");
|
|
if (uIndex === -1) {
|
|
return [localeStr];
|
|
} else {
|
|
var options;
|
|
var smaller = localeStr.substring(0, uIndex);
|
|
try {
|
|
options = getCachedDTF(localeStr).resolvedOptions();
|
|
} catch (e3) {
|
|
options = getCachedDTF(smaller).resolvedOptions();
|
|
}
|
|
var _options = options, numberingSystem = _options.numberingSystem, calendar = _options.calendar;
|
|
return [smaller, numberingSystem, calendar];
|
|
}
|
|
}
|
|
function intlConfigString(localeStr, numberingSystem, outputCalendar) {
|
|
if (outputCalendar || numberingSystem) {
|
|
localeStr += "-u";
|
|
if (outputCalendar) {
|
|
localeStr += "-ca-" + outputCalendar;
|
|
}
|
|
if (numberingSystem) {
|
|
localeStr += "-nu-" + numberingSystem;
|
|
}
|
|
return localeStr;
|
|
} else {
|
|
return localeStr;
|
|
}
|
|
}
|
|
function mapMonths(f3) {
|
|
var ms = [];
|
|
for (var i3 = 1; i3 <= 12; i3++) {
|
|
var dt = DateTime3.utc(2016, i3, 1);
|
|
ms.push(f3(dt));
|
|
}
|
|
return ms;
|
|
}
|
|
function mapWeekdays(f3) {
|
|
var ms = [];
|
|
for (var i3 = 1; i3 <= 7; i3++) {
|
|
var dt = DateTime3.utc(2016, 11, 13 + i3);
|
|
ms.push(f3(dt));
|
|
}
|
|
return ms;
|
|
}
|
|
function listStuff(loc, length, defaultOK, englishFn, intlFn) {
|
|
var mode = loc.listingMode(defaultOK);
|
|
if (mode === "error") {
|
|
return null;
|
|
} else if (mode === "en") {
|
|
return englishFn(length);
|
|
} else {
|
|
return intlFn(length);
|
|
}
|
|
}
|
|
function supportsFastNumbers(loc) {
|
|
if (loc.numberingSystem && loc.numberingSystem !== "latn") {
|
|
return false;
|
|
} else {
|
|
return loc.numberingSystem === "latn" || !loc.locale || loc.locale.startsWith("en") || new Intl.DateTimeFormat(loc.intl).resolvedOptions().numberingSystem === "latn";
|
|
}
|
|
}
|
|
var PolyNumberFormatter = /* @__PURE__ */ function() {
|
|
function PolyNumberFormatter2(intl, forceSimple, opts) {
|
|
this.padTo = opts.padTo || 0;
|
|
this.floor = opts.floor || false;
|
|
opts.padTo;
|
|
opts.floor;
|
|
var otherOpts = _objectWithoutPropertiesLoose(opts, _excluded2);
|
|
if (!forceSimple || Object.keys(otherOpts).length > 0) {
|
|
var intlOpts = _extends({
|
|
useGrouping: false
|
|
}, opts);
|
|
if (opts.padTo > 0)
|
|
intlOpts.minimumIntegerDigits = opts.padTo;
|
|
this.inf = getCachedINF(intl, intlOpts);
|
|
}
|
|
}
|
|
var _proto = PolyNumberFormatter2.prototype;
|
|
_proto.format = function format(i3) {
|
|
if (this.inf) {
|
|
var fixed = this.floor ? Math.floor(i3) : i3;
|
|
return this.inf.format(fixed);
|
|
} else {
|
|
var _fixed = this.floor ? Math.floor(i3) : roundTo(i3, 3);
|
|
return padStart2(_fixed, this.padTo);
|
|
}
|
|
};
|
|
return PolyNumberFormatter2;
|
|
}();
|
|
var PolyDateFormatter = /* @__PURE__ */ function() {
|
|
function PolyDateFormatter2(dt, intl, opts) {
|
|
this.opts = opts;
|
|
var z3;
|
|
if (dt.zone.isUniversal) {
|
|
var gmtOffset = -1 * (dt.offset / 60);
|
|
var offsetZ = gmtOffset >= 0 ? "Etc/GMT+" + gmtOffset : "Etc/GMT" + gmtOffset;
|
|
if (dt.offset !== 0 && IANAZone.create(offsetZ).valid) {
|
|
z3 = offsetZ;
|
|
this.dt = dt;
|
|
} else {
|
|
z3 = "UTC";
|
|
if (opts.timeZoneName) {
|
|
this.dt = dt;
|
|
} else {
|
|
this.dt = dt.offset === 0 ? dt : DateTime3.fromMillis(dt.ts + dt.offset * 60 * 1e3);
|
|
}
|
|
}
|
|
} else if (dt.zone.type === "system") {
|
|
this.dt = dt;
|
|
} else {
|
|
this.dt = dt;
|
|
z3 = dt.zone.name;
|
|
}
|
|
var intlOpts = _extends({}, this.opts);
|
|
if (z3) {
|
|
intlOpts.timeZone = z3;
|
|
}
|
|
this.dtf = getCachedDTF(intl, intlOpts);
|
|
}
|
|
var _proto2 = PolyDateFormatter2.prototype;
|
|
_proto2.format = function format() {
|
|
return this.dtf.format(this.dt.toJSDate());
|
|
};
|
|
_proto2.formatToParts = function formatToParts() {
|
|
return this.dtf.formatToParts(this.dt.toJSDate());
|
|
};
|
|
_proto2.resolvedOptions = function resolvedOptions() {
|
|
return this.dtf.resolvedOptions();
|
|
};
|
|
return PolyDateFormatter2;
|
|
}();
|
|
var PolyRelFormatter = /* @__PURE__ */ function() {
|
|
function PolyRelFormatter2(intl, isEnglish, opts) {
|
|
this.opts = _extends({
|
|
style: "long"
|
|
}, opts);
|
|
if (!isEnglish && hasRelative()) {
|
|
this.rtf = getCachedRTF(intl, opts);
|
|
}
|
|
}
|
|
var _proto3 = PolyRelFormatter2.prototype;
|
|
_proto3.format = function format(count, unit) {
|
|
if (this.rtf) {
|
|
return this.rtf.format(count, unit);
|
|
} else {
|
|
return formatRelativeTime(unit, count, this.opts.numeric, this.opts.style !== "long");
|
|
}
|
|
};
|
|
_proto3.formatToParts = function formatToParts(count, unit) {
|
|
if (this.rtf) {
|
|
return this.rtf.formatToParts(count, unit);
|
|
} else {
|
|
return [];
|
|
}
|
|
};
|
|
return PolyRelFormatter2;
|
|
}();
|
|
var Locale = /* @__PURE__ */ function() {
|
|
Locale2.fromOpts = function fromOpts(opts) {
|
|
return Locale2.create(opts.locale, opts.numberingSystem, opts.outputCalendar, opts.defaultToEN);
|
|
};
|
|
Locale2.create = function create(locale, numberingSystem, outputCalendar, defaultToEN) {
|
|
if (defaultToEN === void 0) {
|
|
defaultToEN = false;
|
|
}
|
|
var specifiedLocale = locale || Settings.defaultLocale;
|
|
var localeR = specifiedLocale || (defaultToEN ? "en-US" : systemLocale());
|
|
var numberingSystemR = numberingSystem || Settings.defaultNumberingSystem;
|
|
var outputCalendarR = outputCalendar || Settings.defaultOutputCalendar;
|
|
return new Locale2(localeR, numberingSystemR, outputCalendarR, specifiedLocale);
|
|
};
|
|
Locale2.resetCache = function resetCache() {
|
|
sysLocaleCache = null;
|
|
intlDTCache = {};
|
|
intlNumCache = {};
|
|
intlRelCache = {};
|
|
};
|
|
Locale2.fromObject = function fromObject(_temp) {
|
|
var _ref = _temp === void 0 ? {} : _temp, locale = _ref.locale, numberingSystem = _ref.numberingSystem, outputCalendar = _ref.outputCalendar;
|
|
return Locale2.create(locale, numberingSystem, outputCalendar);
|
|
};
|
|
function Locale2(locale, numbering, outputCalendar, specifiedLocale) {
|
|
var _parseLocaleString = parseLocaleString(locale), parsedLocale = _parseLocaleString[0], parsedNumberingSystem = _parseLocaleString[1], parsedOutputCalendar = _parseLocaleString[2];
|
|
this.locale = parsedLocale;
|
|
this.numberingSystem = numbering || parsedNumberingSystem || null;
|
|
this.outputCalendar = outputCalendar || parsedOutputCalendar || null;
|
|
this.intl = intlConfigString(this.locale, this.numberingSystem, this.outputCalendar);
|
|
this.weekdaysCache = {
|
|
format: {},
|
|
standalone: {}
|
|
};
|
|
this.monthsCache = {
|
|
format: {},
|
|
standalone: {}
|
|
};
|
|
this.meridiemCache = null;
|
|
this.eraCache = {};
|
|
this.specifiedLocale = specifiedLocale;
|
|
this.fastNumbersCached = null;
|
|
}
|
|
var _proto4 = Locale2.prototype;
|
|
_proto4.listingMode = function listingMode() {
|
|
var isActuallyEn = this.isEnglish();
|
|
var hasNoWeirdness = (this.numberingSystem === null || this.numberingSystem === "latn") && (this.outputCalendar === null || this.outputCalendar === "gregory");
|
|
return isActuallyEn && hasNoWeirdness ? "en" : "intl";
|
|
};
|
|
_proto4.clone = function clone2(alts) {
|
|
if (!alts || Object.getOwnPropertyNames(alts).length === 0) {
|
|
return this;
|
|
} else {
|
|
return Locale2.create(alts.locale || this.specifiedLocale, alts.numberingSystem || this.numberingSystem, alts.outputCalendar || this.outputCalendar, alts.defaultToEN || false);
|
|
}
|
|
};
|
|
_proto4.redefaultToEN = function redefaultToEN(alts) {
|
|
if (alts === void 0) {
|
|
alts = {};
|
|
}
|
|
return this.clone(_extends({}, alts, {
|
|
defaultToEN: true
|
|
}));
|
|
};
|
|
_proto4.redefaultToSystem = function redefaultToSystem(alts) {
|
|
if (alts === void 0) {
|
|
alts = {};
|
|
}
|
|
return this.clone(_extends({}, alts, {
|
|
defaultToEN: false
|
|
}));
|
|
};
|
|
_proto4.months = function months$1(length, format, defaultOK) {
|
|
var _this = this;
|
|
if (format === void 0) {
|
|
format = false;
|
|
}
|
|
if (defaultOK === void 0) {
|
|
defaultOK = true;
|
|
}
|
|
return listStuff(this, length, defaultOK, months, function() {
|
|
var intl = format ? {
|
|
month: length,
|
|
day: "numeric"
|
|
} : {
|
|
month: length
|
|
}, formatStr = format ? "format" : "standalone";
|
|
if (!_this.monthsCache[formatStr][length]) {
|
|
_this.monthsCache[formatStr][length] = mapMonths(function(dt) {
|
|
return _this.extract(dt, intl, "month");
|
|
});
|
|
}
|
|
return _this.monthsCache[formatStr][length];
|
|
});
|
|
};
|
|
_proto4.weekdays = function weekdays$1(length, format, defaultOK) {
|
|
var _this2 = this;
|
|
if (format === void 0) {
|
|
format = false;
|
|
}
|
|
if (defaultOK === void 0) {
|
|
defaultOK = true;
|
|
}
|
|
return listStuff(this, length, defaultOK, weekdays, function() {
|
|
var intl = format ? {
|
|
weekday: length,
|
|
year: "numeric",
|
|
month: "long",
|
|
day: "numeric"
|
|
} : {
|
|
weekday: length
|
|
}, formatStr = format ? "format" : "standalone";
|
|
if (!_this2.weekdaysCache[formatStr][length]) {
|
|
_this2.weekdaysCache[formatStr][length] = mapWeekdays(function(dt) {
|
|
return _this2.extract(dt, intl, "weekday");
|
|
});
|
|
}
|
|
return _this2.weekdaysCache[formatStr][length];
|
|
});
|
|
};
|
|
_proto4.meridiems = function meridiems$1(defaultOK) {
|
|
var _this3 = this;
|
|
if (defaultOK === void 0) {
|
|
defaultOK = true;
|
|
}
|
|
return listStuff(this, void 0, defaultOK, function() {
|
|
return meridiems;
|
|
}, function() {
|
|
if (!_this3.meridiemCache) {
|
|
var intl = {
|
|
hour: "numeric",
|
|
hourCycle: "h12"
|
|
};
|
|
_this3.meridiemCache = [DateTime3.utc(2016, 11, 13, 9), DateTime3.utc(2016, 11, 13, 19)].map(function(dt) {
|
|
return _this3.extract(dt, intl, "dayperiod");
|
|
});
|
|
}
|
|
return _this3.meridiemCache;
|
|
});
|
|
};
|
|
_proto4.eras = function eras$1(length, defaultOK) {
|
|
var _this4 = this;
|
|
if (defaultOK === void 0) {
|
|
defaultOK = true;
|
|
}
|
|
return listStuff(this, length, defaultOK, eras, function() {
|
|
var intl = {
|
|
era: length
|
|
};
|
|
if (!_this4.eraCache[length]) {
|
|
_this4.eraCache[length] = [DateTime3.utc(-40, 1, 1), DateTime3.utc(2017, 1, 1)].map(function(dt) {
|
|
return _this4.extract(dt, intl, "era");
|
|
});
|
|
}
|
|
return _this4.eraCache[length];
|
|
});
|
|
};
|
|
_proto4.extract = function extract(dt, intlOpts, field) {
|
|
var df = this.dtFormatter(dt, intlOpts), results = df.formatToParts(), matching = results.find(function(m2) {
|
|
return m2.type.toLowerCase() === field;
|
|
});
|
|
return matching ? matching.value : null;
|
|
};
|
|
_proto4.numberFormatter = function numberFormatter(opts) {
|
|
if (opts === void 0) {
|
|
opts = {};
|
|
}
|
|
return new PolyNumberFormatter(this.intl, opts.forceSimple || this.fastNumbers, opts);
|
|
};
|
|
_proto4.dtFormatter = function dtFormatter(dt, intlOpts) {
|
|
if (intlOpts === void 0) {
|
|
intlOpts = {};
|
|
}
|
|
return new PolyDateFormatter(dt, this.intl, intlOpts);
|
|
};
|
|
_proto4.relFormatter = function relFormatter(opts) {
|
|
if (opts === void 0) {
|
|
opts = {};
|
|
}
|
|
return new PolyRelFormatter(this.intl, this.isEnglish(), opts);
|
|
};
|
|
_proto4.listFormatter = function listFormatter(opts) {
|
|
if (opts === void 0) {
|
|
opts = {};
|
|
}
|
|
return getCachedLF(this.intl, opts);
|
|
};
|
|
_proto4.isEnglish = function isEnglish() {
|
|
return this.locale === "en" || this.locale.toLowerCase() === "en-us" || new Intl.DateTimeFormat(this.intl).resolvedOptions().locale.startsWith("en-us");
|
|
};
|
|
_proto4.equals = function equals(other) {
|
|
return this.locale === other.locale && this.numberingSystem === other.numberingSystem && this.outputCalendar === other.outputCalendar;
|
|
};
|
|
_createClass(Locale2, [{
|
|
key: "fastNumbers",
|
|
get: function get() {
|
|
if (this.fastNumbersCached == null) {
|
|
this.fastNumbersCached = supportsFastNumbers(this);
|
|
}
|
|
return this.fastNumbersCached;
|
|
}
|
|
}]);
|
|
return Locale2;
|
|
}();
|
|
function combineRegexes() {
|
|
for (var _len = arguments.length, regexes = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
regexes[_key] = arguments[_key];
|
|
}
|
|
var full = regexes.reduce(function(f3, r3) {
|
|
return f3 + r3.source;
|
|
}, "");
|
|
return RegExp("^" + full + "$");
|
|
}
|
|
function combineExtractors() {
|
|
for (var _len2 = arguments.length, extractors = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
extractors[_key2] = arguments[_key2];
|
|
}
|
|
return function(m2) {
|
|
return extractors.reduce(function(_ref, ex) {
|
|
var mergedVals = _ref[0], mergedZone = _ref[1], cursor = _ref[2];
|
|
var _ex = ex(m2, cursor), val = _ex[0], zone = _ex[1], next = _ex[2];
|
|
return [_extends({}, mergedVals, val), mergedZone || zone, next];
|
|
}, [{}, null, 1]).slice(0, 2);
|
|
};
|
|
}
|
|
function parse4(s4) {
|
|
if (s4 == null) {
|
|
return [null, null];
|
|
}
|
|
for (var _len3 = arguments.length, patterns = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) {
|
|
patterns[_key3 - 1] = arguments[_key3];
|
|
}
|
|
for (var _i = 0, _patterns = patterns; _i < _patterns.length; _i++) {
|
|
var _patterns$_i = _patterns[_i], regex = _patterns$_i[0], extractor = _patterns$_i[1];
|
|
var m2 = regex.exec(s4);
|
|
if (m2) {
|
|
return extractor(m2);
|
|
}
|
|
}
|
|
return [null, null];
|
|
}
|
|
function simpleParse() {
|
|
for (var _len4 = arguments.length, keys = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
|
|
keys[_key4] = arguments[_key4];
|
|
}
|
|
return function(match2, cursor) {
|
|
var ret = {};
|
|
var i3;
|
|
for (i3 = 0; i3 < keys.length; i3++) {
|
|
ret[keys[i3]] = parseInteger(match2[cursor + i3]);
|
|
}
|
|
return [ret, null, cursor + i3];
|
|
};
|
|
}
|
|
var offsetRegex = /(?:(Z)|([+-]\d\d)(?::?(\d\d))?)/;
|
|
var isoTimeBaseRegex = /(\d\d)(?::?(\d\d)(?::?(\d\d)(?:[.,](\d{1,30}))?)?)?/;
|
|
var isoTimeRegex = RegExp("" + isoTimeBaseRegex.source + offsetRegex.source + "?");
|
|
var isoTimeExtensionRegex = RegExp("(?:T" + isoTimeRegex.source + ")?");
|
|
var isoYmdRegex = /([+-]\d{6}|\d{4})(?:-?(\d\d)(?:-?(\d\d))?)?/;
|
|
var isoWeekRegex = /(\d{4})-?W(\d\d)(?:-?(\d))?/;
|
|
var isoOrdinalRegex = /(\d{4})-?(\d{3})/;
|
|
var extractISOWeekData = simpleParse("weekYear", "weekNumber", "weekDay");
|
|
var extractISOOrdinalData = simpleParse("year", "ordinal");
|
|
var sqlYmdRegex = /(\d{4})-(\d\d)-(\d\d)/;
|
|
var sqlTimeRegex = RegExp(isoTimeBaseRegex.source + " ?(?:" + offsetRegex.source + "|(" + ianaRegex.source + "))?");
|
|
var sqlTimeExtensionRegex = RegExp("(?: " + sqlTimeRegex.source + ")?");
|
|
function int(match2, pos, fallback) {
|
|
var m2 = match2[pos];
|
|
return isUndefined(m2) ? fallback : parseInteger(m2);
|
|
}
|
|
function extractISOYmd(match2, cursor) {
|
|
var item = {
|
|
year: int(match2, cursor),
|
|
month: int(match2, cursor + 1, 1),
|
|
day: int(match2, cursor + 2, 1)
|
|
};
|
|
return [item, null, cursor + 3];
|
|
}
|
|
function extractISOTime(match2, cursor) {
|
|
var item = {
|
|
hours: int(match2, cursor, 0),
|
|
minutes: int(match2, cursor + 1, 0),
|
|
seconds: int(match2, cursor + 2, 0),
|
|
milliseconds: parseMillis(match2[cursor + 3])
|
|
};
|
|
return [item, null, cursor + 4];
|
|
}
|
|
function extractISOOffset(match2, cursor) {
|
|
var local = !match2[cursor] && !match2[cursor + 1], fullOffset = signedOffset(match2[cursor + 1], match2[cursor + 2]), zone = local ? null : FixedOffsetZone.instance(fullOffset);
|
|
return [{}, zone, cursor + 3];
|
|
}
|
|
function extractIANAZone(match2, cursor) {
|
|
var zone = match2[cursor] ? IANAZone.create(match2[cursor]) : null;
|
|
return [{}, zone, cursor + 1];
|
|
}
|
|
var isoTimeOnly = RegExp("^T?" + isoTimeBaseRegex.source + "$");
|
|
var isoDuration = /^-?P(?:(?:(-?\d{1,9}(?:\.\d{1,9})?)Y)?(?:(-?\d{1,9}(?:\.\d{1,9})?)M)?(?:(-?\d{1,9}(?:\.\d{1,9})?)W)?(?:(-?\d{1,9}(?:\.\d{1,9})?)D)?(?:T(?:(-?\d{1,9}(?:\.\d{1,9})?)H)?(?:(-?\d{1,9}(?:\.\d{1,9})?)M)?(?:(-?\d{1,20})(?:[.,](-?\d{1,9}))?S)?)?)$/;
|
|
function extractISODuration(match2) {
|
|
var s4 = match2[0], yearStr = match2[1], monthStr = match2[2], weekStr = match2[3], dayStr = match2[4], hourStr = match2[5], minuteStr = match2[6], secondStr = match2[7], millisecondsStr = match2[8];
|
|
var hasNegativePrefix = s4[0] === "-";
|
|
var negativeSeconds = secondStr && secondStr[0] === "-";
|
|
var maybeNegate = function maybeNegate2(num, force) {
|
|
if (force === void 0) {
|
|
force = false;
|
|
}
|
|
return num !== void 0 && (force || num && hasNegativePrefix) ? -num : num;
|
|
};
|
|
return [{
|
|
years: maybeNegate(parseFloating(yearStr)),
|
|
months: maybeNegate(parseFloating(monthStr)),
|
|
weeks: maybeNegate(parseFloating(weekStr)),
|
|
days: maybeNegate(parseFloating(dayStr)),
|
|
hours: maybeNegate(parseFloating(hourStr)),
|
|
minutes: maybeNegate(parseFloating(minuteStr)),
|
|
seconds: maybeNegate(parseFloating(secondStr), secondStr === "-0"),
|
|
milliseconds: maybeNegate(parseMillis(millisecondsStr), negativeSeconds)
|
|
}];
|
|
}
|
|
var obsOffsets = {
|
|
GMT: 0,
|
|
EDT: -4 * 60,
|
|
EST: -5 * 60,
|
|
CDT: -5 * 60,
|
|
CST: -6 * 60,
|
|
MDT: -6 * 60,
|
|
MST: -7 * 60,
|
|
PDT: -7 * 60,
|
|
PST: -8 * 60
|
|
};
|
|
function fromStrings(weekdayStr, yearStr, monthStr, dayStr, hourStr, minuteStr, secondStr) {
|
|
var result = {
|
|
year: yearStr.length === 2 ? untruncateYear(parseInteger(yearStr)) : parseInteger(yearStr),
|
|
month: monthsShort.indexOf(monthStr) + 1,
|
|
day: parseInteger(dayStr),
|
|
hour: parseInteger(hourStr),
|
|
minute: parseInteger(minuteStr)
|
|
};
|
|
if (secondStr)
|
|
result.second = parseInteger(secondStr);
|
|
if (weekdayStr) {
|
|
result.weekday = weekdayStr.length > 3 ? weekdaysLong.indexOf(weekdayStr) + 1 : weekdaysShort.indexOf(weekdayStr) + 1;
|
|
}
|
|
return result;
|
|
}
|
|
var rfc2822 = /^(?:(Mon|Tue|Wed|Thu|Fri|Sat|Sun),\s)?(\d{1,2})\s(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s(\d{2,4})\s(\d\d):(\d\d)(?::(\d\d))?\s(?:(UT|GMT|[ECMP][SD]T)|([Zz])|(?:([+-]\d\d)(\d\d)))$/;
|
|
function extractRFC2822(match2) {
|
|
var weekdayStr = match2[1], dayStr = match2[2], monthStr = match2[3], yearStr = match2[4], hourStr = match2[5], minuteStr = match2[6], secondStr = match2[7], obsOffset = match2[8], milOffset = match2[9], offHourStr = match2[10], offMinuteStr = match2[11], result = fromStrings(weekdayStr, yearStr, monthStr, dayStr, hourStr, minuteStr, secondStr);
|
|
var offset2;
|
|
if (obsOffset) {
|
|
offset2 = obsOffsets[obsOffset];
|
|
} else if (milOffset) {
|
|
offset2 = 0;
|
|
} else {
|
|
offset2 = signedOffset(offHourStr, offMinuteStr);
|
|
}
|
|
return [result, new FixedOffsetZone(offset2)];
|
|
}
|
|
function preprocessRFC2822(s4) {
|
|
return s4.replace(/\([^)]*\)|[\n\t]/g, " ").replace(/(\s\s+)/g, " ").trim();
|
|
}
|
|
var rfc1123 = /^(Mon|Tue|Wed|Thu|Fri|Sat|Sun), (\d\d) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) (\d{4}) (\d\d):(\d\d):(\d\d) GMT$/;
|
|
var rfc850 = /^(Monday|Tuesday|Wedsday|Thursday|Friday|Saturday|Sunday), (\d\d)-(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)-(\d\d) (\d\d):(\d\d):(\d\d) GMT$/;
|
|
var ascii = /^(Mon|Tue|Wed|Thu|Fri|Sat|Sun) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) ( \d|\d\d) (\d\d):(\d\d):(\d\d) (\d{4})$/;
|
|
function extractRFC1123Or850(match2) {
|
|
var weekdayStr = match2[1], dayStr = match2[2], monthStr = match2[3], yearStr = match2[4], hourStr = match2[5], minuteStr = match2[6], secondStr = match2[7], result = fromStrings(weekdayStr, yearStr, monthStr, dayStr, hourStr, minuteStr, secondStr);
|
|
return [result, FixedOffsetZone.utcInstance];
|
|
}
|
|
function extractASCII(match2) {
|
|
var weekdayStr = match2[1], monthStr = match2[2], dayStr = match2[3], hourStr = match2[4], minuteStr = match2[5], secondStr = match2[6], yearStr = match2[7], result = fromStrings(weekdayStr, yearStr, monthStr, dayStr, hourStr, minuteStr, secondStr);
|
|
return [result, FixedOffsetZone.utcInstance];
|
|
}
|
|
var isoYmdWithTimeExtensionRegex = combineRegexes(isoYmdRegex, isoTimeExtensionRegex);
|
|
var isoWeekWithTimeExtensionRegex = combineRegexes(isoWeekRegex, isoTimeExtensionRegex);
|
|
var isoOrdinalWithTimeExtensionRegex = combineRegexes(isoOrdinalRegex, isoTimeExtensionRegex);
|
|
var isoTimeCombinedRegex = combineRegexes(isoTimeRegex);
|
|
var extractISOYmdTimeAndOffset = combineExtractors(extractISOYmd, extractISOTime, extractISOOffset);
|
|
var extractISOWeekTimeAndOffset = combineExtractors(extractISOWeekData, extractISOTime, extractISOOffset);
|
|
var extractISOOrdinalDateAndTime = combineExtractors(extractISOOrdinalData, extractISOTime, extractISOOffset);
|
|
var extractISOTimeAndOffset = combineExtractors(extractISOTime, extractISOOffset);
|
|
function parseISODate(s4) {
|
|
return parse4(s4, [isoYmdWithTimeExtensionRegex, extractISOYmdTimeAndOffset], [isoWeekWithTimeExtensionRegex, extractISOWeekTimeAndOffset], [isoOrdinalWithTimeExtensionRegex, extractISOOrdinalDateAndTime], [isoTimeCombinedRegex, extractISOTimeAndOffset]);
|
|
}
|
|
function parseRFC2822Date(s4) {
|
|
return parse4(preprocessRFC2822(s4), [rfc2822, extractRFC2822]);
|
|
}
|
|
function parseHTTPDate(s4) {
|
|
return parse4(s4, [rfc1123, extractRFC1123Or850], [rfc850, extractRFC1123Or850], [ascii, extractASCII]);
|
|
}
|
|
function parseISODuration(s4) {
|
|
return parse4(s4, [isoDuration, extractISODuration]);
|
|
}
|
|
var extractISOTimeOnly = combineExtractors(extractISOTime);
|
|
function parseISOTimeOnly(s4) {
|
|
return parse4(s4, [isoTimeOnly, extractISOTimeOnly]);
|
|
}
|
|
var sqlYmdWithTimeExtensionRegex = combineRegexes(sqlYmdRegex, sqlTimeExtensionRegex);
|
|
var sqlTimeCombinedRegex = combineRegexes(sqlTimeRegex);
|
|
var extractISOYmdTimeOffsetAndIANAZone = combineExtractors(extractISOYmd, extractISOTime, extractISOOffset, extractIANAZone);
|
|
var extractISOTimeOffsetAndIANAZone = combineExtractors(extractISOTime, extractISOOffset, extractIANAZone);
|
|
function parseSQL(s4) {
|
|
return parse4(s4, [sqlYmdWithTimeExtensionRegex, extractISOYmdTimeOffsetAndIANAZone], [sqlTimeCombinedRegex, extractISOTimeOffsetAndIANAZone]);
|
|
}
|
|
var INVALID$2 = "Invalid Duration";
|
|
var lowOrderMatrix = {
|
|
weeks: {
|
|
days: 7,
|
|
hours: 7 * 24,
|
|
minutes: 7 * 24 * 60,
|
|
seconds: 7 * 24 * 60 * 60,
|
|
milliseconds: 7 * 24 * 60 * 60 * 1e3
|
|
},
|
|
days: {
|
|
hours: 24,
|
|
minutes: 24 * 60,
|
|
seconds: 24 * 60 * 60,
|
|
milliseconds: 24 * 60 * 60 * 1e3
|
|
},
|
|
hours: {
|
|
minutes: 60,
|
|
seconds: 60 * 60,
|
|
milliseconds: 60 * 60 * 1e3
|
|
},
|
|
minutes: {
|
|
seconds: 60,
|
|
milliseconds: 60 * 1e3
|
|
},
|
|
seconds: {
|
|
milliseconds: 1e3
|
|
}
|
|
};
|
|
var casualMatrix = _extends({
|
|
years: {
|
|
quarters: 4,
|
|
months: 12,
|
|
weeks: 52,
|
|
days: 365,
|
|
hours: 365 * 24,
|
|
minutes: 365 * 24 * 60,
|
|
seconds: 365 * 24 * 60 * 60,
|
|
milliseconds: 365 * 24 * 60 * 60 * 1e3
|
|
},
|
|
quarters: {
|
|
months: 3,
|
|
weeks: 13,
|
|
days: 91,
|
|
hours: 91 * 24,
|
|
minutes: 91 * 24 * 60,
|
|
seconds: 91 * 24 * 60 * 60,
|
|
milliseconds: 91 * 24 * 60 * 60 * 1e3
|
|
},
|
|
months: {
|
|
weeks: 4,
|
|
days: 30,
|
|
hours: 30 * 24,
|
|
minutes: 30 * 24 * 60,
|
|
seconds: 30 * 24 * 60 * 60,
|
|
milliseconds: 30 * 24 * 60 * 60 * 1e3
|
|
}
|
|
}, lowOrderMatrix);
|
|
var daysInYearAccurate = 146097 / 400;
|
|
var daysInMonthAccurate = 146097 / 4800;
|
|
var accurateMatrix = _extends({
|
|
years: {
|
|
quarters: 4,
|
|
months: 12,
|
|
weeks: daysInYearAccurate / 7,
|
|
days: daysInYearAccurate,
|
|
hours: daysInYearAccurate * 24,
|
|
minutes: daysInYearAccurate * 24 * 60,
|
|
seconds: daysInYearAccurate * 24 * 60 * 60,
|
|
milliseconds: daysInYearAccurate * 24 * 60 * 60 * 1e3
|
|
},
|
|
quarters: {
|
|
months: 3,
|
|
weeks: daysInYearAccurate / 28,
|
|
days: daysInYearAccurate / 4,
|
|
hours: daysInYearAccurate * 24 / 4,
|
|
minutes: daysInYearAccurate * 24 * 60 / 4,
|
|
seconds: daysInYearAccurate * 24 * 60 * 60 / 4,
|
|
milliseconds: daysInYearAccurate * 24 * 60 * 60 * 1e3 / 4
|
|
},
|
|
months: {
|
|
weeks: daysInMonthAccurate / 7,
|
|
days: daysInMonthAccurate,
|
|
hours: daysInMonthAccurate * 24,
|
|
minutes: daysInMonthAccurate * 24 * 60,
|
|
seconds: daysInMonthAccurate * 24 * 60 * 60,
|
|
milliseconds: daysInMonthAccurate * 24 * 60 * 60 * 1e3
|
|
}
|
|
}, lowOrderMatrix);
|
|
var orderedUnits$1 = ["years", "quarters", "months", "weeks", "days", "hours", "minutes", "seconds", "milliseconds"];
|
|
var reverseUnits = orderedUnits$1.slice(0).reverse();
|
|
function clone$1(dur, alts, clear) {
|
|
if (clear === void 0) {
|
|
clear = false;
|
|
}
|
|
var conf = {
|
|
values: clear ? alts.values : _extends({}, dur.values, alts.values || {}),
|
|
loc: dur.loc.clone(alts.loc),
|
|
conversionAccuracy: alts.conversionAccuracy || dur.conversionAccuracy
|
|
};
|
|
return new Duration3(conf);
|
|
}
|
|
function antiTrunc(n3) {
|
|
return n3 < 0 ? Math.floor(n3) : Math.ceil(n3);
|
|
}
|
|
function convert(matrix, fromMap, fromUnit, toMap, toUnit) {
|
|
var conv = matrix[toUnit][fromUnit], raw = fromMap[fromUnit] / conv, sameSign = Math.sign(raw) === Math.sign(toMap[toUnit]), added = !sameSign && toMap[toUnit] !== 0 && Math.abs(raw) <= 1 ? antiTrunc(raw) : Math.trunc(raw);
|
|
toMap[toUnit] += added;
|
|
fromMap[fromUnit] -= added * conv;
|
|
}
|
|
function normalizeValues(matrix, vals) {
|
|
reverseUnits.reduce(function(previous, current) {
|
|
if (!isUndefined(vals[current])) {
|
|
if (previous) {
|
|
convert(matrix, vals, previous, vals, current);
|
|
}
|
|
return current;
|
|
} else {
|
|
return previous;
|
|
}
|
|
}, null);
|
|
}
|
|
var Duration3 = /* @__PURE__ */ function() {
|
|
function Duration4(config2) {
|
|
var accurate = config2.conversionAccuracy === "longterm" || false;
|
|
this.values = config2.values;
|
|
this.loc = config2.loc || Locale.create();
|
|
this.conversionAccuracy = accurate ? "longterm" : "casual";
|
|
this.invalid = config2.invalid || null;
|
|
this.matrix = accurate ? accurateMatrix : casualMatrix;
|
|
this.isLuxonDuration = true;
|
|
}
|
|
Duration4.fromMillis = function fromMillis(count, opts) {
|
|
return Duration4.fromObject({
|
|
milliseconds: count
|
|
}, opts);
|
|
};
|
|
Duration4.fromObject = function fromObject(obj, opts) {
|
|
if (opts === void 0) {
|
|
opts = {};
|
|
}
|
|
if (obj == null || typeof obj !== "object") {
|
|
throw new InvalidArgumentError("Duration.fromObject: argument expected to be an object, got " + (obj === null ? "null" : typeof obj));
|
|
}
|
|
return new Duration4({
|
|
values: normalizeObject(obj, Duration4.normalizeUnit),
|
|
loc: Locale.fromObject(opts),
|
|
conversionAccuracy: opts.conversionAccuracy
|
|
});
|
|
};
|
|
Duration4.fromDurationLike = function fromDurationLike(durationLike) {
|
|
if (isNumber(durationLike)) {
|
|
return Duration4.fromMillis(durationLike);
|
|
} else if (Duration4.isDuration(durationLike)) {
|
|
return durationLike;
|
|
} else if (typeof durationLike === "object") {
|
|
return Duration4.fromObject(durationLike);
|
|
} else {
|
|
throw new InvalidArgumentError("Unknown duration argument " + durationLike + " of type " + typeof durationLike);
|
|
}
|
|
};
|
|
Duration4.fromISO = function fromISO(text, opts) {
|
|
var _parseISODuration = parseISODuration(text), parsed = _parseISODuration[0];
|
|
if (parsed) {
|
|
return Duration4.fromObject(parsed, opts);
|
|
} else {
|
|
return Duration4.invalid("unparsable", 'the input "' + text + `" can't be parsed as ISO 8601`);
|
|
}
|
|
};
|
|
Duration4.fromISOTime = function fromISOTime(text, opts) {
|
|
var _parseISOTimeOnly = parseISOTimeOnly(text), parsed = _parseISOTimeOnly[0];
|
|
if (parsed) {
|
|
return Duration4.fromObject(parsed, opts);
|
|
} else {
|
|
return Duration4.invalid("unparsable", 'the input "' + text + `" can't be parsed as ISO 8601`);
|
|
}
|
|
};
|
|
Duration4.invalid = function invalid(reason, explanation) {
|
|
if (explanation === void 0) {
|
|
explanation = null;
|
|
}
|
|
if (!reason) {
|
|
throw new InvalidArgumentError("need to specify a reason the Duration is invalid");
|
|
}
|
|
var invalid2 = reason instanceof Invalid ? reason : new Invalid(reason, explanation);
|
|
if (Settings.throwOnInvalid) {
|
|
throw new InvalidDurationError(invalid2);
|
|
} else {
|
|
return new Duration4({
|
|
invalid: invalid2
|
|
});
|
|
}
|
|
};
|
|
Duration4.normalizeUnit = function normalizeUnit2(unit) {
|
|
var normalized = {
|
|
year: "years",
|
|
years: "years",
|
|
quarter: "quarters",
|
|
quarters: "quarters",
|
|
month: "months",
|
|
months: "months",
|
|
week: "weeks",
|
|
weeks: "weeks",
|
|
day: "days",
|
|
days: "days",
|
|
hour: "hours",
|
|
hours: "hours",
|
|
minute: "minutes",
|
|
minutes: "minutes",
|
|
second: "seconds",
|
|
seconds: "seconds",
|
|
millisecond: "milliseconds",
|
|
milliseconds: "milliseconds"
|
|
}[unit ? unit.toLowerCase() : unit];
|
|
if (!normalized)
|
|
throw new InvalidUnitError(unit);
|
|
return normalized;
|
|
};
|
|
Duration4.isDuration = function isDuration(o2) {
|
|
return o2 && o2.isLuxonDuration || false;
|
|
};
|
|
var _proto = Duration4.prototype;
|
|
_proto.toFormat = function toFormat(fmt, opts) {
|
|
if (opts === void 0) {
|
|
opts = {};
|
|
}
|
|
var fmtOpts = _extends({}, opts, {
|
|
floor: opts.round !== false && opts.floor !== false
|
|
});
|
|
return this.isValid ? Formatter.create(this.loc, fmtOpts).formatDurationFromString(this, fmt) : INVALID$2;
|
|
};
|
|
_proto.toHuman = function toHuman(opts) {
|
|
var _this = this;
|
|
if (opts === void 0) {
|
|
opts = {};
|
|
}
|
|
var l4 = orderedUnits$1.map(function(unit) {
|
|
var val = _this.values[unit];
|
|
if (isUndefined(val)) {
|
|
return null;
|
|
}
|
|
return _this.loc.numberFormatter(_extends({
|
|
style: "unit",
|
|
unitDisplay: "long"
|
|
}, opts, {
|
|
unit: unit.slice(0, -1)
|
|
})).format(val);
|
|
}).filter(function(n3) {
|
|
return n3;
|
|
});
|
|
return this.loc.listFormatter(_extends({
|
|
type: "conjunction",
|
|
style: opts.listStyle || "narrow"
|
|
}, opts)).format(l4);
|
|
};
|
|
_proto.toObject = function toObject() {
|
|
if (!this.isValid)
|
|
return {};
|
|
return _extends({}, this.values);
|
|
};
|
|
_proto.toISO = function toISO() {
|
|
if (!this.isValid)
|
|
return null;
|
|
var s4 = "P";
|
|
if (this.years !== 0)
|
|
s4 += this.years + "Y";
|
|
if (this.months !== 0 || this.quarters !== 0)
|
|
s4 += this.months + this.quarters * 3 + "M";
|
|
if (this.weeks !== 0)
|
|
s4 += this.weeks + "W";
|
|
if (this.days !== 0)
|
|
s4 += this.days + "D";
|
|
if (this.hours !== 0 || this.minutes !== 0 || this.seconds !== 0 || this.milliseconds !== 0)
|
|
s4 += "T";
|
|
if (this.hours !== 0)
|
|
s4 += this.hours + "H";
|
|
if (this.minutes !== 0)
|
|
s4 += this.minutes + "M";
|
|
if (this.seconds !== 0 || this.milliseconds !== 0)
|
|
s4 += roundTo(this.seconds + this.milliseconds / 1e3, 3) + "S";
|
|
if (s4 === "P")
|
|
s4 += "T0S";
|
|
return s4;
|
|
};
|
|
_proto.toISOTime = function toISOTime(opts) {
|
|
if (opts === void 0) {
|
|
opts = {};
|
|
}
|
|
if (!this.isValid)
|
|
return null;
|
|
var millis = this.toMillis();
|
|
if (millis < 0 || millis >= 864e5)
|
|
return null;
|
|
opts = _extends({
|
|
suppressMilliseconds: false,
|
|
suppressSeconds: false,
|
|
includePrefix: false,
|
|
format: "extended"
|
|
}, opts);
|
|
var value = this.shiftTo("hours", "minutes", "seconds", "milliseconds");
|
|
var fmt = opts.format === "basic" ? "hhmm" : "hh:mm";
|
|
if (!opts.suppressSeconds || value.seconds !== 0 || value.milliseconds !== 0) {
|
|
fmt += opts.format === "basic" ? "ss" : ":ss";
|
|
if (!opts.suppressMilliseconds || value.milliseconds !== 0) {
|
|
fmt += ".SSS";
|
|
}
|
|
}
|
|
var str = value.toFormat(fmt);
|
|
if (opts.includePrefix) {
|
|
str = "T" + str;
|
|
}
|
|
return str;
|
|
};
|
|
_proto.toJSON = function toJSON() {
|
|
return this.toISO();
|
|
};
|
|
_proto.toString = function toString() {
|
|
return this.toISO();
|
|
};
|
|
_proto.toMillis = function toMillis() {
|
|
return this.as("milliseconds");
|
|
};
|
|
_proto.valueOf = function valueOf() {
|
|
return this.toMillis();
|
|
};
|
|
_proto.plus = function plus(duration) {
|
|
if (!this.isValid)
|
|
return this;
|
|
var dur = Duration4.fromDurationLike(duration), result = {};
|
|
for (var _iterator = _createForOfIteratorHelperLoose(orderedUnits$1), _step; !(_step = _iterator()).done; ) {
|
|
var k2 = _step.value;
|
|
if (hasOwnProperty2(dur.values, k2) || hasOwnProperty2(this.values, k2)) {
|
|
result[k2] = dur.get(k2) + this.get(k2);
|
|
}
|
|
}
|
|
return clone$1(this, {
|
|
values: result
|
|
}, true);
|
|
};
|
|
_proto.minus = function minus(duration) {
|
|
if (!this.isValid)
|
|
return this;
|
|
var dur = Duration4.fromDurationLike(duration);
|
|
return this.plus(dur.negate());
|
|
};
|
|
_proto.mapUnits = function mapUnits(fn) {
|
|
if (!this.isValid)
|
|
return this;
|
|
var result = {};
|
|
for (var _i = 0, _Object$keys = Object.keys(this.values); _i < _Object$keys.length; _i++) {
|
|
var k2 = _Object$keys[_i];
|
|
result[k2] = asNumber(fn(this.values[k2], k2));
|
|
}
|
|
return clone$1(this, {
|
|
values: result
|
|
}, true);
|
|
};
|
|
_proto.get = function get(unit) {
|
|
return this[Duration4.normalizeUnit(unit)];
|
|
};
|
|
_proto.set = function set(values) {
|
|
if (!this.isValid)
|
|
return this;
|
|
var mixed = _extends({}, this.values, normalizeObject(values, Duration4.normalizeUnit));
|
|
return clone$1(this, {
|
|
values: mixed
|
|
});
|
|
};
|
|
_proto.reconfigure = function reconfigure(_temp) {
|
|
var _ref = _temp === void 0 ? {} : _temp, locale = _ref.locale, numberingSystem = _ref.numberingSystem, conversionAccuracy = _ref.conversionAccuracy;
|
|
var loc = this.loc.clone({
|
|
locale,
|
|
numberingSystem
|
|
}), opts = {
|
|
loc
|
|
};
|
|
if (conversionAccuracy) {
|
|
opts.conversionAccuracy = conversionAccuracy;
|
|
}
|
|
return clone$1(this, opts);
|
|
};
|
|
_proto.as = function as(unit) {
|
|
return this.isValid ? this.shiftTo(unit).get(unit) : NaN;
|
|
};
|
|
_proto.normalize = function normalize() {
|
|
if (!this.isValid)
|
|
return this;
|
|
var vals = this.toObject();
|
|
normalizeValues(this.matrix, vals);
|
|
return clone$1(this, {
|
|
values: vals
|
|
}, true);
|
|
};
|
|
_proto.shiftTo = function shiftTo() {
|
|
for (var _len = arguments.length, units = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
units[_key] = arguments[_key];
|
|
}
|
|
if (!this.isValid)
|
|
return this;
|
|
if (units.length === 0) {
|
|
return this;
|
|
}
|
|
units = units.map(function(u3) {
|
|
return Duration4.normalizeUnit(u3);
|
|
});
|
|
var built = {}, accumulated = {}, vals = this.toObject();
|
|
var lastUnit;
|
|
for (var _iterator2 = _createForOfIteratorHelperLoose(orderedUnits$1), _step2; !(_step2 = _iterator2()).done; ) {
|
|
var k2 = _step2.value;
|
|
if (units.indexOf(k2) >= 0) {
|
|
lastUnit = k2;
|
|
var own = 0;
|
|
for (var ak in accumulated) {
|
|
own += this.matrix[ak][k2] * accumulated[ak];
|
|
accumulated[ak] = 0;
|
|
}
|
|
if (isNumber(vals[k2])) {
|
|
own += vals[k2];
|
|
}
|
|
var i3 = Math.trunc(own);
|
|
built[k2] = i3;
|
|
accumulated[k2] = (own * 1e3 - i3 * 1e3) / 1e3;
|
|
for (var down in vals) {
|
|
if (orderedUnits$1.indexOf(down) > orderedUnits$1.indexOf(k2)) {
|
|
convert(this.matrix, vals, down, built, k2);
|
|
}
|
|
}
|
|
} else if (isNumber(vals[k2])) {
|
|
accumulated[k2] = vals[k2];
|
|
}
|
|
}
|
|
for (var key in accumulated) {
|
|
if (accumulated[key] !== 0) {
|
|
built[lastUnit] += key === lastUnit ? accumulated[key] : accumulated[key] / this.matrix[lastUnit][key];
|
|
}
|
|
}
|
|
return clone$1(this, {
|
|
values: built
|
|
}, true).normalize();
|
|
};
|
|
_proto.negate = function negate() {
|
|
if (!this.isValid)
|
|
return this;
|
|
var negated = {};
|
|
for (var _i2 = 0, _Object$keys2 = Object.keys(this.values); _i2 < _Object$keys2.length; _i2++) {
|
|
var k2 = _Object$keys2[_i2];
|
|
negated[k2] = this.values[k2] === 0 ? 0 : -this.values[k2];
|
|
}
|
|
return clone$1(this, {
|
|
values: negated
|
|
}, true);
|
|
};
|
|
_proto.equals = function equals(other) {
|
|
if (!this.isValid || !other.isValid) {
|
|
return false;
|
|
}
|
|
if (!this.loc.equals(other.loc)) {
|
|
return false;
|
|
}
|
|
function eq(v1, v22) {
|
|
if (v1 === void 0 || v1 === 0)
|
|
return v22 === void 0 || v22 === 0;
|
|
return v1 === v22;
|
|
}
|
|
for (var _iterator3 = _createForOfIteratorHelperLoose(orderedUnits$1), _step3; !(_step3 = _iterator3()).done; ) {
|
|
var u3 = _step3.value;
|
|
if (!eq(this.values[u3], other.values[u3])) {
|
|
return false;
|
|
}
|
|
}
|
|
return true;
|
|
};
|
|
_createClass(Duration4, [{
|
|
key: "locale",
|
|
get: function get() {
|
|
return this.isValid ? this.loc.locale : null;
|
|
}
|
|
}, {
|
|
key: "numberingSystem",
|
|
get: function get() {
|
|
return this.isValid ? this.loc.numberingSystem : null;
|
|
}
|
|
}, {
|
|
key: "years",
|
|
get: function get() {
|
|
return this.isValid ? this.values.years || 0 : NaN;
|
|
}
|
|
}, {
|
|
key: "quarters",
|
|
get: function get() {
|
|
return this.isValid ? this.values.quarters || 0 : NaN;
|
|
}
|
|
}, {
|
|
key: "months",
|
|
get: function get() {
|
|
return this.isValid ? this.values.months || 0 : NaN;
|
|
}
|
|
}, {
|
|
key: "weeks",
|
|
get: function get() {
|
|
return this.isValid ? this.values.weeks || 0 : NaN;
|
|
}
|
|
}, {
|
|
key: "days",
|
|
get: function get() {
|
|
return this.isValid ? this.values.days || 0 : NaN;
|
|
}
|
|
}, {
|
|
key: "hours",
|
|
get: function get() {
|
|
return this.isValid ? this.values.hours || 0 : NaN;
|
|
}
|
|
}, {
|
|
key: "minutes",
|
|
get: function get() {
|
|
return this.isValid ? this.values.minutes || 0 : NaN;
|
|
}
|
|
}, {
|
|
key: "seconds",
|
|
get: function get() {
|
|
return this.isValid ? this.values.seconds || 0 : NaN;
|
|
}
|
|
}, {
|
|
key: "milliseconds",
|
|
get: function get() {
|
|
return this.isValid ? this.values.milliseconds || 0 : NaN;
|
|
}
|
|
}, {
|
|
key: "isValid",
|
|
get: function get() {
|
|
return this.invalid === null;
|
|
}
|
|
}, {
|
|
key: "invalidReason",
|
|
get: function get() {
|
|
return this.invalid ? this.invalid.reason : null;
|
|
}
|
|
}, {
|
|
key: "invalidExplanation",
|
|
get: function get() {
|
|
return this.invalid ? this.invalid.explanation : null;
|
|
}
|
|
}]);
|
|
return Duration4;
|
|
}();
|
|
var INVALID$1 = "Invalid Interval";
|
|
function validateStartEnd(start, end) {
|
|
if (!start || !start.isValid) {
|
|
return Interval.invalid("missing or invalid start");
|
|
} else if (!end || !end.isValid) {
|
|
return Interval.invalid("missing or invalid end");
|
|
} else if (end < start) {
|
|
return Interval.invalid("end before start", "The end of an interval must be after its start, but you had start=" + start.toISO() + " and end=" + end.toISO());
|
|
} else {
|
|
return null;
|
|
}
|
|
}
|
|
var Interval = /* @__PURE__ */ function() {
|
|
function Interval2(config2) {
|
|
this.s = config2.start;
|
|
this.e = config2.end;
|
|
this.invalid = config2.invalid || null;
|
|
this.isLuxonInterval = true;
|
|
}
|
|
Interval2.invalid = function invalid(reason, explanation) {
|
|
if (explanation === void 0) {
|
|
explanation = null;
|
|
}
|
|
if (!reason) {
|
|
throw new InvalidArgumentError("need to specify a reason the Interval is invalid");
|
|
}
|
|
var invalid2 = reason instanceof Invalid ? reason : new Invalid(reason, explanation);
|
|
if (Settings.throwOnInvalid) {
|
|
throw new InvalidIntervalError(invalid2);
|
|
} else {
|
|
return new Interval2({
|
|
invalid: invalid2
|
|
});
|
|
}
|
|
};
|
|
Interval2.fromDateTimes = function fromDateTimes(start, end) {
|
|
var builtStart = friendlyDateTime(start), builtEnd = friendlyDateTime(end);
|
|
var validateError = validateStartEnd(builtStart, builtEnd);
|
|
if (validateError == null) {
|
|
return new Interval2({
|
|
start: builtStart,
|
|
end: builtEnd
|
|
});
|
|
} else {
|
|
return validateError;
|
|
}
|
|
};
|
|
Interval2.after = function after(start, duration) {
|
|
var dur = Duration3.fromDurationLike(duration), dt = friendlyDateTime(start);
|
|
return Interval2.fromDateTimes(dt, dt.plus(dur));
|
|
};
|
|
Interval2.before = function before(end, duration) {
|
|
var dur = Duration3.fromDurationLike(duration), dt = friendlyDateTime(end);
|
|
return Interval2.fromDateTimes(dt.minus(dur), dt);
|
|
};
|
|
Interval2.fromISO = function fromISO(text, opts) {
|
|
var _split = (text || "").split("/", 2), s4 = _split[0], e3 = _split[1];
|
|
if (s4 && e3) {
|
|
var start, startIsValid;
|
|
try {
|
|
start = DateTime3.fromISO(s4, opts);
|
|
startIsValid = start.isValid;
|
|
} catch (e4) {
|
|
startIsValid = false;
|
|
}
|
|
var end, endIsValid;
|
|
try {
|
|
end = DateTime3.fromISO(e3, opts);
|
|
endIsValid = end.isValid;
|
|
} catch (e4) {
|
|
endIsValid = false;
|
|
}
|
|
if (startIsValid && endIsValid) {
|
|
return Interval2.fromDateTimes(start, end);
|
|
}
|
|
if (startIsValid) {
|
|
var dur = Duration3.fromISO(e3, opts);
|
|
if (dur.isValid) {
|
|
return Interval2.after(start, dur);
|
|
}
|
|
} else if (endIsValid) {
|
|
var _dur = Duration3.fromISO(s4, opts);
|
|
if (_dur.isValid) {
|
|
return Interval2.before(end, _dur);
|
|
}
|
|
}
|
|
}
|
|
return Interval2.invalid("unparsable", 'the input "' + text + `" can't be parsed as ISO 8601`);
|
|
};
|
|
Interval2.isInterval = function isInterval(o2) {
|
|
return o2 && o2.isLuxonInterval || false;
|
|
};
|
|
var _proto = Interval2.prototype;
|
|
_proto.length = function length(unit) {
|
|
if (unit === void 0) {
|
|
unit = "milliseconds";
|
|
}
|
|
return this.isValid ? this.toDuration.apply(this, [unit]).get(unit) : NaN;
|
|
};
|
|
_proto.count = function count(unit) {
|
|
if (unit === void 0) {
|
|
unit = "milliseconds";
|
|
}
|
|
if (!this.isValid)
|
|
return NaN;
|
|
var start = this.start.startOf(unit), end = this.end.startOf(unit);
|
|
return Math.floor(end.diff(start, unit).get(unit)) + 1;
|
|
};
|
|
_proto.hasSame = function hasSame(unit) {
|
|
return this.isValid ? this.isEmpty() || this.e.minus(1).hasSame(this.s, unit) : false;
|
|
};
|
|
_proto.isEmpty = function isEmpty() {
|
|
return this.s.valueOf() === this.e.valueOf();
|
|
};
|
|
_proto.isAfter = function isAfter(dateTime) {
|
|
if (!this.isValid)
|
|
return false;
|
|
return this.s > dateTime;
|
|
};
|
|
_proto.isBefore = function isBefore(dateTime) {
|
|
if (!this.isValid)
|
|
return false;
|
|
return this.e <= dateTime;
|
|
};
|
|
_proto.contains = function contains(dateTime) {
|
|
if (!this.isValid)
|
|
return false;
|
|
return this.s <= dateTime && this.e > dateTime;
|
|
};
|
|
_proto.set = function set(_temp) {
|
|
var _ref = _temp === void 0 ? {} : _temp, start = _ref.start, end = _ref.end;
|
|
if (!this.isValid)
|
|
return this;
|
|
return Interval2.fromDateTimes(start || this.s, end || this.e);
|
|
};
|
|
_proto.splitAt = function splitAt() {
|
|
var _this = this;
|
|
if (!this.isValid)
|
|
return [];
|
|
for (var _len = arguments.length, dateTimes = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
dateTimes[_key] = arguments[_key];
|
|
}
|
|
var sorted = dateTimes.map(friendlyDateTime).filter(function(d3) {
|
|
return _this.contains(d3);
|
|
}).sort(), results = [];
|
|
var s4 = this.s, i3 = 0;
|
|
while (s4 < this.e) {
|
|
var added = sorted[i3] || this.e, next = +added > +this.e ? this.e : added;
|
|
results.push(Interval2.fromDateTimes(s4, next));
|
|
s4 = next;
|
|
i3 += 1;
|
|
}
|
|
return results;
|
|
};
|
|
_proto.splitBy = function splitBy(duration) {
|
|
var dur = Duration3.fromDurationLike(duration);
|
|
if (!this.isValid || !dur.isValid || dur.as("milliseconds") === 0) {
|
|
return [];
|
|
}
|
|
var s4 = this.s, idx = 1, next;
|
|
var results = [];
|
|
while (s4 < this.e) {
|
|
var added = this.start.plus(dur.mapUnits(function(x3) {
|
|
return x3 * idx;
|
|
}));
|
|
next = +added > +this.e ? this.e : added;
|
|
results.push(Interval2.fromDateTimes(s4, next));
|
|
s4 = next;
|
|
idx += 1;
|
|
}
|
|
return results;
|
|
};
|
|
_proto.divideEqually = function divideEqually(numberOfParts) {
|
|
if (!this.isValid)
|
|
return [];
|
|
return this.splitBy(this.length() / numberOfParts).slice(0, numberOfParts);
|
|
};
|
|
_proto.overlaps = function overlaps(other) {
|
|
return this.e > other.s && this.s < other.e;
|
|
};
|
|
_proto.abutsStart = function abutsStart(other) {
|
|
if (!this.isValid)
|
|
return false;
|
|
return +this.e === +other.s;
|
|
};
|
|
_proto.abutsEnd = function abutsEnd(other) {
|
|
if (!this.isValid)
|
|
return false;
|
|
return +other.e === +this.s;
|
|
};
|
|
_proto.engulfs = function engulfs(other) {
|
|
if (!this.isValid)
|
|
return false;
|
|
return this.s <= other.s && this.e >= other.e;
|
|
};
|
|
_proto.equals = function equals(other) {
|
|
if (!this.isValid || !other.isValid) {
|
|
return false;
|
|
}
|
|
return this.s.equals(other.s) && this.e.equals(other.e);
|
|
};
|
|
_proto.intersection = function intersection(other) {
|
|
if (!this.isValid)
|
|
return this;
|
|
var s4 = this.s > other.s ? this.s : other.s, e3 = this.e < other.e ? this.e : other.e;
|
|
if (s4 >= e3) {
|
|
return null;
|
|
} else {
|
|
return Interval2.fromDateTimes(s4, e3);
|
|
}
|
|
};
|
|
_proto.union = function union(other) {
|
|
if (!this.isValid)
|
|
return this;
|
|
var s4 = this.s < other.s ? this.s : other.s, e3 = this.e > other.e ? this.e : other.e;
|
|
return Interval2.fromDateTimes(s4, e3);
|
|
};
|
|
Interval2.merge = function merge(intervals) {
|
|
var _intervals$sort$reduc = intervals.sort(function(a3, b3) {
|
|
return a3.s - b3.s;
|
|
}).reduce(function(_ref2, item) {
|
|
var sofar = _ref2[0], current = _ref2[1];
|
|
if (!current) {
|
|
return [sofar, item];
|
|
} else if (current.overlaps(item) || current.abutsStart(item)) {
|
|
return [sofar, current.union(item)];
|
|
} else {
|
|
return [sofar.concat([current]), item];
|
|
}
|
|
}, [[], null]), found = _intervals$sort$reduc[0], final = _intervals$sort$reduc[1];
|
|
if (final) {
|
|
found.push(final);
|
|
}
|
|
return found;
|
|
};
|
|
Interval2.xor = function xor(intervals) {
|
|
var _Array$prototype;
|
|
var start = null, currentCount = 0;
|
|
var results = [], ends = intervals.map(function(i4) {
|
|
return [{
|
|
time: i4.s,
|
|
type: "s"
|
|
}, {
|
|
time: i4.e,
|
|
type: "e"
|
|
}];
|
|
}), flattened = (_Array$prototype = Array.prototype).concat.apply(_Array$prototype, ends), arr = flattened.sort(function(a3, b3) {
|
|
return a3.time - b3.time;
|
|
});
|
|
for (var _iterator = _createForOfIteratorHelperLoose(arr), _step; !(_step = _iterator()).done; ) {
|
|
var i3 = _step.value;
|
|
currentCount += i3.type === "s" ? 1 : -1;
|
|
if (currentCount === 1) {
|
|
start = i3.time;
|
|
} else {
|
|
if (start && +start !== +i3.time) {
|
|
results.push(Interval2.fromDateTimes(start, i3.time));
|
|
}
|
|
start = null;
|
|
}
|
|
}
|
|
return Interval2.merge(results);
|
|
};
|
|
_proto.difference = function difference() {
|
|
var _this2 = this;
|
|
for (var _len2 = arguments.length, intervals = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
intervals[_key2] = arguments[_key2];
|
|
}
|
|
return Interval2.xor([this].concat(intervals)).map(function(i3) {
|
|
return _this2.intersection(i3);
|
|
}).filter(function(i3) {
|
|
return i3 && !i3.isEmpty();
|
|
});
|
|
};
|
|
_proto.toString = function toString() {
|
|
if (!this.isValid)
|
|
return INVALID$1;
|
|
return "[" + this.s.toISO() + " \u2013 " + this.e.toISO() + ")";
|
|
};
|
|
_proto.toISO = function toISO(opts) {
|
|
if (!this.isValid)
|
|
return INVALID$1;
|
|
return this.s.toISO(opts) + "/" + this.e.toISO(opts);
|
|
};
|
|
_proto.toISODate = function toISODate() {
|
|
if (!this.isValid)
|
|
return INVALID$1;
|
|
return this.s.toISODate() + "/" + this.e.toISODate();
|
|
};
|
|
_proto.toISOTime = function toISOTime(opts) {
|
|
if (!this.isValid)
|
|
return INVALID$1;
|
|
return this.s.toISOTime(opts) + "/" + this.e.toISOTime(opts);
|
|
};
|
|
_proto.toFormat = function toFormat(dateFormat, _temp2) {
|
|
var _ref3 = _temp2 === void 0 ? {} : _temp2, _ref3$separator = _ref3.separator, separator = _ref3$separator === void 0 ? " \u2013 " : _ref3$separator;
|
|
if (!this.isValid)
|
|
return INVALID$1;
|
|
return "" + this.s.toFormat(dateFormat) + separator + this.e.toFormat(dateFormat);
|
|
};
|
|
_proto.toDuration = function toDuration(unit, opts) {
|
|
if (!this.isValid) {
|
|
return Duration3.invalid(this.invalidReason);
|
|
}
|
|
return this.e.diff(this.s, unit, opts);
|
|
};
|
|
_proto.mapEndpoints = function mapEndpoints(mapFn) {
|
|
return Interval2.fromDateTimes(mapFn(this.s), mapFn(this.e));
|
|
};
|
|
_createClass(Interval2, [{
|
|
key: "start",
|
|
get: function get() {
|
|
return this.isValid ? this.s : null;
|
|
}
|
|
}, {
|
|
key: "end",
|
|
get: function get() {
|
|
return this.isValid ? this.e : null;
|
|
}
|
|
}, {
|
|
key: "isValid",
|
|
get: function get() {
|
|
return this.invalidReason === null;
|
|
}
|
|
}, {
|
|
key: "invalidReason",
|
|
get: function get() {
|
|
return this.invalid ? this.invalid.reason : null;
|
|
}
|
|
}, {
|
|
key: "invalidExplanation",
|
|
get: function get() {
|
|
return this.invalid ? this.invalid.explanation : null;
|
|
}
|
|
}]);
|
|
return Interval2;
|
|
}();
|
|
var Info = /* @__PURE__ */ function() {
|
|
function Info2() {
|
|
}
|
|
Info2.hasDST = function hasDST(zone) {
|
|
if (zone === void 0) {
|
|
zone = Settings.defaultZone;
|
|
}
|
|
var proto = DateTime3.now().setZone(zone).set({
|
|
month: 12
|
|
});
|
|
return !zone.isUniversal && proto.offset !== proto.set({
|
|
month: 6
|
|
}).offset;
|
|
};
|
|
Info2.isValidIANAZone = function isValidIANAZone(zone) {
|
|
return IANAZone.isValidZone(zone);
|
|
};
|
|
Info2.normalizeZone = function normalizeZone$1(input) {
|
|
return normalizeZone(input, Settings.defaultZone);
|
|
};
|
|
Info2.months = function months2(length, _temp) {
|
|
if (length === void 0) {
|
|
length = "long";
|
|
}
|
|
var _ref = _temp === void 0 ? {} : _temp, _ref$locale = _ref.locale, locale = _ref$locale === void 0 ? null : _ref$locale, _ref$numberingSystem = _ref.numberingSystem, numberingSystem = _ref$numberingSystem === void 0 ? null : _ref$numberingSystem, _ref$locObj = _ref.locObj, locObj = _ref$locObj === void 0 ? null : _ref$locObj, _ref$outputCalendar = _ref.outputCalendar, outputCalendar = _ref$outputCalendar === void 0 ? "gregory" : _ref$outputCalendar;
|
|
return (locObj || Locale.create(locale, numberingSystem, outputCalendar)).months(length);
|
|
};
|
|
Info2.monthsFormat = function monthsFormat(length, _temp2) {
|
|
if (length === void 0) {
|
|
length = "long";
|
|
}
|
|
var _ref2 = _temp2 === void 0 ? {} : _temp2, _ref2$locale = _ref2.locale, locale = _ref2$locale === void 0 ? null : _ref2$locale, _ref2$numberingSystem = _ref2.numberingSystem, numberingSystem = _ref2$numberingSystem === void 0 ? null : _ref2$numberingSystem, _ref2$locObj = _ref2.locObj, locObj = _ref2$locObj === void 0 ? null : _ref2$locObj, _ref2$outputCalendar = _ref2.outputCalendar, outputCalendar = _ref2$outputCalendar === void 0 ? "gregory" : _ref2$outputCalendar;
|
|
return (locObj || Locale.create(locale, numberingSystem, outputCalendar)).months(length, true);
|
|
};
|
|
Info2.weekdays = function weekdays2(length, _temp3) {
|
|
if (length === void 0) {
|
|
length = "long";
|
|
}
|
|
var _ref3 = _temp3 === void 0 ? {} : _temp3, _ref3$locale = _ref3.locale, locale = _ref3$locale === void 0 ? null : _ref3$locale, _ref3$numberingSystem = _ref3.numberingSystem, numberingSystem = _ref3$numberingSystem === void 0 ? null : _ref3$numberingSystem, _ref3$locObj = _ref3.locObj, locObj = _ref3$locObj === void 0 ? null : _ref3$locObj;
|
|
return (locObj || Locale.create(locale, numberingSystem, null)).weekdays(length);
|
|
};
|
|
Info2.weekdaysFormat = function weekdaysFormat(length, _temp4) {
|
|
if (length === void 0) {
|
|
length = "long";
|
|
}
|
|
var _ref4 = _temp4 === void 0 ? {} : _temp4, _ref4$locale = _ref4.locale, locale = _ref4$locale === void 0 ? null : _ref4$locale, _ref4$numberingSystem = _ref4.numberingSystem, numberingSystem = _ref4$numberingSystem === void 0 ? null : _ref4$numberingSystem, _ref4$locObj = _ref4.locObj, locObj = _ref4$locObj === void 0 ? null : _ref4$locObj;
|
|
return (locObj || Locale.create(locale, numberingSystem, null)).weekdays(length, true);
|
|
};
|
|
Info2.meridiems = function meridiems2(_temp5) {
|
|
var _ref5 = _temp5 === void 0 ? {} : _temp5, _ref5$locale = _ref5.locale, locale = _ref5$locale === void 0 ? null : _ref5$locale;
|
|
return Locale.create(locale).meridiems();
|
|
};
|
|
Info2.eras = function eras2(length, _temp6) {
|
|
if (length === void 0) {
|
|
length = "short";
|
|
}
|
|
var _ref6 = _temp6 === void 0 ? {} : _temp6, _ref6$locale = _ref6.locale, locale = _ref6$locale === void 0 ? null : _ref6$locale;
|
|
return Locale.create(locale, null, "gregory").eras(length);
|
|
};
|
|
Info2.features = function features() {
|
|
return {
|
|
relative: hasRelative()
|
|
};
|
|
};
|
|
return Info2;
|
|
}();
|
|
function dayDiff(earlier, later) {
|
|
var utcDayStart = function utcDayStart2(dt) {
|
|
return dt.toUTC(0, {
|
|
keepLocalTime: true
|
|
}).startOf("day").valueOf();
|
|
}, ms = utcDayStart(later) - utcDayStart(earlier);
|
|
return Math.floor(Duration3.fromMillis(ms).as("days"));
|
|
}
|
|
function highOrderDiffs(cursor, later, units) {
|
|
var differs = [["years", function(a3, b3) {
|
|
return b3.year - a3.year;
|
|
}], ["quarters", function(a3, b3) {
|
|
return b3.quarter - a3.quarter;
|
|
}], ["months", function(a3, b3) {
|
|
return b3.month - a3.month + (b3.year - a3.year) * 12;
|
|
}], ["weeks", function(a3, b3) {
|
|
var days = dayDiff(a3, b3);
|
|
return (days - days % 7) / 7;
|
|
}], ["days", dayDiff]];
|
|
var results = {};
|
|
var lowestOrder, highWater;
|
|
for (var _i = 0, _differs = differs; _i < _differs.length; _i++) {
|
|
var _differs$_i = _differs[_i], unit = _differs$_i[0], differ = _differs$_i[1];
|
|
if (units.indexOf(unit) >= 0) {
|
|
var _cursor$plus;
|
|
lowestOrder = unit;
|
|
var delta = differ(cursor, later);
|
|
highWater = cursor.plus((_cursor$plus = {}, _cursor$plus[unit] = delta, _cursor$plus));
|
|
if (highWater > later) {
|
|
var _cursor$plus2;
|
|
cursor = cursor.plus((_cursor$plus2 = {}, _cursor$plus2[unit] = delta - 1, _cursor$plus2));
|
|
delta -= 1;
|
|
} else {
|
|
cursor = highWater;
|
|
}
|
|
results[unit] = delta;
|
|
}
|
|
}
|
|
return [cursor, results, highWater, lowestOrder];
|
|
}
|
|
function _diff(earlier, later, units, opts) {
|
|
var _highOrderDiffs = highOrderDiffs(earlier, later, units), cursor = _highOrderDiffs[0], results = _highOrderDiffs[1], highWater = _highOrderDiffs[2], lowestOrder = _highOrderDiffs[3];
|
|
var remainingMillis = later - cursor;
|
|
var lowerOrderUnits = units.filter(function(u3) {
|
|
return ["hours", "minutes", "seconds", "milliseconds"].indexOf(u3) >= 0;
|
|
});
|
|
if (lowerOrderUnits.length === 0) {
|
|
if (highWater < later) {
|
|
var _cursor$plus3;
|
|
highWater = cursor.plus((_cursor$plus3 = {}, _cursor$plus3[lowestOrder] = 1, _cursor$plus3));
|
|
}
|
|
if (highWater !== cursor) {
|
|
results[lowestOrder] = (results[lowestOrder] || 0) + remainingMillis / (highWater - cursor);
|
|
}
|
|
}
|
|
var duration = Duration3.fromObject(results, opts);
|
|
if (lowerOrderUnits.length > 0) {
|
|
var _Duration$fromMillis;
|
|
return (_Duration$fromMillis = Duration3.fromMillis(remainingMillis, opts)).shiftTo.apply(_Duration$fromMillis, lowerOrderUnits).plus(duration);
|
|
} else {
|
|
return duration;
|
|
}
|
|
}
|
|
var numberingSystems = {
|
|
arab: "[\u0660-\u0669]",
|
|
arabext: "[\u06F0-\u06F9]",
|
|
bali: "[\u1B50-\u1B59]",
|
|
beng: "[\u09E6-\u09EF]",
|
|
deva: "[\u0966-\u096F]",
|
|
fullwide: "[\uFF10-\uFF19]",
|
|
gujr: "[\u0AE6-\u0AEF]",
|
|
hanidec: "[\u3007|\u4E00|\u4E8C|\u4E09|\u56DB|\u4E94|\u516D|\u4E03|\u516B|\u4E5D]",
|
|
khmr: "[\u17E0-\u17E9]",
|
|
knda: "[\u0CE6-\u0CEF]",
|
|
laoo: "[\u0ED0-\u0ED9]",
|
|
limb: "[\u1946-\u194F]",
|
|
mlym: "[\u0D66-\u0D6F]",
|
|
mong: "[\u1810-\u1819]",
|
|
mymr: "[\u1040-\u1049]",
|
|
orya: "[\u0B66-\u0B6F]",
|
|
tamldec: "[\u0BE6-\u0BEF]",
|
|
telu: "[\u0C66-\u0C6F]",
|
|
thai: "[\u0E50-\u0E59]",
|
|
tibt: "[\u0F20-\u0F29]",
|
|
latn: "\\d"
|
|
};
|
|
var numberingSystemsUTF16 = {
|
|
arab: [1632, 1641],
|
|
arabext: [1776, 1785],
|
|
bali: [6992, 7001],
|
|
beng: [2534, 2543],
|
|
deva: [2406, 2415],
|
|
fullwide: [65296, 65303],
|
|
gujr: [2790, 2799],
|
|
khmr: [6112, 6121],
|
|
knda: [3302, 3311],
|
|
laoo: [3792, 3801],
|
|
limb: [6470, 6479],
|
|
mlym: [3430, 3439],
|
|
mong: [6160, 6169],
|
|
mymr: [4160, 4169],
|
|
orya: [2918, 2927],
|
|
tamldec: [3046, 3055],
|
|
telu: [3174, 3183],
|
|
thai: [3664, 3673],
|
|
tibt: [3872, 3881]
|
|
};
|
|
var hanidecChars = numberingSystems.hanidec.replace(/[\[|\]]/g, "").split("");
|
|
function parseDigits(str) {
|
|
var value = parseInt(str, 10);
|
|
if (isNaN(value)) {
|
|
value = "";
|
|
for (var i3 = 0; i3 < str.length; i3++) {
|
|
var code = str.charCodeAt(i3);
|
|
if (str[i3].search(numberingSystems.hanidec) !== -1) {
|
|
value += hanidecChars.indexOf(str[i3]);
|
|
} else {
|
|
for (var key in numberingSystemsUTF16) {
|
|
var _numberingSystemsUTF = numberingSystemsUTF16[key], min = _numberingSystemsUTF[0], max = _numberingSystemsUTF[1];
|
|
if (code >= min && code <= max) {
|
|
value += code - min;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return parseInt(value, 10);
|
|
} else {
|
|
return value;
|
|
}
|
|
}
|
|
function digitRegex(_ref, append) {
|
|
var numberingSystem = _ref.numberingSystem;
|
|
if (append === void 0) {
|
|
append = "";
|
|
}
|
|
return new RegExp("" + numberingSystems[numberingSystem || "latn"] + append);
|
|
}
|
|
var MISSING_FTP = "missing Intl.DateTimeFormat.formatToParts support";
|
|
function intUnit(regex, post) {
|
|
if (post === void 0) {
|
|
post = function post2(i3) {
|
|
return i3;
|
|
};
|
|
}
|
|
return {
|
|
regex,
|
|
deser: function deser(_ref) {
|
|
var s4 = _ref[0];
|
|
return post(parseDigits(s4));
|
|
}
|
|
};
|
|
}
|
|
var NBSP = String.fromCharCode(160);
|
|
var spaceOrNBSP = "( |" + NBSP + ")";
|
|
var spaceOrNBSPRegExp = new RegExp(spaceOrNBSP, "g");
|
|
function fixListRegex(s4) {
|
|
return s4.replace(/\./g, "\\.?").replace(spaceOrNBSPRegExp, spaceOrNBSP);
|
|
}
|
|
function stripInsensitivities(s4) {
|
|
return s4.replace(/\./g, "").replace(spaceOrNBSPRegExp, " ").toLowerCase();
|
|
}
|
|
function oneOf(strings, startIndex) {
|
|
if (strings === null) {
|
|
return null;
|
|
} else {
|
|
return {
|
|
regex: RegExp(strings.map(fixListRegex).join("|")),
|
|
deser: function deser(_ref2) {
|
|
var s4 = _ref2[0];
|
|
return strings.findIndex(function(i3) {
|
|
return stripInsensitivities(s4) === stripInsensitivities(i3);
|
|
}) + startIndex;
|
|
}
|
|
};
|
|
}
|
|
}
|
|
function offset(regex, groups) {
|
|
return {
|
|
regex,
|
|
deser: function deser(_ref3) {
|
|
var h3 = _ref3[1], m2 = _ref3[2];
|
|
return signedOffset(h3, m2);
|
|
},
|
|
groups
|
|
};
|
|
}
|
|
function simple(regex) {
|
|
return {
|
|
regex,
|
|
deser: function deser(_ref4) {
|
|
var s4 = _ref4[0];
|
|
return s4;
|
|
}
|
|
};
|
|
}
|
|
function escapeToken(value) {
|
|
return value.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&");
|
|
}
|
|
function unitForToken(token, loc) {
|
|
var one = digitRegex(loc), two = digitRegex(loc, "{2}"), three = digitRegex(loc, "{3}"), four = digitRegex(loc, "{4}"), six = digitRegex(loc, "{6}"), oneOrTwo = digitRegex(loc, "{1,2}"), oneToThree = digitRegex(loc, "{1,3}"), oneToSix = digitRegex(loc, "{1,6}"), oneToNine = digitRegex(loc, "{1,9}"), twoToFour = digitRegex(loc, "{2,4}"), fourToSix = digitRegex(loc, "{4,6}"), literal = function literal2(t3) {
|
|
return {
|
|
regex: RegExp(escapeToken(t3.val)),
|
|
deser: function deser(_ref5) {
|
|
var s4 = _ref5[0];
|
|
return s4;
|
|
},
|
|
literal: true
|
|
};
|
|
}, unitate = function unitate2(t3) {
|
|
if (token.literal) {
|
|
return literal(t3);
|
|
}
|
|
switch (t3.val) {
|
|
case "G":
|
|
return oneOf(loc.eras("short", false), 0);
|
|
case "GG":
|
|
return oneOf(loc.eras("long", false), 0);
|
|
case "y":
|
|
return intUnit(oneToSix);
|
|
case "yy":
|
|
return intUnit(twoToFour, untruncateYear);
|
|
case "yyyy":
|
|
return intUnit(four);
|
|
case "yyyyy":
|
|
return intUnit(fourToSix);
|
|
case "yyyyyy":
|
|
return intUnit(six);
|
|
case "M":
|
|
return intUnit(oneOrTwo);
|
|
case "MM":
|
|
return intUnit(two);
|
|
case "MMM":
|
|
return oneOf(loc.months("short", true, false), 1);
|
|
case "MMMM":
|
|
return oneOf(loc.months("long", true, false), 1);
|
|
case "L":
|
|
return intUnit(oneOrTwo);
|
|
case "LL":
|
|
return intUnit(two);
|
|
case "LLL":
|
|
return oneOf(loc.months("short", false, false), 1);
|
|
case "LLLL":
|
|
return oneOf(loc.months("long", false, false), 1);
|
|
case "d":
|
|
return intUnit(oneOrTwo);
|
|
case "dd":
|
|
return intUnit(two);
|
|
case "o":
|
|
return intUnit(oneToThree);
|
|
case "ooo":
|
|
return intUnit(three);
|
|
case "HH":
|
|
return intUnit(two);
|
|
case "H":
|
|
return intUnit(oneOrTwo);
|
|
case "hh":
|
|
return intUnit(two);
|
|
case "h":
|
|
return intUnit(oneOrTwo);
|
|
case "mm":
|
|
return intUnit(two);
|
|
case "m":
|
|
return intUnit(oneOrTwo);
|
|
case "q":
|
|
return intUnit(oneOrTwo);
|
|
case "qq":
|
|
return intUnit(two);
|
|
case "s":
|
|
return intUnit(oneOrTwo);
|
|
case "ss":
|
|
return intUnit(two);
|
|
case "S":
|
|
return intUnit(oneToThree);
|
|
case "SSS":
|
|
return intUnit(three);
|
|
case "u":
|
|
return simple(oneToNine);
|
|
case "uu":
|
|
return simple(oneOrTwo);
|
|
case "uuu":
|
|
return intUnit(one);
|
|
case "a":
|
|
return oneOf(loc.meridiems(), 0);
|
|
case "kkkk":
|
|
return intUnit(four);
|
|
case "kk":
|
|
return intUnit(twoToFour, untruncateYear);
|
|
case "W":
|
|
return intUnit(oneOrTwo);
|
|
case "WW":
|
|
return intUnit(two);
|
|
case "E":
|
|
case "c":
|
|
return intUnit(one);
|
|
case "EEE":
|
|
return oneOf(loc.weekdays("short", false, false), 1);
|
|
case "EEEE":
|
|
return oneOf(loc.weekdays("long", false, false), 1);
|
|
case "ccc":
|
|
return oneOf(loc.weekdays("short", true, false), 1);
|
|
case "cccc":
|
|
return oneOf(loc.weekdays("long", true, false), 1);
|
|
case "Z":
|
|
case "ZZ":
|
|
return offset(new RegExp("([+-]" + oneOrTwo.source + ")(?::(" + two.source + "))?"), 2);
|
|
case "ZZZ":
|
|
return offset(new RegExp("([+-]" + oneOrTwo.source + ")(" + two.source + ")?"), 2);
|
|
case "z":
|
|
return simple(/[a-z_+-/]{1,256}?/i);
|
|
default:
|
|
return literal(t3);
|
|
}
|
|
};
|
|
var unit = unitate(token) || {
|
|
invalidReason: MISSING_FTP
|
|
};
|
|
unit.token = token;
|
|
return unit;
|
|
}
|
|
var partTypeStyleToTokenVal = {
|
|
year: {
|
|
"2-digit": "yy",
|
|
numeric: "yyyyy"
|
|
},
|
|
month: {
|
|
numeric: "M",
|
|
"2-digit": "MM",
|
|
short: "MMM",
|
|
long: "MMMM"
|
|
},
|
|
day: {
|
|
numeric: "d",
|
|
"2-digit": "dd"
|
|
},
|
|
weekday: {
|
|
short: "EEE",
|
|
long: "EEEE"
|
|
},
|
|
dayperiod: "a",
|
|
dayPeriod: "a",
|
|
hour: {
|
|
numeric: "h",
|
|
"2-digit": "hh"
|
|
},
|
|
minute: {
|
|
numeric: "m",
|
|
"2-digit": "mm"
|
|
},
|
|
second: {
|
|
numeric: "s",
|
|
"2-digit": "ss"
|
|
}
|
|
};
|
|
function tokenForPart(part, locale, formatOpts) {
|
|
var type = part.type, value = part.value;
|
|
if (type === "literal") {
|
|
return {
|
|
literal: true,
|
|
val: value
|
|
};
|
|
}
|
|
var style = formatOpts[type];
|
|
var val = partTypeStyleToTokenVal[type];
|
|
if (typeof val === "object") {
|
|
val = val[style];
|
|
}
|
|
if (val) {
|
|
return {
|
|
literal: false,
|
|
val
|
|
};
|
|
}
|
|
return void 0;
|
|
}
|
|
function buildRegex(units) {
|
|
var re = units.map(function(u3) {
|
|
return u3.regex;
|
|
}).reduce(function(f3, r3) {
|
|
return f3 + "(" + r3.source + ")";
|
|
}, "");
|
|
return ["^" + re + "$", units];
|
|
}
|
|
function match(input, regex, handlers) {
|
|
var matches = input.match(regex);
|
|
if (matches) {
|
|
var all = {};
|
|
var matchIndex = 1;
|
|
for (var i3 in handlers) {
|
|
if (hasOwnProperty2(handlers, i3)) {
|
|
var h3 = handlers[i3], groups = h3.groups ? h3.groups + 1 : 1;
|
|
if (!h3.literal && h3.token) {
|
|
all[h3.token.val[0]] = h3.deser(matches.slice(matchIndex, matchIndex + groups));
|
|
}
|
|
matchIndex += groups;
|
|
}
|
|
}
|
|
return [matches, all];
|
|
} else {
|
|
return [matches, {}];
|
|
}
|
|
}
|
|
function dateTimeFromMatches(matches) {
|
|
var toField = function toField2(token) {
|
|
switch (token) {
|
|
case "S":
|
|
return "millisecond";
|
|
case "s":
|
|
return "second";
|
|
case "m":
|
|
return "minute";
|
|
case "h":
|
|
case "H":
|
|
return "hour";
|
|
case "d":
|
|
return "day";
|
|
case "o":
|
|
return "ordinal";
|
|
case "L":
|
|
case "M":
|
|
return "month";
|
|
case "y":
|
|
return "year";
|
|
case "E":
|
|
case "c":
|
|
return "weekday";
|
|
case "W":
|
|
return "weekNumber";
|
|
case "k":
|
|
return "weekYear";
|
|
case "q":
|
|
return "quarter";
|
|
default:
|
|
return null;
|
|
}
|
|
};
|
|
var zone = null;
|
|
var specificOffset;
|
|
if (!isUndefined(matches.z)) {
|
|
zone = IANAZone.create(matches.z);
|
|
}
|
|
if (!isUndefined(matches.Z)) {
|
|
if (!zone) {
|
|
zone = new FixedOffsetZone(matches.Z);
|
|
}
|
|
specificOffset = matches.Z;
|
|
}
|
|
if (!isUndefined(matches.q)) {
|
|
matches.M = (matches.q - 1) * 3 + 1;
|
|
}
|
|
if (!isUndefined(matches.h)) {
|
|
if (matches.h < 12 && matches.a === 1) {
|
|
matches.h += 12;
|
|
} else if (matches.h === 12 && matches.a === 0) {
|
|
matches.h = 0;
|
|
}
|
|
}
|
|
if (matches.G === 0 && matches.y) {
|
|
matches.y = -matches.y;
|
|
}
|
|
if (!isUndefined(matches.u)) {
|
|
matches.S = parseMillis(matches.u);
|
|
}
|
|
var vals = Object.keys(matches).reduce(function(r3, k2) {
|
|
var f3 = toField(k2);
|
|
if (f3) {
|
|
r3[f3] = matches[k2];
|
|
}
|
|
return r3;
|
|
}, {});
|
|
return [vals, zone, specificOffset];
|
|
}
|
|
var dummyDateTimeCache = null;
|
|
function getDummyDateTime() {
|
|
if (!dummyDateTimeCache) {
|
|
dummyDateTimeCache = DateTime3.fromMillis(1555555555555);
|
|
}
|
|
return dummyDateTimeCache;
|
|
}
|
|
function maybeExpandMacroToken(token, locale) {
|
|
if (token.literal) {
|
|
return token;
|
|
}
|
|
var formatOpts = Formatter.macroTokenToFormatOpts(token.val);
|
|
if (!formatOpts) {
|
|
return token;
|
|
}
|
|
var formatter = Formatter.create(locale, formatOpts);
|
|
var parts = formatter.formatDateTimeParts(getDummyDateTime());
|
|
var tokens = parts.map(function(p3) {
|
|
return tokenForPart(p3, locale, formatOpts);
|
|
});
|
|
if (tokens.includes(void 0)) {
|
|
return token;
|
|
}
|
|
return tokens;
|
|
}
|
|
function expandMacroTokens(tokens, locale) {
|
|
var _Array$prototype;
|
|
return (_Array$prototype = Array.prototype).concat.apply(_Array$prototype, tokens.map(function(t3) {
|
|
return maybeExpandMacroToken(t3, locale);
|
|
}));
|
|
}
|
|
function explainFromTokens(locale, input, format) {
|
|
var tokens = expandMacroTokens(Formatter.parseFormat(format), locale), units = tokens.map(function(t3) {
|
|
return unitForToken(t3, locale);
|
|
}), disqualifyingUnit = units.find(function(t3) {
|
|
return t3.invalidReason;
|
|
});
|
|
if (disqualifyingUnit) {
|
|
return {
|
|
input,
|
|
tokens,
|
|
invalidReason: disqualifyingUnit.invalidReason
|
|
};
|
|
} else {
|
|
var _buildRegex = buildRegex(units), regexString = _buildRegex[0], handlers = _buildRegex[1], regex = RegExp(regexString, "i"), _match = match(input, regex, handlers), rawMatches = _match[0], matches = _match[1], _ref6 = matches ? dateTimeFromMatches(matches) : [null, null, void 0], result = _ref6[0], zone = _ref6[1], specificOffset = _ref6[2];
|
|
if (hasOwnProperty2(matches, "a") && hasOwnProperty2(matches, "H")) {
|
|
throw new ConflictingSpecificationError("Can't include meridiem when specifying 24-hour format");
|
|
}
|
|
return {
|
|
input,
|
|
tokens,
|
|
regex,
|
|
rawMatches,
|
|
matches,
|
|
result,
|
|
zone,
|
|
specificOffset
|
|
};
|
|
}
|
|
}
|
|
function parseFromTokens(locale, input, format) {
|
|
var _explainFromTokens = explainFromTokens(locale, input, format), result = _explainFromTokens.result, zone = _explainFromTokens.zone, specificOffset = _explainFromTokens.specificOffset, invalidReason = _explainFromTokens.invalidReason;
|
|
return [result, zone, specificOffset, invalidReason];
|
|
}
|
|
var nonLeapLadder = [0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334];
|
|
var leapLadder = [0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335];
|
|
function unitOutOfRange(unit, value) {
|
|
return new Invalid("unit out of range", "you specified " + value + " (of type " + typeof value + ") as a " + unit + ", which is invalid");
|
|
}
|
|
function dayOfWeek(year, month, day) {
|
|
var js = new Date(Date.UTC(year, month - 1, day)).getUTCDay();
|
|
return js === 0 ? 7 : js;
|
|
}
|
|
function computeOrdinal(year, month, day) {
|
|
return day + (isLeapYear(year) ? leapLadder : nonLeapLadder)[month - 1];
|
|
}
|
|
function uncomputeOrdinal(year, ordinal) {
|
|
var table = isLeapYear(year) ? leapLadder : nonLeapLadder, month0 = table.findIndex(function(i3) {
|
|
return i3 < ordinal;
|
|
}), day = ordinal - table[month0];
|
|
return {
|
|
month: month0 + 1,
|
|
day
|
|
};
|
|
}
|
|
function gregorianToWeek(gregObj) {
|
|
var year = gregObj.year, month = gregObj.month, day = gregObj.day, ordinal = computeOrdinal(year, month, day), weekday = dayOfWeek(year, month, day);
|
|
var weekNumber = Math.floor((ordinal - weekday + 10) / 7), weekYear;
|
|
if (weekNumber < 1) {
|
|
weekYear = year - 1;
|
|
weekNumber = weeksInWeekYear(weekYear);
|
|
} else if (weekNumber > weeksInWeekYear(year)) {
|
|
weekYear = year + 1;
|
|
weekNumber = 1;
|
|
} else {
|
|
weekYear = year;
|
|
}
|
|
return _extends({
|
|
weekYear,
|
|
weekNumber,
|
|
weekday
|
|
}, timeObject(gregObj));
|
|
}
|
|
function weekToGregorian(weekData) {
|
|
var weekYear = weekData.weekYear, weekNumber = weekData.weekNumber, weekday = weekData.weekday, weekdayOfJan4 = dayOfWeek(weekYear, 1, 4), yearInDays = daysInYear(weekYear);
|
|
var ordinal = weekNumber * 7 + weekday - weekdayOfJan4 - 3, year;
|
|
if (ordinal < 1) {
|
|
year = weekYear - 1;
|
|
ordinal += daysInYear(year);
|
|
} else if (ordinal > yearInDays) {
|
|
year = weekYear + 1;
|
|
ordinal -= daysInYear(weekYear);
|
|
} else {
|
|
year = weekYear;
|
|
}
|
|
var _uncomputeOrdinal = uncomputeOrdinal(year, ordinal), month = _uncomputeOrdinal.month, day = _uncomputeOrdinal.day;
|
|
return _extends({
|
|
year,
|
|
month,
|
|
day
|
|
}, timeObject(weekData));
|
|
}
|
|
function gregorianToOrdinal(gregData) {
|
|
var year = gregData.year, month = gregData.month, day = gregData.day;
|
|
var ordinal = computeOrdinal(year, month, day);
|
|
return _extends({
|
|
year,
|
|
ordinal
|
|
}, timeObject(gregData));
|
|
}
|
|
function ordinalToGregorian(ordinalData) {
|
|
var year = ordinalData.year, ordinal = ordinalData.ordinal;
|
|
var _uncomputeOrdinal2 = uncomputeOrdinal(year, ordinal), month = _uncomputeOrdinal2.month, day = _uncomputeOrdinal2.day;
|
|
return _extends({
|
|
year,
|
|
month,
|
|
day
|
|
}, timeObject(ordinalData));
|
|
}
|
|
function hasInvalidWeekData(obj) {
|
|
var validYear = isInteger(obj.weekYear), validWeek = integerBetween(obj.weekNumber, 1, weeksInWeekYear(obj.weekYear)), validWeekday = integerBetween(obj.weekday, 1, 7);
|
|
if (!validYear) {
|
|
return unitOutOfRange("weekYear", obj.weekYear);
|
|
} else if (!validWeek) {
|
|
return unitOutOfRange("week", obj.week);
|
|
} else if (!validWeekday) {
|
|
return unitOutOfRange("weekday", obj.weekday);
|
|
} else
|
|
return false;
|
|
}
|
|
function hasInvalidOrdinalData(obj) {
|
|
var validYear = isInteger(obj.year), validOrdinal = integerBetween(obj.ordinal, 1, daysInYear(obj.year));
|
|
if (!validYear) {
|
|
return unitOutOfRange("year", obj.year);
|
|
} else if (!validOrdinal) {
|
|
return unitOutOfRange("ordinal", obj.ordinal);
|
|
} else
|
|
return false;
|
|
}
|
|
function hasInvalidGregorianData(obj) {
|
|
var validYear = isInteger(obj.year), validMonth = integerBetween(obj.month, 1, 12), validDay = integerBetween(obj.day, 1, daysInMonth(obj.year, obj.month));
|
|
if (!validYear) {
|
|
return unitOutOfRange("year", obj.year);
|
|
} else if (!validMonth) {
|
|
return unitOutOfRange("month", obj.month);
|
|
} else if (!validDay) {
|
|
return unitOutOfRange("day", obj.day);
|
|
} else
|
|
return false;
|
|
}
|
|
function hasInvalidTimeData(obj) {
|
|
var hour = obj.hour, minute = obj.minute, second = obj.second, millisecond = obj.millisecond;
|
|
var validHour = integerBetween(hour, 0, 23) || hour === 24 && minute === 0 && second === 0 && millisecond === 0, validMinute = integerBetween(minute, 0, 59), validSecond = integerBetween(second, 0, 59), validMillisecond = integerBetween(millisecond, 0, 999);
|
|
if (!validHour) {
|
|
return unitOutOfRange("hour", hour);
|
|
} else if (!validMinute) {
|
|
return unitOutOfRange("minute", minute);
|
|
} else if (!validSecond) {
|
|
return unitOutOfRange("second", second);
|
|
} else if (!validMillisecond) {
|
|
return unitOutOfRange("millisecond", millisecond);
|
|
} else
|
|
return false;
|
|
}
|
|
var INVALID = "Invalid DateTime";
|
|
var MAX_DATE = 864e13;
|
|
function unsupportedZone(zone) {
|
|
return new Invalid("unsupported zone", 'the zone "' + zone.name + '" is not supported');
|
|
}
|
|
function possiblyCachedWeekData(dt) {
|
|
if (dt.weekData === null) {
|
|
dt.weekData = gregorianToWeek(dt.c);
|
|
}
|
|
return dt.weekData;
|
|
}
|
|
function clone(inst, alts) {
|
|
var current = {
|
|
ts: inst.ts,
|
|
zone: inst.zone,
|
|
c: inst.c,
|
|
o: inst.o,
|
|
loc: inst.loc,
|
|
invalid: inst.invalid
|
|
};
|
|
return new DateTime3(_extends({}, current, alts, {
|
|
old: current
|
|
}));
|
|
}
|
|
function fixOffset(localTS, o2, tz) {
|
|
var utcGuess = localTS - o2 * 60 * 1e3;
|
|
var o22 = tz.offset(utcGuess);
|
|
if (o2 === o22) {
|
|
return [utcGuess, o2];
|
|
}
|
|
utcGuess -= (o22 - o2) * 60 * 1e3;
|
|
var o3 = tz.offset(utcGuess);
|
|
if (o22 === o3) {
|
|
return [utcGuess, o22];
|
|
}
|
|
return [localTS - Math.min(o22, o3) * 60 * 1e3, Math.max(o22, o3)];
|
|
}
|
|
function tsToObj(ts, offset2) {
|
|
ts += offset2 * 60 * 1e3;
|
|
var d3 = new Date(ts);
|
|
return {
|
|
year: d3.getUTCFullYear(),
|
|
month: d3.getUTCMonth() + 1,
|
|
day: d3.getUTCDate(),
|
|
hour: d3.getUTCHours(),
|
|
minute: d3.getUTCMinutes(),
|
|
second: d3.getUTCSeconds(),
|
|
millisecond: d3.getUTCMilliseconds()
|
|
};
|
|
}
|
|
function objToTS(obj, offset2, zone) {
|
|
return fixOffset(objToLocalTS(obj), offset2, zone);
|
|
}
|
|
function adjustTime(inst, dur) {
|
|
var oPre = inst.o, year = inst.c.year + Math.trunc(dur.years), month = inst.c.month + Math.trunc(dur.months) + Math.trunc(dur.quarters) * 3, c3 = _extends({}, inst.c, {
|
|
year,
|
|
month,
|
|
day: Math.min(inst.c.day, daysInMonth(year, month)) + Math.trunc(dur.days) + Math.trunc(dur.weeks) * 7
|
|
}), millisToAdd = Duration3.fromObject({
|
|
years: dur.years - Math.trunc(dur.years),
|
|
quarters: dur.quarters - Math.trunc(dur.quarters),
|
|
months: dur.months - Math.trunc(dur.months),
|
|
weeks: dur.weeks - Math.trunc(dur.weeks),
|
|
days: dur.days - Math.trunc(dur.days),
|
|
hours: dur.hours,
|
|
minutes: dur.minutes,
|
|
seconds: dur.seconds,
|
|
milliseconds: dur.milliseconds
|
|
}).as("milliseconds"), localTS = objToLocalTS(c3);
|
|
var _fixOffset = fixOffset(localTS, oPre, inst.zone), ts = _fixOffset[0], o2 = _fixOffset[1];
|
|
if (millisToAdd !== 0) {
|
|
ts += millisToAdd;
|
|
o2 = inst.zone.offset(ts);
|
|
}
|
|
return {
|
|
ts,
|
|
o: o2
|
|
};
|
|
}
|
|
function parseDataToDateTime(parsed, parsedZone, opts, format, text, specificOffset) {
|
|
var setZone = opts.setZone, zone = opts.zone;
|
|
if (parsed && Object.keys(parsed).length !== 0) {
|
|
var interpretationZone = parsedZone || zone, inst = DateTime3.fromObject(parsed, _extends({}, opts, {
|
|
zone: interpretationZone,
|
|
specificOffset
|
|
}));
|
|
return setZone ? inst : inst.setZone(zone);
|
|
} else {
|
|
return DateTime3.invalid(new Invalid("unparsable", 'the input "' + text + `" can't be parsed as ` + format));
|
|
}
|
|
}
|
|
function toTechFormat(dt, format, allowZ) {
|
|
if (allowZ === void 0) {
|
|
allowZ = true;
|
|
}
|
|
return dt.isValid ? Formatter.create(Locale.create("en-US"), {
|
|
allowZ,
|
|
forceSimple: true
|
|
}).formatDateTimeFromString(dt, format) : null;
|
|
}
|
|
function _toISODate(o2, extended) {
|
|
var longFormat = o2.c.year > 9999 || o2.c.year < 0;
|
|
var c3 = "";
|
|
if (longFormat && o2.c.year >= 0)
|
|
c3 += "+";
|
|
c3 += padStart2(o2.c.year, longFormat ? 6 : 4);
|
|
if (extended) {
|
|
c3 += "-";
|
|
c3 += padStart2(o2.c.month);
|
|
c3 += "-";
|
|
c3 += padStart2(o2.c.day);
|
|
} else {
|
|
c3 += padStart2(o2.c.month);
|
|
c3 += padStart2(o2.c.day);
|
|
}
|
|
return c3;
|
|
}
|
|
function _toISOTime(o2, extended, suppressSeconds, suppressMilliseconds, includeOffset) {
|
|
var c3 = padStart2(o2.c.hour);
|
|
if (extended) {
|
|
c3 += ":";
|
|
c3 += padStart2(o2.c.minute);
|
|
if (o2.c.second !== 0 || !suppressSeconds) {
|
|
c3 += ":";
|
|
}
|
|
} else {
|
|
c3 += padStart2(o2.c.minute);
|
|
}
|
|
if (o2.c.second !== 0 || !suppressSeconds) {
|
|
c3 += padStart2(o2.c.second);
|
|
if (o2.c.millisecond !== 0 || !suppressMilliseconds) {
|
|
c3 += ".";
|
|
c3 += padStart2(o2.c.millisecond, 3);
|
|
}
|
|
}
|
|
if (includeOffset) {
|
|
if (o2.isOffsetFixed && o2.offset === 0) {
|
|
c3 += "Z";
|
|
} else if (o2.o < 0) {
|
|
c3 += "-";
|
|
c3 += padStart2(Math.trunc(-o2.o / 60));
|
|
c3 += ":";
|
|
c3 += padStart2(Math.trunc(-o2.o % 60));
|
|
} else {
|
|
c3 += "+";
|
|
c3 += padStart2(Math.trunc(o2.o / 60));
|
|
c3 += ":";
|
|
c3 += padStart2(Math.trunc(o2.o % 60));
|
|
}
|
|
}
|
|
return c3;
|
|
}
|
|
var defaultUnitValues = {
|
|
month: 1,
|
|
day: 1,
|
|
hour: 0,
|
|
minute: 0,
|
|
second: 0,
|
|
millisecond: 0
|
|
};
|
|
var defaultWeekUnitValues = {
|
|
weekNumber: 1,
|
|
weekday: 1,
|
|
hour: 0,
|
|
minute: 0,
|
|
second: 0,
|
|
millisecond: 0
|
|
};
|
|
var defaultOrdinalUnitValues = {
|
|
ordinal: 1,
|
|
hour: 0,
|
|
minute: 0,
|
|
second: 0,
|
|
millisecond: 0
|
|
};
|
|
var orderedUnits = ["year", "month", "day", "hour", "minute", "second", "millisecond"];
|
|
var orderedWeekUnits = ["weekYear", "weekNumber", "weekday", "hour", "minute", "second", "millisecond"];
|
|
var orderedOrdinalUnits = ["year", "ordinal", "hour", "minute", "second", "millisecond"];
|
|
function normalizeUnit(unit) {
|
|
var normalized = {
|
|
year: "year",
|
|
years: "year",
|
|
month: "month",
|
|
months: "month",
|
|
day: "day",
|
|
days: "day",
|
|
hour: "hour",
|
|
hours: "hour",
|
|
minute: "minute",
|
|
minutes: "minute",
|
|
quarter: "quarter",
|
|
quarters: "quarter",
|
|
second: "second",
|
|
seconds: "second",
|
|
millisecond: "millisecond",
|
|
milliseconds: "millisecond",
|
|
weekday: "weekday",
|
|
weekdays: "weekday",
|
|
weeknumber: "weekNumber",
|
|
weeksnumber: "weekNumber",
|
|
weeknumbers: "weekNumber",
|
|
weekyear: "weekYear",
|
|
weekyears: "weekYear",
|
|
ordinal: "ordinal"
|
|
}[unit.toLowerCase()];
|
|
if (!normalized)
|
|
throw new InvalidUnitError(unit);
|
|
return normalized;
|
|
}
|
|
function quickDT(obj, opts) {
|
|
var zone = normalizeZone(opts.zone, Settings.defaultZone), loc = Locale.fromObject(opts), tsNow = Settings.now();
|
|
var ts, o2;
|
|
if (!isUndefined(obj.year)) {
|
|
for (var _iterator = _createForOfIteratorHelperLoose(orderedUnits), _step; !(_step = _iterator()).done; ) {
|
|
var u3 = _step.value;
|
|
if (isUndefined(obj[u3])) {
|
|
obj[u3] = defaultUnitValues[u3];
|
|
}
|
|
}
|
|
var invalid = hasInvalidGregorianData(obj) || hasInvalidTimeData(obj);
|
|
if (invalid) {
|
|
return DateTime3.invalid(invalid);
|
|
}
|
|
var offsetProvis = zone.offset(tsNow);
|
|
var _objToTS = objToTS(obj, offsetProvis, zone);
|
|
ts = _objToTS[0];
|
|
o2 = _objToTS[1];
|
|
} else {
|
|
ts = tsNow;
|
|
}
|
|
return new DateTime3({
|
|
ts,
|
|
zone,
|
|
loc,
|
|
o: o2
|
|
});
|
|
}
|
|
function diffRelative(start, end, opts) {
|
|
var round = isUndefined(opts.round) ? true : opts.round, format = function format2(c3, unit2) {
|
|
c3 = roundTo(c3, round || opts.calendary ? 0 : 2, true);
|
|
var formatter = end.loc.clone(opts).relFormatter(opts);
|
|
return formatter.format(c3, unit2);
|
|
}, differ = function differ2(unit2) {
|
|
if (opts.calendary) {
|
|
if (!end.hasSame(start, unit2)) {
|
|
return end.startOf(unit2).diff(start.startOf(unit2), unit2).get(unit2);
|
|
} else
|
|
return 0;
|
|
} else {
|
|
return end.diff(start, unit2).get(unit2);
|
|
}
|
|
};
|
|
if (opts.unit) {
|
|
return format(differ(opts.unit), opts.unit);
|
|
}
|
|
for (var _iterator2 = _createForOfIteratorHelperLoose(opts.units), _step2; !(_step2 = _iterator2()).done; ) {
|
|
var unit = _step2.value;
|
|
var count = differ(unit);
|
|
if (Math.abs(count) >= 1) {
|
|
return format(count, unit);
|
|
}
|
|
}
|
|
return format(start > end ? -0 : 0, opts.units[opts.units.length - 1]);
|
|
}
|
|
function lastOpts(argList) {
|
|
var opts = {}, args;
|
|
if (argList.length > 0 && typeof argList[argList.length - 1] === "object") {
|
|
opts = argList[argList.length - 1];
|
|
args = Array.from(argList).slice(0, argList.length - 1);
|
|
} else {
|
|
args = Array.from(argList);
|
|
}
|
|
return [opts, args];
|
|
}
|
|
var DateTime3 = /* @__PURE__ */ function() {
|
|
function DateTime4(config2) {
|
|
var zone = config2.zone || Settings.defaultZone;
|
|
var invalid = config2.invalid || (Number.isNaN(config2.ts) ? new Invalid("invalid input") : null) || (!zone.isValid ? unsupportedZone(zone) : null);
|
|
this.ts = isUndefined(config2.ts) ? Settings.now() : config2.ts;
|
|
var c3 = null, o2 = null;
|
|
if (!invalid) {
|
|
var unchanged = config2.old && config2.old.ts === this.ts && config2.old.zone.equals(zone);
|
|
if (unchanged) {
|
|
var _ref = [config2.old.c, config2.old.o];
|
|
c3 = _ref[0];
|
|
o2 = _ref[1];
|
|
} else {
|
|
var ot = zone.offset(this.ts);
|
|
c3 = tsToObj(this.ts, ot);
|
|
invalid = Number.isNaN(c3.year) ? new Invalid("invalid input") : null;
|
|
c3 = invalid ? null : c3;
|
|
o2 = invalid ? null : ot;
|
|
}
|
|
}
|
|
this._zone = zone;
|
|
this.loc = config2.loc || Locale.create();
|
|
this.invalid = invalid;
|
|
this.weekData = null;
|
|
this.c = c3;
|
|
this.o = o2;
|
|
this.isLuxonDateTime = true;
|
|
}
|
|
DateTime4.now = function now2() {
|
|
return new DateTime4({});
|
|
};
|
|
DateTime4.local = function local() {
|
|
var _lastOpts = lastOpts(arguments), opts = _lastOpts[0], args = _lastOpts[1], year = args[0], month = args[1], day = args[2], hour = args[3], minute = args[4], second = args[5], millisecond = args[6];
|
|
return quickDT({
|
|
year,
|
|
month,
|
|
day,
|
|
hour,
|
|
minute,
|
|
second,
|
|
millisecond
|
|
}, opts);
|
|
};
|
|
DateTime4.utc = function utc() {
|
|
var _lastOpts2 = lastOpts(arguments), opts = _lastOpts2[0], args = _lastOpts2[1], year = args[0], month = args[1], day = args[2], hour = args[3], minute = args[4], second = args[5], millisecond = args[6];
|
|
opts.zone = FixedOffsetZone.utcInstance;
|
|
return quickDT({
|
|
year,
|
|
month,
|
|
day,
|
|
hour,
|
|
minute,
|
|
second,
|
|
millisecond
|
|
}, opts);
|
|
};
|
|
DateTime4.fromJSDate = function fromJSDate(date, options) {
|
|
if (options === void 0) {
|
|
options = {};
|
|
}
|
|
var ts = isDate(date) ? date.valueOf() : NaN;
|
|
if (Number.isNaN(ts)) {
|
|
return DateTime4.invalid("invalid input");
|
|
}
|
|
var zoneToUse = normalizeZone(options.zone, Settings.defaultZone);
|
|
if (!zoneToUse.isValid) {
|
|
return DateTime4.invalid(unsupportedZone(zoneToUse));
|
|
}
|
|
return new DateTime4({
|
|
ts,
|
|
zone: zoneToUse,
|
|
loc: Locale.fromObject(options)
|
|
});
|
|
};
|
|
DateTime4.fromMillis = function fromMillis(milliseconds, options) {
|
|
if (options === void 0) {
|
|
options = {};
|
|
}
|
|
if (!isNumber(milliseconds)) {
|
|
throw new InvalidArgumentError("fromMillis requires a numerical input, but received a " + typeof milliseconds + " with value " + milliseconds);
|
|
} else if (milliseconds < -MAX_DATE || milliseconds > MAX_DATE) {
|
|
return DateTime4.invalid("Timestamp out of range");
|
|
} else {
|
|
return new DateTime4({
|
|
ts: milliseconds,
|
|
zone: normalizeZone(options.zone, Settings.defaultZone),
|
|
loc: Locale.fromObject(options)
|
|
});
|
|
}
|
|
};
|
|
DateTime4.fromSeconds = function fromSeconds(seconds, options) {
|
|
if (options === void 0) {
|
|
options = {};
|
|
}
|
|
if (!isNumber(seconds)) {
|
|
throw new InvalidArgumentError("fromSeconds requires a numerical input");
|
|
} else {
|
|
return new DateTime4({
|
|
ts: seconds * 1e3,
|
|
zone: normalizeZone(options.zone, Settings.defaultZone),
|
|
loc: Locale.fromObject(options)
|
|
});
|
|
}
|
|
};
|
|
DateTime4.fromObject = function fromObject(obj, opts) {
|
|
if (opts === void 0) {
|
|
opts = {};
|
|
}
|
|
obj = obj || {};
|
|
var zoneToUse = normalizeZone(opts.zone, Settings.defaultZone);
|
|
if (!zoneToUse.isValid) {
|
|
return DateTime4.invalid(unsupportedZone(zoneToUse));
|
|
}
|
|
var tsNow = Settings.now(), offsetProvis = !isUndefined(opts.specificOffset) ? opts.specificOffset : zoneToUse.offset(tsNow), normalized = normalizeObject(obj, normalizeUnit), containsOrdinal = !isUndefined(normalized.ordinal), containsGregorYear = !isUndefined(normalized.year), containsGregorMD = !isUndefined(normalized.month) || !isUndefined(normalized.day), containsGregor = containsGregorYear || containsGregorMD, definiteWeekDef = normalized.weekYear || normalized.weekNumber, loc = Locale.fromObject(opts);
|
|
if ((containsGregor || containsOrdinal) && definiteWeekDef) {
|
|
throw new ConflictingSpecificationError("Can't mix weekYear/weekNumber units with year/month/day or ordinals");
|
|
}
|
|
if (containsGregorMD && containsOrdinal) {
|
|
throw new ConflictingSpecificationError("Can't mix ordinal dates with month/day");
|
|
}
|
|
var useWeekData = definiteWeekDef || normalized.weekday && !containsGregor;
|
|
var units, defaultValues, objNow = tsToObj(tsNow, offsetProvis);
|
|
if (useWeekData) {
|
|
units = orderedWeekUnits;
|
|
defaultValues = defaultWeekUnitValues;
|
|
objNow = gregorianToWeek(objNow);
|
|
} else if (containsOrdinal) {
|
|
units = orderedOrdinalUnits;
|
|
defaultValues = defaultOrdinalUnitValues;
|
|
objNow = gregorianToOrdinal(objNow);
|
|
} else {
|
|
units = orderedUnits;
|
|
defaultValues = defaultUnitValues;
|
|
}
|
|
var foundFirst = false;
|
|
for (var _iterator3 = _createForOfIteratorHelperLoose(units), _step3; !(_step3 = _iterator3()).done; ) {
|
|
var u3 = _step3.value;
|
|
var v3 = normalized[u3];
|
|
if (!isUndefined(v3)) {
|
|
foundFirst = true;
|
|
} else if (foundFirst) {
|
|
normalized[u3] = defaultValues[u3];
|
|
} else {
|
|
normalized[u3] = objNow[u3];
|
|
}
|
|
}
|
|
var higherOrderInvalid = useWeekData ? hasInvalidWeekData(normalized) : containsOrdinal ? hasInvalidOrdinalData(normalized) : hasInvalidGregorianData(normalized), invalid = higherOrderInvalid || hasInvalidTimeData(normalized);
|
|
if (invalid) {
|
|
return DateTime4.invalid(invalid);
|
|
}
|
|
var gregorian = useWeekData ? weekToGregorian(normalized) : containsOrdinal ? ordinalToGregorian(normalized) : normalized, _objToTS2 = objToTS(gregorian, offsetProvis, zoneToUse), tsFinal = _objToTS2[0], offsetFinal = _objToTS2[1], inst = new DateTime4({
|
|
ts: tsFinal,
|
|
zone: zoneToUse,
|
|
o: offsetFinal,
|
|
loc
|
|
});
|
|
if (normalized.weekday && containsGregor && obj.weekday !== inst.weekday) {
|
|
return DateTime4.invalid("mismatched weekday", "you can't specify both a weekday of " + normalized.weekday + " and a date of " + inst.toISO());
|
|
}
|
|
return inst;
|
|
};
|
|
DateTime4.fromISO = function fromISO(text, opts) {
|
|
if (opts === void 0) {
|
|
opts = {};
|
|
}
|
|
var _parseISODate = parseISODate(text), vals = _parseISODate[0], parsedZone = _parseISODate[1];
|
|
return parseDataToDateTime(vals, parsedZone, opts, "ISO 8601", text);
|
|
};
|
|
DateTime4.fromRFC2822 = function fromRFC2822(text, opts) {
|
|
if (opts === void 0) {
|
|
opts = {};
|
|
}
|
|
var _parseRFC2822Date = parseRFC2822Date(text), vals = _parseRFC2822Date[0], parsedZone = _parseRFC2822Date[1];
|
|
return parseDataToDateTime(vals, parsedZone, opts, "RFC 2822", text);
|
|
};
|
|
DateTime4.fromHTTP = function fromHTTP(text, opts) {
|
|
if (opts === void 0) {
|
|
opts = {};
|
|
}
|
|
var _parseHTTPDate = parseHTTPDate(text), vals = _parseHTTPDate[0], parsedZone = _parseHTTPDate[1];
|
|
return parseDataToDateTime(vals, parsedZone, opts, "HTTP", opts);
|
|
};
|
|
DateTime4.fromFormat = function fromFormat(text, fmt, opts) {
|
|
if (opts === void 0) {
|
|
opts = {};
|
|
}
|
|
if (isUndefined(text) || isUndefined(fmt)) {
|
|
throw new InvalidArgumentError("fromFormat requires an input string and a format");
|
|
}
|
|
var _opts = opts, _opts$locale = _opts.locale, locale = _opts$locale === void 0 ? null : _opts$locale, _opts$numberingSystem = _opts.numberingSystem, numberingSystem = _opts$numberingSystem === void 0 ? null : _opts$numberingSystem, localeToUse = Locale.fromOpts({
|
|
locale,
|
|
numberingSystem,
|
|
defaultToEN: true
|
|
}), _parseFromTokens = parseFromTokens(localeToUse, text, fmt), vals = _parseFromTokens[0], parsedZone = _parseFromTokens[1], specificOffset = _parseFromTokens[2], invalid = _parseFromTokens[3];
|
|
if (invalid) {
|
|
return DateTime4.invalid(invalid);
|
|
} else {
|
|
return parseDataToDateTime(vals, parsedZone, opts, "format " + fmt, text, specificOffset);
|
|
}
|
|
};
|
|
DateTime4.fromString = function fromString(text, fmt, opts) {
|
|
if (opts === void 0) {
|
|
opts = {};
|
|
}
|
|
return DateTime4.fromFormat(text, fmt, opts);
|
|
};
|
|
DateTime4.fromSQL = function fromSQL(text, opts) {
|
|
if (opts === void 0) {
|
|
opts = {};
|
|
}
|
|
var _parseSQL = parseSQL(text), vals = _parseSQL[0], parsedZone = _parseSQL[1];
|
|
return parseDataToDateTime(vals, parsedZone, opts, "SQL", text);
|
|
};
|
|
DateTime4.invalid = function invalid(reason, explanation) {
|
|
if (explanation === void 0) {
|
|
explanation = null;
|
|
}
|
|
if (!reason) {
|
|
throw new InvalidArgumentError("need to specify a reason the DateTime is invalid");
|
|
}
|
|
var invalid2 = reason instanceof Invalid ? reason : new Invalid(reason, explanation);
|
|
if (Settings.throwOnInvalid) {
|
|
throw new InvalidDateTimeError(invalid2);
|
|
} else {
|
|
return new DateTime4({
|
|
invalid: invalid2
|
|
});
|
|
}
|
|
};
|
|
DateTime4.isDateTime = function isDateTime(o2) {
|
|
return o2 && o2.isLuxonDateTime || false;
|
|
};
|
|
var _proto = DateTime4.prototype;
|
|
_proto.get = function get(unit) {
|
|
return this[unit];
|
|
};
|
|
_proto.resolvedLocaleOptions = function resolvedLocaleOptions(opts) {
|
|
if (opts === void 0) {
|
|
opts = {};
|
|
}
|
|
var _Formatter$create$res = Formatter.create(this.loc.clone(opts), opts).resolvedOptions(this), locale = _Formatter$create$res.locale, numberingSystem = _Formatter$create$res.numberingSystem, calendar = _Formatter$create$res.calendar;
|
|
return {
|
|
locale,
|
|
numberingSystem,
|
|
outputCalendar: calendar
|
|
};
|
|
};
|
|
_proto.toUTC = function toUTC(offset2, opts) {
|
|
if (offset2 === void 0) {
|
|
offset2 = 0;
|
|
}
|
|
if (opts === void 0) {
|
|
opts = {};
|
|
}
|
|
return this.setZone(FixedOffsetZone.instance(offset2), opts);
|
|
};
|
|
_proto.toLocal = function toLocal() {
|
|
return this.setZone(Settings.defaultZone);
|
|
};
|
|
_proto.setZone = function setZone(zone, _temp) {
|
|
var _ref2 = _temp === void 0 ? {} : _temp, _ref2$keepLocalTime = _ref2.keepLocalTime, keepLocalTime = _ref2$keepLocalTime === void 0 ? false : _ref2$keepLocalTime, _ref2$keepCalendarTim = _ref2.keepCalendarTime, keepCalendarTime = _ref2$keepCalendarTim === void 0 ? false : _ref2$keepCalendarTim;
|
|
zone = normalizeZone(zone, Settings.defaultZone);
|
|
if (zone.equals(this.zone)) {
|
|
return this;
|
|
} else if (!zone.isValid) {
|
|
return DateTime4.invalid(unsupportedZone(zone));
|
|
} else {
|
|
var newTS = this.ts;
|
|
if (keepLocalTime || keepCalendarTime) {
|
|
var offsetGuess = zone.offset(this.ts);
|
|
var asObj = this.toObject();
|
|
var _objToTS3 = objToTS(asObj, offsetGuess, zone);
|
|
newTS = _objToTS3[0];
|
|
}
|
|
return clone(this, {
|
|
ts: newTS,
|
|
zone
|
|
});
|
|
}
|
|
};
|
|
_proto.reconfigure = function reconfigure(_temp2) {
|
|
var _ref3 = _temp2 === void 0 ? {} : _temp2, locale = _ref3.locale, numberingSystem = _ref3.numberingSystem, outputCalendar = _ref3.outputCalendar;
|
|
var loc = this.loc.clone({
|
|
locale,
|
|
numberingSystem,
|
|
outputCalendar
|
|
});
|
|
return clone(this, {
|
|
loc
|
|
});
|
|
};
|
|
_proto.setLocale = function setLocale(locale) {
|
|
return this.reconfigure({
|
|
locale
|
|
});
|
|
};
|
|
_proto.set = function set(values) {
|
|
if (!this.isValid)
|
|
return this;
|
|
var normalized = normalizeObject(values, normalizeUnit), settingWeekStuff = !isUndefined(normalized.weekYear) || !isUndefined(normalized.weekNumber) || !isUndefined(normalized.weekday), containsOrdinal = !isUndefined(normalized.ordinal), containsGregorYear = !isUndefined(normalized.year), containsGregorMD = !isUndefined(normalized.month) || !isUndefined(normalized.day), containsGregor = containsGregorYear || containsGregorMD, definiteWeekDef = normalized.weekYear || normalized.weekNumber;
|
|
if ((containsGregor || containsOrdinal) && definiteWeekDef) {
|
|
throw new ConflictingSpecificationError("Can't mix weekYear/weekNumber units with year/month/day or ordinals");
|
|
}
|
|
if (containsGregorMD && containsOrdinal) {
|
|
throw new ConflictingSpecificationError("Can't mix ordinal dates with month/day");
|
|
}
|
|
var mixed;
|
|
if (settingWeekStuff) {
|
|
mixed = weekToGregorian(_extends({}, gregorianToWeek(this.c), normalized));
|
|
} else if (!isUndefined(normalized.ordinal)) {
|
|
mixed = ordinalToGregorian(_extends({}, gregorianToOrdinal(this.c), normalized));
|
|
} else {
|
|
mixed = _extends({}, this.toObject(), normalized);
|
|
if (isUndefined(normalized.day)) {
|
|
mixed.day = Math.min(daysInMonth(mixed.year, mixed.month), mixed.day);
|
|
}
|
|
}
|
|
var _objToTS4 = objToTS(mixed, this.o, this.zone), ts = _objToTS4[0], o2 = _objToTS4[1];
|
|
return clone(this, {
|
|
ts,
|
|
o: o2
|
|
});
|
|
};
|
|
_proto.plus = function plus(duration) {
|
|
if (!this.isValid)
|
|
return this;
|
|
var dur = Duration3.fromDurationLike(duration);
|
|
return clone(this, adjustTime(this, dur));
|
|
};
|
|
_proto.minus = function minus(duration) {
|
|
if (!this.isValid)
|
|
return this;
|
|
var dur = Duration3.fromDurationLike(duration).negate();
|
|
return clone(this, adjustTime(this, dur));
|
|
};
|
|
_proto.startOf = function startOf(unit) {
|
|
if (!this.isValid)
|
|
return this;
|
|
var o2 = {}, normalizedUnit = Duration3.normalizeUnit(unit);
|
|
switch (normalizedUnit) {
|
|
case "years":
|
|
o2.month = 1;
|
|
case "quarters":
|
|
case "months":
|
|
o2.day = 1;
|
|
case "weeks":
|
|
case "days":
|
|
o2.hour = 0;
|
|
case "hours":
|
|
o2.minute = 0;
|
|
case "minutes":
|
|
o2.second = 0;
|
|
case "seconds":
|
|
o2.millisecond = 0;
|
|
break;
|
|
}
|
|
if (normalizedUnit === "weeks") {
|
|
o2.weekday = 1;
|
|
}
|
|
if (normalizedUnit === "quarters") {
|
|
var q3 = Math.ceil(this.month / 3);
|
|
o2.month = (q3 - 1) * 3 + 1;
|
|
}
|
|
return this.set(o2);
|
|
};
|
|
_proto.endOf = function endOf(unit) {
|
|
var _this$plus;
|
|
return this.isValid ? this.plus((_this$plus = {}, _this$plus[unit] = 1, _this$plus)).startOf(unit).minus(1) : this;
|
|
};
|
|
_proto.toFormat = function toFormat(fmt, opts) {
|
|
if (opts === void 0) {
|
|
opts = {};
|
|
}
|
|
return this.isValid ? Formatter.create(this.loc.redefaultToEN(opts)).formatDateTimeFromString(this, fmt) : INVALID;
|
|
};
|
|
_proto.toLocaleString = function toLocaleString(formatOpts, opts) {
|
|
if (formatOpts === void 0) {
|
|
formatOpts = DATE_SHORT;
|
|
}
|
|
if (opts === void 0) {
|
|
opts = {};
|
|
}
|
|
return this.isValid ? Formatter.create(this.loc.clone(opts), formatOpts).formatDateTime(this) : INVALID;
|
|
};
|
|
_proto.toLocaleParts = function toLocaleParts(opts) {
|
|
if (opts === void 0) {
|
|
opts = {};
|
|
}
|
|
return this.isValid ? Formatter.create(this.loc.clone(opts), opts).formatDateTimeParts(this) : [];
|
|
};
|
|
_proto.toISO = function toISO(_temp3) {
|
|
var _ref4 = _temp3 === void 0 ? {} : _temp3, _ref4$format = _ref4.format, format = _ref4$format === void 0 ? "extended" : _ref4$format, _ref4$suppressSeconds = _ref4.suppressSeconds, suppressSeconds = _ref4$suppressSeconds === void 0 ? false : _ref4$suppressSeconds, _ref4$suppressMillise = _ref4.suppressMilliseconds, suppressMilliseconds = _ref4$suppressMillise === void 0 ? false : _ref4$suppressMillise, _ref4$includeOffset = _ref4.includeOffset, includeOffset = _ref4$includeOffset === void 0 ? true : _ref4$includeOffset;
|
|
if (!this.isValid) {
|
|
return null;
|
|
}
|
|
var ext = format === "extended";
|
|
var c3 = _toISODate(this, ext);
|
|
c3 += "T";
|
|
c3 += _toISOTime(this, ext, suppressSeconds, suppressMilliseconds, includeOffset);
|
|
return c3;
|
|
};
|
|
_proto.toISODate = function toISODate(_temp4) {
|
|
var _ref5 = _temp4 === void 0 ? {} : _temp4, _ref5$format = _ref5.format, format = _ref5$format === void 0 ? "extended" : _ref5$format;
|
|
if (!this.isValid) {
|
|
return null;
|
|
}
|
|
return _toISODate(this, format === "extended");
|
|
};
|
|
_proto.toISOWeekDate = function toISOWeekDate() {
|
|
return toTechFormat(this, "kkkk-'W'WW-c");
|
|
};
|
|
_proto.toISOTime = function toISOTime(_temp5) {
|
|
var _ref6 = _temp5 === void 0 ? {} : _temp5, _ref6$suppressMillise = _ref6.suppressMilliseconds, suppressMilliseconds = _ref6$suppressMillise === void 0 ? false : _ref6$suppressMillise, _ref6$suppressSeconds = _ref6.suppressSeconds, suppressSeconds = _ref6$suppressSeconds === void 0 ? false : _ref6$suppressSeconds, _ref6$includeOffset = _ref6.includeOffset, includeOffset = _ref6$includeOffset === void 0 ? true : _ref6$includeOffset, _ref6$includePrefix = _ref6.includePrefix, includePrefix = _ref6$includePrefix === void 0 ? false : _ref6$includePrefix, _ref6$format = _ref6.format, format = _ref6$format === void 0 ? "extended" : _ref6$format;
|
|
if (!this.isValid) {
|
|
return null;
|
|
}
|
|
var c3 = includePrefix ? "T" : "";
|
|
return c3 + _toISOTime(this, format === "extended", suppressSeconds, suppressMilliseconds, includeOffset);
|
|
};
|
|
_proto.toRFC2822 = function toRFC2822() {
|
|
return toTechFormat(this, "EEE, dd LLL yyyy HH:mm:ss ZZZ", false);
|
|
};
|
|
_proto.toHTTP = function toHTTP() {
|
|
return toTechFormat(this.toUTC(), "EEE, dd LLL yyyy HH:mm:ss 'GMT'");
|
|
};
|
|
_proto.toSQLDate = function toSQLDate() {
|
|
if (!this.isValid) {
|
|
return null;
|
|
}
|
|
return _toISODate(this, true);
|
|
};
|
|
_proto.toSQLTime = function toSQLTime(_temp6) {
|
|
var _ref7 = _temp6 === void 0 ? {} : _temp6, _ref7$includeOffset = _ref7.includeOffset, includeOffset = _ref7$includeOffset === void 0 ? true : _ref7$includeOffset, _ref7$includeZone = _ref7.includeZone, includeZone = _ref7$includeZone === void 0 ? false : _ref7$includeZone, _ref7$includeOffsetSp = _ref7.includeOffsetSpace, includeOffsetSpace = _ref7$includeOffsetSp === void 0 ? true : _ref7$includeOffsetSp;
|
|
var fmt = "HH:mm:ss.SSS";
|
|
if (includeZone || includeOffset) {
|
|
if (includeOffsetSpace) {
|
|
fmt += " ";
|
|
}
|
|
if (includeZone) {
|
|
fmt += "z";
|
|
} else if (includeOffset) {
|
|
fmt += "ZZ";
|
|
}
|
|
}
|
|
return toTechFormat(this, fmt, true);
|
|
};
|
|
_proto.toSQL = function toSQL(opts) {
|
|
if (opts === void 0) {
|
|
opts = {};
|
|
}
|
|
if (!this.isValid) {
|
|
return null;
|
|
}
|
|
return this.toSQLDate() + " " + this.toSQLTime(opts);
|
|
};
|
|
_proto.toString = function toString() {
|
|
return this.isValid ? this.toISO() : INVALID;
|
|
};
|
|
_proto.valueOf = function valueOf() {
|
|
return this.toMillis();
|
|
};
|
|
_proto.toMillis = function toMillis() {
|
|
return this.isValid ? this.ts : NaN;
|
|
};
|
|
_proto.toSeconds = function toSeconds() {
|
|
return this.isValid ? this.ts / 1e3 : NaN;
|
|
};
|
|
_proto.toUnixInteger = function toUnixInteger() {
|
|
return this.isValid ? Math.floor(this.ts / 1e3) : NaN;
|
|
};
|
|
_proto.toJSON = function toJSON() {
|
|
return this.toISO();
|
|
};
|
|
_proto.toBSON = function toBSON() {
|
|
return this.toJSDate();
|
|
};
|
|
_proto.toObject = function toObject(opts) {
|
|
if (opts === void 0) {
|
|
opts = {};
|
|
}
|
|
if (!this.isValid)
|
|
return {};
|
|
var base = _extends({}, this.c);
|
|
if (opts.includeConfig) {
|
|
base.outputCalendar = this.outputCalendar;
|
|
base.numberingSystem = this.loc.numberingSystem;
|
|
base.locale = this.loc.locale;
|
|
}
|
|
return base;
|
|
};
|
|
_proto.toJSDate = function toJSDate() {
|
|
return new Date(this.isValid ? this.ts : NaN);
|
|
};
|
|
_proto.diff = function diff(otherDateTime, unit, opts) {
|
|
if (unit === void 0) {
|
|
unit = "milliseconds";
|
|
}
|
|
if (opts === void 0) {
|
|
opts = {};
|
|
}
|
|
if (!this.isValid || !otherDateTime.isValid) {
|
|
return Duration3.invalid("created by diffing an invalid DateTime");
|
|
}
|
|
var durOpts = _extends({
|
|
locale: this.locale,
|
|
numberingSystem: this.numberingSystem
|
|
}, opts);
|
|
var units = maybeArray(unit).map(Duration3.normalizeUnit), otherIsLater = otherDateTime.valueOf() > this.valueOf(), earlier = otherIsLater ? this : otherDateTime, later = otherIsLater ? otherDateTime : this, diffed = _diff(earlier, later, units, durOpts);
|
|
return otherIsLater ? diffed.negate() : diffed;
|
|
};
|
|
_proto.diffNow = function diffNow(unit, opts) {
|
|
if (unit === void 0) {
|
|
unit = "milliseconds";
|
|
}
|
|
if (opts === void 0) {
|
|
opts = {};
|
|
}
|
|
return this.diff(DateTime4.now(), unit, opts);
|
|
};
|
|
_proto.until = function until(otherDateTime) {
|
|
return this.isValid ? Interval.fromDateTimes(this, otherDateTime) : this;
|
|
};
|
|
_proto.hasSame = function hasSame(otherDateTime, unit) {
|
|
if (!this.isValid)
|
|
return false;
|
|
var inputMs = otherDateTime.valueOf();
|
|
var adjustedToZone = this.setZone(otherDateTime.zone, {
|
|
keepLocalTime: true
|
|
});
|
|
return adjustedToZone.startOf(unit) <= inputMs && inputMs <= adjustedToZone.endOf(unit);
|
|
};
|
|
_proto.equals = function equals(other) {
|
|
return this.isValid && other.isValid && this.valueOf() === other.valueOf() && this.zone.equals(other.zone) && this.loc.equals(other.loc);
|
|
};
|
|
_proto.toRelative = function toRelative(options) {
|
|
if (options === void 0) {
|
|
options = {};
|
|
}
|
|
if (!this.isValid)
|
|
return null;
|
|
var base = options.base || DateTime4.fromObject({}, {
|
|
zone: this.zone
|
|
}), padding = options.padding ? this < base ? -options.padding : options.padding : 0;
|
|
var units = ["years", "months", "days", "hours", "minutes", "seconds"];
|
|
var unit = options.unit;
|
|
if (Array.isArray(options.unit)) {
|
|
units = options.unit;
|
|
unit = void 0;
|
|
}
|
|
return diffRelative(base, this.plus(padding), _extends({}, options, {
|
|
numeric: "always",
|
|
units,
|
|
unit
|
|
}));
|
|
};
|
|
_proto.toRelativeCalendar = function toRelativeCalendar(options) {
|
|
if (options === void 0) {
|
|
options = {};
|
|
}
|
|
if (!this.isValid)
|
|
return null;
|
|
return diffRelative(options.base || DateTime4.fromObject({}, {
|
|
zone: this.zone
|
|
}), this, _extends({}, options, {
|
|
numeric: "auto",
|
|
units: ["years", "months", "days"],
|
|
calendary: true
|
|
}));
|
|
};
|
|
DateTime4.min = function min() {
|
|
for (var _len = arguments.length, dateTimes = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
dateTimes[_key] = arguments[_key];
|
|
}
|
|
if (!dateTimes.every(DateTime4.isDateTime)) {
|
|
throw new InvalidArgumentError("min requires all arguments be DateTimes");
|
|
}
|
|
return bestBy(dateTimes, function(i3) {
|
|
return i3.valueOf();
|
|
}, Math.min);
|
|
};
|
|
DateTime4.max = function max() {
|
|
for (var _len2 = arguments.length, dateTimes = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
|
|
dateTimes[_key2] = arguments[_key2];
|
|
}
|
|
if (!dateTimes.every(DateTime4.isDateTime)) {
|
|
throw new InvalidArgumentError("max requires all arguments be DateTimes");
|
|
}
|
|
return bestBy(dateTimes, function(i3) {
|
|
return i3.valueOf();
|
|
}, Math.max);
|
|
};
|
|
DateTime4.fromFormatExplain = function fromFormatExplain(text, fmt, options) {
|
|
if (options === void 0) {
|
|
options = {};
|
|
}
|
|
var _options = options, _options$locale = _options.locale, locale = _options$locale === void 0 ? null : _options$locale, _options$numberingSys = _options.numberingSystem, numberingSystem = _options$numberingSys === void 0 ? null : _options$numberingSys, localeToUse = Locale.fromOpts({
|
|
locale,
|
|
numberingSystem,
|
|
defaultToEN: true
|
|
});
|
|
return explainFromTokens(localeToUse, text, fmt);
|
|
};
|
|
DateTime4.fromStringExplain = function fromStringExplain(text, fmt, options) {
|
|
if (options === void 0) {
|
|
options = {};
|
|
}
|
|
return DateTime4.fromFormatExplain(text, fmt, options);
|
|
};
|
|
_createClass(DateTime4, [{
|
|
key: "isValid",
|
|
get: function get() {
|
|
return this.invalid === null;
|
|
}
|
|
}, {
|
|
key: "invalidReason",
|
|
get: function get() {
|
|
return this.invalid ? this.invalid.reason : null;
|
|
}
|
|
}, {
|
|
key: "invalidExplanation",
|
|
get: function get() {
|
|
return this.invalid ? this.invalid.explanation : null;
|
|
}
|
|
}, {
|
|
key: "locale",
|
|
get: function get() {
|
|
return this.isValid ? this.loc.locale : null;
|
|
}
|
|
}, {
|
|
key: "numberingSystem",
|
|
get: function get() {
|
|
return this.isValid ? this.loc.numberingSystem : null;
|
|
}
|
|
}, {
|
|
key: "outputCalendar",
|
|
get: function get() {
|
|
return this.isValid ? this.loc.outputCalendar : null;
|
|
}
|
|
}, {
|
|
key: "zone",
|
|
get: function get() {
|
|
return this._zone;
|
|
}
|
|
}, {
|
|
key: "zoneName",
|
|
get: function get() {
|
|
return this.isValid ? this.zone.name : null;
|
|
}
|
|
}, {
|
|
key: "year",
|
|
get: function get() {
|
|
return this.isValid ? this.c.year : NaN;
|
|
}
|
|
}, {
|
|
key: "quarter",
|
|
get: function get() {
|
|
return this.isValid ? Math.ceil(this.c.month / 3) : NaN;
|
|
}
|
|
}, {
|
|
key: "month",
|
|
get: function get() {
|
|
return this.isValid ? this.c.month : NaN;
|
|
}
|
|
}, {
|
|
key: "day",
|
|
get: function get() {
|
|
return this.isValid ? this.c.day : NaN;
|
|
}
|
|
}, {
|
|
key: "hour",
|
|
get: function get() {
|
|
return this.isValid ? this.c.hour : NaN;
|
|
}
|
|
}, {
|
|
key: "minute",
|
|
get: function get() {
|
|
return this.isValid ? this.c.minute : NaN;
|
|
}
|
|
}, {
|
|
key: "second",
|
|
get: function get() {
|
|
return this.isValid ? this.c.second : NaN;
|
|
}
|
|
}, {
|
|
key: "millisecond",
|
|
get: function get() {
|
|
return this.isValid ? this.c.millisecond : NaN;
|
|
}
|
|
}, {
|
|
key: "weekYear",
|
|
get: function get() {
|
|
return this.isValid ? possiblyCachedWeekData(this).weekYear : NaN;
|
|
}
|
|
}, {
|
|
key: "weekNumber",
|
|
get: function get() {
|
|
return this.isValid ? possiblyCachedWeekData(this).weekNumber : NaN;
|
|
}
|
|
}, {
|
|
key: "weekday",
|
|
get: function get() {
|
|
return this.isValid ? possiblyCachedWeekData(this).weekday : NaN;
|
|
}
|
|
}, {
|
|
key: "ordinal",
|
|
get: function get() {
|
|
return this.isValid ? gregorianToOrdinal(this.c).ordinal : NaN;
|
|
}
|
|
}, {
|
|
key: "monthShort",
|
|
get: function get() {
|
|
return this.isValid ? Info.months("short", {
|
|
locObj: this.loc
|
|
})[this.month - 1] : null;
|
|
}
|
|
}, {
|
|
key: "monthLong",
|
|
get: function get() {
|
|
return this.isValid ? Info.months("long", {
|
|
locObj: this.loc
|
|
})[this.month - 1] : null;
|
|
}
|
|
}, {
|
|
key: "weekdayShort",
|
|
get: function get() {
|
|
return this.isValid ? Info.weekdays("short", {
|
|
locObj: this.loc
|
|
})[this.weekday - 1] : null;
|
|
}
|
|
}, {
|
|
key: "weekdayLong",
|
|
get: function get() {
|
|
return this.isValid ? Info.weekdays("long", {
|
|
locObj: this.loc
|
|
})[this.weekday - 1] : null;
|
|
}
|
|
}, {
|
|
key: "offset",
|
|
get: function get() {
|
|
return this.isValid ? +this.o : NaN;
|
|
}
|
|
}, {
|
|
key: "offsetNameShort",
|
|
get: function get() {
|
|
if (this.isValid) {
|
|
return this.zone.offsetName(this.ts, {
|
|
format: "short",
|
|
locale: this.locale
|
|
});
|
|
} else {
|
|
return null;
|
|
}
|
|
}
|
|
}, {
|
|
key: "offsetNameLong",
|
|
get: function get() {
|
|
if (this.isValid) {
|
|
return this.zone.offsetName(this.ts, {
|
|
format: "long",
|
|
locale: this.locale
|
|
});
|
|
} else {
|
|
return null;
|
|
}
|
|
}
|
|
}, {
|
|
key: "isOffsetFixed",
|
|
get: function get() {
|
|
return this.isValid ? this.zone.isUniversal : null;
|
|
}
|
|
}, {
|
|
key: "isInDST",
|
|
get: function get() {
|
|
if (this.isOffsetFixed) {
|
|
return false;
|
|
} else {
|
|
return this.offset > this.set({
|
|
month: 1
|
|
}).offset || this.offset > this.set({
|
|
month: 5
|
|
}).offset;
|
|
}
|
|
}
|
|
}, {
|
|
key: "isInLeapYear",
|
|
get: function get() {
|
|
return isLeapYear(this.year);
|
|
}
|
|
}, {
|
|
key: "daysInMonth",
|
|
get: function get() {
|
|
return daysInMonth(this.year, this.month);
|
|
}
|
|
}, {
|
|
key: "daysInYear",
|
|
get: function get() {
|
|
return this.isValid ? daysInYear(this.year) : NaN;
|
|
}
|
|
}, {
|
|
key: "weeksInWeekYear",
|
|
get: function get() {
|
|
return this.isValid ? weeksInWeekYear(this.weekYear) : NaN;
|
|
}
|
|
}], [{
|
|
key: "DATE_SHORT",
|
|
get: function get() {
|
|
return DATE_SHORT;
|
|
}
|
|
}, {
|
|
key: "DATE_MED",
|
|
get: function get() {
|
|
return DATE_MED;
|
|
}
|
|
}, {
|
|
key: "DATE_MED_WITH_WEEKDAY",
|
|
get: function get() {
|
|
return DATE_MED_WITH_WEEKDAY;
|
|
}
|
|
}, {
|
|
key: "DATE_FULL",
|
|
get: function get() {
|
|
return DATE_FULL;
|
|
}
|
|
}, {
|
|
key: "DATE_HUGE",
|
|
get: function get() {
|
|
return DATE_HUGE;
|
|
}
|
|
}, {
|
|
key: "TIME_SIMPLE",
|
|
get: function get() {
|
|
return TIME_SIMPLE;
|
|
}
|
|
}, {
|
|
key: "TIME_WITH_SECONDS",
|
|
get: function get() {
|
|
return TIME_WITH_SECONDS;
|
|
}
|
|
}, {
|
|
key: "TIME_WITH_SHORT_OFFSET",
|
|
get: function get() {
|
|
return TIME_WITH_SHORT_OFFSET;
|
|
}
|
|
}, {
|
|
key: "TIME_WITH_LONG_OFFSET",
|
|
get: function get() {
|
|
return TIME_WITH_LONG_OFFSET;
|
|
}
|
|
}, {
|
|
key: "TIME_24_SIMPLE",
|
|
get: function get() {
|
|
return TIME_24_SIMPLE;
|
|
}
|
|
}, {
|
|
key: "TIME_24_WITH_SECONDS",
|
|
get: function get() {
|
|
return TIME_24_WITH_SECONDS;
|
|
}
|
|
}, {
|
|
key: "TIME_24_WITH_SHORT_OFFSET",
|
|
get: function get() {
|
|
return TIME_24_WITH_SHORT_OFFSET;
|
|
}
|
|
}, {
|
|
key: "TIME_24_WITH_LONG_OFFSET",
|
|
get: function get() {
|
|
return TIME_24_WITH_LONG_OFFSET;
|
|
}
|
|
}, {
|
|
key: "DATETIME_SHORT",
|
|
get: function get() {
|
|
return DATETIME_SHORT;
|
|
}
|
|
}, {
|
|
key: "DATETIME_SHORT_WITH_SECONDS",
|
|
get: function get() {
|
|
return DATETIME_SHORT_WITH_SECONDS;
|
|
}
|
|
}, {
|
|
key: "DATETIME_MED",
|
|
get: function get() {
|
|
return DATETIME_MED;
|
|
}
|
|
}, {
|
|
key: "DATETIME_MED_WITH_SECONDS",
|
|
get: function get() {
|
|
return DATETIME_MED_WITH_SECONDS;
|
|
}
|
|
}, {
|
|
key: "DATETIME_MED_WITH_WEEKDAY",
|
|
get: function get() {
|
|
return DATETIME_MED_WITH_WEEKDAY;
|
|
}
|
|
}, {
|
|
key: "DATETIME_FULL",
|
|
get: function get() {
|
|
return DATETIME_FULL;
|
|
}
|
|
}, {
|
|
key: "DATETIME_FULL_WITH_SECONDS",
|
|
get: function get() {
|
|
return DATETIME_FULL_WITH_SECONDS;
|
|
}
|
|
}, {
|
|
key: "DATETIME_HUGE",
|
|
get: function get() {
|
|
return DATETIME_HUGE;
|
|
}
|
|
}, {
|
|
key: "DATETIME_HUGE_WITH_SECONDS",
|
|
get: function get() {
|
|
return DATETIME_HUGE_WITH_SECONDS;
|
|
}
|
|
}]);
|
|
return DateTime4;
|
|
}();
|
|
function friendlyDateTime(dateTimeish) {
|
|
if (DateTime3.isDateTime(dateTimeish)) {
|
|
return dateTimeish;
|
|
} else if (dateTimeish && dateTimeish.valueOf && isNumber(dateTimeish.valueOf())) {
|
|
return DateTime3.fromJSDate(dateTimeish);
|
|
} else if (dateTimeish && typeof dateTimeish === "object") {
|
|
return DateTime3.fromObject(dateTimeish);
|
|
} else {
|
|
throw new InvalidArgumentError("Unknown datetime argument: " + dateTimeish + ", of type " + typeof dateTimeish);
|
|
}
|
|
}
|
|
var VERSION = "2.3.1";
|
|
exports.DateTime = DateTime3;
|
|
exports.Duration = Duration3;
|
|
exports.FixedOffsetZone = FixedOffsetZone;
|
|
exports.IANAZone = IANAZone;
|
|
exports.Info = Info;
|
|
exports.Interval = Interval;
|
|
exports.InvalidZone = InvalidZone;
|
|
exports.Settings = Settings;
|
|
exports.SystemZone = SystemZone;
|
|
exports.VERSION = VERSION;
|
|
exports.Zone = Zone;
|
|
}
|
|
});
|
|
|
|
// node_modules/color-name/index.js
|
|
var require_color_name = __commonJS({
|
|
"node_modules/color-name/index.js"(exports, module2) {
|
|
"use strict";
|
|
module2.exports = {
|
|
"aliceblue": [240, 248, 255],
|
|
"antiquewhite": [250, 235, 215],
|
|
"aqua": [0, 255, 255],
|
|
"aquamarine": [127, 255, 212],
|
|
"azure": [240, 255, 255],
|
|
"beige": [245, 245, 220],
|
|
"bisque": [255, 228, 196],
|
|
"black": [0, 0, 0],
|
|
"blanchedalmond": [255, 235, 205],
|
|
"blue": [0, 0, 255],
|
|
"blueviolet": [138, 43, 226],
|
|
"brown": [165, 42, 42],
|
|
"burlywood": [222, 184, 135],
|
|
"cadetblue": [95, 158, 160],
|
|
"chartreuse": [127, 255, 0],
|
|
"chocolate": [210, 105, 30],
|
|
"coral": [255, 127, 80],
|
|
"cornflowerblue": [100, 149, 237],
|
|
"cornsilk": [255, 248, 220],
|
|
"crimson": [220, 20, 60],
|
|
"cyan": [0, 255, 255],
|
|
"darkblue": [0, 0, 139],
|
|
"darkcyan": [0, 139, 139],
|
|
"darkgoldenrod": [184, 134, 11],
|
|
"darkgray": [169, 169, 169],
|
|
"darkgreen": [0, 100, 0],
|
|
"darkgrey": [169, 169, 169],
|
|
"darkkhaki": [189, 183, 107],
|
|
"darkmagenta": [139, 0, 139],
|
|
"darkolivegreen": [85, 107, 47],
|
|
"darkorange": [255, 140, 0],
|
|
"darkorchid": [153, 50, 204],
|
|
"darkred": [139, 0, 0],
|
|
"darksalmon": [233, 150, 122],
|
|
"darkseagreen": [143, 188, 143],
|
|
"darkslateblue": [72, 61, 139],
|
|
"darkslategray": [47, 79, 79],
|
|
"darkslategrey": [47, 79, 79],
|
|
"darkturquoise": [0, 206, 209],
|
|
"darkviolet": [148, 0, 211],
|
|
"deeppink": [255, 20, 147],
|
|
"deepskyblue": [0, 191, 255],
|
|
"dimgray": [105, 105, 105],
|
|
"dimgrey": [105, 105, 105],
|
|
"dodgerblue": [30, 144, 255],
|
|
"firebrick": [178, 34, 34],
|
|
"floralwhite": [255, 250, 240],
|
|
"forestgreen": [34, 139, 34],
|
|
"fuchsia": [255, 0, 255],
|
|
"gainsboro": [220, 220, 220],
|
|
"ghostwhite": [248, 248, 255],
|
|
"gold": [255, 215, 0],
|
|
"goldenrod": [218, 165, 32],
|
|
"gray": [128, 128, 128],
|
|
"green": [0, 128, 0],
|
|
"greenyellow": [173, 255, 47],
|
|
"grey": [128, 128, 128],
|
|
"honeydew": [240, 255, 240],
|
|
"hotpink": [255, 105, 180],
|
|
"indianred": [205, 92, 92],
|
|
"indigo": [75, 0, 130],
|
|
"ivory": [255, 255, 240],
|
|
"khaki": [240, 230, 140],
|
|
"lavender": [230, 230, 250],
|
|
"lavenderblush": [255, 240, 245],
|
|
"lawngreen": [124, 252, 0],
|
|
"lemonchiffon": [255, 250, 205],
|
|
"lightblue": [173, 216, 230],
|
|
"lightcoral": [240, 128, 128],
|
|
"lightcyan": [224, 255, 255],
|
|
"lightgoldenrodyellow": [250, 250, 210],
|
|
"lightgray": [211, 211, 211],
|
|
"lightgreen": [144, 238, 144],
|
|
"lightgrey": [211, 211, 211],
|
|
"lightpink": [255, 182, 193],
|
|
"lightsalmon": [255, 160, 122],
|
|
"lightseagreen": [32, 178, 170],
|
|
"lightskyblue": [135, 206, 250],
|
|
"lightslategray": [119, 136, 153],
|
|
"lightslategrey": [119, 136, 153],
|
|
"lightsteelblue": [176, 196, 222],
|
|
"lightyellow": [255, 255, 224],
|
|
"lime": [0, 255, 0],
|
|
"limegreen": [50, 205, 50],
|
|
"linen": [250, 240, 230],
|
|
"magenta": [255, 0, 255],
|
|
"maroon": [128, 0, 0],
|
|
"mediumaquamarine": [102, 205, 170],
|
|
"mediumblue": [0, 0, 205],
|
|
"mediumorchid": [186, 85, 211],
|
|
"mediumpurple": [147, 112, 219],
|
|
"mediumseagreen": [60, 179, 113],
|
|
"mediumslateblue": [123, 104, 238],
|
|
"mediumspringgreen": [0, 250, 154],
|
|
"mediumturquoise": [72, 209, 204],
|
|
"mediumvioletred": [199, 21, 133],
|
|
"midnightblue": [25, 25, 112],
|
|
"mintcream": [245, 255, 250],
|
|
"mistyrose": [255, 228, 225],
|
|
"moccasin": [255, 228, 181],
|
|
"navajowhite": [255, 222, 173],
|
|
"navy": [0, 0, 128],
|
|
"oldlace": [253, 245, 230],
|
|
"olive": [128, 128, 0],
|
|
"olivedrab": [107, 142, 35],
|
|
"orange": [255, 165, 0],
|
|
"orangered": [255, 69, 0],
|
|
"orchid": [218, 112, 214],
|
|
"palegoldenrod": [238, 232, 170],
|
|
"palegreen": [152, 251, 152],
|
|
"paleturquoise": [175, 238, 238],
|
|
"palevioletred": [219, 112, 147],
|
|
"papayawhip": [255, 239, 213],
|
|
"peachpuff": [255, 218, 185],
|
|
"peru": [205, 133, 63],
|
|
"pink": [255, 192, 203],
|
|
"plum": [221, 160, 221],
|
|
"powderblue": [176, 224, 230],
|
|
"purple": [128, 0, 128],
|
|
"rebeccapurple": [102, 51, 153],
|
|
"red": [255, 0, 0],
|
|
"rosybrown": [188, 143, 143],
|
|
"royalblue": [65, 105, 225],
|
|
"saddlebrown": [139, 69, 19],
|
|
"salmon": [250, 128, 114],
|
|
"sandybrown": [244, 164, 96],
|
|
"seagreen": [46, 139, 87],
|
|
"seashell": [255, 245, 238],
|
|
"sienna": [160, 82, 45],
|
|
"silver": [192, 192, 192],
|
|
"skyblue": [135, 206, 235],
|
|
"slateblue": [106, 90, 205],
|
|
"slategray": [112, 128, 144],
|
|
"slategrey": [112, 128, 144],
|
|
"snow": [255, 250, 250],
|
|
"springgreen": [0, 255, 127],
|
|
"steelblue": [70, 130, 180],
|
|
"tan": [210, 180, 140],
|
|
"teal": [0, 128, 128],
|
|
"thistle": [216, 191, 216],
|
|
"tomato": [255, 99, 71],
|
|
"turquoise": [64, 224, 208],
|
|
"violet": [238, 130, 238],
|
|
"wheat": [245, 222, 179],
|
|
"white": [255, 255, 255],
|
|
"whitesmoke": [245, 245, 245],
|
|
"yellow": [255, 255, 0],
|
|
"yellowgreen": [154, 205, 50]
|
|
};
|
|
}
|
|
});
|
|
|
|
// node_modules/is-arrayish/index.js
|
|
var require_is_arrayish = __commonJS({
|
|
"node_modules/is-arrayish/index.js"(exports, module2) {
|
|
module2.exports = function isArrayish(obj) {
|
|
if (!obj || typeof obj === "string") {
|
|
return false;
|
|
}
|
|
return obj instanceof Array || Array.isArray(obj) || obj.length >= 0 && (obj.splice instanceof Function || Object.getOwnPropertyDescriptor(obj, obj.length - 1) && obj.constructor.name !== "String");
|
|
};
|
|
}
|
|
});
|
|
|
|
// node_modules/simple-swizzle/index.js
|
|
var require_simple_swizzle = __commonJS({
|
|
"node_modules/simple-swizzle/index.js"(exports, module2) {
|
|
"use strict";
|
|
var isArrayish = require_is_arrayish();
|
|
var concat = Array.prototype.concat;
|
|
var slice = Array.prototype.slice;
|
|
var swizzle = module2.exports = function swizzle2(args) {
|
|
var results = [];
|
|
for (var i3 = 0, len = args.length; i3 < len; i3++) {
|
|
var arg = args[i3];
|
|
if (isArrayish(arg)) {
|
|
results = concat.call(results, slice.call(arg));
|
|
} else {
|
|
results.push(arg);
|
|
}
|
|
}
|
|
return results;
|
|
};
|
|
swizzle.wrap = function(fn) {
|
|
return function() {
|
|
return fn(swizzle(arguments));
|
|
};
|
|
};
|
|
}
|
|
});
|
|
|
|
// node_modules/color-string/index.js
|
|
var require_color_string = __commonJS({
|
|
"node_modules/color-string/index.js"(exports, module2) {
|
|
var colorNames = require_color_name();
|
|
var swizzle = require_simple_swizzle();
|
|
var hasOwnProperty2 = Object.hasOwnProperty;
|
|
var reverseNames = {};
|
|
for (name in colorNames) {
|
|
if (hasOwnProperty2.call(colorNames, name)) {
|
|
reverseNames[colorNames[name]] = name;
|
|
}
|
|
}
|
|
var name;
|
|
var cs = module2.exports = {
|
|
to: {},
|
|
get: {}
|
|
};
|
|
cs.get = function(string) {
|
|
var prefix = string.substring(0, 3).toLowerCase();
|
|
var val;
|
|
var model;
|
|
switch (prefix) {
|
|
case "hsl":
|
|
val = cs.get.hsl(string);
|
|
model = "hsl";
|
|
break;
|
|
case "hwb":
|
|
val = cs.get.hwb(string);
|
|
model = "hwb";
|
|
break;
|
|
default:
|
|
val = cs.get.rgb(string);
|
|
model = "rgb";
|
|
break;
|
|
}
|
|
if (!val) {
|
|
return null;
|
|
}
|
|
return { model, value: val };
|
|
};
|
|
cs.get.rgb = function(string) {
|
|
if (!string) {
|
|
return null;
|
|
}
|
|
var abbr = /^#([a-f0-9]{3,4})$/i;
|
|
var hex = /^#([a-f0-9]{6})([a-f0-9]{2})?$/i;
|
|
var rgba = /^rgba?\(\s*([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)\s*(?:[,|\/]\s*([+-]?[\d\.]+)(%?)\s*)?\)$/;
|
|
var per = /^rgba?\(\s*([+-]?[\d\.]+)\%\s*,?\s*([+-]?[\d\.]+)\%\s*,?\s*([+-]?[\d\.]+)\%\s*(?:[,|\/]\s*([+-]?[\d\.]+)(%?)\s*)?\)$/;
|
|
var keyword = /^(\w+)$/;
|
|
var rgb = [0, 0, 0, 1];
|
|
var match;
|
|
var i3;
|
|
var hexAlpha;
|
|
if (match = string.match(hex)) {
|
|
hexAlpha = match[2];
|
|
match = match[1];
|
|
for (i3 = 0; i3 < 3; i3++) {
|
|
var i22 = i3 * 2;
|
|
rgb[i3] = parseInt(match.slice(i22, i22 + 2), 16);
|
|
}
|
|
if (hexAlpha) {
|
|
rgb[3] = parseInt(hexAlpha, 16) / 255;
|
|
}
|
|
} else if (match = string.match(abbr)) {
|
|
match = match[1];
|
|
hexAlpha = match[3];
|
|
for (i3 = 0; i3 < 3; i3++) {
|
|
rgb[i3] = parseInt(match[i3] + match[i3], 16);
|
|
}
|
|
if (hexAlpha) {
|
|
rgb[3] = parseInt(hexAlpha + hexAlpha, 16) / 255;
|
|
}
|
|
} else if (match = string.match(rgba)) {
|
|
for (i3 = 0; i3 < 3; i3++) {
|
|
rgb[i3] = parseInt(match[i3 + 1], 0);
|
|
}
|
|
if (match[4]) {
|
|
if (match[5]) {
|
|
rgb[3] = parseFloat(match[4]) * 0.01;
|
|
} else {
|
|
rgb[3] = parseFloat(match[4]);
|
|
}
|
|
}
|
|
} else if (match = string.match(per)) {
|
|
for (i3 = 0; i3 < 3; i3++) {
|
|
rgb[i3] = Math.round(parseFloat(match[i3 + 1]) * 2.55);
|
|
}
|
|
if (match[4]) {
|
|
if (match[5]) {
|
|
rgb[3] = parseFloat(match[4]) * 0.01;
|
|
} else {
|
|
rgb[3] = parseFloat(match[4]);
|
|
}
|
|
}
|
|
} else if (match = string.match(keyword)) {
|
|
if (match[1] === "transparent") {
|
|
return [0, 0, 0, 0];
|
|
}
|
|
if (!hasOwnProperty2.call(colorNames, match[1])) {
|
|
return null;
|
|
}
|
|
rgb = colorNames[match[1]];
|
|
rgb[3] = 1;
|
|
return rgb;
|
|
} else {
|
|
return null;
|
|
}
|
|
for (i3 = 0; i3 < 3; i3++) {
|
|
rgb[i3] = clamp(rgb[i3], 0, 255);
|
|
}
|
|
rgb[3] = clamp(rgb[3], 0, 1);
|
|
return rgb;
|
|
};
|
|
cs.get.hsl = function(string) {
|
|
if (!string) {
|
|
return null;
|
|
}
|
|
var hsl = /^hsla?\(\s*([+-]?(?:\d{0,3}\.)?\d+)(?:deg)?\s*,?\s*([+-]?[\d\.]+)%\s*,?\s*([+-]?[\d\.]+)%\s*(?:[,|\/]\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:[eE][+-]?\d+)?)\s*)?\)$/;
|
|
var match = string.match(hsl);
|
|
if (match) {
|
|
var alpha = parseFloat(match[4]);
|
|
var h3 = (parseFloat(match[1]) % 360 + 360) % 360;
|
|
var s3 = clamp(parseFloat(match[2]), 0, 100);
|
|
var l3 = clamp(parseFloat(match[3]), 0, 100);
|
|
var a3 = clamp(isNaN(alpha) ? 1 : alpha, 0, 1);
|
|
return [h3, s3, l3, a3];
|
|
}
|
|
return null;
|
|
};
|
|
cs.get.hwb = function(string) {
|
|
if (!string) {
|
|
return null;
|
|
}
|
|
var hwb = /^hwb\(\s*([+-]?\d{0,3}(?:\.\d+)?)(?:deg)?\s*,\s*([+-]?[\d\.]+)%\s*,\s*([+-]?[\d\.]+)%\s*(?:,\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:[eE][+-]?\d+)?)\s*)?\)$/;
|
|
var match = string.match(hwb);
|
|
if (match) {
|
|
var alpha = parseFloat(match[4]);
|
|
var h3 = (parseFloat(match[1]) % 360 + 360) % 360;
|
|
var w3 = clamp(parseFloat(match[2]), 0, 100);
|
|
var b3 = clamp(parseFloat(match[3]), 0, 100);
|
|
var a3 = clamp(isNaN(alpha) ? 1 : alpha, 0, 1);
|
|
return [h3, w3, b3, a3];
|
|
}
|
|
return null;
|
|
};
|
|
cs.to.hex = function() {
|
|
var rgba = swizzle(arguments);
|
|
return "#" + hexDouble(rgba[0]) + hexDouble(rgba[1]) + hexDouble(rgba[2]) + (rgba[3] < 1 ? hexDouble(Math.round(rgba[3] * 255)) : "");
|
|
};
|
|
cs.to.rgb = function() {
|
|
var rgba = swizzle(arguments);
|
|
return rgba.length < 4 || rgba[3] === 1 ? "rgb(" + Math.round(rgba[0]) + ", " + Math.round(rgba[1]) + ", " + Math.round(rgba[2]) + ")" : "rgba(" + Math.round(rgba[0]) + ", " + Math.round(rgba[1]) + ", " + Math.round(rgba[2]) + ", " + rgba[3] + ")";
|
|
};
|
|
cs.to.rgb.percent = function() {
|
|
var rgba = swizzle(arguments);
|
|
var r3 = Math.round(rgba[0] / 255 * 100);
|
|
var g3 = Math.round(rgba[1] / 255 * 100);
|
|
var b3 = Math.round(rgba[2] / 255 * 100);
|
|
return rgba.length < 4 || rgba[3] === 1 ? "rgb(" + r3 + "%, " + g3 + "%, " + b3 + "%)" : "rgba(" + r3 + "%, " + g3 + "%, " + b3 + "%, " + rgba[3] + ")";
|
|
};
|
|
cs.to.hsl = function() {
|
|
var hsla = swizzle(arguments);
|
|
return hsla.length < 4 || hsla[3] === 1 ? "hsl(" + hsla[0] + ", " + hsla[1] + "%, " + hsla[2] + "%)" : "hsla(" + hsla[0] + ", " + hsla[1] + "%, " + hsla[2] + "%, " + hsla[3] + ")";
|
|
};
|
|
cs.to.hwb = function() {
|
|
var hwba = swizzle(arguments);
|
|
var a3 = "";
|
|
if (hwba.length >= 4 && hwba[3] !== 1) {
|
|
a3 = ", " + hwba[3];
|
|
}
|
|
return "hwb(" + hwba[0] + ", " + hwba[1] + "%, " + hwba[2] + "%" + a3 + ")";
|
|
};
|
|
cs.to.keyword = function(rgb) {
|
|
return reverseNames[rgb.slice(0, 3)];
|
|
};
|
|
function clamp(num, min, max) {
|
|
return Math.min(Math.max(min, num), max);
|
|
}
|
|
function hexDouble(num) {
|
|
var str = Math.round(num).toString(16).toUpperCase();
|
|
return str.length < 2 ? "0" + str : str;
|
|
}
|
|
}
|
|
});
|
|
|
|
// node_modules/color-convert/conversions.js
|
|
var require_conversions = __commonJS({
|
|
"node_modules/color-convert/conversions.js"(exports, module2) {
|
|
var cssKeywords = require_color_name();
|
|
var reverseKeywords = {};
|
|
for (const key of Object.keys(cssKeywords)) {
|
|
reverseKeywords[cssKeywords[key]] = key;
|
|
}
|
|
var convert = {
|
|
rgb: { channels: 3, labels: "rgb" },
|
|
hsl: { channels: 3, labels: "hsl" },
|
|
hsv: { channels: 3, labels: "hsv" },
|
|
hwb: { channels: 3, labels: "hwb" },
|
|
cmyk: { channels: 4, labels: "cmyk" },
|
|
xyz: { channels: 3, labels: "xyz" },
|
|
lab: { channels: 3, labels: "lab" },
|
|
lch: { channels: 3, labels: "lch" },
|
|
hex: { channels: 1, labels: ["hex"] },
|
|
keyword: { channels: 1, labels: ["keyword"] },
|
|
ansi16: { channels: 1, labels: ["ansi16"] },
|
|
ansi256: { channels: 1, labels: ["ansi256"] },
|
|
hcg: { channels: 3, labels: ["h", "c", "g"] },
|
|
apple: { channels: 3, labels: ["r16", "g16", "b16"] },
|
|
gray: { channels: 1, labels: ["gray"] }
|
|
};
|
|
module2.exports = convert;
|
|
for (const model of Object.keys(convert)) {
|
|
if (!("channels" in convert[model])) {
|
|
throw new Error("missing channels property: " + model);
|
|
}
|
|
if (!("labels" in convert[model])) {
|
|
throw new Error("missing channel labels property: " + model);
|
|
}
|
|
if (convert[model].labels.length !== convert[model].channels) {
|
|
throw new Error("channel and label counts mismatch: " + model);
|
|
}
|
|
const { channels, labels } = convert[model];
|
|
delete convert[model].channels;
|
|
delete convert[model].labels;
|
|
Object.defineProperty(convert[model], "channels", { value: channels });
|
|
Object.defineProperty(convert[model], "labels", { value: labels });
|
|
}
|
|
convert.rgb.hsl = function(rgb) {
|
|
const r3 = rgb[0] / 255;
|
|
const g3 = rgb[1] / 255;
|
|
const b3 = rgb[2] / 255;
|
|
const min = Math.min(r3, g3, b3);
|
|
const max = Math.max(r3, g3, b3);
|
|
const delta = max - min;
|
|
let h3;
|
|
let s3;
|
|
if (max === min) {
|
|
h3 = 0;
|
|
} else if (r3 === max) {
|
|
h3 = (g3 - b3) / delta;
|
|
} else if (g3 === max) {
|
|
h3 = 2 + (b3 - r3) / delta;
|
|
} else if (b3 === max) {
|
|
h3 = 4 + (r3 - g3) / delta;
|
|
}
|
|
h3 = Math.min(h3 * 60, 360);
|
|
if (h3 < 0) {
|
|
h3 += 360;
|
|
}
|
|
const l3 = (min + max) / 2;
|
|
if (max === min) {
|
|
s3 = 0;
|
|
} else if (l3 <= 0.5) {
|
|
s3 = delta / (max + min);
|
|
} else {
|
|
s3 = delta / (2 - max - min);
|
|
}
|
|
return [h3, s3 * 100, l3 * 100];
|
|
};
|
|
convert.rgb.hsv = function(rgb) {
|
|
let rdif;
|
|
let gdif;
|
|
let bdif;
|
|
let h3;
|
|
let s3;
|
|
const r3 = rgb[0] / 255;
|
|
const g3 = rgb[1] / 255;
|
|
const b3 = rgb[2] / 255;
|
|
const v3 = Math.max(r3, g3, b3);
|
|
const diff = v3 - Math.min(r3, g3, b3);
|
|
const diffc = function(c3) {
|
|
return (v3 - c3) / 6 / diff + 1 / 2;
|
|
};
|
|
if (diff === 0) {
|
|
h3 = 0;
|
|
s3 = 0;
|
|
} else {
|
|
s3 = diff / v3;
|
|
rdif = diffc(r3);
|
|
gdif = diffc(g3);
|
|
bdif = diffc(b3);
|
|
if (r3 === v3) {
|
|
h3 = bdif - gdif;
|
|
} else if (g3 === v3) {
|
|
h3 = 1 / 3 + rdif - bdif;
|
|
} else if (b3 === v3) {
|
|
h3 = 2 / 3 + gdif - rdif;
|
|
}
|
|
if (h3 < 0) {
|
|
h3 += 1;
|
|
} else if (h3 > 1) {
|
|
h3 -= 1;
|
|
}
|
|
}
|
|
return [
|
|
h3 * 360,
|
|
s3 * 100,
|
|
v3 * 100
|
|
];
|
|
};
|
|
convert.rgb.hwb = function(rgb) {
|
|
const r3 = rgb[0];
|
|
const g3 = rgb[1];
|
|
let b3 = rgb[2];
|
|
const h3 = convert.rgb.hsl(rgb)[0];
|
|
const w3 = 1 / 255 * Math.min(r3, Math.min(g3, b3));
|
|
b3 = 1 - 1 / 255 * Math.max(r3, Math.max(g3, b3));
|
|
return [h3, w3 * 100, b3 * 100];
|
|
};
|
|
convert.rgb.cmyk = function(rgb) {
|
|
const r3 = rgb[0] / 255;
|
|
const g3 = rgb[1] / 255;
|
|
const b3 = rgb[2] / 255;
|
|
const k2 = Math.min(1 - r3, 1 - g3, 1 - b3);
|
|
const c3 = (1 - r3 - k2) / (1 - k2) || 0;
|
|
const m2 = (1 - g3 - k2) / (1 - k2) || 0;
|
|
const y3 = (1 - b3 - k2) / (1 - k2) || 0;
|
|
return [c3 * 100, m2 * 100, y3 * 100, k2 * 100];
|
|
};
|
|
function comparativeDistance(x3, y3) {
|
|
return (x3[0] - y3[0]) ** 2 + (x3[1] - y3[1]) ** 2 + (x3[2] - y3[2]) ** 2;
|
|
}
|
|
convert.rgb.keyword = function(rgb) {
|
|
const reversed = reverseKeywords[rgb];
|
|
if (reversed) {
|
|
return reversed;
|
|
}
|
|
let currentClosestDistance = Infinity;
|
|
let currentClosestKeyword;
|
|
for (const keyword of Object.keys(cssKeywords)) {
|
|
const value = cssKeywords[keyword];
|
|
const distance = comparativeDistance(rgb, value);
|
|
if (distance < currentClosestDistance) {
|
|
currentClosestDistance = distance;
|
|
currentClosestKeyword = keyword;
|
|
}
|
|
}
|
|
return currentClosestKeyword;
|
|
};
|
|
convert.keyword.rgb = function(keyword) {
|
|
return cssKeywords[keyword];
|
|
};
|
|
convert.rgb.xyz = function(rgb) {
|
|
let r3 = rgb[0] / 255;
|
|
let g3 = rgb[1] / 255;
|
|
let b3 = rgb[2] / 255;
|
|
r3 = r3 > 0.04045 ? ((r3 + 0.055) / 1.055) ** 2.4 : r3 / 12.92;
|
|
g3 = g3 > 0.04045 ? ((g3 + 0.055) / 1.055) ** 2.4 : g3 / 12.92;
|
|
b3 = b3 > 0.04045 ? ((b3 + 0.055) / 1.055) ** 2.4 : b3 / 12.92;
|
|
const x3 = r3 * 0.4124 + g3 * 0.3576 + b3 * 0.1805;
|
|
const y3 = r3 * 0.2126 + g3 * 0.7152 + b3 * 0.0722;
|
|
const z3 = r3 * 0.0193 + g3 * 0.1192 + b3 * 0.9505;
|
|
return [x3 * 100, y3 * 100, z3 * 100];
|
|
};
|
|
convert.rgb.lab = function(rgb) {
|
|
const xyz = convert.rgb.xyz(rgb);
|
|
let x3 = xyz[0];
|
|
let y3 = xyz[1];
|
|
let z3 = xyz[2];
|
|
x3 /= 95.047;
|
|
y3 /= 100;
|
|
z3 /= 108.883;
|
|
x3 = x3 > 8856e-6 ? x3 ** (1 / 3) : 7.787 * x3 + 16 / 116;
|
|
y3 = y3 > 8856e-6 ? y3 ** (1 / 3) : 7.787 * y3 + 16 / 116;
|
|
z3 = z3 > 8856e-6 ? z3 ** (1 / 3) : 7.787 * z3 + 16 / 116;
|
|
const l3 = 116 * y3 - 16;
|
|
const a3 = 500 * (x3 - y3);
|
|
const b3 = 200 * (y3 - z3);
|
|
return [l3, a3, b3];
|
|
};
|
|
convert.hsl.rgb = function(hsl) {
|
|
const h3 = hsl[0] / 360;
|
|
const s3 = hsl[1] / 100;
|
|
const l3 = hsl[2] / 100;
|
|
let t22;
|
|
let t3;
|
|
let val;
|
|
if (s3 === 0) {
|
|
val = l3 * 255;
|
|
return [val, val, val];
|
|
}
|
|
if (l3 < 0.5) {
|
|
t22 = l3 * (1 + s3);
|
|
} else {
|
|
t22 = l3 + s3 - l3 * s3;
|
|
}
|
|
const t1 = 2 * l3 - t22;
|
|
const rgb = [0, 0, 0];
|
|
for (let i3 = 0; i3 < 3; i3++) {
|
|
t3 = h3 + 1 / 3 * -(i3 - 1);
|
|
if (t3 < 0) {
|
|
t3++;
|
|
}
|
|
if (t3 > 1) {
|
|
t3--;
|
|
}
|
|
if (6 * t3 < 1) {
|
|
val = t1 + (t22 - t1) * 6 * t3;
|
|
} else if (2 * t3 < 1) {
|
|
val = t22;
|
|
} else if (3 * t3 < 2) {
|
|
val = t1 + (t22 - t1) * (2 / 3 - t3) * 6;
|
|
} else {
|
|
val = t1;
|
|
}
|
|
rgb[i3] = val * 255;
|
|
}
|
|
return rgb;
|
|
};
|
|
convert.hsl.hsv = function(hsl) {
|
|
const h3 = hsl[0];
|
|
let s3 = hsl[1] / 100;
|
|
let l3 = hsl[2] / 100;
|
|
let smin = s3;
|
|
const lmin = Math.max(l3, 0.01);
|
|
l3 *= 2;
|
|
s3 *= l3 <= 1 ? l3 : 2 - l3;
|
|
smin *= lmin <= 1 ? lmin : 2 - lmin;
|
|
const v3 = (l3 + s3) / 2;
|
|
const sv = l3 === 0 ? 2 * smin / (lmin + smin) : 2 * s3 / (l3 + s3);
|
|
return [h3, sv * 100, v3 * 100];
|
|
};
|
|
convert.hsv.rgb = function(hsv) {
|
|
const h3 = hsv[0] / 60;
|
|
const s3 = hsv[1] / 100;
|
|
let v3 = hsv[2] / 100;
|
|
const hi = Math.floor(h3) % 6;
|
|
const f3 = h3 - Math.floor(h3);
|
|
const p3 = 255 * v3 * (1 - s3);
|
|
const q3 = 255 * v3 * (1 - s3 * f3);
|
|
const t3 = 255 * v3 * (1 - s3 * (1 - f3));
|
|
v3 *= 255;
|
|
switch (hi) {
|
|
case 0:
|
|
return [v3, t3, p3];
|
|
case 1:
|
|
return [q3, v3, p3];
|
|
case 2:
|
|
return [p3, v3, t3];
|
|
case 3:
|
|
return [p3, q3, v3];
|
|
case 4:
|
|
return [t3, p3, v3];
|
|
case 5:
|
|
return [v3, p3, q3];
|
|
}
|
|
};
|
|
convert.hsv.hsl = function(hsv) {
|
|
const h3 = hsv[0];
|
|
const s3 = hsv[1] / 100;
|
|
const v3 = hsv[2] / 100;
|
|
const vmin = Math.max(v3, 0.01);
|
|
let sl;
|
|
let l3;
|
|
l3 = (2 - s3) * v3;
|
|
const lmin = (2 - s3) * vmin;
|
|
sl = s3 * vmin;
|
|
sl /= lmin <= 1 ? lmin : 2 - lmin;
|
|
sl = sl || 0;
|
|
l3 /= 2;
|
|
return [h3, sl * 100, l3 * 100];
|
|
};
|
|
convert.hwb.rgb = function(hwb) {
|
|
const h3 = hwb[0] / 360;
|
|
let wh = hwb[1] / 100;
|
|
let bl = hwb[2] / 100;
|
|
const ratio = wh + bl;
|
|
let f3;
|
|
if (ratio > 1) {
|
|
wh /= ratio;
|
|
bl /= ratio;
|
|
}
|
|
const i3 = Math.floor(6 * h3);
|
|
const v3 = 1 - bl;
|
|
f3 = 6 * h3 - i3;
|
|
if ((i3 & 1) !== 0) {
|
|
f3 = 1 - f3;
|
|
}
|
|
const n2 = wh + f3 * (v3 - wh);
|
|
let r3;
|
|
let g3;
|
|
let b3;
|
|
switch (i3) {
|
|
default:
|
|
case 6:
|
|
case 0:
|
|
r3 = v3;
|
|
g3 = n2;
|
|
b3 = wh;
|
|
break;
|
|
case 1:
|
|
r3 = n2;
|
|
g3 = v3;
|
|
b3 = wh;
|
|
break;
|
|
case 2:
|
|
r3 = wh;
|
|
g3 = v3;
|
|
b3 = n2;
|
|
break;
|
|
case 3:
|
|
r3 = wh;
|
|
g3 = n2;
|
|
b3 = v3;
|
|
break;
|
|
case 4:
|
|
r3 = n2;
|
|
g3 = wh;
|
|
b3 = v3;
|
|
break;
|
|
case 5:
|
|
r3 = v3;
|
|
g3 = wh;
|
|
b3 = n2;
|
|
break;
|
|
}
|
|
return [r3 * 255, g3 * 255, b3 * 255];
|
|
};
|
|
convert.cmyk.rgb = function(cmyk) {
|
|
const c3 = cmyk[0] / 100;
|
|
const m2 = cmyk[1] / 100;
|
|
const y3 = cmyk[2] / 100;
|
|
const k2 = cmyk[3] / 100;
|
|
const r3 = 1 - Math.min(1, c3 * (1 - k2) + k2);
|
|
const g3 = 1 - Math.min(1, m2 * (1 - k2) + k2);
|
|
const b3 = 1 - Math.min(1, y3 * (1 - k2) + k2);
|
|
return [r3 * 255, g3 * 255, b3 * 255];
|
|
};
|
|
convert.xyz.rgb = function(xyz) {
|
|
const x3 = xyz[0] / 100;
|
|
const y3 = xyz[1] / 100;
|
|
const z3 = xyz[2] / 100;
|
|
let r3;
|
|
let g3;
|
|
let b3;
|
|
r3 = x3 * 3.2406 + y3 * -1.5372 + z3 * -0.4986;
|
|
g3 = x3 * -0.9689 + y3 * 1.8758 + z3 * 0.0415;
|
|
b3 = x3 * 0.0557 + y3 * -0.204 + z3 * 1.057;
|
|
r3 = r3 > 31308e-7 ? 1.055 * r3 ** (1 / 2.4) - 0.055 : r3 * 12.92;
|
|
g3 = g3 > 31308e-7 ? 1.055 * g3 ** (1 / 2.4) - 0.055 : g3 * 12.92;
|
|
b3 = b3 > 31308e-7 ? 1.055 * b3 ** (1 / 2.4) - 0.055 : b3 * 12.92;
|
|
r3 = Math.min(Math.max(0, r3), 1);
|
|
g3 = Math.min(Math.max(0, g3), 1);
|
|
b3 = Math.min(Math.max(0, b3), 1);
|
|
return [r3 * 255, g3 * 255, b3 * 255];
|
|
};
|
|
convert.xyz.lab = function(xyz) {
|
|
let x3 = xyz[0];
|
|
let y3 = xyz[1];
|
|
let z3 = xyz[2];
|
|
x3 /= 95.047;
|
|
y3 /= 100;
|
|
z3 /= 108.883;
|
|
x3 = x3 > 8856e-6 ? x3 ** (1 / 3) : 7.787 * x3 + 16 / 116;
|
|
y3 = y3 > 8856e-6 ? y3 ** (1 / 3) : 7.787 * y3 + 16 / 116;
|
|
z3 = z3 > 8856e-6 ? z3 ** (1 / 3) : 7.787 * z3 + 16 / 116;
|
|
const l3 = 116 * y3 - 16;
|
|
const a3 = 500 * (x3 - y3);
|
|
const b3 = 200 * (y3 - z3);
|
|
return [l3, a3, b3];
|
|
};
|
|
convert.lab.xyz = function(lab) {
|
|
const l3 = lab[0];
|
|
const a3 = lab[1];
|
|
const b3 = lab[2];
|
|
let x3;
|
|
let y3;
|
|
let z3;
|
|
y3 = (l3 + 16) / 116;
|
|
x3 = a3 / 500 + y3;
|
|
z3 = y3 - b3 / 200;
|
|
const y22 = y3 ** 3;
|
|
const x22 = x3 ** 3;
|
|
const z22 = z3 ** 3;
|
|
y3 = y22 > 8856e-6 ? y22 : (y3 - 16 / 116) / 7.787;
|
|
x3 = x22 > 8856e-6 ? x22 : (x3 - 16 / 116) / 7.787;
|
|
z3 = z22 > 8856e-6 ? z22 : (z3 - 16 / 116) / 7.787;
|
|
x3 *= 95.047;
|
|
y3 *= 100;
|
|
z3 *= 108.883;
|
|
return [x3, y3, z3];
|
|
};
|
|
convert.lab.lch = function(lab) {
|
|
const l3 = lab[0];
|
|
const a3 = lab[1];
|
|
const b3 = lab[2];
|
|
let h3;
|
|
const hr = Math.atan2(b3, a3);
|
|
h3 = hr * 360 / 2 / Math.PI;
|
|
if (h3 < 0) {
|
|
h3 += 360;
|
|
}
|
|
const c3 = Math.sqrt(a3 * a3 + b3 * b3);
|
|
return [l3, c3, h3];
|
|
};
|
|
convert.lch.lab = function(lch) {
|
|
const l3 = lch[0];
|
|
const c3 = lch[1];
|
|
const h3 = lch[2];
|
|
const hr = h3 / 360 * 2 * Math.PI;
|
|
const a3 = c3 * Math.cos(hr);
|
|
const b3 = c3 * Math.sin(hr);
|
|
return [l3, a3, b3];
|
|
};
|
|
convert.rgb.ansi16 = function(args, saturation = null) {
|
|
const [r3, g3, b3] = args;
|
|
let value = saturation === null ? convert.rgb.hsv(args)[2] : saturation;
|
|
value = Math.round(value / 50);
|
|
if (value === 0) {
|
|
return 30;
|
|
}
|
|
let ansi = 30 + (Math.round(b3 / 255) << 2 | Math.round(g3 / 255) << 1 | Math.round(r3 / 255));
|
|
if (value === 2) {
|
|
ansi += 60;
|
|
}
|
|
return ansi;
|
|
};
|
|
convert.hsv.ansi16 = function(args) {
|
|
return convert.rgb.ansi16(convert.hsv.rgb(args), args[2]);
|
|
};
|
|
convert.rgb.ansi256 = function(args) {
|
|
const r3 = args[0];
|
|
const g3 = args[1];
|
|
const b3 = args[2];
|
|
if (r3 === g3 && g3 === b3) {
|
|
if (r3 < 8) {
|
|
return 16;
|
|
}
|
|
if (r3 > 248) {
|
|
return 231;
|
|
}
|
|
return Math.round((r3 - 8) / 247 * 24) + 232;
|
|
}
|
|
const ansi = 16 + 36 * Math.round(r3 / 255 * 5) + 6 * Math.round(g3 / 255 * 5) + Math.round(b3 / 255 * 5);
|
|
return ansi;
|
|
};
|
|
convert.ansi16.rgb = function(args) {
|
|
let color = args % 10;
|
|
if (color === 0 || color === 7) {
|
|
if (args > 50) {
|
|
color += 3.5;
|
|
}
|
|
color = color / 10.5 * 255;
|
|
return [color, color, color];
|
|
}
|
|
const mult = (~~(args > 50) + 1) * 0.5;
|
|
const r3 = (color & 1) * mult * 255;
|
|
const g3 = (color >> 1 & 1) * mult * 255;
|
|
const b3 = (color >> 2 & 1) * mult * 255;
|
|
return [r3, g3, b3];
|
|
};
|
|
convert.ansi256.rgb = function(args) {
|
|
if (args >= 232) {
|
|
const c3 = (args - 232) * 10 + 8;
|
|
return [c3, c3, c3];
|
|
}
|
|
args -= 16;
|
|
let rem;
|
|
const r3 = Math.floor(args / 36) / 5 * 255;
|
|
const g3 = Math.floor((rem = args % 36) / 6) / 5 * 255;
|
|
const b3 = rem % 6 / 5 * 255;
|
|
return [r3, g3, b3];
|
|
};
|
|
convert.rgb.hex = function(args) {
|
|
const integer = ((Math.round(args[0]) & 255) << 16) + ((Math.round(args[1]) & 255) << 8) + (Math.round(args[2]) & 255);
|
|
const string = integer.toString(16).toUpperCase();
|
|
return "000000".substring(string.length) + string;
|
|
};
|
|
convert.hex.rgb = function(args) {
|
|
const match = args.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);
|
|
if (!match) {
|
|
return [0, 0, 0];
|
|
}
|
|
let colorString = match[0];
|
|
if (match[0].length === 3) {
|
|
colorString = colorString.split("").map((char) => {
|
|
return char + char;
|
|
}).join("");
|
|
}
|
|
const integer = parseInt(colorString, 16);
|
|
const r3 = integer >> 16 & 255;
|
|
const g3 = integer >> 8 & 255;
|
|
const b3 = integer & 255;
|
|
return [r3, g3, b3];
|
|
};
|
|
convert.rgb.hcg = function(rgb) {
|
|
const r3 = rgb[0] / 255;
|
|
const g3 = rgb[1] / 255;
|
|
const b3 = rgb[2] / 255;
|
|
const max = Math.max(Math.max(r3, g3), b3);
|
|
const min = Math.min(Math.min(r3, g3), b3);
|
|
const chroma = max - min;
|
|
let grayscale;
|
|
let hue;
|
|
if (chroma < 1) {
|
|
grayscale = min / (1 - chroma);
|
|
} else {
|
|
grayscale = 0;
|
|
}
|
|
if (chroma <= 0) {
|
|
hue = 0;
|
|
} else if (max === r3) {
|
|
hue = (g3 - b3) / chroma % 6;
|
|
} else if (max === g3) {
|
|
hue = 2 + (b3 - r3) / chroma;
|
|
} else {
|
|
hue = 4 + (r3 - g3) / chroma;
|
|
}
|
|
hue /= 6;
|
|
hue %= 1;
|
|
return [hue * 360, chroma * 100, grayscale * 100];
|
|
};
|
|
convert.hsl.hcg = function(hsl) {
|
|
const s3 = hsl[1] / 100;
|
|
const l3 = hsl[2] / 100;
|
|
const c3 = l3 < 0.5 ? 2 * s3 * l3 : 2 * s3 * (1 - l3);
|
|
let f3 = 0;
|
|
if (c3 < 1) {
|
|
f3 = (l3 - 0.5 * c3) / (1 - c3);
|
|
}
|
|
return [hsl[0], c3 * 100, f3 * 100];
|
|
};
|
|
convert.hsv.hcg = function(hsv) {
|
|
const s3 = hsv[1] / 100;
|
|
const v3 = hsv[2] / 100;
|
|
const c3 = s3 * v3;
|
|
let f3 = 0;
|
|
if (c3 < 1) {
|
|
f3 = (v3 - c3) / (1 - c3);
|
|
}
|
|
return [hsv[0], c3 * 100, f3 * 100];
|
|
};
|
|
convert.hcg.rgb = function(hcg) {
|
|
const h3 = hcg[0] / 360;
|
|
const c3 = hcg[1] / 100;
|
|
const g3 = hcg[2] / 100;
|
|
if (c3 === 0) {
|
|
return [g3 * 255, g3 * 255, g3 * 255];
|
|
}
|
|
const pure = [0, 0, 0];
|
|
const hi = h3 % 1 * 6;
|
|
const v3 = hi % 1;
|
|
const w3 = 1 - v3;
|
|
let mg = 0;
|
|
switch (Math.floor(hi)) {
|
|
case 0:
|
|
pure[0] = 1;
|
|
pure[1] = v3;
|
|
pure[2] = 0;
|
|
break;
|
|
case 1:
|
|
pure[0] = w3;
|
|
pure[1] = 1;
|
|
pure[2] = 0;
|
|
break;
|
|
case 2:
|
|
pure[0] = 0;
|
|
pure[1] = 1;
|
|
pure[2] = v3;
|
|
break;
|
|
case 3:
|
|
pure[0] = 0;
|
|
pure[1] = w3;
|
|
pure[2] = 1;
|
|
break;
|
|
case 4:
|
|
pure[0] = v3;
|
|
pure[1] = 0;
|
|
pure[2] = 1;
|
|
break;
|
|
default:
|
|
pure[0] = 1;
|
|
pure[1] = 0;
|
|
pure[2] = w3;
|
|
}
|
|
mg = (1 - c3) * g3;
|
|
return [
|
|
(c3 * pure[0] + mg) * 255,
|
|
(c3 * pure[1] + mg) * 255,
|
|
(c3 * pure[2] + mg) * 255
|
|
];
|
|
};
|
|
convert.hcg.hsv = function(hcg) {
|
|
const c3 = hcg[1] / 100;
|
|
const g3 = hcg[2] / 100;
|
|
const v3 = c3 + g3 * (1 - c3);
|
|
let f3 = 0;
|
|
if (v3 > 0) {
|
|
f3 = c3 / v3;
|
|
}
|
|
return [hcg[0], f3 * 100, v3 * 100];
|
|
};
|
|
convert.hcg.hsl = function(hcg) {
|
|
const c3 = hcg[1] / 100;
|
|
const g3 = hcg[2] / 100;
|
|
const l3 = g3 * (1 - c3) + 0.5 * c3;
|
|
let s3 = 0;
|
|
if (l3 > 0 && l3 < 0.5) {
|
|
s3 = c3 / (2 * l3);
|
|
} else if (l3 >= 0.5 && l3 < 1) {
|
|
s3 = c3 / (2 * (1 - l3));
|
|
}
|
|
return [hcg[0], s3 * 100, l3 * 100];
|
|
};
|
|
convert.hcg.hwb = function(hcg) {
|
|
const c3 = hcg[1] / 100;
|
|
const g3 = hcg[2] / 100;
|
|
const v3 = c3 + g3 * (1 - c3);
|
|
return [hcg[0], (v3 - c3) * 100, (1 - v3) * 100];
|
|
};
|
|
convert.hwb.hcg = function(hwb) {
|
|
const w3 = hwb[1] / 100;
|
|
const b3 = hwb[2] / 100;
|
|
const v3 = 1 - b3;
|
|
const c3 = v3 - w3;
|
|
let g3 = 0;
|
|
if (c3 < 1) {
|
|
g3 = (v3 - c3) / (1 - c3);
|
|
}
|
|
return [hwb[0], c3 * 100, g3 * 100];
|
|
};
|
|
convert.apple.rgb = function(apple) {
|
|
return [apple[0] / 65535 * 255, apple[1] / 65535 * 255, apple[2] / 65535 * 255];
|
|
};
|
|
convert.rgb.apple = function(rgb) {
|
|
return [rgb[0] / 255 * 65535, rgb[1] / 255 * 65535, rgb[2] / 255 * 65535];
|
|
};
|
|
convert.gray.rgb = function(args) {
|
|
return [args[0] / 100 * 255, args[0] / 100 * 255, args[0] / 100 * 255];
|
|
};
|
|
convert.gray.hsl = function(args) {
|
|
return [0, 0, args[0]];
|
|
};
|
|
convert.gray.hsv = convert.gray.hsl;
|
|
convert.gray.hwb = function(gray) {
|
|
return [0, 100, gray[0]];
|
|
};
|
|
convert.gray.cmyk = function(gray) {
|
|
return [0, 0, 0, gray[0]];
|
|
};
|
|
convert.gray.lab = function(gray) {
|
|
return [gray[0], 0, 0];
|
|
};
|
|
convert.gray.hex = function(gray) {
|
|
const val = Math.round(gray[0] / 100 * 255) & 255;
|
|
const integer = (val << 16) + (val << 8) + val;
|
|
const string = integer.toString(16).toUpperCase();
|
|
return "000000".substring(string.length) + string;
|
|
};
|
|
convert.rgb.gray = function(rgb) {
|
|
const val = (rgb[0] + rgb[1] + rgb[2]) / 3;
|
|
return [val / 255 * 100];
|
|
};
|
|
}
|
|
});
|
|
|
|
// node_modules/color-convert/route.js
|
|
var require_route = __commonJS({
|
|
"node_modules/color-convert/route.js"(exports, module2) {
|
|
var conversions = require_conversions();
|
|
function buildGraph() {
|
|
const graph = {};
|
|
const models = Object.keys(conversions);
|
|
for (let len = models.length, i3 = 0; i3 < len; i3++) {
|
|
graph[models[i3]] = {
|
|
distance: -1,
|
|
parent: null
|
|
};
|
|
}
|
|
return graph;
|
|
}
|
|
function deriveBFS(fromModel) {
|
|
const graph = buildGraph();
|
|
const queue = [fromModel];
|
|
graph[fromModel].distance = 0;
|
|
while (queue.length) {
|
|
const current = queue.pop();
|
|
const adjacents = Object.keys(conversions[current]);
|
|
for (let len = adjacents.length, i3 = 0; i3 < len; i3++) {
|
|
const adjacent = adjacents[i3];
|
|
const node = graph[adjacent];
|
|
if (node.distance === -1) {
|
|
node.distance = graph[current].distance + 1;
|
|
node.parent = current;
|
|
queue.unshift(adjacent);
|
|
}
|
|
}
|
|
}
|
|
return graph;
|
|
}
|
|
function link(from, to) {
|
|
return function(args) {
|
|
return to(from(args));
|
|
};
|
|
}
|
|
function wrapConversion(toModel, graph) {
|
|
const path = [graph[toModel].parent, toModel];
|
|
let fn = conversions[graph[toModel].parent][toModel];
|
|
let cur = graph[toModel].parent;
|
|
while (graph[cur].parent) {
|
|
path.unshift(graph[cur].parent);
|
|
fn = link(conversions[graph[cur].parent][cur], fn);
|
|
cur = graph[cur].parent;
|
|
}
|
|
fn.conversion = path;
|
|
return fn;
|
|
}
|
|
module2.exports = function(fromModel) {
|
|
const graph = deriveBFS(fromModel);
|
|
const conversion = {};
|
|
const models = Object.keys(graph);
|
|
for (let len = models.length, i3 = 0; i3 < len; i3++) {
|
|
const toModel = models[i3];
|
|
const node = graph[toModel];
|
|
if (node.parent === null) {
|
|
continue;
|
|
}
|
|
conversion[toModel] = wrapConversion(toModel, graph);
|
|
}
|
|
return conversion;
|
|
};
|
|
}
|
|
});
|
|
|
|
// node_modules/color-convert/index.js
|
|
var require_color_convert = __commonJS({
|
|
"node_modules/color-convert/index.js"(exports, module2) {
|
|
var conversions = require_conversions();
|
|
var route = require_route();
|
|
var convert = {};
|
|
var models = Object.keys(conversions);
|
|
function wrapRaw(fn) {
|
|
const wrappedFn = function(...args) {
|
|
const arg0 = args[0];
|
|
if (arg0 === void 0 || arg0 === null) {
|
|
return arg0;
|
|
}
|
|
if (arg0.length > 1) {
|
|
args = arg0;
|
|
}
|
|
return fn(args);
|
|
};
|
|
if ("conversion" in fn) {
|
|
wrappedFn.conversion = fn.conversion;
|
|
}
|
|
return wrappedFn;
|
|
}
|
|
function wrapRounded(fn) {
|
|
const wrappedFn = function(...args) {
|
|
const arg0 = args[0];
|
|
if (arg0 === void 0 || arg0 === null) {
|
|
return arg0;
|
|
}
|
|
if (arg0.length > 1) {
|
|
args = arg0;
|
|
}
|
|
const result = fn(args);
|
|
if (typeof result === "object") {
|
|
for (let len = result.length, i3 = 0; i3 < len; i3++) {
|
|
result[i3] = Math.round(result[i3]);
|
|
}
|
|
}
|
|
return result;
|
|
};
|
|
if ("conversion" in fn) {
|
|
wrappedFn.conversion = fn.conversion;
|
|
}
|
|
return wrappedFn;
|
|
}
|
|
models.forEach((fromModel) => {
|
|
convert[fromModel] = {};
|
|
Object.defineProperty(convert[fromModel], "channels", { value: conversions[fromModel].channels });
|
|
Object.defineProperty(convert[fromModel], "labels", { value: conversions[fromModel].labels });
|
|
const routes = route(fromModel);
|
|
const routeModels = Object.keys(routes);
|
|
routeModels.forEach((toModel) => {
|
|
const fn = routes[toModel];
|
|
convert[fromModel][toModel] = wrapRounded(fn);
|
|
convert[fromModel][toModel].raw = wrapRaw(fn);
|
|
});
|
|
});
|
|
module2.exports = convert;
|
|
}
|
|
});
|
|
|
|
// node_modules/color/index.js
|
|
var require_color = __commonJS({
|
|
"node_modules/color/index.js"(exports, module2) {
|
|
var colorString = require_color_string();
|
|
var convert = require_color_convert();
|
|
var _slice = [].slice;
|
|
var skippedModels = [
|
|
"keyword",
|
|
"gray",
|
|
"hex"
|
|
];
|
|
var hashedModelKeys = {};
|
|
for (const model of Object.keys(convert)) {
|
|
hashedModelKeys[_slice.call(convert[model].labels).sort().join("")] = model;
|
|
}
|
|
var limiters = {};
|
|
function Color2(object, model) {
|
|
if (!(this instanceof Color2)) {
|
|
return new Color2(object, model);
|
|
}
|
|
if (model && model in skippedModels) {
|
|
model = null;
|
|
}
|
|
if (model && !(model in convert)) {
|
|
throw new Error("Unknown model: " + model);
|
|
}
|
|
let i3;
|
|
let channels;
|
|
if (object == null) {
|
|
this.model = "rgb";
|
|
this.color = [0, 0, 0];
|
|
this.valpha = 1;
|
|
} else if (object instanceof Color2) {
|
|
this.model = object.model;
|
|
this.color = object.color.slice();
|
|
this.valpha = object.valpha;
|
|
} else if (typeof object === "string") {
|
|
const result = colorString.get(object);
|
|
if (result === null) {
|
|
throw new Error("Unable to parse color from string: " + object);
|
|
}
|
|
this.model = result.model;
|
|
channels = convert[this.model].channels;
|
|
this.color = result.value.slice(0, channels);
|
|
this.valpha = typeof result.value[channels] === "number" ? result.value[channels] : 1;
|
|
} else if (object.length > 0) {
|
|
this.model = model || "rgb";
|
|
channels = convert[this.model].channels;
|
|
const newArray = _slice.call(object, 0, channels);
|
|
this.color = zeroArray(newArray, channels);
|
|
this.valpha = typeof object[channels] === "number" ? object[channels] : 1;
|
|
} else if (typeof object === "number") {
|
|
this.model = "rgb";
|
|
this.color = [
|
|
object >> 16 & 255,
|
|
object >> 8 & 255,
|
|
object & 255
|
|
];
|
|
this.valpha = 1;
|
|
} else {
|
|
this.valpha = 1;
|
|
const keys = Object.keys(object);
|
|
if ("alpha" in object) {
|
|
keys.splice(keys.indexOf("alpha"), 1);
|
|
this.valpha = typeof object.alpha === "number" ? object.alpha : 0;
|
|
}
|
|
const hashedKeys = keys.sort().join("");
|
|
if (!(hashedKeys in hashedModelKeys)) {
|
|
throw new Error("Unable to parse color from object: " + JSON.stringify(object));
|
|
}
|
|
this.model = hashedModelKeys[hashedKeys];
|
|
const labels = convert[this.model].labels;
|
|
const color = [];
|
|
for (i3 = 0; i3 < labels.length; i3++) {
|
|
color.push(object[labels[i3]]);
|
|
}
|
|
this.color = zeroArray(color);
|
|
}
|
|
if (limiters[this.model]) {
|
|
channels = convert[this.model].channels;
|
|
for (i3 = 0; i3 < channels; i3++) {
|
|
const limit = limiters[this.model][i3];
|
|
if (limit) {
|
|
this.color[i3] = limit(this.color[i3]);
|
|
}
|
|
}
|
|
}
|
|
this.valpha = Math.max(0, Math.min(1, this.valpha));
|
|
if (Object.freeze) {
|
|
Object.freeze(this);
|
|
}
|
|
}
|
|
Color2.prototype = {
|
|
toString() {
|
|
return this.string();
|
|
},
|
|
toJSON() {
|
|
return this[this.model]();
|
|
},
|
|
string(places) {
|
|
let self2 = this.model in colorString.to ? this : this.rgb();
|
|
self2 = self2.round(typeof places === "number" ? places : 1);
|
|
const args = self2.valpha === 1 ? self2.color : self2.color.concat(this.valpha);
|
|
return colorString.to[self2.model](args);
|
|
},
|
|
percentString(places) {
|
|
const self2 = this.rgb().round(typeof places === "number" ? places : 1);
|
|
const args = self2.valpha === 1 ? self2.color : self2.color.concat(this.valpha);
|
|
return colorString.to.rgb.percent(args);
|
|
},
|
|
array() {
|
|
return this.valpha === 1 ? this.color.slice() : this.color.concat(this.valpha);
|
|
},
|
|
object() {
|
|
const result = {};
|
|
const channels = convert[this.model].channels;
|
|
const labels = convert[this.model].labels;
|
|
for (let i3 = 0; i3 < channels; i3++) {
|
|
result[labels[i3]] = this.color[i3];
|
|
}
|
|
if (this.valpha !== 1) {
|
|
result.alpha = this.valpha;
|
|
}
|
|
return result;
|
|
},
|
|
unitArray() {
|
|
const rgb = this.rgb().color;
|
|
rgb[0] /= 255;
|
|
rgb[1] /= 255;
|
|
rgb[2] /= 255;
|
|
if (this.valpha !== 1) {
|
|
rgb.push(this.valpha);
|
|
}
|
|
return rgb;
|
|
},
|
|
unitObject() {
|
|
const rgb = this.rgb().object();
|
|
rgb.r /= 255;
|
|
rgb.g /= 255;
|
|
rgb.b /= 255;
|
|
if (this.valpha !== 1) {
|
|
rgb.alpha = this.valpha;
|
|
}
|
|
return rgb;
|
|
},
|
|
round(places) {
|
|
places = Math.max(places || 0, 0);
|
|
return new Color2(this.color.map(roundToPlace(places)).concat(this.valpha), this.model);
|
|
},
|
|
alpha(value) {
|
|
if (arguments.length > 0) {
|
|
return new Color2(this.color.concat(Math.max(0, Math.min(1, value))), this.model);
|
|
}
|
|
return this.valpha;
|
|
},
|
|
red: getset("rgb", 0, maxfn(255)),
|
|
green: getset("rgb", 1, maxfn(255)),
|
|
blue: getset("rgb", 2, maxfn(255)),
|
|
hue: getset(["hsl", "hsv", "hsl", "hwb", "hcg"], 0, (value) => (value % 360 + 360) % 360),
|
|
saturationl: getset("hsl", 1, maxfn(100)),
|
|
lightness: getset("hsl", 2, maxfn(100)),
|
|
saturationv: getset("hsv", 1, maxfn(100)),
|
|
value: getset("hsv", 2, maxfn(100)),
|
|
chroma: getset("hcg", 1, maxfn(100)),
|
|
gray: getset("hcg", 2, maxfn(100)),
|
|
white: getset("hwb", 1, maxfn(100)),
|
|
wblack: getset("hwb", 2, maxfn(100)),
|
|
cyan: getset("cmyk", 0, maxfn(100)),
|
|
magenta: getset("cmyk", 1, maxfn(100)),
|
|
yellow: getset("cmyk", 2, maxfn(100)),
|
|
black: getset("cmyk", 3, maxfn(100)),
|
|
x: getset("xyz", 0, maxfn(100)),
|
|
y: getset("xyz", 1, maxfn(100)),
|
|
z: getset("xyz", 2, maxfn(100)),
|
|
l: getset("lab", 0, maxfn(100)),
|
|
a: getset("lab", 1),
|
|
b: getset("lab", 2),
|
|
keyword(value) {
|
|
if (arguments.length > 0) {
|
|
return new Color2(value);
|
|
}
|
|
return convert[this.model].keyword(this.color);
|
|
},
|
|
hex(value) {
|
|
if (arguments.length > 0) {
|
|
return new Color2(value);
|
|
}
|
|
return colorString.to.hex(this.rgb().round().color);
|
|
},
|
|
hexa(value) {
|
|
if (arguments.length > 0) {
|
|
return new Color2(value);
|
|
}
|
|
const rgbArray = this.rgb().round().color;
|
|
let alphaHex = Math.round(this.valpha * 255).toString(16).toUpperCase();
|
|
if (alphaHex.length === 1) {
|
|
alphaHex = "0" + alphaHex;
|
|
}
|
|
return colorString.to.hex(rgbArray) + alphaHex;
|
|
},
|
|
rgbNumber() {
|
|
const rgb = this.rgb().color;
|
|
return (rgb[0] & 255) << 16 | (rgb[1] & 255) << 8 | rgb[2] & 255;
|
|
},
|
|
luminosity() {
|
|
const rgb = this.rgb().color;
|
|
const lum = [];
|
|
for (const [i3, element] of rgb.entries()) {
|
|
const chan = element / 255;
|
|
lum[i3] = chan <= 0.03928 ? chan / 12.92 : ((chan + 0.055) / 1.055) ** 2.4;
|
|
}
|
|
return 0.2126 * lum[0] + 0.7152 * lum[1] + 0.0722 * lum[2];
|
|
},
|
|
contrast(color2) {
|
|
const lum1 = this.luminosity();
|
|
const lum2 = color2.luminosity();
|
|
if (lum1 > lum2) {
|
|
return (lum1 + 0.05) / (lum2 + 0.05);
|
|
}
|
|
return (lum2 + 0.05) / (lum1 + 0.05);
|
|
},
|
|
level(color2) {
|
|
const contrastRatio = this.contrast(color2);
|
|
if (contrastRatio >= 7.1) {
|
|
return "AAA";
|
|
}
|
|
return contrastRatio >= 4.5 ? "AA" : "";
|
|
},
|
|
isDark() {
|
|
const rgb = this.rgb().color;
|
|
const yiq = (rgb[0] * 299 + rgb[1] * 587 + rgb[2] * 114) / 1e3;
|
|
return yiq < 128;
|
|
},
|
|
isLight() {
|
|
return !this.isDark();
|
|
},
|
|
negate() {
|
|
const rgb = this.rgb();
|
|
for (let i3 = 0; i3 < 3; i3++) {
|
|
rgb.color[i3] = 255 - rgb.color[i3];
|
|
}
|
|
return rgb;
|
|
},
|
|
lighten(ratio) {
|
|
const hsl = this.hsl();
|
|
hsl.color[2] += hsl.color[2] * ratio;
|
|
return hsl;
|
|
},
|
|
darken(ratio) {
|
|
const hsl = this.hsl();
|
|
hsl.color[2] -= hsl.color[2] * ratio;
|
|
return hsl;
|
|
},
|
|
saturate(ratio) {
|
|
const hsl = this.hsl();
|
|
hsl.color[1] += hsl.color[1] * ratio;
|
|
return hsl;
|
|
},
|
|
desaturate(ratio) {
|
|
const hsl = this.hsl();
|
|
hsl.color[1] -= hsl.color[1] * ratio;
|
|
return hsl;
|
|
},
|
|
whiten(ratio) {
|
|
const hwb = this.hwb();
|
|
hwb.color[1] += hwb.color[1] * ratio;
|
|
return hwb;
|
|
},
|
|
blacken(ratio) {
|
|
const hwb = this.hwb();
|
|
hwb.color[2] += hwb.color[2] * ratio;
|
|
return hwb;
|
|
},
|
|
grayscale() {
|
|
const rgb = this.rgb().color;
|
|
const value = rgb[0] * 0.3 + rgb[1] * 0.59 + rgb[2] * 0.11;
|
|
return Color2.rgb(value, value, value);
|
|
},
|
|
fade(ratio) {
|
|
return this.alpha(this.valpha - this.valpha * ratio);
|
|
},
|
|
opaquer(ratio) {
|
|
return this.alpha(this.valpha + this.valpha * ratio);
|
|
},
|
|
rotate(degrees) {
|
|
const hsl = this.hsl();
|
|
let hue = hsl.color[0];
|
|
hue = (hue + degrees) % 360;
|
|
hue = hue < 0 ? 360 + hue : hue;
|
|
hsl.color[0] = hue;
|
|
return hsl;
|
|
},
|
|
mix(mixinColor, weight) {
|
|
if (!mixinColor || !mixinColor.rgb) {
|
|
throw new Error('Argument to "mix" was not a Color instance, but rather an instance of ' + typeof mixinColor);
|
|
}
|
|
const color1 = mixinColor.rgb();
|
|
const color2 = this.rgb();
|
|
const p3 = weight === void 0 ? 0.5 : weight;
|
|
const w3 = 2 * p3 - 1;
|
|
const a3 = color1.alpha() - color2.alpha();
|
|
const w1 = ((w3 * a3 === -1 ? w3 : (w3 + a3) / (1 + w3 * a3)) + 1) / 2;
|
|
const w22 = 1 - w1;
|
|
return Color2.rgb(w1 * color1.red() + w22 * color2.red(), w1 * color1.green() + w22 * color2.green(), w1 * color1.blue() + w22 * color2.blue(), color1.alpha() * p3 + color2.alpha() * (1 - p3));
|
|
}
|
|
};
|
|
for (const model of Object.keys(convert)) {
|
|
if (skippedModels.includes(model)) {
|
|
continue;
|
|
}
|
|
const channels = convert[model].channels;
|
|
Color2.prototype[model] = function() {
|
|
if (this.model === model) {
|
|
return new Color2(this);
|
|
}
|
|
if (arguments.length > 0) {
|
|
return new Color2(arguments, model);
|
|
}
|
|
const newAlpha = typeof arguments[channels] === "number" ? channels : this.valpha;
|
|
return new Color2(assertArray(convert[this.model][model].raw(this.color)).concat(newAlpha), model);
|
|
};
|
|
Color2[model] = function(color) {
|
|
if (typeof color === "number") {
|
|
color = zeroArray(_slice.call(arguments), channels);
|
|
}
|
|
return new Color2(color, model);
|
|
};
|
|
}
|
|
function roundTo(number, places) {
|
|
return Number(number.toFixed(places));
|
|
}
|
|
function roundToPlace(places) {
|
|
return function(number) {
|
|
return roundTo(number, places);
|
|
};
|
|
}
|
|
function getset(model, channel, modifier) {
|
|
model = Array.isArray(model) ? model : [model];
|
|
for (const m2 of model) {
|
|
(limiters[m2] || (limiters[m2] = []))[channel] = modifier;
|
|
}
|
|
model = model[0];
|
|
return function(value) {
|
|
let result;
|
|
if (arguments.length > 0) {
|
|
if (modifier) {
|
|
value = modifier(value);
|
|
}
|
|
result = this[model]();
|
|
result.color[channel] = value;
|
|
return result;
|
|
}
|
|
result = this[model]().color[channel];
|
|
if (modifier) {
|
|
result = modifier(result);
|
|
}
|
|
return result;
|
|
};
|
|
}
|
|
function maxfn(max) {
|
|
return function(v3) {
|
|
return Math.max(0, Math.min(max, v3));
|
|
};
|
|
}
|
|
function assertArray(value) {
|
|
return Array.isArray(value) ? value : [value];
|
|
}
|
|
function zeroArray(array, length) {
|
|
for (let i3 = 0; i3 < length; i3++) {
|
|
if (typeof array[i3] !== "number") {
|
|
array[i3] = 0;
|
|
}
|
|
}
|
|
return array;
|
|
}
|
|
module2.exports = Color2;
|
|
}
|
|
});
|
|
|
|
// node_modules/dav/dav.js
|
|
var require_dav = __commonJS({
|
|
"node_modules/dav/dav.js"(exports, module2) {
|
|
if (!Array.prototype.find) {
|
|
Array.prototype.find = function(predicate) {
|
|
if (this == null) {
|
|
throw new TypeError("Array.prototype.find called on null or undefined");
|
|
}
|
|
if (typeof predicate !== "function") {
|
|
throw new TypeError("predicate must be a function");
|
|
}
|
|
var list = Object(this);
|
|
var length = list.length >>> 0;
|
|
var thisArg = arguments[1];
|
|
var value;
|
|
for (var i3 = 0; i3 < length; i3++) {
|
|
value = list[i3];
|
|
if (predicate.call(thisArg, value, i3, list)) {
|
|
return value;
|
|
}
|
|
}
|
|
return void 0;
|
|
};
|
|
}
|
|
if (!Object.assign) {
|
|
Object.defineProperty(Object, "assign", {
|
|
enumerable: false,
|
|
configurable: true,
|
|
writable: true,
|
|
value: function(target, firstSource) {
|
|
"use strict";
|
|
if (target === void 0 || target === null) {
|
|
throw new TypeError("Cannot convert first argument to object");
|
|
}
|
|
var to = Object(target);
|
|
for (var i3 = 1; i3 < arguments.length; i3++) {
|
|
var nextSource = arguments[i3];
|
|
if (nextSource === void 0 || nextSource === null) {
|
|
continue;
|
|
}
|
|
nextSource = Object(nextSource);
|
|
var keysArray = Object.keys(Object(nextSource));
|
|
for (var nextIndex = 0, len = keysArray.length; nextIndex < len; nextIndex++) {
|
|
var nextKey = keysArray[nextIndex];
|
|
var desc = Object.getOwnPropertyDescriptor(nextSource, nextKey);
|
|
if (desc !== void 0 && desc.enumerable) {
|
|
to[nextKey] = nextSource[nextKey];
|
|
}
|
|
}
|
|
}
|
|
return to;
|
|
}
|
|
});
|
|
}
|
|
!function(global2) {
|
|
"use strict";
|
|
var hasOwn = Object.prototype.hasOwnProperty;
|
|
var undefined2;
|
|
var iteratorSymbol = typeof Symbol === "function" && Symbol.iterator || "@@iterator";
|
|
var inModule = typeof module2 === "object";
|
|
var runtime = global2.regeneratorRuntime;
|
|
if (runtime) {
|
|
if (inModule) {
|
|
module2.exports = runtime;
|
|
}
|
|
return;
|
|
}
|
|
runtime = global2.regeneratorRuntime = inModule ? module2.exports : {};
|
|
function wrap(innerFn, outerFn, self2, tryLocsList) {
|
|
var generator = Object.create((outerFn || Generator).prototype);
|
|
generator._invoke = makeInvokeMethod(innerFn, self2 || null, new Context(tryLocsList || []));
|
|
return generator;
|
|
}
|
|
runtime.wrap = wrap;
|
|
function tryCatch(fn, obj, arg) {
|
|
try {
|
|
return { type: "normal", arg: fn.call(obj, arg) };
|
|
} catch (err) {
|
|
return { type: "throw", arg: err };
|
|
}
|
|
}
|
|
var GenStateSuspendedStart = "suspendedStart";
|
|
var GenStateSuspendedYield = "suspendedYield";
|
|
var GenStateExecuting = "executing";
|
|
var GenStateCompleted = "completed";
|
|
var ContinueSentinel = {};
|
|
function Generator() {
|
|
}
|
|
function GeneratorFunction() {
|
|
}
|
|
function GeneratorFunctionPrototype() {
|
|
}
|
|
var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype;
|
|
GeneratorFunction.prototype = Gp.constructor = GeneratorFunctionPrototype;
|
|
GeneratorFunctionPrototype.constructor = GeneratorFunction;
|
|
GeneratorFunction.displayName = "GeneratorFunction";
|
|
runtime.isGeneratorFunction = function(genFun) {
|
|
var ctor = typeof genFun === "function" && genFun.constructor;
|
|
return ctor ? ctor === GeneratorFunction || (ctor.displayName || ctor.name) === "GeneratorFunction" : false;
|
|
};
|
|
runtime.mark = function(genFun) {
|
|
genFun.__proto__ = GeneratorFunctionPrototype;
|
|
genFun.prototype = Object.create(Gp);
|
|
return genFun;
|
|
};
|
|
runtime.async = function(innerFn, outerFn, self2, tryLocsList) {
|
|
return new Promise(function(resolve, reject) {
|
|
var generator = wrap(innerFn, outerFn, self2, tryLocsList);
|
|
var callNext = step.bind(generator, "next");
|
|
var callThrow = step.bind(generator, "throw");
|
|
function step(method, arg) {
|
|
var record = tryCatch(generator[method], generator, arg);
|
|
if (record.type === "throw") {
|
|
reject(record.arg);
|
|
return;
|
|
}
|
|
var info = record.arg;
|
|
if (info.done) {
|
|
resolve(info.value);
|
|
} else {
|
|
Promise.resolve(info.value).then(callNext, callThrow);
|
|
}
|
|
}
|
|
callNext();
|
|
});
|
|
};
|
|
function makeInvokeMethod(innerFn, self2, context) {
|
|
var state = GenStateSuspendedStart;
|
|
return function invoke(method, arg) {
|
|
if (state === GenStateExecuting) {
|
|
throw new Error("Generator is already running");
|
|
}
|
|
if (state === GenStateCompleted) {
|
|
return doneResult();
|
|
}
|
|
while (true) {
|
|
var delegate = context.delegate;
|
|
if (delegate) {
|
|
if (method === "return" || method === "throw" && delegate.iterator[method] === undefined2) {
|
|
context.delegate = null;
|
|
var returnMethod = delegate.iterator["return"];
|
|
if (returnMethod) {
|
|
var record = tryCatch(returnMethod, delegate.iterator, arg);
|
|
if (record.type === "throw") {
|
|
method = "throw";
|
|
arg = record.arg;
|
|
continue;
|
|
}
|
|
}
|
|
if (method === "return") {
|
|
continue;
|
|
}
|
|
}
|
|
var record = tryCatch(delegate.iterator[method], delegate.iterator, arg);
|
|
if (record.type === "throw") {
|
|
context.delegate = null;
|
|
method = "throw";
|
|
arg = record.arg;
|
|
continue;
|
|
}
|
|
method = "next";
|
|
arg = undefined2;
|
|
var info = record.arg;
|
|
if (info.done) {
|
|
context[delegate.resultName] = info.value;
|
|
context.next = delegate.nextLoc;
|
|
} else {
|
|
state = GenStateSuspendedYield;
|
|
return info;
|
|
}
|
|
context.delegate = null;
|
|
}
|
|
if (method === "next") {
|
|
if (state === GenStateSuspendedYield) {
|
|
context.sent = arg;
|
|
} else {
|
|
delete context.sent;
|
|
}
|
|
} else if (method === "throw") {
|
|
if (state === GenStateSuspendedStart) {
|
|
state = GenStateCompleted;
|
|
throw arg;
|
|
}
|
|
if (context.dispatchException(arg)) {
|
|
method = "next";
|
|
arg = undefined2;
|
|
}
|
|
} else if (method === "return") {
|
|
context.abrupt("return", arg);
|
|
}
|
|
state = GenStateExecuting;
|
|
var record = tryCatch(innerFn, self2, context);
|
|
if (record.type === "normal") {
|
|
state = context.done ? GenStateCompleted : GenStateSuspendedYield;
|
|
var info = {
|
|
value: record.arg,
|
|
done: context.done
|
|
};
|
|
if (record.arg === ContinueSentinel) {
|
|
if (context.delegate && method === "next") {
|
|
arg = undefined2;
|
|
}
|
|
} else {
|
|
return info;
|
|
}
|
|
} else if (record.type === "throw") {
|
|
state = GenStateCompleted;
|
|
method = "throw";
|
|
arg = record.arg;
|
|
}
|
|
}
|
|
};
|
|
}
|
|
function defineGeneratorMethod(method) {
|
|
Gp[method] = function(arg) {
|
|
return this._invoke(method, arg);
|
|
};
|
|
}
|
|
defineGeneratorMethod("next");
|
|
defineGeneratorMethod("throw");
|
|
defineGeneratorMethod("return");
|
|
Gp[iteratorSymbol] = function() {
|
|
return this;
|
|
};
|
|
Gp.toString = function() {
|
|
return "[object Generator]";
|
|
};
|
|
function pushTryEntry(locs) {
|
|
var entry = { tryLoc: locs[0] };
|
|
if (1 in locs) {
|
|
entry.catchLoc = locs[1];
|
|
}
|
|
if (2 in locs) {
|
|
entry.finallyLoc = locs[2];
|
|
entry.afterLoc = locs[3];
|
|
}
|
|
this.tryEntries.push(entry);
|
|
}
|
|
function resetTryEntry(entry) {
|
|
var record = entry.completion || {};
|
|
record.type = "normal";
|
|
delete record.arg;
|
|
entry.completion = record;
|
|
}
|
|
function Context(tryLocsList) {
|
|
this.tryEntries = [{ tryLoc: "root" }];
|
|
tryLocsList.forEach(pushTryEntry, this);
|
|
this.reset();
|
|
}
|
|
runtime.keys = function(object) {
|
|
var keys = [];
|
|
for (var key in object) {
|
|
keys.push(key);
|
|
}
|
|
keys.reverse();
|
|
return function next() {
|
|
while (keys.length) {
|
|
var key2 = keys.pop();
|
|
if (key2 in object) {
|
|
next.value = key2;
|
|
next.done = false;
|
|
return next;
|
|
}
|
|
}
|
|
next.done = true;
|
|
return next;
|
|
};
|
|
};
|
|
function values(iterable) {
|
|
if (iterable) {
|
|
var iteratorMethod = iterable[iteratorSymbol];
|
|
if (iteratorMethod) {
|
|
return iteratorMethod.call(iterable);
|
|
}
|
|
if (typeof iterable.next === "function") {
|
|
return iterable;
|
|
}
|
|
if (!isNaN(iterable.length)) {
|
|
var i3 = -1, next = function next2() {
|
|
while (++i3 < iterable.length) {
|
|
if (hasOwn.call(iterable, i3)) {
|
|
next2.value = iterable[i3];
|
|
next2.done = false;
|
|
return next2;
|
|
}
|
|
}
|
|
next2.value = undefined2;
|
|
next2.done = true;
|
|
return next2;
|
|
};
|
|
return next.next = next;
|
|
}
|
|
}
|
|
return { next: doneResult };
|
|
}
|
|
runtime.values = values;
|
|
function doneResult() {
|
|
return { value: undefined2, done: true };
|
|
}
|
|
Context.prototype = {
|
|
constructor: Context,
|
|
reset: function() {
|
|
this.prev = 0;
|
|
this.next = 0;
|
|
this.sent = undefined2;
|
|
this.done = false;
|
|
this.delegate = null;
|
|
this.tryEntries.forEach(resetTryEntry);
|
|
for (var tempIndex = 0, tempName; hasOwn.call(this, tempName = "t" + tempIndex) || tempIndex < 20; ++tempIndex) {
|
|
this[tempName] = null;
|
|
}
|
|
},
|
|
stop: function() {
|
|
this.done = true;
|
|
var rootEntry = this.tryEntries[0];
|
|
var rootRecord = rootEntry.completion;
|
|
if (rootRecord.type === "throw") {
|
|
throw rootRecord.arg;
|
|
}
|
|
return this.rval;
|
|
},
|
|
dispatchException: function(exception) {
|
|
if (this.done) {
|
|
throw exception;
|
|
}
|
|
var context = this;
|
|
function handle(loc, caught) {
|
|
record.type = "throw";
|
|
record.arg = exception;
|
|
context.next = loc;
|
|
return !!caught;
|
|
}
|
|
for (var i3 = this.tryEntries.length - 1; i3 >= 0; --i3) {
|
|
var entry = this.tryEntries[i3];
|
|
var record = entry.completion;
|
|
if (entry.tryLoc === "root") {
|
|
return handle("end");
|
|
}
|
|
if (entry.tryLoc <= this.prev) {
|
|
var hasCatch = hasOwn.call(entry, "catchLoc");
|
|
var hasFinally = hasOwn.call(entry, "finallyLoc");
|
|
if (hasCatch && hasFinally) {
|
|
if (this.prev < entry.catchLoc) {
|
|
return handle(entry.catchLoc, true);
|
|
} else if (this.prev < entry.finallyLoc) {
|
|
return handle(entry.finallyLoc);
|
|
}
|
|
} else if (hasCatch) {
|
|
if (this.prev < entry.catchLoc) {
|
|
return handle(entry.catchLoc, true);
|
|
}
|
|
} else if (hasFinally) {
|
|
if (this.prev < entry.finallyLoc) {
|
|
return handle(entry.finallyLoc);
|
|
}
|
|
} else {
|
|
throw new Error("try statement without catch or finally");
|
|
}
|
|
}
|
|
}
|
|
},
|
|
abrupt: function(type, arg) {
|
|
for (var i3 = this.tryEntries.length - 1; i3 >= 0; --i3) {
|
|
var entry = this.tryEntries[i3];
|
|
if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) {
|
|
var finallyEntry = entry;
|
|
break;
|
|
}
|
|
}
|
|
if (finallyEntry && (type === "break" || type === "continue") && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc) {
|
|
finallyEntry = null;
|
|
}
|
|
var record = finallyEntry ? finallyEntry.completion : {};
|
|
record.type = type;
|
|
record.arg = arg;
|
|
if (finallyEntry) {
|
|
this.next = finallyEntry.finallyLoc;
|
|
} else {
|
|
this.complete(record);
|
|
}
|
|
return ContinueSentinel;
|
|
},
|
|
complete: function(record, afterLoc) {
|
|
if (record.type === "throw") {
|
|
throw record.arg;
|
|
}
|
|
if (record.type === "break" || record.type === "continue") {
|
|
this.next = record.arg;
|
|
} else if (record.type === "return") {
|
|
this.rval = record.arg;
|
|
this.next = "end";
|
|
} else if (record.type === "normal" && afterLoc) {
|
|
this.next = afterLoc;
|
|
}
|
|
},
|
|
finish: function(finallyLoc) {
|
|
for (var i3 = this.tryEntries.length - 1; i3 >= 0; --i3) {
|
|
var entry = this.tryEntries[i3];
|
|
if (entry.finallyLoc === finallyLoc) {
|
|
this.complete(entry.completion, entry.afterLoc);
|
|
resetTryEntry(entry);
|
|
return ContinueSentinel;
|
|
}
|
|
}
|
|
},
|
|
"catch": function(tryLoc) {
|
|
for (var i3 = this.tryEntries.length - 1; i3 >= 0; --i3) {
|
|
var entry = this.tryEntries[i3];
|
|
if (entry.tryLoc === tryLoc) {
|
|
var record = entry.completion;
|
|
if (record.type === "throw") {
|
|
var thrown = record.arg;
|
|
resetTryEntry(entry);
|
|
}
|
|
return thrown;
|
|
}
|
|
}
|
|
throw new Error("illegal catch attempt");
|
|
},
|
|
delegateYield: function(iterable, resultName, nextLoc) {
|
|
this.delegate = {
|
|
iterator: values(iterable),
|
|
resultName,
|
|
nextLoc
|
|
};
|
|
return ContinueSentinel;
|
|
}
|
|
};
|
|
}(typeof global === "object" ? global : typeof window === "object" ? window : typeof self === "object" ? self : exports);
|
|
(function(f3) {
|
|
if (typeof exports === "object" && typeof module2 !== "undefined") {
|
|
module2.exports = f3();
|
|
} else if (typeof define === "function" && define.amd) {
|
|
define([], f3);
|
|
} else {
|
|
var g3;
|
|
if (typeof window !== "undefined") {
|
|
g3 = window;
|
|
} else if (typeof global !== "undefined") {
|
|
g3 = global;
|
|
} else if (typeof self !== "undefined") {
|
|
g3 = self;
|
|
} else {
|
|
g3 = this;
|
|
}
|
|
g3.dav = f3();
|
|
}
|
|
})(function() {
|
|
var define2, module3, exports2;
|
|
return function e3(t3, n2, r3) {
|
|
function s3(o3, u3) {
|
|
if (!n2[o3]) {
|
|
if (!t3[o3]) {
|
|
var a3 = typeof require == "function" && require;
|
|
if (!u3 && a3)
|
|
return a3(o3, true);
|
|
if (i3)
|
|
return i3(o3, true);
|
|
var f3 = new Error("Cannot find module '" + o3 + "'");
|
|
throw f3.code = "MODULE_NOT_FOUND", f3;
|
|
}
|
|
var l3 = n2[o3] = { exports: {} };
|
|
t3[o3][0].call(l3.exports, function(e4) {
|
|
var n3 = t3[o3][1][e4];
|
|
return s3(n3 ? n3 : e4);
|
|
}, l3, l3.exports, e3, t3, n2, r3);
|
|
}
|
|
return n2[o3].exports;
|
|
}
|
|
var i3 = typeof require == "function" && require;
|
|
for (var o2 = 0; o2 < r3.length; o2++)
|
|
s3(r3[o2]);
|
|
return s3;
|
|
}({ 1: [function(require2, module4, exports3) {
|
|
"use strict";
|
|
function _interopRequireWildcard(obj) {
|
|
if (obj && obj.__esModule) {
|
|
return obj;
|
|
} else {
|
|
var newObj = {};
|
|
if (obj != null) {
|
|
for (var key in obj) {
|
|
if (Object.prototype.hasOwnProperty.call(obj, key))
|
|
newObj[key] = obj[key];
|
|
}
|
|
}
|
|
newObj["default"] = obj;
|
|
return newObj;
|
|
}
|
|
}
|
|
function _interopRequireDefault(obj) {
|
|
return obj && obj.__esModule ? obj : { "default": obj };
|
|
}
|
|
var _co = require2("co");
|
|
var _co2 = _interopRequireDefault(_co);
|
|
var _url = require2("url");
|
|
var _url2 = _interopRequireDefault(_url);
|
|
var _calendars = require2("./calendars");
|
|
var _contacts = require2("./contacts");
|
|
var _fuzzy_url_equals = require2("./fuzzy_url_equals");
|
|
var _fuzzy_url_equals2 = _interopRequireDefault(_fuzzy_url_equals);
|
|
var _model = require2("./model");
|
|
var _namespace = require2("./namespace");
|
|
var ns2 = _interopRequireWildcard(_namespace);
|
|
var _request = require2("./request");
|
|
var request3 = _interopRequireWildcard(_request);
|
|
var debug = require2("./debug")("dav:accounts");
|
|
var defaults = {
|
|
accountType: "caldav",
|
|
loadCollections: true,
|
|
loadObjects: false
|
|
};
|
|
var serviceDiscovery = _co2["default"].wrap(regeneratorRuntime.mark(function callee$0$0(account, options) {
|
|
var endpoint, uri, req, xhr, _location;
|
|
return regeneratorRuntime.wrap(function callee$0$0$(context$1$0) {
|
|
while (1)
|
|
switch (context$1$0.prev = context$1$0.next) {
|
|
case 0:
|
|
debug("Attempt service discovery.");
|
|
endpoint = _url2["default"].parse(account.server);
|
|
endpoint.protocol = endpoint.protocol || "http";
|
|
uri = _url2["default"].format({
|
|
protocol: endpoint.protocol,
|
|
host: endpoint.host,
|
|
pathname: "/.well-known/" + options.accountType
|
|
});
|
|
req = request3.basic({ method: "GET" });
|
|
context$1$0.prev = 5;
|
|
context$1$0.next = 8;
|
|
return options.xhr.send(req, uri, { sandbox: options.sandbox });
|
|
case 8:
|
|
xhr = context$1$0.sent;
|
|
if (!(xhr.status >= 300 && xhr.status < 400)) {
|
|
context$1$0.next = 14;
|
|
break;
|
|
}
|
|
_location = xhr.getResponseHeader("Location");
|
|
if (!(typeof _location === "string" && _location.length)) {
|
|
context$1$0.next = 14;
|
|
break;
|
|
}
|
|
debug("Discovery redirected to " + _location);
|
|
return context$1$0.abrupt("return", _url2["default"].format({
|
|
protocol: endpoint.protocol,
|
|
host: endpoint.host,
|
|
pathname: _location
|
|
}));
|
|
case 14:
|
|
context$1$0.next = 19;
|
|
break;
|
|
case 16:
|
|
context$1$0.prev = 16;
|
|
context$1$0.t0 = context$1$0["catch"](5);
|
|
debug("Discovery failed... failover to the provided url");
|
|
case 19:
|
|
return context$1$0.abrupt("return", endpoint.href);
|
|
case 20:
|
|
case "end":
|
|
return context$1$0.stop();
|
|
}
|
|
}, callee$0$0, this, [[5, 16]]);
|
|
}));
|
|
var principalUrl = _co2["default"].wrap(regeneratorRuntime.mark(function callee$0$0(account, options) {
|
|
var req, res, container;
|
|
return regeneratorRuntime.wrap(function callee$0$0$(context$1$0) {
|
|
while (1)
|
|
switch (context$1$0.prev = context$1$0.next) {
|
|
case 0:
|
|
debug("Fetch principal url from context path " + account.rootUrl + ".");
|
|
req = request3.propfind({
|
|
props: [{ name: "current-user-principal", namespace: ns2.DAV }],
|
|
depth: 0,
|
|
mergeResponses: true
|
|
});
|
|
context$1$0.next = 4;
|
|
return options.xhr.send(req, account.rootUrl, {
|
|
sandbox: options.sandbox
|
|
});
|
|
case 4:
|
|
res = context$1$0.sent;
|
|
container = res.props;
|
|
debug("Received principal: " + container.currentUserPrincipal);
|
|
return context$1$0.abrupt("return", _url2["default"].resolve(account.rootUrl, container.currentUserPrincipal));
|
|
case 8:
|
|
case "end":
|
|
return context$1$0.stop();
|
|
}
|
|
}, callee$0$0, this);
|
|
}));
|
|
var homeUrl = _co2["default"].wrap(regeneratorRuntime.mark(function callee$0$0(account, options) {
|
|
var prop, req, responses, response, container, href;
|
|
return regeneratorRuntime.wrap(function callee$0$0$(context$1$0) {
|
|
while (1)
|
|
switch (context$1$0.prev = context$1$0.next) {
|
|
case 0:
|
|
debug("Fetch home url from principal url " + account.principalUrl + ".");
|
|
prop = void 0;
|
|
if (options.accountType === "caldav") {
|
|
prop = { name: "calendar-home-set", namespace: ns2.CALDAV };
|
|
} else if (options.accountType === "carddav") {
|
|
prop = { name: "addressbook-home-set", namespace: ns2.CARDDAV };
|
|
}
|
|
req = request3.propfind({ props: [prop] });
|
|
context$1$0.next = 6;
|
|
return options.xhr.send(req, account.principalUrl, {
|
|
sandbox: options.sandbox
|
|
});
|
|
case 6:
|
|
responses = context$1$0.sent;
|
|
response = responses.find(function(response2) {
|
|
return (0, _fuzzy_url_equals2["default"])(account.principalUrl, response2.href);
|
|
});
|
|
container = response.props;
|
|
href = void 0;
|
|
if (options.accountType === "caldav") {
|
|
debug("Received home: " + container.calendarHomeSet);
|
|
href = container.calendarHomeSet;
|
|
} else if (options.accountType === "carddav") {
|
|
debug("Received home: " + container.addressbookHomeSet);
|
|
href = container.addressbookHomeSet;
|
|
}
|
|
return context$1$0.abrupt("return", _url2["default"].resolve(account.rootUrl, href));
|
|
case 12:
|
|
case "end":
|
|
return context$1$0.stop();
|
|
}
|
|
}, callee$0$0, this);
|
|
}));
|
|
exports3.createAccount = _co2["default"].wrap(regeneratorRuntime.mark(function callee$0$0(options) {
|
|
var account, key, loadCollections, loadObjects, collections;
|
|
return regeneratorRuntime.wrap(function callee$0$0$(context$1$0) {
|
|
while (1)
|
|
switch (context$1$0.prev = context$1$0.next) {
|
|
case 0:
|
|
options = Object.assign({}, defaults, options);
|
|
if (typeof options.loadObjects !== "boolean") {
|
|
options.loadObjects = options.loadCollections;
|
|
}
|
|
account = new _model.Account({
|
|
server: options.server,
|
|
credentials: options.xhr.credentials
|
|
});
|
|
context$1$0.next = 5;
|
|
return serviceDiscovery(account, options);
|
|
case 5:
|
|
account.rootUrl = context$1$0.sent;
|
|
context$1$0.next = 8;
|
|
return principalUrl(account, options);
|
|
case 8:
|
|
account.principalUrl = context$1$0.sent;
|
|
context$1$0.next = 11;
|
|
return homeUrl(account, options);
|
|
case 11:
|
|
account.homeUrl = context$1$0.sent;
|
|
if (options.loadCollections) {
|
|
context$1$0.next = 14;
|
|
break;
|
|
}
|
|
return context$1$0.abrupt("return", account);
|
|
case 14:
|
|
key = void 0, loadCollections = void 0, loadObjects = void 0;
|
|
if (options.accountType === "caldav") {
|
|
key = "calendars";
|
|
loadCollections = _calendars.listCalendars;
|
|
loadObjects = _calendars.listCalendarObjects;
|
|
} else if (options.accountType === "carddav") {
|
|
key = "addressBooks";
|
|
loadCollections = _contacts.listAddressBooks;
|
|
loadObjects = _contacts.listVCards;
|
|
}
|
|
context$1$0.next = 18;
|
|
return loadCollections(account, options);
|
|
case 18:
|
|
collections = context$1$0.sent;
|
|
account[key] = collections;
|
|
if (options.loadObjects) {
|
|
context$1$0.next = 22;
|
|
break;
|
|
}
|
|
return context$1$0.abrupt("return", account);
|
|
case 22:
|
|
context$1$0.next = 24;
|
|
return collections.map(_co2["default"].wrap(regeneratorRuntime.mark(function callee$1$0(collection) {
|
|
return regeneratorRuntime.wrap(function callee$1$0$(context$2$0) {
|
|
while (1)
|
|
switch (context$2$0.prev = context$2$0.next) {
|
|
case 0:
|
|
context$2$0.prev = 0;
|
|
context$2$0.next = 3;
|
|
return loadObjects(collection, options);
|
|
case 3:
|
|
collection.objects = context$2$0.sent;
|
|
context$2$0.next = 9;
|
|
break;
|
|
case 6:
|
|
context$2$0.prev = 6;
|
|
context$2$0.t0 = context$2$0["catch"](0);
|
|
collection.error = context$2$0.t0;
|
|
case 9:
|
|
case "end":
|
|
return context$2$0.stop();
|
|
}
|
|
}, callee$1$0, this, [[0, 6]]);
|
|
})));
|
|
case 24:
|
|
account[key] = account[key].filter(function(collection) {
|
|
return !collection.error;
|
|
});
|
|
return context$1$0.abrupt("return", account);
|
|
case 26:
|
|
case "end":
|
|
return context$1$0.stop();
|
|
}
|
|
}, callee$0$0, this);
|
|
}));
|
|
}, { "./calendars": 2, "./contacts": 5, "./debug": 6, "./fuzzy_url_equals": 7, "./model": 9, "./namespace": 10, "./request": 12, "co": 24, "url": 29 }], 2: [function(require2, module4, exports3) {
|
|
"use strict";
|
|
Object.defineProperty(exports3, "__esModule", {
|
|
value: true
|
|
});
|
|
exports3.createCalendarObject = createCalendarObject;
|
|
exports3.updateCalendarObject = updateCalendarObject;
|
|
exports3.deleteCalendarObject = deleteCalendarObject;
|
|
exports3.syncCalendar = syncCalendar;
|
|
function _interopRequireWildcard(obj) {
|
|
if (obj && obj.__esModule) {
|
|
return obj;
|
|
} else {
|
|
var newObj = {};
|
|
if (obj != null) {
|
|
for (var key in obj) {
|
|
if (Object.prototype.hasOwnProperty.call(obj, key))
|
|
newObj[key] = obj[key];
|
|
}
|
|
}
|
|
newObj["default"] = obj;
|
|
return newObj;
|
|
}
|
|
}
|
|
function _interopRequireDefault(obj) {
|
|
return obj && obj.__esModule ? obj : { "default": obj };
|
|
}
|
|
var _co = require2("co");
|
|
var _co2 = _interopRequireDefault(_co);
|
|
var _url = require2("url");
|
|
var _url2 = _interopRequireDefault(_url);
|
|
var _fuzzy_url_equals = require2("./fuzzy_url_equals");
|
|
var _fuzzy_url_equals2 = _interopRequireDefault(_fuzzy_url_equals);
|
|
var _model = require2("./model");
|
|
var _namespace = require2("./namespace");
|
|
var ns2 = _interopRequireWildcard(_namespace);
|
|
var _request = require2("./request");
|
|
var request3 = _interopRequireWildcard(_request);
|
|
var _webdav = require2("./webdav");
|
|
var webdav = _interopRequireWildcard(_webdav);
|
|
var debug = require2("./debug")("dav:calendars");
|
|
var ICAL_OBJS = new Set(["VEVENT", "VTODO", "VJOURNAL", "VFREEBUSY", "VTIMEZONE", "VALARM"]);
|
|
var listCalendars = _co2["default"].wrap(regeneratorRuntime.mark(function callee$0$0(account, options) {
|
|
var req, responses, cals;
|
|
return regeneratorRuntime.wrap(function callee$0$0$(context$1$0) {
|
|
while (1)
|
|
switch (context$1$0.prev = context$1$0.next) {
|
|
case 0:
|
|
debug("Fetch calendars from home url " + account.homeUrl);
|
|
req = request3.propfind({
|
|
props: [{ name: "calendar-description", namespace: ns2.CALDAV }, { name: "calendar-timezone", namespace: ns2.CALDAV }, { name: "displayname", namespace: ns2.DAV }, { name: "getctag", namespace: ns2.CALENDAR_SERVER }, { name: "resourcetype", namespace: ns2.DAV }, { name: "supported-calendar-component-set", namespace: ns2.CALDAV }, { name: "sync-token", namespace: ns2.DAV }],
|
|
depth: 1
|
|
});
|
|
context$1$0.next = 4;
|
|
return options.xhr.send(req, account.homeUrl, {
|
|
sandbox: options.sandbox
|
|
});
|
|
case 4:
|
|
responses = context$1$0.sent;
|
|
debug("Found " + responses.length + " calendars.");
|
|
cals = responses.filter(function(res) {
|
|
return res.props.resourcetype.includes("calendar");
|
|
}).filter(function(res) {
|
|
var components = res.props.supportedCalendarComponentSet || [];
|
|
return components.reduce(function(hasObjs, component) {
|
|
return hasObjs || ICAL_OBJS.has(component);
|
|
}, false);
|
|
}).map(function(res) {
|
|
debug("Found calendar " + res.props.displayname + ",\n props: " + JSON.stringify(res.props));
|
|
return new _model.Calendar({
|
|
data: res,
|
|
account,
|
|
description: res.props.calendarDescription,
|
|
timezone: res.props.calendarTimezone,
|
|
url: _url2["default"].resolve(account.rootUrl, res.href),
|
|
ctag: res.props.getctag,
|
|
displayName: res.props.displayname,
|
|
components: res.props.supportedCalendarComponentSet,
|
|
resourcetype: res.props.resourcetype,
|
|
syncToken: res.props.syncToken
|
|
});
|
|
});
|
|
context$1$0.next = 9;
|
|
return cals.map(_co2["default"].wrap(regeneratorRuntime.mark(function callee$1$0(cal) {
|
|
return regeneratorRuntime.wrap(function callee$1$0$(context$2$0) {
|
|
while (1)
|
|
switch (context$2$0.prev = context$2$0.next) {
|
|
case 0:
|
|
context$2$0.next = 2;
|
|
return webdav.supportedReportSet(cal, options);
|
|
case 2:
|
|
cal.reports = context$2$0.sent;
|
|
case 3:
|
|
case "end":
|
|
return context$2$0.stop();
|
|
}
|
|
}, callee$1$0, this);
|
|
})));
|
|
case 9:
|
|
return context$1$0.abrupt("return", cals);
|
|
case 10:
|
|
case "end":
|
|
return context$1$0.stop();
|
|
}
|
|
}, callee$0$0, this);
|
|
}));
|
|
exports3.listCalendars = listCalendars;
|
|
function createCalendarObject(calendar, options) {
|
|
var objectUrl = _url2["default"].resolve(calendar.url, options.filename);
|
|
options.contentType = options.contentType || "text/calendar; charset=utf-8";
|
|
return webdav.createObject(objectUrl, options.data, options);
|
|
}
|
|
;
|
|
function updateCalendarObject(calendarObject, options) {
|
|
options.contentType = options.contentType || "text/calendar; charset=utf-8";
|
|
return webdav.updateObject(calendarObject.url, calendarObject.calendarData, calendarObject.etag, options);
|
|
}
|
|
function deleteCalendarObject(calendarObject, options) {
|
|
return webdav.deleteObject(calendarObject.url, calendarObject.etag, options);
|
|
}
|
|
var listCalendarObjects2 = _co2["default"].wrap(regeneratorRuntime.mark(function callee$0$0(calendar, options) {
|
|
var filters, req, responses;
|
|
return regeneratorRuntime.wrap(function callee$0$0$(context$1$0) {
|
|
while (1)
|
|
switch (context$1$0.prev = context$1$0.next) {
|
|
case 0:
|
|
debug("Doing REPORT on calendar " + calendar.url + " which belongs to\n " + calendar.account.credentials.username);
|
|
filters = options.filters || [{
|
|
type: "comp-filter",
|
|
attrs: { name: "VCALENDAR" },
|
|
children: [{
|
|
type: "comp-filter",
|
|
attrs: { name: "VEVENT" }
|
|
}]
|
|
}];
|
|
req = request3.calendarQuery({
|
|
depth: 1,
|
|
props: [{ name: "getetag", namespace: ns2.DAV }, { name: "calendar-data", namespace: ns2.CALDAV }],
|
|
filters
|
|
});
|
|
context$1$0.next = 5;
|
|
return options.xhr.send(req, calendar.url, {
|
|
sandbox: options.sandbox
|
|
});
|
|
case 5:
|
|
responses = context$1$0.sent;
|
|
return context$1$0.abrupt("return", responses.map(function(res) {
|
|
debug("Found calendar object with url " + res.href);
|
|
return new _model.CalendarObject({
|
|
data: res,
|
|
calendar,
|
|
url: _url2["default"].resolve(calendar.account.rootUrl, res.href),
|
|
etag: res.props.getetag,
|
|
calendarData: res.props.calendarData
|
|
});
|
|
}));
|
|
case 7:
|
|
case "end":
|
|
return context$1$0.stop();
|
|
}
|
|
}, callee$0$0, this);
|
|
}));
|
|
exports3.listCalendarObjects = listCalendarObjects2;
|
|
function syncCalendar(calendar, options) {
|
|
options.basicSync = basicSync;
|
|
options.webdavSync = webdavSync;
|
|
return webdav.syncCollection(calendar, options);
|
|
}
|
|
var syncCaldavAccount = _co2["default"].wrap(regeneratorRuntime.mark(function callee$0$0(account) {
|
|
var options = arguments.length <= 1 || arguments[1] === void 0 ? {} : arguments[1];
|
|
var cals;
|
|
return regeneratorRuntime.wrap(function callee$0$0$(context$1$0) {
|
|
while (1)
|
|
switch (context$1$0.prev = context$1$0.next) {
|
|
case 0:
|
|
options.loadObjects = false;
|
|
if (!account.calendars)
|
|
account.calendars = [];
|
|
context$1$0.next = 4;
|
|
return listCalendars(account, options);
|
|
case 4:
|
|
cals = context$1$0.sent;
|
|
cals.filter(function(cal) {
|
|
return account.calendars.every(function(prev) {
|
|
return !(0, _fuzzy_url_equals2["default"])(prev.url, cal.url);
|
|
});
|
|
}).forEach(function(cal) {
|
|
account.calendars.push(cal);
|
|
});
|
|
options.loadObjects = true;
|
|
context$1$0.next = 9;
|
|
return account.calendars.map(_co2["default"].wrap(regeneratorRuntime.mark(function callee$1$0(cal, index) {
|
|
return regeneratorRuntime.wrap(function callee$1$0$(context$2$0) {
|
|
while (1)
|
|
switch (context$2$0.prev = context$2$0.next) {
|
|
case 0:
|
|
context$2$0.prev = 0;
|
|
context$2$0.next = 3;
|
|
return syncCalendar(cal, options);
|
|
case 3:
|
|
context$2$0.next = 9;
|
|
break;
|
|
case 5:
|
|
context$2$0.prev = 5;
|
|
context$2$0.t0 = context$2$0["catch"](0);
|
|
debug("Sync calendar " + cal.displayName + " failed with " + context$2$0.t0);
|
|
account.calendars.splice(index, 1);
|
|
case 9:
|
|
case "end":
|
|
return context$2$0.stop();
|
|
}
|
|
}, callee$1$0, this, [[0, 5]]);
|
|
})));
|
|
case 9:
|
|
return context$1$0.abrupt("return", account);
|
|
case 10:
|
|
case "end":
|
|
return context$1$0.stop();
|
|
}
|
|
}, callee$0$0, this);
|
|
}));
|
|
exports3.syncCaldavAccount = syncCaldavAccount;
|
|
var basicSync = _co2["default"].wrap(regeneratorRuntime.mark(function callee$0$0(calendar, options) {
|
|
var sync;
|
|
return regeneratorRuntime.wrap(function callee$0$0$(context$1$0) {
|
|
while (1)
|
|
switch (context$1$0.prev = context$1$0.next) {
|
|
case 0:
|
|
context$1$0.next = 2;
|
|
return webdav.isCollectionDirty(calendar, options);
|
|
case 2:
|
|
sync = context$1$0.sent;
|
|
if (sync) {
|
|
context$1$0.next = 6;
|
|
break;
|
|
}
|
|
debug("Local ctag matched remote! No need to sync :).");
|
|
return context$1$0.abrupt("return", calendar);
|
|
case 6:
|
|
debug("ctag changed so we need to fetch stuffs.");
|
|
context$1$0.next = 9;
|
|
return listCalendarObjects2(calendar, options);
|
|
case 9:
|
|
calendar.objects = context$1$0.sent;
|
|
return context$1$0.abrupt("return", calendar);
|
|
case 11:
|
|
case "end":
|
|
return context$1$0.stop();
|
|
}
|
|
}, callee$0$0, this);
|
|
}));
|
|
var webdavSync = _co2["default"].wrap(regeneratorRuntime.mark(function callee$0$0(calendar, options) {
|
|
var req, result;
|
|
return regeneratorRuntime.wrap(function callee$0$0$(context$1$0) {
|
|
while (1)
|
|
switch (context$1$0.prev = context$1$0.next) {
|
|
case 0:
|
|
req = request3.syncCollection({
|
|
props: [{ name: "getetag", namespace: ns2.DAV }, { name: "calendar-data", namespace: ns2.CALDAV }],
|
|
syncLevel: 1,
|
|
syncToken: calendar.syncToken
|
|
});
|
|
context$1$0.next = 3;
|
|
return options.xhr.send(req, calendar.url, {
|
|
sandbox: options.sandbox
|
|
});
|
|
case 3:
|
|
result = context$1$0.sent;
|
|
result.responses.forEach(function(response) {
|
|
var calendarObject = calendar.objects.filter(function(object) {
|
|
return (0, _fuzzy_url_equals2["default"])(object.url, response.href);
|
|
})[0];
|
|
if (!calendarObject) {
|
|
return;
|
|
}
|
|
calendarObject.etag = response.props.getetag;
|
|
calendarObject.calendarData = response.props.calendarData;
|
|
});
|
|
calendar.syncToken = result.syncToken;
|
|
return context$1$0.abrupt("return", calendar);
|
|
case 7:
|
|
case "end":
|
|
return context$1$0.stop();
|
|
}
|
|
}, callee$0$0, this);
|
|
}));
|
|
}, { "./debug": 6, "./fuzzy_url_equals": 7, "./model": 9, "./namespace": 10, "./request": 12, "./webdav": 22, "co": 24, "url": 29 }], 3: [function(require2, module4, exports3) {
|
|
"use strict";
|
|
Object.defineProperty(exports3, "__esModule", {
|
|
value: true
|
|
});
|
|
exports3["default"] = camelize;
|
|
function camelize(str) {
|
|
var delimiter = arguments.length <= 1 || arguments[1] === void 0 ? "_" : arguments[1];
|
|
var words = str.split(delimiter);
|
|
return [words[0]].concat(words.slice(1).map(function(word) {
|
|
return word.charAt(0).toUpperCase() + word.slice(1);
|
|
})).join("");
|
|
}
|
|
module4.exports = exports3["default"];
|
|
}, {}], 4: [function(require2, module4, exports3) {
|
|
"use strict";
|
|
Object.defineProperty(exports3, "__esModule", {
|
|
value: true
|
|
});
|
|
var _createClass = function() {
|
|
function defineProperties(target, props) {
|
|
for (var i3 = 0; i3 < props.length; i3++) {
|
|
var descriptor = props[i3];
|
|
descriptor.enumerable = descriptor.enumerable || false;
|
|
descriptor.configurable = true;
|
|
if ("value" in descriptor)
|
|
descriptor.writable = true;
|
|
Object.defineProperty(target, descriptor.key, descriptor);
|
|
}
|
|
}
|
|
return function(Constructor, protoProps, staticProps) {
|
|
if (protoProps)
|
|
defineProperties(Constructor.prototype, protoProps);
|
|
if (staticProps)
|
|
defineProperties(Constructor, staticProps);
|
|
return Constructor;
|
|
};
|
|
}();
|
|
function _interopRequireWildcard(obj) {
|
|
if (obj && obj.__esModule) {
|
|
return obj;
|
|
} else {
|
|
var newObj = {};
|
|
if (obj != null) {
|
|
for (var key in obj) {
|
|
if (Object.prototype.hasOwnProperty.call(obj, key))
|
|
newObj[key] = obj[key];
|
|
}
|
|
}
|
|
newObj["default"] = obj;
|
|
return newObj;
|
|
}
|
|
}
|
|
function _interopRequireDefault(obj) {
|
|
return obj && obj.__esModule ? obj : { "default": obj };
|
|
}
|
|
function _classCallCheck(instance, Constructor) {
|
|
if (!(instance instanceof Constructor)) {
|
|
throw new TypeError("Cannot call a class as a function");
|
|
}
|
|
}
|
|
var _url = require2("url");
|
|
var _url2 = _interopRequireDefault(_url);
|
|
var _accounts = require2("./accounts");
|
|
var accounts = _interopRequireWildcard(_accounts);
|
|
var _calendars = require2("./calendars");
|
|
var calendars = _interopRequireWildcard(_calendars);
|
|
var _contacts = require2("./contacts");
|
|
var contacts = _interopRequireWildcard(_contacts);
|
|
var Client = function() {
|
|
function Client2(xhr) {
|
|
var options = arguments.length <= 1 || arguments[1] === void 0 ? {} : arguments[1];
|
|
_classCallCheck(this, Client2);
|
|
this.xhr = xhr;
|
|
Object.assign(this, options);
|
|
this._accounts = accounts;
|
|
this._calendars = calendars;
|
|
this._contacts = contacts;
|
|
}
|
|
_createClass(Client2, [{
|
|
key: "send",
|
|
value: function send(req, uri, options) {
|
|
if (this.baseUrl) {
|
|
var urlObj = _url2["default"].parse(uri);
|
|
uri = _url2["default"].resolve(this.baseUrl, urlObj.path);
|
|
}
|
|
return this.xhr.send(req, uri, options);
|
|
}
|
|
}, {
|
|
key: "createAccount",
|
|
value: function createAccount2() {
|
|
var options = arguments.length <= 0 || arguments[0] === void 0 ? {} : arguments[0];
|
|
options.xhr = options.xhr || this.xhr;
|
|
return accounts.createAccount(options);
|
|
}
|
|
}, {
|
|
key: "createCalendarObject",
|
|
value: function createCalendarObject(calendar) {
|
|
var options = arguments.length <= 1 || arguments[1] === void 0 ? {} : arguments[1];
|
|
options.xhr = options.xhr || this.xhr;
|
|
return calendars.createCalendarObject(calendar, options);
|
|
}
|
|
}, {
|
|
key: "updateCalendarObject",
|
|
value: function updateCalendarObject(calendarObject) {
|
|
var options = arguments.length <= 1 || arguments[1] === void 0 ? {} : arguments[1];
|
|
options.xhr = options.xhr || this.xhr;
|
|
return calendars.updateCalendarObject(calendarObject, options);
|
|
}
|
|
}, {
|
|
key: "deleteCalendarObject",
|
|
value: function deleteCalendarObject(calendarObject) {
|
|
var options = arguments.length <= 1 || arguments[1] === void 0 ? {} : arguments[1];
|
|
options.xhr = options.xhr || this.xhr;
|
|
return calendars.deleteCalendarObject(calendarObject, options);
|
|
}
|
|
}, {
|
|
key: "syncCalendar",
|
|
value: function syncCalendar(calendar) {
|
|
var options = arguments.length <= 1 || arguments[1] === void 0 ? {} : arguments[1];
|
|
options.xhr = options.xhr || this.xhr;
|
|
return calendars.syncCalendar(calendar, options);
|
|
}
|
|
}, {
|
|
key: "syncCaldavAccount",
|
|
value: function syncCaldavAccount(account) {
|
|
var options = arguments.length <= 1 || arguments[1] === void 0 ? {} : arguments[1];
|
|
options.xhr = options.xhr || this.xhr;
|
|
return calendars.syncCaldavAccount(account, options);
|
|
}
|
|
}, {
|
|
key: "createCard",
|
|
value: function createCard(addressBook) {
|
|
var options = arguments.length <= 1 || arguments[1] === void 0 ? {} : arguments[1];
|
|
options.xhr = options.xhr || this.xhr;
|
|
return contacts.createCard(addressBook, options);
|
|
}
|
|
}, {
|
|
key: "updateCard",
|
|
value: function updateCard(card) {
|
|
var options = arguments.length <= 1 || arguments[1] === void 0 ? {} : arguments[1];
|
|
options.xhr = options.xhr || this.xhr;
|
|
return contacts.updateCard(card, options);
|
|
}
|
|
}, {
|
|
key: "deleteCard",
|
|
value: function deleteCard(card) {
|
|
var options = arguments.length <= 1 || arguments[1] === void 0 ? {} : arguments[1];
|
|
options.xhr = options.xhr || this.xhr;
|
|
return contacts.deleteCard(card, options);
|
|
}
|
|
}, {
|
|
key: "syncAddressBook",
|
|
value: function syncAddressBook(addressBook) {
|
|
var options = arguments.length <= 1 || arguments[1] === void 0 ? {} : arguments[1];
|
|
options.xhr = options.xhr || this.xhr;
|
|
return contacts.syncAddressBook(addressBook, options);
|
|
}
|
|
}, {
|
|
key: "syncCarddavAccount",
|
|
value: function syncCarddavAccount(account) {
|
|
var options = arguments.length <= 1 || arguments[1] === void 0 ? {} : arguments[1];
|
|
options.xhr = options.xhr || this.xhr;
|
|
return contacts.syncCarddavAccount(account, options);
|
|
}
|
|
}]);
|
|
return Client2;
|
|
}();
|
|
exports3.Client = Client;
|
|
}, { "./accounts": 1, "./calendars": 2, "./contacts": 5, "url": 29 }], 5: [function(require2, module4, exports3) {
|
|
"use strict";
|
|
Object.defineProperty(exports3, "__esModule", {
|
|
value: true
|
|
});
|
|
exports3.createCard = createCard;
|
|
exports3.updateCard = updateCard;
|
|
exports3.deleteCard = deleteCard;
|
|
exports3.syncAddressBook = syncAddressBook;
|
|
function _interopRequireWildcard(obj) {
|
|
if (obj && obj.__esModule) {
|
|
return obj;
|
|
} else {
|
|
var newObj = {};
|
|
if (obj != null) {
|
|
for (var key in obj) {
|
|
if (Object.prototype.hasOwnProperty.call(obj, key))
|
|
newObj[key] = obj[key];
|
|
}
|
|
}
|
|
newObj["default"] = obj;
|
|
return newObj;
|
|
}
|
|
}
|
|
function _interopRequireDefault(obj) {
|
|
return obj && obj.__esModule ? obj : { "default": obj };
|
|
}
|
|
var _co = require2("co");
|
|
var _co2 = _interopRequireDefault(_co);
|
|
var _url = require2("url");
|
|
var _url2 = _interopRequireDefault(_url);
|
|
var _fuzzy_url_equals = require2("./fuzzy_url_equals");
|
|
var _fuzzy_url_equals2 = _interopRequireDefault(_fuzzy_url_equals);
|
|
var _model = require2("./model");
|
|
var _namespace = require2("./namespace");
|
|
var ns2 = _interopRequireWildcard(_namespace);
|
|
var _request = require2("./request");
|
|
var request3 = _interopRequireWildcard(_request);
|
|
var _webdav = require2("./webdav");
|
|
var webdav = _interopRequireWildcard(_webdav);
|
|
var debug = require2("./debug")("dav:contacts");
|
|
var listAddressBooks = _co2["default"].wrap(regeneratorRuntime.mark(function callee$0$0(account, options) {
|
|
var req, responses, addressBooks;
|
|
return regeneratorRuntime.wrap(function callee$0$0$(context$1$0) {
|
|
while (1)
|
|
switch (context$1$0.prev = context$1$0.next) {
|
|
case 0:
|
|
debug("Fetch address books from home url " + account.homeUrl);
|
|
req = request3.propfind({
|
|
props: [{ name: "displayname", namespace: ns2.DAV }, { name: "getctag", namespace: ns2.CALENDAR_SERVER }, { name: "resourcetype", namespace: ns2.DAV }, { name: "sync-token", namespace: ns2.DAV }],
|
|
depth: 1
|
|
});
|
|
context$1$0.next = 4;
|
|
return options.xhr.send(req, account.homeUrl, {
|
|
sandbox: options.sandbox
|
|
});
|
|
case 4:
|
|
responses = context$1$0.sent;
|
|
addressBooks = responses.filter(function(res) {
|
|
return typeof res.props.displayname === "string";
|
|
}).map(function(res) {
|
|
debug("Found address book named " + res.props.displayname + ",\n props: " + JSON.stringify(res.props));
|
|
return new _model.AddressBook({
|
|
data: res,
|
|
account,
|
|
url: _url2["default"].resolve(account.rootUrl, res.href),
|
|
ctag: res.props.getctag,
|
|
displayName: res.props.displayname,
|
|
resourcetype: res.props.resourcetype,
|
|
syncToken: res.props.syncToken
|
|
});
|
|
});
|
|
context$1$0.next = 8;
|
|
return addressBooks.map(_co2["default"].wrap(regeneratorRuntime.mark(function callee$1$0(addressBook) {
|
|
return regeneratorRuntime.wrap(function callee$1$0$(context$2$0) {
|
|
while (1)
|
|
switch (context$2$0.prev = context$2$0.next) {
|
|
case 0:
|
|
context$2$0.next = 2;
|
|
return webdav.supportedReportSet(addressBook, options);
|
|
case 2:
|
|
addressBook.reports = context$2$0.sent;
|
|
case 3:
|
|
case "end":
|
|
return context$2$0.stop();
|
|
}
|
|
}, callee$1$0, this);
|
|
})));
|
|
case 8:
|
|
return context$1$0.abrupt("return", addressBooks);
|
|
case 9:
|
|
case "end":
|
|
return context$1$0.stop();
|
|
}
|
|
}, callee$0$0, this);
|
|
}));
|
|
exports3.listAddressBooks = listAddressBooks;
|
|
function createCard(addressBook, options) {
|
|
var objectUrl = _url2["default"].resolve(addressBook.url, options.filename);
|
|
return webdav.createObject(objectUrl, options.data, options);
|
|
}
|
|
var listVCards = _co2["default"].wrap(regeneratorRuntime.mark(function callee$0$0(addressBook, options) {
|
|
var req, responses;
|
|
return regeneratorRuntime.wrap(function callee$0$0$(context$1$0) {
|
|
while (1)
|
|
switch (context$1$0.prev = context$1$0.next) {
|
|
case 0:
|
|
debug("Doing REPORT on address book " + addressBook.url + " which belongs to\n " + addressBook.account.credentials.username);
|
|
req = request3.addressBookQuery({
|
|
depth: 1,
|
|
props: [{ name: "getetag", namespace: ns2.DAV }, { name: "address-data", namespace: ns2.CARDDAV }]
|
|
});
|
|
context$1$0.next = 4;
|
|
return options.xhr.send(req, addressBook.url, {
|
|
sandbox: options.sandbox
|
|
});
|
|
case 4:
|
|
responses = context$1$0.sent;
|
|
return context$1$0.abrupt("return", responses.map(function(res) {
|
|
debug("Found vcard with url " + res.href);
|
|
return new _model.VCard({
|
|
data: res,
|
|
addressBook,
|
|
url: _url2["default"].resolve(addressBook.account.rootUrl, res.href),
|
|
etag: res.props.getetag,
|
|
addressData: res.props.addressData
|
|
});
|
|
}));
|
|
case 6:
|
|
case "end":
|
|
return context$1$0.stop();
|
|
}
|
|
}, callee$0$0, this);
|
|
}));
|
|
exports3.listVCards = listVCards;
|
|
function updateCard(card, options) {
|
|
return webdav.updateObject(card.url, card.addressData, card.etag, options);
|
|
}
|
|
function deleteCard(card, options) {
|
|
return webdav.deleteObject(card.url, card.etag, options);
|
|
}
|
|
function syncAddressBook(addressBook, options) {
|
|
options.basicSync = basicSync;
|
|
options.webdavSync = webdavSync;
|
|
return webdav.syncCollection(addressBook, options);
|
|
}
|
|
var syncCarddavAccount = _co2["default"].wrap(regeneratorRuntime.mark(function callee$0$0(account) {
|
|
var options = arguments.length <= 1 || arguments[1] === void 0 ? {} : arguments[1];
|
|
var addressBooks;
|
|
return regeneratorRuntime.wrap(function callee$0$0$(context$1$0) {
|
|
while (1)
|
|
switch (context$1$0.prev = context$1$0.next) {
|
|
case 0:
|
|
options.loadObjects = false;
|
|
if (!account.addressBooks) {
|
|
account.addressBooks = [];
|
|
}
|
|
context$1$0.next = 4;
|
|
return listAddressBooks(account, options);
|
|
case 4:
|
|
addressBooks = context$1$0.sent;
|
|
addressBooks.filter(function(addressBook) {
|
|
return account.addressBooks.every(function(prev) {
|
|
return !(0, _fuzzy_url_equals2["default"])(prev.url, addressBook.url);
|
|
});
|
|
}).forEach(function(addressBook) {
|
|
return account.addressBooks.push(addressBook);
|
|
});
|
|
options.loadObjects = true;
|
|
context$1$0.next = 9;
|
|
return account.addressBooks.map(_co2["default"].wrap(regeneratorRuntime.mark(function callee$1$0(addressBook, index) {
|
|
return regeneratorRuntime.wrap(function callee$1$0$(context$2$0) {
|
|
while (1)
|
|
switch (context$2$0.prev = context$2$0.next) {
|
|
case 0:
|
|
context$2$0.prev = 0;
|
|
context$2$0.next = 3;
|
|
return syncAddressBook(addressBook, options);
|
|
case 3:
|
|
context$2$0.next = 9;
|
|
break;
|
|
case 5:
|
|
context$2$0.prev = 5;
|
|
context$2$0.t0 = context$2$0["catch"](0);
|
|
debug("Syncing " + addressBook.displayName + " failed with " + context$2$0.t0);
|
|
account.addressBooks.splice(index, 1);
|
|
case 9:
|
|
case "end":
|
|
return context$2$0.stop();
|
|
}
|
|
}, callee$1$0, this, [[0, 5]]);
|
|
})));
|
|
case 9:
|
|
return context$1$0.abrupt("return", account);
|
|
case 10:
|
|
case "end":
|
|
return context$1$0.stop();
|
|
}
|
|
}, callee$0$0, this);
|
|
}));
|
|
exports3.syncCarddavAccount = syncCarddavAccount;
|
|
var basicSync = _co2["default"].wrap(regeneratorRuntime.mark(function callee$0$0(addressBook, options) {
|
|
var sync;
|
|
return regeneratorRuntime.wrap(function callee$0$0$(context$1$0) {
|
|
while (1)
|
|
switch (context$1$0.prev = context$1$0.next) {
|
|
case 0:
|
|
sync = webdav.isCollectionDirty(addressBook, options);
|
|
if (sync) {
|
|
context$1$0.next = 4;
|
|
break;
|
|
}
|
|
debug("Local ctag matched remote! No need to sync :).");
|
|
return context$1$0.abrupt("return", addressBook);
|
|
case 4:
|
|
debug("ctag changed so we need to fetch stuffs.");
|
|
context$1$0.next = 7;
|
|
return listVCards(addressBook, options);
|
|
case 7:
|
|
addressBook.objects = context$1$0.sent;
|
|
return context$1$0.abrupt("return", addressBook);
|
|
case 9:
|
|
case "end":
|
|
return context$1$0.stop();
|
|
}
|
|
}, callee$0$0, this);
|
|
}));
|
|
var webdavSync = _co2["default"].wrap(regeneratorRuntime.mark(function callee$0$0(addressBook, options) {
|
|
var req, result;
|
|
return regeneratorRuntime.wrap(function callee$0$0$(context$1$0) {
|
|
while (1)
|
|
switch (context$1$0.prev = context$1$0.next) {
|
|
case 0:
|
|
req = request3.syncCollection({
|
|
props: [{ name: "getetag", namespace: ns2.DAV }, { name: "address-data", namespace: ns2.CARDDAV }],
|
|
syncLevel: 1,
|
|
syncToken: addressBook.syncToken
|
|
});
|
|
context$1$0.next = 3;
|
|
return options.xhr.send(req, addressBook.url, {
|
|
sandbox: options.sandbox
|
|
});
|
|
case 3:
|
|
result = context$1$0.sent;
|
|
result.responses.forEach(function(response) {
|
|
var vcard = addressBook.objects.filter(function(object) {
|
|
return (0, _fuzzy_url_equals2["default"])(object.url, response.href);
|
|
})[0];
|
|
if (!vcard)
|
|
return;
|
|
vcard.etag = response.props.getetag;
|
|
vcard.addressData = response.props.addressData;
|
|
});
|
|
addressBook.syncToken = result.syncToken;
|
|
return context$1$0.abrupt("return", addressBook);
|
|
case 7:
|
|
case "end":
|
|
return context$1$0.stop();
|
|
}
|
|
}, callee$0$0, this);
|
|
}));
|
|
}, { "./debug": 6, "./fuzzy_url_equals": 7, "./model": 9, "./namespace": 10, "./request": 12, "./webdav": 22, "co": 24, "url": 29 }], 6: [function(require2, module4, exports3) {
|
|
"use strict";
|
|
Object.defineProperty(exports3, "__esModule", {
|
|
value: true
|
|
});
|
|
exports3["default"] = debug;
|
|
function debug(topic) {
|
|
return function(message) {
|
|
if (debug.enabled) {
|
|
console.log("[" + topic + "] " + message);
|
|
}
|
|
};
|
|
}
|
|
module4.exports = exports3["default"];
|
|
}, {}], 7: [function(require2, module4, exports3) {
|
|
"use strict";
|
|
Object.defineProperty(exports3, "__esModule", {
|
|
value: true
|
|
});
|
|
exports3["default"] = fuzzyUrlEquals;
|
|
function fuzzyUrlEquals(one, other) {
|
|
return fuzzyIncludes(one, other) || fuzzyIncludes(other, one);
|
|
}
|
|
;
|
|
function fuzzyIncludes(one, other) {
|
|
return one.indexOf(other) !== -1 || other.charAt(other.length - 1) === "/" && one.indexOf(other.slice(0, -1)) !== -1;
|
|
}
|
|
module4.exports = exports3["default"];
|
|
}, {}], 8: [function(require2, module4, exports3) {
|
|
"use strict";
|
|
Object.defineProperty(exports3, "__esModule", {
|
|
value: true
|
|
});
|
|
function _interopExportWildcard(obj, defaults) {
|
|
var newObj = defaults({}, obj);
|
|
delete newObj["default"];
|
|
return newObj;
|
|
}
|
|
function _defaults(obj, defaults) {
|
|
var keys = Object.getOwnPropertyNames(defaults);
|
|
for (var i3 = 0; i3 < keys.length; i3++) {
|
|
var key = keys[i3];
|
|
var value = Object.getOwnPropertyDescriptor(defaults, key);
|
|
if (value && value.configurable && obj[key] === void 0) {
|
|
Object.defineProperty(obj, key, value);
|
|
}
|
|
}
|
|
return obj;
|
|
}
|
|
function _interopRequireWildcard(obj) {
|
|
if (obj && obj.__esModule) {
|
|
return obj;
|
|
} else {
|
|
var newObj = {};
|
|
if (obj != null) {
|
|
for (var key in obj) {
|
|
if (Object.prototype.hasOwnProperty.call(obj, key))
|
|
newObj[key] = obj[key];
|
|
}
|
|
}
|
|
newObj["default"] = obj;
|
|
return newObj;
|
|
}
|
|
}
|
|
function _interopRequireDefault(obj) {
|
|
return obj && obj.__esModule ? obj : { "default": obj };
|
|
}
|
|
var _debug = require2("./debug");
|
|
var _debug2 = _interopRequireDefault(_debug);
|
|
var _namespace = require2("./namespace");
|
|
var ns2 = _interopRequireWildcard(_namespace);
|
|
var _request = require2("./request");
|
|
var request3 = _interopRequireWildcard(_request);
|
|
var _transport = require2("./transport");
|
|
var transport3 = _interopRequireWildcard(_transport);
|
|
var _package = require2("../package");
|
|
Object.defineProperty(exports3, "version", {
|
|
enumerable: true,
|
|
get: function get() {
|
|
return _package.version;
|
|
}
|
|
});
|
|
var _accounts = require2("./accounts");
|
|
Object.defineProperty(exports3, "createAccount", {
|
|
enumerable: true,
|
|
get: function get() {
|
|
return _accounts.createAccount;
|
|
}
|
|
});
|
|
var _calendars = require2("./calendars");
|
|
_defaults(exports3, _interopExportWildcard(_calendars, _defaults));
|
|
var _client = require2("./client");
|
|
Object.defineProperty(exports3, "Client", {
|
|
enumerable: true,
|
|
get: function get() {
|
|
return _client.Client;
|
|
}
|
|
});
|
|
var _contacts = require2("./contacts");
|
|
_defaults(exports3, _interopExportWildcard(_contacts, _defaults));
|
|
var _model = require2("./model");
|
|
_defaults(exports3, _interopExportWildcard(_model, _defaults));
|
|
Object.defineProperty(exports3, "Request", {
|
|
enumerable: true,
|
|
get: function get() {
|
|
return _request.Request;
|
|
}
|
|
});
|
|
var _sandbox = require2("./sandbox");
|
|
Object.defineProperty(exports3, "Sandbox", {
|
|
enumerable: true,
|
|
get: function get() {
|
|
return _sandbox.Sandbox;
|
|
}
|
|
});
|
|
Object.defineProperty(exports3, "createSandbox", {
|
|
enumerable: true,
|
|
get: function get() {
|
|
return _sandbox.createSandbox;
|
|
}
|
|
});
|
|
exports3.debug = _debug2["default"];
|
|
exports3.ns = ns2;
|
|
exports3.request = request3;
|
|
exports3.transport = transport3;
|
|
}, { "../package": 33, "./accounts": 1, "./calendars": 2, "./client": 4, "./contacts": 5, "./debug": 6, "./model": 9, "./namespace": 10, "./request": 12, "./sandbox": 13, "./transport": 21 }], 9: [function(require2, module4, exports3) {
|
|
"use strict";
|
|
Object.defineProperty(exports3, "__esModule", {
|
|
value: true
|
|
});
|
|
var _get = function get(_x, _x2, _x3) {
|
|
var _again = true;
|
|
_function:
|
|
while (_again) {
|
|
var object = _x, property = _x2, receiver = _x3;
|
|
_again = false;
|
|
if (object === null)
|
|
object = Function.prototype;
|
|
var desc = Object.getOwnPropertyDescriptor(object, property);
|
|
if (desc === void 0) {
|
|
var parent = Object.getPrototypeOf(object);
|
|
if (parent === null) {
|
|
return void 0;
|
|
} else {
|
|
_x = parent;
|
|
_x2 = property;
|
|
_x3 = receiver;
|
|
_again = true;
|
|
desc = parent = void 0;
|
|
continue _function;
|
|
}
|
|
} else if ("value" in desc) {
|
|
return desc.value;
|
|
} else {
|
|
var getter = desc.get;
|
|
if (getter === void 0) {
|
|
return void 0;
|
|
}
|
|
return getter.call(receiver);
|
|
}
|
|
}
|
|
};
|
|
function _inherits(subClass, superClass) {
|
|
if (typeof superClass !== "function" && superClass !== null) {
|
|
throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
|
|
}
|
|
subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } });
|
|
if (superClass)
|
|
Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass;
|
|
}
|
|
function _classCallCheck(instance, Constructor) {
|
|
if (!(instance instanceof Constructor)) {
|
|
throw new TypeError("Cannot call a class as a function");
|
|
}
|
|
}
|
|
var Account = function Account2(options) {
|
|
_classCallCheck(this, Account2);
|
|
Object.assign(this, {
|
|
server: null,
|
|
credentials: null,
|
|
rootUrl: null,
|
|
principalUrl: null,
|
|
homeUrl: null,
|
|
calendars: null,
|
|
addressBooks: null
|
|
}, options);
|
|
};
|
|
exports3.Account = Account;
|
|
var Credentials3 = function Credentials4(options) {
|
|
_classCallCheck(this, Credentials4);
|
|
Object.assign(this, {
|
|
username: null,
|
|
password: null,
|
|
clientId: null,
|
|
clientSecret: null,
|
|
authorizationCode: null,
|
|
redirectUrl: null,
|
|
tokenUrl: null,
|
|
accessToken: null,
|
|
refreshToken: null,
|
|
expiration: null
|
|
}, options);
|
|
};
|
|
exports3.Credentials = Credentials3;
|
|
var DAVCollection = function DAVCollection2(options) {
|
|
_classCallCheck(this, DAVCollection2);
|
|
Object.assign(this, {
|
|
data: null,
|
|
objects: null,
|
|
account: null,
|
|
ctag: null,
|
|
description: null,
|
|
displayName: null,
|
|
reports: null,
|
|
resourcetype: null,
|
|
syncToken: null,
|
|
url: null
|
|
}, options);
|
|
};
|
|
exports3.DAVCollection = DAVCollection;
|
|
var AddressBook = function(_DAVCollection) {
|
|
_inherits(AddressBook2, _DAVCollection);
|
|
function AddressBook2(options) {
|
|
_classCallCheck(this, AddressBook2);
|
|
_get(Object.getPrototypeOf(AddressBook2.prototype), "constructor", this).call(this, options);
|
|
}
|
|
return AddressBook2;
|
|
}(DAVCollection);
|
|
exports3.AddressBook = AddressBook;
|
|
var Calendar3 = function(_DAVCollection2) {
|
|
_inherits(Calendar4, _DAVCollection2);
|
|
function Calendar4(options) {
|
|
_classCallCheck(this, Calendar4);
|
|
_get(Object.getPrototypeOf(Calendar4.prototype), "constructor", this).call(this, options);
|
|
Object.assign(this, {
|
|
components: null,
|
|
timezone: null
|
|
}, options);
|
|
}
|
|
return Calendar4;
|
|
}(DAVCollection);
|
|
exports3.Calendar = Calendar3;
|
|
var DAVObject = function DAVObject2(options) {
|
|
_classCallCheck(this, DAVObject2);
|
|
Object.assign(this, {
|
|
data: null,
|
|
etag: null,
|
|
url: null
|
|
}, options);
|
|
};
|
|
exports3.DAVObject = DAVObject;
|
|
var CalendarObject = function(_DAVObject) {
|
|
_inherits(CalendarObject2, _DAVObject);
|
|
function CalendarObject2(options) {
|
|
_classCallCheck(this, CalendarObject2);
|
|
_get(Object.getPrototypeOf(CalendarObject2.prototype), "constructor", this).call(this, options);
|
|
Object.assign(this, {
|
|
calendar: null,
|
|
calendarData: null
|
|
}, options);
|
|
}
|
|
return CalendarObject2;
|
|
}(DAVObject);
|
|
exports3.CalendarObject = CalendarObject;
|
|
var VCard = function(_DAVObject2) {
|
|
_inherits(VCard2, _DAVObject2);
|
|
function VCard2(options) {
|
|
_classCallCheck(this, VCard2);
|
|
_get(Object.getPrototypeOf(VCard2.prototype), "constructor", this).call(this, options);
|
|
Object.assign(this, {
|
|
addressBook: null,
|
|
addressData: null
|
|
}, options);
|
|
}
|
|
return VCard2;
|
|
}(DAVObject);
|
|
exports3.VCard = VCard;
|
|
}, {}], 10: [function(require2, module4, exports3) {
|
|
"use strict";
|
|
Object.defineProperty(exports3, "__esModule", {
|
|
value: true
|
|
});
|
|
var CALENDAR_SERVER = "http://calendarserver.org/ns/";
|
|
exports3.CALENDAR_SERVER = CALENDAR_SERVER;
|
|
var CALDAV_APPLE = "http://apple.com/ns/ical/";
|
|
exports3.CALDAV_APPLE = CALDAV_APPLE;
|
|
var CALDAV = "urn:ietf:params:xml:ns:caldav";
|
|
exports3.CALDAV = CALDAV;
|
|
var CARDDAV = "urn:ietf:params:xml:ns:carddav";
|
|
exports3.CARDDAV = CARDDAV;
|
|
var DAV = "DAV:";
|
|
exports3.DAV = DAV;
|
|
}, {}], 11: [function(require2, module4, exports3) {
|
|
"use strict";
|
|
Object.defineProperty(exports3, "__esModule", {
|
|
value: true
|
|
});
|
|
exports3.multistatus = multistatus;
|
|
function _interopRequireDefault(obj) {
|
|
return obj && obj.__esModule ? obj : { "default": obj };
|
|
}
|
|
var _camelize = require2("./camelize");
|
|
var _camelize2 = _interopRequireDefault(_camelize);
|
|
var debug = require2("./debug")("dav:parser");
|
|
var DOMParser = void 0;
|
|
if (typeof self !== "undefined" && "DOMParser" in self) {
|
|
DOMParser = self.DOMParser;
|
|
} else {
|
|
DOMParser = require2("xmldom").DOMParser;
|
|
}
|
|
function multistatus(string) {
|
|
var parser = new DOMParser();
|
|
var doc = parser.parseFromString(string, "text/xml");
|
|
var result = traverse.multistatus(child(doc, "multistatus"));
|
|
debug("input:\n" + string + "\noutput:\n" + JSON.stringify(result) + "\n");
|
|
return result;
|
|
}
|
|
var traverse = {
|
|
multistatus: function multistatus2(node) {
|
|
return complex(node, { response: true });
|
|
},
|
|
response: function response(node) {
|
|
return complex(node, { propstat: true, href: false });
|
|
},
|
|
propstat: function propstat(node) {
|
|
return complex(node, { prop: false });
|
|
},
|
|
prop: function prop(node) {
|
|
return complex(node, {
|
|
resourcetype: false,
|
|
supportedCalendarComponentSet: false,
|
|
supportedReportSet: false,
|
|
currentUserPrincipal: false
|
|
});
|
|
},
|
|
resourcetype: function resourcetype(node) {
|
|
return childNodes(node).map(function(childNode) {
|
|
return childNode.localName;
|
|
});
|
|
},
|
|
supportedCalendarComponentSet: function supportedCalendarComponentSet(node) {
|
|
return complex(node, { comp: true }, "comp");
|
|
},
|
|
supportedReportSet: function supportedReportSet(node) {
|
|
return complex(node, { supportedReport: true }, "supportedReport");
|
|
},
|
|
comp: function comp(node) {
|
|
return node.getAttribute("name");
|
|
},
|
|
supportedReport: function supportedReport(node) {
|
|
return complex(node, { report: false }, "report");
|
|
},
|
|
report: function report(node) {
|
|
return childNodes(node).map(function(childNode) {
|
|
return childNode.localName;
|
|
});
|
|
},
|
|
href: function href(node) {
|
|
return decodeURIComponent(childNodes(node)[0].nodeValue);
|
|
},
|
|
currentUserPrincipal: function currentUserPrincipal(node) {
|
|
return complex(node, { href: false }, "href");
|
|
}
|
|
};
|
|
function complex(node, childspec, collapse) {
|
|
var result = {};
|
|
for (var key in childspec) {
|
|
if (childspec[key]) {
|
|
result[key] = [];
|
|
}
|
|
}
|
|
childNodes(node).forEach(function(childNode) {
|
|
return traverseChild(node, childNode, childspec, result);
|
|
});
|
|
return maybeCollapse(result, childspec, collapse);
|
|
}
|
|
function traverseChild(node, childNode, childspec, result) {
|
|
if (childNode.nodeType === 3 && /^\s+$/.test(childNode.nodeValue)) {
|
|
return;
|
|
}
|
|
var localName = (0, _camelize2["default"])(childNode.localName, "-");
|
|
if (!(localName in childspec)) {
|
|
debug("Unexpected node of type " + localName + " encountered while parsing " + node.localName + " node!");
|
|
var value = childNode.textContent;
|
|
if (localName in result) {
|
|
if (!Array.isArray(result[localName])) {
|
|
result[localName] = [result[localName]];
|
|
}
|
|
result[localName].push(value);
|
|
return;
|
|
}
|
|
result[localName] = value;
|
|
return;
|
|
}
|
|
var traversal = traverse[localName](childNode);
|
|
if (childspec[localName]) {
|
|
result[localName].push(traversal);
|
|
} else {
|
|
result[localName] = traversal;
|
|
}
|
|
}
|
|
function maybeCollapse(result, childspec, collapse) {
|
|
if (!collapse) {
|
|
return result;
|
|
}
|
|
if (!childspec[collapse]) {
|
|
return result[collapse];
|
|
}
|
|
return result[collapse].reduce(function(a3, b3) {
|
|
return a3.concat(b3);
|
|
}, []);
|
|
}
|
|
function childNodes(node) {
|
|
var result = node.childNodes;
|
|
if (!Array.isArray(result)) {
|
|
result = Array.prototype.slice.call(result);
|
|
}
|
|
return result;
|
|
}
|
|
function children(node, localName) {
|
|
return childNodes(node).filter(function(childNode) {
|
|
return childNode.localName === localName;
|
|
});
|
|
}
|
|
function child(node, localName) {
|
|
return children(node, localName)[0];
|
|
}
|
|
}, { "./camelize": 3, "./debug": 6, "xmldom": 30 }], 12: [function(require2, module4, exports3) {
|
|
"use strict";
|
|
Object.defineProperty(exports3, "__esModule", {
|
|
value: true
|
|
});
|
|
exports3.addressBookQuery = addressBookQuery;
|
|
exports3.basic = basic;
|
|
exports3.calendarQuery = calendarQuery;
|
|
exports3.collectionQuery = collectionQuery;
|
|
exports3.propfind = propfind;
|
|
exports3.syncCollection = syncCollection;
|
|
exports3.mergeProps = mergeProps2;
|
|
exports3.getProps = getProps;
|
|
exports3.setRequestHeaders = setRequestHeaders;
|
|
function _interopRequireWildcard(obj) {
|
|
if (obj && obj.__esModule) {
|
|
return obj;
|
|
} else {
|
|
var newObj = {};
|
|
if (obj != null) {
|
|
for (var key in obj) {
|
|
if (Object.prototype.hasOwnProperty.call(obj, key))
|
|
newObj[key] = obj[key];
|
|
}
|
|
}
|
|
newObj["default"] = obj;
|
|
return newObj;
|
|
}
|
|
}
|
|
function _classCallCheck(instance, Constructor) {
|
|
if (!(instance instanceof Constructor)) {
|
|
throw new TypeError("Cannot call a class as a function");
|
|
}
|
|
}
|
|
var _parser = require2("./parser");
|
|
var _template = require2("./template");
|
|
var template = _interopRequireWildcard(_template);
|
|
function addressBookQuery(options) {
|
|
return collectionQuery(template.addressBookQuery({ props: options.props || [] }), { depth: options.depth });
|
|
}
|
|
function basic(options) {
|
|
function transformRequest(xhr) {
|
|
setRequestHeaders(xhr, options);
|
|
}
|
|
return new Request2({
|
|
method: options.method,
|
|
requestData: options.data,
|
|
transformRequest
|
|
});
|
|
}
|
|
function calendarQuery(options) {
|
|
return collectionQuery(template.calendarQuery({
|
|
props: options.props || [],
|
|
filters: options.filters || [],
|
|
timezone: options.timezone
|
|
}), {
|
|
depth: options.depth
|
|
});
|
|
}
|
|
function collectionQuery(requestData, options) {
|
|
function transformRequest(xhr) {
|
|
setRequestHeaders(xhr, options);
|
|
}
|
|
function transformResponse(xhr) {
|
|
return (0, _parser.multistatus)(xhr.responseText).response.map(function(res) {
|
|
return { href: res.href, props: getProps(res.propstat) };
|
|
});
|
|
}
|
|
return new Request2({
|
|
method: "REPORT",
|
|
requestData,
|
|
transformRequest,
|
|
transformResponse
|
|
});
|
|
}
|
|
function propfind(options) {
|
|
var requestData = template.propfind({ props: options.props });
|
|
function transformRequest(xhr) {
|
|
setRequestHeaders(xhr, options);
|
|
}
|
|
function transformResponse(xhr) {
|
|
var responses = (0, _parser.multistatus)(xhr.responseText).response.map(function(res) {
|
|
return { href: res.href, props: getProps(res.propstat) };
|
|
});
|
|
if (!options.mergeResponses) {
|
|
return responses;
|
|
}
|
|
var merged = mergeProps2(responses.map(function(res) {
|
|
return res.props;
|
|
}));
|
|
var hrefs = responses.map(function(res) {
|
|
return res.href;
|
|
});
|
|
return { props: merged, hrefs };
|
|
}
|
|
return new Request2({
|
|
method: "PROPFIND",
|
|
requestData,
|
|
transformRequest,
|
|
transformResponse
|
|
});
|
|
}
|
|
function syncCollection(options) {
|
|
var requestData = template.syncCollection({
|
|
props: options.props,
|
|
syncLevel: options.syncLevel,
|
|
syncToken: options.syncToken
|
|
});
|
|
function transformRequest(xhr) {
|
|
setRequestHeaders(xhr, options);
|
|
}
|
|
function transformResponse(xhr) {
|
|
var object = (0, _parser.multistatus)(xhr.responseText);
|
|
var responses = object.response.map(function(res) {
|
|
return { href: res.href, props: getProps(res.propstat) };
|
|
});
|
|
return { responses, syncToken: object.syncToken };
|
|
}
|
|
return new Request2({
|
|
method: "REPORT",
|
|
requestData,
|
|
transformRequest,
|
|
transformResponse
|
|
});
|
|
}
|
|
var Request2 = function Request3() {
|
|
var options = arguments.length <= 0 || arguments[0] === void 0 ? {} : arguments[0];
|
|
_classCallCheck(this, Request3);
|
|
Object.assign(this, {
|
|
method: null,
|
|
requestData: null,
|
|
transformRequest: null,
|
|
transformResponse: null,
|
|
onerror: null
|
|
}, options);
|
|
};
|
|
exports3.Request = Request2;
|
|
function getProp(propstat) {
|
|
if (/404/g.test(propstat.status)) {
|
|
return null;
|
|
}
|
|
if (/5\d{2}/g.test(propstat.status) || /4\d{2}/g.test(propstat.status)) {
|
|
throw new Error("Bad status on propstat: " + propstat.status);
|
|
}
|
|
return "prop" in propstat ? propstat.prop : null;
|
|
}
|
|
function mergeProps2(props) {
|
|
return props.reduce(function(a3, b3) {
|
|
return Object.assign(a3, b3);
|
|
}, {});
|
|
}
|
|
function getProps(propstats) {
|
|
return mergeProps2(propstats.map(getProp).filter(function(prop) {
|
|
return prop && typeof prop === "object";
|
|
}));
|
|
}
|
|
function setRequestHeaders(request3, options) {
|
|
request3.setRequestHeader("Content-Type", options.contentType || "application/xml;charset=utf-8");
|
|
if ("depth" in options) {
|
|
request3.setRequestHeader("Depth", options.depth);
|
|
}
|
|
if ("etag" in options && options.etag) {
|
|
request3.setRequestHeader("If-Match", options.etag);
|
|
}
|
|
}
|
|
}, { "./parser": 11, "./template": 17 }], 13: [function(require2, module4, exports3) {
|
|
"use strict";
|
|
Object.defineProperty(exports3, "__esModule", {
|
|
value: true
|
|
});
|
|
var _createClass = function() {
|
|
function defineProperties(target, props) {
|
|
for (var i3 = 0; i3 < props.length; i3++) {
|
|
var descriptor = props[i3];
|
|
descriptor.enumerable = descriptor.enumerable || false;
|
|
descriptor.configurable = true;
|
|
if ("value" in descriptor)
|
|
descriptor.writable = true;
|
|
Object.defineProperty(target, descriptor.key, descriptor);
|
|
}
|
|
}
|
|
return function(Constructor, protoProps, staticProps) {
|
|
if (protoProps)
|
|
defineProperties(Constructor.prototype, protoProps);
|
|
if (staticProps)
|
|
defineProperties(Constructor, staticProps);
|
|
return Constructor;
|
|
};
|
|
}();
|
|
exports3.createSandbox = createSandbox;
|
|
function _classCallCheck(instance, Constructor) {
|
|
if (!(instance instanceof Constructor)) {
|
|
throw new TypeError("Cannot call a class as a function");
|
|
}
|
|
}
|
|
var debug = require2("./debug")("dav:sandbox");
|
|
var Sandbox = function() {
|
|
function Sandbox2() {
|
|
_classCallCheck(this, Sandbox2);
|
|
this.requestList = [];
|
|
}
|
|
_createClass(Sandbox2, [{
|
|
key: "add",
|
|
value: function add2(request3) {
|
|
debug("Adding request to sandbox.");
|
|
this.requestList.push(request3);
|
|
}
|
|
}, {
|
|
key: "abort",
|
|
value: function abort() {
|
|
debug("Aborting sandboxed requests.");
|
|
this.requestList.forEach(function(request3) {
|
|
return request3.abort();
|
|
});
|
|
}
|
|
}]);
|
|
return Sandbox2;
|
|
}();
|
|
exports3.Sandbox = Sandbox;
|
|
function createSandbox() {
|
|
return new Sandbox();
|
|
}
|
|
}, { "./debug": 6 }], 14: [function(require2, module4, exports3) {
|
|
"use strict";
|
|
Object.defineProperty(exports3, "__esModule", {
|
|
value: true
|
|
});
|
|
exports3["default"] = addressBookQuery;
|
|
function _interopRequireDefault(obj) {
|
|
return obj && obj.__esModule ? obj : { "default": obj };
|
|
}
|
|
var _prop = require2("./prop");
|
|
var _prop2 = _interopRequireDefault(_prop);
|
|
function addressBookQuery(object) {
|
|
return '<card:addressbook-query xmlns:card="urn:ietf:params:xml:ns:carddav"\n xmlns:d="DAV:">\n <d:prop>\n ' + object.props.map(_prop2["default"]) + `
|
|
</d:prop>
|
|
<!-- According to http://stackoverflow.com/questions/23742568/google-carddav-api-addressbook-multiget-returns-400-bad-request,
|
|
Google's CardDAV server requires a filter element. I don't think all addressbook-query calls need a filter in the spec though? -->
|
|
<card:filter>
|
|
<card:prop-filter name="FN">
|
|
</card:prop-filter>
|
|
</card:filter>
|
|
</card:addressbook-query>`;
|
|
}
|
|
module4.exports = exports3["default"];
|
|
}, { "./prop": 18 }], 15: [function(require2, module4, exports3) {
|
|
"use strict";
|
|
Object.defineProperty(exports3, "__esModule", {
|
|
value: true
|
|
});
|
|
exports3["default"] = calendarQuery;
|
|
function _interopRequireDefault(obj) {
|
|
return obj && obj.__esModule ? obj : { "default": obj };
|
|
}
|
|
var _filter = require2("./filter");
|
|
var _filter2 = _interopRequireDefault(_filter);
|
|
var _prop = require2("./prop");
|
|
var _prop2 = _interopRequireDefault(_prop);
|
|
function calendarQuery(object) {
|
|
return '<c:calendar-query xmlns:c="urn:ietf:params:xml:ns:caldav"\n xmlns:cs="http://calendarserver.org/ns/"\n xmlns:ca="http://apple.com/ns/ical/"\n xmlns:d="DAV:">\n <d:prop>\n ' + object.props.map(_prop2["default"]) + "\n </d:prop>\n <c:filter>\n " + object.filters.map(_filter2["default"]) + "\n </c:filter>\n " + (object.timezone ? "<c:timezone>" + object.timezone + "</c:timezone>" : "") + "\n </c:calendar-query>";
|
|
}
|
|
module4.exports = exports3["default"];
|
|
}, { "./filter": 16, "./prop": 18 }], 16: [function(require2, module4, exports3) {
|
|
"use strict";
|
|
Object.defineProperty(exports3, "__esModule", {
|
|
value: true
|
|
});
|
|
exports3["default"] = filter;
|
|
function filter(item) {
|
|
if (!item.children || !item.children.length) {
|
|
if (typeof item.value === "undefined") {
|
|
return "<c:" + item.type + " " + formatAttrs(item.attrs) + "/>";
|
|
}
|
|
return "<c:" + item.type + " " + formatAttrs(item.attrs) + ">" + item.value + "</c:" + item.type + ">";
|
|
}
|
|
var children = item.children.map(filter);
|
|
return "<c:" + item.type + " " + formatAttrs(item.attrs) + ">\n " + children + "\n </c:" + item.type + ">";
|
|
}
|
|
function formatAttrs(attrs) {
|
|
if (typeof attrs !== "object") {
|
|
return "";
|
|
}
|
|
return Object.keys(attrs).map(function(attr) {
|
|
return attr + '="' + attrs[attr] + '"';
|
|
}).join(" ");
|
|
}
|
|
module4.exports = exports3["default"];
|
|
}, {}], 17: [function(require2, module4, exports3) {
|
|
"use strict";
|
|
exports3.addressBookQuery = require2("./address_book_query");
|
|
exports3.calendarQuery = require2("./calendar_query");
|
|
exports3.propfind = require2("./propfind");
|
|
exports3.syncCollection = require2("./sync_collection");
|
|
}, { "./address_book_query": 14, "./calendar_query": 15, "./propfind": 19, "./sync_collection": 20 }], 18: [function(require2, module4, exports3) {
|
|
"use strict";
|
|
Object.defineProperty(exports3, "__esModule", {
|
|
value: true
|
|
});
|
|
exports3["default"] = prop;
|
|
function _interopRequireWildcard(obj) {
|
|
if (obj && obj.__esModule) {
|
|
return obj;
|
|
} else {
|
|
var newObj = {};
|
|
if (obj != null) {
|
|
for (var key in obj) {
|
|
if (Object.prototype.hasOwnProperty.call(obj, key))
|
|
newObj[key] = obj[key];
|
|
}
|
|
}
|
|
newObj["default"] = obj;
|
|
return newObj;
|
|
}
|
|
}
|
|
var _namespace = require2("../namespace");
|
|
var ns2 = _interopRequireWildcard(_namespace);
|
|
function prop(item) {
|
|
return "<" + xmlnsPrefix(item.namespace) + ":" + item.name + " />";
|
|
}
|
|
function xmlnsPrefix(namespace) {
|
|
switch (namespace) {
|
|
case ns2.DAV:
|
|
return "d";
|
|
case ns2.CALENDAR_SERVER:
|
|
return "cs";
|
|
case ns2.CALDAV_APPLE:
|
|
return "ca";
|
|
case ns2.CALDAV:
|
|
return "c";
|
|
case ns2.CARDDAV:
|
|
return "card";
|
|
default:
|
|
throw new Error("Unrecognized xmlns " + namespace);
|
|
}
|
|
}
|
|
module4.exports = exports3["default"];
|
|
}, { "../namespace": 10 }], 19: [function(require2, module4, exports3) {
|
|
"use strict";
|
|
Object.defineProperty(exports3, "__esModule", {
|
|
value: true
|
|
});
|
|
exports3["default"] = propfind;
|
|
function _interopRequireDefault(obj) {
|
|
return obj && obj.__esModule ? obj : { "default": obj };
|
|
}
|
|
var _prop = require2("./prop");
|
|
var _prop2 = _interopRequireDefault(_prop);
|
|
function propfind(object) {
|
|
return '<d:propfind xmlns:c="urn:ietf:params:xml:ns:caldav"\n xmlns:card="urn:ietf:params:xml:ns:carddav"\n xmlns:cs="http://calendarserver.org/ns/"\n xmlns:ca="http://apple.com/ns/ical/"\n xmlns:d="DAV:">\n <d:prop>\n ' + object.props.map(_prop2["default"]) + "\n </d:prop>\n </d:propfind>";
|
|
}
|
|
module4.exports = exports3["default"];
|
|
}, { "./prop": 18 }], 20: [function(require2, module4, exports3) {
|
|
"use strict";
|
|
Object.defineProperty(exports3, "__esModule", {
|
|
value: true
|
|
});
|
|
exports3["default"] = syncCollection;
|
|
function _interopRequireDefault(obj) {
|
|
return obj && obj.__esModule ? obj : { "default": obj };
|
|
}
|
|
var _prop = require2("./prop");
|
|
var _prop2 = _interopRequireDefault(_prop);
|
|
function syncCollection(object) {
|
|
return '<d:sync-collection xmlns:c="urn:ietf:params:xml:ns:caldav"\n xmlns:card="urn:ietf:params:xml:ns:carddav"\n xmlns:d="DAV:">\n <d:sync-level>' + object.syncLevel + "</d:sync-level>\n <d:sync-token>" + object.syncToken + "</d:sync-token>\n <d:prop>\n " + object.props.map(_prop2["default"]) + "\n </d:prop>\n </d:sync-collection>";
|
|
}
|
|
module4.exports = exports3["default"];
|
|
}, { "./prop": 18 }], 21: [function(require2, module4, exports3) {
|
|
"use strict";
|
|
Object.defineProperty(exports3, "__esModule", {
|
|
value: true
|
|
});
|
|
var _get = function get(_x2, _x3, _x4) {
|
|
var _again = true;
|
|
_function:
|
|
while (_again) {
|
|
var object = _x2, property = _x3, receiver = _x4;
|
|
_again = false;
|
|
if (object === null)
|
|
object = Function.prototype;
|
|
var desc = Object.getOwnPropertyDescriptor(object, property);
|
|
if (desc === void 0) {
|
|
var parent = Object.getPrototypeOf(object);
|
|
if (parent === null) {
|
|
return void 0;
|
|
} else {
|
|
_x2 = parent;
|
|
_x3 = property;
|
|
_x4 = receiver;
|
|
_again = true;
|
|
desc = parent = void 0;
|
|
continue _function;
|
|
}
|
|
} else if ("value" in desc) {
|
|
return desc.value;
|
|
} else {
|
|
var getter = desc.get;
|
|
if (getter === void 0) {
|
|
return void 0;
|
|
}
|
|
return getter.call(receiver);
|
|
}
|
|
}
|
|
};
|
|
var _createClass = function() {
|
|
function defineProperties(target, props) {
|
|
for (var i3 = 0; i3 < props.length; i3++) {
|
|
var descriptor = props[i3];
|
|
descriptor.enumerable = descriptor.enumerable || false;
|
|
descriptor.configurable = true;
|
|
if ("value" in descriptor)
|
|
descriptor.writable = true;
|
|
Object.defineProperty(target, descriptor.key, descriptor);
|
|
}
|
|
}
|
|
return function(Constructor, protoProps, staticProps) {
|
|
if (protoProps)
|
|
defineProperties(Constructor.prototype, protoProps);
|
|
if (staticProps)
|
|
defineProperties(Constructor, staticProps);
|
|
return Constructor;
|
|
};
|
|
}();
|
|
function _interopRequireDefault(obj) {
|
|
return obj && obj.__esModule ? obj : { "default": obj };
|
|
}
|
|
function _inherits(subClass, superClass) {
|
|
if (typeof superClass !== "function" && superClass !== null) {
|
|
throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
|
|
}
|
|
subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } });
|
|
if (superClass)
|
|
Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass;
|
|
}
|
|
function _classCallCheck(instance, Constructor) {
|
|
if (!(instance instanceof Constructor)) {
|
|
throw new TypeError("Cannot call a class as a function");
|
|
}
|
|
}
|
|
var _co = require2("co");
|
|
var _co2 = _interopRequireDefault(_co);
|
|
var _querystring = require2("querystring");
|
|
var _querystring2 = _interopRequireDefault(_querystring);
|
|
var _xmlhttprequest = require2("./xmlhttprequest");
|
|
var _xmlhttprequest2 = _interopRequireDefault(_xmlhttprequest);
|
|
var Transport = function() {
|
|
function Transport2(credentials) {
|
|
_classCallCheck(this, Transport2);
|
|
this.credentials = credentials || null;
|
|
}
|
|
_createClass(Transport2, [{
|
|
key: "send",
|
|
value: function send() {
|
|
}
|
|
}]);
|
|
return Transport2;
|
|
}();
|
|
exports3.Transport = Transport;
|
|
var Basic2 = function(_Transport) {
|
|
_inherits(Basic3, _Transport);
|
|
function Basic3(credentials) {
|
|
_classCallCheck(this, Basic3);
|
|
_get(Object.getPrototypeOf(Basic3.prototype), "constructor", this).call(this, credentials);
|
|
}
|
|
_createClass(Basic3, [{
|
|
key: "send",
|
|
value: function send(request3, url, options) {
|
|
return (0, _co2["default"])(regeneratorRuntime.mark(function callee$2$0() {
|
|
var sandbox, transformRequest, transformResponse, onerror, xhr, result;
|
|
return regeneratorRuntime.wrap(function callee$2$0$(context$3$0) {
|
|
while (1)
|
|
switch (context$3$0.prev = context$3$0.next) {
|
|
case 0:
|
|
sandbox = options && options.sandbox;
|
|
transformRequest = request3.transformRequest;
|
|
transformResponse = request3.transformResponse;
|
|
onerror = request3.onerror;
|
|
xhr = new _xmlhttprequest2["default"]();
|
|
if (sandbox)
|
|
sandbox.add(xhr);
|
|
xhr.open(request3.method, url, true, this.credentials.username, this.credentials.password);
|
|
if (transformRequest)
|
|
transformRequest(xhr);
|
|
result = void 0;
|
|
context$3$0.prev = 9;
|
|
context$3$0.next = 12;
|
|
return xhr.send(request3.requestData);
|
|
case 12:
|
|
result = transformResponse ? transformResponse(xhr) : xhr;
|
|
context$3$0.next = 19;
|
|
break;
|
|
case 15:
|
|
context$3$0.prev = 15;
|
|
context$3$0.t0 = context$3$0["catch"](9);
|
|
if (onerror)
|
|
onerror(context$3$0.t0);
|
|
throw context$3$0.t0;
|
|
case 19:
|
|
return context$3$0.abrupt("return", result);
|
|
case 20:
|
|
case "end":
|
|
return context$3$0.stop();
|
|
}
|
|
}, callee$2$0, this, [[9, 15]]);
|
|
}).bind(this));
|
|
}
|
|
}]);
|
|
return Basic3;
|
|
}(Transport);
|
|
exports3.Basic = Basic2;
|
|
var OAuth2 = function(_Transport2) {
|
|
_inherits(OAuth22, _Transport2);
|
|
function OAuth22(credentials) {
|
|
_classCallCheck(this, OAuth22);
|
|
_get(Object.getPrototypeOf(OAuth22.prototype), "constructor", this).call(this, credentials);
|
|
}
|
|
_createClass(OAuth22, [{
|
|
key: "send",
|
|
value: function send(request3, url) {
|
|
var options = arguments.length <= 2 || arguments[2] === void 0 ? {} : arguments[2];
|
|
return (0, _co2["default"])(regeneratorRuntime.mark(function callee$2$0() {
|
|
var sandbox, transformRequest, transformResponse, onerror, result, xhr, token;
|
|
return regeneratorRuntime.wrap(function callee$2$0$(context$3$0) {
|
|
while (1)
|
|
switch (context$3$0.prev = context$3$0.next) {
|
|
case 0:
|
|
sandbox = options.sandbox;
|
|
transformRequest = request3.transformRequest;
|
|
transformResponse = request3.transformResponse;
|
|
onerror = request3.onerror;
|
|
if (!("retry" in options))
|
|
options.retry = true;
|
|
result = void 0, xhr = void 0;
|
|
context$3$0.prev = 6;
|
|
context$3$0.next = 9;
|
|
return access(this.credentials, options);
|
|
case 9:
|
|
token = context$3$0.sent;
|
|
xhr = new _xmlhttprequest2["default"]();
|
|
if (sandbox)
|
|
sandbox.add(xhr);
|
|
xhr.open(request3.method, url, true);
|
|
xhr.setRequestHeader("Authorization", "Bearer " + token);
|
|
if (transformRequest)
|
|
transformRequest(xhr);
|
|
context$3$0.next = 17;
|
|
return xhr.send(request3.requestData);
|
|
case 17:
|
|
result = transformResponse ? transformResponse(xhr) : xhr;
|
|
context$3$0.next = 28;
|
|
break;
|
|
case 20:
|
|
context$3$0.prev = 20;
|
|
context$3$0.t0 = context$3$0["catch"](6);
|
|
if (!(options.retry && xhr.status === 401)) {
|
|
context$3$0.next = 26;
|
|
break;
|
|
}
|
|
this.credentials.expiration = 0;
|
|
options.retry = false;
|
|
return context$3$0.abrupt("return", this.send(request3, url, options));
|
|
case 26:
|
|
if (onerror)
|
|
onerror(context$3$0.t0);
|
|
throw context$3$0.t0;
|
|
case 28:
|
|
return context$3$0.abrupt("return", result);
|
|
case 29:
|
|
case "end":
|
|
return context$3$0.stop();
|
|
}
|
|
}, callee$2$0, this, [[6, 20]]);
|
|
}).bind(this));
|
|
}
|
|
}]);
|
|
return OAuth22;
|
|
}(Transport);
|
|
exports3.OAuth2 = OAuth2;
|
|
function access(credentials, options) {
|
|
if (!credentials.accessToken) {
|
|
return getAccessToken(credentials, options);
|
|
}
|
|
if (credentials.refreshToken && isExpired(credentials)) {
|
|
return refreshAccessToken(credentials, options);
|
|
}
|
|
return Promise.resolve(credentials.accessToken);
|
|
}
|
|
function isExpired(credentials) {
|
|
return typeof credentials.expiration === "number" && Date.now() > credentials.expiration;
|
|
}
|
|
var getAccessToken = _co2["default"].wrap(regeneratorRuntime.mark(function callee$0$0(credentials, options) {
|
|
var sandbox, xhr, data, now, response;
|
|
return regeneratorRuntime.wrap(function callee$0$0$(context$1$0) {
|
|
while (1)
|
|
switch (context$1$0.prev = context$1$0.next) {
|
|
case 0:
|
|
sandbox = options.sandbox;
|
|
xhr = new _xmlhttprequest2["default"]();
|
|
if (sandbox)
|
|
sandbox.add(xhr);
|
|
xhr.open("POST", credentials.tokenUrl, true);
|
|
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
|
|
data = _querystring2["default"].stringify({
|
|
code: credentials.authorizationCode,
|
|
redirect_uri: credentials.redirectUrl,
|
|
client_id: credentials.clientId,
|
|
client_secret: credentials.clientSecret,
|
|
grant_type: "authorization_code"
|
|
});
|
|
now = Date.now();
|
|
context$1$0.next = 9;
|
|
return xhr.send(data);
|
|
case 9:
|
|
response = JSON.parse(xhr.responseText);
|
|
credentials.accessToken = response.access_token;
|
|
credentials.refreshToken = "refresh_token" in response ? response.refresh_token : null;
|
|
credentials.expiration = "expires_in" in response ? now + response.expires_in : null;
|
|
return context$1$0.abrupt("return", response.access_token);
|
|
case 14:
|
|
case "end":
|
|
return context$1$0.stop();
|
|
}
|
|
}, callee$0$0, this);
|
|
}));
|
|
var refreshAccessToken = _co2["default"].wrap(regeneratorRuntime.mark(function callee$0$0(credentials, options) {
|
|
var sandbox, xhr, data, now, response;
|
|
return regeneratorRuntime.wrap(function callee$0$0$(context$1$0) {
|
|
while (1)
|
|
switch (context$1$0.prev = context$1$0.next) {
|
|
case 0:
|
|
sandbox = options.sandbox;
|
|
xhr = new _xmlhttprequest2["default"]();
|
|
if (sandbox)
|
|
sandbox.add(xhr);
|
|
xhr.open("POST", credentials.tokenUrl, true);
|
|
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
|
|
data = _querystring2["default"].stringify({
|
|
client_id: credentials.clientId,
|
|
client_secret: credentials.clientSecret,
|
|
refresh_token: credentials.refreshToken,
|
|
grant_type: "refresh_token"
|
|
});
|
|
now = Date.now();
|
|
context$1$0.next = 9;
|
|
return xhr.send(data);
|
|
case 9:
|
|
response = JSON.parse(xhr.responseText);
|
|
credentials.accessToken = response.access_token;
|
|
credentials.expiration = "expires_in" in response ? now + response.expires_in : null;
|
|
return context$1$0.abrupt("return", response.access_token);
|
|
case 13:
|
|
case "end":
|
|
return context$1$0.stop();
|
|
}
|
|
}, callee$0$0, this);
|
|
}));
|
|
}, { "./xmlhttprequest": 23, "co": 24, "querystring": 28 }], 22: [function(require2, module4, exports3) {
|
|
"use strict";
|
|
Object.defineProperty(exports3, "__esModule", {
|
|
value: true
|
|
});
|
|
exports3.createObject = createObject;
|
|
exports3.updateObject = updateObject;
|
|
exports3.deleteObject = deleteObject;
|
|
exports3.syncCollection = syncCollection;
|
|
function _interopRequireWildcard(obj) {
|
|
if (obj && obj.__esModule) {
|
|
return obj;
|
|
} else {
|
|
var newObj = {};
|
|
if (obj != null) {
|
|
for (var key in obj) {
|
|
if (Object.prototype.hasOwnProperty.call(obj, key))
|
|
newObj[key] = obj[key];
|
|
}
|
|
}
|
|
newObj["default"] = obj;
|
|
return newObj;
|
|
}
|
|
}
|
|
function _interopRequireDefault(obj) {
|
|
return obj && obj.__esModule ? obj : { "default": obj };
|
|
}
|
|
var _co = require2("co");
|
|
var _co2 = _interopRequireDefault(_co);
|
|
var _fuzzy_url_equals = require2("./fuzzy_url_equals");
|
|
var _fuzzy_url_equals2 = _interopRequireDefault(_fuzzy_url_equals);
|
|
var _namespace = require2("./namespace");
|
|
var ns2 = _interopRequireWildcard(_namespace);
|
|
var _request = require2("./request");
|
|
var request3 = _interopRequireWildcard(_request);
|
|
var debug = require2("./debug")("dav:webdav");
|
|
function createObject(objectUrl, objectData, options) {
|
|
var req = request3.basic({ method: "PUT", data: objectData, contentType: options.contentType });
|
|
return options.xhr.send(req, objectUrl, { sandbox: options.sandbox });
|
|
}
|
|
function updateObject(objectUrl, objectData, etag, options) {
|
|
var req = request3.basic({ method: "PUT", data: objectData, etag, contentType: options.contentType });
|
|
return options.xhr.send(req, objectUrl, { sandbox: options.sandbox });
|
|
}
|
|
function deleteObject(objectUrl, etag, options) {
|
|
var req = request3.basic({ method: "DELETE", etag });
|
|
return options.xhr.send(req, objectUrl, { sandbox: options.sandbox });
|
|
}
|
|
function syncCollection(collection, options) {
|
|
var syncMethod = void 0;
|
|
if ("syncMethod" in options) {
|
|
syncMethod = options.syncMethod;
|
|
} else if (collection.reports && collection.reports.indexOf("syncCollection") !== -1) {
|
|
syncMethod = "webdav";
|
|
} else {
|
|
syncMethod = "basic";
|
|
}
|
|
if (syncMethod === "webdav") {
|
|
debug("rfc 6578 sync.");
|
|
return options.webdavSync(collection, options);
|
|
} else {
|
|
debug("basic sync.");
|
|
return options.basicSync(collection, options);
|
|
}
|
|
}
|
|
var supportedReportSet = _co2["default"].wrap(regeneratorRuntime.mark(function callee$0$0(collection, options) {
|
|
var req, response;
|
|
return regeneratorRuntime.wrap(function callee$0$0$(context$1$0) {
|
|
while (1)
|
|
switch (context$1$0.prev = context$1$0.next) {
|
|
case 0:
|
|
debug("Checking supported report set for collection at " + collection.url);
|
|
req = request3.propfind({
|
|
props: [{ name: "supported-report-set", namespace: ns2.DAV }],
|
|
depth: 1,
|
|
mergeResponses: true
|
|
});
|
|
context$1$0.next = 4;
|
|
return options.xhr.send(req, collection.url, {
|
|
sandbox: options.sandbox
|
|
});
|
|
case 4:
|
|
response = context$1$0.sent;
|
|
return context$1$0.abrupt("return", response.props.supportedReportSet);
|
|
case 6:
|
|
case "end":
|
|
return context$1$0.stop();
|
|
}
|
|
}, callee$0$0, this);
|
|
}));
|
|
exports3.supportedReportSet = supportedReportSet;
|
|
var isCollectionDirty = _co2["default"].wrap(regeneratorRuntime.mark(function callee$0$0(collection, options) {
|
|
var req, responses, response;
|
|
return regeneratorRuntime.wrap(function callee$0$0$(context$1$0) {
|
|
while (1)
|
|
switch (context$1$0.prev = context$1$0.next) {
|
|
case 0:
|
|
if (collection.ctag) {
|
|
context$1$0.next = 3;
|
|
break;
|
|
}
|
|
debug("Missing ctag.");
|
|
return context$1$0.abrupt("return", false);
|
|
case 3:
|
|
debug("Fetch remote getctag prop.");
|
|
req = request3.propfind({
|
|
props: [{ name: "getctag", namespace: ns2.CALENDAR_SERVER }],
|
|
depth: 0
|
|
});
|
|
context$1$0.next = 7;
|
|
return options.xhr.send(req, collection.account.homeUrl, {
|
|
sandbox: options.sandbox
|
|
});
|
|
case 7:
|
|
responses = context$1$0.sent;
|
|
response = responses.filter(function(response2) {
|
|
return (0, _fuzzy_url_equals2["default"])(collection.url, response2.href);
|
|
})[0];
|
|
if (response) {
|
|
context$1$0.next = 11;
|
|
break;
|
|
}
|
|
throw new Error("Could not find collection on remote. Was it deleted?");
|
|
case 11:
|
|
debug("Check whether cached ctag matches remote.");
|
|
return context$1$0.abrupt("return", collection.ctag !== response.props.getctag);
|
|
case 13:
|
|
case "end":
|
|
return context$1$0.stop();
|
|
}
|
|
}, callee$0$0, this);
|
|
}));
|
|
exports3.isCollectionDirty = isCollectionDirty;
|
|
}, { "./debug": 6, "./fuzzy_url_equals": 7, "./namespace": 10, "./request": 12, "co": 24 }], 23: [function(require2, module4, exports3) {
|
|
"use strict";
|
|
Object.defineProperty(exports3, "__esModule", {
|
|
value: true
|
|
});
|
|
var _createClass = function() {
|
|
function defineProperties(target, props) {
|
|
for (var i3 = 0; i3 < props.length; i3++) {
|
|
var descriptor = props[i3];
|
|
descriptor.enumerable = descriptor.enumerable || false;
|
|
descriptor.configurable = true;
|
|
if ("value" in descriptor)
|
|
descriptor.writable = true;
|
|
Object.defineProperty(target, descriptor.key, descriptor);
|
|
}
|
|
}
|
|
return function(Constructor, protoProps, staticProps) {
|
|
if (protoProps)
|
|
defineProperties(Constructor.prototype, protoProps);
|
|
if (staticProps)
|
|
defineProperties(Constructor, staticProps);
|
|
return Constructor;
|
|
};
|
|
}();
|
|
function _classCallCheck(instance, Constructor) {
|
|
if (!(instance instanceof Constructor)) {
|
|
throw new TypeError("Cannot call a class as a function");
|
|
}
|
|
}
|
|
var debug = require2("./debug")("dav:xmlhttprequest");
|
|
var Native = void 0;
|
|
if (typeof self !== "undefined" && "XMLHttpRequest" in self) {
|
|
Native = self.XMLHttpRequest;
|
|
} else {
|
|
Native = require2("xmlhttprequest").XMLHttpRequest;
|
|
}
|
|
var XMLHttpRequest2 = function() {
|
|
function XMLHttpRequest3(options) {
|
|
var _this = this;
|
|
_classCallCheck(this, XMLHttpRequest3);
|
|
this.request = new Native(options);
|
|
this.sandbox = null;
|
|
["response", "responseText", "responseType", "responseXML", "timeout", "upload", "withCredentials"].forEach(function(attribute) {
|
|
Object.defineProperty(_this, attribute, {
|
|
get: function get() {
|
|
return this.request[attribute];
|
|
},
|
|
set: function set(value) {
|
|
this.request[attribute] = value;
|
|
}
|
|
});
|
|
});
|
|
["status", "statusText"].forEach(function(attribute) {
|
|
Object.defineProperty(_this, attribute, {
|
|
get: function get() {
|
|
return this.request[attribute];
|
|
}
|
|
});
|
|
});
|
|
}
|
|
_createClass(XMLHttpRequest3, [{
|
|
key: "abort",
|
|
value: function abort() {
|
|
return this._callNative("abort", arguments);
|
|
}
|
|
}, {
|
|
key: "getAllResponseHeaders",
|
|
value: function getAllResponseHeaders() {
|
|
return this._callNative("getAllResponseHeaders", arguments);
|
|
}
|
|
}, {
|
|
key: "getResponseHeader",
|
|
value: function getResponseHeader() {
|
|
return this._callNative("getResponseHeader", arguments);
|
|
}
|
|
}, {
|
|
key: "open",
|
|
value: function open() {
|
|
return this._callNative("open", arguments);
|
|
}
|
|
}, {
|
|
key: "overrideMimeType",
|
|
value: function overrideMimeType() {
|
|
return this._callNative("overrideMimeType", arguments);
|
|
}
|
|
}, {
|
|
key: "setRequestHeader",
|
|
value: function setRequestHeader() {
|
|
return this._callNative("setRequestHeader", arguments);
|
|
}
|
|
}, {
|
|
key: "send",
|
|
value: function send(data) {
|
|
debug("Sending request data: " + data);
|
|
if (this.sandbox)
|
|
this.sandbox.add(this);
|
|
var request3 = this.request;
|
|
request3.send(data);
|
|
return new Promise(function(resolve, reject) {
|
|
request3.onreadystatechange = function() {
|
|
if (request3.readyState !== 4) {
|
|
return;
|
|
}
|
|
if (request3.status < 200 || request3.status >= 400) {
|
|
return reject(new Error("Bad status: " + request3.status));
|
|
}
|
|
return resolve(request3.responseText);
|
|
};
|
|
request3.ontimeout = function() {
|
|
reject(new Error("Request timed out after " + request3.timeout + " ms"));
|
|
};
|
|
});
|
|
}
|
|
}, {
|
|
key: "_callNative",
|
|
value: function _callNative(method, args) {
|
|
return this.request[method].apply(this.request, args);
|
|
}
|
|
}]);
|
|
return XMLHttpRequest3;
|
|
}();
|
|
exports3["default"] = XMLHttpRequest2;
|
|
module4.exports = exports3["default"];
|
|
}, { "./debug": 6 }], 24: [function(require2, module4, exports3) {
|
|
var slice = Array.prototype.slice;
|
|
module4.exports = co2["default"] = co2.co = co2;
|
|
co2.wrap = function(fn) {
|
|
createPromise.__generatorFunction__ = fn;
|
|
return createPromise;
|
|
function createPromise() {
|
|
return co2.call(this, fn.apply(this, arguments));
|
|
}
|
|
};
|
|
function co2(gen) {
|
|
var ctx = this;
|
|
var args = slice.call(arguments, 1);
|
|
return new Promise(function(resolve, reject) {
|
|
if (typeof gen === "function")
|
|
gen = gen.apply(ctx, args);
|
|
if (!gen || typeof gen.next !== "function")
|
|
return resolve(gen);
|
|
onFulfilled();
|
|
function onFulfilled(res) {
|
|
var ret;
|
|
try {
|
|
ret = gen.next(res);
|
|
} catch (e3) {
|
|
return reject(e3);
|
|
}
|
|
next(ret);
|
|
}
|
|
function onRejected(err) {
|
|
var ret;
|
|
try {
|
|
ret = gen.throw(err);
|
|
} catch (e3) {
|
|
return reject(e3);
|
|
}
|
|
next(ret);
|
|
}
|
|
function next(ret) {
|
|
if (ret.done)
|
|
return resolve(ret.value);
|
|
var value = toPromise.call(ctx, ret.value);
|
|
if (value && isPromise(value))
|
|
return value.then(onFulfilled, onRejected);
|
|
return onRejected(new TypeError('You may only yield a function, promise, generator, array, or object, but the following object was passed: "' + String(ret.value) + '"'));
|
|
}
|
|
});
|
|
}
|
|
function toPromise(obj) {
|
|
if (!obj)
|
|
return obj;
|
|
if (isPromise(obj))
|
|
return obj;
|
|
if (isGeneratorFunction(obj) || isGenerator(obj))
|
|
return co2.call(this, obj);
|
|
if (typeof obj == "function")
|
|
return thunkToPromise.call(this, obj);
|
|
if (Array.isArray(obj))
|
|
return arrayToPromise.call(this, obj);
|
|
if (isObject(obj))
|
|
return objectToPromise.call(this, obj);
|
|
return obj;
|
|
}
|
|
function thunkToPromise(fn) {
|
|
var ctx = this;
|
|
return new Promise(function(resolve, reject) {
|
|
fn.call(ctx, function(err, res) {
|
|
if (err)
|
|
return reject(err);
|
|
if (arguments.length > 2)
|
|
res = slice.call(arguments, 1);
|
|
resolve(res);
|
|
});
|
|
});
|
|
}
|
|
function arrayToPromise(obj) {
|
|
return Promise.all(obj.map(toPromise, this));
|
|
}
|
|
function objectToPromise(obj) {
|
|
var results = new obj.constructor();
|
|
var keys = Object.keys(obj);
|
|
var promises = [];
|
|
for (var i3 = 0; i3 < keys.length; i3++) {
|
|
var key = keys[i3];
|
|
var promise = toPromise.call(this, obj[key]);
|
|
if (promise && isPromise(promise))
|
|
defer(promise, key);
|
|
else
|
|
results[key] = obj[key];
|
|
}
|
|
return Promise.all(promises).then(function() {
|
|
return results;
|
|
});
|
|
function defer(promise2, key2) {
|
|
results[key2] = void 0;
|
|
promises.push(promise2.then(function(res) {
|
|
results[key2] = res;
|
|
}));
|
|
}
|
|
}
|
|
function isPromise(obj) {
|
|
return typeof obj.then == "function";
|
|
}
|
|
function isGenerator(obj) {
|
|
return typeof obj.next == "function" && typeof obj.throw == "function";
|
|
}
|
|
function isGeneratorFunction(obj) {
|
|
var constructor = obj.constructor;
|
|
if (!constructor)
|
|
return false;
|
|
if (constructor.name === "GeneratorFunction" || constructor.displayName === "GeneratorFunction")
|
|
return true;
|
|
return isGenerator(constructor.prototype);
|
|
}
|
|
function isObject(val) {
|
|
return Object == val.constructor;
|
|
}
|
|
}, {}], 25: [function(require2, module4, exports3) {
|
|
(function(global2) {
|
|
;
|
|
(function(root) {
|
|
var freeExports = typeof exports3 == "object" && exports3 && !exports3.nodeType && exports3;
|
|
var freeModule = typeof module4 == "object" && module4 && !module4.nodeType && module4;
|
|
var freeGlobal = typeof global2 == "object" && global2;
|
|
if (freeGlobal.global === freeGlobal || freeGlobal.window === freeGlobal || freeGlobal.self === freeGlobal) {
|
|
root = freeGlobal;
|
|
}
|
|
var punycode, maxInt = 2147483647, base = 36, tMin = 1, tMax = 26, skew = 38, damp = 700, initialBias = 72, initialN = 128, delimiter = "-", regexPunycode = /^xn--/, regexNonASCII = /[^\x20-\x7E]/, regexSeparators = /[\x2E\u3002\uFF0E\uFF61]/g, errors = {
|
|
"overflow": "Overflow: input needs wider integers to process",
|
|
"not-basic": "Illegal input >= 0x80 (not a basic code point)",
|
|
"invalid-input": "Invalid input"
|
|
}, baseMinusTMin = base - tMin, floor = Math.floor, stringFromCharCode = String.fromCharCode, key;
|
|
function error(type) {
|
|
throw new RangeError(errors[type]);
|
|
}
|
|
function map(array, fn) {
|
|
var length = array.length;
|
|
var result = [];
|
|
while (length--) {
|
|
result[length] = fn(array[length]);
|
|
}
|
|
return result;
|
|
}
|
|
function mapDomain(string, fn) {
|
|
var parts = string.split("@");
|
|
var result = "";
|
|
if (parts.length > 1) {
|
|
result = parts[0] + "@";
|
|
string = parts[1];
|
|
}
|
|
string = string.replace(regexSeparators, ".");
|
|
var labels = string.split(".");
|
|
var encoded = map(labels, fn).join(".");
|
|
return result + encoded;
|
|
}
|
|
function ucs2decode(string) {
|
|
var output = [], counter = 0, length = string.length, value, extra;
|
|
while (counter < length) {
|
|
value = string.charCodeAt(counter++);
|
|
if (value >= 55296 && value <= 56319 && counter < length) {
|
|
extra = string.charCodeAt(counter++);
|
|
if ((extra & 64512) == 56320) {
|
|
output.push(((value & 1023) << 10) + (extra & 1023) + 65536);
|
|
} else {
|
|
output.push(value);
|
|
counter--;
|
|
}
|
|
} else {
|
|
output.push(value);
|
|
}
|
|
}
|
|
return output;
|
|
}
|
|
function ucs2encode(array) {
|
|
return map(array, function(value) {
|
|
var output = "";
|
|
if (value > 65535) {
|
|
value -= 65536;
|
|
output += stringFromCharCode(value >>> 10 & 1023 | 55296);
|
|
value = 56320 | value & 1023;
|
|
}
|
|
output += stringFromCharCode(value);
|
|
return output;
|
|
}).join("");
|
|
}
|
|
function basicToDigit(codePoint) {
|
|
if (codePoint - 48 < 10) {
|
|
return codePoint - 22;
|
|
}
|
|
if (codePoint - 65 < 26) {
|
|
return codePoint - 65;
|
|
}
|
|
if (codePoint - 97 < 26) {
|
|
return codePoint - 97;
|
|
}
|
|
return base;
|
|
}
|
|
function digitToBasic(digit, flag) {
|
|
return digit + 22 + 75 * (digit < 26) - ((flag != 0) << 5);
|
|
}
|
|
function adapt(delta, numPoints, firstTime) {
|
|
var k2 = 0;
|
|
delta = firstTime ? floor(delta / damp) : delta >> 1;
|
|
delta += floor(delta / numPoints);
|
|
for (; delta > baseMinusTMin * tMax >> 1; k2 += base) {
|
|
delta = floor(delta / baseMinusTMin);
|
|
}
|
|
return floor(k2 + (baseMinusTMin + 1) * delta / (delta + skew));
|
|
}
|
|
function decode(input) {
|
|
var output = [], inputLength = input.length, out, i3 = 0, n2 = initialN, bias = initialBias, basic, j4, index, oldi, w3, k2, digit, t3, baseMinusT;
|
|
basic = input.lastIndexOf(delimiter);
|
|
if (basic < 0) {
|
|
basic = 0;
|
|
}
|
|
for (j4 = 0; j4 < basic; ++j4) {
|
|
if (input.charCodeAt(j4) >= 128) {
|
|
error("not-basic");
|
|
}
|
|
output.push(input.charCodeAt(j4));
|
|
}
|
|
for (index = basic > 0 ? basic + 1 : 0; index < inputLength; ) {
|
|
for (oldi = i3, w3 = 1, k2 = base; ; k2 += base) {
|
|
if (index >= inputLength) {
|
|
error("invalid-input");
|
|
}
|
|
digit = basicToDigit(input.charCodeAt(index++));
|
|
if (digit >= base || digit > floor((maxInt - i3) / w3)) {
|
|
error("overflow");
|
|
}
|
|
i3 += digit * w3;
|
|
t3 = k2 <= bias ? tMin : k2 >= bias + tMax ? tMax : k2 - bias;
|
|
if (digit < t3) {
|
|
break;
|
|
}
|
|
baseMinusT = base - t3;
|
|
if (w3 > floor(maxInt / baseMinusT)) {
|
|
error("overflow");
|
|
}
|
|
w3 *= baseMinusT;
|
|
}
|
|
out = output.length + 1;
|
|
bias = adapt(i3 - oldi, out, oldi == 0);
|
|
if (floor(i3 / out) > maxInt - n2) {
|
|
error("overflow");
|
|
}
|
|
n2 += floor(i3 / out);
|
|
i3 %= out;
|
|
output.splice(i3++, 0, n2);
|
|
}
|
|
return ucs2encode(output);
|
|
}
|
|
function encode(input) {
|
|
var n2, delta, handledCPCount, basicLength, bias, j4, m2, q3, k2, t3, currentValue, output = [], inputLength, handledCPCountPlusOne, baseMinusT, qMinusT;
|
|
input = ucs2decode(input);
|
|
inputLength = input.length;
|
|
n2 = initialN;
|
|
delta = 0;
|
|
bias = initialBias;
|
|
for (j4 = 0; j4 < inputLength; ++j4) {
|
|
currentValue = input[j4];
|
|
if (currentValue < 128) {
|
|
output.push(stringFromCharCode(currentValue));
|
|
}
|
|
}
|
|
handledCPCount = basicLength = output.length;
|
|
if (basicLength) {
|
|
output.push(delimiter);
|
|
}
|
|
while (handledCPCount < inputLength) {
|
|
for (m2 = maxInt, j4 = 0; j4 < inputLength; ++j4) {
|
|
currentValue = input[j4];
|
|
if (currentValue >= n2 && currentValue < m2) {
|
|
m2 = currentValue;
|
|
}
|
|
}
|
|
handledCPCountPlusOne = handledCPCount + 1;
|
|
if (m2 - n2 > floor((maxInt - delta) / handledCPCountPlusOne)) {
|
|
error("overflow");
|
|
}
|
|
delta += (m2 - n2) * handledCPCountPlusOne;
|
|
n2 = m2;
|
|
for (j4 = 0; j4 < inputLength; ++j4) {
|
|
currentValue = input[j4];
|
|
if (currentValue < n2 && ++delta > maxInt) {
|
|
error("overflow");
|
|
}
|
|
if (currentValue == n2) {
|
|
for (q3 = delta, k2 = base; ; k2 += base) {
|
|
t3 = k2 <= bias ? tMin : k2 >= bias + tMax ? tMax : k2 - bias;
|
|
if (q3 < t3) {
|
|
break;
|
|
}
|
|
qMinusT = q3 - t3;
|
|
baseMinusT = base - t3;
|
|
output.push(stringFromCharCode(digitToBasic(t3 + qMinusT % baseMinusT, 0)));
|
|
q3 = floor(qMinusT / baseMinusT);
|
|
}
|
|
output.push(stringFromCharCode(digitToBasic(q3, 0)));
|
|
bias = adapt(delta, handledCPCountPlusOne, handledCPCount == basicLength);
|
|
delta = 0;
|
|
++handledCPCount;
|
|
}
|
|
}
|
|
++delta;
|
|
++n2;
|
|
}
|
|
return output.join("");
|
|
}
|
|
function toUnicode(input) {
|
|
return mapDomain(input, function(string) {
|
|
return regexPunycode.test(string) ? decode(string.slice(4).toLowerCase()) : string;
|
|
});
|
|
}
|
|
function toASCII(input) {
|
|
return mapDomain(input, function(string) {
|
|
return regexNonASCII.test(string) ? "xn--" + encode(string) : string;
|
|
});
|
|
}
|
|
punycode = {
|
|
"version": "1.4.1",
|
|
"ucs2": {
|
|
"decode": ucs2decode,
|
|
"encode": ucs2encode
|
|
},
|
|
"decode": decode,
|
|
"encode": encode,
|
|
"toASCII": toASCII,
|
|
"toUnicode": toUnicode
|
|
};
|
|
if (typeof define2 == "function" && typeof define2.amd == "object" && define2.amd) {
|
|
define2("punycode", function() {
|
|
return punycode;
|
|
});
|
|
} else if (freeExports && freeModule) {
|
|
if (module4.exports == freeExports) {
|
|
freeModule.exports = punycode;
|
|
} else {
|
|
for (key in punycode) {
|
|
punycode.hasOwnProperty(key) && (freeExports[key] = punycode[key]);
|
|
}
|
|
}
|
|
} else {
|
|
root.punycode = punycode;
|
|
}
|
|
})(this);
|
|
}).call(this, typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {});
|
|
}, {}], 26: [function(require2, module4, exports3) {
|
|
"use strict";
|
|
function hasOwnProperty2(obj, prop) {
|
|
return Object.prototype.hasOwnProperty.call(obj, prop);
|
|
}
|
|
module4.exports = function(qs, sep, eq, options) {
|
|
sep = sep || "&";
|
|
eq = eq || "=";
|
|
var obj = {};
|
|
if (typeof qs !== "string" || qs.length === 0) {
|
|
return obj;
|
|
}
|
|
var regexp = /\+/g;
|
|
qs = qs.split(sep);
|
|
var maxKeys = 1e3;
|
|
if (options && typeof options.maxKeys === "number") {
|
|
maxKeys = options.maxKeys;
|
|
}
|
|
var len = qs.length;
|
|
if (maxKeys > 0 && len > maxKeys) {
|
|
len = maxKeys;
|
|
}
|
|
for (var i3 = 0; i3 < len; ++i3) {
|
|
var x3 = qs[i3].replace(regexp, "%20"), idx = x3.indexOf(eq), kstr, vstr, k2, v3;
|
|
if (idx >= 0) {
|
|
kstr = x3.substr(0, idx);
|
|
vstr = x3.substr(idx + 1);
|
|
} else {
|
|
kstr = x3;
|
|
vstr = "";
|
|
}
|
|
k2 = decodeURIComponent(kstr);
|
|
v3 = decodeURIComponent(vstr);
|
|
if (!hasOwnProperty2(obj, k2)) {
|
|
obj[k2] = v3;
|
|
} else if (isArray(obj[k2])) {
|
|
obj[k2].push(v3);
|
|
} else {
|
|
obj[k2] = [obj[k2], v3];
|
|
}
|
|
}
|
|
return obj;
|
|
};
|
|
var isArray = Array.isArray || function(xs) {
|
|
return Object.prototype.toString.call(xs) === "[object Array]";
|
|
};
|
|
}, {}], 27: [function(require2, module4, exports3) {
|
|
"use strict";
|
|
var stringifyPrimitive = function(v3) {
|
|
switch (typeof v3) {
|
|
case "string":
|
|
return v3;
|
|
case "boolean":
|
|
return v3 ? "true" : "false";
|
|
case "number":
|
|
return isFinite(v3) ? v3 : "";
|
|
default:
|
|
return "";
|
|
}
|
|
};
|
|
module4.exports = function(obj, sep, eq, name) {
|
|
sep = sep || "&";
|
|
eq = eq || "=";
|
|
if (obj === null) {
|
|
obj = void 0;
|
|
}
|
|
if (typeof obj === "object") {
|
|
return map(objectKeys(obj), function(k2) {
|
|
var ks = encodeURIComponent(stringifyPrimitive(k2)) + eq;
|
|
if (isArray(obj[k2])) {
|
|
return map(obj[k2], function(v3) {
|
|
return ks + encodeURIComponent(stringifyPrimitive(v3));
|
|
}).join(sep);
|
|
} else {
|
|
return ks + encodeURIComponent(stringifyPrimitive(obj[k2]));
|
|
}
|
|
}).join(sep);
|
|
}
|
|
if (!name)
|
|
return "";
|
|
return encodeURIComponent(stringifyPrimitive(name)) + eq + encodeURIComponent(stringifyPrimitive(obj));
|
|
};
|
|
var isArray = Array.isArray || function(xs) {
|
|
return Object.prototype.toString.call(xs) === "[object Array]";
|
|
};
|
|
function map(xs, f3) {
|
|
if (xs.map)
|
|
return xs.map(f3);
|
|
var res = [];
|
|
for (var i3 = 0; i3 < xs.length; i3++) {
|
|
res.push(f3(xs[i3], i3));
|
|
}
|
|
return res;
|
|
}
|
|
var objectKeys = Object.keys || function(obj) {
|
|
var res = [];
|
|
for (var key in obj) {
|
|
if (Object.prototype.hasOwnProperty.call(obj, key))
|
|
res.push(key);
|
|
}
|
|
return res;
|
|
};
|
|
}, {}], 28: [function(require2, module4, exports3) {
|
|
"use strict";
|
|
exports3.decode = exports3.parse = require2("./decode");
|
|
exports3.encode = exports3.stringify = require2("./encode");
|
|
}, { "./decode": 26, "./encode": 27 }], 29: [function(require2, module4, exports3) {
|
|
var punycode = require2("punycode");
|
|
exports3.parse = urlParse;
|
|
exports3.resolve = urlResolve;
|
|
exports3.resolveObject = urlResolveObject;
|
|
exports3.format = urlFormat;
|
|
exports3.Url = Url;
|
|
function Url() {
|
|
this.protocol = null;
|
|
this.slashes = null;
|
|
this.auth = null;
|
|
this.host = null;
|
|
this.port = null;
|
|
this.hostname = null;
|
|
this.hash = null;
|
|
this.search = null;
|
|
this.query = null;
|
|
this.pathname = null;
|
|
this.path = null;
|
|
this.href = null;
|
|
}
|
|
var protocolPattern = /^([a-z0-9.+-]+:)/i, portPattern = /:[0-9]*$/, delims = ["<", ">", '"', "`", " ", "\r", "\n", " "], unwise = ["{", "}", "|", "\\", "^", "`"].concat(delims), autoEscape = ["'"].concat(unwise), nonHostChars = ["%", "/", "?", ";", "#"].concat(autoEscape), hostEndingChars = ["/", "?", "#"], hostnameMaxLen = 255, hostnamePartPattern = /^[a-z0-9A-Z_-]{0,63}$/, hostnamePartStart = /^([a-z0-9A-Z_-]{0,63})(.*)$/, unsafeProtocol = {
|
|
"javascript": true,
|
|
"javascript:": true
|
|
}, hostlessProtocol = {
|
|
"javascript": true,
|
|
"javascript:": true
|
|
}, slashedProtocol = {
|
|
"http": true,
|
|
"https": true,
|
|
"ftp": true,
|
|
"gopher": true,
|
|
"file": true,
|
|
"http:": true,
|
|
"https:": true,
|
|
"ftp:": true,
|
|
"gopher:": true,
|
|
"file:": true
|
|
}, querystring = require2("querystring");
|
|
function urlParse(url, parseQueryString, slashesDenoteHost) {
|
|
if (url && isObject(url) && url instanceof Url)
|
|
return url;
|
|
var u3 = new Url();
|
|
u3.parse(url, parseQueryString, slashesDenoteHost);
|
|
return u3;
|
|
}
|
|
Url.prototype.parse = function(url, parseQueryString, slashesDenoteHost) {
|
|
if (!isString(url)) {
|
|
throw new TypeError("Parameter 'url' must be a string, not " + typeof url);
|
|
}
|
|
var rest = url;
|
|
rest = rest.trim();
|
|
var proto = protocolPattern.exec(rest);
|
|
if (proto) {
|
|
proto = proto[0];
|
|
var lowerProto = proto.toLowerCase();
|
|
this.protocol = lowerProto;
|
|
rest = rest.substr(proto.length);
|
|
}
|
|
if (slashesDenoteHost || proto || rest.match(/^\/\/[^@\/]+@[^@\/]+/)) {
|
|
var slashes = rest.substr(0, 2) === "//";
|
|
if (slashes && !(proto && hostlessProtocol[proto])) {
|
|
rest = rest.substr(2);
|
|
this.slashes = true;
|
|
}
|
|
}
|
|
if (!hostlessProtocol[proto] && (slashes || proto && !slashedProtocol[proto])) {
|
|
var hostEnd = -1;
|
|
for (var i3 = 0; i3 < hostEndingChars.length; i3++) {
|
|
var hec = rest.indexOf(hostEndingChars[i3]);
|
|
if (hec !== -1 && (hostEnd === -1 || hec < hostEnd))
|
|
hostEnd = hec;
|
|
}
|
|
var auth, atSign;
|
|
if (hostEnd === -1) {
|
|
atSign = rest.lastIndexOf("@");
|
|
} else {
|
|
atSign = rest.lastIndexOf("@", hostEnd);
|
|
}
|
|
if (atSign !== -1) {
|
|
auth = rest.slice(0, atSign);
|
|
rest = rest.slice(atSign + 1);
|
|
this.auth = decodeURIComponent(auth);
|
|
}
|
|
hostEnd = -1;
|
|
for (var i3 = 0; i3 < nonHostChars.length; i3++) {
|
|
var hec = rest.indexOf(nonHostChars[i3]);
|
|
if (hec !== -1 && (hostEnd === -1 || hec < hostEnd))
|
|
hostEnd = hec;
|
|
}
|
|
if (hostEnd === -1)
|
|
hostEnd = rest.length;
|
|
this.host = rest.slice(0, hostEnd);
|
|
rest = rest.slice(hostEnd);
|
|
this.parseHost();
|
|
this.hostname = this.hostname || "";
|
|
var ipv6Hostname = this.hostname[0] === "[" && this.hostname[this.hostname.length - 1] === "]";
|
|
if (!ipv6Hostname) {
|
|
var hostparts = this.hostname.split(/\./);
|
|
for (var i3 = 0, l3 = hostparts.length; i3 < l3; i3++) {
|
|
var part = hostparts[i3];
|
|
if (!part)
|
|
continue;
|
|
if (!part.match(hostnamePartPattern)) {
|
|
var newpart = "";
|
|
for (var j4 = 0, k2 = part.length; j4 < k2; j4++) {
|
|
if (part.charCodeAt(j4) > 127) {
|
|
newpart += "x";
|
|
} else {
|
|
newpart += part[j4];
|
|
}
|
|
}
|
|
if (!newpart.match(hostnamePartPattern)) {
|
|
var validParts = hostparts.slice(0, i3);
|
|
var notHost = hostparts.slice(i3 + 1);
|
|
var bit = part.match(hostnamePartStart);
|
|
if (bit) {
|
|
validParts.push(bit[1]);
|
|
notHost.unshift(bit[2]);
|
|
}
|
|
if (notHost.length) {
|
|
rest = "/" + notHost.join(".") + rest;
|
|
}
|
|
this.hostname = validParts.join(".");
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (this.hostname.length > hostnameMaxLen) {
|
|
this.hostname = "";
|
|
} else {
|
|
this.hostname = this.hostname.toLowerCase();
|
|
}
|
|
if (!ipv6Hostname) {
|
|
var domainArray = this.hostname.split(".");
|
|
var newOut = [];
|
|
for (var i3 = 0; i3 < domainArray.length; ++i3) {
|
|
var s3 = domainArray[i3];
|
|
newOut.push(s3.match(/[^A-Za-z0-9_-]/) ? "xn--" + punycode.encode(s3) : s3);
|
|
}
|
|
this.hostname = newOut.join(".");
|
|
}
|
|
var p3 = this.port ? ":" + this.port : "";
|
|
var h3 = this.hostname || "";
|
|
this.host = h3 + p3;
|
|
this.href += this.host;
|
|
if (ipv6Hostname) {
|
|
this.hostname = this.hostname.substr(1, this.hostname.length - 2);
|
|
if (rest[0] !== "/") {
|
|
rest = "/" + rest;
|
|
}
|
|
}
|
|
}
|
|
if (!unsafeProtocol[lowerProto]) {
|
|
for (var i3 = 0, l3 = autoEscape.length; i3 < l3; i3++) {
|
|
var ae = autoEscape[i3];
|
|
var esc = encodeURIComponent(ae);
|
|
if (esc === ae) {
|
|
esc = escape(ae);
|
|
}
|
|
rest = rest.split(ae).join(esc);
|
|
}
|
|
}
|
|
var hash = rest.indexOf("#");
|
|
if (hash !== -1) {
|
|
this.hash = rest.substr(hash);
|
|
rest = rest.slice(0, hash);
|
|
}
|
|
var qm = rest.indexOf("?");
|
|
if (qm !== -1) {
|
|
this.search = rest.substr(qm);
|
|
this.query = rest.substr(qm + 1);
|
|
if (parseQueryString) {
|
|
this.query = querystring.parse(this.query);
|
|
}
|
|
rest = rest.slice(0, qm);
|
|
} else if (parseQueryString) {
|
|
this.search = "";
|
|
this.query = {};
|
|
}
|
|
if (rest)
|
|
this.pathname = rest;
|
|
if (slashedProtocol[lowerProto] && this.hostname && !this.pathname) {
|
|
this.pathname = "/";
|
|
}
|
|
if (this.pathname || this.search) {
|
|
var p3 = this.pathname || "";
|
|
var s3 = this.search || "";
|
|
this.path = p3 + s3;
|
|
}
|
|
this.href = this.format();
|
|
return this;
|
|
};
|
|
function urlFormat(obj) {
|
|
if (isString(obj))
|
|
obj = urlParse(obj);
|
|
if (!(obj instanceof Url))
|
|
return Url.prototype.format.call(obj);
|
|
return obj.format();
|
|
}
|
|
Url.prototype.format = function() {
|
|
var auth = this.auth || "";
|
|
if (auth) {
|
|
auth = encodeURIComponent(auth);
|
|
auth = auth.replace(/%3A/i, ":");
|
|
auth += "@";
|
|
}
|
|
var protocol = this.protocol || "", pathname = this.pathname || "", hash = this.hash || "", host = false, query = "";
|
|
if (this.host) {
|
|
host = auth + this.host;
|
|
} else if (this.hostname) {
|
|
host = auth + (this.hostname.indexOf(":") === -1 ? this.hostname : "[" + this.hostname + "]");
|
|
if (this.port) {
|
|
host += ":" + this.port;
|
|
}
|
|
}
|
|
if (this.query && isObject(this.query) && Object.keys(this.query).length) {
|
|
query = querystring.stringify(this.query);
|
|
}
|
|
var search = this.search || query && "?" + query || "";
|
|
if (protocol && protocol.substr(-1) !== ":")
|
|
protocol += ":";
|
|
if (this.slashes || (!protocol || slashedProtocol[protocol]) && host !== false) {
|
|
host = "//" + (host || "");
|
|
if (pathname && pathname.charAt(0) !== "/")
|
|
pathname = "/" + pathname;
|
|
} else if (!host) {
|
|
host = "";
|
|
}
|
|
if (hash && hash.charAt(0) !== "#")
|
|
hash = "#" + hash;
|
|
if (search && search.charAt(0) !== "?")
|
|
search = "?" + search;
|
|
pathname = pathname.replace(/[?#]/g, function(match) {
|
|
return encodeURIComponent(match);
|
|
});
|
|
search = search.replace("#", "%23");
|
|
return protocol + host + pathname + search + hash;
|
|
};
|
|
function urlResolve(source, relative) {
|
|
return urlParse(source, false, true).resolve(relative);
|
|
}
|
|
Url.prototype.resolve = function(relative) {
|
|
return this.resolveObject(urlParse(relative, false, true)).format();
|
|
};
|
|
function urlResolveObject(source, relative) {
|
|
if (!source)
|
|
return relative;
|
|
return urlParse(source, false, true).resolveObject(relative);
|
|
}
|
|
Url.prototype.resolveObject = function(relative) {
|
|
if (isString(relative)) {
|
|
var rel = new Url();
|
|
rel.parse(relative, false, true);
|
|
relative = rel;
|
|
}
|
|
var result = new Url();
|
|
Object.keys(this).forEach(function(k2) {
|
|
result[k2] = this[k2];
|
|
}, this);
|
|
result.hash = relative.hash;
|
|
if (relative.href === "") {
|
|
result.href = result.format();
|
|
return result;
|
|
}
|
|
if (relative.slashes && !relative.protocol) {
|
|
Object.keys(relative).forEach(function(k2) {
|
|
if (k2 !== "protocol")
|
|
result[k2] = relative[k2];
|
|
});
|
|
if (slashedProtocol[result.protocol] && result.hostname && !result.pathname) {
|
|
result.path = result.pathname = "/";
|
|
}
|
|
result.href = result.format();
|
|
return result;
|
|
}
|
|
if (relative.protocol && relative.protocol !== result.protocol) {
|
|
if (!slashedProtocol[relative.protocol]) {
|
|
Object.keys(relative).forEach(function(k2) {
|
|
result[k2] = relative[k2];
|
|
});
|
|
result.href = result.format();
|
|
return result;
|
|
}
|
|
result.protocol = relative.protocol;
|
|
if (!relative.host && !hostlessProtocol[relative.protocol]) {
|
|
var relPath = (relative.pathname || "").split("/");
|
|
while (relPath.length && !(relative.host = relPath.shift()))
|
|
;
|
|
if (!relative.host)
|
|
relative.host = "";
|
|
if (!relative.hostname)
|
|
relative.hostname = "";
|
|
if (relPath[0] !== "")
|
|
relPath.unshift("");
|
|
if (relPath.length < 2)
|
|
relPath.unshift("");
|
|
result.pathname = relPath.join("/");
|
|
} else {
|
|
result.pathname = relative.pathname;
|
|
}
|
|
result.search = relative.search;
|
|
result.query = relative.query;
|
|
result.host = relative.host || "";
|
|
result.auth = relative.auth;
|
|
result.hostname = relative.hostname || relative.host;
|
|
result.port = relative.port;
|
|
if (result.pathname || result.search) {
|
|
var p3 = result.pathname || "";
|
|
var s3 = result.search || "";
|
|
result.path = p3 + s3;
|
|
}
|
|
result.slashes = result.slashes || relative.slashes;
|
|
result.href = result.format();
|
|
return result;
|
|
}
|
|
var isSourceAbs = result.pathname && result.pathname.charAt(0) === "/", isRelAbs = relative.host || relative.pathname && relative.pathname.charAt(0) === "/", mustEndAbs = isRelAbs || isSourceAbs || result.host && relative.pathname, removeAllDots = mustEndAbs, srcPath = result.pathname && result.pathname.split("/") || [], relPath = relative.pathname && relative.pathname.split("/") || [], psychotic = result.protocol && !slashedProtocol[result.protocol];
|
|
if (psychotic) {
|
|
result.hostname = "";
|
|
result.port = null;
|
|
if (result.host) {
|
|
if (srcPath[0] === "")
|
|
srcPath[0] = result.host;
|
|
else
|
|
srcPath.unshift(result.host);
|
|
}
|
|
result.host = "";
|
|
if (relative.protocol) {
|
|
relative.hostname = null;
|
|
relative.port = null;
|
|
if (relative.host) {
|
|
if (relPath[0] === "")
|
|
relPath[0] = relative.host;
|
|
else
|
|
relPath.unshift(relative.host);
|
|
}
|
|
relative.host = null;
|
|
}
|
|
mustEndAbs = mustEndAbs && (relPath[0] === "" || srcPath[0] === "");
|
|
}
|
|
if (isRelAbs) {
|
|
result.host = relative.host || relative.host === "" ? relative.host : result.host;
|
|
result.hostname = relative.hostname || relative.hostname === "" ? relative.hostname : result.hostname;
|
|
result.search = relative.search;
|
|
result.query = relative.query;
|
|
srcPath = relPath;
|
|
} else if (relPath.length) {
|
|
if (!srcPath)
|
|
srcPath = [];
|
|
srcPath.pop();
|
|
srcPath = srcPath.concat(relPath);
|
|
result.search = relative.search;
|
|
result.query = relative.query;
|
|
} else if (!isNullOrUndefined(relative.search)) {
|
|
if (psychotic) {
|
|
result.hostname = result.host = srcPath.shift();
|
|
var authInHost = result.host && result.host.indexOf("@") > 0 ? result.host.split("@") : false;
|
|
if (authInHost) {
|
|
result.auth = authInHost.shift();
|
|
result.host = result.hostname = authInHost.shift();
|
|
}
|
|
}
|
|
result.search = relative.search;
|
|
result.query = relative.query;
|
|
if (!isNull(result.pathname) || !isNull(result.search)) {
|
|
result.path = (result.pathname ? result.pathname : "") + (result.search ? result.search : "");
|
|
}
|
|
result.href = result.format();
|
|
return result;
|
|
}
|
|
if (!srcPath.length) {
|
|
result.pathname = null;
|
|
if (result.search) {
|
|
result.path = "/" + result.search;
|
|
} else {
|
|
result.path = null;
|
|
}
|
|
result.href = result.format();
|
|
return result;
|
|
}
|
|
var last = srcPath.slice(-1)[0];
|
|
var hasTrailingSlash = (result.host || relative.host) && (last === "." || last === "..") || last === "";
|
|
var up = 0;
|
|
for (var i3 = srcPath.length; i3 >= 0; i3--) {
|
|
last = srcPath[i3];
|
|
if (last == ".") {
|
|
srcPath.splice(i3, 1);
|
|
} else if (last === "..") {
|
|
srcPath.splice(i3, 1);
|
|
up++;
|
|
} else if (up) {
|
|
srcPath.splice(i3, 1);
|
|
up--;
|
|
}
|
|
}
|
|
if (!mustEndAbs && !removeAllDots) {
|
|
for (; up--; up) {
|
|
srcPath.unshift("..");
|
|
}
|
|
}
|
|
if (mustEndAbs && srcPath[0] !== "" && (!srcPath[0] || srcPath[0].charAt(0) !== "/")) {
|
|
srcPath.unshift("");
|
|
}
|
|
if (hasTrailingSlash && srcPath.join("/").substr(-1) !== "/") {
|
|
srcPath.push("");
|
|
}
|
|
var isAbsolute = srcPath[0] === "" || srcPath[0] && srcPath[0].charAt(0) === "/";
|
|
if (psychotic) {
|
|
result.hostname = result.host = isAbsolute ? "" : srcPath.length ? srcPath.shift() : "";
|
|
var authInHost = result.host && result.host.indexOf("@") > 0 ? result.host.split("@") : false;
|
|
if (authInHost) {
|
|
result.auth = authInHost.shift();
|
|
result.host = result.hostname = authInHost.shift();
|
|
}
|
|
}
|
|
mustEndAbs = mustEndAbs || result.host && srcPath.length;
|
|
if (mustEndAbs && !isAbsolute) {
|
|
srcPath.unshift("");
|
|
}
|
|
if (!srcPath.length) {
|
|
result.pathname = null;
|
|
result.path = null;
|
|
} else {
|
|
result.pathname = srcPath.join("/");
|
|
}
|
|
if (!isNull(result.pathname) || !isNull(result.search)) {
|
|
result.path = (result.pathname ? result.pathname : "") + (result.search ? result.search : "");
|
|
}
|
|
result.auth = relative.auth || result.auth;
|
|
result.slashes = result.slashes || relative.slashes;
|
|
result.href = result.format();
|
|
return result;
|
|
};
|
|
Url.prototype.parseHost = function() {
|
|
var host = this.host;
|
|
var port = portPattern.exec(host);
|
|
if (port) {
|
|
port = port[0];
|
|
if (port !== ":") {
|
|
this.port = port.substr(1);
|
|
}
|
|
host = host.substr(0, host.length - port.length);
|
|
}
|
|
if (host)
|
|
this.hostname = host;
|
|
};
|
|
function isString(arg) {
|
|
return typeof arg === "string";
|
|
}
|
|
function isObject(arg) {
|
|
return typeof arg === "object" && arg !== null;
|
|
}
|
|
function isNull(arg) {
|
|
return arg === null;
|
|
}
|
|
function isNullOrUndefined(arg) {
|
|
return arg == null;
|
|
}
|
|
}, { "punycode": 25, "querystring": 28 }], 30: [function(require2, module4, exports3) {
|
|
function DOMParser(options) {
|
|
this.options = options || { locator: {} };
|
|
}
|
|
DOMParser.prototype.parseFromString = function(source, mimeType) {
|
|
var options = this.options;
|
|
var sax = new XMLReader();
|
|
var domBuilder = options.domBuilder || new DOMHandler();
|
|
var errorHandler = options.errorHandler;
|
|
var locator = options.locator;
|
|
var defaultNSMap = options.xmlns || {};
|
|
var entityMap = { "lt": "<", "gt": ">", "amp": "&", "quot": '"', "apos": "'" };
|
|
if (locator) {
|
|
domBuilder.setDocumentLocator(locator);
|
|
}
|
|
sax.errorHandler = buildErrorHandler(errorHandler, domBuilder, locator);
|
|
sax.domBuilder = options.domBuilder || domBuilder;
|
|
if (/\/x?html?$/.test(mimeType)) {
|
|
entityMap.nbsp = "\xA0";
|
|
entityMap.copy = "\xA9";
|
|
defaultNSMap[""] = "http://www.w3.org/1999/xhtml";
|
|
}
|
|
defaultNSMap.xml = defaultNSMap.xml || "http://www.w3.org/XML/1998/namespace";
|
|
if (source) {
|
|
sax.parse(source, defaultNSMap, entityMap);
|
|
} else {
|
|
sax.errorHandler.error("invalid doc source");
|
|
}
|
|
return domBuilder.doc;
|
|
};
|
|
function buildErrorHandler(errorImpl, domBuilder, locator) {
|
|
if (!errorImpl) {
|
|
if (domBuilder instanceof DOMHandler) {
|
|
return domBuilder;
|
|
}
|
|
errorImpl = domBuilder;
|
|
}
|
|
var errorHandler = {};
|
|
var isCallback = errorImpl instanceof Function;
|
|
locator = locator || {};
|
|
function build(key) {
|
|
var fn = errorImpl[key];
|
|
if (!fn && isCallback) {
|
|
fn = errorImpl.length == 2 ? function(msg) {
|
|
errorImpl(key, msg);
|
|
} : errorImpl;
|
|
}
|
|
errorHandler[key] = fn && function(msg) {
|
|
fn("[xmldom " + key + "] " + msg + _locator(locator));
|
|
} || function() {
|
|
};
|
|
}
|
|
build("warning");
|
|
build("error");
|
|
build("fatalError");
|
|
return errorHandler;
|
|
}
|
|
function DOMHandler() {
|
|
this.cdata = false;
|
|
}
|
|
function position(locator, node) {
|
|
node.lineNumber = locator.lineNumber;
|
|
node.columnNumber = locator.columnNumber;
|
|
}
|
|
DOMHandler.prototype = {
|
|
startDocument: function() {
|
|
this.doc = new DOMImplementation().createDocument(null, null, null);
|
|
if (this.locator) {
|
|
this.doc.documentURI = this.locator.systemId;
|
|
}
|
|
},
|
|
startElement: function(namespaceURI, localName, qName, attrs) {
|
|
var doc = this.doc;
|
|
var el = doc.createElementNS(namespaceURI, qName || localName);
|
|
var len = attrs.length;
|
|
appendElement(this, el);
|
|
this.currentElement = el;
|
|
this.locator && position(this.locator, el);
|
|
for (var i3 = 0; i3 < len; i3++) {
|
|
var namespaceURI = attrs.getURI(i3);
|
|
var value = attrs.getValue(i3);
|
|
var qName = attrs.getQName(i3);
|
|
var attr = doc.createAttributeNS(namespaceURI, qName);
|
|
this.locator && position(attrs.getLocator(i3), attr);
|
|
attr.value = attr.nodeValue = value;
|
|
el.setAttributeNode(attr);
|
|
}
|
|
},
|
|
endElement: function(namespaceURI, localName, qName) {
|
|
var current = this.currentElement;
|
|
var tagName = current.tagName;
|
|
this.currentElement = current.parentNode;
|
|
},
|
|
startPrefixMapping: function(prefix, uri) {
|
|
},
|
|
endPrefixMapping: function(prefix) {
|
|
},
|
|
processingInstruction: function(target, data) {
|
|
var ins = this.doc.createProcessingInstruction(target, data);
|
|
this.locator && position(this.locator, ins);
|
|
appendElement(this, ins);
|
|
},
|
|
ignorableWhitespace: function(ch, start, length) {
|
|
},
|
|
characters: function(chars, start, length) {
|
|
chars = _toString.apply(this, arguments);
|
|
if (chars) {
|
|
if (this.cdata) {
|
|
var charNode = this.doc.createCDATASection(chars);
|
|
} else {
|
|
var charNode = this.doc.createTextNode(chars);
|
|
}
|
|
if (this.currentElement) {
|
|
this.currentElement.appendChild(charNode);
|
|
} else if (/^\s*$/.test(chars)) {
|
|
this.doc.appendChild(charNode);
|
|
}
|
|
this.locator && position(this.locator, charNode);
|
|
}
|
|
},
|
|
skippedEntity: function(name) {
|
|
},
|
|
endDocument: function() {
|
|
this.doc.normalize();
|
|
},
|
|
setDocumentLocator: function(locator) {
|
|
if (this.locator = locator) {
|
|
locator.lineNumber = 0;
|
|
}
|
|
},
|
|
comment: function(chars, start, length) {
|
|
chars = _toString.apply(this, arguments);
|
|
var comm = this.doc.createComment(chars);
|
|
this.locator && position(this.locator, comm);
|
|
appendElement(this, comm);
|
|
},
|
|
startCDATA: function() {
|
|
this.cdata = true;
|
|
},
|
|
endCDATA: function() {
|
|
this.cdata = false;
|
|
},
|
|
startDTD: function(name, publicId, systemId) {
|
|
var impl = this.doc.implementation;
|
|
if (impl && impl.createDocumentType) {
|
|
var dt = impl.createDocumentType(name, publicId, systemId);
|
|
this.locator && position(this.locator, dt);
|
|
appendElement(this, dt);
|
|
}
|
|
},
|
|
warning: function(error) {
|
|
console.warn("[xmldom warning] " + error, _locator(this.locator));
|
|
},
|
|
error: function(error) {
|
|
console.error("[xmldom error] " + error, _locator(this.locator));
|
|
},
|
|
fatalError: function(error) {
|
|
console.error("[xmldom fatalError] " + error, _locator(this.locator));
|
|
throw error;
|
|
}
|
|
};
|
|
function _locator(l3) {
|
|
if (l3) {
|
|
return "\n@" + (l3.systemId || "") + "#[line:" + l3.lineNumber + ",col:" + l3.columnNumber + "]";
|
|
}
|
|
}
|
|
function _toString(chars, start, length) {
|
|
if (typeof chars == "string") {
|
|
return chars.substr(start, length);
|
|
} else {
|
|
if (chars.length >= start + length || start) {
|
|
return new java.lang.String(chars, start, length) + "";
|
|
}
|
|
return chars;
|
|
}
|
|
}
|
|
"endDTD,startEntity,endEntity,attributeDecl,elementDecl,externalEntityDecl,internalEntityDecl,resolveEntity,getExternalSubset,notationDecl,unparsedEntityDecl".replace(/\w+/g, function(key) {
|
|
DOMHandler.prototype[key] = function() {
|
|
return null;
|
|
};
|
|
});
|
|
function appendElement(hander, node) {
|
|
if (!hander.currentElement) {
|
|
hander.doc.appendChild(node);
|
|
} else {
|
|
hander.currentElement.appendChild(node);
|
|
}
|
|
}
|
|
var XMLReader = require2("./sax").XMLReader;
|
|
var DOMImplementation = exports3.DOMImplementation = require2("./dom").DOMImplementation;
|
|
exports3.XMLSerializer = require2("./dom").XMLSerializer;
|
|
exports3.DOMParser = DOMParser;
|
|
}, { "./dom": 31, "./sax": 32 }], 31: [function(require2, module4, exports3) {
|
|
function copy(src, dest) {
|
|
for (var p3 in src) {
|
|
dest[p3] = src[p3];
|
|
}
|
|
}
|
|
function _extends(Class, Super) {
|
|
var pt = Class.prototype;
|
|
if (Object.create) {
|
|
var ppt = Object.create(Super.prototype);
|
|
pt.__proto__ = ppt;
|
|
}
|
|
if (!(pt instanceof Super)) {
|
|
let t4 = function() {
|
|
};
|
|
var t3 = t4;
|
|
;
|
|
t4.prototype = Super.prototype;
|
|
t4 = new t4();
|
|
copy(pt, t4);
|
|
Class.prototype = pt = t4;
|
|
}
|
|
if (pt.constructor != Class) {
|
|
if (typeof Class != "function") {
|
|
console.error("unknow Class:" + Class);
|
|
}
|
|
pt.constructor = Class;
|
|
}
|
|
}
|
|
var htmlns = "http://www.w3.org/1999/xhtml";
|
|
var NodeType = {};
|
|
var ELEMENT_NODE = NodeType.ELEMENT_NODE = 1;
|
|
var ATTRIBUTE_NODE = NodeType.ATTRIBUTE_NODE = 2;
|
|
var TEXT_NODE = NodeType.TEXT_NODE = 3;
|
|
var CDATA_SECTION_NODE = NodeType.CDATA_SECTION_NODE = 4;
|
|
var ENTITY_REFERENCE_NODE = NodeType.ENTITY_REFERENCE_NODE = 5;
|
|
var ENTITY_NODE = NodeType.ENTITY_NODE = 6;
|
|
var PROCESSING_INSTRUCTION_NODE = NodeType.PROCESSING_INSTRUCTION_NODE = 7;
|
|
var COMMENT_NODE = NodeType.COMMENT_NODE = 8;
|
|
var DOCUMENT_NODE = NodeType.DOCUMENT_NODE = 9;
|
|
var DOCUMENT_TYPE_NODE = NodeType.DOCUMENT_TYPE_NODE = 10;
|
|
var DOCUMENT_FRAGMENT_NODE = NodeType.DOCUMENT_FRAGMENT_NODE = 11;
|
|
var NOTATION_NODE = NodeType.NOTATION_NODE = 12;
|
|
var ExceptionCode = {};
|
|
var ExceptionMessage = {};
|
|
var INDEX_SIZE_ERR = ExceptionCode.INDEX_SIZE_ERR = (ExceptionMessage[1] = "Index size error", 1);
|
|
var DOMSTRING_SIZE_ERR = ExceptionCode.DOMSTRING_SIZE_ERR = (ExceptionMessage[2] = "DOMString size error", 2);
|
|
var HIERARCHY_REQUEST_ERR = ExceptionCode.HIERARCHY_REQUEST_ERR = (ExceptionMessage[3] = "Hierarchy request error", 3);
|
|
var WRONG_DOCUMENT_ERR = ExceptionCode.WRONG_DOCUMENT_ERR = (ExceptionMessage[4] = "Wrong document", 4);
|
|
var INVALID_CHARACTER_ERR = ExceptionCode.INVALID_CHARACTER_ERR = (ExceptionMessage[5] = "Invalid character", 5);
|
|
var NO_DATA_ALLOWED_ERR = ExceptionCode.NO_DATA_ALLOWED_ERR = (ExceptionMessage[6] = "No data allowed", 6);
|
|
var NO_MODIFICATION_ALLOWED_ERR = ExceptionCode.NO_MODIFICATION_ALLOWED_ERR = (ExceptionMessage[7] = "No modification allowed", 7);
|
|
var NOT_FOUND_ERR = ExceptionCode.NOT_FOUND_ERR = (ExceptionMessage[8] = "Not found", 8);
|
|
var NOT_SUPPORTED_ERR = ExceptionCode.NOT_SUPPORTED_ERR = (ExceptionMessage[9] = "Not supported", 9);
|
|
var INUSE_ATTRIBUTE_ERR = ExceptionCode.INUSE_ATTRIBUTE_ERR = (ExceptionMessage[10] = "Attribute in use", 10);
|
|
var INVALID_STATE_ERR = ExceptionCode.INVALID_STATE_ERR = (ExceptionMessage[11] = "Invalid state", 11);
|
|
var SYNTAX_ERR = ExceptionCode.SYNTAX_ERR = (ExceptionMessage[12] = "Syntax error", 12);
|
|
var INVALID_MODIFICATION_ERR = ExceptionCode.INVALID_MODIFICATION_ERR = (ExceptionMessage[13] = "Invalid modification", 13);
|
|
var NAMESPACE_ERR = ExceptionCode.NAMESPACE_ERR = (ExceptionMessage[14] = "Invalid namespace", 14);
|
|
var INVALID_ACCESS_ERR = ExceptionCode.INVALID_ACCESS_ERR = (ExceptionMessage[15] = "Invalid access", 15);
|
|
function DOMException(code, message) {
|
|
if (message instanceof Error) {
|
|
var error = message;
|
|
} else {
|
|
error = this;
|
|
Error.call(this, ExceptionMessage[code]);
|
|
this.message = ExceptionMessage[code];
|
|
if (Error.captureStackTrace)
|
|
Error.captureStackTrace(this, DOMException);
|
|
}
|
|
error.code = code;
|
|
if (message)
|
|
this.message = this.message + ": " + message;
|
|
return error;
|
|
}
|
|
;
|
|
DOMException.prototype = Error.prototype;
|
|
copy(ExceptionCode, DOMException);
|
|
function NodeList() {
|
|
}
|
|
;
|
|
NodeList.prototype = {
|
|
length: 0,
|
|
item: function(index) {
|
|
return this[index] || null;
|
|
},
|
|
toString: function(isHTML, nodeFilter) {
|
|
for (var buf = [], i3 = 0; i3 < this.length; i3++) {
|
|
serializeToString(this[i3], buf, isHTML, nodeFilter);
|
|
}
|
|
return buf.join("");
|
|
}
|
|
};
|
|
function LiveNodeList(node, refresh) {
|
|
this._node = node;
|
|
this._refresh = refresh;
|
|
_updateLiveList(this);
|
|
}
|
|
function _updateLiveList(list) {
|
|
var inc = list._node._inc || list._node.ownerDocument._inc;
|
|
if (list._inc != inc) {
|
|
var ls = list._refresh(list._node);
|
|
__set__(list, "length", ls.length);
|
|
copy(ls, list);
|
|
list._inc = inc;
|
|
}
|
|
}
|
|
LiveNodeList.prototype.item = function(i3) {
|
|
_updateLiveList(this);
|
|
return this[i3];
|
|
};
|
|
_extends(LiveNodeList, NodeList);
|
|
function NamedNodeMap() {
|
|
}
|
|
;
|
|
function _findNodeIndex(list, node) {
|
|
var i3 = list.length;
|
|
while (i3--) {
|
|
if (list[i3] === node) {
|
|
return i3;
|
|
}
|
|
}
|
|
}
|
|
function _addNamedNode(el, list, newAttr, oldAttr) {
|
|
if (oldAttr) {
|
|
list[_findNodeIndex(list, oldAttr)] = newAttr;
|
|
} else {
|
|
list[list.length++] = newAttr;
|
|
}
|
|
if (el) {
|
|
newAttr.ownerElement = el;
|
|
var doc = el.ownerDocument;
|
|
if (doc) {
|
|
oldAttr && _onRemoveAttribute(doc, el, oldAttr);
|
|
_onAddAttribute(doc, el, newAttr);
|
|
}
|
|
}
|
|
}
|
|
function _removeNamedNode(el, list, attr) {
|
|
var i3 = _findNodeIndex(list, attr);
|
|
if (i3 >= 0) {
|
|
var lastIndex = list.length - 1;
|
|
while (i3 < lastIndex) {
|
|
list[i3] = list[++i3];
|
|
}
|
|
list.length = lastIndex;
|
|
if (el) {
|
|
var doc = el.ownerDocument;
|
|
if (doc) {
|
|
_onRemoveAttribute(doc, el, attr);
|
|
attr.ownerElement = null;
|
|
}
|
|
}
|
|
} else {
|
|
throw DOMException(NOT_FOUND_ERR, new Error(el.tagName + "@" + attr));
|
|
}
|
|
}
|
|
NamedNodeMap.prototype = {
|
|
length: 0,
|
|
item: NodeList.prototype.item,
|
|
getNamedItem: function(key) {
|
|
var i3 = this.length;
|
|
while (i3--) {
|
|
var attr = this[i3];
|
|
if (attr.nodeName == key) {
|
|
return attr;
|
|
}
|
|
}
|
|
},
|
|
setNamedItem: function(attr) {
|
|
var el = attr.ownerElement;
|
|
if (el && el != this._ownerElement) {
|
|
throw new DOMException(INUSE_ATTRIBUTE_ERR);
|
|
}
|
|
var oldAttr = this.getNamedItem(attr.nodeName);
|
|
_addNamedNode(this._ownerElement, this, attr, oldAttr);
|
|
return oldAttr;
|
|
},
|
|
setNamedItemNS: function(attr) {
|
|
var el = attr.ownerElement, oldAttr;
|
|
if (el && el != this._ownerElement) {
|
|
throw new DOMException(INUSE_ATTRIBUTE_ERR);
|
|
}
|
|
oldAttr = this.getNamedItemNS(attr.namespaceURI, attr.localName);
|
|
_addNamedNode(this._ownerElement, this, attr, oldAttr);
|
|
return oldAttr;
|
|
},
|
|
removeNamedItem: function(key) {
|
|
var attr = this.getNamedItem(key);
|
|
_removeNamedNode(this._ownerElement, this, attr);
|
|
return attr;
|
|
},
|
|
removeNamedItemNS: function(namespaceURI, localName) {
|
|
var attr = this.getNamedItemNS(namespaceURI, localName);
|
|
_removeNamedNode(this._ownerElement, this, attr);
|
|
return attr;
|
|
},
|
|
getNamedItemNS: function(namespaceURI, localName) {
|
|
var i3 = this.length;
|
|
while (i3--) {
|
|
var node = this[i3];
|
|
if (node.localName == localName && node.namespaceURI == namespaceURI) {
|
|
return node;
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
};
|
|
function DOMImplementation(features) {
|
|
this._features = {};
|
|
if (features) {
|
|
for (var feature in features) {
|
|
this._features = features[feature];
|
|
}
|
|
}
|
|
}
|
|
;
|
|
DOMImplementation.prototype = {
|
|
hasFeature: function(feature, version) {
|
|
var versions = this._features[feature.toLowerCase()];
|
|
if (versions && (!version || version in versions)) {
|
|
return true;
|
|
} else {
|
|
return false;
|
|
}
|
|
},
|
|
createDocument: function(namespaceURI, qualifiedName, doctype) {
|
|
var doc = new Document();
|
|
doc.implementation = this;
|
|
doc.childNodes = new NodeList();
|
|
doc.doctype = doctype;
|
|
if (doctype) {
|
|
doc.appendChild(doctype);
|
|
}
|
|
if (qualifiedName) {
|
|
var root = doc.createElementNS(namespaceURI, qualifiedName);
|
|
doc.appendChild(root);
|
|
}
|
|
return doc;
|
|
},
|
|
createDocumentType: function(qualifiedName, publicId, systemId) {
|
|
var node = new DocumentType();
|
|
node.name = qualifiedName;
|
|
node.nodeName = qualifiedName;
|
|
node.publicId = publicId;
|
|
node.systemId = systemId;
|
|
return node;
|
|
}
|
|
};
|
|
function Node() {
|
|
}
|
|
;
|
|
Node.prototype = {
|
|
firstChild: null,
|
|
lastChild: null,
|
|
previousSibling: null,
|
|
nextSibling: null,
|
|
attributes: null,
|
|
parentNode: null,
|
|
childNodes: null,
|
|
ownerDocument: null,
|
|
nodeValue: null,
|
|
namespaceURI: null,
|
|
prefix: null,
|
|
localName: null,
|
|
insertBefore: function(newChild, refChild) {
|
|
return _insertBefore(this, newChild, refChild);
|
|
},
|
|
replaceChild: function(newChild, oldChild) {
|
|
this.insertBefore(newChild, oldChild);
|
|
if (oldChild) {
|
|
this.removeChild(oldChild);
|
|
}
|
|
},
|
|
removeChild: function(oldChild) {
|
|
return _removeChild(this, oldChild);
|
|
},
|
|
appendChild: function(newChild) {
|
|
return this.insertBefore(newChild, null);
|
|
},
|
|
hasChildNodes: function() {
|
|
return this.firstChild != null;
|
|
},
|
|
cloneNode: function(deep) {
|
|
return cloneNode(this.ownerDocument || this, this, deep);
|
|
},
|
|
normalize: function() {
|
|
var child = this.firstChild;
|
|
while (child) {
|
|
var next = child.nextSibling;
|
|
if (next && next.nodeType == TEXT_NODE && child.nodeType == TEXT_NODE) {
|
|
this.removeChild(next);
|
|
child.appendData(next.data);
|
|
} else {
|
|
child.normalize();
|
|
child = next;
|
|
}
|
|
}
|
|
},
|
|
isSupported: function(feature, version) {
|
|
return this.ownerDocument.implementation.hasFeature(feature, version);
|
|
},
|
|
hasAttributes: function() {
|
|
return this.attributes.length > 0;
|
|
},
|
|
lookupPrefix: function(namespaceURI) {
|
|
var el = this;
|
|
while (el) {
|
|
var map = el._nsMap;
|
|
if (map) {
|
|
for (var n2 in map) {
|
|
if (map[n2] == namespaceURI) {
|
|
return n2;
|
|
}
|
|
}
|
|
}
|
|
el = el.nodeType == ATTRIBUTE_NODE ? el.ownerDocument : el.parentNode;
|
|
}
|
|
return null;
|
|
},
|
|
lookupNamespaceURI: function(prefix) {
|
|
var el = this;
|
|
while (el) {
|
|
var map = el._nsMap;
|
|
if (map) {
|
|
if (prefix in map) {
|
|
return map[prefix];
|
|
}
|
|
}
|
|
el = el.nodeType == ATTRIBUTE_NODE ? el.ownerDocument : el.parentNode;
|
|
}
|
|
return null;
|
|
},
|
|
isDefaultNamespace: function(namespaceURI) {
|
|
var prefix = this.lookupPrefix(namespaceURI);
|
|
return prefix == null;
|
|
}
|
|
};
|
|
function _xmlEncoder(c3) {
|
|
return c3 == "<" && "<" || c3 == ">" && ">" || c3 == "&" && "&" || c3 == '"' && """ || "&#" + c3.charCodeAt() + ";";
|
|
}
|
|
copy(NodeType, Node);
|
|
copy(NodeType, Node.prototype);
|
|
function _visitNode(node, callback) {
|
|
if (callback(node)) {
|
|
return true;
|
|
}
|
|
if (node = node.firstChild) {
|
|
do {
|
|
if (_visitNode(node, callback)) {
|
|
return true;
|
|
}
|
|
} while (node = node.nextSibling);
|
|
}
|
|
}
|
|
function Document() {
|
|
}
|
|
function _onAddAttribute(doc, el, newAttr) {
|
|
doc && doc._inc++;
|
|
var ns2 = newAttr.namespaceURI;
|
|
if (ns2 == "http://www.w3.org/2000/xmlns/") {
|
|
el._nsMap[newAttr.prefix ? newAttr.localName : ""] = newAttr.value;
|
|
}
|
|
}
|
|
function _onRemoveAttribute(doc, el, newAttr, remove) {
|
|
doc && doc._inc++;
|
|
var ns2 = newAttr.namespaceURI;
|
|
if (ns2 == "http://www.w3.org/2000/xmlns/") {
|
|
delete el._nsMap[newAttr.prefix ? newAttr.localName : ""];
|
|
}
|
|
}
|
|
function _onUpdateChild(doc, el, newChild) {
|
|
if (doc && doc._inc) {
|
|
doc._inc++;
|
|
var cs = el.childNodes;
|
|
if (newChild) {
|
|
cs[cs.length++] = newChild;
|
|
} else {
|
|
var child = el.firstChild;
|
|
var i3 = 0;
|
|
while (child) {
|
|
cs[i3++] = child;
|
|
child = child.nextSibling;
|
|
}
|
|
cs.length = i3;
|
|
}
|
|
}
|
|
}
|
|
function _removeChild(parentNode, child) {
|
|
var previous = child.previousSibling;
|
|
var next = child.nextSibling;
|
|
if (previous) {
|
|
previous.nextSibling = next;
|
|
} else {
|
|
parentNode.firstChild = next;
|
|
}
|
|
if (next) {
|
|
next.previousSibling = previous;
|
|
} else {
|
|
parentNode.lastChild = previous;
|
|
}
|
|
_onUpdateChild(parentNode.ownerDocument, parentNode);
|
|
return child;
|
|
}
|
|
function _insertBefore(parentNode, newChild, nextChild) {
|
|
var cp = newChild.parentNode;
|
|
if (cp) {
|
|
cp.removeChild(newChild);
|
|
}
|
|
if (newChild.nodeType === DOCUMENT_FRAGMENT_NODE) {
|
|
var newFirst = newChild.firstChild;
|
|
if (newFirst == null) {
|
|
return newChild;
|
|
}
|
|
var newLast = newChild.lastChild;
|
|
} else {
|
|
newFirst = newLast = newChild;
|
|
}
|
|
var pre = nextChild ? nextChild.previousSibling : parentNode.lastChild;
|
|
newFirst.previousSibling = pre;
|
|
newLast.nextSibling = nextChild;
|
|
if (pre) {
|
|
pre.nextSibling = newFirst;
|
|
} else {
|
|
parentNode.firstChild = newFirst;
|
|
}
|
|
if (nextChild == null) {
|
|
parentNode.lastChild = newLast;
|
|
} else {
|
|
nextChild.previousSibling = newLast;
|
|
}
|
|
do {
|
|
newFirst.parentNode = parentNode;
|
|
} while (newFirst !== newLast && (newFirst = newFirst.nextSibling));
|
|
_onUpdateChild(parentNode.ownerDocument || parentNode, parentNode);
|
|
if (newChild.nodeType == DOCUMENT_FRAGMENT_NODE) {
|
|
newChild.firstChild = newChild.lastChild = null;
|
|
}
|
|
return newChild;
|
|
}
|
|
function _appendSingleChild(parentNode, newChild) {
|
|
var cp = newChild.parentNode;
|
|
if (cp) {
|
|
var pre = parentNode.lastChild;
|
|
cp.removeChild(newChild);
|
|
var pre = parentNode.lastChild;
|
|
}
|
|
var pre = parentNode.lastChild;
|
|
newChild.parentNode = parentNode;
|
|
newChild.previousSibling = pre;
|
|
newChild.nextSibling = null;
|
|
if (pre) {
|
|
pre.nextSibling = newChild;
|
|
} else {
|
|
parentNode.firstChild = newChild;
|
|
}
|
|
parentNode.lastChild = newChild;
|
|
_onUpdateChild(parentNode.ownerDocument, parentNode, newChild);
|
|
return newChild;
|
|
}
|
|
Document.prototype = {
|
|
nodeName: "#document",
|
|
nodeType: DOCUMENT_NODE,
|
|
doctype: null,
|
|
documentElement: null,
|
|
_inc: 1,
|
|
insertBefore: function(newChild, refChild) {
|
|
if (newChild.nodeType == DOCUMENT_FRAGMENT_NODE) {
|
|
var child = newChild.firstChild;
|
|
while (child) {
|
|
var next = child.nextSibling;
|
|
this.insertBefore(child, refChild);
|
|
child = next;
|
|
}
|
|
return newChild;
|
|
}
|
|
if (this.documentElement == null && newChild.nodeType == ELEMENT_NODE) {
|
|
this.documentElement = newChild;
|
|
}
|
|
return _insertBefore(this, newChild, refChild), newChild.ownerDocument = this, newChild;
|
|
},
|
|
removeChild: function(oldChild) {
|
|
if (this.documentElement == oldChild) {
|
|
this.documentElement = null;
|
|
}
|
|
return _removeChild(this, oldChild);
|
|
},
|
|
importNode: function(importedNode, deep) {
|
|
return importNode(this, importedNode, deep);
|
|
},
|
|
getElementById: function(id) {
|
|
var rtv = null;
|
|
_visitNode(this.documentElement, function(node) {
|
|
if (node.nodeType == ELEMENT_NODE) {
|
|
if (node.getAttribute("id") == id) {
|
|
rtv = node;
|
|
return true;
|
|
}
|
|
}
|
|
});
|
|
return rtv;
|
|
},
|
|
createElement: function(tagName) {
|
|
var node = new Element2();
|
|
node.ownerDocument = this;
|
|
node.nodeName = tagName;
|
|
node.tagName = tagName;
|
|
node.childNodes = new NodeList();
|
|
var attrs = node.attributes = new NamedNodeMap();
|
|
attrs._ownerElement = node;
|
|
return node;
|
|
},
|
|
createDocumentFragment: function() {
|
|
var node = new DocumentFragment();
|
|
node.ownerDocument = this;
|
|
node.childNodes = new NodeList();
|
|
return node;
|
|
},
|
|
createTextNode: function(data) {
|
|
var node = new Text();
|
|
node.ownerDocument = this;
|
|
node.appendData(data);
|
|
return node;
|
|
},
|
|
createComment: function(data) {
|
|
var node = new Comment();
|
|
node.ownerDocument = this;
|
|
node.appendData(data);
|
|
return node;
|
|
},
|
|
createCDATASection: function(data) {
|
|
var node = new CDATASection();
|
|
node.ownerDocument = this;
|
|
node.appendData(data);
|
|
return node;
|
|
},
|
|
createProcessingInstruction: function(target, data) {
|
|
var node = new ProcessingInstruction();
|
|
node.ownerDocument = this;
|
|
node.tagName = node.target = target;
|
|
node.nodeValue = node.data = data;
|
|
return node;
|
|
},
|
|
createAttribute: function(name) {
|
|
var node = new Attr();
|
|
node.ownerDocument = this;
|
|
node.name = name;
|
|
node.nodeName = name;
|
|
node.localName = name;
|
|
node.specified = true;
|
|
return node;
|
|
},
|
|
createEntityReference: function(name) {
|
|
var node = new EntityReference();
|
|
node.ownerDocument = this;
|
|
node.nodeName = name;
|
|
return node;
|
|
},
|
|
createElementNS: function(namespaceURI, qualifiedName) {
|
|
var node = new Element2();
|
|
var pl = qualifiedName.split(":");
|
|
var attrs = node.attributes = new NamedNodeMap();
|
|
node.childNodes = new NodeList();
|
|
node.ownerDocument = this;
|
|
node.nodeName = qualifiedName;
|
|
node.tagName = qualifiedName;
|
|
node.namespaceURI = namespaceURI;
|
|
if (pl.length == 2) {
|
|
node.prefix = pl[0];
|
|
node.localName = pl[1];
|
|
} else {
|
|
node.localName = qualifiedName;
|
|
}
|
|
attrs._ownerElement = node;
|
|
return node;
|
|
},
|
|
createAttributeNS: function(namespaceURI, qualifiedName) {
|
|
var node = new Attr();
|
|
var pl = qualifiedName.split(":");
|
|
node.ownerDocument = this;
|
|
node.nodeName = qualifiedName;
|
|
node.name = qualifiedName;
|
|
node.namespaceURI = namespaceURI;
|
|
node.specified = true;
|
|
if (pl.length == 2) {
|
|
node.prefix = pl[0];
|
|
node.localName = pl[1];
|
|
} else {
|
|
node.localName = qualifiedName;
|
|
}
|
|
return node;
|
|
}
|
|
};
|
|
_extends(Document, Node);
|
|
function Element2() {
|
|
this._nsMap = {};
|
|
}
|
|
;
|
|
Element2.prototype = {
|
|
nodeType: ELEMENT_NODE,
|
|
hasAttribute: function(name) {
|
|
return this.getAttributeNode(name) != null;
|
|
},
|
|
getAttribute: function(name) {
|
|
var attr = this.getAttributeNode(name);
|
|
return attr && attr.value || "";
|
|
},
|
|
getAttributeNode: function(name) {
|
|
return this.attributes.getNamedItem(name);
|
|
},
|
|
setAttribute: function(name, value) {
|
|
var attr = this.ownerDocument.createAttribute(name);
|
|
attr.value = attr.nodeValue = "" + value;
|
|
this.setAttributeNode(attr);
|
|
},
|
|
removeAttribute: function(name) {
|
|
var attr = this.getAttributeNode(name);
|
|
attr && this.removeAttributeNode(attr);
|
|
},
|
|
appendChild: function(newChild) {
|
|
if (newChild.nodeType === DOCUMENT_FRAGMENT_NODE) {
|
|
return this.insertBefore(newChild, null);
|
|
} else {
|
|
return _appendSingleChild(this, newChild);
|
|
}
|
|
},
|
|
setAttributeNode: function(newAttr) {
|
|
return this.attributes.setNamedItem(newAttr);
|
|
},
|
|
setAttributeNodeNS: function(newAttr) {
|
|
return this.attributes.setNamedItemNS(newAttr);
|
|
},
|
|
removeAttributeNode: function(oldAttr) {
|
|
return this.attributes.removeNamedItem(oldAttr.nodeName);
|
|
},
|
|
removeAttributeNS: function(namespaceURI, localName) {
|
|
var old = this.getAttributeNodeNS(namespaceURI, localName);
|
|
old && this.removeAttributeNode(old);
|
|
},
|
|
hasAttributeNS: function(namespaceURI, localName) {
|
|
return this.getAttributeNodeNS(namespaceURI, localName) != null;
|
|
},
|
|
getAttributeNS: function(namespaceURI, localName) {
|
|
var attr = this.getAttributeNodeNS(namespaceURI, localName);
|
|
return attr && attr.value || "";
|
|
},
|
|
setAttributeNS: function(namespaceURI, qualifiedName, value) {
|
|
var attr = this.ownerDocument.createAttributeNS(namespaceURI, qualifiedName);
|
|
attr.value = attr.nodeValue = "" + value;
|
|
this.setAttributeNode(attr);
|
|
},
|
|
getAttributeNodeNS: function(namespaceURI, localName) {
|
|
return this.attributes.getNamedItemNS(namespaceURI, localName);
|
|
},
|
|
getElementsByTagName: function(tagName) {
|
|
return new LiveNodeList(this, function(base) {
|
|
var ls = [];
|
|
_visitNode(base, function(node) {
|
|
if (node !== base && node.nodeType == ELEMENT_NODE && (tagName === "*" || node.tagName == tagName)) {
|
|
ls.push(node);
|
|
}
|
|
});
|
|
return ls;
|
|
});
|
|
},
|
|
getElementsByTagNameNS: function(namespaceURI, localName) {
|
|
return new LiveNodeList(this, function(base) {
|
|
var ls = [];
|
|
_visitNode(base, function(node) {
|
|
if (node !== base && node.nodeType === ELEMENT_NODE && (namespaceURI === "*" || node.namespaceURI === namespaceURI) && (localName === "*" || node.localName == localName)) {
|
|
ls.push(node);
|
|
}
|
|
});
|
|
return ls;
|
|
});
|
|
}
|
|
};
|
|
Document.prototype.getElementsByTagName = Element2.prototype.getElementsByTagName;
|
|
Document.prototype.getElementsByTagNameNS = Element2.prototype.getElementsByTagNameNS;
|
|
_extends(Element2, Node);
|
|
function Attr() {
|
|
}
|
|
;
|
|
Attr.prototype.nodeType = ATTRIBUTE_NODE;
|
|
_extends(Attr, Node);
|
|
function CharacterData() {
|
|
}
|
|
;
|
|
CharacterData.prototype = {
|
|
data: "",
|
|
substringData: function(offset, count) {
|
|
return this.data.substring(offset, offset + count);
|
|
},
|
|
appendData: function(text) {
|
|
text = this.data + text;
|
|
this.nodeValue = this.data = text;
|
|
this.length = text.length;
|
|
},
|
|
insertData: function(offset, text) {
|
|
this.replaceData(offset, 0, text);
|
|
},
|
|
appendChild: function(newChild) {
|
|
throw new Error(ExceptionMessage[HIERARCHY_REQUEST_ERR]);
|
|
},
|
|
deleteData: function(offset, count) {
|
|
this.replaceData(offset, count, "");
|
|
},
|
|
replaceData: function(offset, count, text) {
|
|
var start = this.data.substring(0, offset);
|
|
var end = this.data.substring(offset + count);
|
|
text = start + text + end;
|
|
this.nodeValue = this.data = text;
|
|
this.length = text.length;
|
|
}
|
|
};
|
|
_extends(CharacterData, Node);
|
|
function Text() {
|
|
}
|
|
;
|
|
Text.prototype = {
|
|
nodeName: "#text",
|
|
nodeType: TEXT_NODE,
|
|
splitText: function(offset) {
|
|
var text = this.data;
|
|
var newText = text.substring(offset);
|
|
text = text.substring(0, offset);
|
|
this.data = this.nodeValue = text;
|
|
this.length = text.length;
|
|
var newNode = this.ownerDocument.createTextNode(newText);
|
|
if (this.parentNode) {
|
|
this.parentNode.insertBefore(newNode, this.nextSibling);
|
|
}
|
|
return newNode;
|
|
}
|
|
};
|
|
_extends(Text, CharacterData);
|
|
function Comment() {
|
|
}
|
|
;
|
|
Comment.prototype = {
|
|
nodeName: "#comment",
|
|
nodeType: COMMENT_NODE
|
|
};
|
|
_extends(Comment, CharacterData);
|
|
function CDATASection() {
|
|
}
|
|
;
|
|
CDATASection.prototype = {
|
|
nodeName: "#cdata-section",
|
|
nodeType: CDATA_SECTION_NODE
|
|
};
|
|
_extends(CDATASection, CharacterData);
|
|
function DocumentType() {
|
|
}
|
|
;
|
|
DocumentType.prototype.nodeType = DOCUMENT_TYPE_NODE;
|
|
_extends(DocumentType, Node);
|
|
function Notation() {
|
|
}
|
|
;
|
|
Notation.prototype.nodeType = NOTATION_NODE;
|
|
_extends(Notation, Node);
|
|
function Entity() {
|
|
}
|
|
;
|
|
Entity.prototype.nodeType = ENTITY_NODE;
|
|
_extends(Entity, Node);
|
|
function EntityReference() {
|
|
}
|
|
;
|
|
EntityReference.prototype.nodeType = ENTITY_REFERENCE_NODE;
|
|
_extends(EntityReference, Node);
|
|
function DocumentFragment() {
|
|
}
|
|
;
|
|
DocumentFragment.prototype.nodeName = "#document-fragment";
|
|
DocumentFragment.prototype.nodeType = DOCUMENT_FRAGMENT_NODE;
|
|
_extends(DocumentFragment, Node);
|
|
function ProcessingInstruction() {
|
|
}
|
|
ProcessingInstruction.prototype.nodeType = PROCESSING_INSTRUCTION_NODE;
|
|
_extends(ProcessingInstruction, Node);
|
|
function XMLSerializer() {
|
|
}
|
|
XMLSerializer.prototype.serializeToString = function(node, isHtml, nodeFilter) {
|
|
return nodeSerializeToString.call(node, isHtml, nodeFilter);
|
|
};
|
|
Node.prototype.toString = nodeSerializeToString;
|
|
function nodeSerializeToString(isHtml, nodeFilter) {
|
|
var buf = [];
|
|
var refNode = this.nodeType == 9 ? this.documentElement : this;
|
|
var prefix = refNode.prefix;
|
|
var uri = refNode.namespaceURI;
|
|
if (uri && prefix == null) {
|
|
var prefix = refNode.lookupPrefix(uri);
|
|
if (prefix == null) {
|
|
var visibleNamespaces = [
|
|
{ namespace: uri, prefix: null }
|
|
];
|
|
}
|
|
}
|
|
serializeToString(this, buf, isHtml, nodeFilter, visibleNamespaces);
|
|
return buf.join("");
|
|
}
|
|
function needNamespaceDefine(node, isHTML, visibleNamespaces) {
|
|
var prefix = node.prefix || "";
|
|
var uri = node.namespaceURI;
|
|
if (!prefix && !uri) {
|
|
return false;
|
|
}
|
|
if (prefix === "xml" && uri === "http://www.w3.org/XML/1998/namespace" || uri == "http://www.w3.org/2000/xmlns/") {
|
|
return false;
|
|
}
|
|
var i3 = visibleNamespaces.length;
|
|
while (i3--) {
|
|
var ns2 = visibleNamespaces[i3];
|
|
if (ns2.prefix == prefix) {
|
|
return ns2.namespace != uri;
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
function serializeToString(node, buf, isHTML, nodeFilter, visibleNamespaces) {
|
|
if (nodeFilter) {
|
|
node = nodeFilter(node);
|
|
if (node) {
|
|
if (typeof node == "string") {
|
|
buf.push(node);
|
|
return;
|
|
}
|
|
} else {
|
|
return;
|
|
}
|
|
}
|
|
switch (node.nodeType) {
|
|
case ELEMENT_NODE:
|
|
if (!visibleNamespaces)
|
|
visibleNamespaces = [];
|
|
var startVisibleNamespaces = visibleNamespaces.length;
|
|
var attrs = node.attributes;
|
|
var len = attrs.length;
|
|
var child = node.firstChild;
|
|
var nodeName = node.tagName;
|
|
isHTML = htmlns === node.namespaceURI || isHTML;
|
|
buf.push("<", nodeName);
|
|
for (var i3 = 0; i3 < len; i3++) {
|
|
var attr = attrs.item(i3);
|
|
if (attr.prefix == "xmlns") {
|
|
visibleNamespaces.push({ prefix: attr.localName, namespace: attr.value });
|
|
} else if (attr.nodeName == "xmlns") {
|
|
visibleNamespaces.push({ prefix: "", namespace: attr.value });
|
|
}
|
|
}
|
|
for (var i3 = 0; i3 < len; i3++) {
|
|
var attr = attrs.item(i3);
|
|
if (needNamespaceDefine(attr, isHTML, visibleNamespaces)) {
|
|
var prefix = attr.prefix || "";
|
|
var uri = attr.namespaceURI;
|
|
var ns2 = prefix ? " xmlns:" + prefix : " xmlns";
|
|
buf.push(ns2, '="', uri, '"');
|
|
visibleNamespaces.push({ prefix, namespace: uri });
|
|
}
|
|
serializeToString(attr, buf, isHTML, nodeFilter, visibleNamespaces);
|
|
}
|
|
if (needNamespaceDefine(node, isHTML, visibleNamespaces)) {
|
|
var prefix = node.prefix || "";
|
|
var uri = node.namespaceURI;
|
|
var ns2 = prefix ? " xmlns:" + prefix : " xmlns";
|
|
buf.push(ns2, '="', uri, '"');
|
|
visibleNamespaces.push({ prefix, namespace: uri });
|
|
}
|
|
if (child || isHTML && !/^(?:meta|link|img|br|hr|input)$/i.test(nodeName)) {
|
|
buf.push(">");
|
|
if (isHTML && /^script$/i.test(nodeName)) {
|
|
while (child) {
|
|
if (child.data) {
|
|
buf.push(child.data);
|
|
} else {
|
|
serializeToString(child, buf, isHTML, nodeFilter, visibleNamespaces);
|
|
}
|
|
child = child.nextSibling;
|
|
}
|
|
} else {
|
|
while (child) {
|
|
serializeToString(child, buf, isHTML, nodeFilter, visibleNamespaces);
|
|
child = child.nextSibling;
|
|
}
|
|
}
|
|
buf.push("</", nodeName, ">");
|
|
} else {
|
|
buf.push("/>");
|
|
}
|
|
return;
|
|
case DOCUMENT_NODE:
|
|
case DOCUMENT_FRAGMENT_NODE:
|
|
var child = node.firstChild;
|
|
while (child) {
|
|
serializeToString(child, buf, isHTML, nodeFilter, visibleNamespaces);
|
|
child = child.nextSibling;
|
|
}
|
|
return;
|
|
case ATTRIBUTE_NODE:
|
|
return buf.push(" ", node.name, '="', node.value.replace(/[<&"]/g, _xmlEncoder), '"');
|
|
case TEXT_NODE:
|
|
return buf.push(node.data.replace(/[<&]/g, _xmlEncoder));
|
|
case CDATA_SECTION_NODE:
|
|
return buf.push("<![CDATA[", node.data, "]]>");
|
|
case COMMENT_NODE:
|
|
return buf.push("<!--", node.data, "-->");
|
|
case DOCUMENT_TYPE_NODE:
|
|
var pubid = node.publicId;
|
|
var sysid = node.systemId;
|
|
buf.push("<!DOCTYPE ", node.name);
|
|
if (pubid) {
|
|
buf.push(' PUBLIC "', pubid);
|
|
if (sysid && sysid != ".") {
|
|
buf.push('" "', sysid);
|
|
}
|
|
buf.push('">');
|
|
} else if (sysid && sysid != ".") {
|
|
buf.push(' SYSTEM "', sysid, '">');
|
|
} else {
|
|
var sub = node.internalSubset;
|
|
if (sub) {
|
|
buf.push(" [", sub, "]");
|
|
}
|
|
buf.push(">");
|
|
}
|
|
return;
|
|
case PROCESSING_INSTRUCTION_NODE:
|
|
return buf.push("<?", node.target, " ", node.data, "?>");
|
|
case ENTITY_REFERENCE_NODE:
|
|
return buf.push("&", node.nodeName, ";");
|
|
default:
|
|
buf.push("??", node.nodeName);
|
|
}
|
|
}
|
|
function importNode(doc, node, deep) {
|
|
var node2;
|
|
switch (node.nodeType) {
|
|
case ELEMENT_NODE:
|
|
node2 = node.cloneNode(false);
|
|
node2.ownerDocument = doc;
|
|
case DOCUMENT_FRAGMENT_NODE:
|
|
break;
|
|
case ATTRIBUTE_NODE:
|
|
deep = true;
|
|
break;
|
|
}
|
|
if (!node2) {
|
|
node2 = node.cloneNode(false);
|
|
}
|
|
node2.ownerDocument = doc;
|
|
node2.parentNode = null;
|
|
if (deep) {
|
|
var child = node.firstChild;
|
|
while (child) {
|
|
node2.appendChild(importNode(doc, child, deep));
|
|
child = child.nextSibling;
|
|
}
|
|
}
|
|
return node2;
|
|
}
|
|
function cloneNode(doc, node, deep) {
|
|
var node2 = new node.constructor();
|
|
for (var n2 in node) {
|
|
var v3 = node[n2];
|
|
if (typeof v3 != "object") {
|
|
if (v3 != node2[n2]) {
|
|
node2[n2] = v3;
|
|
}
|
|
}
|
|
}
|
|
if (node.childNodes) {
|
|
node2.childNodes = new NodeList();
|
|
}
|
|
node2.ownerDocument = doc;
|
|
switch (node2.nodeType) {
|
|
case ELEMENT_NODE:
|
|
var attrs = node.attributes;
|
|
var attrs2 = node2.attributes = new NamedNodeMap();
|
|
var len = attrs.length;
|
|
attrs2._ownerElement = node2;
|
|
for (var i3 = 0; i3 < len; i3++) {
|
|
node2.setAttributeNode(cloneNode(doc, attrs.item(i3), true));
|
|
}
|
|
break;
|
|
;
|
|
case ATTRIBUTE_NODE:
|
|
deep = true;
|
|
}
|
|
if (deep) {
|
|
var child = node.firstChild;
|
|
while (child) {
|
|
node2.appendChild(cloneNode(doc, child, deep));
|
|
child = child.nextSibling;
|
|
}
|
|
}
|
|
return node2;
|
|
}
|
|
function __set__(object, key, value) {
|
|
object[key] = value;
|
|
}
|
|
try {
|
|
if (Object.defineProperty) {
|
|
let getTextContent2 = function(node) {
|
|
switch (node.nodeType) {
|
|
case ELEMENT_NODE:
|
|
case DOCUMENT_FRAGMENT_NODE:
|
|
var buf = [];
|
|
node = node.firstChild;
|
|
while (node) {
|
|
if (node.nodeType !== 7 && node.nodeType !== 8) {
|
|
buf.push(getTextContent2(node));
|
|
}
|
|
node = node.nextSibling;
|
|
}
|
|
return buf.join("");
|
|
default:
|
|
return node.nodeValue;
|
|
}
|
|
};
|
|
var getTextContent = getTextContent2;
|
|
Object.defineProperty(LiveNodeList.prototype, "length", {
|
|
get: function() {
|
|
_updateLiveList(this);
|
|
return this.$$length;
|
|
}
|
|
});
|
|
Object.defineProperty(Node.prototype, "textContent", {
|
|
get: function() {
|
|
return getTextContent2(this);
|
|
},
|
|
set: function(data) {
|
|
switch (this.nodeType) {
|
|
case ELEMENT_NODE:
|
|
case DOCUMENT_FRAGMENT_NODE:
|
|
while (this.firstChild) {
|
|
this.removeChild(this.firstChild);
|
|
}
|
|
if (data || String(data)) {
|
|
this.appendChild(this.ownerDocument.createTextNode(data));
|
|
}
|
|
break;
|
|
default:
|
|
this.data = data;
|
|
this.value = data;
|
|
this.nodeValue = data;
|
|
}
|
|
}
|
|
});
|
|
__set__ = function(object, key, value) {
|
|
object["$$" + key] = value;
|
|
};
|
|
}
|
|
} catch (e3) {
|
|
}
|
|
exports3.DOMImplementation = DOMImplementation;
|
|
exports3.XMLSerializer = XMLSerializer;
|
|
}, {}], 32: [function(require2, module4, exports3) {
|
|
var nameStartChar = /[A-Z_a-z\xC0-\xD6\xD8-\xF6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/;
|
|
var nameChar = new RegExp("[\\-\\.0-9" + nameStartChar.source.slice(1, -1) + "\\u00B7\\u0300-\\u036F\\u203F-\\u2040]");
|
|
var tagNamePattern = new RegExp("^" + nameStartChar.source + nameChar.source + "*(?::" + nameStartChar.source + nameChar.source + "*)?$");
|
|
var S_TAG = 0;
|
|
var S_ATTR = 1;
|
|
var S_ATTR_SPACE = 2;
|
|
var S_EQ = 3;
|
|
var S_ATTR_NOQUOT_VALUE = 4;
|
|
var S_ATTR_END = 5;
|
|
var S_TAG_SPACE = 6;
|
|
var S_TAG_CLOSE = 7;
|
|
function XMLReader() {
|
|
}
|
|
XMLReader.prototype = {
|
|
parse: function(source, defaultNSMap, entityMap) {
|
|
var domBuilder = this.domBuilder;
|
|
domBuilder.startDocument();
|
|
_copy(defaultNSMap, defaultNSMap = {});
|
|
parse4(source, defaultNSMap, entityMap, domBuilder, this.errorHandler);
|
|
domBuilder.endDocument();
|
|
}
|
|
};
|
|
function parse4(source, defaultNSMapCopy, entityMap, domBuilder, errorHandler) {
|
|
function fixedFromCharCode(code) {
|
|
if (code > 65535) {
|
|
code -= 65536;
|
|
var surrogate1 = 55296 + (code >> 10), surrogate2 = 56320 + (code & 1023);
|
|
return String.fromCharCode(surrogate1, surrogate2);
|
|
} else {
|
|
return String.fromCharCode(code);
|
|
}
|
|
}
|
|
function entityReplacer(a4) {
|
|
var k2 = a4.slice(1, -1);
|
|
if (k2 in entityMap) {
|
|
return entityMap[k2];
|
|
} else if (k2.charAt(0) === "#") {
|
|
return fixedFromCharCode(parseInt(k2.substr(1).replace("x", "0x")));
|
|
} else {
|
|
errorHandler.error("entity not found:" + a4);
|
|
return a4;
|
|
}
|
|
}
|
|
function appendText(end2) {
|
|
if (end2 > start) {
|
|
var xt = source.substring(start, end2).replace(/&#?\w+;/g, entityReplacer);
|
|
locator && position(start);
|
|
domBuilder.characters(xt, 0, end2 - start);
|
|
start = end2;
|
|
}
|
|
}
|
|
function position(p3, m2) {
|
|
while (p3 >= lineEnd && (m2 = linePattern.exec(source))) {
|
|
lineStart = m2.index;
|
|
lineEnd = lineStart + m2[0].length;
|
|
locator.lineNumber++;
|
|
}
|
|
locator.columnNumber = p3 - lineStart + 1;
|
|
}
|
|
var lineStart = 0;
|
|
var lineEnd = 0;
|
|
var linePattern = /.*(?:\r\n?|\n)|.*$/g;
|
|
var locator = domBuilder.locator;
|
|
var parseStack = [{ currentNSMap: defaultNSMapCopy }];
|
|
var closeMap = {};
|
|
var start = 0;
|
|
while (true) {
|
|
try {
|
|
var tagStart = source.indexOf("<", start);
|
|
if (tagStart < 0) {
|
|
if (!source.substr(start).match(/^\s*$/)) {
|
|
var doc = domBuilder.doc;
|
|
var text = doc.createTextNode(source.substr(start));
|
|
doc.appendChild(text);
|
|
domBuilder.currentElement = text;
|
|
}
|
|
return;
|
|
}
|
|
if (tagStart > start) {
|
|
appendText(tagStart);
|
|
}
|
|
switch (source.charAt(tagStart + 1)) {
|
|
case "/":
|
|
var end = source.indexOf(">", tagStart + 3);
|
|
var tagName = source.substring(tagStart + 2, end);
|
|
var config2 = parseStack.pop();
|
|
if (end < 0) {
|
|
tagName = source.substring(tagStart + 2).replace(/[\s<].*/, "");
|
|
errorHandler.error("end tag name: " + tagName + " is not complete:" + config2.tagName);
|
|
end = tagStart + 1 + tagName.length;
|
|
} else if (tagName.match(/\s</)) {
|
|
tagName = tagName.replace(/[\s<].*/, "");
|
|
errorHandler.error("end tag name: " + tagName + " maybe not complete");
|
|
end = tagStart + 1 + tagName.length;
|
|
}
|
|
var localNSMap = config2.localNSMap;
|
|
var endMatch = config2.tagName == tagName;
|
|
var endIgnoreCaseMach = endMatch || config2.tagName && config2.tagName.toLowerCase() == tagName.toLowerCase();
|
|
if (endIgnoreCaseMach) {
|
|
domBuilder.endElement(config2.uri, config2.localName, tagName);
|
|
if (localNSMap) {
|
|
for (var prefix in localNSMap) {
|
|
domBuilder.endPrefixMapping(prefix);
|
|
}
|
|
}
|
|
if (!endMatch) {
|
|
errorHandler.fatalError("end tag name: " + tagName + " is not match the current start tagName:" + config2.tagName);
|
|
}
|
|
} else {
|
|
parseStack.push(config2);
|
|
}
|
|
end++;
|
|
break;
|
|
case "?":
|
|
locator && position(tagStart);
|
|
end = parseInstruction(source, tagStart, domBuilder);
|
|
break;
|
|
case "!":
|
|
locator && position(tagStart);
|
|
end = parseDCC(source, tagStart, domBuilder, errorHandler);
|
|
break;
|
|
default:
|
|
locator && position(tagStart);
|
|
var el = new ElementAttributes();
|
|
var currentNSMap = parseStack[parseStack.length - 1].currentNSMap;
|
|
var end = parseElementStartPart(source, tagStart, el, currentNSMap, entityReplacer, errorHandler);
|
|
var len = el.length;
|
|
if (!el.closed && fixSelfClosed(source, end, el.tagName, closeMap)) {
|
|
el.closed = true;
|
|
if (!entityMap.nbsp) {
|
|
errorHandler.warning("unclosed xml attribute");
|
|
}
|
|
}
|
|
if (locator && len) {
|
|
var locator2 = copyLocator(locator, {});
|
|
for (var i3 = 0; i3 < len; i3++) {
|
|
var a3 = el[i3];
|
|
position(a3.offset);
|
|
a3.locator = copyLocator(locator, {});
|
|
}
|
|
domBuilder.locator = locator2;
|
|
if (appendElement(el, domBuilder, currentNSMap)) {
|
|
parseStack.push(el);
|
|
}
|
|
domBuilder.locator = locator;
|
|
} else {
|
|
if (appendElement(el, domBuilder, currentNSMap)) {
|
|
parseStack.push(el);
|
|
}
|
|
}
|
|
if (el.uri === "http://www.w3.org/1999/xhtml" && !el.closed) {
|
|
end = parseHtmlSpecialContent(source, end, el.tagName, entityReplacer, domBuilder);
|
|
} else {
|
|
end++;
|
|
}
|
|
}
|
|
} catch (e3) {
|
|
errorHandler.error("element parse error: " + e3);
|
|
end = -1;
|
|
}
|
|
if (end > start) {
|
|
start = end;
|
|
} else {
|
|
appendText(Math.max(tagStart, start) + 1);
|
|
}
|
|
}
|
|
}
|
|
function copyLocator(f3, t3) {
|
|
t3.lineNumber = f3.lineNumber;
|
|
t3.columnNumber = f3.columnNumber;
|
|
return t3;
|
|
}
|
|
function parseElementStartPart(source, start, el, currentNSMap, entityReplacer, errorHandler) {
|
|
var attrName;
|
|
var value;
|
|
var p3 = ++start;
|
|
var s3 = S_TAG;
|
|
while (true) {
|
|
var c3 = source.charAt(p3);
|
|
switch (c3) {
|
|
case "=":
|
|
if (s3 === S_ATTR) {
|
|
attrName = source.slice(start, p3);
|
|
s3 = S_EQ;
|
|
} else if (s3 === S_ATTR_SPACE) {
|
|
s3 = S_EQ;
|
|
} else {
|
|
throw new Error("attribute equal must after attrName");
|
|
}
|
|
break;
|
|
case "'":
|
|
case '"':
|
|
if (s3 === S_EQ || s3 === S_ATTR) {
|
|
if (s3 === S_ATTR) {
|
|
errorHandler.warning('attribute value must after "="');
|
|
attrName = source.slice(start, p3);
|
|
}
|
|
start = p3 + 1;
|
|
p3 = source.indexOf(c3, start);
|
|
if (p3 > 0) {
|
|
value = source.slice(start, p3).replace(/&#?\w+;/g, entityReplacer);
|
|
el.add(attrName, value, start - 1);
|
|
s3 = S_ATTR_END;
|
|
} else {
|
|
throw new Error("attribute value no end '" + c3 + "' match");
|
|
}
|
|
} else if (s3 == S_ATTR_NOQUOT_VALUE) {
|
|
value = source.slice(start, p3).replace(/&#?\w+;/g, entityReplacer);
|
|
el.add(attrName, value, start);
|
|
errorHandler.warning('attribute "' + attrName + '" missed start quot(' + c3 + ")!!");
|
|
start = p3 + 1;
|
|
s3 = S_ATTR_END;
|
|
} else {
|
|
throw new Error('attribute value must after "="');
|
|
}
|
|
break;
|
|
case "/":
|
|
switch (s3) {
|
|
case S_TAG:
|
|
el.setTagName(source.slice(start, p3));
|
|
case S_ATTR_END:
|
|
case S_TAG_SPACE:
|
|
case S_TAG_CLOSE:
|
|
s3 = S_TAG_CLOSE;
|
|
el.closed = true;
|
|
case S_ATTR_NOQUOT_VALUE:
|
|
case S_ATTR:
|
|
case S_ATTR_SPACE:
|
|
break;
|
|
default:
|
|
throw new Error("attribute invalid close char('/')");
|
|
}
|
|
break;
|
|
case "":
|
|
errorHandler.error("unexpected end of input");
|
|
if (s3 == S_TAG) {
|
|
el.setTagName(source.slice(start, p3));
|
|
}
|
|
return p3;
|
|
case ">":
|
|
switch (s3) {
|
|
case S_TAG:
|
|
el.setTagName(source.slice(start, p3));
|
|
case S_ATTR_END:
|
|
case S_TAG_SPACE:
|
|
case S_TAG_CLOSE:
|
|
break;
|
|
case S_ATTR_NOQUOT_VALUE:
|
|
case S_ATTR:
|
|
value = source.slice(start, p3);
|
|
if (value.slice(-1) === "/") {
|
|
el.closed = true;
|
|
value = value.slice(0, -1);
|
|
}
|
|
case S_ATTR_SPACE:
|
|
if (s3 === S_ATTR_SPACE) {
|
|
value = attrName;
|
|
}
|
|
if (s3 == S_ATTR_NOQUOT_VALUE) {
|
|
errorHandler.warning('attribute "' + value + '" missed quot(")!!');
|
|
el.add(attrName, value.replace(/&#?\w+;/g, entityReplacer), start);
|
|
} else {
|
|
if (currentNSMap[""] !== "http://www.w3.org/1999/xhtml" || !value.match(/^(?:disabled|checked|selected)$/i)) {
|
|
errorHandler.warning('attribute "' + value + '" missed value!! "' + value + '" instead!!');
|
|
}
|
|
el.add(value, value, start);
|
|
}
|
|
break;
|
|
case S_EQ:
|
|
throw new Error("attribute value missed!!");
|
|
}
|
|
return p3;
|
|
case "\x80":
|
|
c3 = " ";
|
|
default:
|
|
if (c3 <= " ") {
|
|
switch (s3) {
|
|
case S_TAG:
|
|
el.setTagName(source.slice(start, p3));
|
|
s3 = S_TAG_SPACE;
|
|
break;
|
|
case S_ATTR:
|
|
attrName = source.slice(start, p3);
|
|
s3 = S_ATTR_SPACE;
|
|
break;
|
|
case S_ATTR_NOQUOT_VALUE:
|
|
var value = source.slice(start, p3).replace(/&#?\w+;/g, entityReplacer);
|
|
errorHandler.warning('attribute "' + value + '" missed quot(")!!');
|
|
el.add(attrName, value, start);
|
|
case S_ATTR_END:
|
|
s3 = S_TAG_SPACE;
|
|
break;
|
|
}
|
|
} else {
|
|
switch (s3) {
|
|
case S_ATTR_SPACE:
|
|
var tagName = el.tagName;
|
|
if (currentNSMap[""] !== "http://www.w3.org/1999/xhtml" || !attrName.match(/^(?:disabled|checked|selected)$/i)) {
|
|
errorHandler.warning('attribute "' + attrName + '" missed value!! "' + attrName + '" instead2!!');
|
|
}
|
|
el.add(attrName, attrName, start);
|
|
start = p3;
|
|
s3 = S_ATTR;
|
|
break;
|
|
case S_ATTR_END:
|
|
errorHandler.warning('attribute space is required"' + attrName + '"!!');
|
|
case S_TAG_SPACE:
|
|
s3 = S_ATTR;
|
|
start = p3;
|
|
break;
|
|
case S_EQ:
|
|
s3 = S_ATTR_NOQUOT_VALUE;
|
|
start = p3;
|
|
break;
|
|
case S_TAG_CLOSE:
|
|
throw new Error("elements closed character '/' and '>' must be connected to");
|
|
}
|
|
}
|
|
}
|
|
p3++;
|
|
}
|
|
}
|
|
function appendElement(el, domBuilder, currentNSMap) {
|
|
var tagName = el.tagName;
|
|
var localNSMap = null;
|
|
var i3 = el.length;
|
|
while (i3--) {
|
|
var a3 = el[i3];
|
|
var qName = a3.qName;
|
|
var value = a3.value;
|
|
var nsp = qName.indexOf(":");
|
|
if (nsp > 0) {
|
|
var prefix = a3.prefix = qName.slice(0, nsp);
|
|
var localName = qName.slice(nsp + 1);
|
|
var nsPrefix = prefix === "xmlns" && localName;
|
|
} else {
|
|
localName = qName;
|
|
prefix = null;
|
|
nsPrefix = qName === "xmlns" && "";
|
|
}
|
|
a3.localName = localName;
|
|
if (nsPrefix !== false) {
|
|
if (localNSMap == null) {
|
|
localNSMap = {};
|
|
_copy(currentNSMap, currentNSMap = {});
|
|
}
|
|
currentNSMap[nsPrefix] = localNSMap[nsPrefix] = value;
|
|
a3.uri = "http://www.w3.org/2000/xmlns/";
|
|
domBuilder.startPrefixMapping(nsPrefix, value);
|
|
}
|
|
}
|
|
var i3 = el.length;
|
|
while (i3--) {
|
|
a3 = el[i3];
|
|
var prefix = a3.prefix;
|
|
if (prefix) {
|
|
if (prefix === "xml") {
|
|
a3.uri = "http://www.w3.org/XML/1998/namespace";
|
|
}
|
|
if (prefix !== "xmlns") {
|
|
a3.uri = currentNSMap[prefix || ""];
|
|
}
|
|
}
|
|
}
|
|
var nsp = tagName.indexOf(":");
|
|
if (nsp > 0) {
|
|
prefix = el.prefix = tagName.slice(0, nsp);
|
|
localName = el.localName = tagName.slice(nsp + 1);
|
|
} else {
|
|
prefix = null;
|
|
localName = el.localName = tagName;
|
|
}
|
|
var ns2 = el.uri = currentNSMap[prefix || ""];
|
|
domBuilder.startElement(ns2, localName, tagName, el);
|
|
if (el.closed) {
|
|
domBuilder.endElement(ns2, localName, tagName);
|
|
if (localNSMap) {
|
|
for (prefix in localNSMap) {
|
|
domBuilder.endPrefixMapping(prefix);
|
|
}
|
|
}
|
|
} else {
|
|
el.currentNSMap = currentNSMap;
|
|
el.localNSMap = localNSMap;
|
|
return true;
|
|
}
|
|
}
|
|
function parseHtmlSpecialContent(source, elStartEnd, tagName, entityReplacer, domBuilder) {
|
|
if (/^(?:script|textarea)$/i.test(tagName)) {
|
|
var elEndStart = source.indexOf("</" + tagName + ">", elStartEnd);
|
|
var text = source.substring(elStartEnd + 1, elEndStart);
|
|
if (/[&<]/.test(text)) {
|
|
if (/^script$/i.test(tagName)) {
|
|
domBuilder.characters(text, 0, text.length);
|
|
return elEndStart;
|
|
}
|
|
text = text.replace(/&#?\w+;/g, entityReplacer);
|
|
domBuilder.characters(text, 0, text.length);
|
|
return elEndStart;
|
|
}
|
|
}
|
|
return elStartEnd + 1;
|
|
}
|
|
function fixSelfClosed(source, elStartEnd, tagName, closeMap) {
|
|
var pos = closeMap[tagName];
|
|
if (pos == null) {
|
|
pos = source.lastIndexOf("</" + tagName + ">");
|
|
if (pos < elStartEnd) {
|
|
pos = source.lastIndexOf("</" + tagName);
|
|
}
|
|
closeMap[tagName] = pos;
|
|
}
|
|
return pos < elStartEnd;
|
|
}
|
|
function _copy(source, target) {
|
|
for (var n2 in source) {
|
|
target[n2] = source[n2];
|
|
}
|
|
}
|
|
function parseDCC(source, start, domBuilder, errorHandler) {
|
|
var next = source.charAt(start + 2);
|
|
switch (next) {
|
|
case "-":
|
|
if (source.charAt(start + 3) === "-") {
|
|
var end = source.indexOf("-->", start + 4);
|
|
if (end > start) {
|
|
domBuilder.comment(source, start + 4, end - start - 4);
|
|
return end + 3;
|
|
} else {
|
|
errorHandler.error("Unclosed comment");
|
|
return -1;
|
|
}
|
|
} else {
|
|
return -1;
|
|
}
|
|
default:
|
|
if (source.substr(start + 3, 6) == "CDATA[") {
|
|
var end = source.indexOf("]]>", start + 9);
|
|
domBuilder.startCDATA();
|
|
domBuilder.characters(source, start + 9, end - start - 9);
|
|
domBuilder.endCDATA();
|
|
return end + 3;
|
|
}
|
|
var matchs = split(source, start);
|
|
var len = matchs.length;
|
|
if (len > 1 && /!doctype/i.test(matchs[0][0])) {
|
|
var name = matchs[1][0];
|
|
var pubid = len > 3 && /^public$/i.test(matchs[2][0]) && matchs[3][0];
|
|
var sysid = len > 4 && matchs[4][0];
|
|
var lastMatch = matchs[len - 1];
|
|
domBuilder.startDTD(name, pubid && pubid.replace(/^(['"])(.*?)\1$/, "$2"), sysid && sysid.replace(/^(['"])(.*?)\1$/, "$2"));
|
|
domBuilder.endDTD();
|
|
return lastMatch.index + lastMatch[0].length;
|
|
}
|
|
}
|
|
return -1;
|
|
}
|
|
function parseInstruction(source, start, domBuilder) {
|
|
var end = source.indexOf("?>", start);
|
|
if (end) {
|
|
var match = source.substring(start, end).match(/^<\?(\S*)\s*([\s\S]*?)\s*$/);
|
|
if (match) {
|
|
var len = match[0].length;
|
|
domBuilder.processingInstruction(match[1], match[2]);
|
|
return end + 2;
|
|
} else {
|
|
return -1;
|
|
}
|
|
}
|
|
return -1;
|
|
}
|
|
function ElementAttributes(source) {
|
|
}
|
|
ElementAttributes.prototype = {
|
|
setTagName: function(tagName) {
|
|
if (!tagNamePattern.test(tagName)) {
|
|
throw new Error("invalid tagName:" + tagName);
|
|
}
|
|
this.tagName = tagName;
|
|
},
|
|
add: function(qName, value, offset) {
|
|
if (!tagNamePattern.test(qName)) {
|
|
throw new Error("invalid attribute:" + qName);
|
|
}
|
|
this[this.length++] = { qName, value, offset };
|
|
},
|
|
length: 0,
|
|
getLocalName: function(i3) {
|
|
return this[i3].localName;
|
|
},
|
|
getLocator: function(i3) {
|
|
return this[i3].locator;
|
|
},
|
|
getQName: function(i3) {
|
|
return this[i3].qName;
|
|
},
|
|
getURI: function(i3) {
|
|
return this[i3].uri;
|
|
},
|
|
getValue: function(i3) {
|
|
return this[i3].value;
|
|
}
|
|
};
|
|
function _set_proto_(thiz, parent) {
|
|
thiz.__proto__ = parent;
|
|
return thiz;
|
|
}
|
|
if (!(_set_proto_({}, _set_proto_.prototype) instanceof _set_proto_)) {
|
|
_set_proto_ = function(thiz, parent) {
|
|
function p3() {
|
|
}
|
|
;
|
|
p3.prototype = parent;
|
|
p3 = new p3();
|
|
for (parent in thiz) {
|
|
p3[parent] = thiz[parent];
|
|
}
|
|
return p3;
|
|
};
|
|
}
|
|
function split(source, start) {
|
|
var match;
|
|
var buf = [];
|
|
var reg = /'[^']+'|"[^"]+"|[^\s<>\/=]+=?|(\/?\s*>|<)/g;
|
|
reg.lastIndex = start;
|
|
reg.exec(source);
|
|
while (match = reg.exec(source)) {
|
|
buf.push(match);
|
|
if (match[1])
|
|
return buf;
|
|
}
|
|
}
|
|
exports3.XMLReader = XMLReader;
|
|
}, {}], 33: [function(require2, module4, exports3) {
|
|
module4.exports = {
|
|
"name": "dav",
|
|
"version": "1.8.0",
|
|
"author": "Gareth Aye [:gaye] <gaye@mozilla.com>",
|
|
"description": "WebDAV, CalDAV, and CardDAV client for nodejs and the browser",
|
|
"license": "MPL-2.0",
|
|
"main": "./dav.js",
|
|
"repository": "https://github.com/gaye/dav",
|
|
"keywords": [
|
|
"address book",
|
|
"calendar",
|
|
"contacts",
|
|
"dav",
|
|
"caldav",
|
|
"carddav",
|
|
"webdav",
|
|
"ical",
|
|
"vcard",
|
|
"sync",
|
|
"rfc 4791",
|
|
"rfc 6352",
|
|
"rfc 6578"
|
|
],
|
|
"dependencies": {
|
|
"co": "^4.6.0",
|
|
"xmldom": "^0.1.19",
|
|
"xmlhttprequest": "^1.7.0"
|
|
},
|
|
"devDependencies": {
|
|
"babel": "^5.8.23",
|
|
"browserify": "^11.0.1",
|
|
"chai": "^3.2.0",
|
|
"doctoc": "^0.15.0",
|
|
"mocha": "^2.3.2",
|
|
"nock": "^2.10.0",
|
|
"sinon": "^1.16.1",
|
|
"tcp-port-used": "^0.1.2",
|
|
"uglify-js": "^2.4.24"
|
|
},
|
|
"scripts": {
|
|
"test": "make test"
|
|
}
|
|
};
|
|
}, {}] }, {}, [8])(8);
|
|
});
|
|
}
|
|
});
|
|
|
|
// node_modules/co/index.js
|
|
var require_co = __commonJS({
|
|
"node_modules/co/index.js"(exports, module2) {
|
|
var slice = Array.prototype.slice;
|
|
module2.exports = co2["default"] = co2.co = co2;
|
|
co2.wrap = function(fn) {
|
|
createPromise.__generatorFunction__ = fn;
|
|
return createPromise;
|
|
function createPromise() {
|
|
return co2.call(this, fn.apply(this, arguments));
|
|
}
|
|
};
|
|
function co2(gen) {
|
|
var ctx = this;
|
|
var args = slice.call(arguments, 1);
|
|
return new Promise(function(resolve, reject) {
|
|
if (typeof gen === "function")
|
|
gen = gen.apply(ctx, args);
|
|
if (!gen || typeof gen.next !== "function")
|
|
return resolve(gen);
|
|
onFulfilled();
|
|
function onFulfilled(res) {
|
|
var ret;
|
|
try {
|
|
ret = gen.next(res);
|
|
} catch (e3) {
|
|
return reject(e3);
|
|
}
|
|
next(ret);
|
|
}
|
|
function onRejected(err) {
|
|
var ret;
|
|
try {
|
|
ret = gen.throw(err);
|
|
} catch (e3) {
|
|
return reject(e3);
|
|
}
|
|
next(ret);
|
|
}
|
|
function next(ret) {
|
|
if (ret.done)
|
|
return resolve(ret.value);
|
|
var value = toPromise.call(ctx, ret.value);
|
|
if (value && isPromise(value))
|
|
return value.then(onFulfilled, onRejected);
|
|
return onRejected(new TypeError('You may only yield a function, promise, generator, array, or object, but the following object was passed: "' + String(ret.value) + '"'));
|
|
}
|
|
});
|
|
}
|
|
function toPromise(obj) {
|
|
if (!obj)
|
|
return obj;
|
|
if (isPromise(obj))
|
|
return obj;
|
|
if (isGeneratorFunction(obj) || isGenerator(obj))
|
|
return co2.call(this, obj);
|
|
if (typeof obj == "function")
|
|
return thunkToPromise.call(this, obj);
|
|
if (Array.isArray(obj))
|
|
return arrayToPromise.call(this, obj);
|
|
if (isObject(obj))
|
|
return objectToPromise.call(this, obj);
|
|
return obj;
|
|
}
|
|
function thunkToPromise(fn) {
|
|
var ctx = this;
|
|
return new Promise(function(resolve, reject) {
|
|
fn.call(ctx, function(err, res) {
|
|
if (err)
|
|
return reject(err);
|
|
if (arguments.length > 2)
|
|
res = slice.call(arguments, 1);
|
|
resolve(res);
|
|
});
|
|
});
|
|
}
|
|
function arrayToPromise(obj) {
|
|
return Promise.all(obj.map(toPromise, this));
|
|
}
|
|
function objectToPromise(obj) {
|
|
var results = new obj.constructor();
|
|
var keys = Object.keys(obj);
|
|
var promises = [];
|
|
for (var i3 = 0; i3 < keys.length; i3++) {
|
|
var key = keys[i3];
|
|
var promise = toPromise.call(this, obj[key]);
|
|
if (promise && isPromise(promise))
|
|
defer(promise, key);
|
|
else
|
|
results[key] = obj[key];
|
|
}
|
|
return Promise.all(promises).then(function() {
|
|
return results;
|
|
});
|
|
function defer(promise2, key2) {
|
|
results[key2] = void 0;
|
|
promises.push(promise2.then(function(res) {
|
|
results[key2] = res;
|
|
}));
|
|
}
|
|
}
|
|
function isPromise(obj) {
|
|
return typeof obj.then == "function";
|
|
}
|
|
function isGenerator(obj) {
|
|
return typeof obj.next == "function" && typeof obj.throw == "function";
|
|
}
|
|
function isGeneratorFunction(obj) {
|
|
var constructor = obj.constructor;
|
|
if (!constructor)
|
|
return false;
|
|
if (constructor.name === "GeneratorFunction" || constructor.displayName === "GeneratorFunction")
|
|
return true;
|
|
return isGenerator(constructor.prototype);
|
|
}
|
|
function isObject(val) {
|
|
return Object == val.constructor;
|
|
}
|
|
}
|
|
});
|
|
|
|
// src/main.ts
|
|
__export(exports, {
|
|
default: () => FullCalendarPlugin
|
|
});
|
|
var import_obsidian8 = __toModule(require("obsidian"));
|
|
|
|
// src/view.ts
|
|
var import_obsidian7 = __toModule(require("obsidian"));
|
|
|
|
// node_modules/tslib/modules/index.js
|
|
var import_tslib = __toModule(require_tslib());
|
|
var {
|
|
__extends,
|
|
__assign,
|
|
__rest,
|
|
__decorate,
|
|
__param,
|
|
__metadata,
|
|
__awaiter,
|
|
__generator,
|
|
__exportStar,
|
|
__createBinding,
|
|
__values,
|
|
__read,
|
|
__spread,
|
|
__spreadArrays,
|
|
__spreadArray,
|
|
__await,
|
|
__asyncGenerator,
|
|
__asyncDelegator,
|
|
__asyncValues,
|
|
__makeTemplateObject,
|
|
__importStar,
|
|
__importDefault,
|
|
__classPrivateFieldGet,
|
|
__classPrivateFieldSet
|
|
} = import_tslib.default;
|
|
|
|
// node_modules/preact/dist/preact.module.js
|
|
var n;
|
|
var l;
|
|
var u;
|
|
var i;
|
|
var t;
|
|
var o;
|
|
var r;
|
|
var f;
|
|
var e = {};
|
|
var c = [];
|
|
var s = /acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i;
|
|
function a(n2, l3) {
|
|
for (var u3 in l3)
|
|
n2[u3] = l3[u3];
|
|
return n2;
|
|
}
|
|
function h(n2) {
|
|
var l3 = n2.parentNode;
|
|
l3 && l3.removeChild(n2);
|
|
}
|
|
function v(l3, u3, i3) {
|
|
var t3, o2, r3, f3 = {};
|
|
for (r3 in u3)
|
|
r3 == "key" ? t3 = u3[r3] : r3 == "ref" ? o2 = u3[r3] : f3[r3] = u3[r3];
|
|
if (arguments.length > 2 && (f3.children = arguments.length > 3 ? n.call(arguments, 2) : i3), typeof l3 == "function" && l3.defaultProps != null)
|
|
for (r3 in l3.defaultProps)
|
|
f3[r3] === void 0 && (f3[r3] = l3.defaultProps[r3]);
|
|
return y(l3, f3, t3, o2, null);
|
|
}
|
|
function y(n2, i3, t3, o2, r3) {
|
|
var f3 = { type: n2, props: i3, key: t3, ref: o2, __k: null, __: null, __b: 0, __e: null, __d: void 0, __c: null, __h: null, constructor: void 0, __v: r3 == null ? ++u : r3 };
|
|
return r3 == null && l.vnode != null && l.vnode(f3), f3;
|
|
}
|
|
function p() {
|
|
return { current: null };
|
|
}
|
|
function d(n2) {
|
|
return n2.children;
|
|
}
|
|
function _(n2, l3) {
|
|
this.props = n2, this.context = l3;
|
|
}
|
|
function k(n2, l3) {
|
|
if (l3 == null)
|
|
return n2.__ ? k(n2.__, n2.__.__k.indexOf(n2) + 1) : null;
|
|
for (var u3; l3 < n2.__k.length; l3++)
|
|
if ((u3 = n2.__k[l3]) != null && u3.__e != null)
|
|
return u3.__e;
|
|
return typeof n2.type == "function" ? k(n2) : null;
|
|
}
|
|
function b(n2) {
|
|
var l3, u3;
|
|
if ((n2 = n2.__) != null && n2.__c != null) {
|
|
for (n2.__e = n2.__c.base = null, l3 = 0; l3 < n2.__k.length; l3++)
|
|
if ((u3 = n2.__k[l3]) != null && u3.__e != null) {
|
|
n2.__e = n2.__c.base = u3.__e;
|
|
break;
|
|
}
|
|
return b(n2);
|
|
}
|
|
}
|
|
function m(n2) {
|
|
(!n2.__d && (n2.__d = true) && t.push(n2) && !g.__r++ || r !== l.debounceRendering) && ((r = l.debounceRendering) || o)(g);
|
|
}
|
|
function g() {
|
|
for (var n2; g.__r = t.length; )
|
|
n2 = t.sort(function(n3, l3) {
|
|
return n3.__v.__b - l3.__v.__b;
|
|
}), t = [], n2.some(function(n3) {
|
|
var l3, u3, i3, t3, o2, r3;
|
|
n3.__d && (o2 = (t3 = (l3 = n3).__v).__e, (r3 = l3.__P) && (u3 = [], (i3 = a({}, t3)).__v = t3.__v + 1, j(r3, t3, i3, l3.__n, r3.ownerSVGElement !== void 0, t3.__h != null ? [o2] : null, u3, o2 == null ? k(t3) : o2, t3.__h), z(u3, t3), t3.__e != o2 && b(t3)));
|
|
});
|
|
}
|
|
function w(n2, l3, u3, i3, t3, o2, r3, f3, s3, a3) {
|
|
var h3, v3, p3, _3, b3, m2, g3, w3 = i3 && i3.__k || c, A4 = w3.length;
|
|
for (u3.__k = [], h3 = 0; h3 < l3.length; h3++)
|
|
if ((_3 = u3.__k[h3] = (_3 = l3[h3]) == null || typeof _3 == "boolean" ? null : typeof _3 == "string" || typeof _3 == "number" || typeof _3 == "bigint" ? y(null, _3, null, null, _3) : Array.isArray(_3) ? y(d, { children: _3 }, null, null, null) : _3.__b > 0 ? y(_3.type, _3.props, _3.key, null, _3.__v) : _3) != null) {
|
|
if (_3.__ = u3, _3.__b = u3.__b + 1, (p3 = w3[h3]) === null || p3 && _3.key == p3.key && _3.type === p3.type)
|
|
w3[h3] = void 0;
|
|
else
|
|
for (v3 = 0; v3 < A4; v3++) {
|
|
if ((p3 = w3[v3]) && _3.key == p3.key && _3.type === p3.type) {
|
|
w3[v3] = void 0;
|
|
break;
|
|
}
|
|
p3 = null;
|
|
}
|
|
j(n2, _3, p3 = p3 || e, t3, o2, r3, f3, s3, a3), b3 = _3.__e, (v3 = _3.ref) && p3.ref != v3 && (g3 || (g3 = []), p3.ref && g3.push(p3.ref, null, _3), g3.push(v3, _3.__c || b3, _3)), b3 != null ? (m2 == null && (m2 = b3), typeof _3.type == "function" && _3.__k === p3.__k ? _3.__d = s3 = x(_3, s3, n2) : s3 = P(n2, _3, p3, w3, b3, s3), typeof u3.type == "function" && (u3.__d = s3)) : s3 && p3.__e == s3 && s3.parentNode != n2 && (s3 = k(p3));
|
|
}
|
|
for (u3.__e = m2, h3 = A4; h3--; )
|
|
w3[h3] != null && (typeof u3.type == "function" && w3[h3].__e != null && w3[h3].__e == u3.__d && (u3.__d = k(i3, h3 + 1)), N(w3[h3], w3[h3]));
|
|
if (g3)
|
|
for (h3 = 0; h3 < g3.length; h3++)
|
|
M(g3[h3], g3[++h3], g3[++h3]);
|
|
}
|
|
function x(n2, l3, u3) {
|
|
for (var i3, t3 = n2.__k, o2 = 0; t3 && o2 < t3.length; o2++)
|
|
(i3 = t3[o2]) && (i3.__ = n2, l3 = typeof i3.type == "function" ? x(i3, l3, u3) : P(u3, i3, i3, t3, i3.__e, l3));
|
|
return l3;
|
|
}
|
|
function A(n2, l3) {
|
|
return l3 = l3 || [], n2 == null || typeof n2 == "boolean" || (Array.isArray(n2) ? n2.some(function(n3) {
|
|
A(n3, l3);
|
|
}) : l3.push(n2)), l3;
|
|
}
|
|
function P(n2, l3, u3, i3, t3, o2) {
|
|
var r3, f3, e3;
|
|
if (l3.__d !== void 0)
|
|
r3 = l3.__d, l3.__d = void 0;
|
|
else if (u3 == null || t3 != o2 || t3.parentNode == null)
|
|
n:
|
|
if (o2 == null || o2.parentNode !== n2)
|
|
n2.appendChild(t3), r3 = null;
|
|
else {
|
|
for (f3 = o2, e3 = 0; (f3 = f3.nextSibling) && e3 < i3.length; e3 += 2)
|
|
if (f3 == t3)
|
|
break n;
|
|
n2.insertBefore(t3, o2), r3 = o2;
|
|
}
|
|
return r3 !== void 0 ? r3 : t3.nextSibling;
|
|
}
|
|
function C(n2, l3, u3, i3, t3) {
|
|
var o2;
|
|
for (o2 in u3)
|
|
o2 === "children" || o2 === "key" || o2 in l3 || H(n2, o2, null, u3[o2], i3);
|
|
for (o2 in l3)
|
|
t3 && typeof l3[o2] != "function" || o2 === "children" || o2 === "key" || o2 === "value" || o2 === "checked" || u3[o2] === l3[o2] || H(n2, o2, l3[o2], u3[o2], i3);
|
|
}
|
|
function $(n2, l3, u3) {
|
|
l3[0] === "-" ? n2.setProperty(l3, u3) : n2[l3] = u3 == null ? "" : typeof u3 != "number" || s.test(l3) ? u3 : u3 + "px";
|
|
}
|
|
function H(n2, l3, u3, i3, t3) {
|
|
var o2;
|
|
n:
|
|
if (l3 === "style")
|
|
if (typeof u3 == "string")
|
|
n2.style.cssText = u3;
|
|
else {
|
|
if (typeof i3 == "string" && (n2.style.cssText = i3 = ""), i3)
|
|
for (l3 in i3)
|
|
u3 && l3 in u3 || $(n2.style, l3, "");
|
|
if (u3)
|
|
for (l3 in u3)
|
|
i3 && u3[l3] === i3[l3] || $(n2.style, l3, u3[l3]);
|
|
}
|
|
else if (l3[0] === "o" && l3[1] === "n")
|
|
o2 = l3 !== (l3 = l3.replace(/Capture$/, "")), l3 = l3.toLowerCase() in n2 ? l3.toLowerCase().slice(2) : l3.slice(2), n2.l || (n2.l = {}), n2.l[l3 + o2] = u3, u3 ? i3 || n2.addEventListener(l3, o2 ? T : I, o2) : n2.removeEventListener(l3, o2 ? T : I, o2);
|
|
else if (l3 !== "dangerouslySetInnerHTML") {
|
|
if (t3)
|
|
l3 = l3.replace(/xlink[H:h]/, "h").replace(/sName$/, "s");
|
|
else if (l3 !== "href" && l3 !== "list" && l3 !== "form" && l3 !== "tabIndex" && l3 !== "download" && l3 in n2)
|
|
try {
|
|
n2[l3] = u3 == null ? "" : u3;
|
|
break n;
|
|
} catch (n3) {
|
|
}
|
|
typeof u3 == "function" || (u3 != null && (u3 !== false || l3[0] === "a" && l3[1] === "r") ? n2.setAttribute(l3, u3) : n2.removeAttribute(l3));
|
|
}
|
|
}
|
|
function I(n2) {
|
|
this.l[n2.type + false](l.event ? l.event(n2) : n2);
|
|
}
|
|
function T(n2) {
|
|
this.l[n2.type + true](l.event ? l.event(n2) : n2);
|
|
}
|
|
function j(n2, u3, i3, t3, o2, r3, f3, e3, c3) {
|
|
var s3, h3, v3, y3, p3, k2, b3, m2, g3, x3, A4, P3 = u3.type;
|
|
if (u3.constructor !== void 0)
|
|
return null;
|
|
i3.__h != null && (c3 = i3.__h, e3 = u3.__e = i3.__e, u3.__h = null, r3 = [e3]), (s3 = l.__b) && s3(u3);
|
|
try {
|
|
n:
|
|
if (typeof P3 == "function") {
|
|
if (m2 = u3.props, g3 = (s3 = P3.contextType) && t3[s3.__c], x3 = s3 ? g3 ? g3.props.value : s3.__ : t3, i3.__c ? b3 = (h3 = u3.__c = i3.__c).__ = h3.__E : ("prototype" in P3 && P3.prototype.render ? u3.__c = h3 = new P3(m2, x3) : (u3.__c = h3 = new _(m2, x3), h3.constructor = P3, h3.render = O), g3 && g3.sub(h3), h3.props = m2, h3.state || (h3.state = {}), h3.context = x3, h3.__n = t3, v3 = h3.__d = true, h3.__h = []), h3.__s == null && (h3.__s = h3.state), P3.getDerivedStateFromProps != null && (h3.__s == h3.state && (h3.__s = a({}, h3.__s)), a(h3.__s, P3.getDerivedStateFromProps(m2, h3.__s))), y3 = h3.props, p3 = h3.state, v3)
|
|
P3.getDerivedStateFromProps == null && h3.componentWillMount != null && h3.componentWillMount(), h3.componentDidMount != null && h3.__h.push(h3.componentDidMount);
|
|
else {
|
|
if (P3.getDerivedStateFromProps == null && m2 !== y3 && h3.componentWillReceiveProps != null && h3.componentWillReceiveProps(m2, x3), !h3.__e && h3.shouldComponentUpdate != null && h3.shouldComponentUpdate(m2, h3.__s, x3) === false || u3.__v === i3.__v) {
|
|
h3.props = m2, h3.state = h3.__s, u3.__v !== i3.__v && (h3.__d = false), h3.__v = u3, u3.__e = i3.__e, u3.__k = i3.__k, u3.__k.forEach(function(n3) {
|
|
n3 && (n3.__ = u3);
|
|
}), h3.__h.length && f3.push(h3);
|
|
break n;
|
|
}
|
|
h3.componentWillUpdate != null && h3.componentWillUpdate(m2, h3.__s, x3), h3.componentDidUpdate != null && h3.__h.push(function() {
|
|
h3.componentDidUpdate(y3, p3, k2);
|
|
});
|
|
}
|
|
h3.context = x3, h3.props = m2, h3.state = h3.__s, (s3 = l.__r) && s3(u3), h3.__d = false, h3.__v = u3, h3.__P = n2, s3 = h3.render(h3.props, h3.state, h3.context), h3.state = h3.__s, h3.getChildContext != null && (t3 = a(a({}, t3), h3.getChildContext())), v3 || h3.getSnapshotBeforeUpdate == null || (k2 = h3.getSnapshotBeforeUpdate(y3, p3)), A4 = s3 != null && s3.type === d && s3.key == null ? s3.props.children : s3, w(n2, Array.isArray(A4) ? A4 : [A4], u3, i3, t3, o2, r3, f3, e3, c3), h3.base = u3.__e, u3.__h = null, h3.__h.length && f3.push(h3), b3 && (h3.__E = h3.__ = null), h3.__e = false;
|
|
} else
|
|
r3 == null && u3.__v === i3.__v ? (u3.__k = i3.__k, u3.__e = i3.__e) : u3.__e = L(i3.__e, u3, i3, t3, o2, r3, f3, c3);
|
|
(s3 = l.diffed) && s3(u3);
|
|
} catch (n3) {
|
|
u3.__v = null, (c3 || r3 != null) && (u3.__e = e3, u3.__h = !!c3, r3[r3.indexOf(e3)] = null), l.__e(n3, u3, i3);
|
|
}
|
|
}
|
|
function z(n2, u3) {
|
|
l.__c && l.__c(u3, n2), n2.some(function(u4) {
|
|
try {
|
|
n2 = u4.__h, u4.__h = [], n2.some(function(n3) {
|
|
n3.call(u4);
|
|
});
|
|
} catch (n3) {
|
|
l.__e(n3, u4.__v);
|
|
}
|
|
});
|
|
}
|
|
function L(l3, u3, i3, t3, o2, r3, f3, c3) {
|
|
var s3, a3, v3, y3 = i3.props, p3 = u3.props, d3 = u3.type, _3 = 0;
|
|
if (d3 === "svg" && (o2 = true), r3 != null) {
|
|
for (; _3 < r3.length; _3++)
|
|
if ((s3 = r3[_3]) && "setAttribute" in s3 == !!d3 && (d3 ? s3.localName === d3 : s3.nodeType === 3)) {
|
|
l3 = s3, r3[_3] = null;
|
|
break;
|
|
}
|
|
}
|
|
if (l3 == null) {
|
|
if (d3 === null)
|
|
return document.createTextNode(p3);
|
|
l3 = o2 ? document.createElementNS("http://www.w3.org/2000/svg", d3) : document.createElement(d3, p3.is && p3), r3 = null, c3 = false;
|
|
}
|
|
if (d3 === null)
|
|
y3 === p3 || c3 && l3.data === p3 || (l3.data = p3);
|
|
else {
|
|
if (r3 = r3 && n.call(l3.childNodes), a3 = (y3 = i3.props || e).dangerouslySetInnerHTML, v3 = p3.dangerouslySetInnerHTML, !c3) {
|
|
if (r3 != null)
|
|
for (y3 = {}, _3 = 0; _3 < l3.attributes.length; _3++)
|
|
y3[l3.attributes[_3].name] = l3.attributes[_3].value;
|
|
(v3 || a3) && (v3 && (a3 && v3.__html == a3.__html || v3.__html === l3.innerHTML) || (l3.innerHTML = v3 && v3.__html || ""));
|
|
}
|
|
if (C(l3, p3, y3, o2, c3), v3)
|
|
u3.__k = [];
|
|
else if (_3 = u3.props.children, w(l3, Array.isArray(_3) ? _3 : [_3], u3, i3, t3, o2 && d3 !== "foreignObject", r3, f3, r3 ? r3[0] : i3.__k && k(i3, 0), c3), r3 != null)
|
|
for (_3 = r3.length; _3--; )
|
|
r3[_3] != null && h(r3[_3]);
|
|
c3 || ("value" in p3 && (_3 = p3.value) !== void 0 && (_3 !== l3.value || d3 === "progress" && !_3 || d3 === "option" && _3 !== y3.value) && H(l3, "value", _3, y3.value, false), "checked" in p3 && (_3 = p3.checked) !== void 0 && _3 !== l3.checked && H(l3, "checked", _3, y3.checked, false));
|
|
}
|
|
return l3;
|
|
}
|
|
function M(n2, u3, i3) {
|
|
try {
|
|
typeof n2 == "function" ? n2(u3) : n2.current = u3;
|
|
} catch (n3) {
|
|
l.__e(n3, i3);
|
|
}
|
|
}
|
|
function N(n2, u3, i3) {
|
|
var t3, o2;
|
|
if (l.unmount && l.unmount(n2), (t3 = n2.ref) && (t3.current && t3.current !== n2.__e || M(t3, null, u3)), (t3 = n2.__c) != null) {
|
|
if (t3.componentWillUnmount)
|
|
try {
|
|
t3.componentWillUnmount();
|
|
} catch (n3) {
|
|
l.__e(n3, u3);
|
|
}
|
|
t3.base = t3.__P = null;
|
|
}
|
|
if (t3 = n2.__k)
|
|
for (o2 = 0; o2 < t3.length; o2++)
|
|
t3[o2] && N(t3[o2], u3, typeof n2.type != "function");
|
|
i3 || n2.__e == null || h(n2.__e), n2.__e = n2.__d = void 0;
|
|
}
|
|
function O(n2, l3, u3) {
|
|
return this.constructor(n2, u3);
|
|
}
|
|
function S(u3, i3, t3) {
|
|
var o2, r3, f3;
|
|
l.__ && l.__(u3, i3), r3 = (o2 = typeof t3 == "function") ? null : t3 && t3.__k || i3.__k, f3 = [], j(i3, u3 = (!o2 && t3 || i3).__k = v(d, null, [u3]), r3 || e, e, i3.ownerSVGElement !== void 0, !o2 && t3 ? [t3] : r3 ? null : i3.firstChild ? n.call(i3.childNodes) : null, f3, !o2 && t3 ? t3 : r3 ? r3.__e : i3.firstChild, o2), z(f3, u3);
|
|
}
|
|
function D(n2, l3) {
|
|
var u3 = { __c: l3 = "__cC" + f++, __: n2, Consumer: function(n3, l4) {
|
|
return n3.children(l4);
|
|
}, Provider: function(n3) {
|
|
var u4, i3;
|
|
return this.getChildContext || (u4 = [], (i3 = {})[l3] = this, this.getChildContext = function() {
|
|
return i3;
|
|
}, this.shouldComponentUpdate = function(n4) {
|
|
this.props.value !== n4.value && u4.some(m);
|
|
}, this.sub = function(n4) {
|
|
u4.push(n4);
|
|
var l4 = n4.componentWillUnmount;
|
|
n4.componentWillUnmount = function() {
|
|
u4.splice(u4.indexOf(n4), 1), l4 && l4.call(n4);
|
|
};
|
|
}), n3.children;
|
|
} };
|
|
return u3.Provider.__ = u3.Consumer.contextType = u3;
|
|
}
|
|
n = c.slice, l = { __e: function(n2, l3) {
|
|
for (var u3, i3, t3; l3 = l3.__; )
|
|
if ((u3 = l3.__c) && !u3.__)
|
|
try {
|
|
if ((i3 = u3.constructor) && i3.getDerivedStateFromError != null && (u3.setState(i3.getDerivedStateFromError(n2)), t3 = u3.__d), u3.componentDidCatch != null && (u3.componentDidCatch(n2), t3 = u3.__d), t3)
|
|
return u3.__E = u3;
|
|
} catch (l4) {
|
|
n2 = l4;
|
|
}
|
|
throw n2;
|
|
} }, u = 0, i = function(n2) {
|
|
return n2 != null && n2.constructor === void 0;
|
|
}, _.prototype.setState = function(n2, l3) {
|
|
var u3;
|
|
u3 = this.__s != null && this.__s !== this.state ? this.__s : this.__s = a({}, this.state), typeof n2 == "function" && (n2 = n2(a({}, u3), this.props)), n2 && a(u3, n2), n2 != null && this.__v && (l3 && this.__h.push(l3), m(this));
|
|
}, _.prototype.forceUpdate = function(n2) {
|
|
this.__v && (this.__e = true, n2 && this.__h.push(n2), m(this));
|
|
}, _.prototype.render = d, t = [], o = typeof Promise == "function" ? Promise.prototype.then.bind(Promise.resolve()) : setTimeout, g.__r = 0, f = 0;
|
|
|
|
// node_modules/preact/hooks/dist/hooks.module.js
|
|
var t2;
|
|
var u2;
|
|
var r2;
|
|
var i2 = [];
|
|
var c2 = l.__b;
|
|
var f2 = l.__r;
|
|
var e2 = l.diffed;
|
|
var a2 = l.__c;
|
|
var v2 = l.unmount;
|
|
function x2() {
|
|
for (var t3; t3 = i2.shift(); )
|
|
if (t3.__P)
|
|
try {
|
|
t3.__H.__h.forEach(g2), t3.__H.__h.forEach(j2), t3.__H.__h = [];
|
|
} catch (u3) {
|
|
t3.__H.__h = [], l.__e(u3, t3.__v);
|
|
}
|
|
}
|
|
l.__b = function(n2) {
|
|
u2 = null, c2 && c2(n2);
|
|
}, l.__r = function(n2) {
|
|
f2 && f2(n2), t2 = 0;
|
|
var r3 = (u2 = n2.__c).__H;
|
|
r3 && (r3.__h.forEach(g2), r3.__h.forEach(j2), r3.__h = []);
|
|
}, l.diffed = function(t3) {
|
|
e2 && e2(t3);
|
|
var o2 = t3.__c;
|
|
o2 && o2.__H && o2.__H.__h.length && (i2.push(o2) !== 1 && r2 === l.requestAnimationFrame || ((r2 = l.requestAnimationFrame) || function(n2) {
|
|
var t4, u3 = function() {
|
|
clearTimeout(r3), b2 && cancelAnimationFrame(t4), setTimeout(n2);
|
|
}, r3 = setTimeout(u3, 100);
|
|
b2 && (t4 = requestAnimationFrame(u3));
|
|
})(x2)), u2 = null;
|
|
}, l.__c = function(t3, u3) {
|
|
u3.some(function(t4) {
|
|
try {
|
|
t4.__h.forEach(g2), t4.__h = t4.__h.filter(function(n2) {
|
|
return !n2.__ || j2(n2);
|
|
});
|
|
} catch (r3) {
|
|
u3.some(function(n2) {
|
|
n2.__h && (n2.__h = []);
|
|
}), u3 = [], l.__e(r3, t4.__v);
|
|
}
|
|
}), a2 && a2(t3, u3);
|
|
}, l.unmount = function(t3) {
|
|
v2 && v2(t3);
|
|
var u3, r3 = t3.__c;
|
|
r3 && r3.__H && (r3.__H.__.forEach(function(n2) {
|
|
try {
|
|
g2(n2);
|
|
} catch (n3) {
|
|
u3 = n3;
|
|
}
|
|
}), u3 && l.__e(u3, r3.__v));
|
|
};
|
|
var b2 = typeof requestAnimationFrame == "function";
|
|
function g2(n2) {
|
|
var t3 = u2, r3 = n2.__c;
|
|
typeof r3 == "function" && (n2.__c = void 0, r3()), u2 = t3;
|
|
}
|
|
function j2(n2) {
|
|
var t3 = u2;
|
|
n2.__c = n2.__(), u2 = t3;
|
|
}
|
|
|
|
// node_modules/preact/compat/dist/compat.module.js
|
|
function C2(n2, t3) {
|
|
for (var e3 in t3)
|
|
n2[e3] = t3[e3];
|
|
return n2;
|
|
}
|
|
function S2(n2, t3) {
|
|
for (var e3 in n2)
|
|
if (e3 !== "__source" && !(e3 in t3))
|
|
return true;
|
|
for (var r3 in t3)
|
|
if (r3 !== "__source" && n2[r3] !== t3[r3])
|
|
return true;
|
|
return false;
|
|
}
|
|
function E(n2) {
|
|
this.props = n2;
|
|
}
|
|
(E.prototype = new _()).isPureReactComponent = true, E.prototype.shouldComponentUpdate = function(n2, t3) {
|
|
return S2(this.props, n2) || S2(this.state, t3);
|
|
};
|
|
var w2 = l.__b;
|
|
l.__b = function(n2) {
|
|
n2.type && n2.type.__f && n2.ref && (n2.props.ref = n2.ref, n2.ref = null), w2 && w2(n2);
|
|
};
|
|
var R = typeof Symbol != "undefined" && Symbol.for && Symbol.for("react.forward_ref") || 3911;
|
|
var A3 = l.__e;
|
|
l.__e = function(n2, t3, e3) {
|
|
if (n2.then) {
|
|
for (var r3, u3 = t3; u3 = u3.__; )
|
|
if ((r3 = u3.__c) && r3.__c)
|
|
return t3.__e == null && (t3.__e = e3.__e, t3.__k = e3.__k), r3.__c(n2, t3);
|
|
}
|
|
A3(n2, t3, e3);
|
|
};
|
|
var O2 = l.unmount;
|
|
function L2() {
|
|
this.__u = 0, this.t = null, this.__b = null;
|
|
}
|
|
function U(n2) {
|
|
var t3 = n2.__.__c;
|
|
return t3 && t3.__e && t3.__e(n2);
|
|
}
|
|
function M2() {
|
|
this.u = null, this.o = null;
|
|
}
|
|
l.unmount = function(n2) {
|
|
var t3 = n2.__c;
|
|
t3 && t3.__R && t3.__R(), t3 && n2.__h === true && (n2.type = null), O2 && O2(n2);
|
|
}, (L2.prototype = new _()).__c = function(n2, t3) {
|
|
var e3 = t3.__c, r3 = this;
|
|
r3.t == null && (r3.t = []), r3.t.push(e3);
|
|
var u3 = U(r3.__v), o2 = false, i3 = function() {
|
|
o2 || (o2 = true, e3.__R = null, u3 ? u3(l3) : l3());
|
|
};
|
|
e3.__R = i3;
|
|
var l3 = function() {
|
|
if (!--r3.__u) {
|
|
if (r3.state.__e) {
|
|
var n3 = r3.state.__e;
|
|
r3.__v.__k[0] = function n4(t5, e4, r4) {
|
|
return t5 && (t5.__v = null, t5.__k = t5.__k && t5.__k.map(function(t6) {
|
|
return n4(t6, e4, r4);
|
|
}), t5.__c && t5.__c.__P === e4 && (t5.__e && r4.insertBefore(t5.__e, t5.__d), t5.__c.__e = true, t5.__c.__P = r4)), t5;
|
|
}(n3, n3.__c.__P, n3.__c.__O);
|
|
}
|
|
var t4;
|
|
for (r3.setState({ __e: r3.__b = null }); t4 = r3.t.pop(); )
|
|
t4.forceUpdate();
|
|
}
|
|
}, c3 = t3.__h === true;
|
|
r3.__u++ || c3 || r3.setState({ __e: r3.__b = r3.__v.__k[0] }), n2.then(i3, i3);
|
|
}, L2.prototype.componentWillUnmount = function() {
|
|
this.t = [];
|
|
}, L2.prototype.render = function(n2, t3) {
|
|
if (this.__b) {
|
|
if (this.__v.__k) {
|
|
var e3 = document.createElement("div"), r3 = this.__v.__k[0].__c;
|
|
this.__v.__k[0] = function n3(t4, e4, r4) {
|
|
return t4 && (t4.__c && t4.__c.__H && (t4.__c.__H.__.forEach(function(n4) {
|
|
typeof n4.__c == "function" && n4.__c();
|
|
}), t4.__c.__H = null), (t4 = C2({}, t4)).__c != null && (t4.__c.__P === r4 && (t4.__c.__P = e4), t4.__c = null), t4.__k = t4.__k && t4.__k.map(function(t5) {
|
|
return n3(t5, e4, r4);
|
|
})), t4;
|
|
}(this.__b, e3, r3.__O = r3.__P);
|
|
}
|
|
this.__b = null;
|
|
}
|
|
var u3 = t3.__e && v(d, null, n2.fallback);
|
|
return u3 && (u3.__h = null), [v(d, null, t3.__e ? null : n2.children), u3];
|
|
};
|
|
var T3 = function(n2, t3, e3) {
|
|
if (++e3[1] === e3[0] && n2.o.delete(t3), n2.props.revealOrder && (n2.props.revealOrder[0] !== "t" || !n2.o.size))
|
|
for (e3 = n2.u; e3; ) {
|
|
for (; e3.length > 3; )
|
|
e3.pop()();
|
|
if (e3[1] < e3[0])
|
|
break;
|
|
n2.u = e3 = e3[2];
|
|
}
|
|
};
|
|
function D2(n2) {
|
|
return this.getChildContext = function() {
|
|
return n2.context;
|
|
}, n2.children;
|
|
}
|
|
function I2(n2) {
|
|
var t3 = this, e3 = n2.i;
|
|
t3.componentWillUnmount = function() {
|
|
S(null, t3.l), t3.l = null, t3.i = null;
|
|
}, t3.i && t3.i !== e3 && t3.componentWillUnmount(), n2.__v ? (t3.l || (t3.i = e3, t3.l = { nodeType: 1, parentNode: e3, childNodes: [], appendChild: function(n3) {
|
|
this.childNodes.push(n3), t3.i.appendChild(n3);
|
|
}, insertBefore: function(n3, e4) {
|
|
this.childNodes.push(n3), t3.i.appendChild(n3);
|
|
}, removeChild: function(n3) {
|
|
this.childNodes.splice(this.childNodes.indexOf(n3) >>> 1, 1), t3.i.removeChild(n3);
|
|
} }), S(v(D2, { context: t3.context }, n2.__v), t3.l)) : t3.l && t3.componentWillUnmount();
|
|
}
|
|
function W(n2, t3) {
|
|
return v(I2, { __v: n2, i: t3 });
|
|
}
|
|
(M2.prototype = new _()).__e = function(n2) {
|
|
var t3 = this, e3 = U(t3.__v), r3 = t3.o.get(n2);
|
|
return r3[0]++, function(u3) {
|
|
var o2 = function() {
|
|
t3.props.revealOrder ? (r3.push(u3), T3(t3, n2, r3)) : u3();
|
|
};
|
|
e3 ? e3(o2) : o2();
|
|
};
|
|
}, M2.prototype.render = function(n2) {
|
|
this.u = null, this.o = new Map();
|
|
var t3 = A(n2.children);
|
|
n2.revealOrder && n2.revealOrder[0] === "b" && t3.reverse();
|
|
for (var e3 = t3.length; e3--; )
|
|
this.o.set(t3[e3], this.u = [1, 0, this.u]);
|
|
return n2.children;
|
|
}, M2.prototype.componentDidUpdate = M2.prototype.componentDidMount = function() {
|
|
var n2 = this;
|
|
this.o.forEach(function(t3, e3) {
|
|
T3(n2, e3, t3);
|
|
});
|
|
};
|
|
var j3 = typeof Symbol != "undefined" && Symbol.for && Symbol.for("react.element") || 60103;
|
|
var P2 = /^(?:accent|alignment|arabic|baseline|cap|clip(?!PathU)|color|dominant|fill|flood|font|glyph(?!R)|horiz|marker(?!H|W|U)|overline|paint|stop|strikethrough|stroke|text(?!L)|underline|unicode|units|v|vector|vert|word|writing|x(?!C))[A-Z]/;
|
|
var V = typeof document != "undefined";
|
|
var z2 = function(n2) {
|
|
return (typeof Symbol != "undefined" && typeof Symbol() == "symbol" ? /fil|che|rad/i : /fil|che|ra/i).test(n2);
|
|
};
|
|
_.prototype.isReactComponent = {}, ["componentWillMount", "componentWillReceiveProps", "componentWillUpdate"].forEach(function(n2) {
|
|
Object.defineProperty(_.prototype, n2, { configurable: true, get: function() {
|
|
return this["UNSAFE_" + n2];
|
|
}, set: function(t3) {
|
|
Object.defineProperty(this, n2, { configurable: true, writable: true, value: t3 });
|
|
} });
|
|
});
|
|
var H2 = l.event;
|
|
function Z() {
|
|
}
|
|
function Y() {
|
|
return this.cancelBubble;
|
|
}
|
|
function q2() {
|
|
return this.defaultPrevented;
|
|
}
|
|
l.event = function(n2) {
|
|
return H2 && (n2 = H2(n2)), n2.persist = Z, n2.isPropagationStopped = Y, n2.isDefaultPrevented = q2, n2.nativeEvent = n2;
|
|
};
|
|
var G;
|
|
var J = { configurable: true, get: function() {
|
|
return this.class;
|
|
} };
|
|
var K = l.vnode;
|
|
l.vnode = function(n2) {
|
|
var t3 = n2.type, e3 = n2.props, r3 = e3;
|
|
if (typeof t3 == "string") {
|
|
var u3 = t3.indexOf("-") === -1;
|
|
for (var o2 in r3 = {}, e3) {
|
|
var i3 = e3[o2];
|
|
V && o2 === "children" && t3 === "noscript" || o2 === "value" && "defaultValue" in e3 && i3 == null || (o2 === "defaultValue" && "value" in e3 && e3.value == null ? o2 = "value" : o2 === "download" && i3 === true ? i3 = "" : /ondoubleclick/i.test(o2) ? o2 = "ondblclick" : /^onchange(textarea|input)/i.test(o2 + t3) && !z2(e3.type) ? o2 = "oninput" : /^onfocus$/i.test(o2) ? o2 = "onfocusin" : /^onblur$/i.test(o2) ? o2 = "onfocusout" : /^on(Ani|Tra|Tou|BeforeInp|Compo)/.test(o2) ? o2 = o2.toLowerCase() : u3 && P2.test(o2) ? o2 = o2.replace(/[A-Z0-9]/, "-$&").toLowerCase() : i3 === null && (i3 = void 0), r3[o2] = i3);
|
|
}
|
|
t3 == "select" && r3.multiple && Array.isArray(r3.value) && (r3.value = A(e3.children).forEach(function(n3) {
|
|
n3.props.selected = r3.value.indexOf(n3.props.value) != -1;
|
|
})), t3 == "select" && r3.defaultValue != null && (r3.value = A(e3.children).forEach(function(n3) {
|
|
n3.props.selected = r3.multiple ? r3.defaultValue.indexOf(n3.props.value) != -1 : r3.defaultValue == n3.props.value;
|
|
})), n2.props = r3, e3.class != e3.className && (J.enumerable = "className" in e3, e3.className != null && (r3.class = e3.className), Object.defineProperty(r3, "className", J));
|
|
}
|
|
n2.$$typeof = j3, K && K(n2);
|
|
};
|
|
var Q = l.__r;
|
|
l.__r = function(n2) {
|
|
Q && Q(n2), G = n2.__c;
|
|
};
|
|
|
|
// node_modules/@fullcalendar/core/vdom.js
|
|
var globalObj = typeof globalThis !== "undefined" ? globalThis : window;
|
|
if (globalObj.FullCalendarVDom) {
|
|
console.warn("FullCalendar VDOM already loaded");
|
|
} else {
|
|
globalObj.FullCalendarVDom = {
|
|
Component: _,
|
|
createElement: v,
|
|
render: S,
|
|
createRef: p,
|
|
Fragment: d,
|
|
createContext,
|
|
createPortal: W,
|
|
flushToDom,
|
|
unmountComponentAtNode
|
|
};
|
|
}
|
|
function flushToDom() {
|
|
var oldDebounceRendering = l.debounceRendering;
|
|
var callbackQ = [];
|
|
function execCallbackSync(callback) {
|
|
callbackQ.push(callback);
|
|
}
|
|
l.debounceRendering = execCallbackSync;
|
|
S(v(FakeComponent, {}), document.createElement("div"));
|
|
while (callbackQ.length) {
|
|
callbackQ.shift()();
|
|
}
|
|
l.debounceRendering = oldDebounceRendering;
|
|
}
|
|
var FakeComponent = function(_super) {
|
|
__extends(FakeComponent2, _super);
|
|
function FakeComponent2() {
|
|
return _super !== null && _super.apply(this, arguments) || this;
|
|
}
|
|
FakeComponent2.prototype.render = function() {
|
|
return v("div", {});
|
|
};
|
|
FakeComponent2.prototype.componentDidMount = function() {
|
|
this.setState({});
|
|
};
|
|
return FakeComponent2;
|
|
}(_);
|
|
function createContext(defaultValue) {
|
|
var ContextType = D(defaultValue);
|
|
var origProvider = ContextType.Provider;
|
|
ContextType.Provider = function() {
|
|
var _this = this;
|
|
var isNew = !this.getChildContext;
|
|
var children = origProvider.apply(this, arguments);
|
|
if (isNew) {
|
|
var subs_1 = [];
|
|
this.shouldComponentUpdate = function(_props) {
|
|
if (_this.props.value !== _props.value) {
|
|
subs_1.forEach(function(c3) {
|
|
c3.context = _props.value;
|
|
c3.forceUpdate();
|
|
});
|
|
}
|
|
};
|
|
this.sub = function(c3) {
|
|
subs_1.push(c3);
|
|
var old = c3.componentWillUnmount;
|
|
c3.componentWillUnmount = function() {
|
|
subs_1.splice(subs_1.indexOf(c3), 1);
|
|
old && old.call(c3);
|
|
};
|
|
};
|
|
}
|
|
return children;
|
|
};
|
|
return ContextType;
|
|
}
|
|
function unmountComponentAtNode(node) {
|
|
S(null, node);
|
|
}
|
|
|
|
// node_modules/@fullcalendar/common/vdom.js
|
|
if (typeof FullCalendarVDom === "undefined") {
|
|
throw new Error("Please import the top-level fullcalendar lib before attempting to import a plugin.");
|
|
}
|
|
var Component = FullCalendarVDom.Component;
|
|
var createElement = FullCalendarVDom.createElement;
|
|
var render = FullCalendarVDom.render;
|
|
var createRef = FullCalendarVDom.createRef;
|
|
var Fragment = FullCalendarVDom.Fragment;
|
|
var createContext2 = FullCalendarVDom.createContext;
|
|
var createPortal = FullCalendarVDom.createPortal;
|
|
var flushToDom2 = FullCalendarVDom.flushToDom;
|
|
var unmountComponentAtNode2 = FullCalendarVDom.unmountComponentAtNode;
|
|
|
|
// node_modules/@fullcalendar/common/main.js
|
|
var EventSourceApi = function() {
|
|
function EventSourceApi2(context, internalEventSource) {
|
|
this.context = context;
|
|
this.internalEventSource = internalEventSource;
|
|
}
|
|
EventSourceApi2.prototype.remove = function() {
|
|
this.context.dispatch({
|
|
type: "REMOVE_EVENT_SOURCE",
|
|
sourceId: this.internalEventSource.sourceId
|
|
});
|
|
};
|
|
EventSourceApi2.prototype.refetch = function() {
|
|
this.context.dispatch({
|
|
type: "FETCH_EVENT_SOURCES",
|
|
sourceIds: [this.internalEventSource.sourceId],
|
|
isRefetch: true
|
|
});
|
|
};
|
|
Object.defineProperty(EventSourceApi2.prototype, "id", {
|
|
get: function() {
|
|
return this.internalEventSource.publicId;
|
|
},
|
|
enumerable: false,
|
|
configurable: true
|
|
});
|
|
Object.defineProperty(EventSourceApi2.prototype, "url", {
|
|
get: function() {
|
|
return this.internalEventSource.meta.url;
|
|
},
|
|
enumerable: false,
|
|
configurable: true
|
|
});
|
|
Object.defineProperty(EventSourceApi2.prototype, "format", {
|
|
get: function() {
|
|
return this.internalEventSource.meta.format;
|
|
},
|
|
enumerable: false,
|
|
configurable: true
|
|
});
|
|
return EventSourceApi2;
|
|
}();
|
|
function removeElement(el) {
|
|
if (el.parentNode) {
|
|
el.parentNode.removeChild(el);
|
|
}
|
|
}
|
|
function elementClosest(el, selector) {
|
|
if (el.closest) {
|
|
return el.closest(selector);
|
|
}
|
|
if (!document.documentElement.contains(el)) {
|
|
return null;
|
|
}
|
|
do {
|
|
if (elementMatches(el, selector)) {
|
|
return el;
|
|
}
|
|
el = el.parentElement || el.parentNode;
|
|
} while (el !== null && el.nodeType === 1);
|
|
return null;
|
|
}
|
|
function elementMatches(el, selector) {
|
|
var method = el.matches || el.matchesSelector || el.msMatchesSelector;
|
|
return method.call(el, selector);
|
|
}
|
|
function findElements(container, selector) {
|
|
var containers = container instanceof HTMLElement ? [container] : container;
|
|
var allMatches = [];
|
|
for (var i3 = 0; i3 < containers.length; i3 += 1) {
|
|
var matches = containers[i3].querySelectorAll(selector);
|
|
for (var j4 = 0; j4 < matches.length; j4 += 1) {
|
|
allMatches.push(matches[j4]);
|
|
}
|
|
}
|
|
return allMatches;
|
|
}
|
|
var PIXEL_PROP_RE = /(top|left|right|bottom|width|height)$/i;
|
|
function applyStyle(el, props) {
|
|
for (var propName in props) {
|
|
applyStyleProp(el, propName, props[propName]);
|
|
}
|
|
}
|
|
function applyStyleProp(el, name, val) {
|
|
if (val == null) {
|
|
el.style[name] = "";
|
|
} else if (typeof val === "number" && PIXEL_PROP_RE.test(name)) {
|
|
el.style[name] = val + "px";
|
|
} else {
|
|
el.style[name] = val;
|
|
}
|
|
}
|
|
function getEventTargetViaRoot(ev) {
|
|
var _a, _b;
|
|
return (_b = (_a = ev.composedPath) === null || _a === void 0 ? void 0 : _a.call(ev)[0]) !== null && _b !== void 0 ? _b : ev.target;
|
|
}
|
|
function getElRoot(el) {
|
|
return el.getRootNode ? el.getRootNode() : document;
|
|
}
|
|
var guid$1 = 0;
|
|
function getUniqueDomId() {
|
|
guid$1 += 1;
|
|
return "fc-dom-" + guid$1;
|
|
}
|
|
function preventDefault(ev) {
|
|
ev.preventDefault();
|
|
}
|
|
function buildDelegationHandler(selector, handler) {
|
|
return function(ev) {
|
|
var matchedChild = elementClosest(ev.target, selector);
|
|
if (matchedChild) {
|
|
handler.call(matchedChild, ev, matchedChild);
|
|
}
|
|
};
|
|
}
|
|
function listenBySelector(container, eventType, selector, handler) {
|
|
var attachedHandler = buildDelegationHandler(selector, handler);
|
|
container.addEventListener(eventType, attachedHandler);
|
|
return function() {
|
|
container.removeEventListener(eventType, attachedHandler);
|
|
};
|
|
}
|
|
function listenToHoverBySelector(container, selector, onMouseEnter, onMouseLeave) {
|
|
var currentMatchedChild;
|
|
return listenBySelector(container, "mouseover", selector, function(mouseOverEv, matchedChild) {
|
|
if (matchedChild !== currentMatchedChild) {
|
|
currentMatchedChild = matchedChild;
|
|
onMouseEnter(mouseOverEv, matchedChild);
|
|
var realOnMouseLeave_1 = function(mouseLeaveEv) {
|
|
currentMatchedChild = null;
|
|
onMouseLeave(mouseLeaveEv, matchedChild);
|
|
matchedChild.removeEventListener("mouseleave", realOnMouseLeave_1);
|
|
};
|
|
matchedChild.addEventListener("mouseleave", realOnMouseLeave_1);
|
|
}
|
|
});
|
|
}
|
|
var transitionEventNames = [
|
|
"webkitTransitionEnd",
|
|
"otransitionend",
|
|
"oTransitionEnd",
|
|
"msTransitionEnd",
|
|
"transitionend"
|
|
];
|
|
function whenTransitionDone(el, callback) {
|
|
var realCallback = function(ev) {
|
|
callback(ev);
|
|
transitionEventNames.forEach(function(eventName) {
|
|
el.removeEventListener(eventName, realCallback);
|
|
});
|
|
};
|
|
transitionEventNames.forEach(function(eventName) {
|
|
el.addEventListener(eventName, realCallback);
|
|
});
|
|
}
|
|
function createAriaClickAttrs(handler) {
|
|
return __assign({ onClick: handler }, createAriaKeyboardAttrs(handler));
|
|
}
|
|
function createAriaKeyboardAttrs(handler) {
|
|
return {
|
|
tabIndex: 0,
|
|
onKeyDown: function(ev) {
|
|
if (ev.key === "Enter" || ev.key === " ") {
|
|
handler(ev);
|
|
ev.preventDefault();
|
|
}
|
|
}
|
|
};
|
|
}
|
|
var guidNumber = 0;
|
|
function guid() {
|
|
guidNumber += 1;
|
|
return String(guidNumber);
|
|
}
|
|
function disableCursor() {
|
|
document.body.classList.add("fc-not-allowed");
|
|
}
|
|
function enableCursor() {
|
|
document.body.classList.remove("fc-not-allowed");
|
|
}
|
|
function preventSelection(el) {
|
|
el.classList.add("fc-unselectable");
|
|
el.addEventListener("selectstart", preventDefault);
|
|
}
|
|
function allowSelection(el) {
|
|
el.classList.remove("fc-unselectable");
|
|
el.removeEventListener("selectstart", preventDefault);
|
|
}
|
|
function preventContextMenu(el) {
|
|
el.addEventListener("contextmenu", preventDefault);
|
|
}
|
|
function allowContextMenu(el) {
|
|
el.removeEventListener("contextmenu", preventDefault);
|
|
}
|
|
function parseFieldSpecs(input) {
|
|
var specs = [];
|
|
var tokens = [];
|
|
var i3;
|
|
var token;
|
|
if (typeof input === "string") {
|
|
tokens = input.split(/\s*,\s*/);
|
|
} else if (typeof input === "function") {
|
|
tokens = [input];
|
|
} else if (Array.isArray(input)) {
|
|
tokens = input;
|
|
}
|
|
for (i3 = 0; i3 < tokens.length; i3 += 1) {
|
|
token = tokens[i3];
|
|
if (typeof token === "string") {
|
|
specs.push(token.charAt(0) === "-" ? { field: token.substring(1), order: -1 } : { field: token, order: 1 });
|
|
} else if (typeof token === "function") {
|
|
specs.push({ func: token });
|
|
}
|
|
}
|
|
return specs;
|
|
}
|
|
function compareByFieldSpecs(obj0, obj1, fieldSpecs) {
|
|
var i3;
|
|
var cmp;
|
|
for (i3 = 0; i3 < fieldSpecs.length; i3 += 1) {
|
|
cmp = compareByFieldSpec(obj0, obj1, fieldSpecs[i3]);
|
|
if (cmp) {
|
|
return cmp;
|
|
}
|
|
}
|
|
return 0;
|
|
}
|
|
function compareByFieldSpec(obj0, obj1, fieldSpec) {
|
|
if (fieldSpec.func) {
|
|
return fieldSpec.func(obj0, obj1);
|
|
}
|
|
return flexibleCompare(obj0[fieldSpec.field], obj1[fieldSpec.field]) * (fieldSpec.order || 1);
|
|
}
|
|
function flexibleCompare(a3, b3) {
|
|
if (!a3 && !b3) {
|
|
return 0;
|
|
}
|
|
if (b3 == null) {
|
|
return -1;
|
|
}
|
|
if (a3 == null) {
|
|
return 1;
|
|
}
|
|
if (typeof a3 === "string" || typeof b3 === "string") {
|
|
return String(a3).localeCompare(String(b3));
|
|
}
|
|
return a3 - b3;
|
|
}
|
|
function padStart(val, len) {
|
|
var s3 = String(val);
|
|
return "000".substr(0, len - s3.length) + s3;
|
|
}
|
|
function formatWithOrdinals(formatter, args, fallbackText) {
|
|
if (typeof formatter === "function") {
|
|
return formatter.apply(void 0, args);
|
|
}
|
|
if (typeof formatter === "string") {
|
|
return args.reduce(function(str, arg, index) {
|
|
return str.replace("$" + index, arg || "");
|
|
}, formatter);
|
|
}
|
|
return fallbackText;
|
|
}
|
|
function compareNumbers(a3, b3) {
|
|
return a3 - b3;
|
|
}
|
|
function isInt(n2) {
|
|
return n2 % 1 === 0;
|
|
}
|
|
function computeSmallestCellWidth(cellEl) {
|
|
var allWidthEl = cellEl.querySelector(".fc-scrollgrid-shrink-frame");
|
|
var contentWidthEl = cellEl.querySelector(".fc-scrollgrid-shrink-cushion");
|
|
if (!allWidthEl) {
|
|
throw new Error("needs fc-scrollgrid-shrink-frame className");
|
|
}
|
|
if (!contentWidthEl) {
|
|
throw new Error("needs fc-scrollgrid-shrink-cushion className");
|
|
}
|
|
return cellEl.getBoundingClientRect().width - allWidthEl.getBoundingClientRect().width + contentWidthEl.getBoundingClientRect().width;
|
|
}
|
|
var DAY_IDS = ["sun", "mon", "tue", "wed", "thu", "fri", "sat"];
|
|
function addWeeks(m2, n2) {
|
|
var a3 = dateToUtcArray(m2);
|
|
a3[2] += n2 * 7;
|
|
return arrayToUtcDate(a3);
|
|
}
|
|
function addDays(m2, n2) {
|
|
var a3 = dateToUtcArray(m2);
|
|
a3[2] += n2;
|
|
return arrayToUtcDate(a3);
|
|
}
|
|
function addMs(m2, n2) {
|
|
var a3 = dateToUtcArray(m2);
|
|
a3[6] += n2;
|
|
return arrayToUtcDate(a3);
|
|
}
|
|
function diffWeeks(m0, m1) {
|
|
return diffDays(m0, m1) / 7;
|
|
}
|
|
function diffDays(m0, m1) {
|
|
return (m1.valueOf() - m0.valueOf()) / (1e3 * 60 * 60 * 24);
|
|
}
|
|
function diffHours(m0, m1) {
|
|
return (m1.valueOf() - m0.valueOf()) / (1e3 * 60 * 60);
|
|
}
|
|
function diffMinutes(m0, m1) {
|
|
return (m1.valueOf() - m0.valueOf()) / (1e3 * 60);
|
|
}
|
|
function diffSeconds(m0, m1) {
|
|
return (m1.valueOf() - m0.valueOf()) / 1e3;
|
|
}
|
|
function diffDayAndTime(m0, m1) {
|
|
var m0day = startOfDay(m0);
|
|
var m1day = startOfDay(m1);
|
|
return {
|
|
years: 0,
|
|
months: 0,
|
|
days: Math.round(diffDays(m0day, m1day)),
|
|
milliseconds: m1.valueOf() - m1day.valueOf() - (m0.valueOf() - m0day.valueOf())
|
|
};
|
|
}
|
|
function diffWholeWeeks(m0, m1) {
|
|
var d3 = diffWholeDays(m0, m1);
|
|
if (d3 !== null && d3 % 7 === 0) {
|
|
return d3 / 7;
|
|
}
|
|
return null;
|
|
}
|
|
function diffWholeDays(m0, m1) {
|
|
if (timeAsMs(m0) === timeAsMs(m1)) {
|
|
return Math.round(diffDays(m0, m1));
|
|
}
|
|
return null;
|
|
}
|
|
function startOfDay(m2) {
|
|
return arrayToUtcDate([
|
|
m2.getUTCFullYear(),
|
|
m2.getUTCMonth(),
|
|
m2.getUTCDate()
|
|
]);
|
|
}
|
|
function startOfHour(m2) {
|
|
return arrayToUtcDate([
|
|
m2.getUTCFullYear(),
|
|
m2.getUTCMonth(),
|
|
m2.getUTCDate(),
|
|
m2.getUTCHours()
|
|
]);
|
|
}
|
|
function startOfMinute(m2) {
|
|
return arrayToUtcDate([
|
|
m2.getUTCFullYear(),
|
|
m2.getUTCMonth(),
|
|
m2.getUTCDate(),
|
|
m2.getUTCHours(),
|
|
m2.getUTCMinutes()
|
|
]);
|
|
}
|
|
function startOfSecond(m2) {
|
|
return arrayToUtcDate([
|
|
m2.getUTCFullYear(),
|
|
m2.getUTCMonth(),
|
|
m2.getUTCDate(),
|
|
m2.getUTCHours(),
|
|
m2.getUTCMinutes(),
|
|
m2.getUTCSeconds()
|
|
]);
|
|
}
|
|
function weekOfYear(marker, dow, doy) {
|
|
var y3 = marker.getUTCFullYear();
|
|
var w3 = weekOfGivenYear(marker, y3, dow, doy);
|
|
if (w3 < 1) {
|
|
return weekOfGivenYear(marker, y3 - 1, dow, doy);
|
|
}
|
|
var nextW = weekOfGivenYear(marker, y3 + 1, dow, doy);
|
|
if (nextW >= 1) {
|
|
return Math.min(w3, nextW);
|
|
}
|
|
return w3;
|
|
}
|
|
function weekOfGivenYear(marker, year, dow, doy) {
|
|
var firstWeekStart = arrayToUtcDate([year, 0, 1 + firstWeekOffset(year, dow, doy)]);
|
|
var dayStart = startOfDay(marker);
|
|
var days = Math.round(diffDays(firstWeekStart, dayStart));
|
|
return Math.floor(days / 7) + 1;
|
|
}
|
|
function firstWeekOffset(year, dow, doy) {
|
|
var fwd = 7 + dow - doy;
|
|
var fwdlw = (7 + arrayToUtcDate([year, 0, fwd]).getUTCDay() - dow) % 7;
|
|
return -fwdlw + fwd - 1;
|
|
}
|
|
function dateToLocalArray(date) {
|
|
return [
|
|
date.getFullYear(),
|
|
date.getMonth(),
|
|
date.getDate(),
|
|
date.getHours(),
|
|
date.getMinutes(),
|
|
date.getSeconds(),
|
|
date.getMilliseconds()
|
|
];
|
|
}
|
|
function arrayToLocalDate(a3) {
|
|
return new Date(a3[0], a3[1] || 0, a3[2] == null ? 1 : a3[2], a3[3] || 0, a3[4] || 0, a3[5] || 0);
|
|
}
|
|
function dateToUtcArray(date) {
|
|
return [
|
|
date.getUTCFullYear(),
|
|
date.getUTCMonth(),
|
|
date.getUTCDate(),
|
|
date.getUTCHours(),
|
|
date.getUTCMinutes(),
|
|
date.getUTCSeconds(),
|
|
date.getUTCMilliseconds()
|
|
];
|
|
}
|
|
function arrayToUtcDate(a3) {
|
|
if (a3.length === 1) {
|
|
a3 = a3.concat([0]);
|
|
}
|
|
return new Date(Date.UTC.apply(Date, a3));
|
|
}
|
|
function isValidDate(m2) {
|
|
return !isNaN(m2.valueOf());
|
|
}
|
|
function timeAsMs(m2) {
|
|
return m2.getUTCHours() * 1e3 * 60 * 60 + m2.getUTCMinutes() * 1e3 * 60 + m2.getUTCSeconds() * 1e3 + m2.getUTCMilliseconds();
|
|
}
|
|
function createEventInstance(defId, range, forcedStartTzo, forcedEndTzo) {
|
|
return {
|
|
instanceId: guid(),
|
|
defId,
|
|
range,
|
|
forcedStartTzo: forcedStartTzo == null ? null : forcedStartTzo,
|
|
forcedEndTzo: forcedEndTzo == null ? null : forcedEndTzo
|
|
};
|
|
}
|
|
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
function mergeProps(propObjs, complexPropsMap) {
|
|
var dest = {};
|
|
if (complexPropsMap) {
|
|
for (var name_1 in complexPropsMap) {
|
|
var complexObjs = [];
|
|
for (var i3 = propObjs.length - 1; i3 >= 0; i3 -= 1) {
|
|
var val = propObjs[i3][name_1];
|
|
if (typeof val === "object" && val) {
|
|
complexObjs.unshift(val);
|
|
} else if (val !== void 0) {
|
|
dest[name_1] = val;
|
|
break;
|
|
}
|
|
}
|
|
if (complexObjs.length) {
|
|
dest[name_1] = mergeProps(complexObjs);
|
|
}
|
|
}
|
|
}
|
|
for (var i3 = propObjs.length - 1; i3 >= 0; i3 -= 1) {
|
|
var props = propObjs[i3];
|
|
for (var name_2 in props) {
|
|
if (!(name_2 in dest)) {
|
|
dest[name_2] = props[name_2];
|
|
}
|
|
}
|
|
}
|
|
return dest;
|
|
}
|
|
function filterHash(hash, func) {
|
|
var filtered = {};
|
|
for (var key in hash) {
|
|
if (func(hash[key], key)) {
|
|
filtered[key] = hash[key];
|
|
}
|
|
}
|
|
return filtered;
|
|
}
|
|
function mapHash(hash, func) {
|
|
var newHash = {};
|
|
for (var key in hash) {
|
|
newHash[key] = func(hash[key], key);
|
|
}
|
|
return newHash;
|
|
}
|
|
function arrayToHash(a3) {
|
|
var hash = {};
|
|
for (var _i = 0, a_1 = a3; _i < a_1.length; _i++) {
|
|
var item = a_1[_i];
|
|
hash[item] = true;
|
|
}
|
|
return hash;
|
|
}
|
|
function hashValuesToArray(obj) {
|
|
var a3 = [];
|
|
for (var key in obj) {
|
|
a3.push(obj[key]);
|
|
}
|
|
return a3;
|
|
}
|
|
function isPropsEqual(obj0, obj1) {
|
|
if (obj0 === obj1) {
|
|
return true;
|
|
}
|
|
for (var key in obj0) {
|
|
if (hasOwnProperty.call(obj0, key)) {
|
|
if (!(key in obj1)) {
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
for (var key in obj1) {
|
|
if (hasOwnProperty.call(obj1, key)) {
|
|
if (obj0[key] !== obj1[key]) {
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
function getUnequalProps(obj0, obj1) {
|
|
var keys = [];
|
|
for (var key in obj0) {
|
|
if (hasOwnProperty.call(obj0, key)) {
|
|
if (!(key in obj1)) {
|
|
keys.push(key);
|
|
}
|
|
}
|
|
}
|
|
for (var key in obj1) {
|
|
if (hasOwnProperty.call(obj1, key)) {
|
|
if (obj0[key] !== obj1[key]) {
|
|
keys.push(key);
|
|
}
|
|
}
|
|
}
|
|
return keys;
|
|
}
|
|
function compareObjs(oldProps, newProps, equalityFuncs) {
|
|
if (equalityFuncs === void 0) {
|
|
equalityFuncs = {};
|
|
}
|
|
if (oldProps === newProps) {
|
|
return true;
|
|
}
|
|
for (var key in newProps) {
|
|
if (key in oldProps && isObjValsEqual(oldProps[key], newProps[key], equalityFuncs[key]))
|
|
;
|
|
else {
|
|
return false;
|
|
}
|
|
}
|
|
for (var key in oldProps) {
|
|
if (!(key in newProps)) {
|
|
return false;
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
function isObjValsEqual(val0, val1, comparator) {
|
|
if (val0 === val1 || comparator === true) {
|
|
return true;
|
|
}
|
|
if (comparator) {
|
|
return comparator(val0, val1);
|
|
}
|
|
return false;
|
|
}
|
|
function collectFromHash(hash, startIndex, endIndex, step) {
|
|
if (startIndex === void 0) {
|
|
startIndex = 0;
|
|
}
|
|
if (step === void 0) {
|
|
step = 1;
|
|
}
|
|
var res = [];
|
|
if (endIndex == null) {
|
|
endIndex = Object.keys(hash).length;
|
|
}
|
|
for (var i3 = startIndex; i3 < endIndex; i3 += step) {
|
|
var val = hash[i3];
|
|
if (val !== void 0) {
|
|
res.push(val);
|
|
}
|
|
}
|
|
return res;
|
|
}
|
|
function parseRecurring(refined, defaultAllDay, dateEnv, recurringTypes) {
|
|
for (var i3 = 0; i3 < recurringTypes.length; i3 += 1) {
|
|
var parsed = recurringTypes[i3].parse(refined, dateEnv);
|
|
if (parsed) {
|
|
var allDay = refined.allDay;
|
|
if (allDay == null) {
|
|
allDay = defaultAllDay;
|
|
if (allDay == null) {
|
|
allDay = parsed.allDayGuess;
|
|
if (allDay == null) {
|
|
allDay = false;
|
|
}
|
|
}
|
|
}
|
|
return {
|
|
allDay,
|
|
duration: parsed.duration,
|
|
typeData: parsed.typeData,
|
|
typeId: i3
|
|
};
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
function expandRecurring(eventStore, framingRange, context) {
|
|
var dateEnv = context.dateEnv, pluginHooks = context.pluginHooks, options = context.options;
|
|
var defs = eventStore.defs, instances = eventStore.instances;
|
|
instances = filterHash(instances, function(instance2) {
|
|
return !defs[instance2.defId].recurringDef;
|
|
});
|
|
for (var defId in defs) {
|
|
var def = defs[defId];
|
|
if (def.recurringDef) {
|
|
var duration = def.recurringDef.duration;
|
|
if (!duration) {
|
|
duration = def.allDay ? options.defaultAllDayEventDuration : options.defaultTimedEventDuration;
|
|
}
|
|
var starts = expandRecurringRanges(def, duration, framingRange, dateEnv, pluginHooks.recurringTypes);
|
|
for (var _i = 0, starts_1 = starts; _i < starts_1.length; _i++) {
|
|
var start = starts_1[_i];
|
|
var instance = createEventInstance(defId, {
|
|
start,
|
|
end: dateEnv.add(start, duration)
|
|
});
|
|
instances[instance.instanceId] = instance;
|
|
}
|
|
}
|
|
}
|
|
return { defs, instances };
|
|
}
|
|
function expandRecurringRanges(eventDef, duration, framingRange, dateEnv, recurringTypes) {
|
|
var typeDef = recurringTypes[eventDef.recurringDef.typeId];
|
|
var markers = typeDef.expand(eventDef.recurringDef.typeData, {
|
|
start: dateEnv.subtract(framingRange.start, duration),
|
|
end: framingRange.end
|
|
}, dateEnv);
|
|
if (eventDef.allDay) {
|
|
markers = markers.map(startOfDay);
|
|
}
|
|
return markers;
|
|
}
|
|
var INTERNAL_UNITS = ["years", "months", "days", "milliseconds"];
|
|
var PARSE_RE = /^(-?)(?:(\d+)\.)?(\d+):(\d\d)(?::(\d\d)(?:\.(\d\d\d))?)?/;
|
|
function createDuration(input, unit) {
|
|
var _a;
|
|
if (typeof input === "string") {
|
|
return parseString(input);
|
|
}
|
|
if (typeof input === "object" && input) {
|
|
return parseObject(input);
|
|
}
|
|
if (typeof input === "number") {
|
|
return parseObject((_a = {}, _a[unit || "milliseconds"] = input, _a));
|
|
}
|
|
return null;
|
|
}
|
|
function parseString(s3) {
|
|
var m2 = PARSE_RE.exec(s3);
|
|
if (m2) {
|
|
var sign = m2[1] ? -1 : 1;
|
|
return {
|
|
years: 0,
|
|
months: 0,
|
|
days: sign * (m2[2] ? parseInt(m2[2], 10) : 0),
|
|
milliseconds: sign * ((m2[3] ? parseInt(m2[3], 10) : 0) * 60 * 60 * 1e3 + (m2[4] ? parseInt(m2[4], 10) : 0) * 60 * 1e3 + (m2[5] ? parseInt(m2[5], 10) : 0) * 1e3 + (m2[6] ? parseInt(m2[6], 10) : 0))
|
|
};
|
|
}
|
|
return null;
|
|
}
|
|
function parseObject(obj) {
|
|
var duration = {
|
|
years: obj.years || obj.year || 0,
|
|
months: obj.months || obj.month || 0,
|
|
days: obj.days || obj.day || 0,
|
|
milliseconds: (obj.hours || obj.hour || 0) * 60 * 60 * 1e3 + (obj.minutes || obj.minute || 0) * 60 * 1e3 + (obj.seconds || obj.second || 0) * 1e3 + (obj.milliseconds || obj.millisecond || obj.ms || 0)
|
|
};
|
|
var weeks = obj.weeks || obj.week;
|
|
if (weeks) {
|
|
duration.days += weeks * 7;
|
|
duration.specifiedWeeks = true;
|
|
}
|
|
return duration;
|
|
}
|
|
function durationsEqual(d0, d1) {
|
|
return d0.years === d1.years && d0.months === d1.months && d0.days === d1.days && d0.milliseconds === d1.milliseconds;
|
|
}
|
|
function addDurations(d0, d1) {
|
|
return {
|
|
years: d0.years + d1.years,
|
|
months: d0.months + d1.months,
|
|
days: d0.days + d1.days,
|
|
milliseconds: d0.milliseconds + d1.milliseconds
|
|
};
|
|
}
|
|
function subtractDurations(d1, d0) {
|
|
return {
|
|
years: d1.years - d0.years,
|
|
months: d1.months - d0.months,
|
|
days: d1.days - d0.days,
|
|
milliseconds: d1.milliseconds - d0.milliseconds
|
|
};
|
|
}
|
|
function multiplyDuration(d3, n2) {
|
|
return {
|
|
years: d3.years * n2,
|
|
months: d3.months * n2,
|
|
days: d3.days * n2,
|
|
milliseconds: d3.milliseconds * n2
|
|
};
|
|
}
|
|
function asRoughYears(dur) {
|
|
return asRoughDays(dur) / 365;
|
|
}
|
|
function asRoughMonths(dur) {
|
|
return asRoughDays(dur) / 30;
|
|
}
|
|
function asRoughDays(dur) {
|
|
return asRoughMs(dur) / 864e5;
|
|
}
|
|
function asRoughMs(dur) {
|
|
return dur.years * (365 * 864e5) + dur.months * (30 * 864e5) + dur.days * 864e5 + dur.milliseconds;
|
|
}
|
|
function wholeDivideDurations(numerator, denominator) {
|
|
var res = null;
|
|
for (var i3 = 0; i3 < INTERNAL_UNITS.length; i3 += 1) {
|
|
var unit = INTERNAL_UNITS[i3];
|
|
if (denominator[unit]) {
|
|
var localRes = numerator[unit] / denominator[unit];
|
|
if (!isInt(localRes) || res !== null && res !== localRes) {
|
|
return null;
|
|
}
|
|
res = localRes;
|
|
} else if (numerator[unit]) {
|
|
return null;
|
|
}
|
|
}
|
|
return res;
|
|
}
|
|
function greatestDurationDenominator(dur) {
|
|
var ms = dur.milliseconds;
|
|
if (ms) {
|
|
if (ms % 1e3 !== 0) {
|
|
return { unit: "millisecond", value: ms };
|
|
}
|
|
if (ms % (1e3 * 60) !== 0) {
|
|
return { unit: "second", value: ms / 1e3 };
|
|
}
|
|
if (ms % (1e3 * 60 * 60) !== 0) {
|
|
return { unit: "minute", value: ms / (1e3 * 60) };
|
|
}
|
|
if (ms) {
|
|
return { unit: "hour", value: ms / (1e3 * 60 * 60) };
|
|
}
|
|
}
|
|
if (dur.days) {
|
|
if (dur.specifiedWeeks && dur.days % 7 === 0) {
|
|
return { unit: "week", value: dur.days / 7 };
|
|
}
|
|
return { unit: "day", value: dur.days };
|
|
}
|
|
if (dur.months) {
|
|
return { unit: "month", value: dur.months };
|
|
}
|
|
if (dur.years) {
|
|
return { unit: "year", value: dur.years };
|
|
}
|
|
return { unit: "millisecond", value: 0 };
|
|
}
|
|
function buildIsoString(marker, timeZoneOffset, stripZeroTime) {
|
|
if (stripZeroTime === void 0) {
|
|
stripZeroTime = false;
|
|
}
|
|
var s3 = marker.toISOString();
|
|
s3 = s3.replace(".000", "");
|
|
if (stripZeroTime) {
|
|
s3 = s3.replace("T00:00:00Z", "");
|
|
}
|
|
if (s3.length > 10) {
|
|
if (timeZoneOffset == null) {
|
|
s3 = s3.replace("Z", "");
|
|
} else if (timeZoneOffset !== 0) {
|
|
s3 = s3.replace("Z", formatTimeZoneOffset(timeZoneOffset, true));
|
|
}
|
|
}
|
|
return s3;
|
|
}
|
|
function formatDayString(marker) {
|
|
return marker.toISOString().replace(/T.*$/, "");
|
|
}
|
|
function formatIsoTimeString(marker) {
|
|
return padStart(marker.getUTCHours(), 2) + ":" + padStart(marker.getUTCMinutes(), 2) + ":" + padStart(marker.getUTCSeconds(), 2);
|
|
}
|
|
function formatTimeZoneOffset(minutes, doIso) {
|
|
if (doIso === void 0) {
|
|
doIso = false;
|
|
}
|
|
var sign = minutes < 0 ? "-" : "+";
|
|
var abs = Math.abs(minutes);
|
|
var hours = Math.floor(abs / 60);
|
|
var mins = Math.round(abs % 60);
|
|
if (doIso) {
|
|
return sign + padStart(hours, 2) + ":" + padStart(mins, 2);
|
|
}
|
|
return "GMT" + sign + hours + (mins ? ":" + padStart(mins, 2) : "");
|
|
}
|
|
function isArraysEqual(a0, a1, equalityFunc) {
|
|
if (a0 === a1) {
|
|
return true;
|
|
}
|
|
var len = a0.length;
|
|
var i3;
|
|
if (len !== a1.length) {
|
|
return false;
|
|
}
|
|
for (i3 = 0; i3 < len; i3 += 1) {
|
|
if (!(equalityFunc ? equalityFunc(a0[i3], a1[i3]) : a0[i3] === a1[i3])) {
|
|
return false;
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
function memoize(workerFunc, resEquality, teardownFunc) {
|
|
var currentArgs;
|
|
var currentRes;
|
|
return function() {
|
|
var newArgs = [];
|
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
newArgs[_i] = arguments[_i];
|
|
}
|
|
if (!currentArgs) {
|
|
currentRes = workerFunc.apply(this, newArgs);
|
|
} else if (!isArraysEqual(currentArgs, newArgs)) {
|
|
if (teardownFunc) {
|
|
teardownFunc(currentRes);
|
|
}
|
|
var res = workerFunc.apply(this, newArgs);
|
|
if (!resEquality || !resEquality(res, currentRes)) {
|
|
currentRes = res;
|
|
}
|
|
}
|
|
currentArgs = newArgs;
|
|
return currentRes;
|
|
};
|
|
}
|
|
function memoizeObjArg(workerFunc, resEquality, teardownFunc) {
|
|
var _this = this;
|
|
var currentArg;
|
|
var currentRes;
|
|
return function(newArg) {
|
|
if (!currentArg) {
|
|
currentRes = workerFunc.call(_this, newArg);
|
|
} else if (!isPropsEqual(currentArg, newArg)) {
|
|
if (teardownFunc) {
|
|
teardownFunc(currentRes);
|
|
}
|
|
var res = workerFunc.call(_this, newArg);
|
|
if (!resEquality || !resEquality(res, currentRes)) {
|
|
currentRes = res;
|
|
}
|
|
}
|
|
currentArg = newArg;
|
|
return currentRes;
|
|
};
|
|
}
|
|
var EXTENDED_SETTINGS_AND_SEVERITIES = {
|
|
week: 3,
|
|
separator: 0,
|
|
omitZeroMinute: 0,
|
|
meridiem: 0,
|
|
omitCommas: 0
|
|
};
|
|
var STANDARD_DATE_PROP_SEVERITIES = {
|
|
timeZoneName: 7,
|
|
era: 6,
|
|
year: 5,
|
|
month: 4,
|
|
day: 2,
|
|
weekday: 2,
|
|
hour: 1,
|
|
minute: 1,
|
|
second: 1
|
|
};
|
|
var MERIDIEM_RE = /\s*([ap])\.?m\.?/i;
|
|
var COMMA_RE = /,/g;
|
|
var MULTI_SPACE_RE = /\s+/g;
|
|
var LTR_RE = /\u200e/g;
|
|
var UTC_RE = /UTC|GMT/;
|
|
var NativeFormatter = function() {
|
|
function NativeFormatter2(formatSettings) {
|
|
var standardDateProps = {};
|
|
var extendedSettings = {};
|
|
var severity = 0;
|
|
for (var name_1 in formatSettings) {
|
|
if (name_1 in EXTENDED_SETTINGS_AND_SEVERITIES) {
|
|
extendedSettings[name_1] = formatSettings[name_1];
|
|
severity = Math.max(EXTENDED_SETTINGS_AND_SEVERITIES[name_1], severity);
|
|
} else {
|
|
standardDateProps[name_1] = formatSettings[name_1];
|
|
if (name_1 in STANDARD_DATE_PROP_SEVERITIES) {
|
|
severity = Math.max(STANDARD_DATE_PROP_SEVERITIES[name_1], severity);
|
|
}
|
|
}
|
|
}
|
|
this.standardDateProps = standardDateProps;
|
|
this.extendedSettings = extendedSettings;
|
|
this.severity = severity;
|
|
this.buildFormattingFunc = memoize(buildFormattingFunc);
|
|
}
|
|
NativeFormatter2.prototype.format = function(date, context) {
|
|
return this.buildFormattingFunc(this.standardDateProps, this.extendedSettings, context)(date);
|
|
};
|
|
NativeFormatter2.prototype.formatRange = function(start, end, context, betterDefaultSeparator) {
|
|
var _a = this, standardDateProps = _a.standardDateProps, extendedSettings = _a.extendedSettings;
|
|
var diffSeverity = computeMarkerDiffSeverity(start.marker, end.marker, context.calendarSystem);
|
|
if (!diffSeverity) {
|
|
return this.format(start, context);
|
|
}
|
|
var biggestUnitForPartial = diffSeverity;
|
|
if (biggestUnitForPartial > 1 && (standardDateProps.year === "numeric" || standardDateProps.year === "2-digit") && (standardDateProps.month === "numeric" || standardDateProps.month === "2-digit") && (standardDateProps.day === "numeric" || standardDateProps.day === "2-digit")) {
|
|
biggestUnitForPartial = 1;
|
|
}
|
|
var full0 = this.format(start, context);
|
|
var full1 = this.format(end, context);
|
|
if (full0 === full1) {
|
|
return full0;
|
|
}
|
|
var partialDateProps = computePartialFormattingOptions(standardDateProps, biggestUnitForPartial);
|
|
var partialFormattingFunc = buildFormattingFunc(partialDateProps, extendedSettings, context);
|
|
var partial0 = partialFormattingFunc(start);
|
|
var partial1 = partialFormattingFunc(end);
|
|
var insertion = findCommonInsertion(full0, partial0, full1, partial1);
|
|
var separator = extendedSettings.separator || betterDefaultSeparator || context.defaultSeparator || "";
|
|
if (insertion) {
|
|
return insertion.before + partial0 + separator + partial1 + insertion.after;
|
|
}
|
|
return full0 + separator + full1;
|
|
};
|
|
NativeFormatter2.prototype.getLargestUnit = function() {
|
|
switch (this.severity) {
|
|
case 7:
|
|
case 6:
|
|
case 5:
|
|
return "year";
|
|
case 4:
|
|
return "month";
|
|
case 3:
|
|
return "week";
|
|
case 2:
|
|
return "day";
|
|
default:
|
|
return "time";
|
|
}
|
|
};
|
|
return NativeFormatter2;
|
|
}();
|
|
function buildFormattingFunc(standardDateProps, extendedSettings, context) {
|
|
var standardDatePropCnt = Object.keys(standardDateProps).length;
|
|
if (standardDatePropCnt === 1 && standardDateProps.timeZoneName === "short") {
|
|
return function(date) {
|
|
return formatTimeZoneOffset(date.timeZoneOffset);
|
|
};
|
|
}
|
|
if (standardDatePropCnt === 0 && extendedSettings.week) {
|
|
return function(date) {
|
|
return formatWeekNumber(context.computeWeekNumber(date.marker), context.weekText, context.weekTextLong, context.locale, extendedSettings.week);
|
|
};
|
|
}
|
|
return buildNativeFormattingFunc(standardDateProps, extendedSettings, context);
|
|
}
|
|
function buildNativeFormattingFunc(standardDateProps, extendedSettings, context) {
|
|
standardDateProps = __assign({}, standardDateProps);
|
|
extendedSettings = __assign({}, extendedSettings);
|
|
sanitizeSettings(standardDateProps, extendedSettings);
|
|
standardDateProps.timeZone = "UTC";
|
|
var normalFormat = new Intl.DateTimeFormat(context.locale.codes, standardDateProps);
|
|
var zeroFormat;
|
|
if (extendedSettings.omitZeroMinute) {
|
|
var zeroProps = __assign({}, standardDateProps);
|
|
delete zeroProps.minute;
|
|
zeroFormat = new Intl.DateTimeFormat(context.locale.codes, zeroProps);
|
|
}
|
|
return function(date) {
|
|
var marker = date.marker;
|
|
var format;
|
|
if (zeroFormat && !marker.getUTCMinutes()) {
|
|
format = zeroFormat;
|
|
} else {
|
|
format = normalFormat;
|
|
}
|
|
var s3 = format.format(marker);
|
|
return postProcess(s3, date, standardDateProps, extendedSettings, context);
|
|
};
|
|
}
|
|
function sanitizeSettings(standardDateProps, extendedSettings) {
|
|
if (standardDateProps.timeZoneName) {
|
|
if (!standardDateProps.hour) {
|
|
standardDateProps.hour = "2-digit";
|
|
}
|
|
if (!standardDateProps.minute) {
|
|
standardDateProps.minute = "2-digit";
|
|
}
|
|
}
|
|
if (standardDateProps.timeZoneName === "long") {
|
|
standardDateProps.timeZoneName = "short";
|
|
}
|
|
if (extendedSettings.omitZeroMinute && (standardDateProps.second || standardDateProps.millisecond)) {
|
|
delete extendedSettings.omitZeroMinute;
|
|
}
|
|
}
|
|
function postProcess(s3, date, standardDateProps, extendedSettings, context) {
|
|
s3 = s3.replace(LTR_RE, "");
|
|
if (standardDateProps.timeZoneName === "short") {
|
|
s3 = injectTzoStr(s3, context.timeZone === "UTC" || date.timeZoneOffset == null ? "UTC" : formatTimeZoneOffset(date.timeZoneOffset));
|
|
}
|
|
if (extendedSettings.omitCommas) {
|
|
s3 = s3.replace(COMMA_RE, "").trim();
|
|
}
|
|
if (extendedSettings.omitZeroMinute) {
|
|
s3 = s3.replace(":00", "");
|
|
}
|
|
if (extendedSettings.meridiem === false) {
|
|
s3 = s3.replace(MERIDIEM_RE, "").trim();
|
|
} else if (extendedSettings.meridiem === "narrow") {
|
|
s3 = s3.replace(MERIDIEM_RE, function(m0, m1) {
|
|
return m1.toLocaleLowerCase();
|
|
});
|
|
} else if (extendedSettings.meridiem === "short") {
|
|
s3 = s3.replace(MERIDIEM_RE, function(m0, m1) {
|
|
return m1.toLocaleLowerCase() + "m";
|
|
});
|
|
} else if (extendedSettings.meridiem === "lowercase") {
|
|
s3 = s3.replace(MERIDIEM_RE, function(m0) {
|
|
return m0.toLocaleLowerCase();
|
|
});
|
|
}
|
|
s3 = s3.replace(MULTI_SPACE_RE, " ");
|
|
s3 = s3.trim();
|
|
return s3;
|
|
}
|
|
function injectTzoStr(s3, tzoStr) {
|
|
var replaced = false;
|
|
s3 = s3.replace(UTC_RE, function() {
|
|
replaced = true;
|
|
return tzoStr;
|
|
});
|
|
if (!replaced) {
|
|
s3 += " " + tzoStr;
|
|
}
|
|
return s3;
|
|
}
|
|
function formatWeekNumber(num, weekText, weekTextLong, locale, display) {
|
|
var parts = [];
|
|
if (display === "long") {
|
|
parts.push(weekTextLong);
|
|
} else if (display === "short" || display === "narrow") {
|
|
parts.push(weekText);
|
|
}
|
|
if (display === "long" || display === "short") {
|
|
parts.push(" ");
|
|
}
|
|
parts.push(locale.simpleNumberFormat.format(num));
|
|
if (locale.options.direction === "rtl") {
|
|
parts.reverse();
|
|
}
|
|
return parts.join("");
|
|
}
|
|
function computeMarkerDiffSeverity(d0, d1, ca) {
|
|
if (ca.getMarkerYear(d0) !== ca.getMarkerYear(d1)) {
|
|
return 5;
|
|
}
|
|
if (ca.getMarkerMonth(d0) !== ca.getMarkerMonth(d1)) {
|
|
return 4;
|
|
}
|
|
if (ca.getMarkerDay(d0) !== ca.getMarkerDay(d1)) {
|
|
return 2;
|
|
}
|
|
if (timeAsMs(d0) !== timeAsMs(d1)) {
|
|
return 1;
|
|
}
|
|
return 0;
|
|
}
|
|
function computePartialFormattingOptions(options, biggestUnit) {
|
|
var partialOptions = {};
|
|
for (var name_2 in options) {
|
|
if (!(name_2 in STANDARD_DATE_PROP_SEVERITIES) || STANDARD_DATE_PROP_SEVERITIES[name_2] <= biggestUnit) {
|
|
partialOptions[name_2] = options[name_2];
|
|
}
|
|
}
|
|
return partialOptions;
|
|
}
|
|
function findCommonInsertion(full0, partial0, full1, partial1) {
|
|
var i0 = 0;
|
|
while (i0 < full0.length) {
|
|
var found0 = full0.indexOf(partial0, i0);
|
|
if (found0 === -1) {
|
|
break;
|
|
}
|
|
var before0 = full0.substr(0, found0);
|
|
i0 = found0 + partial0.length;
|
|
var after0 = full0.substr(i0);
|
|
var i1 = 0;
|
|
while (i1 < full1.length) {
|
|
var found1 = full1.indexOf(partial1, i1);
|
|
if (found1 === -1) {
|
|
break;
|
|
}
|
|
var before1 = full1.substr(0, found1);
|
|
i1 = found1 + partial1.length;
|
|
var after1 = full1.substr(i1);
|
|
if (before0 === before1 && after0 === after1) {
|
|
return {
|
|
before: before0,
|
|
after: after0
|
|
};
|
|
}
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
function expandZonedMarker(dateInfo, calendarSystem) {
|
|
var a3 = calendarSystem.markerToArray(dateInfo.marker);
|
|
return {
|
|
marker: dateInfo.marker,
|
|
timeZoneOffset: dateInfo.timeZoneOffset,
|
|
array: a3,
|
|
year: a3[0],
|
|
month: a3[1],
|
|
day: a3[2],
|
|
hour: a3[3],
|
|
minute: a3[4],
|
|
second: a3[5],
|
|
millisecond: a3[6]
|
|
};
|
|
}
|
|
function createVerboseFormattingArg(start, end, context, betterDefaultSeparator) {
|
|
var startInfo = expandZonedMarker(start, context.calendarSystem);
|
|
var endInfo = end ? expandZonedMarker(end, context.calendarSystem) : null;
|
|
return {
|
|
date: startInfo,
|
|
start: startInfo,
|
|
end: endInfo,
|
|
timeZone: context.timeZone,
|
|
localeCodes: context.locale.codes,
|
|
defaultSeparator: betterDefaultSeparator || context.defaultSeparator
|
|
};
|
|
}
|
|
var CmdFormatter = function() {
|
|
function CmdFormatter2(cmdStr) {
|
|
this.cmdStr = cmdStr;
|
|
}
|
|
CmdFormatter2.prototype.format = function(date, context, betterDefaultSeparator) {
|
|
return context.cmdFormatter(this.cmdStr, createVerboseFormattingArg(date, null, context, betterDefaultSeparator));
|
|
};
|
|
CmdFormatter2.prototype.formatRange = function(start, end, context, betterDefaultSeparator) {
|
|
return context.cmdFormatter(this.cmdStr, createVerboseFormattingArg(start, end, context, betterDefaultSeparator));
|
|
};
|
|
return CmdFormatter2;
|
|
}();
|
|
var FuncFormatter = function() {
|
|
function FuncFormatter2(func) {
|
|
this.func = func;
|
|
}
|
|
FuncFormatter2.prototype.format = function(date, context, betterDefaultSeparator) {
|
|
return this.func(createVerboseFormattingArg(date, null, context, betterDefaultSeparator));
|
|
};
|
|
FuncFormatter2.prototype.formatRange = function(start, end, context, betterDefaultSeparator) {
|
|
return this.func(createVerboseFormattingArg(start, end, context, betterDefaultSeparator));
|
|
};
|
|
return FuncFormatter2;
|
|
}();
|
|
function createFormatter(input) {
|
|
if (typeof input === "object" && input) {
|
|
return new NativeFormatter(input);
|
|
}
|
|
if (typeof input === "string") {
|
|
return new CmdFormatter(input);
|
|
}
|
|
if (typeof input === "function") {
|
|
return new FuncFormatter(input);
|
|
}
|
|
return null;
|
|
}
|
|
var BASE_OPTION_REFINERS = {
|
|
navLinkDayClick: identity,
|
|
navLinkWeekClick: identity,
|
|
duration: createDuration,
|
|
bootstrapFontAwesome: identity,
|
|
buttonIcons: identity,
|
|
customButtons: identity,
|
|
defaultAllDayEventDuration: createDuration,
|
|
defaultTimedEventDuration: createDuration,
|
|
nextDayThreshold: createDuration,
|
|
scrollTime: createDuration,
|
|
scrollTimeReset: Boolean,
|
|
slotMinTime: createDuration,
|
|
slotMaxTime: createDuration,
|
|
dayPopoverFormat: createFormatter,
|
|
slotDuration: createDuration,
|
|
snapDuration: createDuration,
|
|
headerToolbar: identity,
|
|
footerToolbar: identity,
|
|
defaultRangeSeparator: String,
|
|
titleRangeSeparator: String,
|
|
forceEventDuration: Boolean,
|
|
dayHeaders: Boolean,
|
|
dayHeaderFormat: createFormatter,
|
|
dayHeaderClassNames: identity,
|
|
dayHeaderContent: identity,
|
|
dayHeaderDidMount: identity,
|
|
dayHeaderWillUnmount: identity,
|
|
dayCellClassNames: identity,
|
|
dayCellContent: identity,
|
|
dayCellDidMount: identity,
|
|
dayCellWillUnmount: identity,
|
|
initialView: String,
|
|
aspectRatio: Number,
|
|
weekends: Boolean,
|
|
weekNumberCalculation: identity,
|
|
weekNumbers: Boolean,
|
|
weekNumberClassNames: identity,
|
|
weekNumberContent: identity,
|
|
weekNumberDidMount: identity,
|
|
weekNumberWillUnmount: identity,
|
|
editable: Boolean,
|
|
viewClassNames: identity,
|
|
viewDidMount: identity,
|
|
viewWillUnmount: identity,
|
|
nowIndicator: Boolean,
|
|
nowIndicatorClassNames: identity,
|
|
nowIndicatorContent: identity,
|
|
nowIndicatorDidMount: identity,
|
|
nowIndicatorWillUnmount: identity,
|
|
showNonCurrentDates: Boolean,
|
|
lazyFetching: Boolean,
|
|
startParam: String,
|
|
endParam: String,
|
|
timeZoneParam: String,
|
|
timeZone: String,
|
|
locales: identity,
|
|
locale: identity,
|
|
themeSystem: String,
|
|
dragRevertDuration: Number,
|
|
dragScroll: Boolean,
|
|
allDayMaintainDuration: Boolean,
|
|
unselectAuto: Boolean,
|
|
dropAccept: identity,
|
|
eventOrder: parseFieldSpecs,
|
|
eventOrderStrict: Boolean,
|
|
handleWindowResize: Boolean,
|
|
windowResizeDelay: Number,
|
|
longPressDelay: Number,
|
|
eventDragMinDistance: Number,
|
|
expandRows: Boolean,
|
|
height: identity,
|
|
contentHeight: identity,
|
|
direction: String,
|
|
weekNumberFormat: createFormatter,
|
|
eventResizableFromStart: Boolean,
|
|
displayEventTime: Boolean,
|
|
displayEventEnd: Boolean,
|
|
weekText: String,
|
|
weekTextLong: String,
|
|
progressiveEventRendering: Boolean,
|
|
businessHours: identity,
|
|
initialDate: identity,
|
|
now: identity,
|
|
eventDataTransform: identity,
|
|
stickyHeaderDates: identity,
|
|
stickyFooterScrollbar: identity,
|
|
viewHeight: identity,
|
|
defaultAllDay: Boolean,
|
|
eventSourceFailure: identity,
|
|
eventSourceSuccess: identity,
|
|
eventDisplay: String,
|
|
eventStartEditable: Boolean,
|
|
eventDurationEditable: Boolean,
|
|
eventOverlap: identity,
|
|
eventConstraint: identity,
|
|
eventAllow: identity,
|
|
eventBackgroundColor: String,
|
|
eventBorderColor: String,
|
|
eventTextColor: String,
|
|
eventColor: String,
|
|
eventClassNames: identity,
|
|
eventContent: identity,
|
|
eventDidMount: identity,
|
|
eventWillUnmount: identity,
|
|
selectConstraint: identity,
|
|
selectOverlap: identity,
|
|
selectAllow: identity,
|
|
droppable: Boolean,
|
|
unselectCancel: String,
|
|
slotLabelFormat: identity,
|
|
slotLaneClassNames: identity,
|
|
slotLaneContent: identity,
|
|
slotLaneDidMount: identity,
|
|
slotLaneWillUnmount: identity,
|
|
slotLabelClassNames: identity,
|
|
slotLabelContent: identity,
|
|
slotLabelDidMount: identity,
|
|
slotLabelWillUnmount: identity,
|
|
dayMaxEvents: identity,
|
|
dayMaxEventRows: identity,
|
|
dayMinWidth: Number,
|
|
slotLabelInterval: createDuration,
|
|
allDayText: String,
|
|
allDayClassNames: identity,
|
|
allDayContent: identity,
|
|
allDayDidMount: identity,
|
|
allDayWillUnmount: identity,
|
|
slotMinWidth: Number,
|
|
navLinks: Boolean,
|
|
eventTimeFormat: createFormatter,
|
|
rerenderDelay: Number,
|
|
moreLinkText: identity,
|
|
moreLinkHint: identity,
|
|
selectMinDistance: Number,
|
|
selectable: Boolean,
|
|
selectLongPressDelay: Number,
|
|
eventLongPressDelay: Number,
|
|
selectMirror: Boolean,
|
|
eventMaxStack: Number,
|
|
eventMinHeight: Number,
|
|
eventMinWidth: Number,
|
|
eventShortHeight: Number,
|
|
slotEventOverlap: Boolean,
|
|
plugins: identity,
|
|
firstDay: Number,
|
|
dayCount: Number,
|
|
dateAlignment: String,
|
|
dateIncrement: createDuration,
|
|
hiddenDays: identity,
|
|
monthMode: Boolean,
|
|
fixedWeekCount: Boolean,
|
|
validRange: identity,
|
|
visibleRange: identity,
|
|
titleFormat: identity,
|
|
eventInteractive: Boolean,
|
|
noEventsText: String,
|
|
viewHint: identity,
|
|
navLinkHint: identity,
|
|
closeHint: String,
|
|
timeHint: String,
|
|
eventHint: String,
|
|
moreLinkClick: identity,
|
|
moreLinkClassNames: identity,
|
|
moreLinkContent: identity,
|
|
moreLinkDidMount: identity,
|
|
moreLinkWillUnmount: identity
|
|
};
|
|
var BASE_OPTION_DEFAULTS = {
|
|
eventDisplay: "auto",
|
|
defaultRangeSeparator: " - ",
|
|
titleRangeSeparator: " \u2013 ",
|
|
defaultTimedEventDuration: "01:00:00",
|
|
defaultAllDayEventDuration: { day: 1 },
|
|
forceEventDuration: false,
|
|
nextDayThreshold: "00:00:00",
|
|
dayHeaders: true,
|
|
initialView: "",
|
|
aspectRatio: 1.35,
|
|
headerToolbar: {
|
|
start: "title",
|
|
center: "",
|
|
end: "today prev,next"
|
|
},
|
|
weekends: true,
|
|
weekNumbers: false,
|
|
weekNumberCalculation: "local",
|
|
editable: false,
|
|
nowIndicator: false,
|
|
scrollTime: "06:00:00",
|
|
scrollTimeReset: true,
|
|
slotMinTime: "00:00:00",
|
|
slotMaxTime: "24:00:00",
|
|
showNonCurrentDates: true,
|
|
lazyFetching: true,
|
|
startParam: "start",
|
|
endParam: "end",
|
|
timeZoneParam: "timeZone",
|
|
timeZone: "local",
|
|
locales: [],
|
|
locale: "",
|
|
themeSystem: "standard",
|
|
dragRevertDuration: 500,
|
|
dragScroll: true,
|
|
allDayMaintainDuration: false,
|
|
unselectAuto: true,
|
|
dropAccept: "*",
|
|
eventOrder: "start,-duration,allDay,title",
|
|
dayPopoverFormat: { month: "long", day: "numeric", year: "numeric" },
|
|
handleWindowResize: true,
|
|
windowResizeDelay: 100,
|
|
longPressDelay: 1e3,
|
|
eventDragMinDistance: 5,
|
|
expandRows: false,
|
|
navLinks: false,
|
|
selectable: false,
|
|
eventMinHeight: 15,
|
|
eventMinWidth: 30,
|
|
eventShortHeight: 30
|
|
};
|
|
var CALENDAR_LISTENER_REFINERS = {
|
|
datesSet: identity,
|
|
eventsSet: identity,
|
|
eventAdd: identity,
|
|
eventChange: identity,
|
|
eventRemove: identity,
|
|
windowResize: identity,
|
|
eventClick: identity,
|
|
eventMouseEnter: identity,
|
|
eventMouseLeave: identity,
|
|
select: identity,
|
|
unselect: identity,
|
|
loading: identity,
|
|
_unmount: identity,
|
|
_beforeprint: identity,
|
|
_afterprint: identity,
|
|
_noEventDrop: identity,
|
|
_noEventResize: identity,
|
|
_resize: identity,
|
|
_scrollRequest: identity
|
|
};
|
|
var CALENDAR_OPTION_REFINERS = {
|
|
buttonText: identity,
|
|
buttonHints: identity,
|
|
views: identity,
|
|
plugins: identity,
|
|
initialEvents: identity,
|
|
events: identity,
|
|
eventSources: identity
|
|
};
|
|
var COMPLEX_OPTION_COMPARATORS = {
|
|
headerToolbar: isBoolComplexEqual,
|
|
footerToolbar: isBoolComplexEqual,
|
|
buttonText: isBoolComplexEqual,
|
|
buttonHints: isBoolComplexEqual,
|
|
buttonIcons: isBoolComplexEqual
|
|
};
|
|
function isBoolComplexEqual(a3, b3) {
|
|
if (typeof a3 === "object" && typeof b3 === "object" && a3 && b3) {
|
|
return isPropsEqual(a3, b3);
|
|
}
|
|
return a3 === b3;
|
|
}
|
|
var VIEW_OPTION_REFINERS = {
|
|
type: String,
|
|
component: identity,
|
|
buttonText: String,
|
|
buttonTextKey: String,
|
|
dateProfileGeneratorClass: identity,
|
|
usesMinMaxTime: Boolean,
|
|
classNames: identity,
|
|
content: identity,
|
|
didMount: identity,
|
|
willUnmount: identity
|
|
};
|
|
function mergeRawOptions(optionSets) {
|
|
return mergeProps(optionSets, COMPLEX_OPTION_COMPARATORS);
|
|
}
|
|
function refineProps(input, refiners) {
|
|
var refined = {};
|
|
var extra = {};
|
|
for (var propName in refiners) {
|
|
if (propName in input) {
|
|
refined[propName] = refiners[propName](input[propName]);
|
|
}
|
|
}
|
|
for (var propName in input) {
|
|
if (!(propName in refiners)) {
|
|
extra[propName] = input[propName];
|
|
}
|
|
}
|
|
return { refined, extra };
|
|
}
|
|
function identity(raw) {
|
|
return raw;
|
|
}
|
|
function parseEvents(rawEvents, eventSource, context, allowOpenRange) {
|
|
var eventStore = createEmptyEventStore();
|
|
var eventRefiners = buildEventRefiners(context);
|
|
for (var _i = 0, rawEvents_1 = rawEvents; _i < rawEvents_1.length; _i++) {
|
|
var rawEvent = rawEvents_1[_i];
|
|
var tuple = parseEvent(rawEvent, eventSource, context, allowOpenRange, eventRefiners);
|
|
if (tuple) {
|
|
eventTupleToStore(tuple, eventStore);
|
|
}
|
|
}
|
|
return eventStore;
|
|
}
|
|
function eventTupleToStore(tuple, eventStore) {
|
|
if (eventStore === void 0) {
|
|
eventStore = createEmptyEventStore();
|
|
}
|
|
eventStore.defs[tuple.def.defId] = tuple.def;
|
|
if (tuple.instance) {
|
|
eventStore.instances[tuple.instance.instanceId] = tuple.instance;
|
|
}
|
|
return eventStore;
|
|
}
|
|
function getRelevantEvents(eventStore, instanceId) {
|
|
var instance = eventStore.instances[instanceId];
|
|
if (instance) {
|
|
var def_1 = eventStore.defs[instance.defId];
|
|
var newStore = filterEventStoreDefs(eventStore, function(lookDef) {
|
|
return isEventDefsGrouped(def_1, lookDef);
|
|
});
|
|
newStore.defs[def_1.defId] = def_1;
|
|
newStore.instances[instance.instanceId] = instance;
|
|
return newStore;
|
|
}
|
|
return createEmptyEventStore();
|
|
}
|
|
function isEventDefsGrouped(def0, def1) {
|
|
return Boolean(def0.groupId && def0.groupId === def1.groupId);
|
|
}
|
|
function createEmptyEventStore() {
|
|
return { defs: {}, instances: {} };
|
|
}
|
|
function mergeEventStores(store0, store1) {
|
|
return {
|
|
defs: __assign(__assign({}, store0.defs), store1.defs),
|
|
instances: __assign(__assign({}, store0.instances), store1.instances)
|
|
};
|
|
}
|
|
function filterEventStoreDefs(eventStore, filterFunc) {
|
|
var defs = filterHash(eventStore.defs, filterFunc);
|
|
var instances = filterHash(eventStore.instances, function(instance) {
|
|
return defs[instance.defId];
|
|
});
|
|
return { defs, instances };
|
|
}
|
|
function excludeSubEventStore(master, sub) {
|
|
var defs = master.defs, instances = master.instances;
|
|
var filteredDefs = {};
|
|
var filteredInstances = {};
|
|
for (var defId in defs) {
|
|
if (!sub.defs[defId]) {
|
|
filteredDefs[defId] = defs[defId];
|
|
}
|
|
}
|
|
for (var instanceId in instances) {
|
|
if (!sub.instances[instanceId] && filteredDefs[instances[instanceId].defId]) {
|
|
filteredInstances[instanceId] = instances[instanceId];
|
|
}
|
|
}
|
|
return {
|
|
defs: filteredDefs,
|
|
instances: filteredInstances
|
|
};
|
|
}
|
|
function normalizeConstraint(input, context) {
|
|
if (Array.isArray(input)) {
|
|
return parseEvents(input, null, context, true);
|
|
}
|
|
if (typeof input === "object" && input) {
|
|
return parseEvents([input], null, context, true);
|
|
}
|
|
if (input != null) {
|
|
return String(input);
|
|
}
|
|
return null;
|
|
}
|
|
function parseClassNames(raw) {
|
|
if (Array.isArray(raw)) {
|
|
return raw;
|
|
}
|
|
if (typeof raw === "string") {
|
|
return raw.split(/\s+/);
|
|
}
|
|
return [];
|
|
}
|
|
var EVENT_UI_REFINERS = {
|
|
display: String,
|
|
editable: Boolean,
|
|
startEditable: Boolean,
|
|
durationEditable: Boolean,
|
|
constraint: identity,
|
|
overlap: identity,
|
|
allow: identity,
|
|
className: parseClassNames,
|
|
classNames: parseClassNames,
|
|
color: String,
|
|
backgroundColor: String,
|
|
borderColor: String,
|
|
textColor: String
|
|
};
|
|
var EMPTY_EVENT_UI = {
|
|
display: null,
|
|
startEditable: null,
|
|
durationEditable: null,
|
|
constraints: [],
|
|
overlap: null,
|
|
allows: [],
|
|
backgroundColor: "",
|
|
borderColor: "",
|
|
textColor: "",
|
|
classNames: []
|
|
};
|
|
function createEventUi(refined, context) {
|
|
var constraint = normalizeConstraint(refined.constraint, context);
|
|
return {
|
|
display: refined.display || null,
|
|
startEditable: refined.startEditable != null ? refined.startEditable : refined.editable,
|
|
durationEditable: refined.durationEditable != null ? refined.durationEditable : refined.editable,
|
|
constraints: constraint != null ? [constraint] : [],
|
|
overlap: refined.overlap != null ? refined.overlap : null,
|
|
allows: refined.allow != null ? [refined.allow] : [],
|
|
backgroundColor: refined.backgroundColor || refined.color || "",
|
|
borderColor: refined.borderColor || refined.color || "",
|
|
textColor: refined.textColor || "",
|
|
classNames: (refined.className || []).concat(refined.classNames || [])
|
|
};
|
|
}
|
|
function combineEventUis(uis) {
|
|
return uis.reduce(combineTwoEventUis, EMPTY_EVENT_UI);
|
|
}
|
|
function combineTwoEventUis(item0, item1) {
|
|
return {
|
|
display: item1.display != null ? item1.display : item0.display,
|
|
startEditable: item1.startEditable != null ? item1.startEditable : item0.startEditable,
|
|
durationEditable: item1.durationEditable != null ? item1.durationEditable : item0.durationEditable,
|
|
constraints: item0.constraints.concat(item1.constraints),
|
|
overlap: typeof item1.overlap === "boolean" ? item1.overlap : item0.overlap,
|
|
allows: item0.allows.concat(item1.allows),
|
|
backgroundColor: item1.backgroundColor || item0.backgroundColor,
|
|
borderColor: item1.borderColor || item0.borderColor,
|
|
textColor: item1.textColor || item0.textColor,
|
|
classNames: item0.classNames.concat(item1.classNames)
|
|
};
|
|
}
|
|
var EVENT_NON_DATE_REFINERS = {
|
|
id: String,
|
|
groupId: String,
|
|
title: String,
|
|
url: String,
|
|
interactive: Boolean
|
|
};
|
|
var EVENT_DATE_REFINERS = {
|
|
start: identity,
|
|
end: identity,
|
|
date: identity,
|
|
allDay: Boolean
|
|
};
|
|
var EVENT_REFINERS = __assign(__assign(__assign({}, EVENT_NON_DATE_REFINERS), EVENT_DATE_REFINERS), { extendedProps: identity });
|
|
function parseEvent(raw, eventSource, context, allowOpenRange, refiners) {
|
|
if (refiners === void 0) {
|
|
refiners = buildEventRefiners(context);
|
|
}
|
|
var _a = refineEventDef(raw, context, refiners), refined = _a.refined, extra = _a.extra;
|
|
var defaultAllDay = computeIsDefaultAllDay(eventSource, context);
|
|
var recurringRes = parseRecurring(refined, defaultAllDay, context.dateEnv, context.pluginHooks.recurringTypes);
|
|
if (recurringRes) {
|
|
var def = parseEventDef(refined, extra, eventSource ? eventSource.sourceId : "", recurringRes.allDay, Boolean(recurringRes.duration), context);
|
|
def.recurringDef = {
|
|
typeId: recurringRes.typeId,
|
|
typeData: recurringRes.typeData,
|
|
duration: recurringRes.duration
|
|
};
|
|
return { def, instance: null };
|
|
}
|
|
var singleRes = parseSingle(refined, defaultAllDay, context, allowOpenRange);
|
|
if (singleRes) {
|
|
var def = parseEventDef(refined, extra, eventSource ? eventSource.sourceId : "", singleRes.allDay, singleRes.hasEnd, context);
|
|
var instance = createEventInstance(def.defId, singleRes.range, singleRes.forcedStartTzo, singleRes.forcedEndTzo);
|
|
return { def, instance };
|
|
}
|
|
return null;
|
|
}
|
|
function refineEventDef(raw, context, refiners) {
|
|
if (refiners === void 0) {
|
|
refiners = buildEventRefiners(context);
|
|
}
|
|
return refineProps(raw, refiners);
|
|
}
|
|
function buildEventRefiners(context) {
|
|
return __assign(__assign(__assign({}, EVENT_UI_REFINERS), EVENT_REFINERS), context.pluginHooks.eventRefiners);
|
|
}
|
|
function parseEventDef(refined, extra, sourceId, allDay, hasEnd, context) {
|
|
var def = {
|
|
title: refined.title || "",
|
|
groupId: refined.groupId || "",
|
|
publicId: refined.id || "",
|
|
url: refined.url || "",
|
|
recurringDef: null,
|
|
defId: guid(),
|
|
sourceId,
|
|
allDay,
|
|
hasEnd,
|
|
interactive: refined.interactive,
|
|
ui: createEventUi(refined, context),
|
|
extendedProps: __assign(__assign({}, refined.extendedProps || {}), extra)
|
|
};
|
|
for (var _i = 0, _a = context.pluginHooks.eventDefMemberAdders; _i < _a.length; _i++) {
|
|
var memberAdder = _a[_i];
|
|
__assign(def, memberAdder(refined));
|
|
}
|
|
Object.freeze(def.ui.classNames);
|
|
Object.freeze(def.extendedProps);
|
|
return def;
|
|
}
|
|
function parseSingle(refined, defaultAllDay, context, allowOpenRange) {
|
|
var allDay = refined.allDay;
|
|
var startMeta;
|
|
var startMarker = null;
|
|
var hasEnd = false;
|
|
var endMeta;
|
|
var endMarker = null;
|
|
var startInput = refined.start != null ? refined.start : refined.date;
|
|
startMeta = context.dateEnv.createMarkerMeta(startInput);
|
|
if (startMeta) {
|
|
startMarker = startMeta.marker;
|
|
} else if (!allowOpenRange) {
|
|
return null;
|
|
}
|
|
if (refined.end != null) {
|
|
endMeta = context.dateEnv.createMarkerMeta(refined.end);
|
|
}
|
|
if (allDay == null) {
|
|
if (defaultAllDay != null) {
|
|
allDay = defaultAllDay;
|
|
} else {
|
|
allDay = (!startMeta || startMeta.isTimeUnspecified) && (!endMeta || endMeta.isTimeUnspecified);
|
|
}
|
|
}
|
|
if (allDay && startMarker) {
|
|
startMarker = startOfDay(startMarker);
|
|
}
|
|
if (endMeta) {
|
|
endMarker = endMeta.marker;
|
|
if (allDay) {
|
|
endMarker = startOfDay(endMarker);
|
|
}
|
|
if (startMarker && endMarker <= startMarker) {
|
|
endMarker = null;
|
|
}
|
|
}
|
|
if (endMarker) {
|
|
hasEnd = true;
|
|
} else if (!allowOpenRange) {
|
|
hasEnd = context.options.forceEventDuration || false;
|
|
endMarker = context.dateEnv.add(startMarker, allDay ? context.options.defaultAllDayEventDuration : context.options.defaultTimedEventDuration);
|
|
}
|
|
return {
|
|
allDay,
|
|
hasEnd,
|
|
range: { start: startMarker, end: endMarker },
|
|
forcedStartTzo: startMeta ? startMeta.forcedTzo : null,
|
|
forcedEndTzo: endMeta ? endMeta.forcedTzo : null
|
|
};
|
|
}
|
|
function computeIsDefaultAllDay(eventSource, context) {
|
|
var res = null;
|
|
if (eventSource) {
|
|
res = eventSource.defaultAllDay;
|
|
}
|
|
if (res == null) {
|
|
res = context.options.defaultAllDay;
|
|
}
|
|
return res;
|
|
}
|
|
function computeAlignedDayRange(timedRange) {
|
|
var dayCnt = Math.floor(diffDays(timedRange.start, timedRange.end)) || 1;
|
|
var start = startOfDay(timedRange.start);
|
|
var end = addDays(start, dayCnt);
|
|
return { start, end };
|
|
}
|
|
function computeVisibleDayRange(timedRange, nextDayThreshold) {
|
|
if (nextDayThreshold === void 0) {
|
|
nextDayThreshold = createDuration(0);
|
|
}
|
|
var startDay = null;
|
|
var endDay = null;
|
|
if (timedRange.end) {
|
|
endDay = startOfDay(timedRange.end);
|
|
var endTimeMS = timedRange.end.valueOf() - endDay.valueOf();
|
|
if (endTimeMS && endTimeMS >= asRoughMs(nextDayThreshold)) {
|
|
endDay = addDays(endDay, 1);
|
|
}
|
|
}
|
|
if (timedRange.start) {
|
|
startDay = startOfDay(timedRange.start);
|
|
if (endDay && endDay <= startDay) {
|
|
endDay = addDays(startDay, 1);
|
|
}
|
|
}
|
|
return { start: startDay, end: endDay };
|
|
}
|
|
function isMultiDayRange(range) {
|
|
var visibleRange = computeVisibleDayRange(range);
|
|
return diffDays(visibleRange.start, visibleRange.end) > 1;
|
|
}
|
|
function diffDates(date0, date1, dateEnv, largeUnit) {
|
|
if (largeUnit === "year") {
|
|
return createDuration(dateEnv.diffWholeYears(date0, date1), "year");
|
|
}
|
|
if (largeUnit === "month") {
|
|
return createDuration(dateEnv.diffWholeMonths(date0, date1), "month");
|
|
}
|
|
return diffDayAndTime(date0, date1);
|
|
}
|
|
function parseRange(input, dateEnv) {
|
|
var start = null;
|
|
var end = null;
|
|
if (input.start) {
|
|
start = dateEnv.createMarker(input.start);
|
|
}
|
|
if (input.end) {
|
|
end = dateEnv.createMarker(input.end);
|
|
}
|
|
if (!start && !end) {
|
|
return null;
|
|
}
|
|
if (start && end && end < start) {
|
|
return null;
|
|
}
|
|
return { start, end };
|
|
}
|
|
function invertRanges(ranges, constraintRange) {
|
|
var invertedRanges = [];
|
|
var start = constraintRange.start;
|
|
var i3;
|
|
var dateRange;
|
|
ranges.sort(compareRanges);
|
|
for (i3 = 0; i3 < ranges.length; i3 += 1) {
|
|
dateRange = ranges[i3];
|
|
if (dateRange.start > start) {
|
|
invertedRanges.push({ start, end: dateRange.start });
|
|
}
|
|
if (dateRange.end > start) {
|
|
start = dateRange.end;
|
|
}
|
|
}
|
|
if (start < constraintRange.end) {
|
|
invertedRanges.push({ start, end: constraintRange.end });
|
|
}
|
|
return invertedRanges;
|
|
}
|
|
function compareRanges(range0, range1) {
|
|
return range0.start.valueOf() - range1.start.valueOf();
|
|
}
|
|
function intersectRanges(range0, range1) {
|
|
var start = range0.start, end = range0.end;
|
|
var newRange = null;
|
|
if (range1.start !== null) {
|
|
if (start === null) {
|
|
start = range1.start;
|
|
} else {
|
|
start = new Date(Math.max(start.valueOf(), range1.start.valueOf()));
|
|
}
|
|
}
|
|
if (range1.end != null) {
|
|
if (end === null) {
|
|
end = range1.end;
|
|
} else {
|
|
end = new Date(Math.min(end.valueOf(), range1.end.valueOf()));
|
|
}
|
|
}
|
|
if (start === null || end === null || start < end) {
|
|
newRange = { start, end };
|
|
}
|
|
return newRange;
|
|
}
|
|
function rangesEqual(range0, range1) {
|
|
return (range0.start === null ? null : range0.start.valueOf()) === (range1.start === null ? null : range1.start.valueOf()) && (range0.end === null ? null : range0.end.valueOf()) === (range1.end === null ? null : range1.end.valueOf());
|
|
}
|
|
function rangesIntersect(range0, range1) {
|
|
return (range0.end === null || range1.start === null || range0.end > range1.start) && (range0.start === null || range1.end === null || range0.start < range1.end);
|
|
}
|
|
function rangeContainsRange(outerRange, innerRange) {
|
|
return (outerRange.start === null || innerRange.start !== null && innerRange.start >= outerRange.start) && (outerRange.end === null || innerRange.end !== null && innerRange.end <= outerRange.end);
|
|
}
|
|
function rangeContainsMarker(range, date) {
|
|
return (range.start === null || date >= range.start) && (range.end === null || date < range.end);
|
|
}
|
|
function constrainMarkerToRange(date, range) {
|
|
if (range.start != null && date < range.start) {
|
|
return range.start;
|
|
}
|
|
if (range.end != null && date >= range.end) {
|
|
return new Date(range.end.valueOf() - 1);
|
|
}
|
|
return date;
|
|
}
|
|
function sliceEventStore(eventStore, eventUiBases, framingRange, nextDayThreshold) {
|
|
var inverseBgByGroupId = {};
|
|
var inverseBgByDefId = {};
|
|
var defByGroupId = {};
|
|
var bgRanges = [];
|
|
var fgRanges = [];
|
|
var eventUis = compileEventUis(eventStore.defs, eventUiBases);
|
|
for (var defId in eventStore.defs) {
|
|
var def = eventStore.defs[defId];
|
|
var ui = eventUis[def.defId];
|
|
if (ui.display === "inverse-background") {
|
|
if (def.groupId) {
|
|
inverseBgByGroupId[def.groupId] = [];
|
|
if (!defByGroupId[def.groupId]) {
|
|
defByGroupId[def.groupId] = def;
|
|
}
|
|
} else {
|
|
inverseBgByDefId[defId] = [];
|
|
}
|
|
}
|
|
}
|
|
for (var instanceId in eventStore.instances) {
|
|
var instance = eventStore.instances[instanceId];
|
|
var def = eventStore.defs[instance.defId];
|
|
var ui = eventUis[def.defId];
|
|
var origRange = instance.range;
|
|
var normalRange = !def.allDay && nextDayThreshold ? computeVisibleDayRange(origRange, nextDayThreshold) : origRange;
|
|
var slicedRange = intersectRanges(normalRange, framingRange);
|
|
if (slicedRange) {
|
|
if (ui.display === "inverse-background") {
|
|
if (def.groupId) {
|
|
inverseBgByGroupId[def.groupId].push(slicedRange);
|
|
} else {
|
|
inverseBgByDefId[instance.defId].push(slicedRange);
|
|
}
|
|
} else if (ui.display !== "none") {
|
|
(ui.display === "background" ? bgRanges : fgRanges).push({
|
|
def,
|
|
ui,
|
|
instance,
|
|
range: slicedRange,
|
|
isStart: normalRange.start && normalRange.start.valueOf() === slicedRange.start.valueOf(),
|
|
isEnd: normalRange.end && normalRange.end.valueOf() === slicedRange.end.valueOf()
|
|
});
|
|
}
|
|
}
|
|
}
|
|
for (var groupId in inverseBgByGroupId) {
|
|
var ranges = inverseBgByGroupId[groupId];
|
|
var invertedRanges = invertRanges(ranges, framingRange);
|
|
for (var _i = 0, invertedRanges_1 = invertedRanges; _i < invertedRanges_1.length; _i++) {
|
|
var invertedRange = invertedRanges_1[_i];
|
|
var def = defByGroupId[groupId];
|
|
var ui = eventUis[def.defId];
|
|
bgRanges.push({
|
|
def,
|
|
ui,
|
|
instance: null,
|
|
range: invertedRange,
|
|
isStart: false,
|
|
isEnd: false
|
|
});
|
|
}
|
|
}
|
|
for (var defId in inverseBgByDefId) {
|
|
var ranges = inverseBgByDefId[defId];
|
|
var invertedRanges = invertRanges(ranges, framingRange);
|
|
for (var _a = 0, invertedRanges_2 = invertedRanges; _a < invertedRanges_2.length; _a++) {
|
|
var invertedRange = invertedRanges_2[_a];
|
|
bgRanges.push({
|
|
def: eventStore.defs[defId],
|
|
ui: eventUis[defId],
|
|
instance: null,
|
|
range: invertedRange,
|
|
isStart: false,
|
|
isEnd: false
|
|
});
|
|
}
|
|
}
|
|
return { bg: bgRanges, fg: fgRanges };
|
|
}
|
|
function hasBgRendering(def) {
|
|
return def.ui.display === "background" || def.ui.display === "inverse-background";
|
|
}
|
|
function setElSeg(el, seg) {
|
|
el.fcSeg = seg;
|
|
}
|
|
function getElSeg(el) {
|
|
return el.fcSeg || el.parentNode.fcSeg || null;
|
|
}
|
|
function compileEventUis(eventDefs, eventUiBases) {
|
|
return mapHash(eventDefs, function(eventDef) {
|
|
return compileEventUi(eventDef, eventUiBases);
|
|
});
|
|
}
|
|
function compileEventUi(eventDef, eventUiBases) {
|
|
var uis = [];
|
|
if (eventUiBases[""]) {
|
|
uis.push(eventUiBases[""]);
|
|
}
|
|
if (eventUiBases[eventDef.defId]) {
|
|
uis.push(eventUiBases[eventDef.defId]);
|
|
}
|
|
uis.push(eventDef.ui);
|
|
return combineEventUis(uis);
|
|
}
|
|
function sortEventSegs(segs, eventOrderSpecs) {
|
|
var objs = segs.map(buildSegCompareObj);
|
|
objs.sort(function(obj0, obj1) {
|
|
return compareByFieldSpecs(obj0, obj1, eventOrderSpecs);
|
|
});
|
|
return objs.map(function(c3) {
|
|
return c3._seg;
|
|
});
|
|
}
|
|
function buildSegCompareObj(seg) {
|
|
var eventRange = seg.eventRange;
|
|
var eventDef = eventRange.def;
|
|
var range = eventRange.instance ? eventRange.instance.range : eventRange.range;
|
|
var start = range.start ? range.start.valueOf() : 0;
|
|
var end = range.end ? range.end.valueOf() : 0;
|
|
return __assign(__assign(__assign({}, eventDef.extendedProps), eventDef), {
|
|
id: eventDef.publicId,
|
|
start,
|
|
end,
|
|
duration: end - start,
|
|
allDay: Number(eventDef.allDay),
|
|
_seg: seg
|
|
});
|
|
}
|
|
function computeSegDraggable(seg, context) {
|
|
var pluginHooks = context.pluginHooks;
|
|
var transformers = pluginHooks.isDraggableTransformers;
|
|
var _a = seg.eventRange, def = _a.def, ui = _a.ui;
|
|
var val = ui.startEditable;
|
|
for (var _i = 0, transformers_1 = transformers; _i < transformers_1.length; _i++) {
|
|
var transformer = transformers_1[_i];
|
|
val = transformer(val, def, ui, context);
|
|
}
|
|
return val;
|
|
}
|
|
function computeSegStartResizable(seg, context) {
|
|
return seg.isStart && seg.eventRange.ui.durationEditable && context.options.eventResizableFromStart;
|
|
}
|
|
function computeSegEndResizable(seg, context) {
|
|
return seg.isEnd && seg.eventRange.ui.durationEditable;
|
|
}
|
|
function buildSegTimeText(seg, timeFormat, context, defaultDisplayEventTime, defaultDisplayEventEnd, startOverride, endOverride) {
|
|
var dateEnv = context.dateEnv, options = context.options;
|
|
var displayEventTime = options.displayEventTime, displayEventEnd = options.displayEventEnd;
|
|
var eventDef = seg.eventRange.def;
|
|
var eventInstance = seg.eventRange.instance;
|
|
if (displayEventTime == null) {
|
|
displayEventTime = defaultDisplayEventTime !== false;
|
|
}
|
|
if (displayEventEnd == null) {
|
|
displayEventEnd = defaultDisplayEventEnd !== false;
|
|
}
|
|
var wholeEventStart = eventInstance.range.start;
|
|
var wholeEventEnd = eventInstance.range.end;
|
|
var segStart = startOverride || seg.start || seg.eventRange.range.start;
|
|
var segEnd = endOverride || seg.end || seg.eventRange.range.end;
|
|
var isStartDay = startOfDay(wholeEventStart).valueOf() === startOfDay(segStart).valueOf();
|
|
var isEndDay = startOfDay(addMs(wholeEventEnd, -1)).valueOf() === startOfDay(addMs(segEnd, -1)).valueOf();
|
|
if (displayEventTime && !eventDef.allDay && (isStartDay || isEndDay)) {
|
|
segStart = isStartDay ? wholeEventStart : segStart;
|
|
segEnd = isEndDay ? wholeEventEnd : segEnd;
|
|
if (displayEventEnd && eventDef.hasEnd) {
|
|
return dateEnv.formatRange(segStart, segEnd, timeFormat, {
|
|
forcedStartTzo: startOverride ? null : eventInstance.forcedStartTzo,
|
|
forcedEndTzo: endOverride ? null : eventInstance.forcedEndTzo
|
|
});
|
|
}
|
|
return dateEnv.format(segStart, timeFormat, {
|
|
forcedTzo: startOverride ? null : eventInstance.forcedStartTzo
|
|
});
|
|
}
|
|
return "";
|
|
}
|
|
function getSegMeta(seg, todayRange, nowDate) {
|
|
var segRange = seg.eventRange.range;
|
|
return {
|
|
isPast: segRange.end < (nowDate || todayRange.start),
|
|
isFuture: segRange.start >= (nowDate || todayRange.end),
|
|
isToday: todayRange && rangeContainsMarker(todayRange, segRange.start)
|
|
};
|
|
}
|
|
function getEventClassNames(props) {
|
|
var classNames = ["fc-event"];
|
|
if (props.isMirror) {
|
|
classNames.push("fc-event-mirror");
|
|
}
|
|
if (props.isDraggable) {
|
|
classNames.push("fc-event-draggable");
|
|
}
|
|
if (props.isStartResizable || props.isEndResizable) {
|
|
classNames.push("fc-event-resizable");
|
|
}
|
|
if (props.isDragging) {
|
|
classNames.push("fc-event-dragging");
|
|
}
|
|
if (props.isResizing) {
|
|
classNames.push("fc-event-resizing");
|
|
}
|
|
if (props.isSelected) {
|
|
classNames.push("fc-event-selected");
|
|
}
|
|
if (props.isStart) {
|
|
classNames.push("fc-event-start");
|
|
}
|
|
if (props.isEnd) {
|
|
classNames.push("fc-event-end");
|
|
}
|
|
if (props.isPast) {
|
|
classNames.push("fc-event-past");
|
|
}
|
|
if (props.isToday) {
|
|
classNames.push("fc-event-today");
|
|
}
|
|
if (props.isFuture) {
|
|
classNames.push("fc-event-future");
|
|
}
|
|
return classNames;
|
|
}
|
|
function buildEventRangeKey(eventRange) {
|
|
return eventRange.instance ? eventRange.instance.instanceId : eventRange.def.defId + ":" + eventRange.range.start.toISOString();
|
|
}
|
|
function getSegAnchorAttrs(seg, context) {
|
|
var _a = seg.eventRange, def = _a.def, instance = _a.instance;
|
|
var url = def.url;
|
|
if (url) {
|
|
return { href: url };
|
|
}
|
|
var emitter = context.emitter, options = context.options;
|
|
var eventInteractive = options.eventInteractive;
|
|
if (eventInteractive == null) {
|
|
eventInteractive = def.interactive;
|
|
if (eventInteractive == null) {
|
|
eventInteractive = Boolean(emitter.hasHandlers("eventClick"));
|
|
}
|
|
}
|
|
if (eventInteractive) {
|
|
return createAriaKeyboardAttrs(function(ev) {
|
|
emitter.trigger("eventClick", {
|
|
el: ev.target,
|
|
event: new EventApi(context, def, instance),
|
|
jsEvent: ev,
|
|
view: context.viewApi
|
|
});
|
|
});
|
|
}
|
|
return {};
|
|
}
|
|
var STANDARD_PROPS = {
|
|
start: identity,
|
|
end: identity,
|
|
allDay: Boolean
|
|
};
|
|
function parseDateSpan(raw, dateEnv, defaultDuration) {
|
|
var span = parseOpenDateSpan(raw, dateEnv);
|
|
var range = span.range;
|
|
if (!range.start) {
|
|
return null;
|
|
}
|
|
if (!range.end) {
|
|
if (defaultDuration == null) {
|
|
return null;
|
|
}
|
|
range.end = dateEnv.add(range.start, defaultDuration);
|
|
}
|
|
return span;
|
|
}
|
|
function parseOpenDateSpan(raw, dateEnv) {
|
|
var _a = refineProps(raw, STANDARD_PROPS), standardProps = _a.refined, extra = _a.extra;
|
|
var startMeta = standardProps.start ? dateEnv.createMarkerMeta(standardProps.start) : null;
|
|
var endMeta = standardProps.end ? dateEnv.createMarkerMeta(standardProps.end) : null;
|
|
var allDay = standardProps.allDay;
|
|
if (allDay == null) {
|
|
allDay = startMeta && startMeta.isTimeUnspecified && (!endMeta || endMeta.isTimeUnspecified);
|
|
}
|
|
return __assign({ range: {
|
|
start: startMeta ? startMeta.marker : null,
|
|
end: endMeta ? endMeta.marker : null
|
|
}, allDay }, extra);
|
|
}
|
|
function isDateSpansEqual(span0, span1) {
|
|
return rangesEqual(span0.range, span1.range) && span0.allDay === span1.allDay && isSpanPropsEqual(span0, span1);
|
|
}
|
|
function isSpanPropsEqual(span0, span1) {
|
|
for (var propName in span1) {
|
|
if (propName !== "range" && propName !== "allDay") {
|
|
if (span0[propName] !== span1[propName]) {
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
for (var propName in span0) {
|
|
if (!(propName in span1)) {
|
|
return false;
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
function buildDateSpanApi(span, dateEnv) {
|
|
return __assign(__assign({}, buildRangeApi(span.range, dateEnv, span.allDay)), { allDay: span.allDay });
|
|
}
|
|
function buildRangeApiWithTimeZone(range, dateEnv, omitTime) {
|
|
return __assign(__assign({}, buildRangeApi(range, dateEnv, omitTime)), { timeZone: dateEnv.timeZone });
|
|
}
|
|
function buildRangeApi(range, dateEnv, omitTime) {
|
|
return {
|
|
start: dateEnv.toDate(range.start),
|
|
end: dateEnv.toDate(range.end),
|
|
startStr: dateEnv.formatIso(range.start, { omitTime }),
|
|
endStr: dateEnv.formatIso(range.end, { omitTime })
|
|
};
|
|
}
|
|
function fabricateEventRange(dateSpan, eventUiBases, context) {
|
|
var res = refineEventDef({ editable: false }, context);
|
|
var def = parseEventDef(res.refined, res.extra, "", dateSpan.allDay, true, context);
|
|
return {
|
|
def,
|
|
ui: compileEventUi(def, eventUiBases),
|
|
instance: createEventInstance(def.defId, dateSpan.range),
|
|
range: dateSpan.range,
|
|
isStart: true,
|
|
isEnd: true
|
|
};
|
|
}
|
|
function triggerDateSelect(selection, pev, context) {
|
|
context.emitter.trigger("select", __assign(__assign({}, buildDateSpanApiWithContext(selection, context)), { jsEvent: pev ? pev.origEvent : null, view: context.viewApi || context.calendarApi.view }));
|
|
}
|
|
function triggerDateUnselect(pev, context) {
|
|
context.emitter.trigger("unselect", {
|
|
jsEvent: pev ? pev.origEvent : null,
|
|
view: context.viewApi || context.calendarApi.view
|
|
});
|
|
}
|
|
function buildDateSpanApiWithContext(dateSpan, context) {
|
|
var props = {};
|
|
for (var _i = 0, _a = context.pluginHooks.dateSpanTransforms; _i < _a.length; _i++) {
|
|
var transform = _a[_i];
|
|
__assign(props, transform(dateSpan, context));
|
|
}
|
|
__assign(props, buildDateSpanApi(dateSpan, context.dateEnv));
|
|
return props;
|
|
}
|
|
function getDefaultEventEnd(allDay, marker, context) {
|
|
var dateEnv = context.dateEnv, options = context.options;
|
|
var end = marker;
|
|
if (allDay) {
|
|
end = startOfDay(end);
|
|
end = dateEnv.add(end, options.defaultAllDayEventDuration);
|
|
} else {
|
|
end = dateEnv.add(end, options.defaultTimedEventDuration);
|
|
}
|
|
return end;
|
|
}
|
|
function applyMutationToEventStore(eventStore, eventConfigBase, mutation, context) {
|
|
var eventConfigs = compileEventUis(eventStore.defs, eventConfigBase);
|
|
var dest = createEmptyEventStore();
|
|
for (var defId in eventStore.defs) {
|
|
var def = eventStore.defs[defId];
|
|
dest.defs[defId] = applyMutationToEventDef(def, eventConfigs[defId], mutation, context);
|
|
}
|
|
for (var instanceId in eventStore.instances) {
|
|
var instance = eventStore.instances[instanceId];
|
|
var def = dest.defs[instance.defId];
|
|
dest.instances[instanceId] = applyMutationToEventInstance(instance, def, eventConfigs[instance.defId], mutation, context);
|
|
}
|
|
return dest;
|
|
}
|
|
function applyMutationToEventDef(eventDef, eventConfig, mutation, context) {
|
|
var standardProps = mutation.standardProps || {};
|
|
if (standardProps.hasEnd == null && eventConfig.durationEditable && (mutation.startDelta || mutation.endDelta)) {
|
|
standardProps.hasEnd = true;
|
|
}
|
|
var copy = __assign(__assign(__assign({}, eventDef), standardProps), { ui: __assign(__assign({}, eventDef.ui), standardProps.ui) });
|
|
if (mutation.extendedProps) {
|
|
copy.extendedProps = __assign(__assign({}, copy.extendedProps), mutation.extendedProps);
|
|
}
|
|
for (var _i = 0, _a = context.pluginHooks.eventDefMutationAppliers; _i < _a.length; _i++) {
|
|
var applier = _a[_i];
|
|
applier(copy, mutation, context);
|
|
}
|
|
if (!copy.hasEnd && context.options.forceEventDuration) {
|
|
copy.hasEnd = true;
|
|
}
|
|
return copy;
|
|
}
|
|
function applyMutationToEventInstance(eventInstance, eventDef, eventConfig, mutation, context) {
|
|
var dateEnv = context.dateEnv;
|
|
var forceAllDay = mutation.standardProps && mutation.standardProps.allDay === true;
|
|
var clearEnd = mutation.standardProps && mutation.standardProps.hasEnd === false;
|
|
var copy = __assign({}, eventInstance);
|
|
if (forceAllDay) {
|
|
copy.range = computeAlignedDayRange(copy.range);
|
|
}
|
|
if (mutation.datesDelta && eventConfig.startEditable) {
|
|
copy.range = {
|
|
start: dateEnv.add(copy.range.start, mutation.datesDelta),
|
|
end: dateEnv.add(copy.range.end, mutation.datesDelta)
|
|
};
|
|
}
|
|
if (mutation.startDelta && eventConfig.durationEditable) {
|
|
copy.range = {
|
|
start: dateEnv.add(copy.range.start, mutation.startDelta),
|
|
end: copy.range.end
|
|
};
|
|
}
|
|
if (mutation.endDelta && eventConfig.durationEditable) {
|
|
copy.range = {
|
|
start: copy.range.start,
|
|
end: dateEnv.add(copy.range.end, mutation.endDelta)
|
|
};
|
|
}
|
|
if (clearEnd) {
|
|
copy.range = {
|
|
start: copy.range.start,
|
|
end: getDefaultEventEnd(eventDef.allDay, copy.range.start, context)
|
|
};
|
|
}
|
|
if (eventDef.allDay) {
|
|
copy.range = {
|
|
start: startOfDay(copy.range.start),
|
|
end: startOfDay(copy.range.end)
|
|
};
|
|
}
|
|
if (copy.range.end < copy.range.start) {
|
|
copy.range.end = getDefaultEventEnd(eventDef.allDay, copy.range.start, context);
|
|
}
|
|
return copy;
|
|
}
|
|
var ViewApi = function() {
|
|
function ViewApi2(type, getCurrentData, dateEnv) {
|
|
this.type = type;
|
|
this.getCurrentData = getCurrentData;
|
|
this.dateEnv = dateEnv;
|
|
}
|
|
Object.defineProperty(ViewApi2.prototype, "calendar", {
|
|
get: function() {
|
|
return this.getCurrentData().calendarApi;
|
|
},
|
|
enumerable: false,
|
|
configurable: true
|
|
});
|
|
Object.defineProperty(ViewApi2.prototype, "title", {
|
|
get: function() {
|
|
return this.getCurrentData().viewTitle;
|
|
},
|
|
enumerable: false,
|
|
configurable: true
|
|
});
|
|
Object.defineProperty(ViewApi2.prototype, "activeStart", {
|
|
get: function() {
|
|
return this.dateEnv.toDate(this.getCurrentData().dateProfile.activeRange.start);
|
|
},
|
|
enumerable: false,
|
|
configurable: true
|
|
});
|
|
Object.defineProperty(ViewApi2.prototype, "activeEnd", {
|
|
get: function() {
|
|
return this.dateEnv.toDate(this.getCurrentData().dateProfile.activeRange.end);
|
|
},
|
|
enumerable: false,
|
|
configurable: true
|
|
});
|
|
Object.defineProperty(ViewApi2.prototype, "currentStart", {
|
|
get: function() {
|
|
return this.dateEnv.toDate(this.getCurrentData().dateProfile.currentRange.start);
|
|
},
|
|
enumerable: false,
|
|
configurable: true
|
|
});
|
|
Object.defineProperty(ViewApi2.prototype, "currentEnd", {
|
|
get: function() {
|
|
return this.dateEnv.toDate(this.getCurrentData().dateProfile.currentRange.end);
|
|
},
|
|
enumerable: false,
|
|
configurable: true
|
|
});
|
|
ViewApi2.prototype.getOption = function(name) {
|
|
return this.getCurrentData().options[name];
|
|
};
|
|
return ViewApi2;
|
|
}();
|
|
var EVENT_SOURCE_REFINERS = {
|
|
id: String,
|
|
defaultAllDay: Boolean,
|
|
url: String,
|
|
format: String,
|
|
events: identity,
|
|
eventDataTransform: identity,
|
|
success: identity,
|
|
failure: identity
|
|
};
|
|
function parseEventSource(raw, context, refiners) {
|
|
if (refiners === void 0) {
|
|
refiners = buildEventSourceRefiners(context);
|
|
}
|
|
var rawObj;
|
|
if (typeof raw === "string") {
|
|
rawObj = { url: raw };
|
|
} else if (typeof raw === "function" || Array.isArray(raw)) {
|
|
rawObj = { events: raw };
|
|
} else if (typeof raw === "object" && raw) {
|
|
rawObj = raw;
|
|
}
|
|
if (rawObj) {
|
|
var _a = refineProps(rawObj, refiners), refined = _a.refined, extra = _a.extra;
|
|
var metaRes = buildEventSourceMeta(refined, context);
|
|
if (metaRes) {
|
|
return {
|
|
_raw: raw,
|
|
isFetching: false,
|
|
latestFetchId: "",
|
|
fetchRange: null,
|
|
defaultAllDay: refined.defaultAllDay,
|
|
eventDataTransform: refined.eventDataTransform,
|
|
success: refined.success,
|
|
failure: refined.failure,
|
|
publicId: refined.id || "",
|
|
sourceId: guid(),
|
|
sourceDefId: metaRes.sourceDefId,
|
|
meta: metaRes.meta,
|
|
ui: createEventUi(refined, context),
|
|
extendedProps: extra
|
|
};
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
function buildEventSourceRefiners(context) {
|
|
return __assign(__assign(__assign({}, EVENT_UI_REFINERS), EVENT_SOURCE_REFINERS), context.pluginHooks.eventSourceRefiners);
|
|
}
|
|
function buildEventSourceMeta(raw, context) {
|
|
var defs = context.pluginHooks.eventSourceDefs;
|
|
for (var i3 = defs.length - 1; i3 >= 0; i3 -= 1) {
|
|
var def = defs[i3];
|
|
var meta = def.parseMeta(raw);
|
|
if (meta) {
|
|
return { sourceDefId: i3, meta };
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
function reduceCurrentDate(currentDate, action) {
|
|
switch (action.type) {
|
|
case "CHANGE_DATE":
|
|
return action.dateMarker;
|
|
default:
|
|
return currentDate;
|
|
}
|
|
}
|
|
function getInitialDate(options, dateEnv) {
|
|
var initialDateInput = options.initialDate;
|
|
if (initialDateInput != null) {
|
|
return dateEnv.createMarker(initialDateInput);
|
|
}
|
|
return getNow(options.now, dateEnv);
|
|
}
|
|
function getNow(nowInput, dateEnv) {
|
|
if (typeof nowInput === "function") {
|
|
nowInput = nowInput();
|
|
}
|
|
if (nowInput == null) {
|
|
return dateEnv.createNowMarker();
|
|
}
|
|
return dateEnv.createMarker(nowInput);
|
|
}
|
|
var CalendarApi = function() {
|
|
function CalendarApi2() {
|
|
}
|
|
CalendarApi2.prototype.getCurrentData = function() {
|
|
return this.currentDataManager.getCurrentData();
|
|
};
|
|
CalendarApi2.prototype.dispatch = function(action) {
|
|
return this.currentDataManager.dispatch(action);
|
|
};
|
|
Object.defineProperty(CalendarApi2.prototype, "view", {
|
|
get: function() {
|
|
return this.getCurrentData().viewApi;
|
|
},
|
|
enumerable: false,
|
|
configurable: true
|
|
});
|
|
CalendarApi2.prototype.batchRendering = function(callback) {
|
|
callback();
|
|
};
|
|
CalendarApi2.prototype.updateSize = function() {
|
|
this.trigger("_resize", true);
|
|
};
|
|
CalendarApi2.prototype.setOption = function(name, val) {
|
|
this.dispatch({
|
|
type: "SET_OPTION",
|
|
optionName: name,
|
|
rawOptionValue: val
|
|
});
|
|
};
|
|
CalendarApi2.prototype.getOption = function(name) {
|
|
return this.currentDataManager.currentCalendarOptionsInput[name];
|
|
};
|
|
CalendarApi2.prototype.getAvailableLocaleCodes = function() {
|
|
return Object.keys(this.getCurrentData().availableRawLocales);
|
|
};
|
|
CalendarApi2.prototype.on = function(handlerName, handler) {
|
|
var currentDataManager = this.currentDataManager;
|
|
if (currentDataManager.currentCalendarOptionsRefiners[handlerName]) {
|
|
currentDataManager.emitter.on(handlerName, handler);
|
|
} else {
|
|
console.warn("Unknown listener name '" + handlerName + "'");
|
|
}
|
|
};
|
|
CalendarApi2.prototype.off = function(handlerName, handler) {
|
|
this.currentDataManager.emitter.off(handlerName, handler);
|
|
};
|
|
CalendarApi2.prototype.trigger = function(handlerName) {
|
|
var _a;
|
|
var args = [];
|
|
for (var _i = 1; _i < arguments.length; _i++) {
|
|
args[_i - 1] = arguments[_i];
|
|
}
|
|
(_a = this.currentDataManager.emitter).trigger.apply(_a, __spreadArray([handlerName], args));
|
|
};
|
|
CalendarApi2.prototype.changeView = function(viewType, dateOrRange) {
|
|
var _this = this;
|
|
this.batchRendering(function() {
|
|
_this.unselect();
|
|
if (dateOrRange) {
|
|
if (dateOrRange.start && dateOrRange.end) {
|
|
_this.dispatch({
|
|
type: "CHANGE_VIEW_TYPE",
|
|
viewType
|
|
});
|
|
_this.dispatch({
|
|
type: "SET_OPTION",
|
|
optionName: "visibleRange",
|
|
rawOptionValue: dateOrRange
|
|
});
|
|
} else {
|
|
var dateEnv = _this.getCurrentData().dateEnv;
|
|
_this.dispatch({
|
|
type: "CHANGE_VIEW_TYPE",
|
|
viewType,
|
|
dateMarker: dateEnv.createMarker(dateOrRange)
|
|
});
|
|
}
|
|
} else {
|
|
_this.dispatch({
|
|
type: "CHANGE_VIEW_TYPE",
|
|
viewType
|
|
});
|
|
}
|
|
});
|
|
};
|
|
CalendarApi2.prototype.zoomTo = function(dateMarker, viewType) {
|
|
var state = this.getCurrentData();
|
|
var spec;
|
|
viewType = viewType || "day";
|
|
spec = state.viewSpecs[viewType] || this.getUnitViewSpec(viewType);
|
|
this.unselect();
|
|
if (spec) {
|
|
this.dispatch({
|
|
type: "CHANGE_VIEW_TYPE",
|
|
viewType: spec.type,
|
|
dateMarker
|
|
});
|
|
} else {
|
|
this.dispatch({
|
|
type: "CHANGE_DATE",
|
|
dateMarker
|
|
});
|
|
}
|
|
};
|
|
CalendarApi2.prototype.getUnitViewSpec = function(unit) {
|
|
var _a = this.getCurrentData(), viewSpecs = _a.viewSpecs, toolbarConfig = _a.toolbarConfig;
|
|
var viewTypes = [].concat(toolbarConfig.header ? toolbarConfig.header.viewsWithButtons : [], toolbarConfig.footer ? toolbarConfig.footer.viewsWithButtons : []);
|
|
var i3;
|
|
var spec;
|
|
for (var viewType in viewSpecs) {
|
|
viewTypes.push(viewType);
|
|
}
|
|
for (i3 = 0; i3 < viewTypes.length; i3 += 1) {
|
|
spec = viewSpecs[viewTypes[i3]];
|
|
if (spec) {
|
|
if (spec.singleUnit === unit) {
|
|
return spec;
|
|
}
|
|
}
|
|
}
|
|
return null;
|
|
};
|
|
CalendarApi2.prototype.prev = function() {
|
|
this.unselect();
|
|
this.dispatch({ type: "PREV" });
|
|
};
|
|
CalendarApi2.prototype.next = function() {
|
|
this.unselect();
|
|
this.dispatch({ type: "NEXT" });
|
|
};
|
|
CalendarApi2.prototype.prevYear = function() {
|
|
var state = this.getCurrentData();
|
|
this.unselect();
|
|
this.dispatch({
|
|
type: "CHANGE_DATE",
|
|
dateMarker: state.dateEnv.addYears(state.currentDate, -1)
|
|
});
|
|
};
|
|
CalendarApi2.prototype.nextYear = function() {
|
|
var state = this.getCurrentData();
|
|
this.unselect();
|
|
this.dispatch({
|
|
type: "CHANGE_DATE",
|
|
dateMarker: state.dateEnv.addYears(state.currentDate, 1)
|
|
});
|
|
};
|
|
CalendarApi2.prototype.today = function() {
|
|
var state = this.getCurrentData();
|
|
this.unselect();
|
|
this.dispatch({
|
|
type: "CHANGE_DATE",
|
|
dateMarker: getNow(state.calendarOptions.now, state.dateEnv)
|
|
});
|
|
};
|
|
CalendarApi2.prototype.gotoDate = function(zonedDateInput) {
|
|
var state = this.getCurrentData();
|
|
this.unselect();
|
|
this.dispatch({
|
|
type: "CHANGE_DATE",
|
|
dateMarker: state.dateEnv.createMarker(zonedDateInput)
|
|
});
|
|
};
|
|
CalendarApi2.prototype.incrementDate = function(deltaInput) {
|
|
var state = this.getCurrentData();
|
|
var delta = createDuration(deltaInput);
|
|
if (delta) {
|
|
this.unselect();
|
|
this.dispatch({
|
|
type: "CHANGE_DATE",
|
|
dateMarker: state.dateEnv.add(state.currentDate, delta)
|
|
});
|
|
}
|
|
};
|
|
CalendarApi2.prototype.getDate = function() {
|
|
var state = this.getCurrentData();
|
|
return state.dateEnv.toDate(state.currentDate);
|
|
};
|
|
CalendarApi2.prototype.formatDate = function(d3, formatter) {
|
|
var dateEnv = this.getCurrentData().dateEnv;
|
|
return dateEnv.format(dateEnv.createMarker(d3), createFormatter(formatter));
|
|
};
|
|
CalendarApi2.prototype.formatRange = function(d0, d1, settings) {
|
|
var dateEnv = this.getCurrentData().dateEnv;
|
|
return dateEnv.formatRange(dateEnv.createMarker(d0), dateEnv.createMarker(d1), createFormatter(settings), settings);
|
|
};
|
|
CalendarApi2.prototype.formatIso = function(d3, omitTime) {
|
|
var dateEnv = this.getCurrentData().dateEnv;
|
|
return dateEnv.formatIso(dateEnv.createMarker(d3), { omitTime });
|
|
};
|
|
CalendarApi2.prototype.select = function(dateOrObj, endDate) {
|
|
var selectionInput;
|
|
if (endDate == null) {
|
|
if (dateOrObj.start != null) {
|
|
selectionInput = dateOrObj;
|
|
} else {
|
|
selectionInput = {
|
|
start: dateOrObj,
|
|
end: null
|
|
};
|
|
}
|
|
} else {
|
|
selectionInput = {
|
|
start: dateOrObj,
|
|
end: endDate
|
|
};
|
|
}
|
|
var state = this.getCurrentData();
|
|
var selection = parseDateSpan(selectionInput, state.dateEnv, createDuration({ days: 1 }));
|
|
if (selection) {
|
|
this.dispatch({ type: "SELECT_DATES", selection });
|
|
triggerDateSelect(selection, null, state);
|
|
}
|
|
};
|
|
CalendarApi2.prototype.unselect = function(pev) {
|
|
var state = this.getCurrentData();
|
|
if (state.dateSelection) {
|
|
this.dispatch({ type: "UNSELECT_DATES" });
|
|
triggerDateUnselect(pev, state);
|
|
}
|
|
};
|
|
CalendarApi2.prototype.addEvent = function(eventInput, sourceInput) {
|
|
if (eventInput instanceof EventApi) {
|
|
var def = eventInput._def;
|
|
var instance = eventInput._instance;
|
|
var currentData = this.getCurrentData();
|
|
if (!currentData.eventStore.defs[def.defId]) {
|
|
this.dispatch({
|
|
type: "ADD_EVENTS",
|
|
eventStore: eventTupleToStore({ def, instance })
|
|
});
|
|
this.triggerEventAdd(eventInput);
|
|
}
|
|
return eventInput;
|
|
}
|
|
var state = this.getCurrentData();
|
|
var eventSource;
|
|
if (sourceInput instanceof EventSourceApi) {
|
|
eventSource = sourceInput.internalEventSource;
|
|
} else if (typeof sourceInput === "boolean") {
|
|
if (sourceInput) {
|
|
eventSource = hashValuesToArray(state.eventSources)[0];
|
|
}
|
|
} else if (sourceInput != null) {
|
|
var sourceApi = this.getEventSourceById(sourceInput);
|
|
if (!sourceApi) {
|
|
console.warn('Could not find an event source with ID "' + sourceInput + '"');
|
|
return null;
|
|
}
|
|
eventSource = sourceApi.internalEventSource;
|
|
}
|
|
var tuple = parseEvent(eventInput, eventSource, state, false);
|
|
if (tuple) {
|
|
var newEventApi = new EventApi(state, tuple.def, tuple.def.recurringDef ? null : tuple.instance);
|
|
this.dispatch({
|
|
type: "ADD_EVENTS",
|
|
eventStore: eventTupleToStore(tuple)
|
|
});
|
|
this.triggerEventAdd(newEventApi);
|
|
return newEventApi;
|
|
}
|
|
return null;
|
|
};
|
|
CalendarApi2.prototype.triggerEventAdd = function(eventApi) {
|
|
var _this = this;
|
|
var emitter = this.getCurrentData().emitter;
|
|
emitter.trigger("eventAdd", {
|
|
event: eventApi,
|
|
relatedEvents: [],
|
|
revert: function() {
|
|
_this.dispatch({
|
|
type: "REMOVE_EVENTS",
|
|
eventStore: eventApiToStore(eventApi)
|
|
});
|
|
}
|
|
});
|
|
};
|
|
CalendarApi2.prototype.getEventById = function(id) {
|
|
var state = this.getCurrentData();
|
|
var _a = state.eventStore, defs = _a.defs, instances = _a.instances;
|
|
id = String(id);
|
|
for (var defId in defs) {
|
|
var def = defs[defId];
|
|
if (def.publicId === id) {
|
|
if (def.recurringDef) {
|
|
return new EventApi(state, def, null);
|
|
}
|
|
for (var instanceId in instances) {
|
|
var instance = instances[instanceId];
|
|
if (instance.defId === def.defId) {
|
|
return new EventApi(state, def, instance);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return null;
|
|
};
|
|
CalendarApi2.prototype.getEvents = function() {
|
|
var currentData = this.getCurrentData();
|
|
return buildEventApis(currentData.eventStore, currentData);
|
|
};
|
|
CalendarApi2.prototype.removeAllEvents = function() {
|
|
this.dispatch({ type: "REMOVE_ALL_EVENTS" });
|
|
};
|
|
CalendarApi2.prototype.getEventSources = function() {
|
|
var state = this.getCurrentData();
|
|
var sourceHash = state.eventSources;
|
|
var sourceApis = [];
|
|
for (var internalId in sourceHash) {
|
|
sourceApis.push(new EventSourceApi(state, sourceHash[internalId]));
|
|
}
|
|
return sourceApis;
|
|
};
|
|
CalendarApi2.prototype.getEventSourceById = function(id) {
|
|
var state = this.getCurrentData();
|
|
var sourceHash = state.eventSources;
|
|
id = String(id);
|
|
for (var sourceId in sourceHash) {
|
|
if (sourceHash[sourceId].publicId === id) {
|
|
return new EventSourceApi(state, sourceHash[sourceId]);
|
|
}
|
|
}
|
|
return null;
|
|
};
|
|
CalendarApi2.prototype.addEventSource = function(sourceInput) {
|
|
var state = this.getCurrentData();
|
|
if (sourceInput instanceof EventSourceApi) {
|
|
if (!state.eventSources[sourceInput.internalEventSource.sourceId]) {
|
|
this.dispatch({
|
|
type: "ADD_EVENT_SOURCES",
|
|
sources: [sourceInput.internalEventSource]
|
|
});
|
|
}
|
|
return sourceInput;
|
|
}
|
|
var eventSource = parseEventSource(sourceInput, state);
|
|
if (eventSource) {
|
|
this.dispatch({ type: "ADD_EVENT_SOURCES", sources: [eventSource] });
|
|
return new EventSourceApi(state, eventSource);
|
|
}
|
|
return null;
|
|
};
|
|
CalendarApi2.prototype.removeAllEventSources = function() {
|
|
this.dispatch({ type: "REMOVE_ALL_EVENT_SOURCES" });
|
|
};
|
|
CalendarApi2.prototype.refetchEvents = function() {
|
|
this.dispatch({ type: "FETCH_EVENT_SOURCES", isRefetch: true });
|
|
};
|
|
CalendarApi2.prototype.scrollToTime = function(timeInput) {
|
|
var time = createDuration(timeInput);
|
|
if (time) {
|
|
this.trigger("_scrollRequest", { time });
|
|
}
|
|
};
|
|
return CalendarApi2;
|
|
}();
|
|
var EventApi = function() {
|
|
function EventApi3(context, def, instance) {
|
|
this._context = context;
|
|
this._def = def;
|
|
this._instance = instance || null;
|
|
}
|
|
EventApi3.prototype.setProp = function(name, val) {
|
|
var _a, _b;
|
|
if (name in EVENT_DATE_REFINERS) {
|
|
console.warn("Could not set date-related prop 'name'. Use one of the date-related methods instead.");
|
|
} else if (name === "id") {
|
|
val = EVENT_NON_DATE_REFINERS[name](val);
|
|
this.mutate({
|
|
standardProps: { publicId: val }
|
|
});
|
|
} else if (name in EVENT_NON_DATE_REFINERS) {
|
|
val = EVENT_NON_DATE_REFINERS[name](val);
|
|
this.mutate({
|
|
standardProps: (_a = {}, _a[name] = val, _a)
|
|
});
|
|
} else if (name in EVENT_UI_REFINERS) {
|
|
var ui = EVENT_UI_REFINERS[name](val);
|
|
if (name === "color") {
|
|
ui = { backgroundColor: val, borderColor: val };
|
|
} else if (name === "editable") {
|
|
ui = { startEditable: val, durationEditable: val };
|
|
} else {
|
|
ui = (_b = {}, _b[name] = val, _b);
|
|
}
|
|
this.mutate({
|
|
standardProps: { ui }
|
|
});
|
|
} else {
|
|
console.warn("Could not set prop '" + name + "'. Use setExtendedProp instead.");
|
|
}
|
|
};
|
|
EventApi3.prototype.setExtendedProp = function(name, val) {
|
|
var _a;
|
|
this.mutate({
|
|
extendedProps: (_a = {}, _a[name] = val, _a)
|
|
});
|
|
};
|
|
EventApi3.prototype.setStart = function(startInput, options) {
|
|
if (options === void 0) {
|
|
options = {};
|
|
}
|
|
var dateEnv = this._context.dateEnv;
|
|
var start = dateEnv.createMarker(startInput);
|
|
if (start && this._instance) {
|
|
var instanceRange = this._instance.range;
|
|
var startDelta = diffDates(instanceRange.start, start, dateEnv, options.granularity);
|
|
if (options.maintainDuration) {
|
|
this.mutate({ datesDelta: startDelta });
|
|
} else {
|
|
this.mutate({ startDelta });
|
|
}
|
|
}
|
|
};
|
|
EventApi3.prototype.setEnd = function(endInput, options) {
|
|
if (options === void 0) {
|
|
options = {};
|
|
}
|
|
var dateEnv = this._context.dateEnv;
|
|
var end;
|
|
if (endInput != null) {
|
|
end = dateEnv.createMarker(endInput);
|
|
if (!end) {
|
|
return;
|
|
}
|
|
}
|
|
if (this._instance) {
|
|
if (end) {
|
|
var endDelta = diffDates(this._instance.range.end, end, dateEnv, options.granularity);
|
|
this.mutate({ endDelta });
|
|
} else {
|
|
this.mutate({ standardProps: { hasEnd: false } });
|
|
}
|
|
}
|
|
};
|
|
EventApi3.prototype.setDates = function(startInput, endInput, options) {
|
|
if (options === void 0) {
|
|
options = {};
|
|
}
|
|
var dateEnv = this._context.dateEnv;
|
|
var standardProps = { allDay: options.allDay };
|
|
var start = dateEnv.createMarker(startInput);
|
|
var end;
|
|
if (!start) {
|
|
return;
|
|
}
|
|
if (endInput != null) {
|
|
end = dateEnv.createMarker(endInput);
|
|
if (!end) {
|
|
return;
|
|
}
|
|
}
|
|
if (this._instance) {
|
|
var instanceRange = this._instance.range;
|
|
if (options.allDay === true) {
|
|
instanceRange = computeAlignedDayRange(instanceRange);
|
|
}
|
|
var startDelta = diffDates(instanceRange.start, start, dateEnv, options.granularity);
|
|
if (end) {
|
|
var endDelta = diffDates(instanceRange.end, end, dateEnv, options.granularity);
|
|
if (durationsEqual(startDelta, endDelta)) {
|
|
this.mutate({ datesDelta: startDelta, standardProps });
|
|
} else {
|
|
this.mutate({ startDelta, endDelta, standardProps });
|
|
}
|
|
} else {
|
|
standardProps.hasEnd = false;
|
|
this.mutate({ datesDelta: startDelta, standardProps });
|
|
}
|
|
}
|
|
};
|
|
EventApi3.prototype.moveStart = function(deltaInput) {
|
|
var delta = createDuration(deltaInput);
|
|
if (delta) {
|
|
this.mutate({ startDelta: delta });
|
|
}
|
|
};
|
|
EventApi3.prototype.moveEnd = function(deltaInput) {
|
|
var delta = createDuration(deltaInput);
|
|
if (delta) {
|
|
this.mutate({ endDelta: delta });
|
|
}
|
|
};
|
|
EventApi3.prototype.moveDates = function(deltaInput) {
|
|
var delta = createDuration(deltaInput);
|
|
if (delta) {
|
|
this.mutate({ datesDelta: delta });
|
|
}
|
|
};
|
|
EventApi3.prototype.setAllDay = function(allDay, options) {
|
|
if (options === void 0) {
|
|
options = {};
|
|
}
|
|
var standardProps = { allDay };
|
|
var maintainDuration = options.maintainDuration;
|
|
if (maintainDuration == null) {
|
|
maintainDuration = this._context.options.allDayMaintainDuration;
|
|
}
|
|
if (this._def.allDay !== allDay) {
|
|
standardProps.hasEnd = maintainDuration;
|
|
}
|
|
this.mutate({ standardProps });
|
|
};
|
|
EventApi3.prototype.formatRange = function(formatInput) {
|
|
var dateEnv = this._context.dateEnv;
|
|
var instance = this._instance;
|
|
var formatter = createFormatter(formatInput);
|
|
if (this._def.hasEnd) {
|
|
return dateEnv.formatRange(instance.range.start, instance.range.end, formatter, {
|
|
forcedStartTzo: instance.forcedStartTzo,
|
|
forcedEndTzo: instance.forcedEndTzo
|
|
});
|
|
}
|
|
return dateEnv.format(instance.range.start, formatter, {
|
|
forcedTzo: instance.forcedStartTzo
|
|
});
|
|
};
|
|
EventApi3.prototype.mutate = function(mutation) {
|
|
var instance = this._instance;
|
|
if (instance) {
|
|
var def = this._def;
|
|
var context_1 = this._context;
|
|
var eventStore_1 = context_1.getCurrentData().eventStore;
|
|
var relevantEvents = getRelevantEvents(eventStore_1, instance.instanceId);
|
|
var eventConfigBase = {
|
|
"": {
|
|
display: "",
|
|
startEditable: true,
|
|
durationEditable: true,
|
|
constraints: [],
|
|
overlap: null,
|
|
allows: [],
|
|
backgroundColor: "",
|
|
borderColor: "",
|
|
textColor: "",
|
|
classNames: []
|
|
}
|
|
};
|
|
relevantEvents = applyMutationToEventStore(relevantEvents, eventConfigBase, mutation, context_1);
|
|
var oldEvent = new EventApi3(context_1, def, instance);
|
|
this._def = relevantEvents.defs[def.defId];
|
|
this._instance = relevantEvents.instances[instance.instanceId];
|
|
context_1.dispatch({
|
|
type: "MERGE_EVENTS",
|
|
eventStore: relevantEvents
|
|
});
|
|
context_1.emitter.trigger("eventChange", {
|
|
oldEvent,
|
|
event: this,
|
|
relatedEvents: buildEventApis(relevantEvents, context_1, instance),
|
|
revert: function() {
|
|
context_1.dispatch({
|
|
type: "RESET_EVENTS",
|
|
eventStore: eventStore_1
|
|
});
|
|
}
|
|
});
|
|
}
|
|
};
|
|
EventApi3.prototype.remove = function() {
|
|
var context = this._context;
|
|
var asStore = eventApiToStore(this);
|
|
context.dispatch({
|
|
type: "REMOVE_EVENTS",
|
|
eventStore: asStore
|
|
});
|
|
context.emitter.trigger("eventRemove", {
|
|
event: this,
|
|
relatedEvents: [],
|
|
revert: function() {
|
|
context.dispatch({
|
|
type: "MERGE_EVENTS",
|
|
eventStore: asStore
|
|
});
|
|
}
|
|
});
|
|
};
|
|
Object.defineProperty(EventApi3.prototype, "source", {
|
|
get: function() {
|
|
var sourceId = this._def.sourceId;
|
|
if (sourceId) {
|
|
return new EventSourceApi(this._context, this._context.getCurrentData().eventSources[sourceId]);
|
|
}
|
|
return null;
|
|
},
|
|
enumerable: false,
|
|
configurable: true
|
|
});
|
|
Object.defineProperty(EventApi3.prototype, "start", {
|
|
get: function() {
|
|
return this._instance ? this._context.dateEnv.toDate(this._instance.range.start) : null;
|
|
},
|
|
enumerable: false,
|
|
configurable: true
|
|
});
|
|
Object.defineProperty(EventApi3.prototype, "end", {
|
|
get: function() {
|
|
return this._instance && this._def.hasEnd ? this._context.dateEnv.toDate(this._instance.range.end) : null;
|
|
},
|
|
enumerable: false,
|
|
configurable: true
|
|
});
|
|
Object.defineProperty(EventApi3.prototype, "startStr", {
|
|
get: function() {
|
|
var instance = this._instance;
|
|
if (instance) {
|
|
return this._context.dateEnv.formatIso(instance.range.start, {
|
|
omitTime: this._def.allDay,
|
|
forcedTzo: instance.forcedStartTzo
|
|
});
|
|
}
|
|
return "";
|
|
},
|
|
enumerable: false,
|
|
configurable: true
|
|
});
|
|
Object.defineProperty(EventApi3.prototype, "endStr", {
|
|
get: function() {
|
|
var instance = this._instance;
|
|
if (instance && this._def.hasEnd) {
|
|
return this._context.dateEnv.formatIso(instance.range.end, {
|
|
omitTime: this._def.allDay,
|
|
forcedTzo: instance.forcedEndTzo
|
|
});
|
|
}
|
|
return "";
|
|
},
|
|
enumerable: false,
|
|
configurable: true
|
|
});
|
|
Object.defineProperty(EventApi3.prototype, "id", {
|
|
get: function() {
|
|
return this._def.publicId;
|
|
},
|
|
enumerable: false,
|
|
configurable: true
|
|
});
|
|
Object.defineProperty(EventApi3.prototype, "groupId", {
|
|
get: function() {
|
|
return this._def.groupId;
|
|
},
|
|
enumerable: false,
|
|
configurable: true
|
|
});
|
|
Object.defineProperty(EventApi3.prototype, "allDay", {
|
|
get: function() {
|
|
return this._def.allDay;
|
|
},
|
|
enumerable: false,
|
|
configurable: true
|
|
});
|
|
Object.defineProperty(EventApi3.prototype, "title", {
|
|
get: function() {
|
|
return this._def.title;
|
|
},
|
|
enumerable: false,
|
|
configurable: true
|
|
});
|
|
Object.defineProperty(EventApi3.prototype, "url", {
|
|
get: function() {
|
|
return this._def.url;
|
|
},
|
|
enumerable: false,
|
|
configurable: true
|
|
});
|
|
Object.defineProperty(EventApi3.prototype, "display", {
|
|
get: function() {
|
|
return this._def.ui.display || "auto";
|
|
},
|
|
enumerable: false,
|
|
configurable: true
|
|
});
|
|
Object.defineProperty(EventApi3.prototype, "startEditable", {
|
|
get: function() {
|
|
return this._def.ui.startEditable;
|
|
},
|
|
enumerable: false,
|
|
configurable: true
|
|
});
|
|
Object.defineProperty(EventApi3.prototype, "durationEditable", {
|
|
get: function() {
|
|
return this._def.ui.durationEditable;
|
|
},
|
|
enumerable: false,
|
|
configurable: true
|
|
});
|
|
Object.defineProperty(EventApi3.prototype, "constraint", {
|
|
get: function() {
|
|
return this._def.ui.constraints[0] || null;
|
|
},
|
|
enumerable: false,
|
|
configurable: true
|
|
});
|
|
Object.defineProperty(EventApi3.prototype, "overlap", {
|
|
get: function() {
|
|
return this._def.ui.overlap;
|
|
},
|
|
enumerable: false,
|
|
configurable: true
|
|
});
|
|
Object.defineProperty(EventApi3.prototype, "allow", {
|
|
get: function() {
|
|
return this._def.ui.allows[0] || null;
|
|
},
|
|
enumerable: false,
|
|
configurable: true
|
|
});
|
|
Object.defineProperty(EventApi3.prototype, "backgroundColor", {
|
|
get: function() {
|
|
return this._def.ui.backgroundColor;
|
|
},
|
|
enumerable: false,
|
|
configurable: true
|
|
});
|
|
Object.defineProperty(EventApi3.prototype, "borderColor", {
|
|
get: function() {
|
|
return this._def.ui.borderColor;
|
|
},
|
|
enumerable: false,
|
|
configurable: true
|
|
});
|
|
Object.defineProperty(EventApi3.prototype, "textColor", {
|
|
get: function() {
|
|
return this._def.ui.textColor;
|
|
},
|
|
enumerable: false,
|
|
configurable: true
|
|
});
|
|
Object.defineProperty(EventApi3.prototype, "classNames", {
|
|
get: function() {
|
|
return this._def.ui.classNames;
|
|
},
|
|
enumerable: false,
|
|
configurable: true
|
|
});
|
|
Object.defineProperty(EventApi3.prototype, "extendedProps", {
|
|
get: function() {
|
|
return this._def.extendedProps;
|
|
},
|
|
enumerable: false,
|
|
configurable: true
|
|
});
|
|
EventApi3.prototype.toPlainObject = function(settings) {
|
|
if (settings === void 0) {
|
|
settings = {};
|
|
}
|
|
var def = this._def;
|
|
var ui = def.ui;
|
|
var _a = this, startStr = _a.startStr, endStr = _a.endStr;
|
|
var res = {};
|
|
if (def.title) {
|
|
res.title = def.title;
|
|
}
|
|
if (startStr) {
|
|
res.start = startStr;
|
|
}
|
|
if (endStr) {
|
|
res.end = endStr;
|
|
}
|
|
if (def.publicId) {
|
|
res.id = def.publicId;
|
|
}
|
|
if (def.groupId) {
|
|
res.groupId = def.groupId;
|
|
}
|
|
if (def.url) {
|
|
res.url = def.url;
|
|
}
|
|
if (ui.display && ui.display !== "auto") {
|
|
res.display = ui.display;
|
|
}
|
|
if (settings.collapseColor && ui.backgroundColor && ui.backgroundColor === ui.borderColor) {
|
|
res.color = ui.backgroundColor;
|
|
} else {
|
|
if (ui.backgroundColor) {
|
|
res.backgroundColor = ui.backgroundColor;
|
|
}
|
|
if (ui.borderColor) {
|
|
res.borderColor = ui.borderColor;
|
|
}
|
|
}
|
|
if (ui.textColor) {
|
|
res.textColor = ui.textColor;
|
|
}
|
|
if (ui.classNames.length) {
|
|
res.classNames = ui.classNames;
|
|
}
|
|
if (Object.keys(def.extendedProps).length) {
|
|
if (settings.collapseExtendedProps) {
|
|
__assign(res, def.extendedProps);
|
|
} else {
|
|
res.extendedProps = def.extendedProps;
|
|
}
|
|
}
|
|
return res;
|
|
};
|
|
EventApi3.prototype.toJSON = function() {
|
|
return this.toPlainObject();
|
|
};
|
|
return EventApi3;
|
|
}();
|
|
function eventApiToStore(eventApi) {
|
|
var _a, _b;
|
|
var def = eventApi._def;
|
|
var instance = eventApi._instance;
|
|
return {
|
|
defs: (_a = {}, _a[def.defId] = def, _a),
|
|
instances: instance ? (_b = {}, _b[instance.instanceId] = instance, _b) : {}
|
|
};
|
|
}
|
|
function buildEventApis(eventStore, context, excludeInstance) {
|
|
var defs = eventStore.defs, instances = eventStore.instances;
|
|
var eventApis = [];
|
|
var excludeInstanceId = excludeInstance ? excludeInstance.instanceId : "";
|
|
for (var id in instances) {
|
|
var instance = instances[id];
|
|
var def = defs[instance.defId];
|
|
if (instance.instanceId !== excludeInstanceId) {
|
|
eventApis.push(new EventApi(context, def, instance));
|
|
}
|
|
}
|
|
return eventApis;
|
|
}
|
|
var calendarSystemClassMap = {};
|
|
function registerCalendarSystem(name, theClass) {
|
|
calendarSystemClassMap[name] = theClass;
|
|
}
|
|
function createCalendarSystem(name) {
|
|
return new calendarSystemClassMap[name]();
|
|
}
|
|
var GregorianCalendarSystem = function() {
|
|
function GregorianCalendarSystem2() {
|
|
}
|
|
GregorianCalendarSystem2.prototype.getMarkerYear = function(d3) {
|
|
return d3.getUTCFullYear();
|
|
};
|
|
GregorianCalendarSystem2.prototype.getMarkerMonth = function(d3) {
|
|
return d3.getUTCMonth();
|
|
};
|
|
GregorianCalendarSystem2.prototype.getMarkerDay = function(d3) {
|
|
return d3.getUTCDate();
|
|
};
|
|
GregorianCalendarSystem2.prototype.arrayToMarker = function(arr) {
|
|
return arrayToUtcDate(arr);
|
|
};
|
|
GregorianCalendarSystem2.prototype.markerToArray = function(marker) {
|
|
return dateToUtcArray(marker);
|
|
};
|
|
return GregorianCalendarSystem2;
|
|
}();
|
|
registerCalendarSystem("gregory", GregorianCalendarSystem);
|
|
var ISO_RE = /^\s*(\d{4})(-?(\d{2})(-?(\d{2})([T ](\d{2}):?(\d{2})(:?(\d{2})(\.(\d+))?)?(Z|(([-+])(\d{2})(:?(\d{2}))?))?)?)?)?$/;
|
|
function parse(str) {
|
|
var m2 = ISO_RE.exec(str);
|
|
if (m2) {
|
|
var marker = new Date(Date.UTC(Number(m2[1]), m2[3] ? Number(m2[3]) - 1 : 0, Number(m2[5] || 1), Number(m2[7] || 0), Number(m2[8] || 0), Number(m2[10] || 0), m2[12] ? Number("0." + m2[12]) * 1e3 : 0));
|
|
if (isValidDate(marker)) {
|
|
var timeZoneOffset = null;
|
|
if (m2[13]) {
|
|
timeZoneOffset = (m2[15] === "-" ? -1 : 1) * (Number(m2[16] || 0) * 60 + Number(m2[18] || 0));
|
|
}
|
|
return {
|
|
marker,
|
|
isTimeUnspecified: !m2[6],
|
|
timeZoneOffset
|
|
};
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
var DateEnv = function() {
|
|
function DateEnv2(settings) {
|
|
var timeZone = this.timeZone = settings.timeZone;
|
|
var isNamedTimeZone = timeZone !== "local" && timeZone !== "UTC";
|
|
if (settings.namedTimeZoneImpl && isNamedTimeZone) {
|
|
this.namedTimeZoneImpl = new settings.namedTimeZoneImpl(timeZone);
|
|
}
|
|
this.canComputeOffset = Boolean(!isNamedTimeZone || this.namedTimeZoneImpl);
|
|
this.calendarSystem = createCalendarSystem(settings.calendarSystem);
|
|
this.locale = settings.locale;
|
|
this.weekDow = settings.locale.week.dow;
|
|
this.weekDoy = settings.locale.week.doy;
|
|
if (settings.weekNumberCalculation === "ISO") {
|
|
this.weekDow = 1;
|
|
this.weekDoy = 4;
|
|
}
|
|
if (typeof settings.firstDay === "number") {
|
|
this.weekDow = settings.firstDay;
|
|
}
|
|
if (typeof settings.weekNumberCalculation === "function") {
|
|
this.weekNumberFunc = settings.weekNumberCalculation;
|
|
}
|
|
this.weekText = settings.weekText != null ? settings.weekText : settings.locale.options.weekText;
|
|
this.weekTextLong = (settings.weekTextLong != null ? settings.weekTextLong : settings.locale.options.weekTextLong) || this.weekText;
|
|
this.cmdFormatter = settings.cmdFormatter;
|
|
this.defaultSeparator = settings.defaultSeparator;
|
|
}
|
|
DateEnv2.prototype.createMarker = function(input) {
|
|
var meta = this.createMarkerMeta(input);
|
|
if (meta === null) {
|
|
return null;
|
|
}
|
|
return meta.marker;
|
|
};
|
|
DateEnv2.prototype.createNowMarker = function() {
|
|
if (this.canComputeOffset) {
|
|
return this.timestampToMarker(new Date().valueOf());
|
|
}
|
|
return arrayToUtcDate(dateToLocalArray(new Date()));
|
|
};
|
|
DateEnv2.prototype.createMarkerMeta = function(input) {
|
|
if (typeof input === "string") {
|
|
return this.parse(input);
|
|
}
|
|
var marker = null;
|
|
if (typeof input === "number") {
|
|
marker = this.timestampToMarker(input);
|
|
} else if (input instanceof Date) {
|
|
input = input.valueOf();
|
|
if (!isNaN(input)) {
|
|
marker = this.timestampToMarker(input);
|
|
}
|
|
} else if (Array.isArray(input)) {
|
|
marker = arrayToUtcDate(input);
|
|
}
|
|
if (marker === null || !isValidDate(marker)) {
|
|
return null;
|
|
}
|
|
return { marker, isTimeUnspecified: false, forcedTzo: null };
|
|
};
|
|
DateEnv2.prototype.parse = function(s3) {
|
|
var parts = parse(s3);
|
|
if (parts === null) {
|
|
return null;
|
|
}
|
|
var marker = parts.marker;
|
|
var forcedTzo = null;
|
|
if (parts.timeZoneOffset !== null) {
|
|
if (this.canComputeOffset) {
|
|
marker = this.timestampToMarker(marker.valueOf() - parts.timeZoneOffset * 60 * 1e3);
|
|
} else {
|
|
forcedTzo = parts.timeZoneOffset;
|
|
}
|
|
}
|
|
return { marker, isTimeUnspecified: parts.isTimeUnspecified, forcedTzo };
|
|
};
|
|
DateEnv2.prototype.getYear = function(marker) {
|
|
return this.calendarSystem.getMarkerYear(marker);
|
|
};
|
|
DateEnv2.prototype.getMonth = function(marker) {
|
|
return this.calendarSystem.getMarkerMonth(marker);
|
|
};
|
|
DateEnv2.prototype.add = function(marker, dur) {
|
|
var a3 = this.calendarSystem.markerToArray(marker);
|
|
a3[0] += dur.years;
|
|
a3[1] += dur.months;
|
|
a3[2] += dur.days;
|
|
a3[6] += dur.milliseconds;
|
|
return this.calendarSystem.arrayToMarker(a3);
|
|
};
|
|
DateEnv2.prototype.subtract = function(marker, dur) {
|
|
var a3 = this.calendarSystem.markerToArray(marker);
|
|
a3[0] -= dur.years;
|
|
a3[1] -= dur.months;
|
|
a3[2] -= dur.days;
|
|
a3[6] -= dur.milliseconds;
|
|
return this.calendarSystem.arrayToMarker(a3);
|
|
};
|
|
DateEnv2.prototype.addYears = function(marker, n2) {
|
|
var a3 = this.calendarSystem.markerToArray(marker);
|
|
a3[0] += n2;
|
|
return this.calendarSystem.arrayToMarker(a3);
|
|
};
|
|
DateEnv2.prototype.addMonths = function(marker, n2) {
|
|
var a3 = this.calendarSystem.markerToArray(marker);
|
|
a3[1] += n2;
|
|
return this.calendarSystem.arrayToMarker(a3);
|
|
};
|
|
DateEnv2.prototype.diffWholeYears = function(m0, m1) {
|
|
var calendarSystem = this.calendarSystem;
|
|
if (timeAsMs(m0) === timeAsMs(m1) && calendarSystem.getMarkerDay(m0) === calendarSystem.getMarkerDay(m1) && calendarSystem.getMarkerMonth(m0) === calendarSystem.getMarkerMonth(m1)) {
|
|
return calendarSystem.getMarkerYear(m1) - calendarSystem.getMarkerYear(m0);
|
|
}
|
|
return null;
|
|
};
|
|
DateEnv2.prototype.diffWholeMonths = function(m0, m1) {
|
|
var calendarSystem = this.calendarSystem;
|
|
if (timeAsMs(m0) === timeAsMs(m1) && calendarSystem.getMarkerDay(m0) === calendarSystem.getMarkerDay(m1)) {
|
|
return calendarSystem.getMarkerMonth(m1) - calendarSystem.getMarkerMonth(m0) + (calendarSystem.getMarkerYear(m1) - calendarSystem.getMarkerYear(m0)) * 12;
|
|
}
|
|
return null;
|
|
};
|
|
DateEnv2.prototype.greatestWholeUnit = function(m0, m1) {
|
|
var n2 = this.diffWholeYears(m0, m1);
|
|
if (n2 !== null) {
|
|
return { unit: "year", value: n2 };
|
|
}
|
|
n2 = this.diffWholeMonths(m0, m1);
|
|
if (n2 !== null) {
|
|
return { unit: "month", value: n2 };
|
|
}
|
|
n2 = diffWholeWeeks(m0, m1);
|
|
if (n2 !== null) {
|
|
return { unit: "week", value: n2 };
|
|
}
|
|
n2 = diffWholeDays(m0, m1);
|
|
if (n2 !== null) {
|
|
return { unit: "day", value: n2 };
|
|
}
|
|
n2 = diffHours(m0, m1);
|
|
if (isInt(n2)) {
|
|
return { unit: "hour", value: n2 };
|
|
}
|
|
n2 = diffMinutes(m0, m1);
|
|
if (isInt(n2)) {
|
|
return { unit: "minute", value: n2 };
|
|
}
|
|
n2 = diffSeconds(m0, m1);
|
|
if (isInt(n2)) {
|
|
return { unit: "second", value: n2 };
|
|
}
|
|
return { unit: "millisecond", value: m1.valueOf() - m0.valueOf() };
|
|
};
|
|
DateEnv2.prototype.countDurationsBetween = function(m0, m1, d3) {
|
|
var diff;
|
|
if (d3.years) {
|
|
diff = this.diffWholeYears(m0, m1);
|
|
if (diff !== null) {
|
|
return diff / asRoughYears(d3);
|
|
}
|
|
}
|
|
if (d3.months) {
|
|
diff = this.diffWholeMonths(m0, m1);
|
|
if (diff !== null) {
|
|
return diff / asRoughMonths(d3);
|
|
}
|
|
}
|
|
if (d3.days) {
|
|
diff = diffWholeDays(m0, m1);
|
|
if (diff !== null) {
|
|
return diff / asRoughDays(d3);
|
|
}
|
|
}
|
|
return (m1.valueOf() - m0.valueOf()) / asRoughMs(d3);
|
|
};
|
|
DateEnv2.prototype.startOf = function(m2, unit) {
|
|
if (unit === "year") {
|
|
return this.startOfYear(m2);
|
|
}
|
|
if (unit === "month") {
|
|
return this.startOfMonth(m2);
|
|
}
|
|
if (unit === "week") {
|
|
return this.startOfWeek(m2);
|
|
}
|
|
if (unit === "day") {
|
|
return startOfDay(m2);
|
|
}
|
|
if (unit === "hour") {
|
|
return startOfHour(m2);
|
|
}
|
|
if (unit === "minute") {
|
|
return startOfMinute(m2);
|
|
}
|
|
if (unit === "second") {
|
|
return startOfSecond(m2);
|
|
}
|
|
return null;
|
|
};
|
|
DateEnv2.prototype.startOfYear = function(m2) {
|
|
return this.calendarSystem.arrayToMarker([
|
|
this.calendarSystem.getMarkerYear(m2)
|
|
]);
|
|
};
|
|
DateEnv2.prototype.startOfMonth = function(m2) {
|
|
return this.calendarSystem.arrayToMarker([
|
|
this.calendarSystem.getMarkerYear(m2),
|
|
this.calendarSystem.getMarkerMonth(m2)
|
|
]);
|
|
};
|
|
DateEnv2.prototype.startOfWeek = function(m2) {
|
|
return this.calendarSystem.arrayToMarker([
|
|
this.calendarSystem.getMarkerYear(m2),
|
|
this.calendarSystem.getMarkerMonth(m2),
|
|
m2.getUTCDate() - (m2.getUTCDay() - this.weekDow + 7) % 7
|
|
]);
|
|
};
|
|
DateEnv2.prototype.computeWeekNumber = function(marker) {
|
|
if (this.weekNumberFunc) {
|
|
return this.weekNumberFunc(this.toDate(marker));
|
|
}
|
|
return weekOfYear(marker, this.weekDow, this.weekDoy);
|
|
};
|
|
DateEnv2.prototype.format = function(marker, formatter, dateOptions) {
|
|
if (dateOptions === void 0) {
|
|
dateOptions = {};
|
|
}
|
|
return formatter.format({
|
|
marker,
|
|
timeZoneOffset: dateOptions.forcedTzo != null ? dateOptions.forcedTzo : this.offsetForMarker(marker)
|
|
}, this);
|
|
};
|
|
DateEnv2.prototype.formatRange = function(start, end, formatter, dateOptions) {
|
|
if (dateOptions === void 0) {
|
|
dateOptions = {};
|
|
}
|
|
if (dateOptions.isEndExclusive) {
|
|
end = addMs(end, -1);
|
|
}
|
|
return formatter.formatRange({
|
|
marker: start,
|
|
timeZoneOffset: dateOptions.forcedStartTzo != null ? dateOptions.forcedStartTzo : this.offsetForMarker(start)
|
|
}, {
|
|
marker: end,
|
|
timeZoneOffset: dateOptions.forcedEndTzo != null ? dateOptions.forcedEndTzo : this.offsetForMarker(end)
|
|
}, this, dateOptions.defaultSeparator);
|
|
};
|
|
DateEnv2.prototype.formatIso = function(marker, extraOptions) {
|
|
if (extraOptions === void 0) {
|
|
extraOptions = {};
|
|
}
|
|
var timeZoneOffset = null;
|
|
if (!extraOptions.omitTimeZoneOffset) {
|
|
if (extraOptions.forcedTzo != null) {
|
|
timeZoneOffset = extraOptions.forcedTzo;
|
|
} else {
|
|
timeZoneOffset = this.offsetForMarker(marker);
|
|
}
|
|
}
|
|
return buildIsoString(marker, timeZoneOffset, extraOptions.omitTime);
|
|
};
|
|
DateEnv2.prototype.timestampToMarker = function(ms) {
|
|
if (this.timeZone === "local") {
|
|
return arrayToUtcDate(dateToLocalArray(new Date(ms)));
|
|
}
|
|
if (this.timeZone === "UTC" || !this.namedTimeZoneImpl) {
|
|
return new Date(ms);
|
|
}
|
|
return arrayToUtcDate(this.namedTimeZoneImpl.timestampToArray(ms));
|
|
};
|
|
DateEnv2.prototype.offsetForMarker = function(m2) {
|
|
if (this.timeZone === "local") {
|
|
return -arrayToLocalDate(dateToUtcArray(m2)).getTimezoneOffset();
|
|
}
|
|
if (this.timeZone === "UTC") {
|
|
return 0;
|
|
}
|
|
if (this.namedTimeZoneImpl) {
|
|
return this.namedTimeZoneImpl.offsetForArray(dateToUtcArray(m2));
|
|
}
|
|
return null;
|
|
};
|
|
DateEnv2.prototype.toDate = function(m2, forcedTzo) {
|
|
if (this.timeZone === "local") {
|
|
return arrayToLocalDate(dateToUtcArray(m2));
|
|
}
|
|
if (this.timeZone === "UTC") {
|
|
return new Date(m2.valueOf());
|
|
}
|
|
if (!this.namedTimeZoneImpl) {
|
|
return new Date(m2.valueOf() - (forcedTzo || 0));
|
|
}
|
|
return new Date(m2.valueOf() - this.namedTimeZoneImpl.offsetForArray(dateToUtcArray(m2)) * 1e3 * 60);
|
|
};
|
|
return DateEnv2;
|
|
}();
|
|
var globalLocales = [];
|
|
var MINIMAL_RAW_EN_LOCALE = {
|
|
code: "en",
|
|
week: {
|
|
dow: 0,
|
|
doy: 4
|
|
},
|
|
direction: "ltr",
|
|
buttonText: {
|
|
prev: "prev",
|
|
next: "next",
|
|
prevYear: "prev year",
|
|
nextYear: "next year",
|
|
year: "year",
|
|
today: "today",
|
|
month: "month",
|
|
week: "week",
|
|
day: "day",
|
|
list: "list"
|
|
},
|
|
weekText: "W",
|
|
weekTextLong: "Week",
|
|
closeHint: "Close",
|
|
timeHint: "Time",
|
|
eventHint: "Event",
|
|
allDayText: "all-day",
|
|
moreLinkText: "more",
|
|
noEventsText: "No events to display"
|
|
};
|
|
var RAW_EN_LOCALE = __assign(__assign({}, MINIMAL_RAW_EN_LOCALE), {
|
|
buttonHints: {
|
|
prev: "Previous $0",
|
|
next: "Next $0",
|
|
today: function(buttonText, unit) {
|
|
return unit === "day" ? "Today" : "This " + buttonText;
|
|
}
|
|
},
|
|
viewHint: "$0 view",
|
|
navLinkHint: "Go to $0",
|
|
moreLinkHint: function(eventCnt) {
|
|
return "Show " + eventCnt + " more event" + (eventCnt === 1 ? "" : "s");
|
|
}
|
|
});
|
|
function organizeRawLocales(explicitRawLocales) {
|
|
var defaultCode = explicitRawLocales.length > 0 ? explicitRawLocales[0].code : "en";
|
|
var allRawLocales = globalLocales.concat(explicitRawLocales);
|
|
var rawLocaleMap = {
|
|
en: RAW_EN_LOCALE
|
|
};
|
|
for (var _i = 0, allRawLocales_1 = allRawLocales; _i < allRawLocales_1.length; _i++) {
|
|
var rawLocale = allRawLocales_1[_i];
|
|
rawLocaleMap[rawLocale.code] = rawLocale;
|
|
}
|
|
return {
|
|
map: rawLocaleMap,
|
|
defaultCode
|
|
};
|
|
}
|
|
function buildLocale(inputSingular, available) {
|
|
if (typeof inputSingular === "object" && !Array.isArray(inputSingular)) {
|
|
return parseLocale(inputSingular.code, [inputSingular.code], inputSingular);
|
|
}
|
|
return queryLocale(inputSingular, available);
|
|
}
|
|
function queryLocale(codeArg, available) {
|
|
var codes = [].concat(codeArg || []);
|
|
var raw = queryRawLocale(codes, available) || RAW_EN_LOCALE;
|
|
return parseLocale(codeArg, codes, raw);
|
|
}
|
|
function queryRawLocale(codes, available) {
|
|
for (var i3 = 0; i3 < codes.length; i3 += 1) {
|
|
var parts = codes[i3].toLocaleLowerCase().split("-");
|
|
for (var j4 = parts.length; j4 > 0; j4 -= 1) {
|
|
var simpleId = parts.slice(0, j4).join("-");
|
|
if (available[simpleId]) {
|
|
return available[simpleId];
|
|
}
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
function parseLocale(codeArg, codes, raw) {
|
|
var merged = mergeProps([MINIMAL_RAW_EN_LOCALE, raw], ["buttonText"]);
|
|
delete merged.code;
|
|
var week = merged.week;
|
|
delete merged.week;
|
|
return {
|
|
codeArg,
|
|
codes,
|
|
week,
|
|
simpleNumberFormat: new Intl.NumberFormat(codeArg),
|
|
options: merged
|
|
};
|
|
}
|
|
var DEF_DEFAULTS = {
|
|
startTime: "09:00",
|
|
endTime: "17:00",
|
|
daysOfWeek: [1, 2, 3, 4, 5],
|
|
display: "inverse-background",
|
|
classNames: "fc-non-business",
|
|
groupId: "_businessHours"
|
|
};
|
|
function parseBusinessHours(input, context) {
|
|
return parseEvents(refineInputs(input), null, context);
|
|
}
|
|
function refineInputs(input) {
|
|
var rawDefs;
|
|
if (input === true) {
|
|
rawDefs = [{}];
|
|
} else if (Array.isArray(input)) {
|
|
rawDefs = input.filter(function(rawDef) {
|
|
return rawDef.daysOfWeek;
|
|
});
|
|
} else if (typeof input === "object" && input) {
|
|
rawDefs = [input];
|
|
} else {
|
|
rawDefs = [];
|
|
}
|
|
rawDefs = rawDefs.map(function(rawDef) {
|
|
return __assign(__assign({}, DEF_DEFAULTS), rawDef);
|
|
});
|
|
return rawDefs;
|
|
}
|
|
function pointInsideRect(point, rect) {
|
|
return point.left >= rect.left && point.left < rect.right && point.top >= rect.top && point.top < rect.bottom;
|
|
}
|
|
function intersectRects(rect1, rect2) {
|
|
var res = {
|
|
left: Math.max(rect1.left, rect2.left),
|
|
right: Math.min(rect1.right, rect2.right),
|
|
top: Math.max(rect1.top, rect2.top),
|
|
bottom: Math.min(rect1.bottom, rect2.bottom)
|
|
};
|
|
if (res.left < res.right && res.top < res.bottom) {
|
|
return res;
|
|
}
|
|
return false;
|
|
}
|
|
function constrainPoint(point, rect) {
|
|
return {
|
|
left: Math.min(Math.max(point.left, rect.left), rect.right),
|
|
top: Math.min(Math.max(point.top, rect.top), rect.bottom)
|
|
};
|
|
}
|
|
function getRectCenter(rect) {
|
|
return {
|
|
left: (rect.left + rect.right) / 2,
|
|
top: (rect.top + rect.bottom) / 2
|
|
};
|
|
}
|
|
function diffPoints(point1, point2) {
|
|
return {
|
|
left: point1.left - point2.left,
|
|
top: point1.top - point2.top
|
|
};
|
|
}
|
|
var canVGrowWithinCell;
|
|
function getCanVGrowWithinCell() {
|
|
if (canVGrowWithinCell == null) {
|
|
canVGrowWithinCell = computeCanVGrowWithinCell();
|
|
}
|
|
return canVGrowWithinCell;
|
|
}
|
|
function computeCanVGrowWithinCell() {
|
|
if (typeof document === "undefined") {
|
|
return true;
|
|
}
|
|
var el = document.createElement("div");
|
|
el.style.position = "absolute";
|
|
el.style.top = "0px";
|
|
el.style.left = "0px";
|
|
el.innerHTML = "<table><tr><td><div></div></td></tr></table>";
|
|
el.querySelector("table").style.height = "100px";
|
|
el.querySelector("div").style.height = "100%";
|
|
document.body.appendChild(el);
|
|
var div = el.querySelector("div");
|
|
var possible = div.offsetHeight > 0;
|
|
document.body.removeChild(el);
|
|
return possible;
|
|
}
|
|
var EMPTY_EVENT_STORE = createEmptyEventStore();
|
|
var Splitter = function() {
|
|
function Splitter2() {
|
|
this.getKeysForEventDefs = memoize(this._getKeysForEventDefs);
|
|
this.splitDateSelection = memoize(this._splitDateSpan);
|
|
this.splitEventStore = memoize(this._splitEventStore);
|
|
this.splitIndividualUi = memoize(this._splitIndividualUi);
|
|
this.splitEventDrag = memoize(this._splitInteraction);
|
|
this.splitEventResize = memoize(this._splitInteraction);
|
|
this.eventUiBuilders = {};
|
|
}
|
|
Splitter2.prototype.splitProps = function(props) {
|
|
var _this = this;
|
|
var keyInfos = this.getKeyInfo(props);
|
|
var defKeys = this.getKeysForEventDefs(props.eventStore);
|
|
var dateSelections = this.splitDateSelection(props.dateSelection);
|
|
var individualUi = this.splitIndividualUi(props.eventUiBases, defKeys);
|
|
var eventStores = this.splitEventStore(props.eventStore, defKeys);
|
|
var eventDrags = this.splitEventDrag(props.eventDrag);
|
|
var eventResizes = this.splitEventResize(props.eventResize);
|
|
var splitProps = {};
|
|
this.eventUiBuilders = mapHash(keyInfos, function(info, key2) {
|
|
return _this.eventUiBuilders[key2] || memoize(buildEventUiForKey);
|
|
});
|
|
for (var key in keyInfos) {
|
|
var keyInfo = keyInfos[key];
|
|
var eventStore = eventStores[key] || EMPTY_EVENT_STORE;
|
|
var buildEventUi = this.eventUiBuilders[key];
|
|
splitProps[key] = {
|
|
businessHours: keyInfo.businessHours || props.businessHours,
|
|
dateSelection: dateSelections[key] || null,
|
|
eventStore,
|
|
eventUiBases: buildEventUi(props.eventUiBases[""], keyInfo.ui, individualUi[key]),
|
|
eventSelection: eventStore.instances[props.eventSelection] ? props.eventSelection : "",
|
|
eventDrag: eventDrags[key] || null,
|
|
eventResize: eventResizes[key] || null
|
|
};
|
|
}
|
|
return splitProps;
|
|
};
|
|
Splitter2.prototype._splitDateSpan = function(dateSpan) {
|
|
var dateSpans = {};
|
|
if (dateSpan) {
|
|
var keys = this.getKeysForDateSpan(dateSpan);
|
|
for (var _i = 0, keys_1 = keys; _i < keys_1.length; _i++) {
|
|
var key = keys_1[_i];
|
|
dateSpans[key] = dateSpan;
|
|
}
|
|
}
|
|
return dateSpans;
|
|
};
|
|
Splitter2.prototype._getKeysForEventDefs = function(eventStore) {
|
|
var _this = this;
|
|
return mapHash(eventStore.defs, function(eventDef) {
|
|
return _this.getKeysForEventDef(eventDef);
|
|
});
|
|
};
|
|
Splitter2.prototype._splitEventStore = function(eventStore, defKeys) {
|
|
var defs = eventStore.defs, instances = eventStore.instances;
|
|
var splitStores = {};
|
|
for (var defId in defs) {
|
|
for (var _i = 0, _a = defKeys[defId]; _i < _a.length; _i++) {
|
|
var key = _a[_i];
|
|
if (!splitStores[key]) {
|
|
splitStores[key] = createEmptyEventStore();
|
|
}
|
|
splitStores[key].defs[defId] = defs[defId];
|
|
}
|
|
}
|
|
for (var instanceId in instances) {
|
|
var instance = instances[instanceId];
|
|
for (var _b = 0, _c = defKeys[instance.defId]; _b < _c.length; _b++) {
|
|
var key = _c[_b];
|
|
if (splitStores[key]) {
|
|
splitStores[key].instances[instanceId] = instance;
|
|
}
|
|
}
|
|
}
|
|
return splitStores;
|
|
};
|
|
Splitter2.prototype._splitIndividualUi = function(eventUiBases, defKeys) {
|
|
var splitHashes = {};
|
|
for (var defId in eventUiBases) {
|
|
if (defId) {
|
|
for (var _i = 0, _a = defKeys[defId]; _i < _a.length; _i++) {
|
|
var key = _a[_i];
|
|
if (!splitHashes[key]) {
|
|
splitHashes[key] = {};
|
|
}
|
|
splitHashes[key][defId] = eventUiBases[defId];
|
|
}
|
|
}
|
|
}
|
|
return splitHashes;
|
|
};
|
|
Splitter2.prototype._splitInteraction = function(interaction) {
|
|
var splitStates = {};
|
|
if (interaction) {
|
|
var affectedStores_1 = this._splitEventStore(interaction.affectedEvents, this._getKeysForEventDefs(interaction.affectedEvents));
|
|
var mutatedKeysByDefId = this._getKeysForEventDefs(interaction.mutatedEvents);
|
|
var mutatedStores_1 = this._splitEventStore(interaction.mutatedEvents, mutatedKeysByDefId);
|
|
var populate = function(key2) {
|
|
if (!splitStates[key2]) {
|
|
splitStates[key2] = {
|
|
affectedEvents: affectedStores_1[key2] || EMPTY_EVENT_STORE,
|
|
mutatedEvents: mutatedStores_1[key2] || EMPTY_EVENT_STORE,
|
|
isEvent: interaction.isEvent
|
|
};
|
|
}
|
|
};
|
|
for (var key in affectedStores_1) {
|
|
populate(key);
|
|
}
|
|
for (var key in mutatedStores_1) {
|
|
populate(key);
|
|
}
|
|
}
|
|
return splitStates;
|
|
};
|
|
return Splitter2;
|
|
}();
|
|
function buildEventUiForKey(allUi, eventUiForKey, individualUi) {
|
|
var baseParts = [];
|
|
if (allUi) {
|
|
baseParts.push(allUi);
|
|
}
|
|
if (eventUiForKey) {
|
|
baseParts.push(eventUiForKey);
|
|
}
|
|
var stuff = {
|
|
"": combineEventUis(baseParts)
|
|
};
|
|
if (individualUi) {
|
|
__assign(stuff, individualUi);
|
|
}
|
|
return stuff;
|
|
}
|
|
function getDateMeta(date, todayRange, nowDate, dateProfile) {
|
|
return {
|
|
dow: date.getUTCDay(),
|
|
isDisabled: Boolean(dateProfile && !rangeContainsMarker(dateProfile.activeRange, date)),
|
|
isOther: Boolean(dateProfile && !rangeContainsMarker(dateProfile.currentRange, date)),
|
|
isToday: Boolean(todayRange && rangeContainsMarker(todayRange, date)),
|
|
isPast: Boolean(nowDate ? date < nowDate : todayRange ? date < todayRange.start : false),
|
|
isFuture: Boolean(nowDate ? date > nowDate : todayRange ? date >= todayRange.end : false)
|
|
};
|
|
}
|
|
function getDayClassNames(meta, theme) {
|
|
var classNames = [
|
|
"fc-day",
|
|
"fc-day-" + DAY_IDS[meta.dow]
|
|
];
|
|
if (meta.isDisabled) {
|
|
classNames.push("fc-day-disabled");
|
|
} else {
|
|
if (meta.isToday) {
|
|
classNames.push("fc-day-today");
|
|
classNames.push(theme.getClass("today"));
|
|
}
|
|
if (meta.isPast) {
|
|
classNames.push("fc-day-past");
|
|
}
|
|
if (meta.isFuture) {
|
|
classNames.push("fc-day-future");
|
|
}
|
|
if (meta.isOther) {
|
|
classNames.push("fc-day-other");
|
|
}
|
|
}
|
|
return classNames;
|
|
}
|
|
var DAY_FORMAT = createFormatter({ year: "numeric", month: "long", day: "numeric" });
|
|
var WEEK_FORMAT = createFormatter({ week: "long" });
|
|
function buildNavLinkAttrs(context, dateMarker, viewType, isTabbable) {
|
|
if (viewType === void 0) {
|
|
viewType = "day";
|
|
}
|
|
if (isTabbable === void 0) {
|
|
isTabbable = true;
|
|
}
|
|
var dateEnv = context.dateEnv, options = context.options, calendarApi = context.calendarApi;
|
|
var dateStr = dateEnv.format(dateMarker, viewType === "week" ? WEEK_FORMAT : DAY_FORMAT);
|
|
if (options.navLinks) {
|
|
var zonedDate = dateEnv.toDate(dateMarker);
|
|
var handleInteraction = function(ev) {
|
|
var customAction = viewType === "day" ? options.navLinkDayClick : viewType === "week" ? options.navLinkWeekClick : null;
|
|
if (typeof customAction === "function") {
|
|
customAction.call(calendarApi, dateEnv.toDate(dateMarker), ev);
|
|
} else {
|
|
if (typeof customAction === "string") {
|
|
viewType = customAction;
|
|
}
|
|
calendarApi.zoomTo(dateMarker, viewType);
|
|
}
|
|
};
|
|
return __assign({ title: formatWithOrdinals(options.navLinkHint, [dateStr, zonedDate], dateStr), "data-navlink": "" }, isTabbable ? createAriaClickAttrs(handleInteraction) : { onClick: handleInteraction });
|
|
}
|
|
return { "aria-label": dateStr };
|
|
}
|
|
var _isRtlScrollbarOnLeft = null;
|
|
function getIsRtlScrollbarOnLeft() {
|
|
if (_isRtlScrollbarOnLeft === null) {
|
|
_isRtlScrollbarOnLeft = computeIsRtlScrollbarOnLeft();
|
|
}
|
|
return _isRtlScrollbarOnLeft;
|
|
}
|
|
function computeIsRtlScrollbarOnLeft() {
|
|
var outerEl = document.createElement("div");
|
|
applyStyle(outerEl, {
|
|
position: "absolute",
|
|
top: -1e3,
|
|
left: 0,
|
|
border: 0,
|
|
padding: 0,
|
|
overflow: "scroll",
|
|
direction: "rtl"
|
|
});
|
|
outerEl.innerHTML = "<div></div>";
|
|
document.body.appendChild(outerEl);
|
|
var innerEl = outerEl.firstChild;
|
|
var res = innerEl.getBoundingClientRect().left > outerEl.getBoundingClientRect().left;
|
|
removeElement(outerEl);
|
|
return res;
|
|
}
|
|
var _scrollbarWidths;
|
|
function getScrollbarWidths() {
|
|
if (!_scrollbarWidths) {
|
|
_scrollbarWidths = computeScrollbarWidths();
|
|
}
|
|
return _scrollbarWidths;
|
|
}
|
|
function computeScrollbarWidths() {
|
|
var el = document.createElement("div");
|
|
el.style.overflow = "scroll";
|
|
el.style.position = "absolute";
|
|
el.style.top = "-9999px";
|
|
el.style.left = "-9999px";
|
|
document.body.appendChild(el);
|
|
var res = computeScrollbarWidthsForEl(el);
|
|
document.body.removeChild(el);
|
|
return res;
|
|
}
|
|
function computeScrollbarWidthsForEl(el) {
|
|
return {
|
|
x: el.offsetHeight - el.clientHeight,
|
|
y: el.offsetWidth - el.clientWidth
|
|
};
|
|
}
|
|
function computeEdges(el, getPadding) {
|
|
if (getPadding === void 0) {
|
|
getPadding = false;
|
|
}
|
|
var computedStyle = window.getComputedStyle(el);
|
|
var borderLeft = parseInt(computedStyle.borderLeftWidth, 10) || 0;
|
|
var borderRight = parseInt(computedStyle.borderRightWidth, 10) || 0;
|
|
var borderTop = parseInt(computedStyle.borderTopWidth, 10) || 0;
|
|
var borderBottom = parseInt(computedStyle.borderBottomWidth, 10) || 0;
|
|
var badScrollbarWidths = computeScrollbarWidthsForEl(el);
|
|
var scrollbarLeftRight = badScrollbarWidths.y - borderLeft - borderRight;
|
|
var scrollbarBottom = badScrollbarWidths.x - borderTop - borderBottom;
|
|
var res = {
|
|
borderLeft,
|
|
borderRight,
|
|
borderTop,
|
|
borderBottom,
|
|
scrollbarBottom,
|
|
scrollbarLeft: 0,
|
|
scrollbarRight: 0
|
|
};
|
|
if (getIsRtlScrollbarOnLeft() && computedStyle.direction === "rtl") {
|
|
res.scrollbarLeft = scrollbarLeftRight;
|
|
} else {
|
|
res.scrollbarRight = scrollbarLeftRight;
|
|
}
|
|
if (getPadding) {
|
|
res.paddingLeft = parseInt(computedStyle.paddingLeft, 10) || 0;
|
|
res.paddingRight = parseInt(computedStyle.paddingRight, 10) || 0;
|
|
res.paddingTop = parseInt(computedStyle.paddingTop, 10) || 0;
|
|
res.paddingBottom = parseInt(computedStyle.paddingBottom, 10) || 0;
|
|
}
|
|
return res;
|
|
}
|
|
function computeInnerRect(el, goWithinPadding, doFromWindowViewport) {
|
|
if (goWithinPadding === void 0) {
|
|
goWithinPadding = false;
|
|
}
|
|
var outerRect = doFromWindowViewport ? el.getBoundingClientRect() : computeRect(el);
|
|
var edges = computeEdges(el, goWithinPadding);
|
|
var res = {
|
|
left: outerRect.left + edges.borderLeft + edges.scrollbarLeft,
|
|
right: outerRect.right - edges.borderRight - edges.scrollbarRight,
|
|
top: outerRect.top + edges.borderTop,
|
|
bottom: outerRect.bottom - edges.borderBottom - edges.scrollbarBottom
|
|
};
|
|
if (goWithinPadding) {
|
|
res.left += edges.paddingLeft;
|
|
res.right -= edges.paddingRight;
|
|
res.top += edges.paddingTop;
|
|
res.bottom -= edges.paddingBottom;
|
|
}
|
|
return res;
|
|
}
|
|
function computeRect(el) {
|
|
var rect = el.getBoundingClientRect();
|
|
return {
|
|
left: rect.left + window.pageXOffset,
|
|
top: rect.top + window.pageYOffset,
|
|
right: rect.right + window.pageXOffset,
|
|
bottom: rect.bottom + window.pageYOffset
|
|
};
|
|
}
|
|
function computeClippedClientRect(el) {
|
|
var clippingParents = getClippingParents(el);
|
|
var rect = el.getBoundingClientRect();
|
|
for (var _i = 0, clippingParents_1 = clippingParents; _i < clippingParents_1.length; _i++) {
|
|
var clippingParent = clippingParents_1[_i];
|
|
var intersection = intersectRects(rect, clippingParent.getBoundingClientRect());
|
|
if (intersection) {
|
|
rect = intersection;
|
|
} else {
|
|
return null;
|
|
}
|
|
}
|
|
return rect;
|
|
}
|
|
function getClippingParents(el) {
|
|
var parents = [];
|
|
while (el instanceof HTMLElement) {
|
|
var computedStyle = window.getComputedStyle(el);
|
|
if (computedStyle.position === "fixed") {
|
|
break;
|
|
}
|
|
if (/(auto|scroll)/.test(computedStyle.overflow + computedStyle.overflowY + computedStyle.overflowX)) {
|
|
parents.push(el);
|
|
}
|
|
el = el.parentNode;
|
|
}
|
|
return parents;
|
|
}
|
|
function unpromisify(func, success, failure) {
|
|
var isResolved = false;
|
|
var wrappedSuccess = function() {
|
|
if (!isResolved) {
|
|
isResolved = true;
|
|
success.apply(this, arguments);
|
|
}
|
|
};
|
|
var wrappedFailure = function() {
|
|
if (!isResolved) {
|
|
isResolved = true;
|
|
if (failure) {
|
|
failure.apply(this, arguments);
|
|
}
|
|
}
|
|
};
|
|
var res = func(wrappedSuccess, wrappedFailure);
|
|
if (res && typeof res.then === "function") {
|
|
res.then(wrappedSuccess, wrappedFailure);
|
|
}
|
|
}
|
|
var Emitter = function() {
|
|
function Emitter2() {
|
|
this.handlers = {};
|
|
this.thisContext = null;
|
|
}
|
|
Emitter2.prototype.setThisContext = function(thisContext) {
|
|
this.thisContext = thisContext;
|
|
};
|
|
Emitter2.prototype.setOptions = function(options) {
|
|
this.options = options;
|
|
};
|
|
Emitter2.prototype.on = function(type, handler) {
|
|
addToHash(this.handlers, type, handler);
|
|
};
|
|
Emitter2.prototype.off = function(type, handler) {
|
|
removeFromHash(this.handlers, type, handler);
|
|
};
|
|
Emitter2.prototype.trigger = function(type) {
|
|
var args = [];
|
|
for (var _i = 1; _i < arguments.length; _i++) {
|
|
args[_i - 1] = arguments[_i];
|
|
}
|
|
var attachedHandlers = this.handlers[type] || [];
|
|
var optionHandler = this.options && this.options[type];
|
|
var handlers = [].concat(optionHandler || [], attachedHandlers);
|
|
for (var _a = 0, handlers_1 = handlers; _a < handlers_1.length; _a++) {
|
|
var handler = handlers_1[_a];
|
|
handler.apply(this.thisContext, args);
|
|
}
|
|
};
|
|
Emitter2.prototype.hasHandlers = function(type) {
|
|
return Boolean(this.handlers[type] && this.handlers[type].length || this.options && this.options[type]);
|
|
};
|
|
return Emitter2;
|
|
}();
|
|
function addToHash(hash, type, handler) {
|
|
(hash[type] || (hash[type] = [])).push(handler);
|
|
}
|
|
function removeFromHash(hash, type, handler) {
|
|
if (handler) {
|
|
if (hash[type]) {
|
|
hash[type] = hash[type].filter(function(func) {
|
|
return func !== handler;
|
|
});
|
|
}
|
|
} else {
|
|
delete hash[type];
|
|
}
|
|
}
|
|
var PositionCache = function() {
|
|
function PositionCache2(originEl, els, isHorizontal, isVertical) {
|
|
this.els = els;
|
|
var originClientRect = this.originClientRect = originEl.getBoundingClientRect();
|
|
if (isHorizontal) {
|
|
this.buildElHorizontals(originClientRect.left);
|
|
}
|
|
if (isVertical) {
|
|
this.buildElVerticals(originClientRect.top);
|
|
}
|
|
}
|
|
PositionCache2.prototype.buildElHorizontals = function(originClientLeft) {
|
|
var lefts = [];
|
|
var rights = [];
|
|
for (var _i = 0, _a = this.els; _i < _a.length; _i++) {
|
|
var el = _a[_i];
|
|
var rect = el.getBoundingClientRect();
|
|
lefts.push(rect.left - originClientLeft);
|
|
rights.push(rect.right - originClientLeft);
|
|
}
|
|
this.lefts = lefts;
|
|
this.rights = rights;
|
|
};
|
|
PositionCache2.prototype.buildElVerticals = function(originClientTop) {
|
|
var tops = [];
|
|
var bottoms = [];
|
|
for (var _i = 0, _a = this.els; _i < _a.length; _i++) {
|
|
var el = _a[_i];
|
|
var rect = el.getBoundingClientRect();
|
|
tops.push(rect.top - originClientTop);
|
|
bottoms.push(rect.bottom - originClientTop);
|
|
}
|
|
this.tops = tops;
|
|
this.bottoms = bottoms;
|
|
};
|
|
PositionCache2.prototype.leftToIndex = function(leftPosition) {
|
|
var _a = this, lefts = _a.lefts, rights = _a.rights;
|
|
var len = lefts.length;
|
|
var i3;
|
|
for (i3 = 0; i3 < len; i3 += 1) {
|
|
if (leftPosition >= lefts[i3] && leftPosition < rights[i3]) {
|
|
return i3;
|
|
}
|
|
}
|
|
return void 0;
|
|
};
|
|
PositionCache2.prototype.topToIndex = function(topPosition) {
|
|
var _a = this, tops = _a.tops, bottoms = _a.bottoms;
|
|
var len = tops.length;
|
|
var i3;
|
|
for (i3 = 0; i3 < len; i3 += 1) {
|
|
if (topPosition >= tops[i3] && topPosition < bottoms[i3]) {
|
|
return i3;
|
|
}
|
|
}
|
|
return void 0;
|
|
};
|
|
PositionCache2.prototype.getWidth = function(leftIndex) {
|
|
return this.rights[leftIndex] - this.lefts[leftIndex];
|
|
};
|
|
PositionCache2.prototype.getHeight = function(topIndex) {
|
|
return this.bottoms[topIndex] - this.tops[topIndex];
|
|
};
|
|
return PositionCache2;
|
|
}();
|
|
var ScrollController = function() {
|
|
function ScrollController2() {
|
|
}
|
|
ScrollController2.prototype.getMaxScrollTop = function() {
|
|
return this.getScrollHeight() - this.getClientHeight();
|
|
};
|
|
ScrollController2.prototype.getMaxScrollLeft = function() {
|
|
return this.getScrollWidth() - this.getClientWidth();
|
|
};
|
|
ScrollController2.prototype.canScrollVertically = function() {
|
|
return this.getMaxScrollTop() > 0;
|
|
};
|
|
ScrollController2.prototype.canScrollHorizontally = function() {
|
|
return this.getMaxScrollLeft() > 0;
|
|
};
|
|
ScrollController2.prototype.canScrollUp = function() {
|
|
return this.getScrollTop() > 0;
|
|
};
|
|
ScrollController2.prototype.canScrollDown = function() {
|
|
return this.getScrollTop() < this.getMaxScrollTop();
|
|
};
|
|
ScrollController2.prototype.canScrollLeft = function() {
|
|
return this.getScrollLeft() > 0;
|
|
};
|
|
ScrollController2.prototype.canScrollRight = function() {
|
|
return this.getScrollLeft() < this.getMaxScrollLeft();
|
|
};
|
|
return ScrollController2;
|
|
}();
|
|
var ElementScrollController = function(_super) {
|
|
__extends(ElementScrollController2, _super);
|
|
function ElementScrollController2(el) {
|
|
var _this = _super.call(this) || this;
|
|
_this.el = el;
|
|
return _this;
|
|
}
|
|
ElementScrollController2.prototype.getScrollTop = function() {
|
|
return this.el.scrollTop;
|
|
};
|
|
ElementScrollController2.prototype.getScrollLeft = function() {
|
|
return this.el.scrollLeft;
|
|
};
|
|
ElementScrollController2.prototype.setScrollTop = function(top) {
|
|
this.el.scrollTop = top;
|
|
};
|
|
ElementScrollController2.prototype.setScrollLeft = function(left) {
|
|
this.el.scrollLeft = left;
|
|
};
|
|
ElementScrollController2.prototype.getScrollWidth = function() {
|
|
return this.el.scrollWidth;
|
|
};
|
|
ElementScrollController2.prototype.getScrollHeight = function() {
|
|
return this.el.scrollHeight;
|
|
};
|
|
ElementScrollController2.prototype.getClientHeight = function() {
|
|
return this.el.clientHeight;
|
|
};
|
|
ElementScrollController2.prototype.getClientWidth = function() {
|
|
return this.el.clientWidth;
|
|
};
|
|
return ElementScrollController2;
|
|
}(ScrollController);
|
|
var WindowScrollController = function(_super) {
|
|
__extends(WindowScrollController2, _super);
|
|
function WindowScrollController2() {
|
|
return _super !== null && _super.apply(this, arguments) || this;
|
|
}
|
|
WindowScrollController2.prototype.getScrollTop = function() {
|
|
return window.pageYOffset;
|
|
};
|
|
WindowScrollController2.prototype.getScrollLeft = function() {
|
|
return window.pageXOffset;
|
|
};
|
|
WindowScrollController2.prototype.setScrollTop = function(n2) {
|
|
window.scroll(window.pageXOffset, n2);
|
|
};
|
|
WindowScrollController2.prototype.setScrollLeft = function(n2) {
|
|
window.scroll(n2, window.pageYOffset);
|
|
};
|
|
WindowScrollController2.prototype.getScrollWidth = function() {
|
|
return document.documentElement.scrollWidth;
|
|
};
|
|
WindowScrollController2.prototype.getScrollHeight = function() {
|
|
return document.documentElement.scrollHeight;
|
|
};
|
|
WindowScrollController2.prototype.getClientHeight = function() {
|
|
return document.documentElement.clientHeight;
|
|
};
|
|
WindowScrollController2.prototype.getClientWidth = function() {
|
|
return document.documentElement.clientWidth;
|
|
};
|
|
return WindowScrollController2;
|
|
}(ScrollController);
|
|
var Theme = function() {
|
|
function Theme2(calendarOptions) {
|
|
if (this.iconOverrideOption) {
|
|
this.setIconOverride(calendarOptions[this.iconOverrideOption]);
|
|
}
|
|
}
|
|
Theme2.prototype.setIconOverride = function(iconOverrideHash) {
|
|
var iconClassesCopy;
|
|
var buttonName;
|
|
if (typeof iconOverrideHash === "object" && iconOverrideHash) {
|
|
iconClassesCopy = __assign({}, this.iconClasses);
|
|
for (buttonName in iconOverrideHash) {
|
|
iconClassesCopy[buttonName] = this.applyIconOverridePrefix(iconOverrideHash[buttonName]);
|
|
}
|
|
this.iconClasses = iconClassesCopy;
|
|
} else if (iconOverrideHash === false) {
|
|
this.iconClasses = {};
|
|
}
|
|
};
|
|
Theme2.prototype.applyIconOverridePrefix = function(className) {
|
|
var prefix = this.iconOverridePrefix;
|
|
if (prefix && className.indexOf(prefix) !== 0) {
|
|
className = prefix + className;
|
|
}
|
|
return className;
|
|
};
|
|
Theme2.prototype.getClass = function(key) {
|
|
return this.classes[key] || "";
|
|
};
|
|
Theme2.prototype.getIconClass = function(buttonName, isRtl) {
|
|
var className;
|
|
if (isRtl && this.rtlIconClasses) {
|
|
className = this.rtlIconClasses[buttonName] || this.iconClasses[buttonName];
|
|
} else {
|
|
className = this.iconClasses[buttonName];
|
|
}
|
|
if (className) {
|
|
return this.baseIconClass + " " + className;
|
|
}
|
|
return "";
|
|
};
|
|
Theme2.prototype.getCustomButtonIconClass = function(customButtonProps) {
|
|
var className;
|
|
if (this.iconOverrideCustomButtonOption) {
|
|
className = customButtonProps[this.iconOverrideCustomButtonOption];
|
|
if (className) {
|
|
return this.baseIconClass + " " + this.applyIconOverridePrefix(className);
|
|
}
|
|
}
|
|
return "";
|
|
};
|
|
return Theme2;
|
|
}();
|
|
Theme.prototype.classes = {};
|
|
Theme.prototype.iconClasses = {};
|
|
Theme.prototype.baseIconClass = "";
|
|
Theme.prototype.iconOverridePrefix = "";
|
|
var ScrollResponder = function() {
|
|
function ScrollResponder2(execFunc, emitter, scrollTime, scrollTimeReset) {
|
|
var _this = this;
|
|
this.execFunc = execFunc;
|
|
this.emitter = emitter;
|
|
this.scrollTime = scrollTime;
|
|
this.scrollTimeReset = scrollTimeReset;
|
|
this.handleScrollRequest = function(request3) {
|
|
_this.queuedRequest = __assign({}, _this.queuedRequest || {}, request3);
|
|
_this.drain();
|
|
};
|
|
emitter.on("_scrollRequest", this.handleScrollRequest);
|
|
this.fireInitialScroll();
|
|
}
|
|
ScrollResponder2.prototype.detach = function() {
|
|
this.emitter.off("_scrollRequest", this.handleScrollRequest);
|
|
};
|
|
ScrollResponder2.prototype.update = function(isDatesNew) {
|
|
if (isDatesNew && this.scrollTimeReset) {
|
|
this.fireInitialScroll();
|
|
} else {
|
|
this.drain();
|
|
}
|
|
};
|
|
ScrollResponder2.prototype.fireInitialScroll = function() {
|
|
this.handleScrollRequest({
|
|
time: this.scrollTime
|
|
});
|
|
};
|
|
ScrollResponder2.prototype.drain = function() {
|
|
if (this.queuedRequest && this.execFunc(this.queuedRequest)) {
|
|
this.queuedRequest = null;
|
|
}
|
|
};
|
|
return ScrollResponder2;
|
|
}();
|
|
var ViewContextType = createContext2({});
|
|
function buildViewContext(viewSpec, viewApi, viewOptions, dateProfileGenerator, dateEnv, theme, pluginHooks, dispatch, getCurrentData, emitter, calendarApi, registerInteractiveComponent, unregisterInteractiveComponent) {
|
|
return {
|
|
dateEnv,
|
|
options: viewOptions,
|
|
pluginHooks,
|
|
emitter,
|
|
dispatch,
|
|
getCurrentData,
|
|
calendarApi,
|
|
viewSpec,
|
|
viewApi,
|
|
dateProfileGenerator,
|
|
theme,
|
|
isRtl: viewOptions.direction === "rtl",
|
|
addResizeHandler: function(handler) {
|
|
emitter.on("_resize", handler);
|
|
},
|
|
removeResizeHandler: function(handler) {
|
|
emitter.off("_resize", handler);
|
|
},
|
|
createScrollResponder: function(execFunc) {
|
|
return new ScrollResponder(execFunc, emitter, createDuration(viewOptions.scrollTime), viewOptions.scrollTimeReset);
|
|
},
|
|
registerInteractiveComponent,
|
|
unregisterInteractiveComponent
|
|
};
|
|
}
|
|
var PureComponent = function(_super) {
|
|
__extends(PureComponent2, _super);
|
|
function PureComponent2() {
|
|
return _super !== null && _super.apply(this, arguments) || this;
|
|
}
|
|
PureComponent2.prototype.shouldComponentUpdate = function(nextProps, nextState) {
|
|
if (this.debug) {
|
|
console.log(getUnequalProps(nextProps, this.props), getUnequalProps(nextState, this.state));
|
|
}
|
|
return !compareObjs(this.props, nextProps, this.propEquality) || !compareObjs(this.state, nextState, this.stateEquality);
|
|
};
|
|
PureComponent2.addPropsEquality = addPropsEquality;
|
|
PureComponent2.addStateEquality = addStateEquality;
|
|
PureComponent2.contextType = ViewContextType;
|
|
return PureComponent2;
|
|
}(Component);
|
|
PureComponent.prototype.propEquality = {};
|
|
PureComponent.prototype.stateEquality = {};
|
|
var BaseComponent = function(_super) {
|
|
__extends(BaseComponent2, _super);
|
|
function BaseComponent2() {
|
|
return _super !== null && _super.apply(this, arguments) || this;
|
|
}
|
|
BaseComponent2.contextType = ViewContextType;
|
|
return BaseComponent2;
|
|
}(PureComponent);
|
|
function addPropsEquality(propEquality) {
|
|
var hash = Object.create(this.prototype.propEquality);
|
|
__assign(hash, propEquality);
|
|
this.prototype.propEquality = hash;
|
|
}
|
|
function addStateEquality(stateEquality) {
|
|
var hash = Object.create(this.prototype.stateEquality);
|
|
__assign(hash, stateEquality);
|
|
this.prototype.stateEquality = hash;
|
|
}
|
|
function setRef(ref, current) {
|
|
if (typeof ref === "function") {
|
|
ref(current);
|
|
} else if (ref) {
|
|
ref.current = current;
|
|
}
|
|
}
|
|
var DateComponent = function(_super) {
|
|
__extends(DateComponent2, _super);
|
|
function DateComponent2() {
|
|
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
_this.uid = guid();
|
|
return _this;
|
|
}
|
|
DateComponent2.prototype.prepareHits = function() {
|
|
};
|
|
DateComponent2.prototype.queryHit = function(positionLeft, positionTop, elWidth, elHeight) {
|
|
return null;
|
|
};
|
|
DateComponent2.prototype.isValidSegDownEl = function(el) {
|
|
return !this.props.eventDrag && !this.props.eventResize && !elementClosest(el, ".fc-event-mirror");
|
|
};
|
|
DateComponent2.prototype.isValidDateDownEl = function(el) {
|
|
return !elementClosest(el, ".fc-event:not(.fc-bg-event)") && !elementClosest(el, ".fc-more-link") && !elementClosest(el, "a[data-navlink]") && !elementClosest(el, ".fc-popover");
|
|
};
|
|
return DateComponent2;
|
|
}(BaseComponent);
|
|
function createPlugin(input) {
|
|
return {
|
|
id: guid(),
|
|
deps: input.deps || [],
|
|
reducers: input.reducers || [],
|
|
isLoadingFuncs: input.isLoadingFuncs || [],
|
|
contextInit: [].concat(input.contextInit || []),
|
|
eventRefiners: input.eventRefiners || {},
|
|
eventDefMemberAdders: input.eventDefMemberAdders || [],
|
|
eventSourceRefiners: input.eventSourceRefiners || {},
|
|
isDraggableTransformers: input.isDraggableTransformers || [],
|
|
eventDragMutationMassagers: input.eventDragMutationMassagers || [],
|
|
eventDefMutationAppliers: input.eventDefMutationAppliers || [],
|
|
dateSelectionTransformers: input.dateSelectionTransformers || [],
|
|
datePointTransforms: input.datePointTransforms || [],
|
|
dateSpanTransforms: input.dateSpanTransforms || [],
|
|
views: input.views || {},
|
|
viewPropsTransformers: input.viewPropsTransformers || [],
|
|
isPropsValid: input.isPropsValid || null,
|
|
externalDefTransforms: input.externalDefTransforms || [],
|
|
viewContainerAppends: input.viewContainerAppends || [],
|
|
eventDropTransformers: input.eventDropTransformers || [],
|
|
componentInteractions: input.componentInteractions || [],
|
|
calendarInteractions: input.calendarInteractions || [],
|
|
themeClasses: input.themeClasses || {},
|
|
eventSourceDefs: input.eventSourceDefs || [],
|
|
cmdFormatter: input.cmdFormatter,
|
|
recurringTypes: input.recurringTypes || [],
|
|
namedTimeZonedImpl: input.namedTimeZonedImpl,
|
|
initialView: input.initialView || "",
|
|
elementDraggingImpl: input.elementDraggingImpl,
|
|
optionChangeHandlers: input.optionChangeHandlers || {},
|
|
scrollGridImpl: input.scrollGridImpl || null,
|
|
contentTypeHandlers: input.contentTypeHandlers || {},
|
|
listenerRefiners: input.listenerRefiners || {},
|
|
optionRefiners: input.optionRefiners || {},
|
|
propSetHandlers: input.propSetHandlers || {}
|
|
};
|
|
}
|
|
function buildPluginHooks(pluginDefs, globalDefs) {
|
|
var isAdded = {};
|
|
var hooks = {
|
|
reducers: [],
|
|
isLoadingFuncs: [],
|
|
contextInit: [],
|
|
eventRefiners: {},
|
|
eventDefMemberAdders: [],
|
|
eventSourceRefiners: {},
|
|
isDraggableTransformers: [],
|
|
eventDragMutationMassagers: [],
|
|
eventDefMutationAppliers: [],
|
|
dateSelectionTransformers: [],
|
|
datePointTransforms: [],
|
|
dateSpanTransforms: [],
|
|
views: {},
|
|
viewPropsTransformers: [],
|
|
isPropsValid: null,
|
|
externalDefTransforms: [],
|
|
viewContainerAppends: [],
|
|
eventDropTransformers: [],
|
|
componentInteractions: [],
|
|
calendarInteractions: [],
|
|
themeClasses: {},
|
|
eventSourceDefs: [],
|
|
cmdFormatter: null,
|
|
recurringTypes: [],
|
|
namedTimeZonedImpl: null,
|
|
initialView: "",
|
|
elementDraggingImpl: null,
|
|
optionChangeHandlers: {},
|
|
scrollGridImpl: null,
|
|
contentTypeHandlers: {},
|
|
listenerRefiners: {},
|
|
optionRefiners: {},
|
|
propSetHandlers: {}
|
|
};
|
|
function addDefs(defs) {
|
|
for (var _i = 0, defs_1 = defs; _i < defs_1.length; _i++) {
|
|
var def = defs_1[_i];
|
|
if (!isAdded[def.id]) {
|
|
isAdded[def.id] = true;
|
|
addDefs(def.deps);
|
|
hooks = combineHooks(hooks, def);
|
|
}
|
|
}
|
|
}
|
|
if (pluginDefs) {
|
|
addDefs(pluginDefs);
|
|
}
|
|
addDefs(globalDefs);
|
|
return hooks;
|
|
}
|
|
function buildBuildPluginHooks() {
|
|
var currentOverrideDefs = [];
|
|
var currentGlobalDefs = [];
|
|
var currentHooks;
|
|
return function(overrideDefs, globalDefs) {
|
|
if (!currentHooks || !isArraysEqual(overrideDefs, currentOverrideDefs) || !isArraysEqual(globalDefs, currentGlobalDefs)) {
|
|
currentHooks = buildPluginHooks(overrideDefs, globalDefs);
|
|
}
|
|
currentOverrideDefs = overrideDefs;
|
|
currentGlobalDefs = globalDefs;
|
|
return currentHooks;
|
|
};
|
|
}
|
|
function combineHooks(hooks0, hooks1) {
|
|
return {
|
|
reducers: hooks0.reducers.concat(hooks1.reducers),
|
|
isLoadingFuncs: hooks0.isLoadingFuncs.concat(hooks1.isLoadingFuncs),
|
|
contextInit: hooks0.contextInit.concat(hooks1.contextInit),
|
|
eventRefiners: __assign(__assign({}, hooks0.eventRefiners), hooks1.eventRefiners),
|
|
eventDefMemberAdders: hooks0.eventDefMemberAdders.concat(hooks1.eventDefMemberAdders),
|
|
eventSourceRefiners: __assign(__assign({}, hooks0.eventSourceRefiners), hooks1.eventSourceRefiners),
|
|
isDraggableTransformers: hooks0.isDraggableTransformers.concat(hooks1.isDraggableTransformers),
|
|
eventDragMutationMassagers: hooks0.eventDragMutationMassagers.concat(hooks1.eventDragMutationMassagers),
|
|
eventDefMutationAppliers: hooks0.eventDefMutationAppliers.concat(hooks1.eventDefMutationAppliers),
|
|
dateSelectionTransformers: hooks0.dateSelectionTransformers.concat(hooks1.dateSelectionTransformers),
|
|
datePointTransforms: hooks0.datePointTransforms.concat(hooks1.datePointTransforms),
|
|
dateSpanTransforms: hooks0.dateSpanTransforms.concat(hooks1.dateSpanTransforms),
|
|
views: __assign(__assign({}, hooks0.views), hooks1.views),
|
|
viewPropsTransformers: hooks0.viewPropsTransformers.concat(hooks1.viewPropsTransformers),
|
|
isPropsValid: hooks1.isPropsValid || hooks0.isPropsValid,
|
|
externalDefTransforms: hooks0.externalDefTransforms.concat(hooks1.externalDefTransforms),
|
|
viewContainerAppends: hooks0.viewContainerAppends.concat(hooks1.viewContainerAppends),
|
|
eventDropTransformers: hooks0.eventDropTransformers.concat(hooks1.eventDropTransformers),
|
|
calendarInteractions: hooks0.calendarInteractions.concat(hooks1.calendarInteractions),
|
|
componentInteractions: hooks0.componentInteractions.concat(hooks1.componentInteractions),
|
|
themeClasses: __assign(__assign({}, hooks0.themeClasses), hooks1.themeClasses),
|
|
eventSourceDefs: hooks0.eventSourceDefs.concat(hooks1.eventSourceDefs),
|
|
cmdFormatter: hooks1.cmdFormatter || hooks0.cmdFormatter,
|
|
recurringTypes: hooks0.recurringTypes.concat(hooks1.recurringTypes),
|
|
namedTimeZonedImpl: hooks1.namedTimeZonedImpl || hooks0.namedTimeZonedImpl,
|
|
initialView: hooks0.initialView || hooks1.initialView,
|
|
elementDraggingImpl: hooks0.elementDraggingImpl || hooks1.elementDraggingImpl,
|
|
optionChangeHandlers: __assign(__assign({}, hooks0.optionChangeHandlers), hooks1.optionChangeHandlers),
|
|
scrollGridImpl: hooks1.scrollGridImpl || hooks0.scrollGridImpl,
|
|
contentTypeHandlers: __assign(__assign({}, hooks0.contentTypeHandlers), hooks1.contentTypeHandlers),
|
|
listenerRefiners: __assign(__assign({}, hooks0.listenerRefiners), hooks1.listenerRefiners),
|
|
optionRefiners: __assign(__assign({}, hooks0.optionRefiners), hooks1.optionRefiners),
|
|
propSetHandlers: __assign(__assign({}, hooks0.propSetHandlers), hooks1.propSetHandlers)
|
|
};
|
|
}
|
|
var StandardTheme = function(_super) {
|
|
__extends(StandardTheme2, _super);
|
|
function StandardTheme2() {
|
|
return _super !== null && _super.apply(this, arguments) || this;
|
|
}
|
|
return StandardTheme2;
|
|
}(Theme);
|
|
StandardTheme.prototype.classes = {
|
|
root: "fc-theme-standard",
|
|
tableCellShaded: "fc-cell-shaded",
|
|
buttonGroup: "fc-button-group",
|
|
button: "fc-button fc-button-primary",
|
|
buttonActive: "fc-button-active"
|
|
};
|
|
StandardTheme.prototype.baseIconClass = "fc-icon";
|
|
StandardTheme.prototype.iconClasses = {
|
|
close: "fc-icon-x",
|
|
prev: "fc-icon-chevron-left",
|
|
next: "fc-icon-chevron-right",
|
|
prevYear: "fc-icon-chevrons-left",
|
|
nextYear: "fc-icon-chevrons-right"
|
|
};
|
|
StandardTheme.prototype.rtlIconClasses = {
|
|
prev: "fc-icon-chevron-right",
|
|
next: "fc-icon-chevron-left",
|
|
prevYear: "fc-icon-chevrons-right",
|
|
nextYear: "fc-icon-chevrons-left"
|
|
};
|
|
StandardTheme.prototype.iconOverrideOption = "buttonIcons";
|
|
StandardTheme.prototype.iconOverrideCustomButtonOption = "icon";
|
|
StandardTheme.prototype.iconOverridePrefix = "fc-icon-";
|
|
function compileViewDefs(defaultConfigs, overrideConfigs) {
|
|
var hash = {};
|
|
var viewType;
|
|
for (viewType in defaultConfigs) {
|
|
ensureViewDef(viewType, hash, defaultConfigs, overrideConfigs);
|
|
}
|
|
for (viewType in overrideConfigs) {
|
|
ensureViewDef(viewType, hash, defaultConfigs, overrideConfigs);
|
|
}
|
|
return hash;
|
|
}
|
|
function ensureViewDef(viewType, hash, defaultConfigs, overrideConfigs) {
|
|
if (hash[viewType]) {
|
|
return hash[viewType];
|
|
}
|
|
var viewDef = buildViewDef(viewType, hash, defaultConfigs, overrideConfigs);
|
|
if (viewDef) {
|
|
hash[viewType] = viewDef;
|
|
}
|
|
return viewDef;
|
|
}
|
|
function buildViewDef(viewType, hash, defaultConfigs, overrideConfigs) {
|
|
var defaultConfig = defaultConfigs[viewType];
|
|
var overrideConfig = overrideConfigs[viewType];
|
|
var queryProp = function(name) {
|
|
return defaultConfig && defaultConfig[name] !== null ? defaultConfig[name] : overrideConfig && overrideConfig[name] !== null ? overrideConfig[name] : null;
|
|
};
|
|
var theComponent = queryProp("component");
|
|
var superType = queryProp("superType");
|
|
var superDef = null;
|
|
if (superType) {
|
|
if (superType === viewType) {
|
|
throw new Error("Can't have a custom view type that references itself");
|
|
}
|
|
superDef = ensureViewDef(superType, hash, defaultConfigs, overrideConfigs);
|
|
}
|
|
if (!theComponent && superDef) {
|
|
theComponent = superDef.component;
|
|
}
|
|
if (!theComponent) {
|
|
return null;
|
|
}
|
|
return {
|
|
type: viewType,
|
|
component: theComponent,
|
|
defaults: __assign(__assign({}, superDef ? superDef.defaults : {}), defaultConfig ? defaultConfig.rawOptions : {}),
|
|
overrides: __assign(__assign({}, superDef ? superDef.overrides : {}), overrideConfig ? overrideConfig.rawOptions : {})
|
|
};
|
|
}
|
|
var RenderHook = function(_super) {
|
|
__extends(RenderHook2, _super);
|
|
function RenderHook2() {
|
|
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
_this.rootElRef = createRef();
|
|
_this.handleRootEl = function(el) {
|
|
setRef(_this.rootElRef, el);
|
|
if (_this.props.elRef) {
|
|
setRef(_this.props.elRef, el);
|
|
}
|
|
};
|
|
return _this;
|
|
}
|
|
RenderHook2.prototype.render = function() {
|
|
var _this = this;
|
|
var props = this.props;
|
|
var hookProps = props.hookProps;
|
|
return createElement(MountHook, { hookProps, didMount: props.didMount, willUnmount: props.willUnmount, elRef: this.handleRootEl }, function(rootElRef) {
|
|
return createElement(ContentHook, { hookProps, content: props.content, defaultContent: props.defaultContent, backupElRef: _this.rootElRef }, function(innerElRef, innerContent) {
|
|
return props.children(rootElRef, normalizeClassNames(props.classNames, hookProps), innerElRef, innerContent);
|
|
});
|
|
});
|
|
};
|
|
return RenderHook2;
|
|
}(BaseComponent);
|
|
var CustomContentRenderContext = createContext2(0);
|
|
function ContentHook(props) {
|
|
return createElement(CustomContentRenderContext.Consumer, null, function(renderId) {
|
|
return createElement(ContentHookInner, __assign({ renderId }, props));
|
|
});
|
|
}
|
|
var ContentHookInner = function(_super) {
|
|
__extends(ContentHookInner2, _super);
|
|
function ContentHookInner2() {
|
|
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
_this.innerElRef = createRef();
|
|
return _this;
|
|
}
|
|
ContentHookInner2.prototype.render = function() {
|
|
return this.props.children(this.innerElRef, this.renderInnerContent());
|
|
};
|
|
ContentHookInner2.prototype.componentDidMount = function() {
|
|
this.updateCustomContent();
|
|
};
|
|
ContentHookInner2.prototype.componentDidUpdate = function() {
|
|
this.updateCustomContent();
|
|
};
|
|
ContentHookInner2.prototype.componentWillUnmount = function() {
|
|
if (this.customContentInfo && this.customContentInfo.destroy) {
|
|
this.customContentInfo.destroy();
|
|
}
|
|
};
|
|
ContentHookInner2.prototype.renderInnerContent = function() {
|
|
var customContentInfo = this.customContentInfo;
|
|
var innerContent = this.getInnerContent();
|
|
var meta = this.getContentMeta(innerContent);
|
|
if (!customContentInfo || customContentInfo.contentKey !== meta.contentKey) {
|
|
if (customContentInfo) {
|
|
if (customContentInfo.destroy) {
|
|
customContentInfo.destroy();
|
|
}
|
|
customContentInfo = this.customContentInfo = null;
|
|
}
|
|
if (meta.contentKey) {
|
|
customContentInfo = this.customContentInfo = __assign({ contentKey: meta.contentKey, contentVal: innerContent[meta.contentKey] }, meta.buildLifecycleFuncs());
|
|
}
|
|
} else if (customContentInfo) {
|
|
customContentInfo.contentVal = innerContent[meta.contentKey];
|
|
}
|
|
return customContentInfo ? [] : innerContent;
|
|
};
|
|
ContentHookInner2.prototype.getInnerContent = function() {
|
|
var props = this.props;
|
|
var innerContent = normalizeContent(props.content, props.hookProps);
|
|
if (innerContent === void 0) {
|
|
innerContent = normalizeContent(props.defaultContent, props.hookProps);
|
|
}
|
|
return innerContent == null ? null : innerContent;
|
|
};
|
|
ContentHookInner2.prototype.getContentMeta = function(innerContent) {
|
|
var contentTypeHandlers = this.context.pluginHooks.contentTypeHandlers;
|
|
var contentKey = "";
|
|
var buildLifecycleFuncs = null;
|
|
if (innerContent) {
|
|
for (var searchKey in contentTypeHandlers) {
|
|
if (innerContent[searchKey] !== void 0) {
|
|
contentKey = searchKey;
|
|
buildLifecycleFuncs = contentTypeHandlers[searchKey];
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
return { contentKey, buildLifecycleFuncs };
|
|
};
|
|
ContentHookInner2.prototype.updateCustomContent = function() {
|
|
if (this.customContentInfo) {
|
|
this.customContentInfo.render(this.innerElRef.current || this.props.backupElRef.current, this.customContentInfo.contentVal);
|
|
}
|
|
};
|
|
return ContentHookInner2;
|
|
}(BaseComponent);
|
|
var MountHook = function(_super) {
|
|
__extends(MountHook2, _super);
|
|
function MountHook2() {
|
|
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
_this.handleRootEl = function(rootEl) {
|
|
_this.rootEl = rootEl;
|
|
if (_this.props.elRef) {
|
|
setRef(_this.props.elRef, rootEl);
|
|
}
|
|
};
|
|
return _this;
|
|
}
|
|
MountHook2.prototype.render = function() {
|
|
return this.props.children(this.handleRootEl);
|
|
};
|
|
MountHook2.prototype.componentDidMount = function() {
|
|
var callback = this.props.didMount;
|
|
if (callback) {
|
|
callback(__assign(__assign({}, this.props.hookProps), { el: this.rootEl }));
|
|
}
|
|
};
|
|
MountHook2.prototype.componentWillUnmount = function() {
|
|
var callback = this.props.willUnmount;
|
|
if (callback) {
|
|
callback(__assign(__assign({}, this.props.hookProps), { el: this.rootEl }));
|
|
}
|
|
};
|
|
return MountHook2;
|
|
}(BaseComponent);
|
|
function buildClassNameNormalizer() {
|
|
var currentGenerator;
|
|
var currentHookProps;
|
|
var currentClassNames = [];
|
|
return function(generator, hookProps) {
|
|
if (!currentHookProps || !isPropsEqual(currentHookProps, hookProps) || generator !== currentGenerator) {
|
|
currentGenerator = generator;
|
|
currentHookProps = hookProps;
|
|
currentClassNames = normalizeClassNames(generator, hookProps);
|
|
}
|
|
return currentClassNames;
|
|
};
|
|
}
|
|
function normalizeClassNames(classNames, hookProps) {
|
|
if (typeof classNames === "function") {
|
|
classNames = classNames(hookProps);
|
|
}
|
|
return parseClassNames(classNames);
|
|
}
|
|
function normalizeContent(input, hookProps) {
|
|
if (typeof input === "function") {
|
|
return input(hookProps, createElement);
|
|
}
|
|
return input;
|
|
}
|
|
var ViewRoot = function(_super) {
|
|
__extends(ViewRoot2, _super);
|
|
function ViewRoot2() {
|
|
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
_this.normalizeClassNames = buildClassNameNormalizer();
|
|
return _this;
|
|
}
|
|
ViewRoot2.prototype.render = function() {
|
|
var _a = this, props = _a.props, context = _a.context;
|
|
var options = context.options;
|
|
var hookProps = { view: context.viewApi };
|
|
var customClassNames = this.normalizeClassNames(options.viewClassNames, hookProps);
|
|
return createElement(MountHook, { hookProps, didMount: options.viewDidMount, willUnmount: options.viewWillUnmount, elRef: props.elRef }, function(rootElRef) {
|
|
return props.children(rootElRef, ["fc-" + props.viewSpec.type + "-view", "fc-view"].concat(customClassNames));
|
|
});
|
|
};
|
|
return ViewRoot2;
|
|
}(BaseComponent);
|
|
function parseViewConfigs(inputs) {
|
|
return mapHash(inputs, parseViewConfig);
|
|
}
|
|
function parseViewConfig(input) {
|
|
var rawOptions = typeof input === "function" ? { component: input } : input;
|
|
var component = rawOptions.component;
|
|
if (rawOptions.content) {
|
|
component = createViewHookComponent(rawOptions);
|
|
}
|
|
return {
|
|
superType: rawOptions.type,
|
|
component,
|
|
rawOptions
|
|
};
|
|
}
|
|
function createViewHookComponent(options) {
|
|
return function(viewProps) {
|
|
return createElement(ViewContextType.Consumer, null, function(context) {
|
|
return createElement(ViewRoot, { viewSpec: context.viewSpec }, function(viewElRef, viewClassNames) {
|
|
var hookProps = __assign(__assign({}, viewProps), { nextDayThreshold: context.options.nextDayThreshold });
|
|
return createElement(RenderHook, { hookProps, classNames: options.classNames, content: options.content, didMount: options.didMount, willUnmount: options.willUnmount, elRef: viewElRef }, function(rootElRef, customClassNames, innerElRef, innerContent) {
|
|
return createElement("div", { className: viewClassNames.concat(customClassNames).join(" "), ref: rootElRef }, innerContent);
|
|
});
|
|
});
|
|
});
|
|
};
|
|
}
|
|
function buildViewSpecs(defaultInputs, optionOverrides, dynamicOptionOverrides, localeDefaults) {
|
|
var defaultConfigs = parseViewConfigs(defaultInputs);
|
|
var overrideConfigs = parseViewConfigs(optionOverrides.views);
|
|
var viewDefs = compileViewDefs(defaultConfigs, overrideConfigs);
|
|
return mapHash(viewDefs, function(viewDef) {
|
|
return buildViewSpec(viewDef, overrideConfigs, optionOverrides, dynamicOptionOverrides, localeDefaults);
|
|
});
|
|
}
|
|
function buildViewSpec(viewDef, overrideConfigs, optionOverrides, dynamicOptionOverrides, localeDefaults) {
|
|
var durationInput = viewDef.overrides.duration || viewDef.defaults.duration || dynamicOptionOverrides.duration || optionOverrides.duration;
|
|
var duration = null;
|
|
var durationUnit = "";
|
|
var singleUnit = "";
|
|
var singleUnitOverrides = {};
|
|
if (durationInput) {
|
|
duration = createDurationCached(durationInput);
|
|
if (duration) {
|
|
var denom = greatestDurationDenominator(duration);
|
|
durationUnit = denom.unit;
|
|
if (denom.value === 1) {
|
|
singleUnit = durationUnit;
|
|
singleUnitOverrides = overrideConfigs[durationUnit] ? overrideConfigs[durationUnit].rawOptions : {};
|
|
}
|
|
}
|
|
}
|
|
var queryButtonText = function(optionsSubset) {
|
|
var buttonTextMap = optionsSubset.buttonText || {};
|
|
var buttonTextKey = viewDef.defaults.buttonTextKey;
|
|
if (buttonTextKey != null && buttonTextMap[buttonTextKey] != null) {
|
|
return buttonTextMap[buttonTextKey];
|
|
}
|
|
if (buttonTextMap[viewDef.type] != null) {
|
|
return buttonTextMap[viewDef.type];
|
|
}
|
|
if (buttonTextMap[singleUnit] != null) {
|
|
return buttonTextMap[singleUnit];
|
|
}
|
|
return null;
|
|
};
|
|
var queryButtonTitle = function(optionsSubset) {
|
|
var buttonHints = optionsSubset.buttonHints || {};
|
|
var buttonKey = viewDef.defaults.buttonTextKey;
|
|
if (buttonKey != null && buttonHints[buttonKey] != null) {
|
|
return buttonHints[buttonKey];
|
|
}
|
|
if (buttonHints[viewDef.type] != null) {
|
|
return buttonHints[viewDef.type];
|
|
}
|
|
if (buttonHints[singleUnit] != null) {
|
|
return buttonHints[singleUnit];
|
|
}
|
|
return null;
|
|
};
|
|
return {
|
|
type: viewDef.type,
|
|
component: viewDef.component,
|
|
duration,
|
|
durationUnit,
|
|
singleUnit,
|
|
optionDefaults: viewDef.defaults,
|
|
optionOverrides: __assign(__assign({}, singleUnitOverrides), viewDef.overrides),
|
|
buttonTextOverride: queryButtonText(dynamicOptionOverrides) || queryButtonText(optionOverrides) || viewDef.overrides.buttonText,
|
|
buttonTextDefault: queryButtonText(localeDefaults) || viewDef.defaults.buttonText || queryButtonText(BASE_OPTION_DEFAULTS) || viewDef.type,
|
|
buttonTitleOverride: queryButtonTitle(dynamicOptionOverrides) || queryButtonTitle(optionOverrides) || viewDef.overrides.buttonHint,
|
|
buttonTitleDefault: queryButtonTitle(localeDefaults) || viewDef.defaults.buttonHint || queryButtonTitle(BASE_OPTION_DEFAULTS)
|
|
};
|
|
}
|
|
var durationInputMap = {};
|
|
function createDurationCached(durationInput) {
|
|
var json = JSON.stringify(durationInput);
|
|
var res = durationInputMap[json];
|
|
if (res === void 0) {
|
|
res = createDuration(durationInput);
|
|
durationInputMap[json] = res;
|
|
}
|
|
return res;
|
|
}
|
|
var DateProfileGenerator = function() {
|
|
function DateProfileGenerator2(props) {
|
|
this.props = props;
|
|
this.nowDate = getNow(props.nowInput, props.dateEnv);
|
|
this.initHiddenDays();
|
|
}
|
|
DateProfileGenerator2.prototype.buildPrev = function(currentDateProfile, currentDate, forceToValid) {
|
|
var dateEnv = this.props.dateEnv;
|
|
var prevDate = dateEnv.subtract(dateEnv.startOf(currentDate, currentDateProfile.currentRangeUnit), currentDateProfile.dateIncrement);
|
|
return this.build(prevDate, -1, forceToValid);
|
|
};
|
|
DateProfileGenerator2.prototype.buildNext = function(currentDateProfile, currentDate, forceToValid) {
|
|
var dateEnv = this.props.dateEnv;
|
|
var nextDate = dateEnv.add(dateEnv.startOf(currentDate, currentDateProfile.currentRangeUnit), currentDateProfile.dateIncrement);
|
|
return this.build(nextDate, 1, forceToValid);
|
|
};
|
|
DateProfileGenerator2.prototype.build = function(currentDate, direction, forceToValid) {
|
|
if (forceToValid === void 0) {
|
|
forceToValid = true;
|
|
}
|
|
var props = this.props;
|
|
var validRange;
|
|
var currentInfo;
|
|
var isRangeAllDay;
|
|
var renderRange;
|
|
var activeRange;
|
|
var isValid;
|
|
validRange = this.buildValidRange();
|
|
validRange = this.trimHiddenDays(validRange);
|
|
if (forceToValid) {
|
|
currentDate = constrainMarkerToRange(currentDate, validRange);
|
|
}
|
|
currentInfo = this.buildCurrentRangeInfo(currentDate, direction);
|
|
isRangeAllDay = /^(year|month|week|day)$/.test(currentInfo.unit);
|
|
renderRange = this.buildRenderRange(this.trimHiddenDays(currentInfo.range), currentInfo.unit, isRangeAllDay);
|
|
renderRange = this.trimHiddenDays(renderRange);
|
|
activeRange = renderRange;
|
|
if (!props.showNonCurrentDates) {
|
|
activeRange = intersectRanges(activeRange, currentInfo.range);
|
|
}
|
|
activeRange = this.adjustActiveRange(activeRange);
|
|
activeRange = intersectRanges(activeRange, validRange);
|
|
isValid = rangesIntersect(currentInfo.range, validRange);
|
|
return {
|
|
validRange,
|
|
currentRange: currentInfo.range,
|
|
currentRangeUnit: currentInfo.unit,
|
|
isRangeAllDay,
|
|
activeRange,
|
|
renderRange,
|
|
slotMinTime: props.slotMinTime,
|
|
slotMaxTime: props.slotMaxTime,
|
|
isValid,
|
|
dateIncrement: this.buildDateIncrement(currentInfo.duration)
|
|
};
|
|
};
|
|
DateProfileGenerator2.prototype.buildValidRange = function() {
|
|
var input = this.props.validRangeInput;
|
|
var simpleInput = typeof input === "function" ? input.call(this.props.calendarApi, this.nowDate) : input;
|
|
return this.refineRange(simpleInput) || { start: null, end: null };
|
|
};
|
|
DateProfileGenerator2.prototype.buildCurrentRangeInfo = function(date, direction) {
|
|
var props = this.props;
|
|
var duration = null;
|
|
var unit = null;
|
|
var range = null;
|
|
var dayCount;
|
|
if (props.duration) {
|
|
duration = props.duration;
|
|
unit = props.durationUnit;
|
|
range = this.buildRangeFromDuration(date, direction, duration, unit);
|
|
} else if (dayCount = this.props.dayCount) {
|
|
unit = "day";
|
|
range = this.buildRangeFromDayCount(date, direction, dayCount);
|
|
} else if (range = this.buildCustomVisibleRange(date)) {
|
|
unit = props.dateEnv.greatestWholeUnit(range.start, range.end).unit;
|
|
} else {
|
|
duration = this.getFallbackDuration();
|
|
unit = greatestDurationDenominator(duration).unit;
|
|
range = this.buildRangeFromDuration(date, direction, duration, unit);
|
|
}
|
|
return { duration, unit, range };
|
|
};
|
|
DateProfileGenerator2.prototype.getFallbackDuration = function() {
|
|
return createDuration({ day: 1 });
|
|
};
|
|
DateProfileGenerator2.prototype.adjustActiveRange = function(range) {
|
|
var _a = this.props, dateEnv = _a.dateEnv, usesMinMaxTime = _a.usesMinMaxTime, slotMinTime = _a.slotMinTime, slotMaxTime = _a.slotMaxTime;
|
|
var start = range.start, end = range.end;
|
|
if (usesMinMaxTime) {
|
|
if (asRoughDays(slotMinTime) < 0) {
|
|
start = startOfDay(start);
|
|
start = dateEnv.add(start, slotMinTime);
|
|
}
|
|
if (asRoughDays(slotMaxTime) > 1) {
|
|
end = startOfDay(end);
|
|
end = addDays(end, -1);
|
|
end = dateEnv.add(end, slotMaxTime);
|
|
}
|
|
}
|
|
return { start, end };
|
|
};
|
|
DateProfileGenerator2.prototype.buildRangeFromDuration = function(date, direction, duration, unit) {
|
|
var _a = this.props, dateEnv = _a.dateEnv, dateAlignment = _a.dateAlignment;
|
|
var start;
|
|
var end;
|
|
var res;
|
|
if (!dateAlignment) {
|
|
var dateIncrement = this.props.dateIncrement;
|
|
if (dateIncrement) {
|
|
if (asRoughMs(dateIncrement) < asRoughMs(duration)) {
|
|
dateAlignment = greatestDurationDenominator(dateIncrement).unit;
|
|
} else {
|
|
dateAlignment = unit;
|
|
}
|
|
} else {
|
|
dateAlignment = unit;
|
|
}
|
|
}
|
|
if (asRoughDays(duration) <= 1) {
|
|
if (this.isHiddenDay(start)) {
|
|
start = this.skipHiddenDays(start, direction);
|
|
start = startOfDay(start);
|
|
}
|
|
}
|
|
function computeRes() {
|
|
start = dateEnv.startOf(date, dateAlignment);
|
|
end = dateEnv.add(start, duration);
|
|
res = { start, end };
|
|
}
|
|
computeRes();
|
|
if (!this.trimHiddenDays(res)) {
|
|
date = this.skipHiddenDays(date, direction);
|
|
computeRes();
|
|
}
|
|
return res;
|
|
};
|
|
DateProfileGenerator2.prototype.buildRangeFromDayCount = function(date, direction, dayCount) {
|
|
var _a = this.props, dateEnv = _a.dateEnv, dateAlignment = _a.dateAlignment;
|
|
var runningCount = 0;
|
|
var start = date;
|
|
var end;
|
|
if (dateAlignment) {
|
|
start = dateEnv.startOf(start, dateAlignment);
|
|
}
|
|
start = startOfDay(start);
|
|
start = this.skipHiddenDays(start, direction);
|
|
end = start;
|
|
do {
|
|
end = addDays(end, 1);
|
|
if (!this.isHiddenDay(end)) {
|
|
runningCount += 1;
|
|
}
|
|
} while (runningCount < dayCount);
|
|
return { start, end };
|
|
};
|
|
DateProfileGenerator2.prototype.buildCustomVisibleRange = function(date) {
|
|
var props = this.props;
|
|
var input = props.visibleRangeInput;
|
|
var simpleInput = typeof input === "function" ? input.call(props.calendarApi, props.dateEnv.toDate(date)) : input;
|
|
var range = this.refineRange(simpleInput);
|
|
if (range && (range.start == null || range.end == null)) {
|
|
return null;
|
|
}
|
|
return range;
|
|
};
|
|
DateProfileGenerator2.prototype.buildRenderRange = function(currentRange, currentRangeUnit, isRangeAllDay) {
|
|
return currentRange;
|
|
};
|
|
DateProfileGenerator2.prototype.buildDateIncrement = function(fallback) {
|
|
var dateIncrement = this.props.dateIncrement;
|
|
var customAlignment;
|
|
if (dateIncrement) {
|
|
return dateIncrement;
|
|
}
|
|
if (customAlignment = this.props.dateAlignment) {
|
|
return createDuration(1, customAlignment);
|
|
}
|
|
if (fallback) {
|
|
return fallback;
|
|
}
|
|
return createDuration({ days: 1 });
|
|
};
|
|
DateProfileGenerator2.prototype.refineRange = function(rangeInput) {
|
|
if (rangeInput) {
|
|
var range = parseRange(rangeInput, this.props.dateEnv);
|
|
if (range) {
|
|
range = computeVisibleDayRange(range);
|
|
}
|
|
return range;
|
|
}
|
|
return null;
|
|
};
|
|
DateProfileGenerator2.prototype.initHiddenDays = function() {
|
|
var hiddenDays = this.props.hiddenDays || [];
|
|
var isHiddenDayHash = [];
|
|
var dayCnt = 0;
|
|
var i3;
|
|
if (this.props.weekends === false) {
|
|
hiddenDays.push(0, 6);
|
|
}
|
|
for (i3 = 0; i3 < 7; i3 += 1) {
|
|
if (!(isHiddenDayHash[i3] = hiddenDays.indexOf(i3) !== -1)) {
|
|
dayCnt += 1;
|
|
}
|
|
}
|
|
if (!dayCnt) {
|
|
throw new Error("invalid hiddenDays");
|
|
}
|
|
this.isHiddenDayHash = isHiddenDayHash;
|
|
};
|
|
DateProfileGenerator2.prototype.trimHiddenDays = function(range) {
|
|
var start = range.start, end = range.end;
|
|
if (start) {
|
|
start = this.skipHiddenDays(start);
|
|
}
|
|
if (end) {
|
|
end = this.skipHiddenDays(end, -1, true);
|
|
}
|
|
if (start == null || end == null || start < end) {
|
|
return { start, end };
|
|
}
|
|
return null;
|
|
};
|
|
DateProfileGenerator2.prototype.isHiddenDay = function(day) {
|
|
if (day instanceof Date) {
|
|
day = day.getUTCDay();
|
|
}
|
|
return this.isHiddenDayHash[day];
|
|
};
|
|
DateProfileGenerator2.prototype.skipHiddenDays = function(date, inc, isExclusive) {
|
|
if (inc === void 0) {
|
|
inc = 1;
|
|
}
|
|
if (isExclusive === void 0) {
|
|
isExclusive = false;
|
|
}
|
|
while (this.isHiddenDayHash[(date.getUTCDay() + (isExclusive ? inc : 0) + 7) % 7]) {
|
|
date = addDays(date, inc);
|
|
}
|
|
return date;
|
|
};
|
|
return DateProfileGenerator2;
|
|
}();
|
|
function reduceViewType(viewType, action) {
|
|
switch (action.type) {
|
|
case "CHANGE_VIEW_TYPE":
|
|
viewType = action.viewType;
|
|
}
|
|
return viewType;
|
|
}
|
|
function reduceDynamicOptionOverrides(dynamicOptionOverrides, action) {
|
|
var _a;
|
|
switch (action.type) {
|
|
case "SET_OPTION":
|
|
return __assign(__assign({}, dynamicOptionOverrides), (_a = {}, _a[action.optionName] = action.rawOptionValue, _a));
|
|
default:
|
|
return dynamicOptionOverrides;
|
|
}
|
|
}
|
|
function reduceDateProfile(currentDateProfile, action, currentDate, dateProfileGenerator) {
|
|
var dp;
|
|
switch (action.type) {
|
|
case "CHANGE_VIEW_TYPE":
|
|
return dateProfileGenerator.build(action.dateMarker || currentDate);
|
|
case "CHANGE_DATE":
|
|
return dateProfileGenerator.build(action.dateMarker);
|
|
case "PREV":
|
|
dp = dateProfileGenerator.buildPrev(currentDateProfile, currentDate);
|
|
if (dp.isValid) {
|
|
return dp;
|
|
}
|
|
break;
|
|
case "NEXT":
|
|
dp = dateProfileGenerator.buildNext(currentDateProfile, currentDate);
|
|
if (dp.isValid) {
|
|
return dp;
|
|
}
|
|
break;
|
|
}
|
|
return currentDateProfile;
|
|
}
|
|
function initEventSources(calendarOptions, dateProfile, context) {
|
|
var activeRange = dateProfile ? dateProfile.activeRange : null;
|
|
return addSources({}, parseInitialSources(calendarOptions, context), activeRange, context);
|
|
}
|
|
function reduceEventSources(eventSources, action, dateProfile, context) {
|
|
var activeRange = dateProfile ? dateProfile.activeRange : null;
|
|
switch (action.type) {
|
|
case "ADD_EVENT_SOURCES":
|
|
return addSources(eventSources, action.sources, activeRange, context);
|
|
case "REMOVE_EVENT_SOURCE":
|
|
return removeSource(eventSources, action.sourceId);
|
|
case "PREV":
|
|
case "NEXT":
|
|
case "CHANGE_DATE":
|
|
case "CHANGE_VIEW_TYPE":
|
|
if (dateProfile) {
|
|
return fetchDirtySources(eventSources, activeRange, context);
|
|
}
|
|
return eventSources;
|
|
case "FETCH_EVENT_SOURCES":
|
|
return fetchSourcesByIds(eventSources, action.sourceIds ? arrayToHash(action.sourceIds) : excludeStaticSources(eventSources, context), activeRange, action.isRefetch || false, context);
|
|
case "RECEIVE_EVENTS":
|
|
case "RECEIVE_EVENT_ERROR":
|
|
return receiveResponse(eventSources, action.sourceId, action.fetchId, action.fetchRange);
|
|
case "REMOVE_ALL_EVENT_SOURCES":
|
|
return {};
|
|
default:
|
|
return eventSources;
|
|
}
|
|
}
|
|
function reduceEventSourcesNewTimeZone(eventSources, dateProfile, context) {
|
|
var activeRange = dateProfile ? dateProfile.activeRange : null;
|
|
return fetchSourcesByIds(eventSources, excludeStaticSources(eventSources, context), activeRange, true, context);
|
|
}
|
|
function computeEventSourcesLoading(eventSources) {
|
|
for (var sourceId in eventSources) {
|
|
if (eventSources[sourceId].isFetching) {
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
function addSources(eventSourceHash, sources, fetchRange, context) {
|
|
var hash = {};
|
|
for (var _i = 0, sources_1 = sources; _i < sources_1.length; _i++) {
|
|
var source = sources_1[_i];
|
|
hash[source.sourceId] = source;
|
|
}
|
|
if (fetchRange) {
|
|
hash = fetchDirtySources(hash, fetchRange, context);
|
|
}
|
|
return __assign(__assign({}, eventSourceHash), hash);
|
|
}
|
|
function removeSource(eventSourceHash, sourceId) {
|
|
return filterHash(eventSourceHash, function(eventSource) {
|
|
return eventSource.sourceId !== sourceId;
|
|
});
|
|
}
|
|
function fetchDirtySources(sourceHash, fetchRange, context) {
|
|
return fetchSourcesByIds(sourceHash, filterHash(sourceHash, function(eventSource) {
|
|
return isSourceDirty(eventSource, fetchRange, context);
|
|
}), fetchRange, false, context);
|
|
}
|
|
function isSourceDirty(eventSource, fetchRange, context) {
|
|
if (!doesSourceNeedRange(eventSource, context)) {
|
|
return !eventSource.latestFetchId;
|
|
}
|
|
return !context.options.lazyFetching || !eventSource.fetchRange || eventSource.isFetching || fetchRange.start < eventSource.fetchRange.start || fetchRange.end > eventSource.fetchRange.end;
|
|
}
|
|
function fetchSourcesByIds(prevSources, sourceIdHash, fetchRange, isRefetch, context) {
|
|
var nextSources = {};
|
|
for (var sourceId in prevSources) {
|
|
var source = prevSources[sourceId];
|
|
if (sourceIdHash[sourceId]) {
|
|
nextSources[sourceId] = fetchSource(source, fetchRange, isRefetch, context);
|
|
} else {
|
|
nextSources[sourceId] = source;
|
|
}
|
|
}
|
|
return nextSources;
|
|
}
|
|
function fetchSource(eventSource, fetchRange, isRefetch, context) {
|
|
var options = context.options, calendarApi = context.calendarApi;
|
|
var sourceDef = context.pluginHooks.eventSourceDefs[eventSource.sourceDefId];
|
|
var fetchId = guid();
|
|
sourceDef.fetch({
|
|
eventSource,
|
|
range: fetchRange,
|
|
isRefetch,
|
|
context
|
|
}, function(res) {
|
|
var rawEvents = res.rawEvents;
|
|
if (options.eventSourceSuccess) {
|
|
rawEvents = options.eventSourceSuccess.call(calendarApi, rawEvents, res.xhr) || rawEvents;
|
|
}
|
|
if (eventSource.success) {
|
|
rawEvents = eventSource.success.call(calendarApi, rawEvents, res.xhr) || rawEvents;
|
|
}
|
|
context.dispatch({
|
|
type: "RECEIVE_EVENTS",
|
|
sourceId: eventSource.sourceId,
|
|
fetchId,
|
|
fetchRange,
|
|
rawEvents
|
|
});
|
|
}, function(error) {
|
|
console.warn(error.message, error);
|
|
if (options.eventSourceFailure) {
|
|
options.eventSourceFailure.call(calendarApi, error);
|
|
}
|
|
if (eventSource.failure) {
|
|
eventSource.failure(error);
|
|
}
|
|
context.dispatch({
|
|
type: "RECEIVE_EVENT_ERROR",
|
|
sourceId: eventSource.sourceId,
|
|
fetchId,
|
|
fetchRange,
|
|
error
|
|
});
|
|
});
|
|
return __assign(__assign({}, eventSource), { isFetching: true, latestFetchId: fetchId });
|
|
}
|
|
function receiveResponse(sourceHash, sourceId, fetchId, fetchRange) {
|
|
var _a;
|
|
var eventSource = sourceHash[sourceId];
|
|
if (eventSource && fetchId === eventSource.latestFetchId) {
|
|
return __assign(__assign({}, sourceHash), (_a = {}, _a[sourceId] = __assign(__assign({}, eventSource), { isFetching: false, fetchRange }), _a));
|
|
}
|
|
return sourceHash;
|
|
}
|
|
function excludeStaticSources(eventSources, context) {
|
|
return filterHash(eventSources, function(eventSource) {
|
|
return doesSourceNeedRange(eventSource, context);
|
|
});
|
|
}
|
|
function parseInitialSources(rawOptions, context) {
|
|
var refiners = buildEventSourceRefiners(context);
|
|
var rawSources = [].concat(rawOptions.eventSources || []);
|
|
var sources = [];
|
|
if (rawOptions.initialEvents) {
|
|
rawSources.unshift(rawOptions.initialEvents);
|
|
}
|
|
if (rawOptions.events) {
|
|
rawSources.unshift(rawOptions.events);
|
|
}
|
|
for (var _i = 0, rawSources_1 = rawSources; _i < rawSources_1.length; _i++) {
|
|
var rawSource = rawSources_1[_i];
|
|
var source = parseEventSource(rawSource, context, refiners);
|
|
if (source) {
|
|
sources.push(source);
|
|
}
|
|
}
|
|
return sources;
|
|
}
|
|
function doesSourceNeedRange(eventSource, context) {
|
|
var defs = context.pluginHooks.eventSourceDefs;
|
|
return !defs[eventSource.sourceDefId].ignoreRange;
|
|
}
|
|
function reduceEventStore(eventStore, action, eventSources, dateProfile, context) {
|
|
switch (action.type) {
|
|
case "RECEIVE_EVENTS":
|
|
return receiveRawEvents(eventStore, eventSources[action.sourceId], action.fetchId, action.fetchRange, action.rawEvents, context);
|
|
case "ADD_EVENTS":
|
|
return addEvent(eventStore, action.eventStore, dateProfile ? dateProfile.activeRange : null, context);
|
|
case "RESET_EVENTS":
|
|
return action.eventStore;
|
|
case "MERGE_EVENTS":
|
|
return mergeEventStores(eventStore, action.eventStore);
|
|
case "PREV":
|
|
case "NEXT":
|
|
case "CHANGE_DATE":
|
|
case "CHANGE_VIEW_TYPE":
|
|
if (dateProfile) {
|
|
return expandRecurring(eventStore, dateProfile.activeRange, context);
|
|
}
|
|
return eventStore;
|
|
case "REMOVE_EVENTS":
|
|
return excludeSubEventStore(eventStore, action.eventStore);
|
|
case "REMOVE_EVENT_SOURCE":
|
|
return excludeEventsBySourceId(eventStore, action.sourceId);
|
|
case "REMOVE_ALL_EVENT_SOURCES":
|
|
return filterEventStoreDefs(eventStore, function(eventDef) {
|
|
return !eventDef.sourceId;
|
|
});
|
|
case "REMOVE_ALL_EVENTS":
|
|
return createEmptyEventStore();
|
|
default:
|
|
return eventStore;
|
|
}
|
|
}
|
|
function receiveRawEvents(eventStore, eventSource, fetchId, fetchRange, rawEvents, context) {
|
|
if (eventSource && fetchId === eventSource.latestFetchId) {
|
|
var subset = parseEvents(transformRawEvents(rawEvents, eventSource, context), eventSource, context);
|
|
if (fetchRange) {
|
|
subset = expandRecurring(subset, fetchRange, context);
|
|
}
|
|
return mergeEventStores(excludeEventsBySourceId(eventStore, eventSource.sourceId), subset);
|
|
}
|
|
return eventStore;
|
|
}
|
|
function transformRawEvents(rawEvents, eventSource, context) {
|
|
var calEachTransform = context.options.eventDataTransform;
|
|
var sourceEachTransform = eventSource ? eventSource.eventDataTransform : null;
|
|
if (sourceEachTransform) {
|
|
rawEvents = transformEachRawEvent(rawEvents, sourceEachTransform);
|
|
}
|
|
if (calEachTransform) {
|
|
rawEvents = transformEachRawEvent(rawEvents, calEachTransform);
|
|
}
|
|
return rawEvents;
|
|
}
|
|
function transformEachRawEvent(rawEvents, func) {
|
|
var refinedEvents;
|
|
if (!func) {
|
|
refinedEvents = rawEvents;
|
|
} else {
|
|
refinedEvents = [];
|
|
for (var _i = 0, rawEvents_1 = rawEvents; _i < rawEvents_1.length; _i++) {
|
|
var rawEvent = rawEvents_1[_i];
|
|
var refinedEvent = func(rawEvent);
|
|
if (refinedEvent) {
|
|
refinedEvents.push(refinedEvent);
|
|
} else if (refinedEvent == null) {
|
|
refinedEvents.push(rawEvent);
|
|
}
|
|
}
|
|
}
|
|
return refinedEvents;
|
|
}
|
|
function addEvent(eventStore, subset, expandRange, context) {
|
|
if (expandRange) {
|
|
subset = expandRecurring(subset, expandRange, context);
|
|
}
|
|
return mergeEventStores(eventStore, subset);
|
|
}
|
|
function rezoneEventStoreDates(eventStore, oldDateEnv, newDateEnv) {
|
|
var defs = eventStore.defs;
|
|
var instances = mapHash(eventStore.instances, function(instance) {
|
|
var def = defs[instance.defId];
|
|
if (def.allDay || def.recurringDef) {
|
|
return instance;
|
|
}
|
|
return __assign(__assign({}, instance), { range: {
|
|
start: newDateEnv.createMarker(oldDateEnv.toDate(instance.range.start, instance.forcedStartTzo)),
|
|
end: newDateEnv.createMarker(oldDateEnv.toDate(instance.range.end, instance.forcedEndTzo))
|
|
}, forcedStartTzo: newDateEnv.canComputeOffset ? null : instance.forcedStartTzo, forcedEndTzo: newDateEnv.canComputeOffset ? null : instance.forcedEndTzo });
|
|
});
|
|
return { defs, instances };
|
|
}
|
|
function excludeEventsBySourceId(eventStore, sourceId) {
|
|
return filterEventStoreDefs(eventStore, function(eventDef) {
|
|
return eventDef.sourceId !== sourceId;
|
|
});
|
|
}
|
|
function excludeInstances(eventStore, removals) {
|
|
return {
|
|
defs: eventStore.defs,
|
|
instances: filterHash(eventStore.instances, function(instance) {
|
|
return !removals[instance.instanceId];
|
|
})
|
|
};
|
|
}
|
|
function reduceDateSelection(currentSelection, action) {
|
|
switch (action.type) {
|
|
case "UNSELECT_DATES":
|
|
return null;
|
|
case "SELECT_DATES":
|
|
return action.selection;
|
|
default:
|
|
return currentSelection;
|
|
}
|
|
}
|
|
function reduceSelectedEvent(currentInstanceId, action) {
|
|
switch (action.type) {
|
|
case "UNSELECT_EVENT":
|
|
return "";
|
|
case "SELECT_EVENT":
|
|
return action.eventInstanceId;
|
|
default:
|
|
return currentInstanceId;
|
|
}
|
|
}
|
|
function reduceEventDrag(currentDrag, action) {
|
|
var newDrag;
|
|
switch (action.type) {
|
|
case "UNSET_EVENT_DRAG":
|
|
return null;
|
|
case "SET_EVENT_DRAG":
|
|
newDrag = action.state;
|
|
return {
|
|
affectedEvents: newDrag.affectedEvents,
|
|
mutatedEvents: newDrag.mutatedEvents,
|
|
isEvent: newDrag.isEvent
|
|
};
|
|
default:
|
|
return currentDrag;
|
|
}
|
|
}
|
|
function reduceEventResize(currentResize, action) {
|
|
var newResize;
|
|
switch (action.type) {
|
|
case "UNSET_EVENT_RESIZE":
|
|
return null;
|
|
case "SET_EVENT_RESIZE":
|
|
newResize = action.state;
|
|
return {
|
|
affectedEvents: newResize.affectedEvents,
|
|
mutatedEvents: newResize.mutatedEvents,
|
|
isEvent: newResize.isEvent
|
|
};
|
|
default:
|
|
return currentResize;
|
|
}
|
|
}
|
|
function parseToolbars(calendarOptions, calendarOptionOverrides, theme, viewSpecs, calendarApi) {
|
|
var header = calendarOptions.headerToolbar ? parseToolbar(calendarOptions.headerToolbar, calendarOptions, calendarOptionOverrides, theme, viewSpecs, calendarApi) : null;
|
|
var footer = calendarOptions.footerToolbar ? parseToolbar(calendarOptions.footerToolbar, calendarOptions, calendarOptionOverrides, theme, viewSpecs, calendarApi) : null;
|
|
return { header, footer };
|
|
}
|
|
function parseToolbar(sectionStrHash, calendarOptions, calendarOptionOverrides, theme, viewSpecs, calendarApi) {
|
|
var sectionWidgets = {};
|
|
var viewsWithButtons = [];
|
|
var hasTitle = false;
|
|
for (var sectionName in sectionStrHash) {
|
|
var sectionStr = sectionStrHash[sectionName];
|
|
var sectionRes = parseSection(sectionStr, calendarOptions, calendarOptionOverrides, theme, viewSpecs, calendarApi);
|
|
sectionWidgets[sectionName] = sectionRes.widgets;
|
|
viewsWithButtons.push.apply(viewsWithButtons, sectionRes.viewsWithButtons);
|
|
hasTitle = hasTitle || sectionRes.hasTitle;
|
|
}
|
|
return { sectionWidgets, viewsWithButtons, hasTitle };
|
|
}
|
|
function parseSection(sectionStr, calendarOptions, calendarOptionOverrides, theme, viewSpecs, calendarApi) {
|
|
var isRtl = calendarOptions.direction === "rtl";
|
|
var calendarCustomButtons = calendarOptions.customButtons || {};
|
|
var calendarButtonTextOverrides = calendarOptionOverrides.buttonText || {};
|
|
var calendarButtonText = calendarOptions.buttonText || {};
|
|
var calendarButtonHintOverrides = calendarOptionOverrides.buttonHints || {};
|
|
var calendarButtonHints = calendarOptions.buttonHints || {};
|
|
var sectionSubstrs = sectionStr ? sectionStr.split(" ") : [];
|
|
var viewsWithButtons = [];
|
|
var hasTitle = false;
|
|
var widgets = sectionSubstrs.map(function(buttonGroupStr) {
|
|
return buttonGroupStr.split(",").map(function(buttonName) {
|
|
if (buttonName === "title") {
|
|
hasTitle = true;
|
|
return { buttonName };
|
|
}
|
|
var customButtonProps;
|
|
var viewSpec;
|
|
var buttonClick;
|
|
var buttonIcon;
|
|
var buttonText;
|
|
var buttonHint;
|
|
if (customButtonProps = calendarCustomButtons[buttonName]) {
|
|
buttonClick = function(ev) {
|
|
if (customButtonProps.click) {
|
|
customButtonProps.click.call(ev.target, ev, ev.target);
|
|
}
|
|
};
|
|
(buttonIcon = theme.getCustomButtonIconClass(customButtonProps)) || (buttonIcon = theme.getIconClass(buttonName, isRtl)) || (buttonText = customButtonProps.text);
|
|
buttonHint = customButtonProps.hint || customButtonProps.text;
|
|
} else if (viewSpec = viewSpecs[buttonName]) {
|
|
viewsWithButtons.push(buttonName);
|
|
buttonClick = function() {
|
|
calendarApi.changeView(buttonName);
|
|
};
|
|
(buttonText = viewSpec.buttonTextOverride) || (buttonIcon = theme.getIconClass(buttonName, isRtl)) || (buttonText = viewSpec.buttonTextDefault);
|
|
var textFallback = viewSpec.buttonTextOverride || viewSpec.buttonTextDefault;
|
|
buttonHint = formatWithOrdinals(viewSpec.buttonTitleOverride || viewSpec.buttonTitleDefault || calendarOptions.viewHint, [textFallback, buttonName], textFallback);
|
|
} else if (calendarApi[buttonName]) {
|
|
buttonClick = function() {
|
|
calendarApi[buttonName]();
|
|
};
|
|
(buttonText = calendarButtonTextOverrides[buttonName]) || (buttonIcon = theme.getIconClass(buttonName, isRtl)) || (buttonText = calendarButtonText[buttonName]);
|
|
if (buttonName === "prevYear" || buttonName === "nextYear") {
|
|
var prevOrNext = buttonName === "prevYear" ? "prev" : "next";
|
|
buttonHint = formatWithOrdinals(calendarButtonHintOverrides[prevOrNext] || calendarButtonHints[prevOrNext], [
|
|
calendarButtonText.year || "year",
|
|
"year"
|
|
], calendarButtonText[buttonName]);
|
|
} else {
|
|
buttonHint = function(navUnit) {
|
|
return formatWithOrdinals(calendarButtonHintOverrides[buttonName] || calendarButtonHints[buttonName], [
|
|
calendarButtonText[navUnit] || navUnit,
|
|
navUnit
|
|
], calendarButtonText[buttonName]);
|
|
};
|
|
}
|
|
}
|
|
return { buttonName, buttonClick, buttonIcon, buttonText, buttonHint };
|
|
});
|
|
});
|
|
return { widgets, viewsWithButtons, hasTitle };
|
|
}
|
|
var eventSourceDef$2 = {
|
|
ignoreRange: true,
|
|
parseMeta: function(refined) {
|
|
if (Array.isArray(refined.events)) {
|
|
return refined.events;
|
|
}
|
|
return null;
|
|
},
|
|
fetch: function(arg, success) {
|
|
success({
|
|
rawEvents: arg.eventSource.meta
|
|
});
|
|
}
|
|
};
|
|
var arrayEventSourcePlugin = createPlugin({
|
|
eventSourceDefs: [eventSourceDef$2]
|
|
});
|
|
var eventSourceDef$1 = {
|
|
parseMeta: function(refined) {
|
|
if (typeof refined.events === "function") {
|
|
return refined.events;
|
|
}
|
|
return null;
|
|
},
|
|
fetch: function(arg, success, failure) {
|
|
var dateEnv = arg.context.dateEnv;
|
|
var func = arg.eventSource.meta;
|
|
unpromisify(func.bind(null, buildRangeApiWithTimeZone(arg.range, dateEnv)), function(rawEvents) {
|
|
success({ rawEvents });
|
|
}, failure);
|
|
}
|
|
};
|
|
var funcEventSourcePlugin = createPlugin({
|
|
eventSourceDefs: [eventSourceDef$1]
|
|
});
|
|
function requestJson(method, url, params, successCallback, failureCallback) {
|
|
method = method.toUpperCase();
|
|
var body = null;
|
|
if (method === "GET") {
|
|
url = injectQueryStringParams(url, params);
|
|
} else {
|
|
body = encodeParams(params);
|
|
}
|
|
var xhr = new XMLHttpRequest();
|
|
xhr.open(method, url, true);
|
|
if (method !== "GET") {
|
|
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
|
|
}
|
|
xhr.onload = function() {
|
|
if (xhr.status >= 200 && xhr.status < 400) {
|
|
var parsed = false;
|
|
var res = void 0;
|
|
try {
|
|
res = JSON.parse(xhr.responseText);
|
|
parsed = true;
|
|
} catch (err) {
|
|
}
|
|
if (parsed) {
|
|
successCallback(res, xhr);
|
|
} else {
|
|
failureCallback("Failure parsing JSON", xhr);
|
|
}
|
|
} else {
|
|
failureCallback("Request failed", xhr);
|
|
}
|
|
};
|
|
xhr.onerror = function() {
|
|
failureCallback("Request failed", xhr);
|
|
};
|
|
xhr.send(body);
|
|
}
|
|
function injectQueryStringParams(url, params) {
|
|
return url + (url.indexOf("?") === -1 ? "?" : "&") + encodeParams(params);
|
|
}
|
|
function encodeParams(params) {
|
|
var parts = [];
|
|
for (var key in params) {
|
|
parts.push(encodeURIComponent(key) + "=" + encodeURIComponent(params[key]));
|
|
}
|
|
return parts.join("&");
|
|
}
|
|
var JSON_FEED_EVENT_SOURCE_REFINERS = {
|
|
method: String,
|
|
extraParams: identity,
|
|
startParam: String,
|
|
endParam: String,
|
|
timeZoneParam: String
|
|
};
|
|
var eventSourceDef = {
|
|
parseMeta: function(refined) {
|
|
if (refined.url && (refined.format === "json" || !refined.format)) {
|
|
return {
|
|
url: refined.url,
|
|
format: "json",
|
|
method: (refined.method || "GET").toUpperCase(),
|
|
extraParams: refined.extraParams,
|
|
startParam: refined.startParam,
|
|
endParam: refined.endParam,
|
|
timeZoneParam: refined.timeZoneParam
|
|
};
|
|
}
|
|
return null;
|
|
},
|
|
fetch: function(arg, success, failure) {
|
|
var meta = arg.eventSource.meta;
|
|
var requestParams = buildRequestParams(meta, arg.range, arg.context);
|
|
requestJson(meta.method, meta.url, requestParams, function(rawEvents, xhr) {
|
|
success({ rawEvents, xhr });
|
|
}, function(errorMessage, xhr) {
|
|
failure({ message: errorMessage, xhr });
|
|
});
|
|
}
|
|
};
|
|
var jsonFeedEventSourcePlugin = createPlugin({
|
|
eventSourceRefiners: JSON_FEED_EVENT_SOURCE_REFINERS,
|
|
eventSourceDefs: [eventSourceDef]
|
|
});
|
|
function buildRequestParams(meta, range, context) {
|
|
var dateEnv = context.dateEnv, options = context.options;
|
|
var startParam;
|
|
var endParam;
|
|
var timeZoneParam;
|
|
var customRequestParams;
|
|
var params = {};
|
|
startParam = meta.startParam;
|
|
if (startParam == null) {
|
|
startParam = options.startParam;
|
|
}
|
|
endParam = meta.endParam;
|
|
if (endParam == null) {
|
|
endParam = options.endParam;
|
|
}
|
|
timeZoneParam = meta.timeZoneParam;
|
|
if (timeZoneParam == null) {
|
|
timeZoneParam = options.timeZoneParam;
|
|
}
|
|
if (typeof meta.extraParams === "function") {
|
|
customRequestParams = meta.extraParams();
|
|
} else {
|
|
customRequestParams = meta.extraParams || {};
|
|
}
|
|
__assign(params, customRequestParams);
|
|
params[startParam] = dateEnv.formatIso(range.start);
|
|
params[endParam] = dateEnv.formatIso(range.end);
|
|
if (dateEnv.timeZone !== "local") {
|
|
params[timeZoneParam] = dateEnv.timeZone;
|
|
}
|
|
return params;
|
|
}
|
|
var SIMPLE_RECURRING_REFINERS = {
|
|
daysOfWeek: identity,
|
|
startTime: createDuration,
|
|
endTime: createDuration,
|
|
duration: createDuration,
|
|
startRecur: identity,
|
|
endRecur: identity
|
|
};
|
|
var recurring = {
|
|
parse: function(refined, dateEnv) {
|
|
if (refined.daysOfWeek || refined.startTime || refined.endTime || refined.startRecur || refined.endRecur) {
|
|
var recurringData = {
|
|
daysOfWeek: refined.daysOfWeek || null,
|
|
startTime: refined.startTime || null,
|
|
endTime: refined.endTime || null,
|
|
startRecur: refined.startRecur ? dateEnv.createMarker(refined.startRecur) : null,
|
|
endRecur: refined.endRecur ? dateEnv.createMarker(refined.endRecur) : null
|
|
};
|
|
var duration = void 0;
|
|
if (refined.duration) {
|
|
duration = refined.duration;
|
|
}
|
|
if (!duration && refined.startTime && refined.endTime) {
|
|
duration = subtractDurations(refined.endTime, refined.startTime);
|
|
}
|
|
return {
|
|
allDayGuess: Boolean(!refined.startTime && !refined.endTime),
|
|
duration,
|
|
typeData: recurringData
|
|
};
|
|
}
|
|
return null;
|
|
},
|
|
expand: function(typeData, framingRange, dateEnv) {
|
|
var clippedFramingRange = intersectRanges(framingRange, { start: typeData.startRecur, end: typeData.endRecur });
|
|
if (clippedFramingRange) {
|
|
return expandRanges(typeData.daysOfWeek, typeData.startTime, clippedFramingRange, dateEnv);
|
|
}
|
|
return [];
|
|
}
|
|
};
|
|
var simpleRecurringEventsPlugin = createPlugin({
|
|
recurringTypes: [recurring],
|
|
eventRefiners: SIMPLE_RECURRING_REFINERS
|
|
});
|
|
function expandRanges(daysOfWeek, startTime, framingRange, dateEnv) {
|
|
var dowHash = daysOfWeek ? arrayToHash(daysOfWeek) : null;
|
|
var dayMarker = startOfDay(framingRange.start);
|
|
var endMarker = framingRange.end;
|
|
var instanceStarts = [];
|
|
while (dayMarker < endMarker) {
|
|
var instanceStart = void 0;
|
|
if (!dowHash || dowHash[dayMarker.getUTCDay()]) {
|
|
if (startTime) {
|
|
instanceStart = dateEnv.add(dayMarker, startTime);
|
|
} else {
|
|
instanceStart = dayMarker;
|
|
}
|
|
instanceStarts.push(instanceStart);
|
|
}
|
|
dayMarker = addDays(dayMarker, 1);
|
|
}
|
|
return instanceStarts;
|
|
}
|
|
var changeHandlerPlugin = createPlugin({
|
|
optionChangeHandlers: {
|
|
events: function(events, context) {
|
|
handleEventSources([events], context);
|
|
},
|
|
eventSources: handleEventSources
|
|
}
|
|
});
|
|
function handleEventSources(inputs, context) {
|
|
var unfoundSources = hashValuesToArray(context.getCurrentData().eventSources);
|
|
var newInputs = [];
|
|
for (var _i = 0, inputs_1 = inputs; _i < inputs_1.length; _i++) {
|
|
var input = inputs_1[_i];
|
|
var inputFound = false;
|
|
for (var i3 = 0; i3 < unfoundSources.length; i3 += 1) {
|
|
if (unfoundSources[i3]._raw === input) {
|
|
unfoundSources.splice(i3, 1);
|
|
inputFound = true;
|
|
break;
|
|
}
|
|
}
|
|
if (!inputFound) {
|
|
newInputs.push(input);
|
|
}
|
|
}
|
|
for (var _a = 0, unfoundSources_1 = unfoundSources; _a < unfoundSources_1.length; _a++) {
|
|
var unfoundSource = unfoundSources_1[_a];
|
|
context.dispatch({
|
|
type: "REMOVE_EVENT_SOURCE",
|
|
sourceId: unfoundSource.sourceId
|
|
});
|
|
}
|
|
for (var _b = 0, newInputs_1 = newInputs; _b < newInputs_1.length; _b++) {
|
|
var newInput = newInputs_1[_b];
|
|
context.calendarApi.addEventSource(newInput);
|
|
}
|
|
}
|
|
function handleDateProfile(dateProfile, context) {
|
|
context.emitter.trigger("datesSet", __assign(__assign({}, buildRangeApiWithTimeZone(dateProfile.activeRange, context.dateEnv)), { view: context.viewApi }));
|
|
}
|
|
function handleEventStore(eventStore, context) {
|
|
var emitter = context.emitter;
|
|
if (emitter.hasHandlers("eventsSet")) {
|
|
emitter.trigger("eventsSet", buildEventApis(eventStore, context));
|
|
}
|
|
}
|
|
var globalPlugins = [
|
|
arrayEventSourcePlugin,
|
|
funcEventSourcePlugin,
|
|
jsonFeedEventSourcePlugin,
|
|
simpleRecurringEventsPlugin,
|
|
changeHandlerPlugin,
|
|
createPlugin({
|
|
isLoadingFuncs: [
|
|
function(state) {
|
|
return computeEventSourcesLoading(state.eventSources);
|
|
}
|
|
],
|
|
contentTypeHandlers: {
|
|
html: buildHtmlRenderer,
|
|
domNodes: buildDomNodeRenderer
|
|
},
|
|
propSetHandlers: {
|
|
dateProfile: handleDateProfile,
|
|
eventStore: handleEventStore
|
|
}
|
|
})
|
|
];
|
|
function buildHtmlRenderer() {
|
|
var currentEl = null;
|
|
var currentHtml = "";
|
|
function render4(el, html) {
|
|
if (el !== currentEl || html !== currentHtml) {
|
|
el.innerHTML = html;
|
|
}
|
|
currentEl = el;
|
|
currentHtml = html;
|
|
}
|
|
function destroy() {
|
|
currentEl.innerHTML = "";
|
|
currentEl = null;
|
|
currentHtml = "";
|
|
}
|
|
return { render: render4, destroy };
|
|
}
|
|
function buildDomNodeRenderer() {
|
|
var currentEl = null;
|
|
var currentDomNodes = [];
|
|
function render4(el, domNodes) {
|
|
var newDomNodes = Array.prototype.slice.call(domNodes);
|
|
if (el !== currentEl || !isArraysEqual(currentDomNodes, newDomNodes)) {
|
|
for (var _i = 0, newDomNodes_1 = newDomNodes; _i < newDomNodes_1.length; _i++) {
|
|
var newNode = newDomNodes_1[_i];
|
|
el.appendChild(newNode);
|
|
}
|
|
destroy();
|
|
}
|
|
currentEl = el;
|
|
currentDomNodes = newDomNodes;
|
|
}
|
|
function destroy() {
|
|
currentDomNodes.forEach(removeElement);
|
|
currentDomNodes = [];
|
|
currentEl = null;
|
|
}
|
|
return { render: render4, destroy };
|
|
}
|
|
var DelayedRunner = function() {
|
|
function DelayedRunner2(drainedOption) {
|
|
this.drainedOption = drainedOption;
|
|
this.isRunning = false;
|
|
this.isDirty = false;
|
|
this.pauseDepths = {};
|
|
this.timeoutId = 0;
|
|
}
|
|
DelayedRunner2.prototype.request = function(delay) {
|
|
this.isDirty = true;
|
|
if (!this.isPaused()) {
|
|
this.clearTimeout();
|
|
if (delay == null) {
|
|
this.tryDrain();
|
|
} else {
|
|
this.timeoutId = setTimeout(this.tryDrain.bind(this), delay);
|
|
}
|
|
}
|
|
};
|
|
DelayedRunner2.prototype.pause = function(scope) {
|
|
if (scope === void 0) {
|
|
scope = "";
|
|
}
|
|
var pauseDepths = this.pauseDepths;
|
|
pauseDepths[scope] = (pauseDepths[scope] || 0) + 1;
|
|
this.clearTimeout();
|
|
};
|
|
DelayedRunner2.prototype.resume = function(scope, force) {
|
|
if (scope === void 0) {
|
|
scope = "";
|
|
}
|
|
var pauseDepths = this.pauseDepths;
|
|
if (scope in pauseDepths) {
|
|
if (force) {
|
|
delete pauseDepths[scope];
|
|
} else {
|
|
pauseDepths[scope] -= 1;
|
|
var depth = pauseDepths[scope];
|
|
if (depth <= 0) {
|
|
delete pauseDepths[scope];
|
|
}
|
|
}
|
|
this.tryDrain();
|
|
}
|
|
};
|
|
DelayedRunner2.prototype.isPaused = function() {
|
|
return Object.keys(this.pauseDepths).length;
|
|
};
|
|
DelayedRunner2.prototype.tryDrain = function() {
|
|
if (!this.isRunning && !this.isPaused()) {
|
|
this.isRunning = true;
|
|
while (this.isDirty) {
|
|
this.isDirty = false;
|
|
this.drained();
|
|
}
|
|
this.isRunning = false;
|
|
}
|
|
};
|
|
DelayedRunner2.prototype.clear = function() {
|
|
this.clearTimeout();
|
|
this.isDirty = false;
|
|
this.pauseDepths = {};
|
|
};
|
|
DelayedRunner2.prototype.clearTimeout = function() {
|
|
if (this.timeoutId) {
|
|
clearTimeout(this.timeoutId);
|
|
this.timeoutId = 0;
|
|
}
|
|
};
|
|
DelayedRunner2.prototype.drained = function() {
|
|
if (this.drainedOption) {
|
|
this.drainedOption();
|
|
}
|
|
};
|
|
return DelayedRunner2;
|
|
}();
|
|
var TaskRunner = function() {
|
|
function TaskRunner2(runTaskOption, drainedOption) {
|
|
this.runTaskOption = runTaskOption;
|
|
this.drainedOption = drainedOption;
|
|
this.queue = [];
|
|
this.delayedRunner = new DelayedRunner(this.drain.bind(this));
|
|
}
|
|
TaskRunner2.prototype.request = function(task, delay) {
|
|
this.queue.push(task);
|
|
this.delayedRunner.request(delay);
|
|
};
|
|
TaskRunner2.prototype.pause = function(scope) {
|
|
this.delayedRunner.pause(scope);
|
|
};
|
|
TaskRunner2.prototype.resume = function(scope, force) {
|
|
this.delayedRunner.resume(scope, force);
|
|
};
|
|
TaskRunner2.prototype.drain = function() {
|
|
var queue = this.queue;
|
|
while (queue.length) {
|
|
var completedTasks = [];
|
|
var task = void 0;
|
|
while (task = queue.shift()) {
|
|
this.runTask(task);
|
|
completedTasks.push(task);
|
|
}
|
|
this.drained(completedTasks);
|
|
}
|
|
};
|
|
TaskRunner2.prototype.runTask = function(task) {
|
|
if (this.runTaskOption) {
|
|
this.runTaskOption(task);
|
|
}
|
|
};
|
|
TaskRunner2.prototype.drained = function(completedTasks) {
|
|
if (this.drainedOption) {
|
|
this.drainedOption(completedTasks);
|
|
}
|
|
};
|
|
return TaskRunner2;
|
|
}();
|
|
function buildTitle(dateProfile, viewOptions, dateEnv) {
|
|
var range;
|
|
if (/^(year|month)$/.test(dateProfile.currentRangeUnit)) {
|
|
range = dateProfile.currentRange;
|
|
} else {
|
|
range = dateProfile.activeRange;
|
|
}
|
|
return dateEnv.formatRange(range.start, range.end, createFormatter(viewOptions.titleFormat || buildTitleFormat(dateProfile)), {
|
|
isEndExclusive: dateProfile.isRangeAllDay,
|
|
defaultSeparator: viewOptions.titleRangeSeparator
|
|
});
|
|
}
|
|
function buildTitleFormat(dateProfile) {
|
|
var currentRangeUnit = dateProfile.currentRangeUnit;
|
|
if (currentRangeUnit === "year") {
|
|
return { year: "numeric" };
|
|
}
|
|
if (currentRangeUnit === "month") {
|
|
return { year: "numeric", month: "long" };
|
|
}
|
|
var days = diffWholeDays(dateProfile.currentRange.start, dateProfile.currentRange.end);
|
|
if (days !== null && days > 1) {
|
|
return { year: "numeric", month: "short", day: "numeric" };
|
|
}
|
|
return { year: "numeric", month: "long", day: "numeric" };
|
|
}
|
|
var CalendarDataManager = function() {
|
|
function CalendarDataManager2(props) {
|
|
var _this = this;
|
|
this.computeOptionsData = memoize(this._computeOptionsData);
|
|
this.computeCurrentViewData = memoize(this._computeCurrentViewData);
|
|
this.organizeRawLocales = memoize(organizeRawLocales);
|
|
this.buildLocale = memoize(buildLocale);
|
|
this.buildPluginHooks = buildBuildPluginHooks();
|
|
this.buildDateEnv = memoize(buildDateEnv);
|
|
this.buildTheme = memoize(buildTheme);
|
|
this.parseToolbars = memoize(parseToolbars);
|
|
this.buildViewSpecs = memoize(buildViewSpecs);
|
|
this.buildDateProfileGenerator = memoizeObjArg(buildDateProfileGenerator);
|
|
this.buildViewApi = memoize(buildViewApi);
|
|
this.buildViewUiProps = memoizeObjArg(buildViewUiProps);
|
|
this.buildEventUiBySource = memoize(buildEventUiBySource, isPropsEqual);
|
|
this.buildEventUiBases = memoize(buildEventUiBases);
|
|
this.parseContextBusinessHours = memoizeObjArg(parseContextBusinessHours);
|
|
this.buildTitle = memoize(buildTitle);
|
|
this.emitter = new Emitter();
|
|
this.actionRunner = new TaskRunner(this._handleAction.bind(this), this.updateData.bind(this));
|
|
this.currentCalendarOptionsInput = {};
|
|
this.currentCalendarOptionsRefined = {};
|
|
this.currentViewOptionsInput = {};
|
|
this.currentViewOptionsRefined = {};
|
|
this.currentCalendarOptionsRefiners = {};
|
|
this.getCurrentData = function() {
|
|
return _this.data;
|
|
};
|
|
this.dispatch = function(action) {
|
|
_this.actionRunner.request(action);
|
|
};
|
|
this.props = props;
|
|
this.actionRunner.pause();
|
|
var dynamicOptionOverrides = {};
|
|
var optionsData = this.computeOptionsData(props.optionOverrides, dynamicOptionOverrides, props.calendarApi);
|
|
var currentViewType = optionsData.calendarOptions.initialView || optionsData.pluginHooks.initialView;
|
|
var currentViewData = this.computeCurrentViewData(currentViewType, optionsData, props.optionOverrides, dynamicOptionOverrides);
|
|
props.calendarApi.currentDataManager = this;
|
|
this.emitter.setThisContext(props.calendarApi);
|
|
this.emitter.setOptions(currentViewData.options);
|
|
var currentDate = getInitialDate(optionsData.calendarOptions, optionsData.dateEnv);
|
|
var dateProfile = currentViewData.dateProfileGenerator.build(currentDate);
|
|
if (!rangeContainsMarker(dateProfile.activeRange, currentDate)) {
|
|
currentDate = dateProfile.currentRange.start;
|
|
}
|
|
var calendarContext = {
|
|
dateEnv: optionsData.dateEnv,
|
|
options: optionsData.calendarOptions,
|
|
pluginHooks: optionsData.pluginHooks,
|
|
calendarApi: props.calendarApi,
|
|
dispatch: this.dispatch,
|
|
emitter: this.emitter,
|
|
getCurrentData: this.getCurrentData
|
|
};
|
|
for (var _i = 0, _a = optionsData.pluginHooks.contextInit; _i < _a.length; _i++) {
|
|
var callback = _a[_i];
|
|
callback(calendarContext);
|
|
}
|
|
var eventSources = initEventSources(optionsData.calendarOptions, dateProfile, calendarContext);
|
|
var initialState = {
|
|
dynamicOptionOverrides,
|
|
currentViewType,
|
|
currentDate,
|
|
dateProfile,
|
|
businessHours: this.parseContextBusinessHours(calendarContext),
|
|
eventSources,
|
|
eventUiBases: {},
|
|
eventStore: createEmptyEventStore(),
|
|
renderableEventStore: createEmptyEventStore(),
|
|
dateSelection: null,
|
|
eventSelection: "",
|
|
eventDrag: null,
|
|
eventResize: null,
|
|
selectionConfig: this.buildViewUiProps(calendarContext).selectionConfig
|
|
};
|
|
var contextAndState = __assign(__assign({}, calendarContext), initialState);
|
|
for (var _b = 0, _c = optionsData.pluginHooks.reducers; _b < _c.length; _b++) {
|
|
var reducer = _c[_b];
|
|
__assign(initialState, reducer(null, null, contextAndState));
|
|
}
|
|
if (computeIsLoading(initialState, calendarContext)) {
|
|
this.emitter.trigger("loading", true);
|
|
}
|
|
this.state = initialState;
|
|
this.updateData();
|
|
this.actionRunner.resume();
|
|
}
|
|
CalendarDataManager2.prototype.resetOptions = function(optionOverrides, append) {
|
|
var props = this.props;
|
|
props.optionOverrides = append ? __assign(__assign({}, props.optionOverrides), optionOverrides) : optionOverrides;
|
|
this.actionRunner.request({
|
|
type: "NOTHING"
|
|
});
|
|
};
|
|
CalendarDataManager2.prototype._handleAction = function(action) {
|
|
var _a = this, props = _a.props, state = _a.state, emitter = _a.emitter;
|
|
var dynamicOptionOverrides = reduceDynamicOptionOverrides(state.dynamicOptionOverrides, action);
|
|
var optionsData = this.computeOptionsData(props.optionOverrides, dynamicOptionOverrides, props.calendarApi);
|
|
var currentViewType = reduceViewType(state.currentViewType, action);
|
|
var currentViewData = this.computeCurrentViewData(currentViewType, optionsData, props.optionOverrides, dynamicOptionOverrides);
|
|
props.calendarApi.currentDataManager = this;
|
|
emitter.setThisContext(props.calendarApi);
|
|
emitter.setOptions(currentViewData.options);
|
|
var calendarContext = {
|
|
dateEnv: optionsData.dateEnv,
|
|
options: optionsData.calendarOptions,
|
|
pluginHooks: optionsData.pluginHooks,
|
|
calendarApi: props.calendarApi,
|
|
dispatch: this.dispatch,
|
|
emitter,
|
|
getCurrentData: this.getCurrentData
|
|
};
|
|
var currentDate = state.currentDate, dateProfile = state.dateProfile;
|
|
if (this.data && this.data.dateProfileGenerator !== currentViewData.dateProfileGenerator) {
|
|
dateProfile = currentViewData.dateProfileGenerator.build(currentDate);
|
|
}
|
|
currentDate = reduceCurrentDate(currentDate, action);
|
|
dateProfile = reduceDateProfile(dateProfile, action, currentDate, currentViewData.dateProfileGenerator);
|
|
if (action.type === "PREV" || action.type === "NEXT" || !rangeContainsMarker(dateProfile.currentRange, currentDate)) {
|
|
currentDate = dateProfile.currentRange.start;
|
|
}
|
|
var eventSources = reduceEventSources(state.eventSources, action, dateProfile, calendarContext);
|
|
var eventStore = reduceEventStore(state.eventStore, action, eventSources, dateProfile, calendarContext);
|
|
var isEventsLoading = computeEventSourcesLoading(eventSources);
|
|
var renderableEventStore = isEventsLoading && !currentViewData.options.progressiveEventRendering ? state.renderableEventStore || eventStore : eventStore;
|
|
var _b = this.buildViewUiProps(calendarContext), eventUiSingleBase = _b.eventUiSingleBase, selectionConfig = _b.selectionConfig;
|
|
var eventUiBySource = this.buildEventUiBySource(eventSources);
|
|
var eventUiBases = this.buildEventUiBases(renderableEventStore.defs, eventUiSingleBase, eventUiBySource);
|
|
var newState = {
|
|
dynamicOptionOverrides,
|
|
currentViewType,
|
|
currentDate,
|
|
dateProfile,
|
|
eventSources,
|
|
eventStore,
|
|
renderableEventStore,
|
|
selectionConfig,
|
|
eventUiBases,
|
|
businessHours: this.parseContextBusinessHours(calendarContext),
|
|
dateSelection: reduceDateSelection(state.dateSelection, action),
|
|
eventSelection: reduceSelectedEvent(state.eventSelection, action),
|
|
eventDrag: reduceEventDrag(state.eventDrag, action),
|
|
eventResize: reduceEventResize(state.eventResize, action)
|
|
};
|
|
var contextAndState = __assign(__assign({}, calendarContext), newState);
|
|
for (var _i = 0, _c = optionsData.pluginHooks.reducers; _i < _c.length; _i++) {
|
|
var reducer = _c[_i];
|
|
__assign(newState, reducer(state, action, contextAndState));
|
|
}
|
|
var wasLoading = computeIsLoading(state, calendarContext);
|
|
var isLoading = computeIsLoading(newState, calendarContext);
|
|
if (!wasLoading && isLoading) {
|
|
emitter.trigger("loading", true);
|
|
} else if (wasLoading && !isLoading) {
|
|
emitter.trigger("loading", false);
|
|
}
|
|
this.state = newState;
|
|
if (props.onAction) {
|
|
props.onAction(action);
|
|
}
|
|
};
|
|
CalendarDataManager2.prototype.updateData = function() {
|
|
var _a = this, props = _a.props, state = _a.state;
|
|
var oldData = this.data;
|
|
var optionsData = this.computeOptionsData(props.optionOverrides, state.dynamicOptionOverrides, props.calendarApi);
|
|
var currentViewData = this.computeCurrentViewData(state.currentViewType, optionsData, props.optionOverrides, state.dynamicOptionOverrides);
|
|
var data = this.data = __assign(__assign(__assign({ viewTitle: this.buildTitle(state.dateProfile, currentViewData.options, optionsData.dateEnv), calendarApi: props.calendarApi, dispatch: this.dispatch, emitter: this.emitter, getCurrentData: this.getCurrentData }, optionsData), currentViewData), state);
|
|
var changeHandlers = optionsData.pluginHooks.optionChangeHandlers;
|
|
var oldCalendarOptions = oldData && oldData.calendarOptions;
|
|
var newCalendarOptions = optionsData.calendarOptions;
|
|
if (oldCalendarOptions && oldCalendarOptions !== newCalendarOptions) {
|
|
if (oldCalendarOptions.timeZone !== newCalendarOptions.timeZone) {
|
|
state.eventSources = data.eventSources = reduceEventSourcesNewTimeZone(data.eventSources, state.dateProfile, data);
|
|
state.eventStore = data.eventStore = rezoneEventStoreDates(data.eventStore, oldData.dateEnv, data.dateEnv);
|
|
}
|
|
for (var optionName in changeHandlers) {
|
|
if (oldCalendarOptions[optionName] !== newCalendarOptions[optionName]) {
|
|
changeHandlers[optionName](newCalendarOptions[optionName], data);
|
|
}
|
|
}
|
|
}
|
|
if (props.onData) {
|
|
props.onData(data);
|
|
}
|
|
};
|
|
CalendarDataManager2.prototype._computeOptionsData = function(optionOverrides, dynamicOptionOverrides, calendarApi) {
|
|
var _a = this.processRawCalendarOptions(optionOverrides, dynamicOptionOverrides), refinedOptions = _a.refinedOptions, pluginHooks = _a.pluginHooks, localeDefaults = _a.localeDefaults, availableLocaleData = _a.availableLocaleData, extra = _a.extra;
|
|
warnUnknownOptions(extra);
|
|
var dateEnv = this.buildDateEnv(refinedOptions.timeZone, refinedOptions.locale, refinedOptions.weekNumberCalculation, refinedOptions.firstDay, refinedOptions.weekText, pluginHooks, availableLocaleData, refinedOptions.defaultRangeSeparator);
|
|
var viewSpecs = this.buildViewSpecs(pluginHooks.views, optionOverrides, dynamicOptionOverrides, localeDefaults);
|
|
var theme = this.buildTheme(refinedOptions, pluginHooks);
|
|
var toolbarConfig = this.parseToolbars(refinedOptions, optionOverrides, theme, viewSpecs, calendarApi);
|
|
return {
|
|
calendarOptions: refinedOptions,
|
|
pluginHooks,
|
|
dateEnv,
|
|
viewSpecs,
|
|
theme,
|
|
toolbarConfig,
|
|
localeDefaults,
|
|
availableRawLocales: availableLocaleData.map
|
|
};
|
|
};
|
|
CalendarDataManager2.prototype.processRawCalendarOptions = function(optionOverrides, dynamicOptionOverrides) {
|
|
var _a = mergeRawOptions([
|
|
BASE_OPTION_DEFAULTS,
|
|
optionOverrides,
|
|
dynamicOptionOverrides
|
|
]), locales = _a.locales, locale = _a.locale;
|
|
var availableLocaleData = this.organizeRawLocales(locales);
|
|
var availableRawLocales = availableLocaleData.map;
|
|
var localeDefaults = this.buildLocale(locale || availableLocaleData.defaultCode, availableRawLocales).options;
|
|
var pluginHooks = this.buildPluginHooks(optionOverrides.plugins || [], globalPlugins);
|
|
var refiners = this.currentCalendarOptionsRefiners = __assign(__assign(__assign(__assign(__assign({}, BASE_OPTION_REFINERS), CALENDAR_LISTENER_REFINERS), CALENDAR_OPTION_REFINERS), pluginHooks.listenerRefiners), pluginHooks.optionRefiners);
|
|
var extra = {};
|
|
var raw = mergeRawOptions([
|
|
BASE_OPTION_DEFAULTS,
|
|
localeDefaults,
|
|
optionOverrides,
|
|
dynamicOptionOverrides
|
|
]);
|
|
var refined = {};
|
|
var currentRaw = this.currentCalendarOptionsInput;
|
|
var currentRefined = this.currentCalendarOptionsRefined;
|
|
var anyChanges = false;
|
|
for (var optionName in raw) {
|
|
if (optionName !== "plugins") {
|
|
if (raw[optionName] === currentRaw[optionName] || COMPLEX_OPTION_COMPARATORS[optionName] && optionName in currentRaw && COMPLEX_OPTION_COMPARATORS[optionName](currentRaw[optionName], raw[optionName])) {
|
|
refined[optionName] = currentRefined[optionName];
|
|
} else if (refiners[optionName]) {
|
|
refined[optionName] = refiners[optionName](raw[optionName]);
|
|
anyChanges = true;
|
|
} else {
|
|
extra[optionName] = currentRaw[optionName];
|
|
}
|
|
}
|
|
}
|
|
if (anyChanges) {
|
|
this.currentCalendarOptionsInput = raw;
|
|
this.currentCalendarOptionsRefined = refined;
|
|
}
|
|
return {
|
|
rawOptions: this.currentCalendarOptionsInput,
|
|
refinedOptions: this.currentCalendarOptionsRefined,
|
|
pluginHooks,
|
|
availableLocaleData,
|
|
localeDefaults,
|
|
extra
|
|
};
|
|
};
|
|
CalendarDataManager2.prototype._computeCurrentViewData = function(viewType, optionsData, optionOverrides, dynamicOptionOverrides) {
|
|
var viewSpec = optionsData.viewSpecs[viewType];
|
|
if (!viewSpec) {
|
|
throw new Error('viewType "' + viewType + `" is not available. Please make sure you've loaded all neccessary plugins`);
|
|
}
|
|
var _a = this.processRawViewOptions(viewSpec, optionsData.pluginHooks, optionsData.localeDefaults, optionOverrides, dynamicOptionOverrides), refinedOptions = _a.refinedOptions, extra = _a.extra;
|
|
warnUnknownOptions(extra);
|
|
var dateProfileGenerator = this.buildDateProfileGenerator({
|
|
dateProfileGeneratorClass: viewSpec.optionDefaults.dateProfileGeneratorClass,
|
|
duration: viewSpec.duration,
|
|
durationUnit: viewSpec.durationUnit,
|
|
usesMinMaxTime: viewSpec.optionDefaults.usesMinMaxTime,
|
|
dateEnv: optionsData.dateEnv,
|
|
calendarApi: this.props.calendarApi,
|
|
slotMinTime: refinedOptions.slotMinTime,
|
|
slotMaxTime: refinedOptions.slotMaxTime,
|
|
showNonCurrentDates: refinedOptions.showNonCurrentDates,
|
|
dayCount: refinedOptions.dayCount,
|
|
dateAlignment: refinedOptions.dateAlignment,
|
|
dateIncrement: refinedOptions.dateIncrement,
|
|
hiddenDays: refinedOptions.hiddenDays,
|
|
weekends: refinedOptions.weekends,
|
|
nowInput: refinedOptions.now,
|
|
validRangeInput: refinedOptions.validRange,
|
|
visibleRangeInput: refinedOptions.visibleRange,
|
|
monthMode: refinedOptions.monthMode,
|
|
fixedWeekCount: refinedOptions.fixedWeekCount
|
|
});
|
|
var viewApi = this.buildViewApi(viewType, this.getCurrentData, optionsData.dateEnv);
|
|
return { viewSpec, options: refinedOptions, dateProfileGenerator, viewApi };
|
|
};
|
|
CalendarDataManager2.prototype.processRawViewOptions = function(viewSpec, pluginHooks, localeDefaults, optionOverrides, dynamicOptionOverrides) {
|
|
var raw = mergeRawOptions([
|
|
BASE_OPTION_DEFAULTS,
|
|
viewSpec.optionDefaults,
|
|
localeDefaults,
|
|
optionOverrides,
|
|
viewSpec.optionOverrides,
|
|
dynamicOptionOverrides
|
|
]);
|
|
var refiners = __assign(__assign(__assign(__assign(__assign(__assign({}, BASE_OPTION_REFINERS), CALENDAR_LISTENER_REFINERS), CALENDAR_OPTION_REFINERS), VIEW_OPTION_REFINERS), pluginHooks.listenerRefiners), pluginHooks.optionRefiners);
|
|
var refined = {};
|
|
var currentRaw = this.currentViewOptionsInput;
|
|
var currentRefined = this.currentViewOptionsRefined;
|
|
var anyChanges = false;
|
|
var extra = {};
|
|
for (var optionName in raw) {
|
|
if (raw[optionName] === currentRaw[optionName]) {
|
|
refined[optionName] = currentRefined[optionName];
|
|
} else {
|
|
if (raw[optionName] === this.currentCalendarOptionsInput[optionName]) {
|
|
if (optionName in this.currentCalendarOptionsRefined) {
|
|
refined[optionName] = this.currentCalendarOptionsRefined[optionName];
|
|
}
|
|
} else if (refiners[optionName]) {
|
|
refined[optionName] = refiners[optionName](raw[optionName]);
|
|
} else {
|
|
extra[optionName] = raw[optionName];
|
|
}
|
|
anyChanges = true;
|
|
}
|
|
}
|
|
if (anyChanges) {
|
|
this.currentViewOptionsInput = raw;
|
|
this.currentViewOptionsRefined = refined;
|
|
}
|
|
return {
|
|
rawOptions: this.currentViewOptionsInput,
|
|
refinedOptions: this.currentViewOptionsRefined,
|
|
extra
|
|
};
|
|
};
|
|
return CalendarDataManager2;
|
|
}();
|
|
function buildDateEnv(timeZone, explicitLocale, weekNumberCalculation, firstDay, weekText, pluginHooks, availableLocaleData, defaultSeparator) {
|
|
var locale = buildLocale(explicitLocale || availableLocaleData.defaultCode, availableLocaleData.map);
|
|
return new DateEnv({
|
|
calendarSystem: "gregory",
|
|
timeZone,
|
|
namedTimeZoneImpl: pluginHooks.namedTimeZonedImpl,
|
|
locale,
|
|
weekNumberCalculation,
|
|
firstDay,
|
|
weekText,
|
|
cmdFormatter: pluginHooks.cmdFormatter,
|
|
defaultSeparator
|
|
});
|
|
}
|
|
function buildTheme(options, pluginHooks) {
|
|
var ThemeClass = pluginHooks.themeClasses[options.themeSystem] || StandardTheme;
|
|
return new ThemeClass(options);
|
|
}
|
|
function buildDateProfileGenerator(props) {
|
|
var DateProfileGeneratorClass = props.dateProfileGeneratorClass || DateProfileGenerator;
|
|
return new DateProfileGeneratorClass(props);
|
|
}
|
|
function buildViewApi(type, getCurrentData, dateEnv) {
|
|
return new ViewApi(type, getCurrentData, dateEnv);
|
|
}
|
|
function buildEventUiBySource(eventSources) {
|
|
return mapHash(eventSources, function(eventSource) {
|
|
return eventSource.ui;
|
|
});
|
|
}
|
|
function buildEventUiBases(eventDefs, eventUiSingleBase, eventUiBySource) {
|
|
var eventUiBases = { "": eventUiSingleBase };
|
|
for (var defId in eventDefs) {
|
|
var def = eventDefs[defId];
|
|
if (def.sourceId && eventUiBySource[def.sourceId]) {
|
|
eventUiBases[defId] = eventUiBySource[def.sourceId];
|
|
}
|
|
}
|
|
return eventUiBases;
|
|
}
|
|
function buildViewUiProps(calendarContext) {
|
|
var options = calendarContext.options;
|
|
return {
|
|
eventUiSingleBase: createEventUi({
|
|
display: options.eventDisplay,
|
|
editable: options.editable,
|
|
startEditable: options.eventStartEditable,
|
|
durationEditable: options.eventDurationEditable,
|
|
constraint: options.eventConstraint,
|
|
overlap: typeof options.eventOverlap === "boolean" ? options.eventOverlap : void 0,
|
|
allow: options.eventAllow,
|
|
backgroundColor: options.eventBackgroundColor,
|
|
borderColor: options.eventBorderColor,
|
|
textColor: options.eventTextColor,
|
|
color: options.eventColor
|
|
}, calendarContext),
|
|
selectionConfig: createEventUi({
|
|
constraint: options.selectConstraint,
|
|
overlap: typeof options.selectOverlap === "boolean" ? options.selectOverlap : void 0,
|
|
allow: options.selectAllow
|
|
}, calendarContext)
|
|
};
|
|
}
|
|
function computeIsLoading(state, context) {
|
|
for (var _i = 0, _a = context.pluginHooks.isLoadingFuncs; _i < _a.length; _i++) {
|
|
var isLoadingFunc = _a[_i];
|
|
if (isLoadingFunc(state)) {
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
function parseContextBusinessHours(calendarContext) {
|
|
return parseBusinessHours(calendarContext.options.businessHours, calendarContext);
|
|
}
|
|
function warnUnknownOptions(options, viewName) {
|
|
for (var optionName in options) {
|
|
console.warn("Unknown option '" + optionName + "'" + (viewName ? " for view '" + viewName + "'" : ""));
|
|
}
|
|
}
|
|
var CalendarDataProvider = function(_super) {
|
|
__extends(CalendarDataProvider2, _super);
|
|
function CalendarDataProvider2(props) {
|
|
var _this = _super.call(this, props) || this;
|
|
_this.handleData = function(data) {
|
|
if (!_this.dataManager) {
|
|
_this.state = data;
|
|
} else {
|
|
_this.setState(data);
|
|
}
|
|
};
|
|
_this.dataManager = new CalendarDataManager({
|
|
optionOverrides: props.optionOverrides,
|
|
calendarApi: props.calendarApi,
|
|
onData: _this.handleData
|
|
});
|
|
return _this;
|
|
}
|
|
CalendarDataProvider2.prototype.render = function() {
|
|
return this.props.children(this.state);
|
|
};
|
|
CalendarDataProvider2.prototype.componentDidUpdate = function(prevProps) {
|
|
var newOptionOverrides = this.props.optionOverrides;
|
|
if (newOptionOverrides !== prevProps.optionOverrides) {
|
|
this.dataManager.resetOptions(newOptionOverrides);
|
|
}
|
|
};
|
|
return CalendarDataProvider2;
|
|
}(Component);
|
|
var NamedTimeZoneImpl = function() {
|
|
function NamedTimeZoneImpl2(timeZoneName) {
|
|
this.timeZoneName = timeZoneName;
|
|
}
|
|
return NamedTimeZoneImpl2;
|
|
}();
|
|
var SegHierarchy = function() {
|
|
function SegHierarchy2() {
|
|
this.strictOrder = false;
|
|
this.allowReslicing = false;
|
|
this.maxCoord = -1;
|
|
this.maxStackCnt = -1;
|
|
this.levelCoords = [];
|
|
this.entriesByLevel = [];
|
|
this.stackCnts = {};
|
|
}
|
|
SegHierarchy2.prototype.addSegs = function(inputs) {
|
|
var hiddenEntries = [];
|
|
for (var _i = 0, inputs_1 = inputs; _i < inputs_1.length; _i++) {
|
|
var input = inputs_1[_i];
|
|
this.insertEntry(input, hiddenEntries);
|
|
}
|
|
return hiddenEntries;
|
|
};
|
|
SegHierarchy2.prototype.insertEntry = function(entry, hiddenEntries) {
|
|
var insertion = this.findInsertion(entry);
|
|
if (this.isInsertionValid(insertion, entry)) {
|
|
this.insertEntryAt(entry, insertion);
|
|
return 1;
|
|
}
|
|
return this.handleInvalidInsertion(insertion, entry, hiddenEntries);
|
|
};
|
|
SegHierarchy2.prototype.isInsertionValid = function(insertion, entry) {
|
|
return (this.maxCoord === -1 || insertion.levelCoord + entry.thickness <= this.maxCoord) && (this.maxStackCnt === -1 || insertion.stackCnt < this.maxStackCnt);
|
|
};
|
|
SegHierarchy2.prototype.handleInvalidInsertion = function(insertion, entry, hiddenEntries) {
|
|
if (this.allowReslicing && insertion.touchingEntry) {
|
|
return this.splitEntry(entry, insertion.touchingEntry, hiddenEntries);
|
|
}
|
|
hiddenEntries.push(entry);
|
|
return 0;
|
|
};
|
|
SegHierarchy2.prototype.splitEntry = function(entry, barrier, hiddenEntries) {
|
|
var partCnt = 0;
|
|
var splitHiddenEntries = [];
|
|
var entrySpan = entry.span;
|
|
var barrierSpan = barrier.span;
|
|
if (entrySpan.start < barrierSpan.start) {
|
|
partCnt += this.insertEntry({
|
|
index: entry.index,
|
|
thickness: entry.thickness,
|
|
span: { start: entrySpan.start, end: barrierSpan.start }
|
|
}, splitHiddenEntries);
|
|
}
|
|
if (entrySpan.end > barrierSpan.end) {
|
|
partCnt += this.insertEntry({
|
|
index: entry.index,
|
|
thickness: entry.thickness,
|
|
span: { start: barrierSpan.end, end: entrySpan.end }
|
|
}, splitHiddenEntries);
|
|
}
|
|
if (partCnt) {
|
|
hiddenEntries.push.apply(hiddenEntries, __spreadArray([{
|
|
index: entry.index,
|
|
thickness: entry.thickness,
|
|
span: intersectSpans(barrierSpan, entrySpan)
|
|
}], splitHiddenEntries));
|
|
return partCnt;
|
|
}
|
|
hiddenEntries.push(entry);
|
|
return 0;
|
|
};
|
|
SegHierarchy2.prototype.insertEntryAt = function(entry, insertion) {
|
|
var _a = this, entriesByLevel = _a.entriesByLevel, levelCoords = _a.levelCoords;
|
|
if (insertion.lateral === -1) {
|
|
insertAt(levelCoords, insertion.level, insertion.levelCoord);
|
|
insertAt(entriesByLevel, insertion.level, [entry]);
|
|
} else {
|
|
insertAt(entriesByLevel[insertion.level], insertion.lateral, entry);
|
|
}
|
|
this.stackCnts[buildEntryKey(entry)] = insertion.stackCnt;
|
|
};
|
|
SegHierarchy2.prototype.findInsertion = function(newEntry) {
|
|
var _a = this, levelCoords = _a.levelCoords, entriesByLevel = _a.entriesByLevel, strictOrder = _a.strictOrder, stackCnts = _a.stackCnts;
|
|
var levelCnt = levelCoords.length;
|
|
var candidateCoord = 0;
|
|
var touchingLevel = -1;
|
|
var touchingLateral = -1;
|
|
var touchingEntry = null;
|
|
var stackCnt = 0;
|
|
for (var trackingLevel = 0; trackingLevel < levelCnt; trackingLevel += 1) {
|
|
var trackingCoord = levelCoords[trackingLevel];
|
|
if (!strictOrder && trackingCoord >= candidateCoord + newEntry.thickness) {
|
|
break;
|
|
}
|
|
var trackingEntries = entriesByLevel[trackingLevel];
|
|
var trackingEntry = void 0;
|
|
var searchRes = binarySearch(trackingEntries, newEntry.span.start, getEntrySpanEnd);
|
|
var lateralIndex = searchRes[0] + searchRes[1];
|
|
while ((trackingEntry = trackingEntries[lateralIndex]) && trackingEntry.span.start < newEntry.span.end) {
|
|
var trackingEntryBottom = trackingCoord + trackingEntry.thickness;
|
|
if (trackingEntryBottom > candidateCoord) {
|
|
candidateCoord = trackingEntryBottom;
|
|
touchingEntry = trackingEntry;
|
|
touchingLevel = trackingLevel;
|
|
touchingLateral = lateralIndex;
|
|
}
|
|
if (trackingEntryBottom === candidateCoord) {
|
|
stackCnt = Math.max(stackCnt, stackCnts[buildEntryKey(trackingEntry)] + 1);
|
|
}
|
|
lateralIndex += 1;
|
|
}
|
|
}
|
|
var destLevel = 0;
|
|
if (touchingEntry) {
|
|
destLevel = touchingLevel + 1;
|
|
while (destLevel < levelCnt && levelCoords[destLevel] < candidateCoord) {
|
|
destLevel += 1;
|
|
}
|
|
}
|
|
var destLateral = -1;
|
|
if (destLevel < levelCnt && levelCoords[destLevel] === candidateCoord) {
|
|
destLateral = binarySearch(entriesByLevel[destLevel], newEntry.span.end, getEntrySpanEnd)[0];
|
|
}
|
|
return {
|
|
touchingLevel,
|
|
touchingLateral,
|
|
touchingEntry,
|
|
stackCnt,
|
|
levelCoord: candidateCoord,
|
|
level: destLevel,
|
|
lateral: destLateral
|
|
};
|
|
};
|
|
SegHierarchy2.prototype.toRects = function() {
|
|
var _a = this, entriesByLevel = _a.entriesByLevel, levelCoords = _a.levelCoords;
|
|
var levelCnt = entriesByLevel.length;
|
|
var rects = [];
|
|
for (var level = 0; level < levelCnt; level += 1) {
|
|
var entries = entriesByLevel[level];
|
|
var levelCoord = levelCoords[level];
|
|
for (var _i = 0, entries_1 = entries; _i < entries_1.length; _i++) {
|
|
var entry = entries_1[_i];
|
|
rects.push(__assign(__assign({}, entry), { levelCoord }));
|
|
}
|
|
}
|
|
return rects;
|
|
};
|
|
return SegHierarchy2;
|
|
}();
|
|
function getEntrySpanEnd(entry) {
|
|
return entry.span.end;
|
|
}
|
|
function buildEntryKey(entry) {
|
|
return entry.index + ":" + entry.span.start;
|
|
}
|
|
function groupIntersectingEntries(entries) {
|
|
var merges = [];
|
|
for (var _i = 0, entries_2 = entries; _i < entries_2.length; _i++) {
|
|
var entry = entries_2[_i];
|
|
var filteredMerges = [];
|
|
var hungryMerge = {
|
|
span: entry.span,
|
|
entries: [entry]
|
|
};
|
|
for (var _a = 0, merges_1 = merges; _a < merges_1.length; _a++) {
|
|
var merge = merges_1[_a];
|
|
if (intersectSpans(merge.span, hungryMerge.span)) {
|
|
hungryMerge = {
|
|
entries: merge.entries.concat(hungryMerge.entries),
|
|
span: joinSpans(merge.span, hungryMerge.span)
|
|
};
|
|
} else {
|
|
filteredMerges.push(merge);
|
|
}
|
|
}
|
|
filteredMerges.push(hungryMerge);
|
|
merges = filteredMerges;
|
|
}
|
|
return merges;
|
|
}
|
|
function joinSpans(span0, span1) {
|
|
return {
|
|
start: Math.min(span0.start, span1.start),
|
|
end: Math.max(span0.end, span1.end)
|
|
};
|
|
}
|
|
function intersectSpans(span0, span1) {
|
|
var start = Math.max(span0.start, span1.start);
|
|
var end = Math.min(span0.end, span1.end);
|
|
if (start < end) {
|
|
return { start, end };
|
|
}
|
|
return null;
|
|
}
|
|
function insertAt(arr, index, item) {
|
|
arr.splice(index, 0, item);
|
|
}
|
|
function binarySearch(a3, searchVal, getItemVal) {
|
|
var startIndex = 0;
|
|
var endIndex = a3.length;
|
|
if (!endIndex || searchVal < getItemVal(a3[startIndex])) {
|
|
return [0, 0];
|
|
}
|
|
if (searchVal > getItemVal(a3[endIndex - 1])) {
|
|
return [endIndex, 0];
|
|
}
|
|
while (startIndex < endIndex) {
|
|
var middleIndex = Math.floor(startIndex + (endIndex - startIndex) / 2);
|
|
var middleVal = getItemVal(a3[middleIndex]);
|
|
if (searchVal < middleVal) {
|
|
endIndex = middleIndex;
|
|
} else if (searchVal > middleVal) {
|
|
startIndex = middleIndex + 1;
|
|
} else {
|
|
return [middleIndex, 1];
|
|
}
|
|
}
|
|
return [startIndex, 0];
|
|
}
|
|
var Interaction = function() {
|
|
function Interaction2(settings) {
|
|
this.component = settings.component;
|
|
this.isHitComboAllowed = settings.isHitComboAllowed || null;
|
|
}
|
|
Interaction2.prototype.destroy = function() {
|
|
};
|
|
return Interaction2;
|
|
}();
|
|
function parseInteractionSettings(component, input) {
|
|
return {
|
|
component,
|
|
el: input.el,
|
|
useEventCenter: input.useEventCenter != null ? input.useEventCenter : true,
|
|
isHitComboAllowed: input.isHitComboAllowed || null
|
|
};
|
|
}
|
|
function interactionSettingsToStore(settings) {
|
|
var _a;
|
|
return _a = {}, _a[settings.component.uid] = settings, _a;
|
|
}
|
|
var interactionSettingsStore = {};
|
|
var ElementDragging = function() {
|
|
function ElementDragging2(el, selector) {
|
|
this.emitter = new Emitter();
|
|
}
|
|
ElementDragging2.prototype.destroy = function() {
|
|
};
|
|
ElementDragging2.prototype.setMirrorIsVisible = function(bool) {
|
|
};
|
|
ElementDragging2.prototype.setMirrorNeedsRevert = function(bool) {
|
|
};
|
|
ElementDragging2.prototype.setAutoScrollEnabled = function(bool) {
|
|
};
|
|
return ElementDragging2;
|
|
}();
|
|
var config = {};
|
|
var DRAG_META_REFINERS = {
|
|
startTime: createDuration,
|
|
duration: createDuration,
|
|
create: Boolean,
|
|
sourceId: String
|
|
};
|
|
function parseDragMeta(raw) {
|
|
var _a = refineProps(raw, DRAG_META_REFINERS), refined = _a.refined, extra = _a.extra;
|
|
return {
|
|
startTime: refined.startTime || null,
|
|
duration: refined.duration || null,
|
|
create: refined.create != null ? refined.create : true,
|
|
sourceId: refined.sourceId,
|
|
leftoverProps: extra
|
|
};
|
|
}
|
|
var ToolbarSection = function(_super) {
|
|
__extends(ToolbarSection2, _super);
|
|
function ToolbarSection2() {
|
|
return _super !== null && _super.apply(this, arguments) || this;
|
|
}
|
|
ToolbarSection2.prototype.render = function() {
|
|
var _this = this;
|
|
var children = this.props.widgetGroups.map(function(widgetGroup) {
|
|
return _this.renderWidgetGroup(widgetGroup);
|
|
});
|
|
return createElement.apply(void 0, __spreadArray(["div", { className: "fc-toolbar-chunk" }], children));
|
|
};
|
|
ToolbarSection2.prototype.renderWidgetGroup = function(widgetGroup) {
|
|
var props = this.props;
|
|
var theme = this.context.theme;
|
|
var children = [];
|
|
var isOnlyButtons = true;
|
|
for (var _i = 0, widgetGroup_1 = widgetGroup; _i < widgetGroup_1.length; _i++) {
|
|
var widget = widgetGroup_1[_i];
|
|
var buttonName = widget.buttonName, buttonClick = widget.buttonClick, buttonText = widget.buttonText, buttonIcon = widget.buttonIcon, buttonHint = widget.buttonHint;
|
|
if (buttonName === "title") {
|
|
isOnlyButtons = false;
|
|
children.push(createElement("h2", { className: "fc-toolbar-title", id: props.titleId }, props.title));
|
|
} else {
|
|
var isPressed = buttonName === props.activeButton;
|
|
var isDisabled = !props.isTodayEnabled && buttonName === "today" || !props.isPrevEnabled && buttonName === "prev" || !props.isNextEnabled && buttonName === "next";
|
|
var buttonClasses = ["fc-" + buttonName + "-button", theme.getClass("button")];
|
|
if (isPressed) {
|
|
buttonClasses.push(theme.getClass("buttonActive"));
|
|
}
|
|
children.push(createElement("button", { type: "button", title: typeof buttonHint === "function" ? buttonHint(props.navUnit) : buttonHint, disabled: isDisabled, "aria-pressed": isPressed, className: buttonClasses.join(" "), onClick: buttonClick }, buttonText || (buttonIcon ? createElement("span", { className: buttonIcon }) : "")));
|
|
}
|
|
}
|
|
if (children.length > 1) {
|
|
var groupClassName = isOnlyButtons && theme.getClass("buttonGroup") || "";
|
|
return createElement.apply(void 0, __spreadArray(["div", { className: groupClassName }], children));
|
|
}
|
|
return children[0];
|
|
};
|
|
return ToolbarSection2;
|
|
}(BaseComponent);
|
|
var Toolbar = function(_super) {
|
|
__extends(Toolbar2, _super);
|
|
function Toolbar2() {
|
|
return _super !== null && _super.apply(this, arguments) || this;
|
|
}
|
|
Toolbar2.prototype.render = function() {
|
|
var _a = this.props, model = _a.model, extraClassName = _a.extraClassName;
|
|
var forceLtr = false;
|
|
var startContent;
|
|
var endContent;
|
|
var sectionWidgets = model.sectionWidgets;
|
|
var centerContent = sectionWidgets.center;
|
|
if (sectionWidgets.left) {
|
|
forceLtr = true;
|
|
startContent = sectionWidgets.left;
|
|
} else {
|
|
startContent = sectionWidgets.start;
|
|
}
|
|
if (sectionWidgets.right) {
|
|
forceLtr = true;
|
|
endContent = sectionWidgets.right;
|
|
} else {
|
|
endContent = sectionWidgets.end;
|
|
}
|
|
var classNames = [
|
|
extraClassName || "",
|
|
"fc-toolbar",
|
|
forceLtr ? "fc-toolbar-ltr" : ""
|
|
];
|
|
return createElement("div", { className: classNames.join(" ") }, this.renderSection("start", startContent || []), this.renderSection("center", centerContent || []), this.renderSection("end", endContent || []));
|
|
};
|
|
Toolbar2.prototype.renderSection = function(key, widgetGroups) {
|
|
var props = this.props;
|
|
return createElement(ToolbarSection, { key, widgetGroups, title: props.title, navUnit: props.navUnit, activeButton: props.activeButton, isTodayEnabled: props.isTodayEnabled, isPrevEnabled: props.isPrevEnabled, isNextEnabled: props.isNextEnabled, titleId: props.titleId });
|
|
};
|
|
return Toolbar2;
|
|
}(BaseComponent);
|
|
var ViewContainer = function(_super) {
|
|
__extends(ViewContainer2, _super);
|
|
function ViewContainer2() {
|
|
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
_this.state = {
|
|
availableWidth: null
|
|
};
|
|
_this.handleEl = function(el) {
|
|
_this.el = el;
|
|
setRef(_this.props.elRef, el);
|
|
_this.updateAvailableWidth();
|
|
};
|
|
_this.handleResize = function() {
|
|
_this.updateAvailableWidth();
|
|
};
|
|
return _this;
|
|
}
|
|
ViewContainer2.prototype.render = function() {
|
|
var _a = this, props = _a.props, state = _a.state;
|
|
var aspectRatio = props.aspectRatio;
|
|
var classNames = [
|
|
"fc-view-harness",
|
|
aspectRatio || props.liquid || props.height ? "fc-view-harness-active" : "fc-view-harness-passive"
|
|
];
|
|
var height = "";
|
|
var paddingBottom = "";
|
|
if (aspectRatio) {
|
|
if (state.availableWidth !== null) {
|
|
height = state.availableWidth / aspectRatio;
|
|
} else {
|
|
paddingBottom = 1 / aspectRatio * 100 + "%";
|
|
}
|
|
} else {
|
|
height = props.height || "";
|
|
}
|
|
return createElement("div", { "aria-labelledby": props.labeledById, ref: this.handleEl, className: classNames.join(" "), style: { height, paddingBottom } }, props.children);
|
|
};
|
|
ViewContainer2.prototype.componentDidMount = function() {
|
|
this.context.addResizeHandler(this.handleResize);
|
|
};
|
|
ViewContainer2.prototype.componentWillUnmount = function() {
|
|
this.context.removeResizeHandler(this.handleResize);
|
|
};
|
|
ViewContainer2.prototype.updateAvailableWidth = function() {
|
|
if (this.el && this.props.aspectRatio) {
|
|
this.setState({ availableWidth: this.el.offsetWidth });
|
|
}
|
|
};
|
|
return ViewContainer2;
|
|
}(BaseComponent);
|
|
var EventClicking = function(_super) {
|
|
__extends(EventClicking2, _super);
|
|
function EventClicking2(settings) {
|
|
var _this = _super.call(this, settings) || this;
|
|
_this.handleSegClick = function(ev, segEl) {
|
|
var component = _this.component;
|
|
var context = component.context;
|
|
var seg = getElSeg(segEl);
|
|
if (seg && component.isValidSegDownEl(ev.target)) {
|
|
var hasUrlContainer = elementClosest(ev.target, ".fc-event-forced-url");
|
|
var url = hasUrlContainer ? hasUrlContainer.querySelector("a[href]").href : "";
|
|
context.emitter.trigger("eventClick", {
|
|
el: segEl,
|
|
event: new EventApi(component.context, seg.eventRange.def, seg.eventRange.instance),
|
|
jsEvent: ev,
|
|
view: context.viewApi
|
|
});
|
|
if (url && !ev.defaultPrevented) {
|
|
window.location.href = url;
|
|
}
|
|
}
|
|
};
|
|
_this.destroy = listenBySelector(settings.el, "click", ".fc-event", _this.handleSegClick);
|
|
return _this;
|
|
}
|
|
return EventClicking2;
|
|
}(Interaction);
|
|
var EventHovering = function(_super) {
|
|
__extends(EventHovering2, _super);
|
|
function EventHovering2(settings) {
|
|
var _this = _super.call(this, settings) || this;
|
|
_this.handleEventElRemove = function(el) {
|
|
if (el === _this.currentSegEl) {
|
|
_this.handleSegLeave(null, _this.currentSegEl);
|
|
}
|
|
};
|
|
_this.handleSegEnter = function(ev, segEl) {
|
|
if (getElSeg(segEl)) {
|
|
_this.currentSegEl = segEl;
|
|
_this.triggerEvent("eventMouseEnter", ev, segEl);
|
|
}
|
|
};
|
|
_this.handleSegLeave = function(ev, segEl) {
|
|
if (_this.currentSegEl) {
|
|
_this.currentSegEl = null;
|
|
_this.triggerEvent("eventMouseLeave", ev, segEl);
|
|
}
|
|
};
|
|
_this.removeHoverListeners = listenToHoverBySelector(settings.el, ".fc-event", _this.handleSegEnter, _this.handleSegLeave);
|
|
return _this;
|
|
}
|
|
EventHovering2.prototype.destroy = function() {
|
|
this.removeHoverListeners();
|
|
};
|
|
EventHovering2.prototype.triggerEvent = function(publicEvName, ev, segEl) {
|
|
var component = this.component;
|
|
var context = component.context;
|
|
var seg = getElSeg(segEl);
|
|
if (!ev || component.isValidSegDownEl(ev.target)) {
|
|
context.emitter.trigger(publicEvName, {
|
|
el: segEl,
|
|
event: new EventApi(context, seg.eventRange.def, seg.eventRange.instance),
|
|
jsEvent: ev,
|
|
view: context.viewApi
|
|
});
|
|
}
|
|
};
|
|
return EventHovering2;
|
|
}(Interaction);
|
|
var CalendarContent = function(_super) {
|
|
__extends(CalendarContent2, _super);
|
|
function CalendarContent2() {
|
|
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
_this.buildViewContext = memoize(buildViewContext);
|
|
_this.buildViewPropTransformers = memoize(buildViewPropTransformers);
|
|
_this.buildToolbarProps = memoize(buildToolbarProps);
|
|
_this.headerRef = createRef();
|
|
_this.footerRef = createRef();
|
|
_this.interactionsStore = {};
|
|
_this.state = {
|
|
viewLabelId: getUniqueDomId()
|
|
};
|
|
_this.registerInteractiveComponent = function(component, settingsInput) {
|
|
var settings = parseInteractionSettings(component, settingsInput);
|
|
var DEFAULT_INTERACTIONS = [
|
|
EventClicking,
|
|
EventHovering
|
|
];
|
|
var interactionClasses = DEFAULT_INTERACTIONS.concat(_this.props.pluginHooks.componentInteractions);
|
|
var interactions = interactionClasses.map(function(TheInteractionClass) {
|
|
return new TheInteractionClass(settings);
|
|
});
|
|
_this.interactionsStore[component.uid] = interactions;
|
|
interactionSettingsStore[component.uid] = settings;
|
|
};
|
|
_this.unregisterInteractiveComponent = function(component) {
|
|
for (var _i = 0, _a = _this.interactionsStore[component.uid]; _i < _a.length; _i++) {
|
|
var listener = _a[_i];
|
|
listener.destroy();
|
|
}
|
|
delete _this.interactionsStore[component.uid];
|
|
delete interactionSettingsStore[component.uid];
|
|
};
|
|
_this.resizeRunner = new DelayedRunner(function() {
|
|
_this.props.emitter.trigger("_resize", true);
|
|
_this.props.emitter.trigger("windowResize", { view: _this.props.viewApi });
|
|
});
|
|
_this.handleWindowResize = function(ev) {
|
|
var options = _this.props.options;
|
|
if (options.handleWindowResize && ev.target === window) {
|
|
_this.resizeRunner.request(options.windowResizeDelay);
|
|
}
|
|
};
|
|
return _this;
|
|
}
|
|
CalendarContent2.prototype.render = function() {
|
|
var props = this.props;
|
|
var toolbarConfig = props.toolbarConfig, options = props.options;
|
|
var toolbarProps = this.buildToolbarProps(props.viewSpec, props.dateProfile, props.dateProfileGenerator, props.currentDate, getNow(props.options.now, props.dateEnv), props.viewTitle);
|
|
var viewVGrow = false;
|
|
var viewHeight = "";
|
|
var viewAspectRatio;
|
|
if (props.isHeightAuto || props.forPrint) {
|
|
viewHeight = "";
|
|
} else if (options.height != null) {
|
|
viewVGrow = true;
|
|
} else if (options.contentHeight != null) {
|
|
viewHeight = options.contentHeight;
|
|
} else {
|
|
viewAspectRatio = Math.max(options.aspectRatio, 0.5);
|
|
}
|
|
var viewContext = this.buildViewContext(props.viewSpec, props.viewApi, props.options, props.dateProfileGenerator, props.dateEnv, props.theme, props.pluginHooks, props.dispatch, props.getCurrentData, props.emitter, props.calendarApi, this.registerInteractiveComponent, this.unregisterInteractiveComponent);
|
|
var viewLabelId = toolbarConfig.header && toolbarConfig.header.hasTitle ? this.state.viewLabelId : "";
|
|
return createElement(ViewContextType.Provider, { value: viewContext }, toolbarConfig.header && createElement(Toolbar, __assign({ ref: this.headerRef, extraClassName: "fc-header-toolbar", model: toolbarConfig.header, titleId: viewLabelId }, toolbarProps)), createElement(ViewContainer, { liquid: viewVGrow, height: viewHeight, aspectRatio: viewAspectRatio, labeledById: viewLabelId }, this.renderView(props), this.buildAppendContent()), toolbarConfig.footer && createElement(Toolbar, __assign({ ref: this.footerRef, extraClassName: "fc-footer-toolbar", model: toolbarConfig.footer, titleId: "" }, toolbarProps)));
|
|
};
|
|
CalendarContent2.prototype.componentDidMount = function() {
|
|
var props = this.props;
|
|
this.calendarInteractions = props.pluginHooks.calendarInteractions.map(function(CalendarInteractionClass) {
|
|
return new CalendarInteractionClass(props);
|
|
});
|
|
window.addEventListener("resize", this.handleWindowResize);
|
|
var propSetHandlers = props.pluginHooks.propSetHandlers;
|
|
for (var propName in propSetHandlers) {
|
|
propSetHandlers[propName](props[propName], props);
|
|
}
|
|
};
|
|
CalendarContent2.prototype.componentDidUpdate = function(prevProps) {
|
|
var props = this.props;
|
|
var propSetHandlers = props.pluginHooks.propSetHandlers;
|
|
for (var propName in propSetHandlers) {
|
|
if (props[propName] !== prevProps[propName]) {
|
|
propSetHandlers[propName](props[propName], props);
|
|
}
|
|
}
|
|
};
|
|
CalendarContent2.prototype.componentWillUnmount = function() {
|
|
window.removeEventListener("resize", this.handleWindowResize);
|
|
this.resizeRunner.clear();
|
|
for (var _i = 0, _a = this.calendarInteractions; _i < _a.length; _i++) {
|
|
var interaction = _a[_i];
|
|
interaction.destroy();
|
|
}
|
|
this.props.emitter.trigger("_unmount");
|
|
};
|
|
CalendarContent2.prototype.buildAppendContent = function() {
|
|
var props = this.props;
|
|
var children = props.pluginHooks.viewContainerAppends.map(function(buildAppendContent) {
|
|
return buildAppendContent(props);
|
|
});
|
|
return createElement.apply(void 0, __spreadArray([Fragment, {}], children));
|
|
};
|
|
CalendarContent2.prototype.renderView = function(props) {
|
|
var pluginHooks = props.pluginHooks;
|
|
var viewSpec = props.viewSpec;
|
|
var viewProps = {
|
|
dateProfile: props.dateProfile,
|
|
businessHours: props.businessHours,
|
|
eventStore: props.renderableEventStore,
|
|
eventUiBases: props.eventUiBases,
|
|
dateSelection: props.dateSelection,
|
|
eventSelection: props.eventSelection,
|
|
eventDrag: props.eventDrag,
|
|
eventResize: props.eventResize,
|
|
isHeightAuto: props.isHeightAuto,
|
|
forPrint: props.forPrint
|
|
};
|
|
var transformers = this.buildViewPropTransformers(pluginHooks.viewPropsTransformers);
|
|
for (var _i = 0, transformers_1 = transformers; _i < transformers_1.length; _i++) {
|
|
var transformer = transformers_1[_i];
|
|
__assign(viewProps, transformer.transform(viewProps, props));
|
|
}
|
|
var ViewComponent = viewSpec.component;
|
|
return createElement(ViewComponent, __assign({}, viewProps));
|
|
};
|
|
return CalendarContent2;
|
|
}(PureComponent);
|
|
function buildToolbarProps(viewSpec, dateProfile, dateProfileGenerator, currentDate, now, title) {
|
|
var todayInfo = dateProfileGenerator.build(now, void 0, false);
|
|
var prevInfo = dateProfileGenerator.buildPrev(dateProfile, currentDate, false);
|
|
var nextInfo = dateProfileGenerator.buildNext(dateProfile, currentDate, false);
|
|
return {
|
|
title,
|
|
activeButton: viewSpec.type,
|
|
navUnit: viewSpec.singleUnit,
|
|
isTodayEnabled: todayInfo.isValid && !rangeContainsMarker(dateProfile.currentRange, now),
|
|
isPrevEnabled: prevInfo.isValid,
|
|
isNextEnabled: nextInfo.isValid
|
|
};
|
|
}
|
|
function buildViewPropTransformers(theClasses) {
|
|
return theClasses.map(function(TheClass) {
|
|
return new TheClass();
|
|
});
|
|
}
|
|
var CalendarRoot = function(_super) {
|
|
__extends(CalendarRoot2, _super);
|
|
function CalendarRoot2() {
|
|
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
_this.state = {
|
|
forPrint: false
|
|
};
|
|
_this.handleBeforePrint = function() {
|
|
_this.setState({ forPrint: true });
|
|
};
|
|
_this.handleAfterPrint = function() {
|
|
_this.setState({ forPrint: false });
|
|
};
|
|
return _this;
|
|
}
|
|
CalendarRoot2.prototype.render = function() {
|
|
var props = this.props;
|
|
var options = props.options;
|
|
var forPrint = this.state.forPrint;
|
|
var isHeightAuto = forPrint || options.height === "auto" || options.contentHeight === "auto";
|
|
var height = !isHeightAuto && options.height != null ? options.height : "";
|
|
var classNames = [
|
|
"fc",
|
|
forPrint ? "fc-media-print" : "fc-media-screen",
|
|
"fc-direction-" + options.direction,
|
|
props.theme.getClass("root")
|
|
];
|
|
if (!getCanVGrowWithinCell()) {
|
|
classNames.push("fc-liquid-hack");
|
|
}
|
|
return props.children(classNames, height, isHeightAuto, forPrint);
|
|
};
|
|
CalendarRoot2.prototype.componentDidMount = function() {
|
|
var emitter = this.props.emitter;
|
|
emitter.on("_beforeprint", this.handleBeforePrint);
|
|
emitter.on("_afterprint", this.handleAfterPrint);
|
|
};
|
|
CalendarRoot2.prototype.componentWillUnmount = function() {
|
|
var emitter = this.props.emitter;
|
|
emitter.off("_beforeprint", this.handleBeforePrint);
|
|
emitter.off("_afterprint", this.handleAfterPrint);
|
|
};
|
|
return CalendarRoot2;
|
|
}(BaseComponent);
|
|
function computeFallbackHeaderFormat(datesRepDistinctDays, dayCnt) {
|
|
if (!datesRepDistinctDays || dayCnt > 10) {
|
|
return createFormatter({ weekday: "short" });
|
|
}
|
|
if (dayCnt > 1) {
|
|
return createFormatter({ weekday: "short", month: "numeric", day: "numeric", omitCommas: true });
|
|
}
|
|
return createFormatter({ weekday: "long" });
|
|
}
|
|
var CLASS_NAME = "fc-col-header-cell";
|
|
function renderInner$1(hookProps) {
|
|
return hookProps.text;
|
|
}
|
|
var TableDateCell = function(_super) {
|
|
__extends(TableDateCell2, _super);
|
|
function TableDateCell2() {
|
|
return _super !== null && _super.apply(this, arguments) || this;
|
|
}
|
|
TableDateCell2.prototype.render = function() {
|
|
var _a = this.context, dateEnv = _a.dateEnv, options = _a.options, theme = _a.theme, viewApi = _a.viewApi;
|
|
var props = this.props;
|
|
var date = props.date, dateProfile = props.dateProfile;
|
|
var dayMeta = getDateMeta(date, props.todayRange, null, dateProfile);
|
|
var classNames = [CLASS_NAME].concat(getDayClassNames(dayMeta, theme));
|
|
var text = dateEnv.format(date, props.dayHeaderFormat);
|
|
var navLinkAttrs = !dayMeta.isDisabled && props.colCnt > 1 ? buildNavLinkAttrs(this.context, date) : {};
|
|
var hookProps = __assign(__assign(__assign({ date: dateEnv.toDate(date), view: viewApi }, props.extraHookProps), { text }), dayMeta);
|
|
return createElement(RenderHook, { hookProps, classNames: options.dayHeaderClassNames, content: options.dayHeaderContent, defaultContent: renderInner$1, didMount: options.dayHeaderDidMount, willUnmount: options.dayHeaderWillUnmount }, function(rootElRef, customClassNames, innerElRef, innerContent) {
|
|
return createElement("th", __assign({ ref: rootElRef, role: "columnheader", className: classNames.concat(customClassNames).join(" "), "data-date": !dayMeta.isDisabled ? formatDayString(date) : void 0, colSpan: props.colSpan }, props.extraDataAttrs), createElement("div", { className: "fc-scrollgrid-sync-inner" }, !dayMeta.isDisabled && createElement("a", __assign({ ref: innerElRef, className: [
|
|
"fc-col-header-cell-cushion",
|
|
props.isSticky ? "fc-sticky" : ""
|
|
].join(" ") }, navLinkAttrs), innerContent)));
|
|
});
|
|
};
|
|
return TableDateCell2;
|
|
}(BaseComponent);
|
|
var WEEKDAY_FORMAT = createFormatter({ weekday: "long" });
|
|
var TableDowCell = function(_super) {
|
|
__extends(TableDowCell2, _super);
|
|
function TableDowCell2() {
|
|
return _super !== null && _super.apply(this, arguments) || this;
|
|
}
|
|
TableDowCell2.prototype.render = function() {
|
|
var props = this.props;
|
|
var _a = this.context, dateEnv = _a.dateEnv, theme = _a.theme, viewApi = _a.viewApi, options = _a.options;
|
|
var date = addDays(new Date(2592e5), props.dow);
|
|
var dateMeta = {
|
|
dow: props.dow,
|
|
isDisabled: false,
|
|
isFuture: false,
|
|
isPast: false,
|
|
isToday: false,
|
|
isOther: false
|
|
};
|
|
var classNames = [CLASS_NAME].concat(getDayClassNames(dateMeta, theme), props.extraClassNames || []);
|
|
var text = dateEnv.format(date, props.dayHeaderFormat);
|
|
var hookProps = __assign(__assign(__assign(__assign({
|
|
date
|
|
}, dateMeta), { view: viewApi }), props.extraHookProps), { text });
|
|
return createElement(RenderHook, { hookProps, classNames: options.dayHeaderClassNames, content: options.dayHeaderContent, defaultContent: renderInner$1, didMount: options.dayHeaderDidMount, willUnmount: options.dayHeaderWillUnmount }, function(rootElRef, customClassNames, innerElRef, innerContent) {
|
|
return createElement("th", __assign({ ref: rootElRef, role: "columnheader", className: classNames.concat(customClassNames).join(" "), colSpan: props.colSpan }, props.extraDataAttrs), createElement("div", { className: "fc-scrollgrid-sync-inner" }, createElement("a", { "aria-label": dateEnv.format(date, WEEKDAY_FORMAT), className: [
|
|
"fc-col-header-cell-cushion",
|
|
props.isSticky ? "fc-sticky" : ""
|
|
].join(" "), ref: innerElRef }, innerContent)));
|
|
});
|
|
};
|
|
return TableDowCell2;
|
|
}(BaseComponent);
|
|
var NowTimer = function(_super) {
|
|
__extends(NowTimer2, _super);
|
|
function NowTimer2(props, context) {
|
|
var _this = _super.call(this, props, context) || this;
|
|
_this.initialNowDate = getNow(context.options.now, context.dateEnv);
|
|
_this.initialNowQueriedMs = new Date().valueOf();
|
|
_this.state = _this.computeTiming().currentState;
|
|
return _this;
|
|
}
|
|
NowTimer2.prototype.render = function() {
|
|
var _a = this, props = _a.props, state = _a.state;
|
|
return props.children(state.nowDate, state.todayRange);
|
|
};
|
|
NowTimer2.prototype.componentDidMount = function() {
|
|
this.setTimeout();
|
|
};
|
|
NowTimer2.prototype.componentDidUpdate = function(prevProps) {
|
|
if (prevProps.unit !== this.props.unit) {
|
|
this.clearTimeout();
|
|
this.setTimeout();
|
|
}
|
|
};
|
|
NowTimer2.prototype.componentWillUnmount = function() {
|
|
this.clearTimeout();
|
|
};
|
|
NowTimer2.prototype.computeTiming = function() {
|
|
var _a = this, props = _a.props, context = _a.context;
|
|
var unroundedNow = addMs(this.initialNowDate, new Date().valueOf() - this.initialNowQueriedMs);
|
|
var currentUnitStart = context.dateEnv.startOf(unroundedNow, props.unit);
|
|
var nextUnitStart = context.dateEnv.add(currentUnitStart, createDuration(1, props.unit));
|
|
var waitMs = nextUnitStart.valueOf() - unroundedNow.valueOf();
|
|
waitMs = Math.min(1e3 * 60 * 60 * 24, waitMs);
|
|
return {
|
|
currentState: { nowDate: currentUnitStart, todayRange: buildDayRange(currentUnitStart) },
|
|
nextState: { nowDate: nextUnitStart, todayRange: buildDayRange(nextUnitStart) },
|
|
waitMs
|
|
};
|
|
};
|
|
NowTimer2.prototype.setTimeout = function() {
|
|
var _this = this;
|
|
var _a = this.computeTiming(), nextState = _a.nextState, waitMs = _a.waitMs;
|
|
this.timeoutId = setTimeout(function() {
|
|
_this.setState(nextState, function() {
|
|
_this.setTimeout();
|
|
});
|
|
}, waitMs);
|
|
};
|
|
NowTimer2.prototype.clearTimeout = function() {
|
|
if (this.timeoutId) {
|
|
clearTimeout(this.timeoutId);
|
|
}
|
|
};
|
|
NowTimer2.contextType = ViewContextType;
|
|
return NowTimer2;
|
|
}(Component);
|
|
function buildDayRange(date) {
|
|
var start = startOfDay(date);
|
|
var end = addDays(start, 1);
|
|
return { start, end };
|
|
}
|
|
var DayHeader = function(_super) {
|
|
__extends(DayHeader2, _super);
|
|
function DayHeader2() {
|
|
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
_this.createDayHeaderFormatter = memoize(createDayHeaderFormatter);
|
|
return _this;
|
|
}
|
|
DayHeader2.prototype.render = function() {
|
|
var context = this.context;
|
|
var _a = this.props, dates = _a.dates, dateProfile = _a.dateProfile, datesRepDistinctDays = _a.datesRepDistinctDays, renderIntro = _a.renderIntro;
|
|
var dayHeaderFormat = this.createDayHeaderFormatter(context.options.dayHeaderFormat, datesRepDistinctDays, dates.length);
|
|
return createElement(NowTimer, { unit: "day" }, function(nowDate, todayRange) {
|
|
return createElement("tr", { role: "row" }, renderIntro && renderIntro("day"), dates.map(function(date) {
|
|
return datesRepDistinctDays ? createElement(TableDateCell, { key: date.toISOString(), date, dateProfile, todayRange, colCnt: dates.length, dayHeaderFormat }) : createElement(TableDowCell, { key: date.getUTCDay(), dow: date.getUTCDay(), dayHeaderFormat });
|
|
}));
|
|
});
|
|
};
|
|
return DayHeader2;
|
|
}(BaseComponent);
|
|
function createDayHeaderFormatter(explicitFormat, datesRepDistinctDays, dateCnt) {
|
|
return explicitFormat || computeFallbackHeaderFormat(datesRepDistinctDays, dateCnt);
|
|
}
|
|
var DaySeriesModel = function() {
|
|
function DaySeriesModel2(range, dateProfileGenerator) {
|
|
var date = range.start;
|
|
var end = range.end;
|
|
var indices = [];
|
|
var dates = [];
|
|
var dayIndex = -1;
|
|
while (date < end) {
|
|
if (dateProfileGenerator.isHiddenDay(date)) {
|
|
indices.push(dayIndex + 0.5);
|
|
} else {
|
|
dayIndex += 1;
|
|
indices.push(dayIndex);
|
|
dates.push(date);
|
|
}
|
|
date = addDays(date, 1);
|
|
}
|
|
this.dates = dates;
|
|
this.indices = indices;
|
|
this.cnt = dates.length;
|
|
}
|
|
DaySeriesModel2.prototype.sliceRange = function(range) {
|
|
var firstIndex = this.getDateDayIndex(range.start);
|
|
var lastIndex = this.getDateDayIndex(addDays(range.end, -1));
|
|
var clippedFirstIndex = Math.max(0, firstIndex);
|
|
var clippedLastIndex = Math.min(this.cnt - 1, lastIndex);
|
|
clippedFirstIndex = Math.ceil(clippedFirstIndex);
|
|
clippedLastIndex = Math.floor(clippedLastIndex);
|
|
if (clippedFirstIndex <= clippedLastIndex) {
|
|
return {
|
|
firstIndex: clippedFirstIndex,
|
|
lastIndex: clippedLastIndex,
|
|
isStart: firstIndex === clippedFirstIndex,
|
|
isEnd: lastIndex === clippedLastIndex
|
|
};
|
|
}
|
|
return null;
|
|
};
|
|
DaySeriesModel2.prototype.getDateDayIndex = function(date) {
|
|
var indices = this.indices;
|
|
var dayOffset = Math.floor(diffDays(this.dates[0], date));
|
|
if (dayOffset < 0) {
|
|
return indices[0] - 1;
|
|
}
|
|
if (dayOffset >= indices.length) {
|
|
return indices[indices.length - 1] + 1;
|
|
}
|
|
return indices[dayOffset];
|
|
};
|
|
return DaySeriesModel2;
|
|
}();
|
|
var DayTableModel = function() {
|
|
function DayTableModel2(daySeries, breakOnWeeks) {
|
|
var dates = daySeries.dates;
|
|
var daysPerRow;
|
|
var firstDay;
|
|
var rowCnt;
|
|
if (breakOnWeeks) {
|
|
firstDay = dates[0].getUTCDay();
|
|
for (daysPerRow = 1; daysPerRow < dates.length; daysPerRow += 1) {
|
|
if (dates[daysPerRow].getUTCDay() === firstDay) {
|
|
break;
|
|
}
|
|
}
|
|
rowCnt = Math.ceil(dates.length / daysPerRow);
|
|
} else {
|
|
rowCnt = 1;
|
|
daysPerRow = dates.length;
|
|
}
|
|
this.rowCnt = rowCnt;
|
|
this.colCnt = daysPerRow;
|
|
this.daySeries = daySeries;
|
|
this.cells = this.buildCells();
|
|
this.headerDates = this.buildHeaderDates();
|
|
}
|
|
DayTableModel2.prototype.buildCells = function() {
|
|
var rows = [];
|
|
for (var row = 0; row < this.rowCnt; row += 1) {
|
|
var cells = [];
|
|
for (var col = 0; col < this.colCnt; col += 1) {
|
|
cells.push(this.buildCell(row, col));
|
|
}
|
|
rows.push(cells);
|
|
}
|
|
return rows;
|
|
};
|
|
DayTableModel2.prototype.buildCell = function(row, col) {
|
|
var date = this.daySeries.dates[row * this.colCnt + col];
|
|
return {
|
|
key: date.toISOString(),
|
|
date
|
|
};
|
|
};
|
|
DayTableModel2.prototype.buildHeaderDates = function() {
|
|
var dates = [];
|
|
for (var col = 0; col < this.colCnt; col += 1) {
|
|
dates.push(this.cells[0][col].date);
|
|
}
|
|
return dates;
|
|
};
|
|
DayTableModel2.prototype.sliceRange = function(range) {
|
|
var colCnt = this.colCnt;
|
|
var seriesSeg = this.daySeries.sliceRange(range);
|
|
var segs = [];
|
|
if (seriesSeg) {
|
|
var firstIndex = seriesSeg.firstIndex, lastIndex = seriesSeg.lastIndex;
|
|
var index = firstIndex;
|
|
while (index <= lastIndex) {
|
|
var row = Math.floor(index / colCnt);
|
|
var nextIndex = Math.min((row + 1) * colCnt, lastIndex + 1);
|
|
segs.push({
|
|
row,
|
|
firstCol: index % colCnt,
|
|
lastCol: (nextIndex - 1) % colCnt,
|
|
isStart: seriesSeg.isStart && index === firstIndex,
|
|
isEnd: seriesSeg.isEnd && nextIndex - 1 === lastIndex
|
|
});
|
|
index = nextIndex;
|
|
}
|
|
}
|
|
return segs;
|
|
};
|
|
return DayTableModel2;
|
|
}();
|
|
var Slicer = function() {
|
|
function Slicer2() {
|
|
this.sliceBusinessHours = memoize(this._sliceBusinessHours);
|
|
this.sliceDateSelection = memoize(this._sliceDateSpan);
|
|
this.sliceEventStore = memoize(this._sliceEventStore);
|
|
this.sliceEventDrag = memoize(this._sliceInteraction);
|
|
this.sliceEventResize = memoize(this._sliceInteraction);
|
|
this.forceDayIfListItem = false;
|
|
}
|
|
Slicer2.prototype.sliceProps = function(props, dateProfile, nextDayThreshold, context) {
|
|
var extraArgs = [];
|
|
for (var _i = 4; _i < arguments.length; _i++) {
|
|
extraArgs[_i - 4] = arguments[_i];
|
|
}
|
|
var eventUiBases = props.eventUiBases;
|
|
var eventSegs = this.sliceEventStore.apply(this, __spreadArray([props.eventStore, eventUiBases, dateProfile, nextDayThreshold], extraArgs));
|
|
return {
|
|
dateSelectionSegs: this.sliceDateSelection.apply(this, __spreadArray([props.dateSelection, eventUiBases, context], extraArgs)),
|
|
businessHourSegs: this.sliceBusinessHours.apply(this, __spreadArray([props.businessHours, dateProfile, nextDayThreshold, context], extraArgs)),
|
|
fgEventSegs: eventSegs.fg,
|
|
bgEventSegs: eventSegs.bg,
|
|
eventDrag: this.sliceEventDrag.apply(this, __spreadArray([props.eventDrag, eventUiBases, dateProfile, nextDayThreshold], extraArgs)),
|
|
eventResize: this.sliceEventResize.apply(this, __spreadArray([props.eventResize, eventUiBases, dateProfile, nextDayThreshold], extraArgs)),
|
|
eventSelection: props.eventSelection
|
|
};
|
|
};
|
|
Slicer2.prototype.sliceNowDate = function(date, context) {
|
|
var extraArgs = [];
|
|
for (var _i = 2; _i < arguments.length; _i++) {
|
|
extraArgs[_i - 2] = arguments[_i];
|
|
}
|
|
return this._sliceDateSpan.apply(this, __spreadArray([
|
|
{ range: { start: date, end: addMs(date, 1) }, allDay: false },
|
|
{},
|
|
context
|
|
], extraArgs));
|
|
};
|
|
Slicer2.prototype._sliceBusinessHours = function(businessHours, dateProfile, nextDayThreshold, context) {
|
|
var extraArgs = [];
|
|
for (var _i = 4; _i < arguments.length; _i++) {
|
|
extraArgs[_i - 4] = arguments[_i];
|
|
}
|
|
if (!businessHours) {
|
|
return [];
|
|
}
|
|
return this._sliceEventStore.apply(this, __spreadArray([
|
|
expandRecurring(businessHours, computeActiveRange(dateProfile, Boolean(nextDayThreshold)), context),
|
|
{},
|
|
dateProfile,
|
|
nextDayThreshold
|
|
], extraArgs)).bg;
|
|
};
|
|
Slicer2.prototype._sliceEventStore = function(eventStore, eventUiBases, dateProfile, nextDayThreshold) {
|
|
var extraArgs = [];
|
|
for (var _i = 4; _i < arguments.length; _i++) {
|
|
extraArgs[_i - 4] = arguments[_i];
|
|
}
|
|
if (eventStore) {
|
|
var rangeRes = sliceEventStore(eventStore, eventUiBases, computeActiveRange(dateProfile, Boolean(nextDayThreshold)), nextDayThreshold);
|
|
return {
|
|
bg: this.sliceEventRanges(rangeRes.bg, extraArgs),
|
|
fg: this.sliceEventRanges(rangeRes.fg, extraArgs)
|
|
};
|
|
}
|
|
return { bg: [], fg: [] };
|
|
};
|
|
Slicer2.prototype._sliceInteraction = function(interaction, eventUiBases, dateProfile, nextDayThreshold) {
|
|
var extraArgs = [];
|
|
for (var _i = 4; _i < arguments.length; _i++) {
|
|
extraArgs[_i - 4] = arguments[_i];
|
|
}
|
|
if (!interaction) {
|
|
return null;
|
|
}
|
|
var rangeRes = sliceEventStore(interaction.mutatedEvents, eventUiBases, computeActiveRange(dateProfile, Boolean(nextDayThreshold)), nextDayThreshold);
|
|
return {
|
|
segs: this.sliceEventRanges(rangeRes.fg, extraArgs),
|
|
affectedInstances: interaction.affectedEvents.instances,
|
|
isEvent: interaction.isEvent
|
|
};
|
|
};
|
|
Slicer2.prototype._sliceDateSpan = function(dateSpan, eventUiBases, context) {
|
|
var extraArgs = [];
|
|
for (var _i = 3; _i < arguments.length; _i++) {
|
|
extraArgs[_i - 3] = arguments[_i];
|
|
}
|
|
if (!dateSpan) {
|
|
return [];
|
|
}
|
|
var eventRange = fabricateEventRange(dateSpan, eventUiBases, context);
|
|
var segs = this.sliceRange.apply(this, __spreadArray([dateSpan.range], extraArgs));
|
|
for (var _a = 0, segs_1 = segs; _a < segs_1.length; _a++) {
|
|
var seg = segs_1[_a];
|
|
seg.eventRange = eventRange;
|
|
}
|
|
return segs;
|
|
};
|
|
Slicer2.prototype.sliceEventRanges = function(eventRanges, extraArgs) {
|
|
var segs = [];
|
|
for (var _i = 0, eventRanges_1 = eventRanges; _i < eventRanges_1.length; _i++) {
|
|
var eventRange = eventRanges_1[_i];
|
|
segs.push.apply(segs, this.sliceEventRange(eventRange, extraArgs));
|
|
}
|
|
return segs;
|
|
};
|
|
Slicer2.prototype.sliceEventRange = function(eventRange, extraArgs) {
|
|
var dateRange = eventRange.range;
|
|
if (this.forceDayIfListItem && eventRange.ui.display === "list-item") {
|
|
dateRange = {
|
|
start: dateRange.start,
|
|
end: addDays(dateRange.start, 1)
|
|
};
|
|
}
|
|
var segs = this.sliceRange.apply(this, __spreadArray([dateRange], extraArgs));
|
|
for (var _i = 0, segs_2 = segs; _i < segs_2.length; _i++) {
|
|
var seg = segs_2[_i];
|
|
seg.eventRange = eventRange;
|
|
seg.isStart = eventRange.isStart && seg.isStart;
|
|
seg.isEnd = eventRange.isEnd && seg.isEnd;
|
|
}
|
|
return segs;
|
|
};
|
|
return Slicer2;
|
|
}();
|
|
function computeActiveRange(dateProfile, isComponentAllDay) {
|
|
var range = dateProfile.activeRange;
|
|
if (isComponentAllDay) {
|
|
return range;
|
|
}
|
|
return {
|
|
start: addMs(range.start, dateProfile.slotMinTime.milliseconds),
|
|
end: addMs(range.end, dateProfile.slotMaxTime.milliseconds - 864e5)
|
|
};
|
|
}
|
|
function isInteractionValid(interaction, dateProfile, context) {
|
|
var instances = interaction.mutatedEvents.instances;
|
|
for (var instanceId in instances) {
|
|
if (!rangeContainsRange(dateProfile.validRange, instances[instanceId].range)) {
|
|
return false;
|
|
}
|
|
}
|
|
return isNewPropsValid({ eventDrag: interaction }, context);
|
|
}
|
|
function isDateSelectionValid(dateSelection, dateProfile, context) {
|
|
if (!rangeContainsRange(dateProfile.validRange, dateSelection.range)) {
|
|
return false;
|
|
}
|
|
return isNewPropsValid({ dateSelection }, context);
|
|
}
|
|
function isNewPropsValid(newProps, context) {
|
|
var calendarState = context.getCurrentData();
|
|
var props = __assign({ businessHours: calendarState.businessHours, dateSelection: "", eventStore: calendarState.eventStore, eventUiBases: calendarState.eventUiBases, eventSelection: "", eventDrag: null, eventResize: null }, newProps);
|
|
return (context.pluginHooks.isPropsValid || isPropsValid)(props, context);
|
|
}
|
|
function isPropsValid(state, context, dateSpanMeta, filterConfig) {
|
|
if (dateSpanMeta === void 0) {
|
|
dateSpanMeta = {};
|
|
}
|
|
if (state.eventDrag && !isInteractionPropsValid(state, context, dateSpanMeta, filterConfig)) {
|
|
return false;
|
|
}
|
|
if (state.dateSelection && !isDateSelectionPropsValid(state, context, dateSpanMeta, filterConfig)) {
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
function isInteractionPropsValid(state, context, dateSpanMeta, filterConfig) {
|
|
var currentState = context.getCurrentData();
|
|
var interaction = state.eventDrag;
|
|
var subjectEventStore = interaction.mutatedEvents;
|
|
var subjectDefs = subjectEventStore.defs;
|
|
var subjectInstances = subjectEventStore.instances;
|
|
var subjectConfigs = compileEventUis(subjectDefs, interaction.isEvent ? state.eventUiBases : { "": currentState.selectionConfig });
|
|
if (filterConfig) {
|
|
subjectConfigs = mapHash(subjectConfigs, filterConfig);
|
|
}
|
|
var otherEventStore = excludeInstances(state.eventStore, interaction.affectedEvents.instances);
|
|
var otherDefs = otherEventStore.defs;
|
|
var otherInstances = otherEventStore.instances;
|
|
var otherConfigs = compileEventUis(otherDefs, state.eventUiBases);
|
|
for (var subjectInstanceId in subjectInstances) {
|
|
var subjectInstance = subjectInstances[subjectInstanceId];
|
|
var subjectRange = subjectInstance.range;
|
|
var subjectConfig = subjectConfigs[subjectInstance.defId];
|
|
var subjectDef = subjectDefs[subjectInstance.defId];
|
|
if (!allConstraintsPass(subjectConfig.constraints, subjectRange, otherEventStore, state.businessHours, context)) {
|
|
return false;
|
|
}
|
|
var eventOverlap = context.options.eventOverlap;
|
|
var eventOverlapFunc = typeof eventOverlap === "function" ? eventOverlap : null;
|
|
for (var otherInstanceId in otherInstances) {
|
|
var otherInstance = otherInstances[otherInstanceId];
|
|
if (rangesIntersect(subjectRange, otherInstance.range)) {
|
|
var otherOverlap = otherConfigs[otherInstance.defId].overlap;
|
|
if (otherOverlap === false && interaction.isEvent) {
|
|
return false;
|
|
}
|
|
if (subjectConfig.overlap === false) {
|
|
return false;
|
|
}
|
|
if (eventOverlapFunc && !eventOverlapFunc(new EventApi(context, otherDefs[otherInstance.defId], otherInstance), new EventApi(context, subjectDef, subjectInstance))) {
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
var calendarEventStore = currentState.eventStore;
|
|
for (var _i = 0, _a = subjectConfig.allows; _i < _a.length; _i++) {
|
|
var subjectAllow = _a[_i];
|
|
var subjectDateSpan = __assign(__assign({}, dateSpanMeta), { range: subjectInstance.range, allDay: subjectDef.allDay });
|
|
var origDef = calendarEventStore.defs[subjectDef.defId];
|
|
var origInstance = calendarEventStore.instances[subjectInstanceId];
|
|
var eventApi = void 0;
|
|
if (origDef) {
|
|
eventApi = new EventApi(context, origDef, origInstance);
|
|
} else {
|
|
eventApi = new EventApi(context, subjectDef);
|
|
}
|
|
if (!subjectAllow(buildDateSpanApiWithContext(subjectDateSpan, context), eventApi)) {
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
function isDateSelectionPropsValid(state, context, dateSpanMeta, filterConfig) {
|
|
var relevantEventStore = state.eventStore;
|
|
var relevantDefs = relevantEventStore.defs;
|
|
var relevantInstances = relevantEventStore.instances;
|
|
var selection = state.dateSelection;
|
|
var selectionRange = selection.range;
|
|
var selectionConfig = context.getCurrentData().selectionConfig;
|
|
if (filterConfig) {
|
|
selectionConfig = filterConfig(selectionConfig);
|
|
}
|
|
if (!allConstraintsPass(selectionConfig.constraints, selectionRange, relevantEventStore, state.businessHours, context)) {
|
|
return false;
|
|
}
|
|
var selectOverlap = context.options.selectOverlap;
|
|
var selectOverlapFunc = typeof selectOverlap === "function" ? selectOverlap : null;
|
|
for (var relevantInstanceId in relevantInstances) {
|
|
var relevantInstance = relevantInstances[relevantInstanceId];
|
|
if (rangesIntersect(selectionRange, relevantInstance.range)) {
|
|
if (selectionConfig.overlap === false) {
|
|
return false;
|
|
}
|
|
if (selectOverlapFunc && !selectOverlapFunc(new EventApi(context, relevantDefs[relevantInstance.defId], relevantInstance), null)) {
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
for (var _i = 0, _a = selectionConfig.allows; _i < _a.length; _i++) {
|
|
var selectionAllow = _a[_i];
|
|
var fullDateSpan = __assign(__assign({}, dateSpanMeta), selection);
|
|
if (!selectionAllow(buildDateSpanApiWithContext(fullDateSpan, context), null)) {
|
|
return false;
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
function allConstraintsPass(constraints, subjectRange, otherEventStore, businessHoursUnexpanded, context) {
|
|
for (var _i = 0, constraints_1 = constraints; _i < constraints_1.length; _i++) {
|
|
var constraint = constraints_1[_i];
|
|
if (!anyRangesContainRange(constraintToRanges(constraint, subjectRange, otherEventStore, businessHoursUnexpanded, context), subjectRange)) {
|
|
return false;
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
function constraintToRanges(constraint, subjectRange, otherEventStore, businessHoursUnexpanded, context) {
|
|
if (constraint === "businessHours") {
|
|
return eventStoreToRanges(expandRecurring(businessHoursUnexpanded, subjectRange, context));
|
|
}
|
|
if (typeof constraint === "string") {
|
|
return eventStoreToRanges(filterEventStoreDefs(otherEventStore, function(eventDef) {
|
|
return eventDef.groupId === constraint;
|
|
}));
|
|
}
|
|
if (typeof constraint === "object" && constraint) {
|
|
return eventStoreToRanges(expandRecurring(constraint, subjectRange, context));
|
|
}
|
|
return [];
|
|
}
|
|
function eventStoreToRanges(eventStore) {
|
|
var instances = eventStore.instances;
|
|
var ranges = [];
|
|
for (var instanceId in instances) {
|
|
ranges.push(instances[instanceId].range);
|
|
}
|
|
return ranges;
|
|
}
|
|
function anyRangesContainRange(outerRanges, innerRange) {
|
|
for (var _i = 0, outerRanges_1 = outerRanges; _i < outerRanges_1.length; _i++) {
|
|
var outerRange = outerRanges_1[_i];
|
|
if (rangeContainsRange(outerRange, innerRange)) {
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
var VISIBLE_HIDDEN_RE = /^(visible|hidden)$/;
|
|
var Scroller = function(_super) {
|
|
__extends(Scroller2, _super);
|
|
function Scroller2() {
|
|
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
_this.handleEl = function(el) {
|
|
_this.el = el;
|
|
setRef(_this.props.elRef, el);
|
|
};
|
|
return _this;
|
|
}
|
|
Scroller2.prototype.render = function() {
|
|
var props = this.props;
|
|
var liquid = props.liquid, liquidIsAbsolute = props.liquidIsAbsolute;
|
|
var isAbsolute = liquid && liquidIsAbsolute;
|
|
var className = ["fc-scroller"];
|
|
if (liquid) {
|
|
if (liquidIsAbsolute) {
|
|
className.push("fc-scroller-liquid-absolute");
|
|
} else {
|
|
className.push("fc-scroller-liquid");
|
|
}
|
|
}
|
|
return createElement("div", { ref: this.handleEl, className: className.join(" "), style: {
|
|
overflowX: props.overflowX,
|
|
overflowY: props.overflowY,
|
|
left: isAbsolute && -(props.overcomeLeft || 0) || "",
|
|
right: isAbsolute && -(props.overcomeRight || 0) || "",
|
|
bottom: isAbsolute && -(props.overcomeBottom || 0) || "",
|
|
marginLeft: !isAbsolute && -(props.overcomeLeft || 0) || "",
|
|
marginRight: !isAbsolute && -(props.overcomeRight || 0) || "",
|
|
marginBottom: !isAbsolute && -(props.overcomeBottom || 0) || "",
|
|
maxHeight: props.maxHeight || ""
|
|
} }, props.children);
|
|
};
|
|
Scroller2.prototype.needsXScrolling = function() {
|
|
if (VISIBLE_HIDDEN_RE.test(this.props.overflowX)) {
|
|
return false;
|
|
}
|
|
var el = this.el;
|
|
var realClientWidth = this.el.getBoundingClientRect().width - this.getYScrollbarWidth();
|
|
var children = el.children;
|
|
for (var i3 = 0; i3 < children.length; i3 += 1) {
|
|
var childEl = children[i3];
|
|
if (childEl.getBoundingClientRect().width > realClientWidth) {
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
};
|
|
Scroller2.prototype.needsYScrolling = function() {
|
|
if (VISIBLE_HIDDEN_RE.test(this.props.overflowY)) {
|
|
return false;
|
|
}
|
|
var el = this.el;
|
|
var realClientHeight = this.el.getBoundingClientRect().height - this.getXScrollbarWidth();
|
|
var children = el.children;
|
|
for (var i3 = 0; i3 < children.length; i3 += 1) {
|
|
var childEl = children[i3];
|
|
if (childEl.getBoundingClientRect().height > realClientHeight) {
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
};
|
|
Scroller2.prototype.getXScrollbarWidth = function() {
|
|
if (VISIBLE_HIDDEN_RE.test(this.props.overflowX)) {
|
|
return 0;
|
|
}
|
|
return this.el.offsetHeight - this.el.clientHeight;
|
|
};
|
|
Scroller2.prototype.getYScrollbarWidth = function() {
|
|
if (VISIBLE_HIDDEN_RE.test(this.props.overflowY)) {
|
|
return 0;
|
|
}
|
|
return this.el.offsetWidth - this.el.clientWidth;
|
|
};
|
|
return Scroller2;
|
|
}(BaseComponent);
|
|
var RefMap = function() {
|
|
function RefMap2(masterCallback) {
|
|
var _this = this;
|
|
this.masterCallback = masterCallback;
|
|
this.currentMap = {};
|
|
this.depths = {};
|
|
this.callbackMap = {};
|
|
this.handleValue = function(val, key) {
|
|
var _a = _this, depths = _a.depths, currentMap = _a.currentMap;
|
|
var removed = false;
|
|
var added = false;
|
|
if (val !== null) {
|
|
removed = key in currentMap;
|
|
currentMap[key] = val;
|
|
depths[key] = (depths[key] || 0) + 1;
|
|
added = true;
|
|
} else {
|
|
depths[key] -= 1;
|
|
if (!depths[key]) {
|
|
delete currentMap[key];
|
|
delete _this.callbackMap[key];
|
|
removed = true;
|
|
}
|
|
}
|
|
if (_this.masterCallback) {
|
|
if (removed) {
|
|
_this.masterCallback(null, String(key));
|
|
}
|
|
if (added) {
|
|
_this.masterCallback(val, String(key));
|
|
}
|
|
}
|
|
};
|
|
}
|
|
RefMap2.prototype.createRef = function(key) {
|
|
var _this = this;
|
|
var refCallback = this.callbackMap[key];
|
|
if (!refCallback) {
|
|
refCallback = this.callbackMap[key] = function(val) {
|
|
_this.handleValue(val, String(key));
|
|
};
|
|
}
|
|
return refCallback;
|
|
};
|
|
RefMap2.prototype.collect = function(startIndex, endIndex, step) {
|
|
return collectFromHash(this.currentMap, startIndex, endIndex, step);
|
|
};
|
|
RefMap2.prototype.getAll = function() {
|
|
return hashValuesToArray(this.currentMap);
|
|
};
|
|
return RefMap2;
|
|
}();
|
|
function computeShrinkWidth(chunkEls) {
|
|
var shrinkCells = findElements(chunkEls, ".fc-scrollgrid-shrink");
|
|
var largestWidth = 0;
|
|
for (var _i = 0, shrinkCells_1 = shrinkCells; _i < shrinkCells_1.length; _i++) {
|
|
var shrinkCell = shrinkCells_1[_i];
|
|
largestWidth = Math.max(largestWidth, computeSmallestCellWidth(shrinkCell));
|
|
}
|
|
return Math.ceil(largestWidth);
|
|
}
|
|
function getSectionHasLiquidHeight(props, sectionConfig) {
|
|
return props.liquid && sectionConfig.liquid;
|
|
}
|
|
function getAllowYScrolling(props, sectionConfig) {
|
|
return sectionConfig.maxHeight != null || getSectionHasLiquidHeight(props, sectionConfig);
|
|
}
|
|
function renderChunkContent(sectionConfig, chunkConfig, arg, isHeader) {
|
|
var expandRows = arg.expandRows;
|
|
var content = typeof chunkConfig.content === "function" ? chunkConfig.content(arg) : createElement("table", {
|
|
role: "presentation",
|
|
className: [
|
|
chunkConfig.tableClassName,
|
|
sectionConfig.syncRowHeights ? "fc-scrollgrid-sync-table" : ""
|
|
].join(" "),
|
|
style: {
|
|
minWidth: arg.tableMinWidth,
|
|
width: arg.clientWidth,
|
|
height: expandRows ? arg.clientHeight : ""
|
|
}
|
|
}, arg.tableColGroupNode, createElement(isHeader ? "thead" : "tbody", {
|
|
role: "presentation"
|
|
}, typeof chunkConfig.rowContent === "function" ? chunkConfig.rowContent(arg) : chunkConfig.rowContent));
|
|
return content;
|
|
}
|
|
function isColPropsEqual(cols0, cols1) {
|
|
return isArraysEqual(cols0, cols1, isPropsEqual);
|
|
}
|
|
function renderMicroColGroup(cols, shrinkWidth) {
|
|
var colNodes = [];
|
|
for (var _i = 0, cols_1 = cols; _i < cols_1.length; _i++) {
|
|
var colProps = cols_1[_i];
|
|
var span = colProps.span || 1;
|
|
for (var i3 = 0; i3 < span; i3 += 1) {
|
|
colNodes.push(createElement("col", { style: {
|
|
width: colProps.width === "shrink" ? sanitizeShrinkWidth(shrinkWidth) : colProps.width || "",
|
|
minWidth: colProps.minWidth || ""
|
|
} }));
|
|
}
|
|
}
|
|
return createElement.apply(void 0, __spreadArray(["colgroup", {}], colNodes));
|
|
}
|
|
function sanitizeShrinkWidth(shrinkWidth) {
|
|
return shrinkWidth == null ? 4 : shrinkWidth;
|
|
}
|
|
function hasShrinkWidth(cols) {
|
|
for (var _i = 0, cols_2 = cols; _i < cols_2.length; _i++) {
|
|
var col = cols_2[_i];
|
|
if (col.width === "shrink") {
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
function getScrollGridClassNames(liquid, context) {
|
|
var classNames = [
|
|
"fc-scrollgrid",
|
|
context.theme.getClass("table")
|
|
];
|
|
if (liquid) {
|
|
classNames.push("fc-scrollgrid-liquid");
|
|
}
|
|
return classNames;
|
|
}
|
|
function getSectionClassNames(sectionConfig, wholeTableVGrow) {
|
|
var classNames = [
|
|
"fc-scrollgrid-section",
|
|
"fc-scrollgrid-section-" + sectionConfig.type,
|
|
sectionConfig.className
|
|
];
|
|
if (wholeTableVGrow && sectionConfig.liquid && sectionConfig.maxHeight == null) {
|
|
classNames.push("fc-scrollgrid-section-liquid");
|
|
}
|
|
if (sectionConfig.isSticky) {
|
|
classNames.push("fc-scrollgrid-section-sticky");
|
|
}
|
|
return classNames;
|
|
}
|
|
function renderScrollShim(arg) {
|
|
return createElement("div", { className: "fc-scrollgrid-sticky-shim", style: {
|
|
width: arg.clientWidth,
|
|
minWidth: arg.tableMinWidth
|
|
} });
|
|
}
|
|
function getStickyHeaderDates(options) {
|
|
var stickyHeaderDates = options.stickyHeaderDates;
|
|
if (stickyHeaderDates == null || stickyHeaderDates === "auto") {
|
|
stickyHeaderDates = options.height === "auto" || options.viewHeight === "auto";
|
|
}
|
|
return stickyHeaderDates;
|
|
}
|
|
function getStickyFooterScrollbar(options) {
|
|
var stickyFooterScrollbar = options.stickyFooterScrollbar;
|
|
if (stickyFooterScrollbar == null || stickyFooterScrollbar === "auto") {
|
|
stickyFooterScrollbar = options.height === "auto" || options.viewHeight === "auto";
|
|
}
|
|
return stickyFooterScrollbar;
|
|
}
|
|
var SimpleScrollGrid = function(_super) {
|
|
__extends(SimpleScrollGrid2, _super);
|
|
function SimpleScrollGrid2() {
|
|
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
_this.processCols = memoize(function(a3) {
|
|
return a3;
|
|
}, isColPropsEqual);
|
|
_this.renderMicroColGroup = memoize(renderMicroColGroup);
|
|
_this.scrollerRefs = new RefMap();
|
|
_this.scrollerElRefs = new RefMap(_this._handleScrollerEl.bind(_this));
|
|
_this.state = {
|
|
shrinkWidth: null,
|
|
forceYScrollbars: false,
|
|
scrollerClientWidths: {},
|
|
scrollerClientHeights: {}
|
|
};
|
|
_this.handleSizing = function() {
|
|
_this.setState(__assign({ shrinkWidth: _this.computeShrinkWidth() }, _this.computeScrollerDims()));
|
|
};
|
|
return _this;
|
|
}
|
|
SimpleScrollGrid2.prototype.render = function() {
|
|
var _a = this, props = _a.props, state = _a.state, context = _a.context;
|
|
var sectionConfigs = props.sections || [];
|
|
var cols = this.processCols(props.cols);
|
|
var microColGroupNode = this.renderMicroColGroup(cols, state.shrinkWidth);
|
|
var classNames = getScrollGridClassNames(props.liquid, context);
|
|
if (props.collapsibleWidth) {
|
|
classNames.push("fc-scrollgrid-collapsible");
|
|
}
|
|
var configCnt = sectionConfigs.length;
|
|
var configI = 0;
|
|
var currentConfig;
|
|
var headSectionNodes = [];
|
|
var bodySectionNodes = [];
|
|
var footSectionNodes = [];
|
|
while (configI < configCnt && (currentConfig = sectionConfigs[configI]).type === "header") {
|
|
headSectionNodes.push(this.renderSection(currentConfig, microColGroupNode, true));
|
|
configI += 1;
|
|
}
|
|
while (configI < configCnt && (currentConfig = sectionConfigs[configI]).type === "body") {
|
|
bodySectionNodes.push(this.renderSection(currentConfig, microColGroupNode, false));
|
|
configI += 1;
|
|
}
|
|
while (configI < configCnt && (currentConfig = sectionConfigs[configI]).type === "footer") {
|
|
footSectionNodes.push(this.renderSection(currentConfig, microColGroupNode, true));
|
|
configI += 1;
|
|
}
|
|
var isBuggy = !getCanVGrowWithinCell();
|
|
var roleAttrs = { role: "rowgroup" };
|
|
return createElement("table", {
|
|
role: "grid",
|
|
className: classNames.join(" "),
|
|
style: { height: props.height }
|
|
}, Boolean(!isBuggy && headSectionNodes.length) && createElement.apply(void 0, __spreadArray(["thead", roleAttrs], headSectionNodes)), Boolean(!isBuggy && bodySectionNodes.length) && createElement.apply(void 0, __spreadArray(["tbody", roleAttrs], bodySectionNodes)), Boolean(!isBuggy && footSectionNodes.length) && createElement.apply(void 0, __spreadArray(["tfoot", roleAttrs], footSectionNodes)), isBuggy && createElement.apply(void 0, __spreadArray(__spreadArray(__spreadArray(["tbody", roleAttrs], headSectionNodes), bodySectionNodes), footSectionNodes)));
|
|
};
|
|
SimpleScrollGrid2.prototype.renderSection = function(sectionConfig, microColGroupNode, isHeader) {
|
|
if ("outerContent" in sectionConfig) {
|
|
return createElement(Fragment, { key: sectionConfig.key }, sectionConfig.outerContent);
|
|
}
|
|
return createElement("tr", { key: sectionConfig.key, role: "presentation", className: getSectionClassNames(sectionConfig, this.props.liquid).join(" ") }, this.renderChunkTd(sectionConfig, microColGroupNode, sectionConfig.chunk, isHeader));
|
|
};
|
|
SimpleScrollGrid2.prototype.renderChunkTd = function(sectionConfig, microColGroupNode, chunkConfig, isHeader) {
|
|
if ("outerContent" in chunkConfig) {
|
|
return chunkConfig.outerContent;
|
|
}
|
|
var props = this.props;
|
|
var _a = this.state, forceYScrollbars = _a.forceYScrollbars, scrollerClientWidths = _a.scrollerClientWidths, scrollerClientHeights = _a.scrollerClientHeights;
|
|
var needsYScrolling = getAllowYScrolling(props, sectionConfig);
|
|
var isLiquid = getSectionHasLiquidHeight(props, sectionConfig);
|
|
var overflowY = !props.liquid ? "visible" : forceYScrollbars ? "scroll" : !needsYScrolling ? "hidden" : "auto";
|
|
var sectionKey = sectionConfig.key;
|
|
var content = renderChunkContent(sectionConfig, chunkConfig, {
|
|
tableColGroupNode: microColGroupNode,
|
|
tableMinWidth: "",
|
|
clientWidth: !props.collapsibleWidth && scrollerClientWidths[sectionKey] !== void 0 ? scrollerClientWidths[sectionKey] : null,
|
|
clientHeight: scrollerClientHeights[sectionKey] !== void 0 ? scrollerClientHeights[sectionKey] : null,
|
|
expandRows: sectionConfig.expandRows,
|
|
syncRowHeights: false,
|
|
rowSyncHeights: [],
|
|
reportRowHeightChange: function() {
|
|
}
|
|
}, isHeader);
|
|
return createElement(isHeader ? "th" : "td", {
|
|
ref: chunkConfig.elRef,
|
|
role: "presentation"
|
|
}, createElement("div", { className: "fc-scroller-harness" + (isLiquid ? " fc-scroller-harness-liquid" : "") }, createElement(Scroller, { ref: this.scrollerRefs.createRef(sectionKey), elRef: this.scrollerElRefs.createRef(sectionKey), overflowY, overflowX: !props.liquid ? "visible" : "hidden", maxHeight: sectionConfig.maxHeight, liquid: isLiquid, liquidIsAbsolute: true }, content)));
|
|
};
|
|
SimpleScrollGrid2.prototype._handleScrollerEl = function(scrollerEl, key) {
|
|
var section = getSectionByKey(this.props.sections, key);
|
|
if (section) {
|
|
setRef(section.chunk.scrollerElRef, scrollerEl);
|
|
}
|
|
};
|
|
SimpleScrollGrid2.prototype.componentDidMount = function() {
|
|
this.handleSizing();
|
|
this.context.addResizeHandler(this.handleSizing);
|
|
};
|
|
SimpleScrollGrid2.prototype.componentDidUpdate = function() {
|
|
this.handleSizing();
|
|
};
|
|
SimpleScrollGrid2.prototype.componentWillUnmount = function() {
|
|
this.context.removeResizeHandler(this.handleSizing);
|
|
};
|
|
SimpleScrollGrid2.prototype.computeShrinkWidth = function() {
|
|
return hasShrinkWidth(this.props.cols) ? computeShrinkWidth(this.scrollerElRefs.getAll()) : 0;
|
|
};
|
|
SimpleScrollGrid2.prototype.computeScrollerDims = function() {
|
|
var scrollbarWidth = getScrollbarWidths();
|
|
var _a = this, scrollerRefs = _a.scrollerRefs, scrollerElRefs = _a.scrollerElRefs;
|
|
var forceYScrollbars = false;
|
|
var scrollerClientWidths = {};
|
|
var scrollerClientHeights = {};
|
|
for (var sectionKey in scrollerRefs.currentMap) {
|
|
var scroller = scrollerRefs.currentMap[sectionKey];
|
|
if (scroller && scroller.needsYScrolling()) {
|
|
forceYScrollbars = true;
|
|
break;
|
|
}
|
|
}
|
|
for (var _i = 0, _b = this.props.sections; _i < _b.length; _i++) {
|
|
var section = _b[_i];
|
|
var sectionKey = section.key;
|
|
var scrollerEl = scrollerElRefs.currentMap[sectionKey];
|
|
if (scrollerEl) {
|
|
var harnessEl = scrollerEl.parentNode;
|
|
scrollerClientWidths[sectionKey] = Math.floor(harnessEl.getBoundingClientRect().width - (forceYScrollbars ? scrollbarWidth.y : 0));
|
|
scrollerClientHeights[sectionKey] = Math.floor(harnessEl.getBoundingClientRect().height);
|
|
}
|
|
}
|
|
return { forceYScrollbars, scrollerClientWidths, scrollerClientHeights };
|
|
};
|
|
return SimpleScrollGrid2;
|
|
}(BaseComponent);
|
|
SimpleScrollGrid.addStateEquality({
|
|
scrollerClientWidths: isPropsEqual,
|
|
scrollerClientHeights: isPropsEqual
|
|
});
|
|
function getSectionByKey(sections, key) {
|
|
for (var _i = 0, sections_1 = sections; _i < sections_1.length; _i++) {
|
|
var section = sections_1[_i];
|
|
if (section.key === key) {
|
|
return section;
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
var EventRoot = function(_super) {
|
|
__extends(EventRoot2, _super);
|
|
function EventRoot2() {
|
|
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
_this.elRef = createRef();
|
|
return _this;
|
|
}
|
|
EventRoot2.prototype.render = function() {
|
|
var _a = this, props = _a.props, context = _a.context;
|
|
var options = context.options;
|
|
var seg = props.seg;
|
|
var eventRange = seg.eventRange;
|
|
var ui = eventRange.ui;
|
|
var hookProps = {
|
|
event: new EventApi(context, eventRange.def, eventRange.instance),
|
|
view: context.viewApi,
|
|
timeText: props.timeText,
|
|
textColor: ui.textColor,
|
|
backgroundColor: ui.backgroundColor,
|
|
borderColor: ui.borderColor,
|
|
isDraggable: !props.disableDragging && computeSegDraggable(seg, context),
|
|
isStartResizable: !props.disableResizing && computeSegStartResizable(seg, context),
|
|
isEndResizable: !props.disableResizing && computeSegEndResizable(seg),
|
|
isMirror: Boolean(props.isDragging || props.isResizing || props.isDateSelecting),
|
|
isStart: Boolean(seg.isStart),
|
|
isEnd: Boolean(seg.isEnd),
|
|
isPast: Boolean(props.isPast),
|
|
isFuture: Boolean(props.isFuture),
|
|
isToday: Boolean(props.isToday),
|
|
isSelected: Boolean(props.isSelected),
|
|
isDragging: Boolean(props.isDragging),
|
|
isResizing: Boolean(props.isResizing)
|
|
};
|
|
var standardClassNames = getEventClassNames(hookProps).concat(ui.classNames);
|
|
return createElement(RenderHook, { hookProps, classNames: options.eventClassNames, content: options.eventContent, defaultContent: props.defaultContent, didMount: options.eventDidMount, willUnmount: options.eventWillUnmount, elRef: this.elRef }, function(rootElRef, customClassNames, innerElRef, innerContent) {
|
|
return props.children(rootElRef, standardClassNames.concat(customClassNames), innerElRef, innerContent, hookProps);
|
|
});
|
|
};
|
|
EventRoot2.prototype.componentDidMount = function() {
|
|
setElSeg(this.elRef.current, this.props.seg);
|
|
};
|
|
EventRoot2.prototype.componentDidUpdate = function(prevProps) {
|
|
var seg = this.props.seg;
|
|
if (seg !== prevProps.seg) {
|
|
setElSeg(this.elRef.current, seg);
|
|
}
|
|
};
|
|
return EventRoot2;
|
|
}(BaseComponent);
|
|
var StandardEvent = function(_super) {
|
|
__extends(StandardEvent2, _super);
|
|
function StandardEvent2() {
|
|
return _super !== null && _super.apply(this, arguments) || this;
|
|
}
|
|
StandardEvent2.prototype.render = function() {
|
|
var _a = this, props = _a.props, context = _a.context;
|
|
var seg = props.seg;
|
|
var timeFormat = context.options.eventTimeFormat || props.defaultTimeFormat;
|
|
var timeText = buildSegTimeText(seg, timeFormat, context, props.defaultDisplayEventTime, props.defaultDisplayEventEnd);
|
|
return createElement(EventRoot, { seg, timeText, disableDragging: props.disableDragging, disableResizing: props.disableResizing, defaultContent: props.defaultContent || renderInnerContent$1, isDragging: props.isDragging, isResizing: props.isResizing, isDateSelecting: props.isDateSelecting, isSelected: props.isSelected, isPast: props.isPast, isFuture: props.isFuture, isToday: props.isToday }, function(rootElRef, classNames, innerElRef, innerContent, hookProps) {
|
|
return createElement("a", __assign({ className: props.extraClassNames.concat(classNames).join(" "), style: {
|
|
borderColor: hookProps.borderColor,
|
|
backgroundColor: hookProps.backgroundColor
|
|
}, ref: rootElRef }, getSegAnchorAttrs(seg, context)), createElement("div", { className: "fc-event-main", ref: innerElRef, style: { color: hookProps.textColor } }, innerContent), hookProps.isStartResizable && createElement("div", { className: "fc-event-resizer fc-event-resizer-start" }), hookProps.isEndResizable && createElement("div", { className: "fc-event-resizer fc-event-resizer-end" }));
|
|
});
|
|
};
|
|
return StandardEvent2;
|
|
}(BaseComponent);
|
|
function renderInnerContent$1(innerProps) {
|
|
return createElement("div", { className: "fc-event-main-frame" }, innerProps.timeText && createElement("div", { className: "fc-event-time" }, innerProps.timeText), createElement("div", { className: "fc-event-title-container" }, createElement("div", { className: "fc-event-title fc-sticky" }, innerProps.event.title || createElement(Fragment, null, "\xA0"))));
|
|
}
|
|
var NowIndicatorRoot = function(props) {
|
|
return createElement(ViewContextType.Consumer, null, function(context) {
|
|
var options = context.options;
|
|
var hookProps = {
|
|
isAxis: props.isAxis,
|
|
date: context.dateEnv.toDate(props.date),
|
|
view: context.viewApi
|
|
};
|
|
return createElement(RenderHook, { hookProps, classNames: options.nowIndicatorClassNames, content: options.nowIndicatorContent, didMount: options.nowIndicatorDidMount, willUnmount: options.nowIndicatorWillUnmount }, props.children);
|
|
});
|
|
};
|
|
var DAY_NUM_FORMAT = createFormatter({ day: "numeric" });
|
|
var DayCellContent = function(_super) {
|
|
__extends(DayCellContent2, _super);
|
|
function DayCellContent2() {
|
|
return _super !== null && _super.apply(this, arguments) || this;
|
|
}
|
|
DayCellContent2.prototype.render = function() {
|
|
var _a = this, props = _a.props, context = _a.context;
|
|
var options = context.options;
|
|
var hookProps = refineDayCellHookProps({
|
|
date: props.date,
|
|
dateProfile: props.dateProfile,
|
|
todayRange: props.todayRange,
|
|
showDayNumber: props.showDayNumber,
|
|
extraProps: props.extraHookProps,
|
|
viewApi: context.viewApi,
|
|
dateEnv: context.dateEnv
|
|
});
|
|
return createElement(ContentHook, { hookProps, content: options.dayCellContent, defaultContent: props.defaultContent }, props.children);
|
|
};
|
|
return DayCellContent2;
|
|
}(BaseComponent);
|
|
function refineDayCellHookProps(raw) {
|
|
var date = raw.date, dateEnv = raw.dateEnv;
|
|
var dayMeta = getDateMeta(date, raw.todayRange, null, raw.dateProfile);
|
|
return __assign(__assign(__assign({ date: dateEnv.toDate(date), view: raw.viewApi }, dayMeta), { dayNumberText: raw.showDayNumber ? dateEnv.format(date, DAY_NUM_FORMAT) : "" }), raw.extraProps);
|
|
}
|
|
var DayCellRoot = function(_super) {
|
|
__extends(DayCellRoot2, _super);
|
|
function DayCellRoot2() {
|
|
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
_this.refineHookProps = memoizeObjArg(refineDayCellHookProps);
|
|
_this.normalizeClassNames = buildClassNameNormalizer();
|
|
return _this;
|
|
}
|
|
DayCellRoot2.prototype.render = function() {
|
|
var _a = this, props = _a.props, context = _a.context;
|
|
var options = context.options;
|
|
var hookProps = this.refineHookProps({
|
|
date: props.date,
|
|
dateProfile: props.dateProfile,
|
|
todayRange: props.todayRange,
|
|
showDayNumber: props.showDayNumber,
|
|
extraProps: props.extraHookProps,
|
|
viewApi: context.viewApi,
|
|
dateEnv: context.dateEnv
|
|
});
|
|
var classNames = getDayClassNames(hookProps, context.theme).concat(hookProps.isDisabled ? [] : this.normalizeClassNames(options.dayCellClassNames, hookProps));
|
|
var dataAttrs = hookProps.isDisabled ? {} : {
|
|
"data-date": formatDayString(props.date)
|
|
};
|
|
return createElement(MountHook, { hookProps, didMount: options.dayCellDidMount, willUnmount: options.dayCellWillUnmount, elRef: props.elRef }, function(rootElRef) {
|
|
return props.children(rootElRef, classNames, dataAttrs, hookProps.isDisabled);
|
|
});
|
|
};
|
|
return DayCellRoot2;
|
|
}(BaseComponent);
|
|
function renderFill(fillType) {
|
|
return createElement("div", { className: "fc-" + fillType });
|
|
}
|
|
var BgEvent = function(props) {
|
|
return createElement(EventRoot, { defaultContent: renderInnerContent, seg: props.seg, timeText: "", disableDragging: true, disableResizing: true, isDragging: false, isResizing: false, isDateSelecting: false, isSelected: false, isPast: props.isPast, isFuture: props.isFuture, isToday: props.isToday }, function(rootElRef, classNames, innerElRef, innerContent, hookProps) {
|
|
return createElement("div", { ref: rootElRef, className: ["fc-bg-event"].concat(classNames).join(" "), style: {
|
|
backgroundColor: hookProps.backgroundColor
|
|
} }, innerContent);
|
|
});
|
|
};
|
|
function renderInnerContent(props) {
|
|
var title = props.event.title;
|
|
return title && createElement("div", { className: "fc-event-title" }, props.event.title);
|
|
}
|
|
var WeekNumberRoot = function(props) {
|
|
return createElement(ViewContextType.Consumer, null, function(context) {
|
|
var dateEnv = context.dateEnv, options = context.options;
|
|
var date = props.date;
|
|
var format = options.weekNumberFormat || props.defaultFormat;
|
|
var num = dateEnv.computeWeekNumber(date);
|
|
var text = dateEnv.format(date, format);
|
|
var hookProps = { num, text, date };
|
|
return createElement(RenderHook, { hookProps, classNames: options.weekNumberClassNames, content: options.weekNumberContent, defaultContent: renderInner, didMount: options.weekNumberDidMount, willUnmount: options.weekNumberWillUnmount }, props.children);
|
|
});
|
|
};
|
|
function renderInner(innerProps) {
|
|
return innerProps.text;
|
|
}
|
|
var PADDING_FROM_VIEWPORT = 10;
|
|
var Popover = function(_super) {
|
|
__extends(Popover2, _super);
|
|
function Popover2() {
|
|
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
_this.state = {
|
|
titleId: getUniqueDomId()
|
|
};
|
|
_this.handleRootEl = function(el) {
|
|
_this.rootEl = el;
|
|
if (_this.props.elRef) {
|
|
setRef(_this.props.elRef, el);
|
|
}
|
|
};
|
|
_this.handleDocumentMouseDown = function(ev) {
|
|
var target = getEventTargetViaRoot(ev);
|
|
if (!_this.rootEl.contains(target)) {
|
|
_this.handleCloseClick();
|
|
}
|
|
};
|
|
_this.handleDocumentKeyDown = function(ev) {
|
|
if (ev.key === "Escape") {
|
|
_this.handleCloseClick();
|
|
}
|
|
};
|
|
_this.handleCloseClick = function() {
|
|
var onClose = _this.props.onClose;
|
|
if (onClose) {
|
|
onClose();
|
|
}
|
|
};
|
|
return _this;
|
|
}
|
|
Popover2.prototype.render = function() {
|
|
var _a = this.context, theme = _a.theme, options = _a.options;
|
|
var _b = this, props = _b.props, state = _b.state;
|
|
var classNames = [
|
|
"fc-popover",
|
|
theme.getClass("popover")
|
|
].concat(props.extraClassNames || []);
|
|
return createPortal(createElement("div", __assign({ id: props.id, className: classNames.join(" "), "aria-labelledby": state.titleId }, props.extraAttrs, { ref: this.handleRootEl }), createElement("div", { className: "fc-popover-header " + theme.getClass("popoverHeader") }, createElement("span", { className: "fc-popover-title", id: state.titleId }, props.title), createElement("span", { className: "fc-popover-close " + theme.getIconClass("close"), title: options.closeHint, onClick: this.handleCloseClick })), createElement("div", { className: "fc-popover-body " + theme.getClass("popoverContent") }, props.children)), props.parentEl);
|
|
};
|
|
Popover2.prototype.componentDidMount = function() {
|
|
document.addEventListener("mousedown", this.handleDocumentMouseDown);
|
|
document.addEventListener("keydown", this.handleDocumentKeyDown);
|
|
this.updateSize();
|
|
};
|
|
Popover2.prototype.componentWillUnmount = function() {
|
|
document.removeEventListener("mousedown", this.handleDocumentMouseDown);
|
|
document.removeEventListener("keydown", this.handleDocumentKeyDown);
|
|
};
|
|
Popover2.prototype.updateSize = function() {
|
|
var isRtl = this.context.isRtl;
|
|
var _a = this.props, alignmentEl = _a.alignmentEl, alignGridTop = _a.alignGridTop;
|
|
var rootEl = this.rootEl;
|
|
var alignmentRect = computeClippedClientRect(alignmentEl);
|
|
if (alignmentRect) {
|
|
var popoverDims = rootEl.getBoundingClientRect();
|
|
var popoverTop = alignGridTop ? elementClosest(alignmentEl, ".fc-scrollgrid").getBoundingClientRect().top : alignmentRect.top;
|
|
var popoverLeft = isRtl ? alignmentRect.right - popoverDims.width : alignmentRect.left;
|
|
popoverTop = Math.max(popoverTop, PADDING_FROM_VIEWPORT);
|
|
popoverLeft = Math.min(popoverLeft, document.documentElement.clientWidth - PADDING_FROM_VIEWPORT - popoverDims.width);
|
|
popoverLeft = Math.max(popoverLeft, PADDING_FROM_VIEWPORT);
|
|
var origin_1 = rootEl.offsetParent.getBoundingClientRect();
|
|
applyStyle(rootEl, {
|
|
top: popoverTop - origin_1.top,
|
|
left: popoverLeft - origin_1.left
|
|
});
|
|
}
|
|
};
|
|
return Popover2;
|
|
}(BaseComponent);
|
|
var MorePopover = function(_super) {
|
|
__extends(MorePopover2, _super);
|
|
function MorePopover2() {
|
|
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
_this.handleRootEl = function(rootEl) {
|
|
_this.rootEl = rootEl;
|
|
if (rootEl) {
|
|
_this.context.registerInteractiveComponent(_this, {
|
|
el: rootEl,
|
|
useEventCenter: false
|
|
});
|
|
} else {
|
|
_this.context.unregisterInteractiveComponent(_this);
|
|
}
|
|
};
|
|
return _this;
|
|
}
|
|
MorePopover2.prototype.render = function() {
|
|
var _a = this.context, options = _a.options, dateEnv = _a.dateEnv;
|
|
var props = this.props;
|
|
var startDate = props.startDate, todayRange = props.todayRange, dateProfile = props.dateProfile;
|
|
var title = dateEnv.format(startDate, options.dayPopoverFormat);
|
|
return createElement(DayCellRoot, { date: startDate, dateProfile, todayRange, elRef: this.handleRootEl }, function(rootElRef, dayClassNames, dataAttrs) {
|
|
return createElement(Popover, { elRef: rootElRef, id: props.id, title, extraClassNames: ["fc-more-popover"].concat(dayClassNames), extraAttrs: dataAttrs, parentEl: props.parentEl, alignmentEl: props.alignmentEl, alignGridTop: props.alignGridTop, onClose: props.onClose }, createElement(DayCellContent, { date: startDate, dateProfile, todayRange }, function(innerElRef, innerContent) {
|
|
return innerContent && createElement("div", { className: "fc-more-popover-misc", ref: innerElRef }, innerContent);
|
|
}), props.children);
|
|
});
|
|
};
|
|
MorePopover2.prototype.queryHit = function(positionLeft, positionTop, elWidth, elHeight) {
|
|
var _a = this, rootEl = _a.rootEl, props = _a.props;
|
|
if (positionLeft >= 0 && positionLeft < elWidth && positionTop >= 0 && positionTop < elHeight) {
|
|
return {
|
|
dateProfile: props.dateProfile,
|
|
dateSpan: __assign({ allDay: true, range: {
|
|
start: props.startDate,
|
|
end: props.endDate
|
|
} }, props.extraDateSpan),
|
|
dayEl: rootEl,
|
|
rect: {
|
|
left: 0,
|
|
top: 0,
|
|
right: elWidth,
|
|
bottom: elHeight
|
|
},
|
|
layer: 1
|
|
};
|
|
}
|
|
return null;
|
|
};
|
|
return MorePopover2;
|
|
}(DateComponent);
|
|
var MoreLinkRoot = function(_super) {
|
|
__extends(MoreLinkRoot2, _super);
|
|
function MoreLinkRoot2() {
|
|
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
_this.linkElRef = createRef();
|
|
_this.state = {
|
|
isPopoverOpen: false,
|
|
popoverId: getUniqueDomId()
|
|
};
|
|
_this.handleClick = function(ev) {
|
|
var _a = _this, props = _a.props, context = _a.context;
|
|
var moreLinkClick = context.options.moreLinkClick;
|
|
var date = computeRange(props).start;
|
|
function buildPublicSeg(seg) {
|
|
var _a2 = seg.eventRange, def = _a2.def, instance = _a2.instance, range = _a2.range;
|
|
return {
|
|
event: new EventApi(context, def, instance),
|
|
start: context.dateEnv.toDate(range.start),
|
|
end: context.dateEnv.toDate(range.end),
|
|
isStart: seg.isStart,
|
|
isEnd: seg.isEnd
|
|
};
|
|
}
|
|
if (typeof moreLinkClick === "function") {
|
|
moreLinkClick = moreLinkClick({
|
|
date,
|
|
allDay: Boolean(props.allDayDate),
|
|
allSegs: props.allSegs.map(buildPublicSeg),
|
|
hiddenSegs: props.hiddenSegs.map(buildPublicSeg),
|
|
jsEvent: ev,
|
|
view: context.viewApi
|
|
});
|
|
}
|
|
if (!moreLinkClick || moreLinkClick === "popover") {
|
|
_this.setState({ isPopoverOpen: true });
|
|
} else if (typeof moreLinkClick === "string") {
|
|
context.calendarApi.zoomTo(date, moreLinkClick);
|
|
}
|
|
};
|
|
_this.handlePopoverClose = function() {
|
|
_this.setState({ isPopoverOpen: false });
|
|
};
|
|
return _this;
|
|
}
|
|
MoreLinkRoot2.prototype.render = function() {
|
|
var _this = this;
|
|
var _a = this, props = _a.props, state = _a.state;
|
|
return createElement(ViewContextType.Consumer, null, function(context) {
|
|
var viewApi = context.viewApi, options = context.options, calendarApi = context.calendarApi;
|
|
var moreLinkText = options.moreLinkText;
|
|
var moreCnt = props.moreCnt;
|
|
var range = computeRange(props);
|
|
var text = typeof moreLinkText === "function" ? moreLinkText.call(calendarApi, moreCnt) : "+" + moreCnt + " " + moreLinkText;
|
|
var title = formatWithOrdinals(options.moreLinkHint, [moreCnt], text);
|
|
var hookProps = {
|
|
num: moreCnt,
|
|
shortText: "+" + moreCnt,
|
|
text,
|
|
view: viewApi
|
|
};
|
|
return createElement(Fragment, null, Boolean(props.moreCnt) && createElement(RenderHook, { elRef: _this.linkElRef, hookProps, classNames: options.moreLinkClassNames, content: options.moreLinkContent, defaultContent: props.defaultContent || renderMoreLinkInner, didMount: options.moreLinkDidMount, willUnmount: options.moreLinkWillUnmount }, function(rootElRef, customClassNames, innerElRef, innerContent) {
|
|
return props.children(rootElRef, ["fc-more-link"].concat(customClassNames), innerElRef, innerContent, _this.handleClick, title, state.isPopoverOpen, state.isPopoverOpen ? state.popoverId : "");
|
|
}), state.isPopoverOpen && createElement(MorePopover, { id: state.popoverId, startDate: range.start, endDate: range.end, dateProfile: props.dateProfile, todayRange: props.todayRange, extraDateSpan: props.extraDateSpan, parentEl: _this.parentEl, alignmentEl: props.alignmentElRef.current, alignGridTop: props.alignGridTop, onClose: _this.handlePopoverClose }, props.popoverContent()));
|
|
});
|
|
};
|
|
MoreLinkRoot2.prototype.componentDidMount = function() {
|
|
this.updateParentEl();
|
|
};
|
|
MoreLinkRoot2.prototype.componentDidUpdate = function() {
|
|
this.updateParentEl();
|
|
};
|
|
MoreLinkRoot2.prototype.updateParentEl = function() {
|
|
if (this.linkElRef.current) {
|
|
this.parentEl = elementClosest(this.linkElRef.current, ".fc-view-harness");
|
|
}
|
|
};
|
|
return MoreLinkRoot2;
|
|
}(BaseComponent);
|
|
function renderMoreLinkInner(props) {
|
|
return props.text;
|
|
}
|
|
function computeRange(props) {
|
|
if (props.allDayDate) {
|
|
return {
|
|
start: props.allDayDate,
|
|
end: addDays(props.allDayDate, 1)
|
|
};
|
|
}
|
|
var hiddenSegs = props.hiddenSegs;
|
|
return {
|
|
start: computeEarliestSegStart(hiddenSegs),
|
|
end: computeLatestSegEnd(hiddenSegs)
|
|
};
|
|
}
|
|
function computeEarliestSegStart(segs) {
|
|
return segs.reduce(pickEarliestStart).eventRange.range.start;
|
|
}
|
|
function pickEarliestStart(seg0, seg1) {
|
|
return seg0.eventRange.range.start < seg1.eventRange.range.start ? seg0 : seg1;
|
|
}
|
|
function computeLatestSegEnd(segs) {
|
|
return segs.reduce(pickLatestEnd).eventRange.range.end;
|
|
}
|
|
function pickLatestEnd(seg0, seg1) {
|
|
return seg0.eventRange.range.end > seg1.eventRange.range.end ? seg0 : seg1;
|
|
}
|
|
|
|
// node_modules/@fullcalendar/core/main.js
|
|
var Calendar = function(_super) {
|
|
__extends(Calendar3, _super);
|
|
function Calendar3(el, optionOverrides) {
|
|
if (optionOverrides === void 0) {
|
|
optionOverrides = {};
|
|
}
|
|
var _this = _super.call(this) || this;
|
|
_this.isRendering = false;
|
|
_this.isRendered = false;
|
|
_this.currentClassNames = [];
|
|
_this.customContentRenderId = 0;
|
|
_this.handleAction = function(action) {
|
|
switch (action.type) {
|
|
case "SET_EVENT_DRAG":
|
|
case "SET_EVENT_RESIZE":
|
|
_this.renderRunner.tryDrain();
|
|
}
|
|
};
|
|
_this.handleData = function(data) {
|
|
_this.currentData = data;
|
|
_this.renderRunner.request(data.calendarOptions.rerenderDelay);
|
|
};
|
|
_this.handleRenderRequest = function() {
|
|
if (_this.isRendering) {
|
|
_this.isRendered = true;
|
|
var currentData_1 = _this.currentData;
|
|
render(createElement(CalendarRoot, { options: currentData_1.calendarOptions, theme: currentData_1.theme, emitter: currentData_1.emitter }, function(classNames, height, isHeightAuto, forPrint) {
|
|
_this.setClassNames(classNames);
|
|
_this.setHeight(height);
|
|
return createElement(CustomContentRenderContext.Provider, { value: _this.customContentRenderId }, createElement(CalendarContent, __assign({ isHeightAuto, forPrint }, currentData_1)));
|
|
}), _this.el);
|
|
} else if (_this.isRendered) {
|
|
_this.isRendered = false;
|
|
unmountComponentAtNode2(_this.el);
|
|
_this.setClassNames([]);
|
|
_this.setHeight("");
|
|
}
|
|
flushToDom2();
|
|
};
|
|
_this.el = el;
|
|
_this.renderRunner = new DelayedRunner(_this.handleRenderRequest);
|
|
new CalendarDataManager({
|
|
optionOverrides,
|
|
calendarApi: _this,
|
|
onAction: _this.handleAction,
|
|
onData: _this.handleData
|
|
});
|
|
return _this;
|
|
}
|
|
Object.defineProperty(Calendar3.prototype, "view", {
|
|
get: function() {
|
|
return this.currentData.viewApi;
|
|
},
|
|
enumerable: false,
|
|
configurable: true
|
|
});
|
|
Calendar3.prototype.render = function() {
|
|
var wasRendering = this.isRendering;
|
|
if (!wasRendering) {
|
|
this.isRendering = true;
|
|
} else {
|
|
this.customContentRenderId += 1;
|
|
}
|
|
this.renderRunner.request();
|
|
if (wasRendering) {
|
|
this.updateSize();
|
|
}
|
|
};
|
|
Calendar3.prototype.destroy = function() {
|
|
if (this.isRendering) {
|
|
this.isRendering = false;
|
|
this.renderRunner.request();
|
|
}
|
|
};
|
|
Calendar3.prototype.updateSize = function() {
|
|
_super.prototype.updateSize.call(this);
|
|
flushToDom2();
|
|
};
|
|
Calendar3.prototype.batchRendering = function(func) {
|
|
this.renderRunner.pause("batchRendering");
|
|
func();
|
|
this.renderRunner.resume("batchRendering");
|
|
};
|
|
Calendar3.prototype.pauseRendering = function() {
|
|
this.renderRunner.pause("pauseRendering");
|
|
};
|
|
Calendar3.prototype.resumeRendering = function() {
|
|
this.renderRunner.resume("pauseRendering", true);
|
|
};
|
|
Calendar3.prototype.resetOptions = function(optionOverrides, append) {
|
|
this.currentDataManager.resetOptions(optionOverrides, append);
|
|
};
|
|
Calendar3.prototype.setClassNames = function(classNames) {
|
|
if (!isArraysEqual(classNames, this.currentClassNames)) {
|
|
var classList = this.el.classList;
|
|
for (var _i = 0, _a = this.currentClassNames; _i < _a.length; _i++) {
|
|
var className = _a[_i];
|
|
classList.remove(className);
|
|
}
|
|
for (var _b = 0, classNames_1 = classNames; _b < classNames_1.length; _b++) {
|
|
var className = classNames_1[_b];
|
|
classList.add(className);
|
|
}
|
|
this.currentClassNames = classNames;
|
|
}
|
|
};
|
|
Calendar3.prototype.setHeight = function(height) {
|
|
applyStyleProp(this.el, "height", height);
|
|
};
|
|
return Calendar3;
|
|
}(CalendarApi);
|
|
|
|
// node_modules/@fullcalendar/daygrid/main.js
|
|
var TableView = function(_super) {
|
|
__extends(TableView2, _super);
|
|
function TableView2() {
|
|
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
_this.headerElRef = createRef();
|
|
return _this;
|
|
}
|
|
TableView2.prototype.renderSimpleLayout = function(headerRowContent, bodyContent) {
|
|
var _a = this, props = _a.props, context = _a.context;
|
|
var sections = [];
|
|
var stickyHeaderDates = getStickyHeaderDates(context.options);
|
|
if (headerRowContent) {
|
|
sections.push({
|
|
type: "header",
|
|
key: "header",
|
|
isSticky: stickyHeaderDates,
|
|
chunk: {
|
|
elRef: this.headerElRef,
|
|
tableClassName: "fc-col-header",
|
|
rowContent: headerRowContent
|
|
}
|
|
});
|
|
}
|
|
sections.push({
|
|
type: "body",
|
|
key: "body",
|
|
liquid: true,
|
|
chunk: { content: bodyContent }
|
|
});
|
|
return createElement(ViewRoot, { viewSpec: context.viewSpec }, function(rootElRef, classNames) {
|
|
return createElement("div", { ref: rootElRef, className: ["fc-daygrid"].concat(classNames).join(" ") }, createElement(SimpleScrollGrid, { liquid: !props.isHeightAuto && !props.forPrint, collapsibleWidth: props.forPrint, cols: [], sections }));
|
|
});
|
|
};
|
|
TableView2.prototype.renderHScrollLayout = function(headerRowContent, bodyContent, colCnt, dayMinWidth) {
|
|
var ScrollGrid = this.context.pluginHooks.scrollGridImpl;
|
|
if (!ScrollGrid) {
|
|
throw new Error("No ScrollGrid implementation");
|
|
}
|
|
var _a = this, props = _a.props, context = _a.context;
|
|
var stickyHeaderDates = !props.forPrint && getStickyHeaderDates(context.options);
|
|
var stickyFooterScrollbar = !props.forPrint && getStickyFooterScrollbar(context.options);
|
|
var sections = [];
|
|
if (headerRowContent) {
|
|
sections.push({
|
|
type: "header",
|
|
key: "header",
|
|
isSticky: stickyHeaderDates,
|
|
chunks: [{
|
|
key: "main",
|
|
elRef: this.headerElRef,
|
|
tableClassName: "fc-col-header",
|
|
rowContent: headerRowContent
|
|
}]
|
|
});
|
|
}
|
|
sections.push({
|
|
type: "body",
|
|
key: "body",
|
|
liquid: true,
|
|
chunks: [{
|
|
key: "main",
|
|
content: bodyContent
|
|
}]
|
|
});
|
|
if (stickyFooterScrollbar) {
|
|
sections.push({
|
|
type: "footer",
|
|
key: "footer",
|
|
isSticky: true,
|
|
chunks: [{
|
|
key: "main",
|
|
content: renderScrollShim
|
|
}]
|
|
});
|
|
}
|
|
return createElement(ViewRoot, { viewSpec: context.viewSpec }, function(rootElRef, classNames) {
|
|
return createElement("div", { ref: rootElRef, className: ["fc-daygrid"].concat(classNames).join(" ") }, createElement(ScrollGrid, { liquid: !props.isHeightAuto && !props.forPrint, collapsibleWidth: props.forPrint, colGroups: [{ cols: [{ span: colCnt, minWidth: dayMinWidth }] }], sections }));
|
|
});
|
|
};
|
|
return TableView2;
|
|
}(DateComponent);
|
|
function splitSegsByRow(segs, rowCnt) {
|
|
var byRow = [];
|
|
for (var i3 = 0; i3 < rowCnt; i3 += 1) {
|
|
byRow[i3] = [];
|
|
}
|
|
for (var _i = 0, segs_1 = segs; _i < segs_1.length; _i++) {
|
|
var seg = segs_1[_i];
|
|
byRow[seg.row].push(seg);
|
|
}
|
|
return byRow;
|
|
}
|
|
function splitSegsByFirstCol(segs, colCnt) {
|
|
var byCol = [];
|
|
for (var i3 = 0; i3 < colCnt; i3 += 1) {
|
|
byCol[i3] = [];
|
|
}
|
|
for (var _i = 0, segs_2 = segs; _i < segs_2.length; _i++) {
|
|
var seg = segs_2[_i];
|
|
byCol[seg.firstCol].push(seg);
|
|
}
|
|
return byCol;
|
|
}
|
|
function splitInteractionByRow(ui, rowCnt) {
|
|
var byRow = [];
|
|
if (!ui) {
|
|
for (var i3 = 0; i3 < rowCnt; i3 += 1) {
|
|
byRow[i3] = null;
|
|
}
|
|
} else {
|
|
for (var i3 = 0; i3 < rowCnt; i3 += 1) {
|
|
byRow[i3] = {
|
|
affectedInstances: ui.affectedInstances,
|
|
isEvent: ui.isEvent,
|
|
segs: []
|
|
};
|
|
}
|
|
for (var _i = 0, _a = ui.segs; _i < _a.length; _i++) {
|
|
var seg = _a[_i];
|
|
byRow[seg.row].segs.push(seg);
|
|
}
|
|
}
|
|
return byRow;
|
|
}
|
|
var TableCellTop = function(_super) {
|
|
__extends(TableCellTop2, _super);
|
|
function TableCellTop2() {
|
|
return _super !== null && _super.apply(this, arguments) || this;
|
|
}
|
|
TableCellTop2.prototype.render = function() {
|
|
var props = this.props;
|
|
var navLinkAttrs = buildNavLinkAttrs(this.context, props.date);
|
|
return createElement(DayCellContent, { date: props.date, dateProfile: props.dateProfile, todayRange: props.todayRange, showDayNumber: props.showDayNumber, extraHookProps: props.extraHookProps, defaultContent: renderTopInner }, function(innerElRef, innerContent) {
|
|
return (innerContent || props.forceDayTop) && createElement("div", { className: "fc-daygrid-day-top", ref: innerElRef }, createElement("a", __assign({ id: props.dayNumberId, className: "fc-daygrid-day-number" }, navLinkAttrs), innerContent || createElement(Fragment, null, "\xA0")));
|
|
});
|
|
};
|
|
return TableCellTop2;
|
|
}(BaseComponent);
|
|
function renderTopInner(props) {
|
|
return props.dayNumberText;
|
|
}
|
|
var DEFAULT_TABLE_EVENT_TIME_FORMAT = createFormatter({
|
|
hour: "numeric",
|
|
minute: "2-digit",
|
|
omitZeroMinute: true,
|
|
meridiem: "narrow"
|
|
});
|
|
function hasListItemDisplay(seg) {
|
|
var display = seg.eventRange.ui.display;
|
|
return display === "list-item" || display === "auto" && !seg.eventRange.def.allDay && seg.firstCol === seg.lastCol && seg.isStart && seg.isEnd;
|
|
}
|
|
var TableBlockEvent = function(_super) {
|
|
__extends(TableBlockEvent2, _super);
|
|
function TableBlockEvent2() {
|
|
return _super !== null && _super.apply(this, arguments) || this;
|
|
}
|
|
TableBlockEvent2.prototype.render = function() {
|
|
var props = this.props;
|
|
return createElement(StandardEvent, __assign({}, props, { extraClassNames: ["fc-daygrid-event", "fc-daygrid-block-event", "fc-h-event"], defaultTimeFormat: DEFAULT_TABLE_EVENT_TIME_FORMAT, defaultDisplayEventEnd: props.defaultDisplayEventEnd, disableResizing: !props.seg.eventRange.def.allDay }));
|
|
};
|
|
return TableBlockEvent2;
|
|
}(BaseComponent);
|
|
var TableListItemEvent = function(_super) {
|
|
__extends(TableListItemEvent2, _super);
|
|
function TableListItemEvent2() {
|
|
return _super !== null && _super.apply(this, arguments) || this;
|
|
}
|
|
TableListItemEvent2.prototype.render = function() {
|
|
var _a = this, props = _a.props, context = _a.context;
|
|
var timeFormat = context.options.eventTimeFormat || DEFAULT_TABLE_EVENT_TIME_FORMAT;
|
|
var timeText = buildSegTimeText(props.seg, timeFormat, context, true, props.defaultDisplayEventEnd);
|
|
return createElement(EventRoot, { seg: props.seg, timeText, defaultContent: renderInnerContent2, isDragging: props.isDragging, isResizing: false, isDateSelecting: false, isSelected: props.isSelected, isPast: props.isPast, isFuture: props.isFuture, isToday: props.isToday }, function(rootElRef, classNames, innerElRef, innerContent) {
|
|
return createElement("a", __assign({ className: ["fc-daygrid-event", "fc-daygrid-dot-event"].concat(classNames).join(" "), ref: rootElRef }, getSegAnchorAttrs(props.seg, context)), innerContent);
|
|
});
|
|
};
|
|
return TableListItemEvent2;
|
|
}(BaseComponent);
|
|
function renderInnerContent2(innerProps) {
|
|
return createElement(Fragment, null, createElement("div", { className: "fc-daygrid-event-dot", style: { borderColor: innerProps.borderColor || innerProps.backgroundColor } }), innerProps.timeText && createElement("div", { className: "fc-event-time" }, innerProps.timeText), createElement("div", { className: "fc-event-title" }, innerProps.event.title || createElement(Fragment, null, "\xA0")));
|
|
}
|
|
var TableCellMoreLink = function(_super) {
|
|
__extends(TableCellMoreLink2, _super);
|
|
function TableCellMoreLink2() {
|
|
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
_this.compileSegs = memoize(compileSegs);
|
|
return _this;
|
|
}
|
|
TableCellMoreLink2.prototype.render = function() {
|
|
var props = this.props;
|
|
var _a = this.compileSegs(props.singlePlacements), allSegs = _a.allSegs, invisibleSegs = _a.invisibleSegs;
|
|
return createElement(MoreLinkRoot, { dateProfile: props.dateProfile, todayRange: props.todayRange, allDayDate: props.allDayDate, moreCnt: props.moreCnt, allSegs, hiddenSegs: invisibleSegs, alignmentElRef: props.alignmentElRef, alignGridTop: props.alignGridTop, extraDateSpan: props.extraDateSpan, popoverContent: function() {
|
|
var isForcedInvisible = (props.eventDrag ? props.eventDrag.affectedInstances : null) || (props.eventResize ? props.eventResize.affectedInstances : null) || {};
|
|
return createElement(Fragment, null, allSegs.map(function(seg) {
|
|
var instanceId = seg.eventRange.instance.instanceId;
|
|
return createElement("div", { className: "fc-daygrid-event-harness", key: instanceId, style: {
|
|
visibility: isForcedInvisible[instanceId] ? "hidden" : ""
|
|
} }, hasListItemDisplay(seg) ? createElement(TableListItemEvent, __assign({ seg, isDragging: false, isSelected: instanceId === props.eventSelection, defaultDisplayEventEnd: false }, getSegMeta(seg, props.todayRange))) : createElement(TableBlockEvent, __assign({ seg, isDragging: false, isResizing: false, isDateSelecting: false, isSelected: instanceId === props.eventSelection, defaultDisplayEventEnd: false }, getSegMeta(seg, props.todayRange))));
|
|
}));
|
|
} }, function(rootElRef, classNames, innerElRef, innerContent, handleClick, title, isExpanded, popoverId) {
|
|
return createElement("a", __assign({ ref: rootElRef, className: ["fc-daygrid-more-link"].concat(classNames).join(" "), title, "aria-expanded": isExpanded, "aria-controls": popoverId }, createAriaClickAttrs(handleClick)), innerContent);
|
|
});
|
|
};
|
|
return TableCellMoreLink2;
|
|
}(BaseComponent);
|
|
function compileSegs(singlePlacements) {
|
|
var allSegs = [];
|
|
var invisibleSegs = [];
|
|
for (var _i = 0, singlePlacements_1 = singlePlacements; _i < singlePlacements_1.length; _i++) {
|
|
var placement = singlePlacements_1[_i];
|
|
allSegs.push(placement.seg);
|
|
if (!placement.isVisible) {
|
|
invisibleSegs.push(placement.seg);
|
|
}
|
|
}
|
|
return { allSegs, invisibleSegs };
|
|
}
|
|
var DEFAULT_WEEK_NUM_FORMAT = createFormatter({ week: "narrow" });
|
|
var TableCell = function(_super) {
|
|
__extends(TableCell2, _super);
|
|
function TableCell2() {
|
|
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
_this.rootElRef = createRef();
|
|
_this.state = {
|
|
dayNumberId: getUniqueDomId()
|
|
};
|
|
_this.handleRootEl = function(el) {
|
|
setRef(_this.rootElRef, el);
|
|
setRef(_this.props.elRef, el);
|
|
};
|
|
return _this;
|
|
}
|
|
TableCell2.prototype.render = function() {
|
|
var _a = this, context = _a.context, props = _a.props, state = _a.state, rootElRef = _a.rootElRef;
|
|
var date = props.date, dateProfile = props.dateProfile;
|
|
var navLinkAttrs = buildNavLinkAttrs(context, date, "week");
|
|
return createElement(DayCellRoot, { date, dateProfile, todayRange: props.todayRange, showDayNumber: props.showDayNumber, extraHookProps: props.extraHookProps, elRef: this.handleRootEl }, function(dayElRef, dayClassNames, rootDataAttrs, isDisabled) {
|
|
return createElement("td", __assign({ ref: dayElRef, role: "gridcell", className: ["fc-daygrid-day"].concat(dayClassNames, props.extraClassNames || []).join(" ") }, rootDataAttrs, props.extraDataAttrs, props.showDayNumber ? { "aria-labelledby": state.dayNumberId } : {}), createElement("div", { className: "fc-daygrid-day-frame fc-scrollgrid-sync-inner", ref: props.innerElRef }, props.showWeekNumber && createElement(WeekNumberRoot, { date, defaultFormat: DEFAULT_WEEK_NUM_FORMAT }, function(weekElRef, weekClassNames, innerElRef, innerContent) {
|
|
return createElement("a", __assign({ ref: weekElRef, className: ["fc-daygrid-week-number"].concat(weekClassNames).join(" ") }, navLinkAttrs), innerContent);
|
|
}), !isDisabled && createElement(TableCellTop, { date, dateProfile, showDayNumber: props.showDayNumber, dayNumberId: state.dayNumberId, forceDayTop: props.forceDayTop, todayRange: props.todayRange, extraHookProps: props.extraHookProps }), createElement("div", { className: "fc-daygrid-day-events", ref: props.fgContentElRef }, props.fgContent, createElement("div", { className: "fc-daygrid-day-bottom", style: { marginTop: props.moreMarginTop } }, createElement(TableCellMoreLink, { allDayDate: date, singlePlacements: props.singlePlacements, moreCnt: props.moreCnt, alignmentElRef: rootElRef, alignGridTop: !props.showDayNumber, extraDateSpan: props.extraDateSpan, dateProfile: props.dateProfile, eventSelection: props.eventSelection, eventDrag: props.eventDrag, eventResize: props.eventResize, todayRange: props.todayRange }))), createElement("div", { className: "fc-daygrid-day-bg" }, props.bgContent)));
|
|
});
|
|
};
|
|
return TableCell2;
|
|
}(DateComponent);
|
|
function computeFgSegPlacement(segs, dayMaxEvents, dayMaxEventRows, strictOrder, eventInstanceHeights, maxContentHeight, cells) {
|
|
var hierarchy = new DayGridSegHierarchy();
|
|
hierarchy.allowReslicing = true;
|
|
hierarchy.strictOrder = strictOrder;
|
|
if (dayMaxEvents === true || dayMaxEventRows === true) {
|
|
hierarchy.maxCoord = maxContentHeight;
|
|
hierarchy.hiddenConsumes = true;
|
|
} else if (typeof dayMaxEvents === "number") {
|
|
hierarchy.maxStackCnt = dayMaxEvents;
|
|
} else if (typeof dayMaxEventRows === "number") {
|
|
hierarchy.maxStackCnt = dayMaxEventRows;
|
|
hierarchy.hiddenConsumes = true;
|
|
}
|
|
var segInputs = [];
|
|
var unknownHeightSegs = [];
|
|
for (var i3 = 0; i3 < segs.length; i3 += 1) {
|
|
var seg = segs[i3];
|
|
var instanceId = seg.eventRange.instance.instanceId;
|
|
var eventHeight = eventInstanceHeights[instanceId];
|
|
if (eventHeight != null) {
|
|
segInputs.push({
|
|
index: i3,
|
|
thickness: eventHeight,
|
|
span: {
|
|
start: seg.firstCol,
|
|
end: seg.lastCol + 1
|
|
}
|
|
});
|
|
} else {
|
|
unknownHeightSegs.push(seg);
|
|
}
|
|
}
|
|
var hiddenEntries = hierarchy.addSegs(segInputs);
|
|
var segRects = hierarchy.toRects();
|
|
var _a = placeRects(segRects, segs, cells), singleColPlacements = _a.singleColPlacements, multiColPlacements = _a.multiColPlacements, leftoverMargins = _a.leftoverMargins;
|
|
var moreCnts = [];
|
|
var moreMarginTops = [];
|
|
for (var _i = 0, unknownHeightSegs_1 = unknownHeightSegs; _i < unknownHeightSegs_1.length; _i++) {
|
|
var seg = unknownHeightSegs_1[_i];
|
|
multiColPlacements[seg.firstCol].push({
|
|
seg,
|
|
isVisible: false,
|
|
isAbsolute: true,
|
|
absoluteTop: 0,
|
|
marginTop: 0
|
|
});
|
|
for (var col = seg.firstCol; col <= seg.lastCol; col += 1) {
|
|
singleColPlacements[col].push({
|
|
seg: resliceSeg(seg, col, col + 1, cells),
|
|
isVisible: false,
|
|
isAbsolute: false,
|
|
absoluteTop: 0,
|
|
marginTop: 0
|
|
});
|
|
}
|
|
}
|
|
for (var col = 0; col < cells.length; col += 1) {
|
|
moreCnts.push(0);
|
|
}
|
|
for (var _b = 0, hiddenEntries_1 = hiddenEntries; _b < hiddenEntries_1.length; _b++) {
|
|
var hiddenEntry = hiddenEntries_1[_b];
|
|
var seg = segs[hiddenEntry.index];
|
|
var hiddenSpan = hiddenEntry.span;
|
|
multiColPlacements[hiddenSpan.start].push({
|
|
seg: resliceSeg(seg, hiddenSpan.start, hiddenSpan.end, cells),
|
|
isVisible: false,
|
|
isAbsolute: true,
|
|
absoluteTop: 0,
|
|
marginTop: 0
|
|
});
|
|
for (var col = hiddenSpan.start; col < hiddenSpan.end; col += 1) {
|
|
moreCnts[col] += 1;
|
|
singleColPlacements[col].push({
|
|
seg: resliceSeg(seg, col, col + 1, cells),
|
|
isVisible: false,
|
|
isAbsolute: false,
|
|
absoluteTop: 0,
|
|
marginTop: 0
|
|
});
|
|
}
|
|
}
|
|
for (var col = 0; col < cells.length; col += 1) {
|
|
moreMarginTops.push(leftoverMargins[col]);
|
|
}
|
|
return { singleColPlacements, multiColPlacements, moreCnts, moreMarginTops };
|
|
}
|
|
function placeRects(allRects, segs, cells) {
|
|
var rectsByEachCol = groupRectsByEachCol(allRects, cells.length);
|
|
var singleColPlacements = [];
|
|
var multiColPlacements = [];
|
|
var leftoverMargins = [];
|
|
for (var col = 0; col < cells.length; col += 1) {
|
|
var rects = rectsByEachCol[col];
|
|
var singlePlacements = [];
|
|
var currentHeight = 0;
|
|
var currentMarginTop = 0;
|
|
for (var _i = 0, rects_1 = rects; _i < rects_1.length; _i++) {
|
|
var rect = rects_1[_i];
|
|
var seg = segs[rect.index];
|
|
singlePlacements.push({
|
|
seg: resliceSeg(seg, col, col + 1, cells),
|
|
isVisible: true,
|
|
isAbsolute: false,
|
|
absoluteTop: rect.levelCoord,
|
|
marginTop: rect.levelCoord - currentHeight
|
|
});
|
|
currentHeight = rect.levelCoord + rect.thickness;
|
|
}
|
|
var multiPlacements = [];
|
|
currentHeight = 0;
|
|
currentMarginTop = 0;
|
|
for (var _a = 0, rects_2 = rects; _a < rects_2.length; _a++) {
|
|
var rect = rects_2[_a];
|
|
var seg = segs[rect.index];
|
|
var isAbsolute = rect.span.end - rect.span.start > 1;
|
|
var isFirstCol = rect.span.start === col;
|
|
currentMarginTop += rect.levelCoord - currentHeight;
|
|
currentHeight = rect.levelCoord + rect.thickness;
|
|
if (isAbsolute) {
|
|
currentMarginTop += rect.thickness;
|
|
if (isFirstCol) {
|
|
multiPlacements.push({
|
|
seg: resliceSeg(seg, rect.span.start, rect.span.end, cells),
|
|
isVisible: true,
|
|
isAbsolute: true,
|
|
absoluteTop: rect.levelCoord,
|
|
marginTop: 0
|
|
});
|
|
}
|
|
} else if (isFirstCol) {
|
|
multiPlacements.push({
|
|
seg: resliceSeg(seg, rect.span.start, rect.span.end, cells),
|
|
isVisible: true,
|
|
isAbsolute: false,
|
|
absoluteTop: rect.levelCoord,
|
|
marginTop: currentMarginTop
|
|
});
|
|
currentMarginTop = 0;
|
|
}
|
|
}
|
|
singleColPlacements.push(singlePlacements);
|
|
multiColPlacements.push(multiPlacements);
|
|
leftoverMargins.push(currentMarginTop);
|
|
}
|
|
return { singleColPlacements, multiColPlacements, leftoverMargins };
|
|
}
|
|
function groupRectsByEachCol(rects, colCnt) {
|
|
var rectsByEachCol = [];
|
|
for (var col = 0; col < colCnt; col += 1) {
|
|
rectsByEachCol.push([]);
|
|
}
|
|
for (var _i = 0, rects_3 = rects; _i < rects_3.length; _i++) {
|
|
var rect = rects_3[_i];
|
|
for (var col = rect.span.start; col < rect.span.end; col += 1) {
|
|
rectsByEachCol[col].push(rect);
|
|
}
|
|
}
|
|
return rectsByEachCol;
|
|
}
|
|
function resliceSeg(seg, spanStart, spanEnd, cells) {
|
|
if (seg.firstCol === spanStart && seg.lastCol === spanEnd - 1) {
|
|
return seg;
|
|
}
|
|
var eventRange = seg.eventRange;
|
|
var origRange = eventRange.range;
|
|
var slicedRange = intersectRanges(origRange, {
|
|
start: cells[spanStart].date,
|
|
end: addDays(cells[spanEnd - 1].date, 1)
|
|
});
|
|
return __assign(__assign({}, seg), { firstCol: spanStart, lastCol: spanEnd - 1, eventRange: {
|
|
def: eventRange.def,
|
|
ui: __assign(__assign({}, eventRange.ui), { durationEditable: false }),
|
|
instance: eventRange.instance,
|
|
range: slicedRange
|
|
}, isStart: seg.isStart && slicedRange.start.valueOf() === origRange.start.valueOf(), isEnd: seg.isEnd && slicedRange.end.valueOf() === origRange.end.valueOf() });
|
|
}
|
|
var DayGridSegHierarchy = function(_super) {
|
|
__extends(DayGridSegHierarchy2, _super);
|
|
function DayGridSegHierarchy2() {
|
|
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
_this.hiddenConsumes = false;
|
|
_this.forceHidden = {};
|
|
return _this;
|
|
}
|
|
DayGridSegHierarchy2.prototype.addSegs = function(segInputs) {
|
|
var _this = this;
|
|
var hiddenSegs = _super.prototype.addSegs.call(this, segInputs);
|
|
var entriesByLevel = this.entriesByLevel;
|
|
var excludeHidden = function(entry) {
|
|
return !_this.forceHidden[buildEntryKey(entry)];
|
|
};
|
|
for (var level = 0; level < entriesByLevel.length; level += 1) {
|
|
entriesByLevel[level] = entriesByLevel[level].filter(excludeHidden);
|
|
}
|
|
return hiddenSegs;
|
|
};
|
|
DayGridSegHierarchy2.prototype.handleInvalidInsertion = function(insertion, entry, hiddenEntries) {
|
|
var _a = this, entriesByLevel = _a.entriesByLevel, forceHidden = _a.forceHidden;
|
|
var touchingEntry = insertion.touchingEntry, touchingLevel = insertion.touchingLevel, touchingLateral = insertion.touchingLateral;
|
|
if (this.hiddenConsumes && touchingEntry) {
|
|
var touchingEntryId = buildEntryKey(touchingEntry);
|
|
if (!forceHidden[touchingEntryId]) {
|
|
if (this.allowReslicing) {
|
|
var placeholderEntry = __assign(__assign({}, touchingEntry), { span: intersectSpans(touchingEntry.span, entry.span) });
|
|
var placeholderEntryId = buildEntryKey(placeholderEntry);
|
|
forceHidden[placeholderEntryId] = true;
|
|
entriesByLevel[touchingLevel][touchingLateral] = placeholderEntry;
|
|
this.splitEntry(touchingEntry, entry, hiddenEntries);
|
|
} else {
|
|
forceHidden[touchingEntryId] = true;
|
|
hiddenEntries.push(touchingEntry);
|
|
}
|
|
}
|
|
}
|
|
return _super.prototype.handleInvalidInsertion.call(this, insertion, entry, hiddenEntries);
|
|
};
|
|
return DayGridSegHierarchy2;
|
|
}(SegHierarchy);
|
|
var TableRow = function(_super) {
|
|
__extends(TableRow2, _super);
|
|
function TableRow2() {
|
|
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
_this.cellElRefs = new RefMap();
|
|
_this.frameElRefs = new RefMap();
|
|
_this.fgElRefs = new RefMap();
|
|
_this.segHarnessRefs = new RefMap();
|
|
_this.rootElRef = createRef();
|
|
_this.state = {
|
|
framePositions: null,
|
|
maxContentHeight: null,
|
|
eventInstanceHeights: {}
|
|
};
|
|
return _this;
|
|
}
|
|
TableRow2.prototype.render = function() {
|
|
var _this = this;
|
|
var _a = this, props = _a.props, state = _a.state, context = _a.context;
|
|
var options = context.options;
|
|
var colCnt = props.cells.length;
|
|
var businessHoursByCol = splitSegsByFirstCol(props.businessHourSegs, colCnt);
|
|
var bgEventSegsByCol = splitSegsByFirstCol(props.bgEventSegs, colCnt);
|
|
var highlightSegsByCol = splitSegsByFirstCol(this.getHighlightSegs(), colCnt);
|
|
var mirrorSegsByCol = splitSegsByFirstCol(this.getMirrorSegs(), colCnt);
|
|
var _b = computeFgSegPlacement(sortEventSegs(props.fgEventSegs, options.eventOrder), props.dayMaxEvents, props.dayMaxEventRows, options.eventOrderStrict, state.eventInstanceHeights, state.maxContentHeight, props.cells), singleColPlacements = _b.singleColPlacements, multiColPlacements = _b.multiColPlacements, moreCnts = _b.moreCnts, moreMarginTops = _b.moreMarginTops;
|
|
var isForcedInvisible = props.eventDrag && props.eventDrag.affectedInstances || props.eventResize && props.eventResize.affectedInstances || {};
|
|
return createElement("tr", { ref: this.rootElRef, role: "row" }, props.renderIntro && props.renderIntro(), props.cells.map(function(cell, col) {
|
|
var normalFgNodes = _this.renderFgSegs(col, props.forPrint ? singleColPlacements[col] : multiColPlacements[col], props.todayRange, isForcedInvisible);
|
|
var mirrorFgNodes = _this.renderFgSegs(col, buildMirrorPlacements(mirrorSegsByCol[col], multiColPlacements), props.todayRange, {}, Boolean(props.eventDrag), Boolean(props.eventResize), false);
|
|
return createElement(TableCell, { key: cell.key, elRef: _this.cellElRefs.createRef(cell.key), innerElRef: _this.frameElRefs.createRef(cell.key), dateProfile: props.dateProfile, date: cell.date, showDayNumber: props.showDayNumbers, showWeekNumber: props.showWeekNumbers && col === 0, forceDayTop: props.showWeekNumbers, todayRange: props.todayRange, eventSelection: props.eventSelection, eventDrag: props.eventDrag, eventResize: props.eventResize, extraHookProps: cell.extraHookProps, extraDataAttrs: cell.extraDataAttrs, extraClassNames: cell.extraClassNames, extraDateSpan: cell.extraDateSpan, moreCnt: moreCnts[col], moreMarginTop: moreMarginTops[col], singlePlacements: singleColPlacements[col], fgContentElRef: _this.fgElRefs.createRef(cell.key), fgContent: createElement(Fragment, null, createElement(Fragment, null, normalFgNodes), createElement(Fragment, null, mirrorFgNodes)), bgContent: createElement(Fragment, null, _this.renderFillSegs(highlightSegsByCol[col], "highlight"), _this.renderFillSegs(businessHoursByCol[col], "non-business"), _this.renderFillSegs(bgEventSegsByCol[col], "bg-event")) });
|
|
}));
|
|
};
|
|
TableRow2.prototype.componentDidMount = function() {
|
|
this.updateSizing(true);
|
|
};
|
|
TableRow2.prototype.componentDidUpdate = function(prevProps, prevState) {
|
|
var currentProps = this.props;
|
|
this.updateSizing(!isPropsEqual(prevProps, currentProps));
|
|
};
|
|
TableRow2.prototype.getHighlightSegs = function() {
|
|
var props = this.props;
|
|
if (props.eventDrag && props.eventDrag.segs.length) {
|
|
return props.eventDrag.segs;
|
|
}
|
|
if (props.eventResize && props.eventResize.segs.length) {
|
|
return props.eventResize.segs;
|
|
}
|
|
return props.dateSelectionSegs;
|
|
};
|
|
TableRow2.prototype.getMirrorSegs = function() {
|
|
var props = this.props;
|
|
if (props.eventResize && props.eventResize.segs.length) {
|
|
return props.eventResize.segs;
|
|
}
|
|
return [];
|
|
};
|
|
TableRow2.prototype.renderFgSegs = function(col, segPlacements, todayRange, isForcedInvisible, isDragging, isResizing, isDateSelecting) {
|
|
var context = this.context;
|
|
var eventSelection = this.props.eventSelection;
|
|
var framePositions = this.state.framePositions;
|
|
var defaultDisplayEventEnd = this.props.cells.length === 1;
|
|
var isMirror = isDragging || isResizing || isDateSelecting;
|
|
var nodes = [];
|
|
if (framePositions) {
|
|
for (var _i = 0, segPlacements_1 = segPlacements; _i < segPlacements_1.length; _i++) {
|
|
var placement = segPlacements_1[_i];
|
|
var seg = placement.seg;
|
|
var instanceId = seg.eventRange.instance.instanceId;
|
|
var key = instanceId + ":" + col;
|
|
var isVisible = placement.isVisible && !isForcedInvisible[instanceId];
|
|
var isAbsolute = placement.isAbsolute;
|
|
var left = "";
|
|
var right = "";
|
|
if (isAbsolute) {
|
|
if (context.isRtl) {
|
|
right = 0;
|
|
left = framePositions.lefts[seg.lastCol] - framePositions.lefts[seg.firstCol];
|
|
} else {
|
|
left = 0;
|
|
right = framePositions.rights[seg.firstCol] - framePositions.rights[seg.lastCol];
|
|
}
|
|
}
|
|
nodes.push(createElement("div", { className: "fc-daygrid-event-harness" + (isAbsolute ? " fc-daygrid-event-harness-abs" : ""), key, ref: isMirror ? null : this.segHarnessRefs.createRef(key), style: {
|
|
visibility: isVisible ? "" : "hidden",
|
|
marginTop: isAbsolute ? "" : placement.marginTop,
|
|
top: isAbsolute ? placement.absoluteTop : "",
|
|
left,
|
|
right
|
|
} }, hasListItemDisplay(seg) ? createElement(TableListItemEvent, __assign({ seg, isDragging, isSelected: instanceId === eventSelection, defaultDisplayEventEnd }, getSegMeta(seg, todayRange))) : createElement(TableBlockEvent, __assign({ seg, isDragging, isResizing, isDateSelecting, isSelected: instanceId === eventSelection, defaultDisplayEventEnd }, getSegMeta(seg, todayRange)))));
|
|
}
|
|
}
|
|
return nodes;
|
|
};
|
|
TableRow2.prototype.renderFillSegs = function(segs, fillType) {
|
|
var isRtl = this.context.isRtl;
|
|
var todayRange = this.props.todayRange;
|
|
var framePositions = this.state.framePositions;
|
|
var nodes = [];
|
|
if (framePositions) {
|
|
for (var _i = 0, segs_1 = segs; _i < segs_1.length; _i++) {
|
|
var seg = segs_1[_i];
|
|
var leftRightCss = isRtl ? {
|
|
right: 0,
|
|
left: framePositions.lefts[seg.lastCol] - framePositions.lefts[seg.firstCol]
|
|
} : {
|
|
left: 0,
|
|
right: framePositions.rights[seg.firstCol] - framePositions.rights[seg.lastCol]
|
|
};
|
|
nodes.push(createElement("div", { key: buildEventRangeKey(seg.eventRange), className: "fc-daygrid-bg-harness", style: leftRightCss }, fillType === "bg-event" ? createElement(BgEvent, __assign({ seg }, getSegMeta(seg, todayRange))) : renderFill(fillType)));
|
|
}
|
|
}
|
|
return createElement.apply(void 0, __spreadArray([Fragment, {}], nodes));
|
|
};
|
|
TableRow2.prototype.updateSizing = function(isExternalSizingChange) {
|
|
var _a = this, props = _a.props, frameElRefs = _a.frameElRefs;
|
|
if (!props.forPrint && props.clientWidth !== null) {
|
|
if (isExternalSizingChange) {
|
|
var frameEls = props.cells.map(function(cell) {
|
|
return frameElRefs.currentMap[cell.key];
|
|
});
|
|
if (frameEls.length) {
|
|
var originEl = this.rootElRef.current;
|
|
this.setState({
|
|
framePositions: new PositionCache(originEl, frameEls, true, false)
|
|
});
|
|
}
|
|
}
|
|
var oldInstanceHeights = this.state.eventInstanceHeights;
|
|
var newInstanceHeights = this.queryEventInstanceHeights();
|
|
var limitByContentHeight = props.dayMaxEvents === true || props.dayMaxEventRows === true;
|
|
this.setState({
|
|
eventInstanceHeights: __assign(__assign({}, oldInstanceHeights), newInstanceHeights),
|
|
maxContentHeight: limitByContentHeight ? this.computeMaxContentHeight() : null
|
|
});
|
|
}
|
|
};
|
|
TableRow2.prototype.queryEventInstanceHeights = function() {
|
|
var segElMap = this.segHarnessRefs.currentMap;
|
|
var eventInstanceHeights = {};
|
|
for (var key in segElMap) {
|
|
var height = Math.round(segElMap[key].getBoundingClientRect().height);
|
|
var instanceId = key.split(":")[0];
|
|
eventInstanceHeights[instanceId] = Math.max(eventInstanceHeights[instanceId] || 0, height);
|
|
}
|
|
return eventInstanceHeights;
|
|
};
|
|
TableRow2.prototype.computeMaxContentHeight = function() {
|
|
var firstKey = this.props.cells[0].key;
|
|
var cellEl = this.cellElRefs.currentMap[firstKey];
|
|
var fcContainerEl = this.fgElRefs.currentMap[firstKey];
|
|
return cellEl.getBoundingClientRect().bottom - fcContainerEl.getBoundingClientRect().top;
|
|
};
|
|
TableRow2.prototype.getCellEls = function() {
|
|
var elMap = this.cellElRefs.currentMap;
|
|
return this.props.cells.map(function(cell) {
|
|
return elMap[cell.key];
|
|
});
|
|
};
|
|
return TableRow2;
|
|
}(DateComponent);
|
|
TableRow.addStateEquality({
|
|
eventInstanceHeights: isPropsEqual
|
|
});
|
|
function buildMirrorPlacements(mirrorSegs, colPlacements) {
|
|
if (!mirrorSegs.length) {
|
|
return [];
|
|
}
|
|
var topsByInstanceId = buildAbsoluteTopHash(colPlacements);
|
|
return mirrorSegs.map(function(seg) {
|
|
return {
|
|
seg,
|
|
isVisible: true,
|
|
isAbsolute: true,
|
|
absoluteTop: topsByInstanceId[seg.eventRange.instance.instanceId],
|
|
marginTop: 0
|
|
};
|
|
});
|
|
}
|
|
function buildAbsoluteTopHash(colPlacements) {
|
|
var topsByInstanceId = {};
|
|
for (var _i = 0, colPlacements_1 = colPlacements; _i < colPlacements_1.length; _i++) {
|
|
var placements = colPlacements_1[_i];
|
|
for (var _a = 0, placements_1 = placements; _a < placements_1.length; _a++) {
|
|
var placement = placements_1[_a];
|
|
topsByInstanceId[placement.seg.eventRange.instance.instanceId] = placement.absoluteTop;
|
|
}
|
|
}
|
|
return topsByInstanceId;
|
|
}
|
|
var Table = function(_super) {
|
|
__extends(Table2, _super);
|
|
function Table2() {
|
|
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
_this.splitBusinessHourSegs = memoize(splitSegsByRow);
|
|
_this.splitBgEventSegs = memoize(splitSegsByRow);
|
|
_this.splitFgEventSegs = memoize(splitSegsByRow);
|
|
_this.splitDateSelectionSegs = memoize(splitSegsByRow);
|
|
_this.splitEventDrag = memoize(splitInteractionByRow);
|
|
_this.splitEventResize = memoize(splitInteractionByRow);
|
|
_this.rowRefs = new RefMap();
|
|
_this.handleRootEl = function(rootEl) {
|
|
_this.rootEl = rootEl;
|
|
if (rootEl) {
|
|
_this.context.registerInteractiveComponent(_this, {
|
|
el: rootEl,
|
|
isHitComboAllowed: _this.props.isHitComboAllowed
|
|
});
|
|
} else {
|
|
_this.context.unregisterInteractiveComponent(_this);
|
|
}
|
|
};
|
|
return _this;
|
|
}
|
|
Table2.prototype.render = function() {
|
|
var _this = this;
|
|
var props = this.props;
|
|
var dateProfile = props.dateProfile, dayMaxEventRows = props.dayMaxEventRows, dayMaxEvents = props.dayMaxEvents, expandRows = props.expandRows;
|
|
var rowCnt = props.cells.length;
|
|
var businessHourSegsByRow = this.splitBusinessHourSegs(props.businessHourSegs, rowCnt);
|
|
var bgEventSegsByRow = this.splitBgEventSegs(props.bgEventSegs, rowCnt);
|
|
var fgEventSegsByRow = this.splitFgEventSegs(props.fgEventSegs, rowCnt);
|
|
var dateSelectionSegsByRow = this.splitDateSelectionSegs(props.dateSelectionSegs, rowCnt);
|
|
var eventDragByRow = this.splitEventDrag(props.eventDrag, rowCnt);
|
|
var eventResizeByRow = this.splitEventResize(props.eventResize, rowCnt);
|
|
var limitViaBalanced = dayMaxEvents === true || dayMaxEventRows === true;
|
|
if (limitViaBalanced && !expandRows) {
|
|
limitViaBalanced = false;
|
|
dayMaxEventRows = null;
|
|
dayMaxEvents = null;
|
|
}
|
|
var classNames = [
|
|
"fc-daygrid-body",
|
|
limitViaBalanced ? "fc-daygrid-body-balanced" : "fc-daygrid-body-unbalanced",
|
|
expandRows ? "" : "fc-daygrid-body-natural"
|
|
];
|
|
return createElement("div", { className: classNames.join(" "), ref: this.handleRootEl, style: {
|
|
width: props.clientWidth,
|
|
minWidth: props.tableMinWidth
|
|
} }, createElement(NowTimer, { unit: "day" }, function(nowDate, todayRange) {
|
|
return createElement(Fragment, null, createElement("table", { role: "presentation", className: "fc-scrollgrid-sync-table", style: {
|
|
width: props.clientWidth,
|
|
minWidth: props.tableMinWidth,
|
|
height: expandRows ? props.clientHeight : ""
|
|
} }, props.colGroupNode, createElement("tbody", { role: "presentation" }, props.cells.map(function(cells, row) {
|
|
return createElement(TableRow, {
|
|
ref: _this.rowRefs.createRef(row),
|
|
key: cells.length ? cells[0].date.toISOString() : row,
|
|
showDayNumbers: rowCnt > 1,
|
|
showWeekNumbers: props.showWeekNumbers,
|
|
todayRange,
|
|
dateProfile,
|
|
cells,
|
|
renderIntro: props.renderRowIntro,
|
|
businessHourSegs: businessHourSegsByRow[row],
|
|
eventSelection: props.eventSelection,
|
|
bgEventSegs: bgEventSegsByRow[row].filter(isSegAllDay),
|
|
fgEventSegs: fgEventSegsByRow[row],
|
|
dateSelectionSegs: dateSelectionSegsByRow[row],
|
|
eventDrag: eventDragByRow[row],
|
|
eventResize: eventResizeByRow[row],
|
|
dayMaxEvents,
|
|
dayMaxEventRows,
|
|
clientWidth: props.clientWidth,
|
|
clientHeight: props.clientHeight,
|
|
forPrint: props.forPrint
|
|
});
|
|
}))));
|
|
}));
|
|
};
|
|
Table2.prototype.prepareHits = function() {
|
|
this.rowPositions = new PositionCache(this.rootEl, this.rowRefs.collect().map(function(rowObj) {
|
|
return rowObj.getCellEls()[0];
|
|
}), false, true);
|
|
this.colPositions = new PositionCache(this.rootEl, this.rowRefs.currentMap[0].getCellEls(), true, false);
|
|
};
|
|
Table2.prototype.queryHit = function(positionLeft, positionTop) {
|
|
var _a = this, colPositions = _a.colPositions, rowPositions = _a.rowPositions;
|
|
var col = colPositions.leftToIndex(positionLeft);
|
|
var row = rowPositions.topToIndex(positionTop);
|
|
if (row != null && col != null) {
|
|
var cell = this.props.cells[row][col];
|
|
return {
|
|
dateProfile: this.props.dateProfile,
|
|
dateSpan: __assign({ range: this.getCellRange(row, col), allDay: true }, cell.extraDateSpan),
|
|
dayEl: this.getCellEl(row, col),
|
|
rect: {
|
|
left: colPositions.lefts[col],
|
|
right: colPositions.rights[col],
|
|
top: rowPositions.tops[row],
|
|
bottom: rowPositions.bottoms[row]
|
|
},
|
|
layer: 0
|
|
};
|
|
}
|
|
return null;
|
|
};
|
|
Table2.prototype.getCellEl = function(row, col) {
|
|
return this.rowRefs.currentMap[row].getCellEls()[col];
|
|
};
|
|
Table2.prototype.getCellRange = function(row, col) {
|
|
var start = this.props.cells[row][col].date;
|
|
var end = addDays(start, 1);
|
|
return { start, end };
|
|
};
|
|
return Table2;
|
|
}(DateComponent);
|
|
function isSegAllDay(seg) {
|
|
return seg.eventRange.def.allDay;
|
|
}
|
|
var DayTableSlicer = function(_super) {
|
|
__extends(DayTableSlicer2, _super);
|
|
function DayTableSlicer2() {
|
|
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
_this.forceDayIfListItem = true;
|
|
return _this;
|
|
}
|
|
DayTableSlicer2.prototype.sliceRange = function(dateRange, dayTableModel) {
|
|
return dayTableModel.sliceRange(dateRange);
|
|
};
|
|
return DayTableSlicer2;
|
|
}(Slicer);
|
|
var DayTable = function(_super) {
|
|
__extends(DayTable2, _super);
|
|
function DayTable2() {
|
|
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
_this.slicer = new DayTableSlicer();
|
|
_this.tableRef = createRef();
|
|
return _this;
|
|
}
|
|
DayTable2.prototype.render = function() {
|
|
var _a = this, props = _a.props, context = _a.context;
|
|
return createElement(Table, __assign({ ref: this.tableRef }, this.slicer.sliceProps(props, props.dateProfile, props.nextDayThreshold, context, props.dayTableModel), { dateProfile: props.dateProfile, cells: props.dayTableModel.cells, colGroupNode: props.colGroupNode, tableMinWidth: props.tableMinWidth, renderRowIntro: props.renderRowIntro, dayMaxEvents: props.dayMaxEvents, dayMaxEventRows: props.dayMaxEventRows, showWeekNumbers: props.showWeekNumbers, expandRows: props.expandRows, headerAlignElRef: props.headerAlignElRef, clientWidth: props.clientWidth, clientHeight: props.clientHeight, forPrint: props.forPrint }));
|
|
};
|
|
return DayTable2;
|
|
}(DateComponent);
|
|
var DayTableView = function(_super) {
|
|
__extends(DayTableView2, _super);
|
|
function DayTableView2() {
|
|
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
_this.buildDayTableModel = memoize(buildDayTableModel);
|
|
_this.headerRef = createRef();
|
|
_this.tableRef = createRef();
|
|
return _this;
|
|
}
|
|
DayTableView2.prototype.render = function() {
|
|
var _this = this;
|
|
var _a = this.context, options = _a.options, dateProfileGenerator = _a.dateProfileGenerator;
|
|
var props = this.props;
|
|
var dayTableModel = this.buildDayTableModel(props.dateProfile, dateProfileGenerator);
|
|
var headerContent = options.dayHeaders && createElement(DayHeader, { ref: this.headerRef, dateProfile: props.dateProfile, dates: dayTableModel.headerDates, datesRepDistinctDays: dayTableModel.rowCnt === 1 });
|
|
var bodyContent = function(contentArg) {
|
|
return createElement(DayTable, { ref: _this.tableRef, dateProfile: props.dateProfile, dayTableModel, businessHours: props.businessHours, dateSelection: props.dateSelection, eventStore: props.eventStore, eventUiBases: props.eventUiBases, eventSelection: props.eventSelection, eventDrag: props.eventDrag, eventResize: props.eventResize, nextDayThreshold: options.nextDayThreshold, colGroupNode: contentArg.tableColGroupNode, tableMinWidth: contentArg.tableMinWidth, dayMaxEvents: options.dayMaxEvents, dayMaxEventRows: options.dayMaxEventRows, showWeekNumbers: options.weekNumbers, expandRows: !props.isHeightAuto, headerAlignElRef: _this.headerElRef, clientWidth: contentArg.clientWidth, clientHeight: contentArg.clientHeight, forPrint: props.forPrint });
|
|
};
|
|
return options.dayMinWidth ? this.renderHScrollLayout(headerContent, bodyContent, dayTableModel.colCnt, options.dayMinWidth) : this.renderSimpleLayout(headerContent, bodyContent);
|
|
};
|
|
return DayTableView2;
|
|
}(TableView);
|
|
function buildDayTableModel(dateProfile, dateProfileGenerator) {
|
|
var daySeries = new DaySeriesModel(dateProfile.renderRange, dateProfileGenerator);
|
|
return new DayTableModel(daySeries, /year|month|week/.test(dateProfile.currentRangeUnit));
|
|
}
|
|
var TableDateProfileGenerator = function(_super) {
|
|
__extends(TableDateProfileGenerator2, _super);
|
|
function TableDateProfileGenerator2() {
|
|
return _super !== null && _super.apply(this, arguments) || this;
|
|
}
|
|
TableDateProfileGenerator2.prototype.buildRenderRange = function(currentRange, currentRangeUnit, isRangeAllDay) {
|
|
var dateEnv = this.props.dateEnv;
|
|
var renderRange = _super.prototype.buildRenderRange.call(this, currentRange, currentRangeUnit, isRangeAllDay);
|
|
var start = renderRange.start;
|
|
var end = renderRange.end;
|
|
var endOfWeek;
|
|
if (/^(year|month)$/.test(currentRangeUnit)) {
|
|
start = dateEnv.startOfWeek(start);
|
|
endOfWeek = dateEnv.startOfWeek(end);
|
|
if (endOfWeek.valueOf() !== end.valueOf()) {
|
|
end = addWeeks(endOfWeek, 1);
|
|
}
|
|
}
|
|
if (this.props.monthMode && this.props.fixedWeekCount) {
|
|
var rowCnt = Math.ceil(diffWeeks(start, end));
|
|
end = addWeeks(end, 6 - rowCnt);
|
|
}
|
|
return { start, end };
|
|
};
|
|
return TableDateProfileGenerator2;
|
|
}(DateProfileGenerator);
|
|
var main = createPlugin({
|
|
initialView: "dayGridMonth",
|
|
views: {
|
|
dayGrid: {
|
|
component: DayTableView,
|
|
dateProfileGeneratorClass: TableDateProfileGenerator
|
|
},
|
|
dayGridDay: {
|
|
type: "dayGrid",
|
|
duration: { days: 1 }
|
|
},
|
|
dayGridWeek: {
|
|
type: "dayGrid",
|
|
duration: { weeks: 1 }
|
|
},
|
|
dayGridMonth: {
|
|
type: "dayGrid",
|
|
duration: { months: 1 },
|
|
monthMode: true,
|
|
fixedWeekCount: true
|
|
}
|
|
}
|
|
});
|
|
var main_default = main;
|
|
|
|
// node_modules/@fullcalendar/timegrid/main.js
|
|
var AllDaySplitter = function(_super) {
|
|
__extends(AllDaySplitter2, _super);
|
|
function AllDaySplitter2() {
|
|
return _super !== null && _super.apply(this, arguments) || this;
|
|
}
|
|
AllDaySplitter2.prototype.getKeyInfo = function() {
|
|
return {
|
|
allDay: {},
|
|
timed: {}
|
|
};
|
|
};
|
|
AllDaySplitter2.prototype.getKeysForDateSpan = function(dateSpan) {
|
|
if (dateSpan.allDay) {
|
|
return ["allDay"];
|
|
}
|
|
return ["timed"];
|
|
};
|
|
AllDaySplitter2.prototype.getKeysForEventDef = function(eventDef) {
|
|
if (!eventDef.allDay) {
|
|
return ["timed"];
|
|
}
|
|
if (hasBgRendering(eventDef)) {
|
|
return ["timed", "allDay"];
|
|
}
|
|
return ["allDay"];
|
|
};
|
|
return AllDaySplitter2;
|
|
}(Splitter);
|
|
var DEFAULT_SLAT_LABEL_FORMAT = createFormatter({
|
|
hour: "numeric",
|
|
minute: "2-digit",
|
|
omitZeroMinute: true,
|
|
meridiem: "short"
|
|
});
|
|
function TimeColsAxisCell(props) {
|
|
var classNames = [
|
|
"fc-timegrid-slot",
|
|
"fc-timegrid-slot-label",
|
|
props.isLabeled ? "fc-scrollgrid-shrink" : "fc-timegrid-slot-minor"
|
|
];
|
|
return createElement(ViewContextType.Consumer, null, function(context) {
|
|
if (!props.isLabeled) {
|
|
return createElement("td", { className: classNames.join(" "), "data-time": props.isoTimeStr });
|
|
}
|
|
var dateEnv = context.dateEnv, options = context.options, viewApi = context.viewApi;
|
|
var labelFormat = options.slotLabelFormat == null ? DEFAULT_SLAT_LABEL_FORMAT : Array.isArray(options.slotLabelFormat) ? createFormatter(options.slotLabelFormat[0]) : createFormatter(options.slotLabelFormat);
|
|
var hookProps = {
|
|
level: 0,
|
|
time: props.time,
|
|
date: dateEnv.toDate(props.date),
|
|
view: viewApi,
|
|
text: dateEnv.format(props.date, labelFormat)
|
|
};
|
|
return createElement(RenderHook, { hookProps, classNames: options.slotLabelClassNames, content: options.slotLabelContent, defaultContent: renderInnerContent3, didMount: options.slotLabelDidMount, willUnmount: options.slotLabelWillUnmount }, function(rootElRef, customClassNames, innerElRef, innerContent) {
|
|
return createElement("td", { ref: rootElRef, className: classNames.concat(customClassNames).join(" "), "data-time": props.isoTimeStr }, createElement("div", { className: "fc-timegrid-slot-label-frame fc-scrollgrid-shrink-frame" }, createElement("div", { className: "fc-timegrid-slot-label-cushion fc-scrollgrid-shrink-cushion", ref: innerElRef }, innerContent)));
|
|
});
|
|
});
|
|
}
|
|
function renderInnerContent3(props) {
|
|
return props.text;
|
|
}
|
|
var TimeBodyAxis = function(_super) {
|
|
__extends(TimeBodyAxis2, _super);
|
|
function TimeBodyAxis2() {
|
|
return _super !== null && _super.apply(this, arguments) || this;
|
|
}
|
|
TimeBodyAxis2.prototype.render = function() {
|
|
return this.props.slatMetas.map(function(slatMeta) {
|
|
return createElement("tr", { key: slatMeta.key }, createElement(TimeColsAxisCell, __assign({}, slatMeta)));
|
|
});
|
|
};
|
|
return TimeBodyAxis2;
|
|
}(BaseComponent);
|
|
var DEFAULT_WEEK_NUM_FORMAT2 = createFormatter({ week: "short" });
|
|
var AUTO_ALL_DAY_MAX_EVENT_ROWS = 5;
|
|
var TimeColsView = function(_super) {
|
|
__extends(TimeColsView2, _super);
|
|
function TimeColsView2() {
|
|
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
_this.allDaySplitter = new AllDaySplitter();
|
|
_this.headerElRef = createRef();
|
|
_this.rootElRef = createRef();
|
|
_this.scrollerElRef = createRef();
|
|
_this.state = {
|
|
slatCoords: null
|
|
};
|
|
_this.handleScrollTopRequest = function(scrollTop) {
|
|
var scrollerEl = _this.scrollerElRef.current;
|
|
if (scrollerEl) {
|
|
scrollerEl.scrollTop = scrollTop;
|
|
}
|
|
};
|
|
_this.renderHeadAxis = function(rowKey, frameHeight) {
|
|
if (frameHeight === void 0) {
|
|
frameHeight = "";
|
|
}
|
|
var options = _this.context.options;
|
|
var dateProfile = _this.props.dateProfile;
|
|
var range = dateProfile.renderRange;
|
|
var dayCnt = diffDays(range.start, range.end);
|
|
var navLinkAttrs = dayCnt === 1 ? buildNavLinkAttrs(_this.context, range.start, "week") : {};
|
|
if (options.weekNumbers && rowKey === "day") {
|
|
return createElement(WeekNumberRoot, { date: range.start, defaultFormat: DEFAULT_WEEK_NUM_FORMAT2 }, function(rootElRef, classNames, innerElRef, innerContent) {
|
|
return createElement("th", { ref: rootElRef, "aria-hidden": true, className: [
|
|
"fc-timegrid-axis",
|
|
"fc-scrollgrid-shrink"
|
|
].concat(classNames).join(" ") }, createElement("div", { className: "fc-timegrid-axis-frame fc-scrollgrid-shrink-frame fc-timegrid-axis-frame-liquid", style: { height: frameHeight } }, createElement("a", __assign({ ref: innerElRef, className: "fc-timegrid-axis-cushion fc-scrollgrid-shrink-cushion fc-scrollgrid-sync-inner" }, navLinkAttrs), innerContent)));
|
|
});
|
|
}
|
|
return createElement("th", { "aria-hidden": true, className: "fc-timegrid-axis" }, createElement("div", { className: "fc-timegrid-axis-frame", style: { height: frameHeight } }));
|
|
};
|
|
_this.renderTableRowAxis = function(rowHeight) {
|
|
var _a = _this.context, options = _a.options, viewApi = _a.viewApi;
|
|
var hookProps = {
|
|
text: options.allDayText,
|
|
view: viewApi
|
|
};
|
|
return createElement(RenderHook, { hookProps, classNames: options.allDayClassNames, content: options.allDayContent, defaultContent: renderAllDayInner, didMount: options.allDayDidMount, willUnmount: options.allDayWillUnmount }, function(rootElRef, classNames, innerElRef, innerContent) {
|
|
return createElement("td", { ref: rootElRef, "aria-hidden": true, className: [
|
|
"fc-timegrid-axis",
|
|
"fc-scrollgrid-shrink"
|
|
].concat(classNames).join(" ") }, createElement("div", { className: "fc-timegrid-axis-frame fc-scrollgrid-shrink-frame" + (rowHeight == null ? " fc-timegrid-axis-frame-liquid" : ""), style: { height: rowHeight } }, createElement("span", { className: "fc-timegrid-axis-cushion fc-scrollgrid-shrink-cushion fc-scrollgrid-sync-inner", ref: innerElRef }, innerContent)));
|
|
});
|
|
};
|
|
_this.handleSlatCoords = function(slatCoords) {
|
|
_this.setState({ slatCoords });
|
|
};
|
|
return _this;
|
|
}
|
|
TimeColsView2.prototype.renderSimpleLayout = function(headerRowContent, allDayContent, timeContent) {
|
|
var _a = this, context = _a.context, props = _a.props;
|
|
var sections = [];
|
|
var stickyHeaderDates = getStickyHeaderDates(context.options);
|
|
if (headerRowContent) {
|
|
sections.push({
|
|
type: "header",
|
|
key: "header",
|
|
isSticky: stickyHeaderDates,
|
|
chunk: {
|
|
elRef: this.headerElRef,
|
|
tableClassName: "fc-col-header",
|
|
rowContent: headerRowContent
|
|
}
|
|
});
|
|
}
|
|
if (allDayContent) {
|
|
sections.push({
|
|
type: "body",
|
|
key: "all-day",
|
|
chunk: { content: allDayContent }
|
|
});
|
|
sections.push({
|
|
type: "body",
|
|
key: "all-day-divider",
|
|
outerContent: createElement("tr", { role: "presentation", className: "fc-scrollgrid-section" }, createElement("td", { className: "fc-timegrid-divider " + context.theme.getClass("tableCellShaded") }))
|
|
});
|
|
}
|
|
sections.push({
|
|
type: "body",
|
|
key: "body",
|
|
liquid: true,
|
|
expandRows: Boolean(context.options.expandRows),
|
|
chunk: {
|
|
scrollerElRef: this.scrollerElRef,
|
|
content: timeContent
|
|
}
|
|
});
|
|
return createElement(ViewRoot, { viewSpec: context.viewSpec, elRef: this.rootElRef }, function(rootElRef, classNames) {
|
|
return createElement("div", { className: ["fc-timegrid"].concat(classNames).join(" "), ref: rootElRef }, createElement(SimpleScrollGrid, { liquid: !props.isHeightAuto && !props.forPrint, collapsibleWidth: props.forPrint, cols: [{ width: "shrink" }], sections }));
|
|
});
|
|
};
|
|
TimeColsView2.prototype.renderHScrollLayout = function(headerRowContent, allDayContent, timeContent, colCnt, dayMinWidth, slatMetas, slatCoords) {
|
|
var _this = this;
|
|
var ScrollGrid = this.context.pluginHooks.scrollGridImpl;
|
|
if (!ScrollGrid) {
|
|
throw new Error("No ScrollGrid implementation");
|
|
}
|
|
var _a = this, context = _a.context, props = _a.props;
|
|
var stickyHeaderDates = !props.forPrint && getStickyHeaderDates(context.options);
|
|
var stickyFooterScrollbar = !props.forPrint && getStickyFooterScrollbar(context.options);
|
|
var sections = [];
|
|
if (headerRowContent) {
|
|
sections.push({
|
|
type: "header",
|
|
key: "header",
|
|
isSticky: stickyHeaderDates,
|
|
syncRowHeights: true,
|
|
chunks: [
|
|
{
|
|
key: "axis",
|
|
rowContent: function(arg) {
|
|
return createElement("tr", { role: "presentation" }, _this.renderHeadAxis("day", arg.rowSyncHeights[0]));
|
|
}
|
|
},
|
|
{
|
|
key: "cols",
|
|
elRef: this.headerElRef,
|
|
tableClassName: "fc-col-header",
|
|
rowContent: headerRowContent
|
|
}
|
|
]
|
|
});
|
|
}
|
|
if (allDayContent) {
|
|
sections.push({
|
|
type: "body",
|
|
key: "all-day",
|
|
syncRowHeights: true,
|
|
chunks: [
|
|
{
|
|
key: "axis",
|
|
rowContent: function(contentArg) {
|
|
return createElement("tr", { role: "presentation" }, _this.renderTableRowAxis(contentArg.rowSyncHeights[0]));
|
|
}
|
|
},
|
|
{
|
|
key: "cols",
|
|
content: allDayContent
|
|
}
|
|
]
|
|
});
|
|
sections.push({
|
|
key: "all-day-divider",
|
|
type: "body",
|
|
outerContent: createElement("tr", { role: "presentation", className: "fc-scrollgrid-section" }, createElement("td", { colSpan: 2, className: "fc-timegrid-divider " + context.theme.getClass("tableCellShaded") }))
|
|
});
|
|
}
|
|
var isNowIndicator = context.options.nowIndicator;
|
|
sections.push({
|
|
type: "body",
|
|
key: "body",
|
|
liquid: true,
|
|
expandRows: Boolean(context.options.expandRows),
|
|
chunks: [
|
|
{
|
|
key: "axis",
|
|
content: function(arg) {
|
|
return createElement("div", { className: "fc-timegrid-axis-chunk" }, createElement("table", { "aria-hidden": true, style: { height: arg.expandRows ? arg.clientHeight : "" } }, arg.tableColGroupNode, createElement("tbody", null, createElement(TimeBodyAxis, { slatMetas }))), createElement("div", { className: "fc-timegrid-now-indicator-container" }, createElement(NowTimer, { unit: isNowIndicator ? "minute" : "day" }, function(nowDate) {
|
|
var nowIndicatorTop = isNowIndicator && slatCoords && slatCoords.safeComputeTop(nowDate);
|
|
if (typeof nowIndicatorTop === "number") {
|
|
return createElement(NowIndicatorRoot, { isAxis: true, date: nowDate }, function(rootElRef, classNames, innerElRef, innerContent) {
|
|
return createElement("div", { ref: rootElRef, className: ["fc-timegrid-now-indicator-arrow"].concat(classNames).join(" "), style: { top: nowIndicatorTop } }, innerContent);
|
|
});
|
|
}
|
|
return null;
|
|
})));
|
|
}
|
|
},
|
|
{
|
|
key: "cols",
|
|
scrollerElRef: this.scrollerElRef,
|
|
content: timeContent
|
|
}
|
|
]
|
|
});
|
|
if (stickyFooterScrollbar) {
|
|
sections.push({
|
|
key: "footer",
|
|
type: "footer",
|
|
isSticky: true,
|
|
chunks: [
|
|
{
|
|
key: "axis",
|
|
content: renderScrollShim
|
|
},
|
|
{
|
|
key: "cols",
|
|
content: renderScrollShim
|
|
}
|
|
]
|
|
});
|
|
}
|
|
return createElement(ViewRoot, { viewSpec: context.viewSpec, elRef: this.rootElRef }, function(rootElRef, classNames) {
|
|
return createElement("div", { className: ["fc-timegrid"].concat(classNames).join(" "), ref: rootElRef }, createElement(ScrollGrid, { liquid: !props.isHeightAuto && !props.forPrint, collapsibleWidth: false, colGroups: [
|
|
{ width: "shrink", cols: [{ width: "shrink" }] },
|
|
{ cols: [{ span: colCnt, minWidth: dayMinWidth }] }
|
|
], sections }));
|
|
});
|
|
};
|
|
TimeColsView2.prototype.getAllDayMaxEventProps = function() {
|
|
var _a = this.context.options, dayMaxEvents = _a.dayMaxEvents, dayMaxEventRows = _a.dayMaxEventRows;
|
|
if (dayMaxEvents === true || dayMaxEventRows === true) {
|
|
dayMaxEvents = void 0;
|
|
dayMaxEventRows = AUTO_ALL_DAY_MAX_EVENT_ROWS;
|
|
}
|
|
return { dayMaxEvents, dayMaxEventRows };
|
|
};
|
|
return TimeColsView2;
|
|
}(DateComponent);
|
|
function renderAllDayInner(hookProps) {
|
|
return hookProps.text;
|
|
}
|
|
var TimeColsSlatsCoords = function() {
|
|
function TimeColsSlatsCoords2(positions, dateProfile, slotDuration) {
|
|
this.positions = positions;
|
|
this.dateProfile = dateProfile;
|
|
this.slotDuration = slotDuration;
|
|
}
|
|
TimeColsSlatsCoords2.prototype.safeComputeTop = function(date) {
|
|
var dateProfile = this.dateProfile;
|
|
if (rangeContainsMarker(dateProfile.currentRange, date)) {
|
|
var startOfDayDate = startOfDay(date);
|
|
var timeMs = date.valueOf() - startOfDayDate.valueOf();
|
|
if (timeMs >= asRoughMs(dateProfile.slotMinTime) && timeMs < asRoughMs(dateProfile.slotMaxTime)) {
|
|
return this.computeTimeTop(createDuration(timeMs));
|
|
}
|
|
}
|
|
return null;
|
|
};
|
|
TimeColsSlatsCoords2.prototype.computeDateTop = function(when, startOfDayDate) {
|
|
if (!startOfDayDate) {
|
|
startOfDayDate = startOfDay(when);
|
|
}
|
|
return this.computeTimeTop(createDuration(when.valueOf() - startOfDayDate.valueOf()));
|
|
};
|
|
TimeColsSlatsCoords2.prototype.computeTimeTop = function(duration) {
|
|
var _a = this, positions = _a.positions, dateProfile = _a.dateProfile;
|
|
var len = positions.els.length;
|
|
var slatCoverage = (duration.milliseconds - asRoughMs(dateProfile.slotMinTime)) / asRoughMs(this.slotDuration);
|
|
var slatIndex;
|
|
var slatRemainder;
|
|
slatCoverage = Math.max(0, slatCoverage);
|
|
slatCoverage = Math.min(len, slatCoverage);
|
|
slatIndex = Math.floor(slatCoverage);
|
|
slatIndex = Math.min(slatIndex, len - 1);
|
|
slatRemainder = slatCoverage - slatIndex;
|
|
return positions.tops[slatIndex] + positions.getHeight(slatIndex) * slatRemainder;
|
|
};
|
|
return TimeColsSlatsCoords2;
|
|
}();
|
|
var TimeColsSlatsBody = function(_super) {
|
|
__extends(TimeColsSlatsBody2, _super);
|
|
function TimeColsSlatsBody2() {
|
|
return _super !== null && _super.apply(this, arguments) || this;
|
|
}
|
|
TimeColsSlatsBody2.prototype.render = function() {
|
|
var _a = this, props = _a.props, context = _a.context;
|
|
var options = context.options;
|
|
var slatElRefs = props.slatElRefs;
|
|
return createElement("tbody", null, props.slatMetas.map(function(slatMeta, i3) {
|
|
var hookProps = {
|
|
time: slatMeta.time,
|
|
date: context.dateEnv.toDate(slatMeta.date),
|
|
view: context.viewApi
|
|
};
|
|
var classNames = [
|
|
"fc-timegrid-slot",
|
|
"fc-timegrid-slot-lane",
|
|
slatMeta.isLabeled ? "" : "fc-timegrid-slot-minor"
|
|
];
|
|
return createElement("tr", { key: slatMeta.key, ref: slatElRefs.createRef(slatMeta.key) }, props.axis && createElement(TimeColsAxisCell, __assign({}, slatMeta)), createElement(RenderHook, { hookProps, classNames: options.slotLaneClassNames, content: options.slotLaneContent, didMount: options.slotLaneDidMount, willUnmount: options.slotLaneWillUnmount }, function(rootElRef, customClassNames, innerElRef, innerContent) {
|
|
return createElement("td", { ref: rootElRef, className: classNames.concat(customClassNames).join(" "), "data-time": slatMeta.isoTimeStr }, innerContent);
|
|
}));
|
|
}));
|
|
};
|
|
return TimeColsSlatsBody2;
|
|
}(BaseComponent);
|
|
var TimeColsSlats = function(_super) {
|
|
__extends(TimeColsSlats2, _super);
|
|
function TimeColsSlats2() {
|
|
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
_this.rootElRef = createRef();
|
|
_this.slatElRefs = new RefMap();
|
|
return _this;
|
|
}
|
|
TimeColsSlats2.prototype.render = function() {
|
|
var _a = this, props = _a.props, context = _a.context;
|
|
return createElement("div", { ref: this.rootElRef, className: "fc-timegrid-slots" }, createElement("table", { "aria-hidden": true, className: context.theme.getClass("table"), style: {
|
|
minWidth: props.tableMinWidth,
|
|
width: props.clientWidth,
|
|
height: props.minHeight
|
|
} }, props.tableColGroupNode, createElement(TimeColsSlatsBody, { slatElRefs: this.slatElRefs, axis: props.axis, slatMetas: props.slatMetas })));
|
|
};
|
|
TimeColsSlats2.prototype.componentDidMount = function() {
|
|
this.updateSizing();
|
|
};
|
|
TimeColsSlats2.prototype.componentDidUpdate = function() {
|
|
this.updateSizing();
|
|
};
|
|
TimeColsSlats2.prototype.componentWillUnmount = function() {
|
|
if (this.props.onCoords) {
|
|
this.props.onCoords(null);
|
|
}
|
|
};
|
|
TimeColsSlats2.prototype.updateSizing = function() {
|
|
var _a = this, context = _a.context, props = _a.props;
|
|
if (props.onCoords && props.clientWidth !== null) {
|
|
var rootEl = this.rootElRef.current;
|
|
if (rootEl.offsetHeight) {
|
|
props.onCoords(new TimeColsSlatsCoords(new PositionCache(this.rootElRef.current, collectSlatEls(this.slatElRefs.currentMap, props.slatMetas), false, true), this.props.dateProfile, context.options.slotDuration));
|
|
}
|
|
}
|
|
};
|
|
return TimeColsSlats2;
|
|
}(BaseComponent);
|
|
function collectSlatEls(elMap, slatMetas) {
|
|
return slatMetas.map(function(slatMeta) {
|
|
return elMap[slatMeta.key];
|
|
});
|
|
}
|
|
function splitSegsByCol(segs, colCnt) {
|
|
var segsByCol = [];
|
|
var i3;
|
|
for (i3 = 0; i3 < colCnt; i3 += 1) {
|
|
segsByCol.push([]);
|
|
}
|
|
if (segs) {
|
|
for (i3 = 0; i3 < segs.length; i3 += 1) {
|
|
segsByCol[segs[i3].col].push(segs[i3]);
|
|
}
|
|
}
|
|
return segsByCol;
|
|
}
|
|
function splitInteractionByCol(ui, colCnt) {
|
|
var byRow = [];
|
|
if (!ui) {
|
|
for (var i3 = 0; i3 < colCnt; i3 += 1) {
|
|
byRow[i3] = null;
|
|
}
|
|
} else {
|
|
for (var i3 = 0; i3 < colCnt; i3 += 1) {
|
|
byRow[i3] = {
|
|
affectedInstances: ui.affectedInstances,
|
|
isEvent: ui.isEvent,
|
|
segs: []
|
|
};
|
|
}
|
|
for (var _i = 0, _a = ui.segs; _i < _a.length; _i++) {
|
|
var seg = _a[_i];
|
|
byRow[seg.col].segs.push(seg);
|
|
}
|
|
}
|
|
return byRow;
|
|
}
|
|
var TimeColMoreLink = function(_super) {
|
|
__extends(TimeColMoreLink2, _super);
|
|
function TimeColMoreLink2() {
|
|
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
_this.rootElRef = createRef();
|
|
return _this;
|
|
}
|
|
TimeColMoreLink2.prototype.render = function() {
|
|
var _this = this;
|
|
var props = this.props;
|
|
return createElement(MoreLinkRoot, { allDayDate: null, moreCnt: props.hiddenSegs.length, allSegs: props.hiddenSegs, hiddenSegs: props.hiddenSegs, alignmentElRef: this.rootElRef, defaultContent: renderMoreLinkInner2, extraDateSpan: props.extraDateSpan, dateProfile: props.dateProfile, todayRange: props.todayRange, popoverContent: function() {
|
|
return renderPlainFgSegs(props.hiddenSegs, props);
|
|
} }, function(rootElRef, classNames, innerElRef, innerContent, handleClick, title, isExpanded, popoverId) {
|
|
return createElement("a", { ref: function(el) {
|
|
setRef(rootElRef, el);
|
|
setRef(_this.rootElRef, el);
|
|
}, className: ["fc-timegrid-more-link"].concat(classNames).join(" "), style: { top: props.top, bottom: props.bottom }, onClick: handleClick, title, "aria-expanded": isExpanded, "aria-controls": popoverId }, createElement("div", { ref: innerElRef, className: "fc-timegrid-more-link-inner fc-sticky" }, innerContent));
|
|
});
|
|
};
|
|
return TimeColMoreLink2;
|
|
}(BaseComponent);
|
|
function renderMoreLinkInner2(props) {
|
|
return props.shortText;
|
|
}
|
|
function buildPositioning(segInputs, strictOrder, maxStackCnt) {
|
|
var hierarchy = new SegHierarchy();
|
|
if (strictOrder != null) {
|
|
hierarchy.strictOrder = strictOrder;
|
|
}
|
|
if (maxStackCnt != null) {
|
|
hierarchy.maxStackCnt = maxStackCnt;
|
|
}
|
|
var hiddenEntries = hierarchy.addSegs(segInputs);
|
|
var hiddenGroups = groupIntersectingEntries(hiddenEntries);
|
|
var web = buildWeb(hierarchy);
|
|
web = stretchWeb(web, 1);
|
|
var segRects = webToRects(web);
|
|
return { segRects, hiddenGroups };
|
|
}
|
|
function buildWeb(hierarchy) {
|
|
var entriesByLevel = hierarchy.entriesByLevel;
|
|
var buildNode = cacheable(function(level, lateral) {
|
|
return level + ":" + lateral;
|
|
}, function(level, lateral) {
|
|
var siblingRange = findNextLevelSegs(hierarchy, level, lateral);
|
|
var nextLevelRes = buildNodes(siblingRange, buildNode);
|
|
var entry = entriesByLevel[level][lateral];
|
|
return [
|
|
__assign(__assign({}, entry), { nextLevelNodes: nextLevelRes[0] }),
|
|
entry.thickness + nextLevelRes[1]
|
|
];
|
|
});
|
|
return buildNodes(entriesByLevel.length ? { level: 0, lateralStart: 0, lateralEnd: entriesByLevel[0].length } : null, buildNode)[0];
|
|
}
|
|
function buildNodes(siblingRange, buildNode) {
|
|
if (!siblingRange) {
|
|
return [[], 0];
|
|
}
|
|
var level = siblingRange.level, lateralStart = siblingRange.lateralStart, lateralEnd = siblingRange.lateralEnd;
|
|
var lateral = lateralStart;
|
|
var pairs = [];
|
|
while (lateral < lateralEnd) {
|
|
pairs.push(buildNode(level, lateral));
|
|
lateral += 1;
|
|
}
|
|
pairs.sort(cmpDescPressures);
|
|
return [
|
|
pairs.map(extractNode),
|
|
pairs[0][1]
|
|
];
|
|
}
|
|
function cmpDescPressures(a3, b3) {
|
|
return b3[1] - a3[1];
|
|
}
|
|
function extractNode(a3) {
|
|
return a3[0];
|
|
}
|
|
function findNextLevelSegs(hierarchy, subjectLevel, subjectLateral) {
|
|
var levelCoords = hierarchy.levelCoords, entriesByLevel = hierarchy.entriesByLevel;
|
|
var subjectEntry = entriesByLevel[subjectLevel][subjectLateral];
|
|
var afterSubject = levelCoords[subjectLevel] + subjectEntry.thickness;
|
|
var levelCnt = levelCoords.length;
|
|
var level = subjectLevel;
|
|
for (; level < levelCnt && levelCoords[level] < afterSubject; level += 1)
|
|
;
|
|
for (; level < levelCnt; level += 1) {
|
|
var entries = entriesByLevel[level];
|
|
var entry = void 0;
|
|
var searchIndex = binarySearch(entries, subjectEntry.span.start, getEntrySpanEnd);
|
|
var lateralStart = searchIndex[0] + searchIndex[1];
|
|
var lateralEnd = lateralStart;
|
|
while ((entry = entries[lateralEnd]) && entry.span.start < subjectEntry.span.end) {
|
|
lateralEnd += 1;
|
|
}
|
|
if (lateralStart < lateralEnd) {
|
|
return { level, lateralStart, lateralEnd };
|
|
}
|
|
}
|
|
return null;
|
|
}
|
|
function stretchWeb(topLevelNodes, totalThickness) {
|
|
var stretchNode = cacheable(function(node, startCoord, prevThickness) {
|
|
return buildEntryKey(node);
|
|
}, function(node, startCoord, prevThickness) {
|
|
var nextLevelNodes = node.nextLevelNodes, thickness = node.thickness;
|
|
var allThickness = thickness + prevThickness;
|
|
var thicknessFraction = thickness / allThickness;
|
|
var endCoord;
|
|
var newChildren = [];
|
|
if (!nextLevelNodes.length) {
|
|
endCoord = totalThickness;
|
|
} else {
|
|
for (var _i = 0, nextLevelNodes_1 = nextLevelNodes; _i < nextLevelNodes_1.length; _i++) {
|
|
var childNode = nextLevelNodes_1[_i];
|
|
if (endCoord === void 0) {
|
|
var res = stretchNode(childNode, startCoord, allThickness);
|
|
endCoord = res[0];
|
|
newChildren.push(res[1]);
|
|
} else {
|
|
var res = stretchNode(childNode, endCoord, 0);
|
|
newChildren.push(res[1]);
|
|
}
|
|
}
|
|
}
|
|
var newThickness = (endCoord - startCoord) * thicknessFraction;
|
|
return [endCoord - newThickness, __assign(__assign({}, node), { thickness: newThickness, nextLevelNodes: newChildren })];
|
|
});
|
|
return topLevelNodes.map(function(node) {
|
|
return stretchNode(node, 0, 0)[1];
|
|
});
|
|
}
|
|
function webToRects(topLevelNodes) {
|
|
var rects = [];
|
|
var processNode = cacheable(function(node, levelCoord, stackDepth) {
|
|
return buildEntryKey(node);
|
|
}, function(node, levelCoord, stackDepth) {
|
|
var rect = __assign(__assign({}, node), {
|
|
levelCoord,
|
|
stackDepth,
|
|
stackForward: 0
|
|
});
|
|
rects.push(rect);
|
|
return rect.stackForward = processNodes(node.nextLevelNodes, levelCoord + node.thickness, stackDepth + 1) + 1;
|
|
});
|
|
function processNodes(nodes, levelCoord, stackDepth) {
|
|
var stackForward = 0;
|
|
for (var _i = 0, nodes_1 = nodes; _i < nodes_1.length; _i++) {
|
|
var node = nodes_1[_i];
|
|
stackForward = Math.max(processNode(node, levelCoord, stackDepth), stackForward);
|
|
}
|
|
return stackForward;
|
|
}
|
|
processNodes(topLevelNodes, 0, 0);
|
|
return rects;
|
|
}
|
|
function cacheable(keyFunc, workFunc) {
|
|
var cache = {};
|
|
return function() {
|
|
var args = [];
|
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
args[_i] = arguments[_i];
|
|
}
|
|
var key = keyFunc.apply(void 0, args);
|
|
return key in cache ? cache[key] : cache[key] = workFunc.apply(void 0, args);
|
|
};
|
|
}
|
|
function computeSegVCoords(segs, colDate, slatCoords, eventMinHeight) {
|
|
if (slatCoords === void 0) {
|
|
slatCoords = null;
|
|
}
|
|
if (eventMinHeight === void 0) {
|
|
eventMinHeight = 0;
|
|
}
|
|
var vcoords = [];
|
|
if (slatCoords) {
|
|
for (var i3 = 0; i3 < segs.length; i3 += 1) {
|
|
var seg = segs[i3];
|
|
var spanStart = slatCoords.computeDateTop(seg.start, colDate);
|
|
var spanEnd = Math.max(spanStart + (eventMinHeight || 0), slatCoords.computeDateTop(seg.end, colDate));
|
|
vcoords.push({
|
|
start: Math.round(spanStart),
|
|
end: Math.round(spanEnd)
|
|
});
|
|
}
|
|
}
|
|
return vcoords;
|
|
}
|
|
function computeFgSegPlacements(segs, segVCoords, eventOrderStrict, eventMaxStack) {
|
|
var segInputs = [];
|
|
var dumbSegs = [];
|
|
for (var i3 = 0; i3 < segs.length; i3 += 1) {
|
|
var vcoords = segVCoords[i3];
|
|
if (vcoords) {
|
|
segInputs.push({
|
|
index: i3,
|
|
thickness: 1,
|
|
span: vcoords
|
|
});
|
|
} else {
|
|
dumbSegs.push(segs[i3]);
|
|
}
|
|
}
|
|
var _a = buildPositioning(segInputs, eventOrderStrict, eventMaxStack), segRects = _a.segRects, hiddenGroups = _a.hiddenGroups;
|
|
var segPlacements = [];
|
|
for (var _i = 0, segRects_1 = segRects; _i < segRects_1.length; _i++) {
|
|
var segRect = segRects_1[_i];
|
|
segPlacements.push({
|
|
seg: segs[segRect.index],
|
|
rect: segRect
|
|
});
|
|
}
|
|
for (var _b = 0, dumbSegs_1 = dumbSegs; _b < dumbSegs_1.length; _b++) {
|
|
var dumbSeg = dumbSegs_1[_b];
|
|
segPlacements.push({ seg: dumbSeg, rect: null });
|
|
}
|
|
return { segPlacements, hiddenGroups };
|
|
}
|
|
var DEFAULT_TIME_FORMAT = createFormatter({
|
|
hour: "numeric",
|
|
minute: "2-digit",
|
|
meridiem: false
|
|
});
|
|
var TimeColEvent = function(_super) {
|
|
__extends(TimeColEvent2, _super);
|
|
function TimeColEvent2() {
|
|
return _super !== null && _super.apply(this, arguments) || this;
|
|
}
|
|
TimeColEvent2.prototype.render = function() {
|
|
var classNames = [
|
|
"fc-timegrid-event",
|
|
"fc-v-event"
|
|
];
|
|
if (this.props.isShort) {
|
|
classNames.push("fc-timegrid-event-short");
|
|
}
|
|
return createElement(StandardEvent, __assign({}, this.props, { defaultTimeFormat: DEFAULT_TIME_FORMAT, extraClassNames: classNames }));
|
|
};
|
|
return TimeColEvent2;
|
|
}(BaseComponent);
|
|
var TimeColMisc = function(_super) {
|
|
__extends(TimeColMisc2, _super);
|
|
function TimeColMisc2() {
|
|
return _super !== null && _super.apply(this, arguments) || this;
|
|
}
|
|
TimeColMisc2.prototype.render = function() {
|
|
var props = this.props;
|
|
return createElement(DayCellContent, { date: props.date, dateProfile: props.dateProfile, todayRange: props.todayRange, extraHookProps: props.extraHookProps }, function(innerElRef, innerContent) {
|
|
return innerContent && createElement("div", { className: "fc-timegrid-col-misc", ref: innerElRef }, innerContent);
|
|
});
|
|
};
|
|
return TimeColMisc2;
|
|
}(BaseComponent);
|
|
var TimeCol = function(_super) {
|
|
__extends(TimeCol2, _super);
|
|
function TimeCol2() {
|
|
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
_this.sortEventSegs = memoize(sortEventSegs);
|
|
return _this;
|
|
}
|
|
TimeCol2.prototype.render = function() {
|
|
var _this = this;
|
|
var _a = this, props = _a.props, context = _a.context;
|
|
var isSelectMirror = context.options.selectMirror;
|
|
var mirrorSegs = props.eventDrag && props.eventDrag.segs || props.eventResize && props.eventResize.segs || isSelectMirror && props.dateSelectionSegs || [];
|
|
var interactionAffectedInstances = props.eventDrag && props.eventDrag.affectedInstances || props.eventResize && props.eventResize.affectedInstances || {};
|
|
var sortedFgSegs = this.sortEventSegs(props.fgEventSegs, context.options.eventOrder);
|
|
return createElement(DayCellRoot, { elRef: props.elRef, date: props.date, dateProfile: props.dateProfile, todayRange: props.todayRange, extraHookProps: props.extraHookProps }, function(rootElRef, classNames, dataAttrs) {
|
|
return createElement("td", __assign({ ref: rootElRef, role: "gridcell", className: ["fc-timegrid-col"].concat(classNames, props.extraClassNames || []).join(" ") }, dataAttrs, props.extraDataAttrs), createElement("div", { className: "fc-timegrid-col-frame" }, createElement("div", { className: "fc-timegrid-col-bg" }, _this.renderFillSegs(props.businessHourSegs, "non-business"), _this.renderFillSegs(props.bgEventSegs, "bg-event"), _this.renderFillSegs(props.dateSelectionSegs, "highlight")), createElement("div", { className: "fc-timegrid-col-events" }, _this.renderFgSegs(sortedFgSegs, interactionAffectedInstances, false, false, false)), createElement("div", { className: "fc-timegrid-col-events" }, _this.renderFgSegs(mirrorSegs, {}, Boolean(props.eventDrag), Boolean(props.eventResize), Boolean(isSelectMirror))), createElement("div", { className: "fc-timegrid-now-indicator-container" }, _this.renderNowIndicator(props.nowIndicatorSegs)), createElement(TimeColMisc, { date: props.date, dateProfile: props.dateProfile, todayRange: props.todayRange, extraHookProps: props.extraHookProps })));
|
|
});
|
|
};
|
|
TimeCol2.prototype.renderFgSegs = function(sortedFgSegs, segIsInvisible, isDragging, isResizing, isDateSelecting) {
|
|
var props = this.props;
|
|
if (props.forPrint) {
|
|
return renderPlainFgSegs(sortedFgSegs, props);
|
|
}
|
|
return this.renderPositionedFgSegs(sortedFgSegs, segIsInvisible, isDragging, isResizing, isDateSelecting);
|
|
};
|
|
TimeCol2.prototype.renderPositionedFgSegs = function(segs, segIsInvisible, isDragging, isResizing, isDateSelecting) {
|
|
var _this = this;
|
|
var _a = this.context.options, eventMaxStack = _a.eventMaxStack, eventShortHeight = _a.eventShortHeight, eventOrderStrict = _a.eventOrderStrict, eventMinHeight = _a.eventMinHeight;
|
|
var _b = this.props, date = _b.date, slatCoords = _b.slatCoords, eventSelection = _b.eventSelection, todayRange = _b.todayRange, nowDate = _b.nowDate;
|
|
var isMirror = isDragging || isResizing || isDateSelecting;
|
|
var segVCoords = computeSegVCoords(segs, date, slatCoords, eventMinHeight);
|
|
var _c = computeFgSegPlacements(segs, segVCoords, eventOrderStrict, eventMaxStack), segPlacements = _c.segPlacements, hiddenGroups = _c.hiddenGroups;
|
|
return createElement(Fragment, null, this.renderHiddenGroups(hiddenGroups, segs), segPlacements.map(function(segPlacement) {
|
|
var seg = segPlacement.seg, rect = segPlacement.rect;
|
|
var instanceId = seg.eventRange.instance.instanceId;
|
|
var isVisible = isMirror || Boolean(!segIsInvisible[instanceId] && rect);
|
|
var vStyle = computeSegVStyle(rect && rect.span);
|
|
var hStyle = !isMirror && rect ? _this.computeSegHStyle(rect) : { left: 0, right: 0 };
|
|
var isInset = Boolean(rect) && rect.stackForward > 0;
|
|
var isShort = Boolean(rect) && rect.span.end - rect.span.start < eventShortHeight;
|
|
return createElement("div", { className: "fc-timegrid-event-harness" + (isInset ? " fc-timegrid-event-harness-inset" : ""), key: instanceId, style: __assign(__assign({ visibility: isVisible ? "" : "hidden" }, vStyle), hStyle) }, createElement(TimeColEvent, __assign({ seg, isDragging, isResizing, isDateSelecting, isSelected: instanceId === eventSelection, isShort }, getSegMeta(seg, todayRange, nowDate))));
|
|
}));
|
|
};
|
|
TimeCol2.prototype.renderHiddenGroups = function(hiddenGroups, segs) {
|
|
var _a = this.props, extraDateSpan = _a.extraDateSpan, dateProfile = _a.dateProfile, todayRange = _a.todayRange, nowDate = _a.nowDate, eventSelection = _a.eventSelection, eventDrag = _a.eventDrag, eventResize = _a.eventResize;
|
|
return createElement(Fragment, null, hiddenGroups.map(function(hiddenGroup) {
|
|
var positionCss = computeSegVStyle(hiddenGroup.span);
|
|
var hiddenSegs = compileSegsFromEntries(hiddenGroup.entries, segs);
|
|
return createElement(TimeColMoreLink, { key: buildIsoString(computeEarliestSegStart(hiddenSegs)), hiddenSegs, top: positionCss.top, bottom: positionCss.bottom, extraDateSpan, dateProfile, todayRange, nowDate, eventSelection, eventDrag, eventResize });
|
|
}));
|
|
};
|
|
TimeCol2.prototype.renderFillSegs = function(segs, fillType) {
|
|
var _a = this, props = _a.props, context = _a.context;
|
|
var segVCoords = computeSegVCoords(segs, props.date, props.slatCoords, context.options.eventMinHeight);
|
|
var children = segVCoords.map(function(vcoords, i3) {
|
|
var seg = segs[i3];
|
|
return createElement("div", { key: buildEventRangeKey(seg.eventRange), className: "fc-timegrid-bg-harness", style: computeSegVStyle(vcoords) }, fillType === "bg-event" ? createElement(BgEvent, __assign({ seg }, getSegMeta(seg, props.todayRange, props.nowDate))) : renderFill(fillType));
|
|
});
|
|
return createElement(Fragment, null, children);
|
|
};
|
|
TimeCol2.prototype.renderNowIndicator = function(segs) {
|
|
var _a = this.props, slatCoords = _a.slatCoords, date = _a.date;
|
|
if (!slatCoords) {
|
|
return null;
|
|
}
|
|
return segs.map(function(seg, i3) {
|
|
return createElement(NowIndicatorRoot, {
|
|
isAxis: false,
|
|
date,
|
|
key: i3
|
|
}, function(rootElRef, classNames, innerElRef, innerContent) {
|
|
return createElement("div", { ref: rootElRef, className: ["fc-timegrid-now-indicator-line"].concat(classNames).join(" "), style: { top: slatCoords.computeDateTop(seg.start, date) } }, innerContent);
|
|
});
|
|
});
|
|
};
|
|
TimeCol2.prototype.computeSegHStyle = function(segHCoords) {
|
|
var _a = this.context, isRtl = _a.isRtl, options = _a.options;
|
|
var shouldOverlap = options.slotEventOverlap;
|
|
var nearCoord = segHCoords.levelCoord;
|
|
var farCoord = segHCoords.levelCoord + segHCoords.thickness;
|
|
var left;
|
|
var right;
|
|
if (shouldOverlap) {
|
|
farCoord = Math.min(1, nearCoord + (farCoord - nearCoord) * 2);
|
|
}
|
|
if (isRtl) {
|
|
left = 1 - farCoord;
|
|
right = nearCoord;
|
|
} else {
|
|
left = nearCoord;
|
|
right = 1 - farCoord;
|
|
}
|
|
var props = {
|
|
zIndex: segHCoords.stackDepth + 1,
|
|
left: left * 100 + "%",
|
|
right: right * 100 + "%"
|
|
};
|
|
if (shouldOverlap && !segHCoords.stackForward) {
|
|
props[isRtl ? "marginLeft" : "marginRight"] = 10 * 2;
|
|
}
|
|
return props;
|
|
};
|
|
return TimeCol2;
|
|
}(BaseComponent);
|
|
function renderPlainFgSegs(sortedFgSegs, _a) {
|
|
var todayRange = _a.todayRange, nowDate = _a.nowDate, eventSelection = _a.eventSelection, eventDrag = _a.eventDrag, eventResize = _a.eventResize;
|
|
var hiddenInstances = (eventDrag ? eventDrag.affectedInstances : null) || (eventResize ? eventResize.affectedInstances : null) || {};
|
|
return createElement(Fragment, null, sortedFgSegs.map(function(seg) {
|
|
var instanceId = seg.eventRange.instance.instanceId;
|
|
return createElement("div", { key: instanceId, style: { visibility: hiddenInstances[instanceId] ? "hidden" : "" } }, createElement(TimeColEvent, __assign({ seg, isDragging: false, isResizing: false, isDateSelecting: false, isSelected: instanceId === eventSelection, isShort: false }, getSegMeta(seg, todayRange, nowDate))));
|
|
}));
|
|
}
|
|
function computeSegVStyle(segVCoords) {
|
|
if (!segVCoords) {
|
|
return { top: "", bottom: "" };
|
|
}
|
|
return {
|
|
top: segVCoords.start,
|
|
bottom: -segVCoords.end
|
|
};
|
|
}
|
|
function compileSegsFromEntries(segEntries, allSegs) {
|
|
return segEntries.map(function(segEntry) {
|
|
return allSegs[segEntry.index];
|
|
});
|
|
}
|
|
var TimeColsContent = function(_super) {
|
|
__extends(TimeColsContent2, _super);
|
|
function TimeColsContent2() {
|
|
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
_this.splitFgEventSegs = memoize(splitSegsByCol);
|
|
_this.splitBgEventSegs = memoize(splitSegsByCol);
|
|
_this.splitBusinessHourSegs = memoize(splitSegsByCol);
|
|
_this.splitNowIndicatorSegs = memoize(splitSegsByCol);
|
|
_this.splitDateSelectionSegs = memoize(splitSegsByCol);
|
|
_this.splitEventDrag = memoize(splitInteractionByCol);
|
|
_this.splitEventResize = memoize(splitInteractionByCol);
|
|
_this.rootElRef = createRef();
|
|
_this.cellElRefs = new RefMap();
|
|
return _this;
|
|
}
|
|
TimeColsContent2.prototype.render = function() {
|
|
var _this = this;
|
|
var _a = this, props = _a.props, context = _a.context;
|
|
var nowIndicatorTop = context.options.nowIndicator && props.slatCoords && props.slatCoords.safeComputeTop(props.nowDate);
|
|
var colCnt = props.cells.length;
|
|
var fgEventSegsByRow = this.splitFgEventSegs(props.fgEventSegs, colCnt);
|
|
var bgEventSegsByRow = this.splitBgEventSegs(props.bgEventSegs, colCnt);
|
|
var businessHourSegsByRow = this.splitBusinessHourSegs(props.businessHourSegs, colCnt);
|
|
var nowIndicatorSegsByRow = this.splitNowIndicatorSegs(props.nowIndicatorSegs, colCnt);
|
|
var dateSelectionSegsByRow = this.splitDateSelectionSegs(props.dateSelectionSegs, colCnt);
|
|
var eventDragByRow = this.splitEventDrag(props.eventDrag, colCnt);
|
|
var eventResizeByRow = this.splitEventResize(props.eventResize, colCnt);
|
|
return createElement("div", { className: "fc-timegrid-cols", ref: this.rootElRef }, createElement("table", { role: "presentation", style: {
|
|
minWidth: props.tableMinWidth,
|
|
width: props.clientWidth
|
|
} }, props.tableColGroupNode, createElement("tbody", { role: "presentation" }, createElement("tr", { role: "row" }, props.axis && createElement("td", { "aria-hidden": true, className: "fc-timegrid-col fc-timegrid-axis" }, createElement("div", { className: "fc-timegrid-col-frame" }, createElement("div", { className: "fc-timegrid-now-indicator-container" }, typeof nowIndicatorTop === "number" && createElement(NowIndicatorRoot, { isAxis: true, date: props.nowDate }, function(rootElRef, classNames, innerElRef, innerContent) {
|
|
return createElement("div", { ref: rootElRef, className: ["fc-timegrid-now-indicator-arrow"].concat(classNames).join(" "), style: { top: nowIndicatorTop } }, innerContent);
|
|
})))), props.cells.map(function(cell, i3) {
|
|
return createElement(TimeCol, { key: cell.key, elRef: _this.cellElRefs.createRef(cell.key), dateProfile: props.dateProfile, date: cell.date, nowDate: props.nowDate, todayRange: props.todayRange, extraHookProps: cell.extraHookProps, extraDataAttrs: cell.extraDataAttrs, extraClassNames: cell.extraClassNames, extraDateSpan: cell.extraDateSpan, fgEventSegs: fgEventSegsByRow[i3], bgEventSegs: bgEventSegsByRow[i3], businessHourSegs: businessHourSegsByRow[i3], nowIndicatorSegs: nowIndicatorSegsByRow[i3], dateSelectionSegs: dateSelectionSegsByRow[i3], eventDrag: eventDragByRow[i3], eventResize: eventResizeByRow[i3], slatCoords: props.slatCoords, eventSelection: props.eventSelection, forPrint: props.forPrint });
|
|
})))));
|
|
};
|
|
TimeColsContent2.prototype.componentDidMount = function() {
|
|
this.updateCoords();
|
|
};
|
|
TimeColsContent2.prototype.componentDidUpdate = function() {
|
|
this.updateCoords();
|
|
};
|
|
TimeColsContent2.prototype.updateCoords = function() {
|
|
var props = this.props;
|
|
if (props.onColCoords && props.clientWidth !== null) {
|
|
props.onColCoords(new PositionCache(this.rootElRef.current, collectCellEls(this.cellElRefs.currentMap, props.cells), true, false));
|
|
}
|
|
};
|
|
return TimeColsContent2;
|
|
}(BaseComponent);
|
|
function collectCellEls(elMap, cells) {
|
|
return cells.map(function(cell) {
|
|
return elMap[cell.key];
|
|
});
|
|
}
|
|
var TimeCols = function(_super) {
|
|
__extends(TimeCols2, _super);
|
|
function TimeCols2() {
|
|
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
_this.processSlotOptions = memoize(processSlotOptions);
|
|
_this.state = {
|
|
slatCoords: null
|
|
};
|
|
_this.handleRootEl = function(el) {
|
|
if (el) {
|
|
_this.context.registerInteractiveComponent(_this, {
|
|
el,
|
|
isHitComboAllowed: _this.props.isHitComboAllowed
|
|
});
|
|
} else {
|
|
_this.context.unregisterInteractiveComponent(_this);
|
|
}
|
|
};
|
|
_this.handleScrollRequest = function(request3) {
|
|
var onScrollTopRequest = _this.props.onScrollTopRequest;
|
|
var slatCoords = _this.state.slatCoords;
|
|
if (onScrollTopRequest && slatCoords) {
|
|
if (request3.time) {
|
|
var top_1 = slatCoords.computeTimeTop(request3.time);
|
|
top_1 = Math.ceil(top_1);
|
|
if (top_1) {
|
|
top_1 += 1;
|
|
}
|
|
onScrollTopRequest(top_1);
|
|
}
|
|
return true;
|
|
}
|
|
return false;
|
|
};
|
|
_this.handleColCoords = function(colCoords) {
|
|
_this.colCoords = colCoords;
|
|
};
|
|
_this.handleSlatCoords = function(slatCoords) {
|
|
_this.setState({ slatCoords });
|
|
if (_this.props.onSlatCoords) {
|
|
_this.props.onSlatCoords(slatCoords);
|
|
}
|
|
};
|
|
return _this;
|
|
}
|
|
TimeCols2.prototype.render = function() {
|
|
var _a = this, props = _a.props, state = _a.state;
|
|
return createElement("div", { className: "fc-timegrid-body", ref: this.handleRootEl, style: {
|
|
width: props.clientWidth,
|
|
minWidth: props.tableMinWidth
|
|
} }, createElement(TimeColsSlats, { axis: props.axis, dateProfile: props.dateProfile, slatMetas: props.slatMetas, clientWidth: props.clientWidth, minHeight: props.expandRows ? props.clientHeight : "", tableMinWidth: props.tableMinWidth, tableColGroupNode: props.axis ? props.tableColGroupNode : null, onCoords: this.handleSlatCoords }), createElement(TimeColsContent, { cells: props.cells, axis: props.axis, dateProfile: props.dateProfile, businessHourSegs: props.businessHourSegs, bgEventSegs: props.bgEventSegs, fgEventSegs: props.fgEventSegs, dateSelectionSegs: props.dateSelectionSegs, eventSelection: props.eventSelection, eventDrag: props.eventDrag, eventResize: props.eventResize, todayRange: props.todayRange, nowDate: props.nowDate, nowIndicatorSegs: props.nowIndicatorSegs, clientWidth: props.clientWidth, tableMinWidth: props.tableMinWidth, tableColGroupNode: props.tableColGroupNode, slatCoords: state.slatCoords, onColCoords: this.handleColCoords, forPrint: props.forPrint }));
|
|
};
|
|
TimeCols2.prototype.componentDidMount = function() {
|
|
this.scrollResponder = this.context.createScrollResponder(this.handleScrollRequest);
|
|
};
|
|
TimeCols2.prototype.componentDidUpdate = function(prevProps) {
|
|
this.scrollResponder.update(prevProps.dateProfile !== this.props.dateProfile);
|
|
};
|
|
TimeCols2.prototype.componentWillUnmount = function() {
|
|
this.scrollResponder.detach();
|
|
};
|
|
TimeCols2.prototype.queryHit = function(positionLeft, positionTop) {
|
|
var _a = this.context, dateEnv = _a.dateEnv, options = _a.options;
|
|
var colCoords = this.colCoords;
|
|
var dateProfile = this.props.dateProfile;
|
|
var slatCoords = this.state.slatCoords;
|
|
var _b = this.processSlotOptions(this.props.slotDuration, options.snapDuration), snapDuration = _b.snapDuration, snapsPerSlot = _b.snapsPerSlot;
|
|
var colIndex = colCoords.leftToIndex(positionLeft);
|
|
var slatIndex = slatCoords.positions.topToIndex(positionTop);
|
|
if (colIndex != null && slatIndex != null) {
|
|
var cell = this.props.cells[colIndex];
|
|
var slatTop = slatCoords.positions.tops[slatIndex];
|
|
var slatHeight = slatCoords.positions.getHeight(slatIndex);
|
|
var partial = (positionTop - slatTop) / slatHeight;
|
|
var localSnapIndex = Math.floor(partial * snapsPerSlot);
|
|
var snapIndex = slatIndex * snapsPerSlot + localSnapIndex;
|
|
var dayDate = this.props.cells[colIndex].date;
|
|
var time = addDurations(dateProfile.slotMinTime, multiplyDuration(snapDuration, snapIndex));
|
|
var start = dateEnv.add(dayDate, time);
|
|
var end = dateEnv.add(start, snapDuration);
|
|
return {
|
|
dateProfile,
|
|
dateSpan: __assign({ range: { start, end }, allDay: false }, cell.extraDateSpan),
|
|
dayEl: colCoords.els[colIndex],
|
|
rect: {
|
|
left: colCoords.lefts[colIndex],
|
|
right: colCoords.rights[colIndex],
|
|
top: slatTop,
|
|
bottom: slatTop + slatHeight
|
|
},
|
|
layer: 0
|
|
};
|
|
}
|
|
return null;
|
|
};
|
|
return TimeCols2;
|
|
}(DateComponent);
|
|
function processSlotOptions(slotDuration, snapDurationOverride) {
|
|
var snapDuration = snapDurationOverride || slotDuration;
|
|
var snapsPerSlot = wholeDivideDurations(slotDuration, snapDuration);
|
|
if (snapsPerSlot === null) {
|
|
snapDuration = slotDuration;
|
|
snapsPerSlot = 1;
|
|
}
|
|
return { snapDuration, snapsPerSlot };
|
|
}
|
|
var DayTimeColsSlicer = function(_super) {
|
|
__extends(DayTimeColsSlicer2, _super);
|
|
function DayTimeColsSlicer2() {
|
|
return _super !== null && _super.apply(this, arguments) || this;
|
|
}
|
|
DayTimeColsSlicer2.prototype.sliceRange = function(range, dayRanges) {
|
|
var segs = [];
|
|
for (var col = 0; col < dayRanges.length; col += 1) {
|
|
var segRange = intersectRanges(range, dayRanges[col]);
|
|
if (segRange) {
|
|
segs.push({
|
|
start: segRange.start,
|
|
end: segRange.end,
|
|
isStart: segRange.start.valueOf() === range.start.valueOf(),
|
|
isEnd: segRange.end.valueOf() === range.end.valueOf(),
|
|
col
|
|
});
|
|
}
|
|
}
|
|
return segs;
|
|
};
|
|
return DayTimeColsSlicer2;
|
|
}(Slicer);
|
|
var DayTimeCols = function(_super) {
|
|
__extends(DayTimeCols2, _super);
|
|
function DayTimeCols2() {
|
|
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
_this.buildDayRanges = memoize(buildDayRanges);
|
|
_this.slicer = new DayTimeColsSlicer();
|
|
_this.timeColsRef = createRef();
|
|
return _this;
|
|
}
|
|
DayTimeCols2.prototype.render = function() {
|
|
var _this = this;
|
|
var _a = this, props = _a.props, context = _a.context;
|
|
var dateProfile = props.dateProfile, dayTableModel = props.dayTableModel;
|
|
var isNowIndicator = context.options.nowIndicator;
|
|
var dayRanges = this.buildDayRanges(dayTableModel, dateProfile, context.dateEnv);
|
|
return createElement(NowTimer, { unit: isNowIndicator ? "minute" : "day" }, function(nowDate, todayRange) {
|
|
return createElement(TimeCols, __assign({ ref: _this.timeColsRef }, _this.slicer.sliceProps(props, dateProfile, null, context, dayRanges), { forPrint: props.forPrint, axis: props.axis, dateProfile, slatMetas: props.slatMetas, slotDuration: props.slotDuration, cells: dayTableModel.cells[0], tableColGroupNode: props.tableColGroupNode, tableMinWidth: props.tableMinWidth, clientWidth: props.clientWidth, clientHeight: props.clientHeight, expandRows: props.expandRows, nowDate, nowIndicatorSegs: isNowIndicator && _this.slicer.sliceNowDate(nowDate, context, dayRanges), todayRange, onScrollTopRequest: props.onScrollTopRequest, onSlatCoords: props.onSlatCoords }));
|
|
});
|
|
};
|
|
return DayTimeCols2;
|
|
}(DateComponent);
|
|
function buildDayRanges(dayTableModel, dateProfile, dateEnv) {
|
|
var ranges = [];
|
|
for (var _i = 0, _a = dayTableModel.headerDates; _i < _a.length; _i++) {
|
|
var date = _a[_i];
|
|
ranges.push({
|
|
start: dateEnv.add(date, dateProfile.slotMinTime),
|
|
end: dateEnv.add(date, dateProfile.slotMaxTime)
|
|
});
|
|
}
|
|
return ranges;
|
|
}
|
|
var STOCK_SUB_DURATIONS = [
|
|
{ hours: 1 },
|
|
{ minutes: 30 },
|
|
{ minutes: 15 },
|
|
{ seconds: 30 },
|
|
{ seconds: 15 }
|
|
];
|
|
function buildSlatMetas(slotMinTime, slotMaxTime, explicitLabelInterval, slotDuration, dateEnv) {
|
|
var dayStart = new Date(0);
|
|
var slatTime = slotMinTime;
|
|
var slatIterator = createDuration(0);
|
|
var labelInterval = explicitLabelInterval || computeLabelInterval(slotDuration);
|
|
var metas = [];
|
|
while (asRoughMs(slatTime) < asRoughMs(slotMaxTime)) {
|
|
var date = dateEnv.add(dayStart, slatTime);
|
|
var isLabeled = wholeDivideDurations(slatIterator, labelInterval) !== null;
|
|
metas.push({
|
|
date,
|
|
time: slatTime,
|
|
key: date.toISOString(),
|
|
isoTimeStr: formatIsoTimeString(date),
|
|
isLabeled
|
|
});
|
|
slatTime = addDurations(slatTime, slotDuration);
|
|
slatIterator = addDurations(slatIterator, slotDuration);
|
|
}
|
|
return metas;
|
|
}
|
|
function computeLabelInterval(slotDuration) {
|
|
var i3;
|
|
var labelInterval;
|
|
var slotsPerLabel;
|
|
for (i3 = STOCK_SUB_DURATIONS.length - 1; i3 >= 0; i3 -= 1) {
|
|
labelInterval = createDuration(STOCK_SUB_DURATIONS[i3]);
|
|
slotsPerLabel = wholeDivideDurations(labelInterval, slotDuration);
|
|
if (slotsPerLabel !== null && slotsPerLabel > 1) {
|
|
return labelInterval;
|
|
}
|
|
}
|
|
return slotDuration;
|
|
}
|
|
var DayTimeColsView = function(_super) {
|
|
__extends(DayTimeColsView2, _super);
|
|
function DayTimeColsView2() {
|
|
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
_this.buildTimeColsModel = memoize(buildTimeColsModel);
|
|
_this.buildSlatMetas = memoize(buildSlatMetas);
|
|
return _this;
|
|
}
|
|
DayTimeColsView2.prototype.render = function() {
|
|
var _this = this;
|
|
var _a = this.context, options = _a.options, dateEnv = _a.dateEnv, dateProfileGenerator = _a.dateProfileGenerator;
|
|
var props = this.props;
|
|
var dateProfile = props.dateProfile;
|
|
var dayTableModel = this.buildTimeColsModel(dateProfile, dateProfileGenerator);
|
|
var splitProps = this.allDaySplitter.splitProps(props);
|
|
var slatMetas = this.buildSlatMetas(dateProfile.slotMinTime, dateProfile.slotMaxTime, options.slotLabelInterval, options.slotDuration, dateEnv);
|
|
var dayMinWidth = options.dayMinWidth;
|
|
var hasAttachedAxis = !dayMinWidth;
|
|
var hasDetachedAxis = dayMinWidth;
|
|
var headerContent = options.dayHeaders && createElement(DayHeader, { dates: dayTableModel.headerDates, dateProfile, datesRepDistinctDays: true, renderIntro: hasAttachedAxis ? this.renderHeadAxis : null });
|
|
var allDayContent = options.allDaySlot !== false && function(contentArg) {
|
|
return createElement(DayTable, __assign({}, splitProps.allDay, { dateProfile, dayTableModel, nextDayThreshold: options.nextDayThreshold, tableMinWidth: contentArg.tableMinWidth, colGroupNode: contentArg.tableColGroupNode, renderRowIntro: hasAttachedAxis ? _this.renderTableRowAxis : null, showWeekNumbers: false, expandRows: false, headerAlignElRef: _this.headerElRef, clientWidth: contentArg.clientWidth, clientHeight: contentArg.clientHeight, forPrint: props.forPrint }, _this.getAllDayMaxEventProps()));
|
|
};
|
|
var timeGridContent = function(contentArg) {
|
|
return createElement(DayTimeCols, __assign({}, splitProps.timed, { dayTableModel, dateProfile, axis: hasAttachedAxis, slotDuration: options.slotDuration, slatMetas, forPrint: props.forPrint, tableColGroupNode: contentArg.tableColGroupNode, tableMinWidth: contentArg.tableMinWidth, clientWidth: contentArg.clientWidth, clientHeight: contentArg.clientHeight, onSlatCoords: _this.handleSlatCoords, expandRows: contentArg.expandRows, onScrollTopRequest: _this.handleScrollTopRequest }));
|
|
};
|
|
return hasDetachedAxis ? this.renderHScrollLayout(headerContent, allDayContent, timeGridContent, dayTableModel.colCnt, dayMinWidth, slatMetas, this.state.slatCoords) : this.renderSimpleLayout(headerContent, allDayContent, timeGridContent);
|
|
};
|
|
return DayTimeColsView2;
|
|
}(TimeColsView);
|
|
function buildTimeColsModel(dateProfile, dateProfileGenerator) {
|
|
var daySeries = new DaySeriesModel(dateProfile.renderRange, dateProfileGenerator);
|
|
return new DayTableModel(daySeries, false);
|
|
}
|
|
var OPTION_REFINERS = {
|
|
allDaySlot: Boolean
|
|
};
|
|
var main2 = createPlugin({
|
|
initialView: "timeGridWeek",
|
|
optionRefiners: OPTION_REFINERS,
|
|
views: {
|
|
timeGrid: {
|
|
component: DayTimeColsView,
|
|
usesMinMaxTime: true,
|
|
allDaySlot: true,
|
|
slotDuration: "00:30:00",
|
|
slotEventOverlap: true
|
|
},
|
|
timeGridDay: {
|
|
type: "timeGrid",
|
|
duration: { days: 1 }
|
|
},
|
|
timeGridWeek: {
|
|
type: "timeGrid",
|
|
duration: { weeks: 1 }
|
|
}
|
|
}
|
|
});
|
|
var main_default2 = main2;
|
|
|
|
// node_modules/@fullcalendar/list/main.js
|
|
var ListViewHeaderRow = function(_super) {
|
|
__extends(ListViewHeaderRow2, _super);
|
|
function ListViewHeaderRow2() {
|
|
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
_this.state = {
|
|
textId: getUniqueDomId()
|
|
};
|
|
return _this;
|
|
}
|
|
ListViewHeaderRow2.prototype.render = function() {
|
|
var _a = this.context, theme = _a.theme, dateEnv = _a.dateEnv, options = _a.options, viewApi = _a.viewApi;
|
|
var _b = this.props, cellId = _b.cellId, dayDate = _b.dayDate, todayRange = _b.todayRange;
|
|
var textId = this.state.textId;
|
|
var dayMeta = getDateMeta(dayDate, todayRange);
|
|
var text = options.listDayFormat ? dateEnv.format(dayDate, options.listDayFormat) : "";
|
|
var sideText = options.listDaySideFormat ? dateEnv.format(dayDate, options.listDaySideFormat) : "";
|
|
var hookProps = __assign({
|
|
date: dateEnv.toDate(dayDate),
|
|
view: viewApi,
|
|
textId,
|
|
text,
|
|
sideText,
|
|
navLinkAttrs: buildNavLinkAttrs(this.context, dayDate),
|
|
sideNavLinkAttrs: buildNavLinkAttrs(this.context, dayDate, "day", false)
|
|
}, dayMeta);
|
|
var classNames = ["fc-list-day"].concat(getDayClassNames(dayMeta, theme));
|
|
return createElement(RenderHook, { hookProps, classNames: options.dayHeaderClassNames, content: options.dayHeaderContent, defaultContent: renderInnerContent4, didMount: options.dayHeaderDidMount, willUnmount: options.dayHeaderWillUnmount }, function(rootElRef, customClassNames, innerElRef, innerContent) {
|
|
return createElement("tr", { ref: rootElRef, className: classNames.concat(customClassNames).join(" "), "data-date": formatDayString(dayDate) }, createElement("th", { scope: "colgroup", colSpan: 3, id: cellId, "aria-labelledby": textId }, createElement("div", { className: "fc-list-day-cushion " + theme.getClass("tableCellShaded"), ref: innerElRef }, innerContent)));
|
|
});
|
|
};
|
|
return ListViewHeaderRow2;
|
|
}(BaseComponent);
|
|
function renderInnerContent4(props) {
|
|
return createElement(Fragment, null, props.text && createElement("a", __assign({ id: props.textId, className: "fc-list-day-text" }, props.navLinkAttrs), props.text), props.sideText && createElement("a", __assign({ "aria-hidden": true, className: "fc-list-day-side-text" }, props.sideNavLinkAttrs), props.sideText));
|
|
}
|
|
var DEFAULT_TIME_FORMAT2 = createFormatter({
|
|
hour: "numeric",
|
|
minute: "2-digit",
|
|
meridiem: "short"
|
|
});
|
|
var ListViewEventRow = function(_super) {
|
|
__extends(ListViewEventRow2, _super);
|
|
function ListViewEventRow2() {
|
|
return _super !== null && _super.apply(this, arguments) || this;
|
|
}
|
|
ListViewEventRow2.prototype.render = function() {
|
|
var _a = this, props = _a.props, context = _a.context;
|
|
var seg = props.seg, timeHeaderId = props.timeHeaderId, eventHeaderId = props.eventHeaderId, dateHeaderId = props.dateHeaderId;
|
|
var timeFormat = context.options.eventTimeFormat || DEFAULT_TIME_FORMAT2;
|
|
return createElement(EventRoot, {
|
|
seg,
|
|
timeText: "",
|
|
disableDragging: true,
|
|
disableResizing: true,
|
|
defaultContent: function() {
|
|
return renderEventInnerContent(seg, context);
|
|
},
|
|
isPast: props.isPast,
|
|
isFuture: props.isFuture,
|
|
isToday: props.isToday,
|
|
isSelected: props.isSelected,
|
|
isDragging: props.isDragging,
|
|
isResizing: props.isResizing,
|
|
isDateSelecting: props.isDateSelecting
|
|
}, function(rootElRef, classNames, innerElRef, innerContent, hookProps) {
|
|
return createElement("tr", { className: ["fc-list-event", hookProps.event.url ? "fc-event-forced-url" : ""].concat(classNames).join(" "), ref: rootElRef }, buildTimeContent(seg, timeFormat, context, timeHeaderId, dateHeaderId), createElement("td", { "aria-hidden": true, className: "fc-list-event-graphic" }, createElement("span", { className: "fc-list-event-dot", style: { borderColor: hookProps.borderColor || hookProps.backgroundColor } })), createElement("td", { ref: innerElRef, headers: eventHeaderId + " " + dateHeaderId, className: "fc-list-event-title" }, innerContent));
|
|
});
|
|
};
|
|
return ListViewEventRow2;
|
|
}(BaseComponent);
|
|
function renderEventInnerContent(seg, context) {
|
|
var interactiveAttrs = getSegAnchorAttrs(seg, context);
|
|
return createElement("a", __assign({}, interactiveAttrs), seg.eventRange.def.title);
|
|
}
|
|
function buildTimeContent(seg, timeFormat, context, timeHeaderId, dateHeaderId) {
|
|
var options = context.options;
|
|
if (options.displayEventTime !== false) {
|
|
var eventDef = seg.eventRange.def;
|
|
var eventInstance = seg.eventRange.instance;
|
|
var doAllDay = false;
|
|
var timeText = void 0;
|
|
if (eventDef.allDay) {
|
|
doAllDay = true;
|
|
} else if (isMultiDayRange(seg.eventRange.range)) {
|
|
if (seg.isStart) {
|
|
timeText = buildSegTimeText(seg, timeFormat, context, null, null, eventInstance.range.start, seg.end);
|
|
} else if (seg.isEnd) {
|
|
timeText = buildSegTimeText(seg, timeFormat, context, null, null, seg.start, eventInstance.range.end);
|
|
} else {
|
|
doAllDay = true;
|
|
}
|
|
} else {
|
|
timeText = buildSegTimeText(seg, timeFormat, context);
|
|
}
|
|
if (doAllDay) {
|
|
var hookProps = {
|
|
text: context.options.allDayText,
|
|
view: context.viewApi
|
|
};
|
|
return createElement(RenderHook, { hookProps, classNames: options.allDayClassNames, content: options.allDayContent, defaultContent: renderAllDayInner2, didMount: options.allDayDidMount, willUnmount: options.allDayWillUnmount }, function(rootElRef, classNames, innerElRef, innerContent) {
|
|
return createElement("td", { ref: rootElRef, headers: timeHeaderId + " " + dateHeaderId, className: ["fc-list-event-time"].concat(classNames).join(" ") }, innerContent);
|
|
});
|
|
}
|
|
return createElement("td", { className: "fc-list-event-time" }, timeText);
|
|
}
|
|
return null;
|
|
}
|
|
function renderAllDayInner2(hookProps) {
|
|
return hookProps.text;
|
|
}
|
|
var ListView = function(_super) {
|
|
__extends(ListView2, _super);
|
|
function ListView2() {
|
|
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
_this.computeDateVars = memoize(computeDateVars);
|
|
_this.eventStoreToSegs = memoize(_this._eventStoreToSegs);
|
|
_this.state = {
|
|
timeHeaderId: getUniqueDomId(),
|
|
eventHeaderId: getUniqueDomId(),
|
|
dateHeaderIdRoot: getUniqueDomId()
|
|
};
|
|
_this.setRootEl = function(rootEl) {
|
|
if (rootEl) {
|
|
_this.context.registerInteractiveComponent(_this, {
|
|
el: rootEl
|
|
});
|
|
} else {
|
|
_this.context.unregisterInteractiveComponent(_this);
|
|
}
|
|
};
|
|
return _this;
|
|
}
|
|
ListView2.prototype.render = function() {
|
|
var _this = this;
|
|
var _a = this, props = _a.props, context = _a.context;
|
|
var extraClassNames = [
|
|
"fc-list",
|
|
context.theme.getClass("table"),
|
|
context.options.stickyHeaderDates !== false ? "fc-list-sticky" : ""
|
|
];
|
|
var _b = this.computeDateVars(props.dateProfile), dayDates = _b.dayDates, dayRanges = _b.dayRanges;
|
|
var eventSegs = this.eventStoreToSegs(props.eventStore, props.eventUiBases, dayRanges);
|
|
return createElement(ViewRoot, { viewSpec: context.viewSpec, elRef: this.setRootEl }, function(rootElRef, classNames) {
|
|
return createElement("div", { ref: rootElRef, className: extraClassNames.concat(classNames).join(" ") }, createElement(Scroller, { liquid: !props.isHeightAuto, overflowX: props.isHeightAuto ? "visible" : "hidden", overflowY: props.isHeightAuto ? "visible" : "auto" }, eventSegs.length > 0 ? _this.renderSegList(eventSegs, dayDates) : _this.renderEmptyMessage()));
|
|
});
|
|
};
|
|
ListView2.prototype.renderEmptyMessage = function() {
|
|
var _a = this.context, options = _a.options, viewApi = _a.viewApi;
|
|
var hookProps = {
|
|
text: options.noEventsText,
|
|
view: viewApi
|
|
};
|
|
return createElement(RenderHook, { hookProps, classNames: options.noEventsClassNames, content: options.noEventsContent, defaultContent: renderNoEventsInner, didMount: options.noEventsDidMount, willUnmount: options.noEventsWillUnmount }, function(rootElRef, classNames, innerElRef, innerContent) {
|
|
return createElement("div", { className: ["fc-list-empty"].concat(classNames).join(" "), ref: rootElRef }, createElement("div", { className: "fc-list-empty-cushion", ref: innerElRef }, innerContent));
|
|
});
|
|
};
|
|
ListView2.prototype.renderSegList = function(allSegs, dayDates) {
|
|
var _a = this.context, theme = _a.theme, options = _a.options;
|
|
var _b = this.state, timeHeaderId = _b.timeHeaderId, eventHeaderId = _b.eventHeaderId, dateHeaderIdRoot = _b.dateHeaderIdRoot;
|
|
var segsByDay = groupSegsByDay(allSegs);
|
|
return createElement(NowTimer, { unit: "day" }, function(nowDate, todayRange) {
|
|
var innerNodes = [];
|
|
for (var dayIndex = 0; dayIndex < segsByDay.length; dayIndex += 1) {
|
|
var daySegs = segsByDay[dayIndex];
|
|
if (daySegs) {
|
|
var dayStr = formatDayString(dayDates[dayIndex]);
|
|
var dateHeaderId = dateHeaderIdRoot + "-" + dayStr;
|
|
innerNodes.push(createElement(ListViewHeaderRow, { key: dayStr, cellId: dateHeaderId, dayDate: dayDates[dayIndex], todayRange }));
|
|
daySegs = sortEventSegs(daySegs, options.eventOrder);
|
|
for (var _i = 0, daySegs_1 = daySegs; _i < daySegs_1.length; _i++) {
|
|
var seg = daySegs_1[_i];
|
|
innerNodes.push(createElement(ListViewEventRow, __assign({ key: dayStr + ":" + seg.eventRange.instance.instanceId, seg, isDragging: false, isResizing: false, isDateSelecting: false, isSelected: false, timeHeaderId, eventHeaderId, dateHeaderId }, getSegMeta(seg, todayRange, nowDate))));
|
|
}
|
|
}
|
|
}
|
|
return createElement("table", { className: "fc-list-table " + theme.getClass("table") }, createElement("thead", null, createElement("tr", null, createElement("th", { scope: "col", id: timeHeaderId }, options.timeHint), createElement("th", { scope: "col", "aria-hidden": true }), createElement("th", { scope: "col", id: eventHeaderId }, options.eventHint))), createElement("tbody", null, innerNodes));
|
|
});
|
|
};
|
|
ListView2.prototype._eventStoreToSegs = function(eventStore, eventUiBases, dayRanges) {
|
|
return this.eventRangesToSegs(sliceEventStore(eventStore, eventUiBases, this.props.dateProfile.activeRange, this.context.options.nextDayThreshold).fg, dayRanges);
|
|
};
|
|
ListView2.prototype.eventRangesToSegs = function(eventRanges, dayRanges) {
|
|
var segs = [];
|
|
for (var _i = 0, eventRanges_1 = eventRanges; _i < eventRanges_1.length; _i++) {
|
|
var eventRange = eventRanges_1[_i];
|
|
segs.push.apply(segs, this.eventRangeToSegs(eventRange, dayRanges));
|
|
}
|
|
return segs;
|
|
};
|
|
ListView2.prototype.eventRangeToSegs = function(eventRange, dayRanges) {
|
|
var dateEnv = this.context.dateEnv;
|
|
var nextDayThreshold = this.context.options.nextDayThreshold;
|
|
var range = eventRange.range;
|
|
var allDay = eventRange.def.allDay;
|
|
var dayIndex;
|
|
var segRange;
|
|
var seg;
|
|
var segs = [];
|
|
for (dayIndex = 0; dayIndex < dayRanges.length; dayIndex += 1) {
|
|
segRange = intersectRanges(range, dayRanges[dayIndex]);
|
|
if (segRange) {
|
|
seg = {
|
|
component: this,
|
|
eventRange,
|
|
start: segRange.start,
|
|
end: segRange.end,
|
|
isStart: eventRange.isStart && segRange.start.valueOf() === range.start.valueOf(),
|
|
isEnd: eventRange.isEnd && segRange.end.valueOf() === range.end.valueOf(),
|
|
dayIndex
|
|
};
|
|
segs.push(seg);
|
|
if (!seg.isEnd && !allDay && dayIndex + 1 < dayRanges.length && range.end < dateEnv.add(dayRanges[dayIndex + 1].start, nextDayThreshold)) {
|
|
seg.end = range.end;
|
|
seg.isEnd = true;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
return segs;
|
|
};
|
|
return ListView2;
|
|
}(DateComponent);
|
|
function renderNoEventsInner(hookProps) {
|
|
return hookProps.text;
|
|
}
|
|
function computeDateVars(dateProfile) {
|
|
var dayStart = startOfDay(dateProfile.renderRange.start);
|
|
var viewEnd = dateProfile.renderRange.end;
|
|
var dayDates = [];
|
|
var dayRanges = [];
|
|
while (dayStart < viewEnd) {
|
|
dayDates.push(dayStart);
|
|
dayRanges.push({
|
|
start: dayStart,
|
|
end: addDays(dayStart, 1)
|
|
});
|
|
dayStart = addDays(dayStart, 1);
|
|
}
|
|
return { dayDates, dayRanges };
|
|
}
|
|
function groupSegsByDay(segs) {
|
|
var segsByDay = [];
|
|
var i3;
|
|
var seg;
|
|
for (i3 = 0; i3 < segs.length; i3 += 1) {
|
|
seg = segs[i3];
|
|
(segsByDay[seg.dayIndex] || (segsByDay[seg.dayIndex] = [])).push(seg);
|
|
}
|
|
return segsByDay;
|
|
}
|
|
var OPTION_REFINERS2 = {
|
|
listDayFormat: createFalsableFormatter,
|
|
listDaySideFormat: createFalsableFormatter,
|
|
noEventsClassNames: identity,
|
|
noEventsContent: identity,
|
|
noEventsDidMount: identity,
|
|
noEventsWillUnmount: identity
|
|
};
|
|
function createFalsableFormatter(input) {
|
|
return input === false ? null : createFormatter(input);
|
|
}
|
|
var main3 = createPlugin({
|
|
optionRefiners: OPTION_REFINERS2,
|
|
views: {
|
|
list: {
|
|
component: ListView,
|
|
buttonTextKey: "list",
|
|
listDayFormat: { month: "long", day: "numeric", year: "numeric" }
|
|
},
|
|
listDay: {
|
|
type: "list",
|
|
duration: { days: 1 },
|
|
listDayFormat: { weekday: "long" }
|
|
},
|
|
listWeek: {
|
|
type: "list",
|
|
duration: { weeks: 1 },
|
|
listDayFormat: { weekday: "long" },
|
|
listDaySideFormat: { month: "long", day: "numeric", year: "numeric" }
|
|
},
|
|
listMonth: {
|
|
type: "list",
|
|
duration: { month: 1 },
|
|
listDaySideFormat: { weekday: "long" }
|
|
},
|
|
listYear: {
|
|
type: "list",
|
|
duration: { year: 1 },
|
|
listDaySideFormat: { weekday: "long" }
|
|
}
|
|
}
|
|
});
|
|
var main_default3 = main3;
|
|
|
|
// node_modules/@fullcalendar/interaction/main.js
|
|
config.touchMouseIgnoreWait = 500;
|
|
var ignoreMouseDepth = 0;
|
|
var listenerCnt = 0;
|
|
var isWindowTouchMoveCancelled = false;
|
|
var PointerDragging = function() {
|
|
function PointerDragging2(containerEl) {
|
|
var _this = this;
|
|
this.subjectEl = null;
|
|
this.selector = "";
|
|
this.handleSelector = "";
|
|
this.shouldIgnoreMove = false;
|
|
this.shouldWatchScroll = true;
|
|
this.isDragging = false;
|
|
this.isTouchDragging = false;
|
|
this.wasTouchScroll = false;
|
|
this.handleMouseDown = function(ev) {
|
|
if (!_this.shouldIgnoreMouse() && isPrimaryMouseButton(ev) && _this.tryStart(ev)) {
|
|
var pev = _this.createEventFromMouse(ev, true);
|
|
_this.emitter.trigger("pointerdown", pev);
|
|
_this.initScrollWatch(pev);
|
|
if (!_this.shouldIgnoreMove) {
|
|
document.addEventListener("mousemove", _this.handleMouseMove);
|
|
}
|
|
document.addEventListener("mouseup", _this.handleMouseUp);
|
|
}
|
|
};
|
|
this.handleMouseMove = function(ev) {
|
|
var pev = _this.createEventFromMouse(ev);
|
|
_this.recordCoords(pev);
|
|
_this.emitter.trigger("pointermove", pev);
|
|
};
|
|
this.handleMouseUp = function(ev) {
|
|
document.removeEventListener("mousemove", _this.handleMouseMove);
|
|
document.removeEventListener("mouseup", _this.handleMouseUp);
|
|
_this.emitter.trigger("pointerup", _this.createEventFromMouse(ev));
|
|
_this.cleanup();
|
|
};
|
|
this.handleTouchStart = function(ev) {
|
|
if (_this.tryStart(ev)) {
|
|
_this.isTouchDragging = true;
|
|
var pev = _this.createEventFromTouch(ev, true);
|
|
_this.emitter.trigger("pointerdown", pev);
|
|
_this.initScrollWatch(pev);
|
|
var targetEl = ev.target;
|
|
if (!_this.shouldIgnoreMove) {
|
|
targetEl.addEventListener("touchmove", _this.handleTouchMove);
|
|
}
|
|
targetEl.addEventListener("touchend", _this.handleTouchEnd);
|
|
targetEl.addEventListener("touchcancel", _this.handleTouchEnd);
|
|
window.addEventListener("scroll", _this.handleTouchScroll, true);
|
|
}
|
|
};
|
|
this.handleTouchMove = function(ev) {
|
|
var pev = _this.createEventFromTouch(ev);
|
|
_this.recordCoords(pev);
|
|
_this.emitter.trigger("pointermove", pev);
|
|
};
|
|
this.handleTouchEnd = function(ev) {
|
|
if (_this.isDragging) {
|
|
var targetEl = ev.target;
|
|
targetEl.removeEventListener("touchmove", _this.handleTouchMove);
|
|
targetEl.removeEventListener("touchend", _this.handleTouchEnd);
|
|
targetEl.removeEventListener("touchcancel", _this.handleTouchEnd);
|
|
window.removeEventListener("scroll", _this.handleTouchScroll, true);
|
|
_this.emitter.trigger("pointerup", _this.createEventFromTouch(ev));
|
|
_this.cleanup();
|
|
_this.isTouchDragging = false;
|
|
startIgnoringMouse();
|
|
}
|
|
};
|
|
this.handleTouchScroll = function() {
|
|
_this.wasTouchScroll = true;
|
|
};
|
|
this.handleScroll = function(ev) {
|
|
if (!_this.shouldIgnoreMove) {
|
|
var pageX = window.pageXOffset - _this.prevScrollX + _this.prevPageX;
|
|
var pageY = window.pageYOffset - _this.prevScrollY + _this.prevPageY;
|
|
_this.emitter.trigger("pointermove", {
|
|
origEvent: ev,
|
|
isTouch: _this.isTouchDragging,
|
|
subjectEl: _this.subjectEl,
|
|
pageX,
|
|
pageY,
|
|
deltaX: pageX - _this.origPageX,
|
|
deltaY: pageY - _this.origPageY
|
|
});
|
|
}
|
|
};
|
|
this.containerEl = containerEl;
|
|
this.emitter = new Emitter();
|
|
containerEl.addEventListener("mousedown", this.handleMouseDown);
|
|
containerEl.addEventListener("touchstart", this.handleTouchStart, { passive: true });
|
|
listenerCreated();
|
|
}
|
|
PointerDragging2.prototype.destroy = function() {
|
|
this.containerEl.removeEventListener("mousedown", this.handleMouseDown);
|
|
this.containerEl.removeEventListener("touchstart", this.handleTouchStart, { passive: true });
|
|
listenerDestroyed();
|
|
};
|
|
PointerDragging2.prototype.tryStart = function(ev) {
|
|
var subjectEl = this.querySubjectEl(ev);
|
|
var downEl = ev.target;
|
|
if (subjectEl && (!this.handleSelector || elementClosest(downEl, this.handleSelector))) {
|
|
this.subjectEl = subjectEl;
|
|
this.isDragging = true;
|
|
this.wasTouchScroll = false;
|
|
return true;
|
|
}
|
|
return false;
|
|
};
|
|
PointerDragging2.prototype.cleanup = function() {
|
|
isWindowTouchMoveCancelled = false;
|
|
this.isDragging = false;
|
|
this.subjectEl = null;
|
|
this.destroyScrollWatch();
|
|
};
|
|
PointerDragging2.prototype.querySubjectEl = function(ev) {
|
|
if (this.selector) {
|
|
return elementClosest(ev.target, this.selector);
|
|
}
|
|
return this.containerEl;
|
|
};
|
|
PointerDragging2.prototype.shouldIgnoreMouse = function() {
|
|
return ignoreMouseDepth || this.isTouchDragging;
|
|
};
|
|
PointerDragging2.prototype.cancelTouchScroll = function() {
|
|
if (this.isDragging) {
|
|
isWindowTouchMoveCancelled = true;
|
|
}
|
|
};
|
|
PointerDragging2.prototype.initScrollWatch = function(ev) {
|
|
if (this.shouldWatchScroll) {
|
|
this.recordCoords(ev);
|
|
window.addEventListener("scroll", this.handleScroll, true);
|
|
}
|
|
};
|
|
PointerDragging2.prototype.recordCoords = function(ev) {
|
|
if (this.shouldWatchScroll) {
|
|
this.prevPageX = ev.pageX;
|
|
this.prevPageY = ev.pageY;
|
|
this.prevScrollX = window.pageXOffset;
|
|
this.prevScrollY = window.pageYOffset;
|
|
}
|
|
};
|
|
PointerDragging2.prototype.destroyScrollWatch = function() {
|
|
if (this.shouldWatchScroll) {
|
|
window.removeEventListener("scroll", this.handleScroll, true);
|
|
}
|
|
};
|
|
PointerDragging2.prototype.createEventFromMouse = function(ev, isFirst) {
|
|
var deltaX = 0;
|
|
var deltaY = 0;
|
|
if (isFirst) {
|
|
this.origPageX = ev.pageX;
|
|
this.origPageY = ev.pageY;
|
|
} else {
|
|
deltaX = ev.pageX - this.origPageX;
|
|
deltaY = ev.pageY - this.origPageY;
|
|
}
|
|
return {
|
|
origEvent: ev,
|
|
isTouch: false,
|
|
subjectEl: this.subjectEl,
|
|
pageX: ev.pageX,
|
|
pageY: ev.pageY,
|
|
deltaX,
|
|
deltaY
|
|
};
|
|
};
|
|
PointerDragging2.prototype.createEventFromTouch = function(ev, isFirst) {
|
|
var touches = ev.touches;
|
|
var pageX;
|
|
var pageY;
|
|
var deltaX = 0;
|
|
var deltaY = 0;
|
|
if (touches && touches.length) {
|
|
pageX = touches[0].pageX;
|
|
pageY = touches[0].pageY;
|
|
} else {
|
|
pageX = ev.pageX;
|
|
pageY = ev.pageY;
|
|
}
|
|
if (isFirst) {
|
|
this.origPageX = pageX;
|
|
this.origPageY = pageY;
|
|
} else {
|
|
deltaX = pageX - this.origPageX;
|
|
deltaY = pageY - this.origPageY;
|
|
}
|
|
return {
|
|
origEvent: ev,
|
|
isTouch: true,
|
|
subjectEl: this.subjectEl,
|
|
pageX,
|
|
pageY,
|
|
deltaX,
|
|
deltaY
|
|
};
|
|
};
|
|
return PointerDragging2;
|
|
}();
|
|
function isPrimaryMouseButton(ev) {
|
|
return ev.button === 0 && !ev.ctrlKey;
|
|
}
|
|
function startIgnoringMouse() {
|
|
ignoreMouseDepth += 1;
|
|
setTimeout(function() {
|
|
ignoreMouseDepth -= 1;
|
|
}, config.touchMouseIgnoreWait);
|
|
}
|
|
function listenerCreated() {
|
|
listenerCnt += 1;
|
|
if (listenerCnt === 1) {
|
|
window.addEventListener("touchmove", onWindowTouchMove, { passive: false });
|
|
}
|
|
}
|
|
function listenerDestroyed() {
|
|
listenerCnt -= 1;
|
|
if (!listenerCnt) {
|
|
window.removeEventListener("touchmove", onWindowTouchMove, { passive: false });
|
|
}
|
|
}
|
|
function onWindowTouchMove(ev) {
|
|
if (isWindowTouchMoveCancelled) {
|
|
ev.preventDefault();
|
|
}
|
|
}
|
|
var ElementMirror = function() {
|
|
function ElementMirror2() {
|
|
this.isVisible = false;
|
|
this.sourceEl = null;
|
|
this.mirrorEl = null;
|
|
this.sourceElRect = null;
|
|
this.parentNode = document.body;
|
|
this.zIndex = 9999;
|
|
this.revertDuration = 0;
|
|
}
|
|
ElementMirror2.prototype.start = function(sourceEl, pageX, pageY) {
|
|
this.sourceEl = sourceEl;
|
|
this.sourceElRect = this.sourceEl.getBoundingClientRect();
|
|
this.origScreenX = pageX - window.pageXOffset;
|
|
this.origScreenY = pageY - window.pageYOffset;
|
|
this.deltaX = 0;
|
|
this.deltaY = 0;
|
|
this.updateElPosition();
|
|
};
|
|
ElementMirror2.prototype.handleMove = function(pageX, pageY) {
|
|
this.deltaX = pageX - window.pageXOffset - this.origScreenX;
|
|
this.deltaY = pageY - window.pageYOffset - this.origScreenY;
|
|
this.updateElPosition();
|
|
};
|
|
ElementMirror2.prototype.setIsVisible = function(bool) {
|
|
if (bool) {
|
|
if (!this.isVisible) {
|
|
if (this.mirrorEl) {
|
|
this.mirrorEl.style.display = "";
|
|
}
|
|
this.isVisible = bool;
|
|
this.updateElPosition();
|
|
}
|
|
} else if (this.isVisible) {
|
|
if (this.mirrorEl) {
|
|
this.mirrorEl.style.display = "none";
|
|
}
|
|
this.isVisible = bool;
|
|
}
|
|
};
|
|
ElementMirror2.prototype.stop = function(needsRevertAnimation, callback) {
|
|
var _this = this;
|
|
var done = function() {
|
|
_this.cleanup();
|
|
callback();
|
|
};
|
|
if (needsRevertAnimation && this.mirrorEl && this.isVisible && this.revertDuration && (this.deltaX || this.deltaY)) {
|
|
this.doRevertAnimation(done, this.revertDuration);
|
|
} else {
|
|
setTimeout(done, 0);
|
|
}
|
|
};
|
|
ElementMirror2.prototype.doRevertAnimation = function(callback, revertDuration) {
|
|
var mirrorEl = this.mirrorEl;
|
|
var finalSourceElRect = this.sourceEl.getBoundingClientRect();
|
|
mirrorEl.style.transition = "top " + revertDuration + "ms,left " + revertDuration + "ms";
|
|
applyStyle(mirrorEl, {
|
|
left: finalSourceElRect.left,
|
|
top: finalSourceElRect.top
|
|
});
|
|
whenTransitionDone(mirrorEl, function() {
|
|
mirrorEl.style.transition = "";
|
|
callback();
|
|
});
|
|
};
|
|
ElementMirror2.prototype.cleanup = function() {
|
|
if (this.mirrorEl) {
|
|
removeElement(this.mirrorEl);
|
|
this.mirrorEl = null;
|
|
}
|
|
this.sourceEl = null;
|
|
};
|
|
ElementMirror2.prototype.updateElPosition = function() {
|
|
if (this.sourceEl && this.isVisible) {
|
|
applyStyle(this.getMirrorEl(), {
|
|
left: this.sourceElRect.left + this.deltaX,
|
|
top: this.sourceElRect.top + this.deltaY
|
|
});
|
|
}
|
|
};
|
|
ElementMirror2.prototype.getMirrorEl = function() {
|
|
var sourceElRect = this.sourceElRect;
|
|
var mirrorEl = this.mirrorEl;
|
|
if (!mirrorEl) {
|
|
mirrorEl = this.mirrorEl = this.sourceEl.cloneNode(true);
|
|
mirrorEl.classList.add("fc-unselectable");
|
|
mirrorEl.classList.add("fc-event-dragging");
|
|
applyStyle(mirrorEl, {
|
|
position: "fixed",
|
|
zIndex: this.zIndex,
|
|
visibility: "",
|
|
boxSizing: "border-box",
|
|
width: sourceElRect.right - sourceElRect.left,
|
|
height: sourceElRect.bottom - sourceElRect.top,
|
|
right: "auto",
|
|
bottom: "auto",
|
|
margin: 0
|
|
});
|
|
this.parentNode.appendChild(mirrorEl);
|
|
}
|
|
return mirrorEl;
|
|
};
|
|
return ElementMirror2;
|
|
}();
|
|
var ScrollGeomCache = function(_super) {
|
|
__extends(ScrollGeomCache2, _super);
|
|
function ScrollGeomCache2(scrollController, doesListening) {
|
|
var _this = _super.call(this) || this;
|
|
_this.handleScroll = function() {
|
|
_this.scrollTop = _this.scrollController.getScrollTop();
|
|
_this.scrollLeft = _this.scrollController.getScrollLeft();
|
|
_this.handleScrollChange();
|
|
};
|
|
_this.scrollController = scrollController;
|
|
_this.doesListening = doesListening;
|
|
_this.scrollTop = _this.origScrollTop = scrollController.getScrollTop();
|
|
_this.scrollLeft = _this.origScrollLeft = scrollController.getScrollLeft();
|
|
_this.scrollWidth = scrollController.getScrollWidth();
|
|
_this.scrollHeight = scrollController.getScrollHeight();
|
|
_this.clientWidth = scrollController.getClientWidth();
|
|
_this.clientHeight = scrollController.getClientHeight();
|
|
_this.clientRect = _this.computeClientRect();
|
|
if (_this.doesListening) {
|
|
_this.getEventTarget().addEventListener("scroll", _this.handleScroll);
|
|
}
|
|
return _this;
|
|
}
|
|
ScrollGeomCache2.prototype.destroy = function() {
|
|
if (this.doesListening) {
|
|
this.getEventTarget().removeEventListener("scroll", this.handleScroll);
|
|
}
|
|
};
|
|
ScrollGeomCache2.prototype.getScrollTop = function() {
|
|
return this.scrollTop;
|
|
};
|
|
ScrollGeomCache2.prototype.getScrollLeft = function() {
|
|
return this.scrollLeft;
|
|
};
|
|
ScrollGeomCache2.prototype.setScrollTop = function(top) {
|
|
this.scrollController.setScrollTop(top);
|
|
if (!this.doesListening) {
|
|
this.scrollTop = Math.max(Math.min(top, this.getMaxScrollTop()), 0);
|
|
this.handleScrollChange();
|
|
}
|
|
};
|
|
ScrollGeomCache2.prototype.setScrollLeft = function(top) {
|
|
this.scrollController.setScrollLeft(top);
|
|
if (!this.doesListening) {
|
|
this.scrollLeft = Math.max(Math.min(top, this.getMaxScrollLeft()), 0);
|
|
this.handleScrollChange();
|
|
}
|
|
};
|
|
ScrollGeomCache2.prototype.getClientWidth = function() {
|
|
return this.clientWidth;
|
|
};
|
|
ScrollGeomCache2.prototype.getClientHeight = function() {
|
|
return this.clientHeight;
|
|
};
|
|
ScrollGeomCache2.prototype.getScrollWidth = function() {
|
|
return this.scrollWidth;
|
|
};
|
|
ScrollGeomCache2.prototype.getScrollHeight = function() {
|
|
return this.scrollHeight;
|
|
};
|
|
ScrollGeomCache2.prototype.handleScrollChange = function() {
|
|
};
|
|
return ScrollGeomCache2;
|
|
}(ScrollController);
|
|
var ElementScrollGeomCache = function(_super) {
|
|
__extends(ElementScrollGeomCache2, _super);
|
|
function ElementScrollGeomCache2(el, doesListening) {
|
|
return _super.call(this, new ElementScrollController(el), doesListening) || this;
|
|
}
|
|
ElementScrollGeomCache2.prototype.getEventTarget = function() {
|
|
return this.scrollController.el;
|
|
};
|
|
ElementScrollGeomCache2.prototype.computeClientRect = function() {
|
|
return computeInnerRect(this.scrollController.el);
|
|
};
|
|
return ElementScrollGeomCache2;
|
|
}(ScrollGeomCache);
|
|
var WindowScrollGeomCache = function(_super) {
|
|
__extends(WindowScrollGeomCache2, _super);
|
|
function WindowScrollGeomCache2(doesListening) {
|
|
return _super.call(this, new WindowScrollController(), doesListening) || this;
|
|
}
|
|
WindowScrollGeomCache2.prototype.getEventTarget = function() {
|
|
return window;
|
|
};
|
|
WindowScrollGeomCache2.prototype.computeClientRect = function() {
|
|
return {
|
|
left: this.scrollLeft,
|
|
right: this.scrollLeft + this.clientWidth,
|
|
top: this.scrollTop,
|
|
bottom: this.scrollTop + this.clientHeight
|
|
};
|
|
};
|
|
WindowScrollGeomCache2.prototype.handleScrollChange = function() {
|
|
this.clientRect = this.computeClientRect();
|
|
};
|
|
return WindowScrollGeomCache2;
|
|
}(ScrollGeomCache);
|
|
var getTime = typeof performance === "function" ? performance.now : Date.now;
|
|
var AutoScroller = function() {
|
|
function AutoScroller2() {
|
|
var _this = this;
|
|
this.isEnabled = true;
|
|
this.scrollQuery = [window, ".fc-scroller"];
|
|
this.edgeThreshold = 50;
|
|
this.maxVelocity = 300;
|
|
this.pointerScreenX = null;
|
|
this.pointerScreenY = null;
|
|
this.isAnimating = false;
|
|
this.scrollCaches = null;
|
|
this.everMovedUp = false;
|
|
this.everMovedDown = false;
|
|
this.everMovedLeft = false;
|
|
this.everMovedRight = false;
|
|
this.animate = function() {
|
|
if (_this.isAnimating) {
|
|
var edge = _this.computeBestEdge(_this.pointerScreenX + window.pageXOffset, _this.pointerScreenY + window.pageYOffset);
|
|
if (edge) {
|
|
var now = getTime();
|
|
_this.handleSide(edge, (now - _this.msSinceRequest) / 1e3);
|
|
_this.requestAnimation(now);
|
|
} else {
|
|
_this.isAnimating = false;
|
|
}
|
|
}
|
|
};
|
|
}
|
|
AutoScroller2.prototype.start = function(pageX, pageY, scrollStartEl) {
|
|
if (this.isEnabled) {
|
|
this.scrollCaches = this.buildCaches(scrollStartEl);
|
|
this.pointerScreenX = null;
|
|
this.pointerScreenY = null;
|
|
this.everMovedUp = false;
|
|
this.everMovedDown = false;
|
|
this.everMovedLeft = false;
|
|
this.everMovedRight = false;
|
|
this.handleMove(pageX, pageY);
|
|
}
|
|
};
|
|
AutoScroller2.prototype.handleMove = function(pageX, pageY) {
|
|
if (this.isEnabled) {
|
|
var pointerScreenX = pageX - window.pageXOffset;
|
|
var pointerScreenY = pageY - window.pageYOffset;
|
|
var yDelta = this.pointerScreenY === null ? 0 : pointerScreenY - this.pointerScreenY;
|
|
var xDelta = this.pointerScreenX === null ? 0 : pointerScreenX - this.pointerScreenX;
|
|
if (yDelta < 0) {
|
|
this.everMovedUp = true;
|
|
} else if (yDelta > 0) {
|
|
this.everMovedDown = true;
|
|
}
|
|
if (xDelta < 0) {
|
|
this.everMovedLeft = true;
|
|
} else if (xDelta > 0) {
|
|
this.everMovedRight = true;
|
|
}
|
|
this.pointerScreenX = pointerScreenX;
|
|
this.pointerScreenY = pointerScreenY;
|
|
if (!this.isAnimating) {
|
|
this.isAnimating = true;
|
|
this.requestAnimation(getTime());
|
|
}
|
|
}
|
|
};
|
|
AutoScroller2.prototype.stop = function() {
|
|
if (this.isEnabled) {
|
|
this.isAnimating = false;
|
|
for (var _i = 0, _a = this.scrollCaches; _i < _a.length; _i++) {
|
|
var scrollCache = _a[_i];
|
|
scrollCache.destroy();
|
|
}
|
|
this.scrollCaches = null;
|
|
}
|
|
};
|
|
AutoScroller2.prototype.requestAnimation = function(now) {
|
|
this.msSinceRequest = now;
|
|
requestAnimationFrame(this.animate);
|
|
};
|
|
AutoScroller2.prototype.handleSide = function(edge, seconds) {
|
|
var scrollCache = edge.scrollCache;
|
|
var edgeThreshold = this.edgeThreshold;
|
|
var invDistance = edgeThreshold - edge.distance;
|
|
var velocity = invDistance * invDistance / (edgeThreshold * edgeThreshold) * this.maxVelocity * seconds;
|
|
var sign = 1;
|
|
switch (edge.name) {
|
|
case "left":
|
|
sign = -1;
|
|
case "right":
|
|
scrollCache.setScrollLeft(scrollCache.getScrollLeft() + velocity * sign);
|
|
break;
|
|
case "top":
|
|
sign = -1;
|
|
case "bottom":
|
|
scrollCache.setScrollTop(scrollCache.getScrollTop() + velocity * sign);
|
|
break;
|
|
}
|
|
};
|
|
AutoScroller2.prototype.computeBestEdge = function(left, top) {
|
|
var edgeThreshold = this.edgeThreshold;
|
|
var bestSide = null;
|
|
for (var _i = 0, _a = this.scrollCaches; _i < _a.length; _i++) {
|
|
var scrollCache = _a[_i];
|
|
var rect = scrollCache.clientRect;
|
|
var leftDist = left - rect.left;
|
|
var rightDist = rect.right - left;
|
|
var topDist = top - rect.top;
|
|
var bottomDist = rect.bottom - top;
|
|
if (leftDist >= 0 && rightDist >= 0 && topDist >= 0 && bottomDist >= 0) {
|
|
if (topDist <= edgeThreshold && this.everMovedUp && scrollCache.canScrollUp() && (!bestSide || bestSide.distance > topDist)) {
|
|
bestSide = { scrollCache, name: "top", distance: topDist };
|
|
}
|
|
if (bottomDist <= edgeThreshold && this.everMovedDown && scrollCache.canScrollDown() && (!bestSide || bestSide.distance > bottomDist)) {
|
|
bestSide = { scrollCache, name: "bottom", distance: bottomDist };
|
|
}
|
|
if (leftDist <= edgeThreshold && this.everMovedLeft && scrollCache.canScrollLeft() && (!bestSide || bestSide.distance > leftDist)) {
|
|
bestSide = { scrollCache, name: "left", distance: leftDist };
|
|
}
|
|
if (rightDist <= edgeThreshold && this.everMovedRight && scrollCache.canScrollRight() && (!bestSide || bestSide.distance > rightDist)) {
|
|
bestSide = { scrollCache, name: "right", distance: rightDist };
|
|
}
|
|
}
|
|
}
|
|
return bestSide;
|
|
};
|
|
AutoScroller2.prototype.buildCaches = function(scrollStartEl) {
|
|
return this.queryScrollEls(scrollStartEl).map(function(el) {
|
|
if (el === window) {
|
|
return new WindowScrollGeomCache(false);
|
|
}
|
|
return new ElementScrollGeomCache(el, false);
|
|
});
|
|
};
|
|
AutoScroller2.prototype.queryScrollEls = function(scrollStartEl) {
|
|
var els = [];
|
|
for (var _i = 0, _a = this.scrollQuery; _i < _a.length; _i++) {
|
|
var query = _a[_i];
|
|
if (typeof query === "object") {
|
|
els.push(query);
|
|
} else {
|
|
els.push.apply(els, Array.prototype.slice.call(getElRoot(scrollStartEl).querySelectorAll(query)));
|
|
}
|
|
}
|
|
return els;
|
|
};
|
|
return AutoScroller2;
|
|
}();
|
|
var FeaturefulElementDragging = function(_super) {
|
|
__extends(FeaturefulElementDragging2, _super);
|
|
function FeaturefulElementDragging2(containerEl, selector) {
|
|
var _this = _super.call(this, containerEl) || this;
|
|
_this.containerEl = containerEl;
|
|
_this.delay = null;
|
|
_this.minDistance = 0;
|
|
_this.touchScrollAllowed = true;
|
|
_this.mirrorNeedsRevert = false;
|
|
_this.isInteracting = false;
|
|
_this.isDragging = false;
|
|
_this.isDelayEnded = false;
|
|
_this.isDistanceSurpassed = false;
|
|
_this.delayTimeoutId = null;
|
|
_this.onPointerDown = function(ev) {
|
|
if (!_this.isDragging) {
|
|
_this.isInteracting = true;
|
|
_this.isDelayEnded = false;
|
|
_this.isDistanceSurpassed = false;
|
|
preventSelection(document.body);
|
|
preventContextMenu(document.body);
|
|
if (!ev.isTouch) {
|
|
ev.origEvent.preventDefault();
|
|
}
|
|
_this.emitter.trigger("pointerdown", ev);
|
|
if (_this.isInteracting && !_this.pointer.shouldIgnoreMove) {
|
|
_this.mirror.setIsVisible(false);
|
|
_this.mirror.start(ev.subjectEl, ev.pageX, ev.pageY);
|
|
_this.startDelay(ev);
|
|
if (!_this.minDistance) {
|
|
_this.handleDistanceSurpassed(ev);
|
|
}
|
|
}
|
|
}
|
|
};
|
|
_this.onPointerMove = function(ev) {
|
|
if (_this.isInteracting) {
|
|
_this.emitter.trigger("pointermove", ev);
|
|
if (!_this.isDistanceSurpassed) {
|
|
var minDistance = _this.minDistance;
|
|
var distanceSq = void 0;
|
|
var deltaX = ev.deltaX, deltaY = ev.deltaY;
|
|
distanceSq = deltaX * deltaX + deltaY * deltaY;
|
|
if (distanceSq >= minDistance * minDistance) {
|
|
_this.handleDistanceSurpassed(ev);
|
|
}
|
|
}
|
|
if (_this.isDragging) {
|
|
if (ev.origEvent.type !== "scroll") {
|
|
_this.mirror.handleMove(ev.pageX, ev.pageY);
|
|
_this.autoScroller.handleMove(ev.pageX, ev.pageY);
|
|
}
|
|
_this.emitter.trigger("dragmove", ev);
|
|
}
|
|
}
|
|
};
|
|
_this.onPointerUp = function(ev) {
|
|
if (_this.isInteracting) {
|
|
_this.isInteracting = false;
|
|
allowSelection(document.body);
|
|
allowContextMenu(document.body);
|
|
_this.emitter.trigger("pointerup", ev);
|
|
if (_this.isDragging) {
|
|
_this.autoScroller.stop();
|
|
_this.tryStopDrag(ev);
|
|
}
|
|
if (_this.delayTimeoutId) {
|
|
clearTimeout(_this.delayTimeoutId);
|
|
_this.delayTimeoutId = null;
|
|
}
|
|
}
|
|
};
|
|
var pointer = _this.pointer = new PointerDragging(containerEl);
|
|
pointer.emitter.on("pointerdown", _this.onPointerDown);
|
|
pointer.emitter.on("pointermove", _this.onPointerMove);
|
|
pointer.emitter.on("pointerup", _this.onPointerUp);
|
|
if (selector) {
|
|
pointer.selector = selector;
|
|
}
|
|
_this.mirror = new ElementMirror();
|
|
_this.autoScroller = new AutoScroller();
|
|
return _this;
|
|
}
|
|
FeaturefulElementDragging2.prototype.destroy = function() {
|
|
this.pointer.destroy();
|
|
this.onPointerUp({});
|
|
};
|
|
FeaturefulElementDragging2.prototype.startDelay = function(ev) {
|
|
var _this = this;
|
|
if (typeof this.delay === "number") {
|
|
this.delayTimeoutId = setTimeout(function() {
|
|
_this.delayTimeoutId = null;
|
|
_this.handleDelayEnd(ev);
|
|
}, this.delay);
|
|
} else {
|
|
this.handleDelayEnd(ev);
|
|
}
|
|
};
|
|
FeaturefulElementDragging2.prototype.handleDelayEnd = function(ev) {
|
|
this.isDelayEnded = true;
|
|
this.tryStartDrag(ev);
|
|
};
|
|
FeaturefulElementDragging2.prototype.handleDistanceSurpassed = function(ev) {
|
|
this.isDistanceSurpassed = true;
|
|
this.tryStartDrag(ev);
|
|
};
|
|
FeaturefulElementDragging2.prototype.tryStartDrag = function(ev) {
|
|
if (this.isDelayEnded && this.isDistanceSurpassed) {
|
|
if (!this.pointer.wasTouchScroll || this.touchScrollAllowed) {
|
|
this.isDragging = true;
|
|
this.mirrorNeedsRevert = false;
|
|
this.autoScroller.start(ev.pageX, ev.pageY, this.containerEl);
|
|
this.emitter.trigger("dragstart", ev);
|
|
if (this.touchScrollAllowed === false) {
|
|
this.pointer.cancelTouchScroll();
|
|
}
|
|
}
|
|
}
|
|
};
|
|
FeaturefulElementDragging2.prototype.tryStopDrag = function(ev) {
|
|
this.mirror.stop(this.mirrorNeedsRevert, this.stopDrag.bind(this, ev));
|
|
};
|
|
FeaturefulElementDragging2.prototype.stopDrag = function(ev) {
|
|
this.isDragging = false;
|
|
this.emitter.trigger("dragend", ev);
|
|
};
|
|
FeaturefulElementDragging2.prototype.setIgnoreMove = function(bool) {
|
|
this.pointer.shouldIgnoreMove = bool;
|
|
};
|
|
FeaturefulElementDragging2.prototype.setMirrorIsVisible = function(bool) {
|
|
this.mirror.setIsVisible(bool);
|
|
};
|
|
FeaturefulElementDragging2.prototype.setMirrorNeedsRevert = function(bool) {
|
|
this.mirrorNeedsRevert = bool;
|
|
};
|
|
FeaturefulElementDragging2.prototype.setAutoScrollEnabled = function(bool) {
|
|
this.autoScroller.isEnabled = bool;
|
|
};
|
|
return FeaturefulElementDragging2;
|
|
}(ElementDragging);
|
|
var OffsetTracker = function() {
|
|
function OffsetTracker2(el) {
|
|
this.origRect = computeRect(el);
|
|
this.scrollCaches = getClippingParents(el).map(function(scrollEl) {
|
|
return new ElementScrollGeomCache(scrollEl, true);
|
|
});
|
|
}
|
|
OffsetTracker2.prototype.destroy = function() {
|
|
for (var _i = 0, _a = this.scrollCaches; _i < _a.length; _i++) {
|
|
var scrollCache = _a[_i];
|
|
scrollCache.destroy();
|
|
}
|
|
};
|
|
OffsetTracker2.prototype.computeLeft = function() {
|
|
var left = this.origRect.left;
|
|
for (var _i = 0, _a = this.scrollCaches; _i < _a.length; _i++) {
|
|
var scrollCache = _a[_i];
|
|
left += scrollCache.origScrollLeft - scrollCache.getScrollLeft();
|
|
}
|
|
return left;
|
|
};
|
|
OffsetTracker2.prototype.computeTop = function() {
|
|
var top = this.origRect.top;
|
|
for (var _i = 0, _a = this.scrollCaches; _i < _a.length; _i++) {
|
|
var scrollCache = _a[_i];
|
|
top += scrollCache.origScrollTop - scrollCache.getScrollTop();
|
|
}
|
|
return top;
|
|
};
|
|
OffsetTracker2.prototype.isWithinClipping = function(pageX, pageY) {
|
|
var point = { left: pageX, top: pageY };
|
|
for (var _i = 0, _a = this.scrollCaches; _i < _a.length; _i++) {
|
|
var scrollCache = _a[_i];
|
|
if (!isIgnoredClipping(scrollCache.getEventTarget()) && !pointInsideRect(point, scrollCache.clientRect)) {
|
|
return false;
|
|
}
|
|
}
|
|
return true;
|
|
};
|
|
return OffsetTracker2;
|
|
}();
|
|
function isIgnoredClipping(node) {
|
|
var tagName = node.tagName;
|
|
return tagName === "HTML" || tagName === "BODY";
|
|
}
|
|
var HitDragging = function() {
|
|
function HitDragging2(dragging, droppableStore) {
|
|
var _this = this;
|
|
this.useSubjectCenter = false;
|
|
this.requireInitial = true;
|
|
this.initialHit = null;
|
|
this.movingHit = null;
|
|
this.finalHit = null;
|
|
this.handlePointerDown = function(ev) {
|
|
var dragging2 = _this.dragging;
|
|
_this.initialHit = null;
|
|
_this.movingHit = null;
|
|
_this.finalHit = null;
|
|
_this.prepareHits();
|
|
_this.processFirstCoord(ev);
|
|
if (_this.initialHit || !_this.requireInitial) {
|
|
dragging2.setIgnoreMove(false);
|
|
_this.emitter.trigger("pointerdown", ev);
|
|
} else {
|
|
dragging2.setIgnoreMove(true);
|
|
}
|
|
};
|
|
this.handleDragStart = function(ev) {
|
|
_this.emitter.trigger("dragstart", ev);
|
|
_this.handleMove(ev, true);
|
|
};
|
|
this.handleDragMove = function(ev) {
|
|
_this.emitter.trigger("dragmove", ev);
|
|
_this.handleMove(ev);
|
|
};
|
|
this.handlePointerUp = function(ev) {
|
|
_this.releaseHits();
|
|
_this.emitter.trigger("pointerup", ev);
|
|
};
|
|
this.handleDragEnd = function(ev) {
|
|
if (_this.movingHit) {
|
|
_this.emitter.trigger("hitupdate", null, true, ev);
|
|
}
|
|
_this.finalHit = _this.movingHit;
|
|
_this.movingHit = null;
|
|
_this.emitter.trigger("dragend", ev);
|
|
};
|
|
this.droppableStore = droppableStore;
|
|
dragging.emitter.on("pointerdown", this.handlePointerDown);
|
|
dragging.emitter.on("dragstart", this.handleDragStart);
|
|
dragging.emitter.on("dragmove", this.handleDragMove);
|
|
dragging.emitter.on("pointerup", this.handlePointerUp);
|
|
dragging.emitter.on("dragend", this.handleDragEnd);
|
|
this.dragging = dragging;
|
|
this.emitter = new Emitter();
|
|
}
|
|
HitDragging2.prototype.processFirstCoord = function(ev) {
|
|
var origPoint = { left: ev.pageX, top: ev.pageY };
|
|
var adjustedPoint = origPoint;
|
|
var subjectEl = ev.subjectEl;
|
|
var subjectRect;
|
|
if (subjectEl instanceof HTMLElement) {
|
|
subjectRect = computeRect(subjectEl);
|
|
adjustedPoint = constrainPoint(adjustedPoint, subjectRect);
|
|
}
|
|
var initialHit = this.initialHit = this.queryHitForOffset(adjustedPoint.left, adjustedPoint.top);
|
|
if (initialHit) {
|
|
if (this.useSubjectCenter && subjectRect) {
|
|
var slicedSubjectRect = intersectRects(subjectRect, initialHit.rect);
|
|
if (slicedSubjectRect) {
|
|
adjustedPoint = getRectCenter(slicedSubjectRect);
|
|
}
|
|
}
|
|
this.coordAdjust = diffPoints(adjustedPoint, origPoint);
|
|
} else {
|
|
this.coordAdjust = { left: 0, top: 0 };
|
|
}
|
|
};
|
|
HitDragging2.prototype.handleMove = function(ev, forceHandle) {
|
|
var hit = this.queryHitForOffset(ev.pageX + this.coordAdjust.left, ev.pageY + this.coordAdjust.top);
|
|
if (forceHandle || !isHitsEqual(this.movingHit, hit)) {
|
|
this.movingHit = hit;
|
|
this.emitter.trigger("hitupdate", hit, false, ev);
|
|
}
|
|
};
|
|
HitDragging2.prototype.prepareHits = function() {
|
|
this.offsetTrackers = mapHash(this.droppableStore, function(interactionSettings) {
|
|
interactionSettings.component.prepareHits();
|
|
return new OffsetTracker(interactionSettings.el);
|
|
});
|
|
};
|
|
HitDragging2.prototype.releaseHits = function() {
|
|
var offsetTrackers = this.offsetTrackers;
|
|
for (var id in offsetTrackers) {
|
|
offsetTrackers[id].destroy();
|
|
}
|
|
this.offsetTrackers = {};
|
|
};
|
|
HitDragging2.prototype.queryHitForOffset = function(offsetLeft, offsetTop) {
|
|
var _a = this, droppableStore = _a.droppableStore, offsetTrackers = _a.offsetTrackers;
|
|
var bestHit = null;
|
|
for (var id in droppableStore) {
|
|
var component = droppableStore[id].component;
|
|
var offsetTracker = offsetTrackers[id];
|
|
if (offsetTracker && offsetTracker.isWithinClipping(offsetLeft, offsetTop)) {
|
|
var originLeft = offsetTracker.computeLeft();
|
|
var originTop = offsetTracker.computeTop();
|
|
var positionLeft = offsetLeft - originLeft;
|
|
var positionTop = offsetTop - originTop;
|
|
var origRect = offsetTracker.origRect;
|
|
var width = origRect.right - origRect.left;
|
|
var height = origRect.bottom - origRect.top;
|
|
if (positionLeft >= 0 && positionLeft < width && positionTop >= 0 && positionTop < height) {
|
|
var hit = component.queryHit(positionLeft, positionTop, width, height);
|
|
if (hit && rangeContainsRange(hit.dateProfile.activeRange, hit.dateSpan.range) && (!bestHit || hit.layer > bestHit.layer)) {
|
|
hit.componentId = id;
|
|
hit.context = component.context;
|
|
hit.rect.left += originLeft;
|
|
hit.rect.right += originLeft;
|
|
hit.rect.top += originTop;
|
|
hit.rect.bottom += originTop;
|
|
bestHit = hit;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return bestHit;
|
|
};
|
|
return HitDragging2;
|
|
}();
|
|
function isHitsEqual(hit0, hit1) {
|
|
if (!hit0 && !hit1) {
|
|
return true;
|
|
}
|
|
if (Boolean(hit0) !== Boolean(hit1)) {
|
|
return false;
|
|
}
|
|
return isDateSpansEqual(hit0.dateSpan, hit1.dateSpan);
|
|
}
|
|
function buildDatePointApiWithContext(dateSpan, context) {
|
|
var props = {};
|
|
for (var _i = 0, _a = context.pluginHooks.datePointTransforms; _i < _a.length; _i++) {
|
|
var transform = _a[_i];
|
|
__assign(props, transform(dateSpan, context));
|
|
}
|
|
__assign(props, buildDatePointApi(dateSpan, context.dateEnv));
|
|
return props;
|
|
}
|
|
function buildDatePointApi(span, dateEnv) {
|
|
return {
|
|
date: dateEnv.toDate(span.range.start),
|
|
dateStr: dateEnv.formatIso(span.range.start, { omitTime: span.allDay }),
|
|
allDay: span.allDay
|
|
};
|
|
}
|
|
var DateClicking = function(_super) {
|
|
__extends(DateClicking2, _super);
|
|
function DateClicking2(settings) {
|
|
var _this = _super.call(this, settings) || this;
|
|
_this.handlePointerDown = function(pev) {
|
|
var dragging = _this.dragging;
|
|
var downEl = pev.origEvent.target;
|
|
dragging.setIgnoreMove(!_this.component.isValidDateDownEl(downEl));
|
|
};
|
|
_this.handleDragEnd = function(ev) {
|
|
var component = _this.component;
|
|
var pointer = _this.dragging.pointer;
|
|
if (!pointer.wasTouchScroll) {
|
|
var _a = _this.hitDragging, initialHit = _a.initialHit, finalHit = _a.finalHit;
|
|
if (initialHit && finalHit && isHitsEqual(initialHit, finalHit)) {
|
|
var context = component.context;
|
|
var arg = __assign(__assign({}, buildDatePointApiWithContext(initialHit.dateSpan, context)), { dayEl: initialHit.dayEl, jsEvent: ev.origEvent, view: context.viewApi || context.calendarApi.view });
|
|
context.emitter.trigger("dateClick", arg);
|
|
}
|
|
}
|
|
};
|
|
_this.dragging = new FeaturefulElementDragging(settings.el);
|
|
_this.dragging.autoScroller.isEnabled = false;
|
|
var hitDragging = _this.hitDragging = new HitDragging(_this.dragging, interactionSettingsToStore(settings));
|
|
hitDragging.emitter.on("pointerdown", _this.handlePointerDown);
|
|
hitDragging.emitter.on("dragend", _this.handleDragEnd);
|
|
return _this;
|
|
}
|
|
DateClicking2.prototype.destroy = function() {
|
|
this.dragging.destroy();
|
|
};
|
|
return DateClicking2;
|
|
}(Interaction);
|
|
var DateSelecting = function(_super) {
|
|
__extends(DateSelecting2, _super);
|
|
function DateSelecting2(settings) {
|
|
var _this = _super.call(this, settings) || this;
|
|
_this.dragSelection = null;
|
|
_this.handlePointerDown = function(ev) {
|
|
var _a = _this, component2 = _a.component, dragging2 = _a.dragging;
|
|
var options2 = component2.context.options;
|
|
var canSelect = options2.selectable && component2.isValidDateDownEl(ev.origEvent.target);
|
|
dragging2.setIgnoreMove(!canSelect);
|
|
dragging2.delay = ev.isTouch ? getComponentTouchDelay$1(component2) : null;
|
|
};
|
|
_this.handleDragStart = function(ev) {
|
|
_this.component.context.calendarApi.unselect(ev);
|
|
};
|
|
_this.handleHitUpdate = function(hit, isFinal) {
|
|
var context = _this.component.context;
|
|
var dragSelection = null;
|
|
var isInvalid = false;
|
|
if (hit) {
|
|
var initialHit = _this.hitDragging.initialHit;
|
|
var disallowed = hit.componentId === initialHit.componentId && _this.isHitComboAllowed && !_this.isHitComboAllowed(initialHit, hit);
|
|
if (!disallowed) {
|
|
dragSelection = joinHitsIntoSelection(initialHit, hit, context.pluginHooks.dateSelectionTransformers);
|
|
}
|
|
if (!dragSelection || !isDateSelectionValid(dragSelection, hit.dateProfile, context)) {
|
|
isInvalid = true;
|
|
dragSelection = null;
|
|
}
|
|
}
|
|
if (dragSelection) {
|
|
context.dispatch({ type: "SELECT_DATES", selection: dragSelection });
|
|
} else if (!isFinal) {
|
|
context.dispatch({ type: "UNSELECT_DATES" });
|
|
}
|
|
if (!isInvalid) {
|
|
enableCursor();
|
|
} else {
|
|
disableCursor();
|
|
}
|
|
if (!isFinal) {
|
|
_this.dragSelection = dragSelection;
|
|
}
|
|
};
|
|
_this.handlePointerUp = function(pev) {
|
|
if (_this.dragSelection) {
|
|
triggerDateSelect(_this.dragSelection, pev, _this.component.context);
|
|
_this.dragSelection = null;
|
|
}
|
|
};
|
|
var component = settings.component;
|
|
var options = component.context.options;
|
|
var dragging = _this.dragging = new FeaturefulElementDragging(settings.el);
|
|
dragging.touchScrollAllowed = false;
|
|
dragging.minDistance = options.selectMinDistance || 0;
|
|
dragging.autoScroller.isEnabled = options.dragScroll;
|
|
var hitDragging = _this.hitDragging = new HitDragging(_this.dragging, interactionSettingsToStore(settings));
|
|
hitDragging.emitter.on("pointerdown", _this.handlePointerDown);
|
|
hitDragging.emitter.on("dragstart", _this.handleDragStart);
|
|
hitDragging.emitter.on("hitupdate", _this.handleHitUpdate);
|
|
hitDragging.emitter.on("pointerup", _this.handlePointerUp);
|
|
return _this;
|
|
}
|
|
DateSelecting2.prototype.destroy = function() {
|
|
this.dragging.destroy();
|
|
};
|
|
return DateSelecting2;
|
|
}(Interaction);
|
|
function getComponentTouchDelay$1(component) {
|
|
var options = component.context.options;
|
|
var delay = options.selectLongPressDelay;
|
|
if (delay == null) {
|
|
delay = options.longPressDelay;
|
|
}
|
|
return delay;
|
|
}
|
|
function joinHitsIntoSelection(hit0, hit1, dateSelectionTransformers) {
|
|
var dateSpan0 = hit0.dateSpan;
|
|
var dateSpan1 = hit1.dateSpan;
|
|
var ms = [
|
|
dateSpan0.range.start,
|
|
dateSpan0.range.end,
|
|
dateSpan1.range.start,
|
|
dateSpan1.range.end
|
|
];
|
|
ms.sort(compareNumbers);
|
|
var props = {};
|
|
for (var _i = 0, dateSelectionTransformers_1 = dateSelectionTransformers; _i < dateSelectionTransformers_1.length; _i++) {
|
|
var transformer = dateSelectionTransformers_1[_i];
|
|
var res = transformer(hit0, hit1);
|
|
if (res === false) {
|
|
return null;
|
|
}
|
|
if (res) {
|
|
__assign(props, res);
|
|
}
|
|
}
|
|
props.range = { start: ms[0], end: ms[3] };
|
|
props.allDay = dateSpan0.allDay;
|
|
return props;
|
|
}
|
|
var EventDragging = function(_super) {
|
|
__extends(EventDragging2, _super);
|
|
function EventDragging2(settings) {
|
|
var _this = _super.call(this, settings) || this;
|
|
_this.subjectEl = null;
|
|
_this.subjectSeg = null;
|
|
_this.isDragging = false;
|
|
_this.eventRange = null;
|
|
_this.relevantEvents = null;
|
|
_this.receivingContext = null;
|
|
_this.validMutation = null;
|
|
_this.mutatedRelevantEvents = null;
|
|
_this.handlePointerDown = function(ev) {
|
|
var origTarget = ev.origEvent.target;
|
|
var _a = _this, component2 = _a.component, dragging2 = _a.dragging;
|
|
var mirror = dragging2.mirror;
|
|
var options2 = component2.context.options;
|
|
var initialContext = component2.context;
|
|
_this.subjectEl = ev.subjectEl;
|
|
var subjectSeg = _this.subjectSeg = getElSeg(ev.subjectEl);
|
|
var eventRange = _this.eventRange = subjectSeg.eventRange;
|
|
var eventInstanceId = eventRange.instance.instanceId;
|
|
_this.relevantEvents = getRelevantEvents(initialContext.getCurrentData().eventStore, eventInstanceId);
|
|
dragging2.minDistance = ev.isTouch ? 0 : options2.eventDragMinDistance;
|
|
dragging2.delay = ev.isTouch && eventInstanceId !== component2.props.eventSelection ? getComponentTouchDelay(component2) : null;
|
|
if (options2.fixedMirrorParent) {
|
|
mirror.parentNode = options2.fixedMirrorParent;
|
|
} else {
|
|
mirror.parentNode = elementClosest(origTarget, ".fc");
|
|
}
|
|
mirror.revertDuration = options2.dragRevertDuration;
|
|
var isValid = component2.isValidSegDownEl(origTarget) && !elementClosest(origTarget, ".fc-event-resizer");
|
|
dragging2.setIgnoreMove(!isValid);
|
|
_this.isDragging = isValid && ev.subjectEl.classList.contains("fc-event-draggable");
|
|
};
|
|
_this.handleDragStart = function(ev) {
|
|
var initialContext = _this.component.context;
|
|
var eventRange = _this.eventRange;
|
|
var eventInstanceId = eventRange.instance.instanceId;
|
|
if (ev.isTouch) {
|
|
if (eventInstanceId !== _this.component.props.eventSelection) {
|
|
initialContext.dispatch({ type: "SELECT_EVENT", eventInstanceId });
|
|
}
|
|
} else {
|
|
initialContext.dispatch({ type: "UNSELECT_EVENT" });
|
|
}
|
|
if (_this.isDragging) {
|
|
initialContext.calendarApi.unselect(ev);
|
|
initialContext.emitter.trigger("eventDragStart", {
|
|
el: _this.subjectEl,
|
|
event: new EventApi(initialContext, eventRange.def, eventRange.instance),
|
|
jsEvent: ev.origEvent,
|
|
view: initialContext.viewApi
|
|
});
|
|
}
|
|
};
|
|
_this.handleHitUpdate = function(hit, isFinal) {
|
|
if (!_this.isDragging) {
|
|
return;
|
|
}
|
|
var relevantEvents = _this.relevantEvents;
|
|
var initialHit = _this.hitDragging.initialHit;
|
|
var initialContext = _this.component.context;
|
|
var receivingContext = null;
|
|
var mutation = null;
|
|
var mutatedRelevantEvents = null;
|
|
var isInvalid = false;
|
|
var interaction = {
|
|
affectedEvents: relevantEvents,
|
|
mutatedEvents: createEmptyEventStore(),
|
|
isEvent: true
|
|
};
|
|
if (hit) {
|
|
receivingContext = hit.context;
|
|
var receivingOptions = receivingContext.options;
|
|
if (initialContext === receivingContext || receivingOptions.editable && receivingOptions.droppable) {
|
|
mutation = computeEventMutation(initialHit, hit, receivingContext.getCurrentData().pluginHooks.eventDragMutationMassagers);
|
|
if (mutation) {
|
|
mutatedRelevantEvents = applyMutationToEventStore(relevantEvents, receivingContext.getCurrentData().eventUiBases, mutation, receivingContext);
|
|
interaction.mutatedEvents = mutatedRelevantEvents;
|
|
if (!isInteractionValid(interaction, hit.dateProfile, receivingContext)) {
|
|
isInvalid = true;
|
|
mutation = null;
|
|
mutatedRelevantEvents = null;
|
|
interaction.mutatedEvents = createEmptyEventStore();
|
|
}
|
|
}
|
|
} else {
|
|
receivingContext = null;
|
|
}
|
|
}
|
|
_this.displayDrag(receivingContext, interaction);
|
|
if (!isInvalid) {
|
|
enableCursor();
|
|
} else {
|
|
disableCursor();
|
|
}
|
|
if (!isFinal) {
|
|
if (initialContext === receivingContext && isHitsEqual(initialHit, hit)) {
|
|
mutation = null;
|
|
}
|
|
_this.dragging.setMirrorNeedsRevert(!mutation);
|
|
_this.dragging.setMirrorIsVisible(!hit || !getElRoot(_this.subjectEl).querySelector(".fc-event-mirror"));
|
|
_this.receivingContext = receivingContext;
|
|
_this.validMutation = mutation;
|
|
_this.mutatedRelevantEvents = mutatedRelevantEvents;
|
|
}
|
|
};
|
|
_this.handlePointerUp = function() {
|
|
if (!_this.isDragging) {
|
|
_this.cleanup();
|
|
}
|
|
};
|
|
_this.handleDragEnd = function(ev) {
|
|
if (_this.isDragging) {
|
|
var initialContext_1 = _this.component.context;
|
|
var initialView = initialContext_1.viewApi;
|
|
var _a = _this, receivingContext_1 = _a.receivingContext, validMutation = _a.validMutation;
|
|
var eventDef = _this.eventRange.def;
|
|
var eventInstance = _this.eventRange.instance;
|
|
var eventApi = new EventApi(initialContext_1, eventDef, eventInstance);
|
|
var relevantEvents_1 = _this.relevantEvents;
|
|
var mutatedRelevantEvents_1 = _this.mutatedRelevantEvents;
|
|
var finalHit = _this.hitDragging.finalHit;
|
|
_this.clearDrag();
|
|
initialContext_1.emitter.trigger("eventDragStop", {
|
|
el: _this.subjectEl,
|
|
event: eventApi,
|
|
jsEvent: ev.origEvent,
|
|
view: initialView
|
|
});
|
|
if (validMutation) {
|
|
if (receivingContext_1 === initialContext_1) {
|
|
var updatedEventApi = new EventApi(initialContext_1, mutatedRelevantEvents_1.defs[eventDef.defId], eventInstance ? mutatedRelevantEvents_1.instances[eventInstance.instanceId] : null);
|
|
initialContext_1.dispatch({
|
|
type: "MERGE_EVENTS",
|
|
eventStore: mutatedRelevantEvents_1
|
|
});
|
|
var eventChangeArg = {
|
|
oldEvent: eventApi,
|
|
event: updatedEventApi,
|
|
relatedEvents: buildEventApis(mutatedRelevantEvents_1, initialContext_1, eventInstance),
|
|
revert: function() {
|
|
initialContext_1.dispatch({
|
|
type: "MERGE_EVENTS",
|
|
eventStore: relevantEvents_1
|
|
});
|
|
}
|
|
};
|
|
var transformed = {};
|
|
for (var _i = 0, _b = initialContext_1.getCurrentData().pluginHooks.eventDropTransformers; _i < _b.length; _i++) {
|
|
var transformer = _b[_i];
|
|
__assign(transformed, transformer(validMutation, initialContext_1));
|
|
}
|
|
initialContext_1.emitter.trigger("eventDrop", __assign(__assign(__assign({}, eventChangeArg), transformed), { el: ev.subjectEl, delta: validMutation.datesDelta, jsEvent: ev.origEvent, view: initialView }));
|
|
initialContext_1.emitter.trigger("eventChange", eventChangeArg);
|
|
} else if (receivingContext_1) {
|
|
var eventRemoveArg = {
|
|
event: eventApi,
|
|
relatedEvents: buildEventApis(relevantEvents_1, initialContext_1, eventInstance),
|
|
revert: function() {
|
|
initialContext_1.dispatch({
|
|
type: "MERGE_EVENTS",
|
|
eventStore: relevantEvents_1
|
|
});
|
|
}
|
|
};
|
|
initialContext_1.emitter.trigger("eventLeave", __assign(__assign({}, eventRemoveArg), { draggedEl: ev.subjectEl, view: initialView }));
|
|
initialContext_1.dispatch({
|
|
type: "REMOVE_EVENTS",
|
|
eventStore: relevantEvents_1
|
|
});
|
|
initialContext_1.emitter.trigger("eventRemove", eventRemoveArg);
|
|
var addedEventDef = mutatedRelevantEvents_1.defs[eventDef.defId];
|
|
var addedEventInstance = mutatedRelevantEvents_1.instances[eventInstance.instanceId];
|
|
var addedEventApi = new EventApi(receivingContext_1, addedEventDef, addedEventInstance);
|
|
receivingContext_1.dispatch({
|
|
type: "MERGE_EVENTS",
|
|
eventStore: mutatedRelevantEvents_1
|
|
});
|
|
var eventAddArg = {
|
|
event: addedEventApi,
|
|
relatedEvents: buildEventApis(mutatedRelevantEvents_1, receivingContext_1, addedEventInstance),
|
|
revert: function() {
|
|
receivingContext_1.dispatch({
|
|
type: "REMOVE_EVENTS",
|
|
eventStore: mutatedRelevantEvents_1
|
|
});
|
|
}
|
|
};
|
|
receivingContext_1.emitter.trigger("eventAdd", eventAddArg);
|
|
if (ev.isTouch) {
|
|
receivingContext_1.dispatch({
|
|
type: "SELECT_EVENT",
|
|
eventInstanceId: eventInstance.instanceId
|
|
});
|
|
}
|
|
receivingContext_1.emitter.trigger("drop", __assign(__assign({}, buildDatePointApiWithContext(finalHit.dateSpan, receivingContext_1)), { draggedEl: ev.subjectEl, jsEvent: ev.origEvent, view: finalHit.context.viewApi }));
|
|
receivingContext_1.emitter.trigger("eventReceive", __assign(__assign({}, eventAddArg), { draggedEl: ev.subjectEl, view: finalHit.context.viewApi }));
|
|
}
|
|
} else {
|
|
initialContext_1.emitter.trigger("_noEventDrop");
|
|
}
|
|
}
|
|
_this.cleanup();
|
|
};
|
|
var component = _this.component;
|
|
var options = component.context.options;
|
|
var dragging = _this.dragging = new FeaturefulElementDragging(settings.el);
|
|
dragging.pointer.selector = EventDragging2.SELECTOR;
|
|
dragging.touchScrollAllowed = false;
|
|
dragging.autoScroller.isEnabled = options.dragScroll;
|
|
var hitDragging = _this.hitDragging = new HitDragging(_this.dragging, interactionSettingsStore);
|
|
hitDragging.useSubjectCenter = settings.useEventCenter;
|
|
hitDragging.emitter.on("pointerdown", _this.handlePointerDown);
|
|
hitDragging.emitter.on("dragstart", _this.handleDragStart);
|
|
hitDragging.emitter.on("hitupdate", _this.handleHitUpdate);
|
|
hitDragging.emitter.on("pointerup", _this.handlePointerUp);
|
|
hitDragging.emitter.on("dragend", _this.handleDragEnd);
|
|
return _this;
|
|
}
|
|
EventDragging2.prototype.destroy = function() {
|
|
this.dragging.destroy();
|
|
};
|
|
EventDragging2.prototype.displayDrag = function(nextContext, state) {
|
|
var initialContext = this.component.context;
|
|
var prevContext = this.receivingContext;
|
|
if (prevContext && prevContext !== nextContext) {
|
|
if (prevContext === initialContext) {
|
|
prevContext.dispatch({
|
|
type: "SET_EVENT_DRAG",
|
|
state: {
|
|
affectedEvents: state.affectedEvents,
|
|
mutatedEvents: createEmptyEventStore(),
|
|
isEvent: true
|
|
}
|
|
});
|
|
} else {
|
|
prevContext.dispatch({ type: "UNSET_EVENT_DRAG" });
|
|
}
|
|
}
|
|
if (nextContext) {
|
|
nextContext.dispatch({ type: "SET_EVENT_DRAG", state });
|
|
}
|
|
};
|
|
EventDragging2.prototype.clearDrag = function() {
|
|
var initialCalendar = this.component.context;
|
|
var receivingContext = this.receivingContext;
|
|
if (receivingContext) {
|
|
receivingContext.dispatch({ type: "UNSET_EVENT_DRAG" });
|
|
}
|
|
if (initialCalendar !== receivingContext) {
|
|
initialCalendar.dispatch({ type: "UNSET_EVENT_DRAG" });
|
|
}
|
|
};
|
|
EventDragging2.prototype.cleanup = function() {
|
|
this.subjectSeg = null;
|
|
this.isDragging = false;
|
|
this.eventRange = null;
|
|
this.relevantEvents = null;
|
|
this.receivingContext = null;
|
|
this.validMutation = null;
|
|
this.mutatedRelevantEvents = null;
|
|
};
|
|
EventDragging2.SELECTOR = ".fc-event-draggable, .fc-event-resizable";
|
|
return EventDragging2;
|
|
}(Interaction);
|
|
function computeEventMutation(hit0, hit1, massagers) {
|
|
var dateSpan0 = hit0.dateSpan;
|
|
var dateSpan1 = hit1.dateSpan;
|
|
var date0 = dateSpan0.range.start;
|
|
var date1 = dateSpan1.range.start;
|
|
var standardProps = {};
|
|
if (dateSpan0.allDay !== dateSpan1.allDay) {
|
|
standardProps.allDay = dateSpan1.allDay;
|
|
standardProps.hasEnd = hit1.context.options.allDayMaintainDuration;
|
|
if (dateSpan1.allDay) {
|
|
date0 = startOfDay(date0);
|
|
}
|
|
}
|
|
var delta = diffDates(date0, date1, hit0.context.dateEnv, hit0.componentId === hit1.componentId ? hit0.largeUnit : null);
|
|
if (delta.milliseconds) {
|
|
standardProps.allDay = false;
|
|
}
|
|
var mutation = {
|
|
datesDelta: delta,
|
|
standardProps
|
|
};
|
|
for (var _i = 0, massagers_1 = massagers; _i < massagers_1.length; _i++) {
|
|
var massager = massagers_1[_i];
|
|
massager(mutation, hit0, hit1);
|
|
}
|
|
return mutation;
|
|
}
|
|
function getComponentTouchDelay(component) {
|
|
var options = component.context.options;
|
|
var delay = options.eventLongPressDelay;
|
|
if (delay == null) {
|
|
delay = options.longPressDelay;
|
|
}
|
|
return delay;
|
|
}
|
|
var EventResizing = function(_super) {
|
|
__extends(EventResizing2, _super);
|
|
function EventResizing2(settings) {
|
|
var _this = _super.call(this, settings) || this;
|
|
_this.draggingSegEl = null;
|
|
_this.draggingSeg = null;
|
|
_this.eventRange = null;
|
|
_this.relevantEvents = null;
|
|
_this.validMutation = null;
|
|
_this.mutatedRelevantEvents = null;
|
|
_this.handlePointerDown = function(ev) {
|
|
var component2 = _this.component;
|
|
var segEl = _this.querySegEl(ev);
|
|
var seg = getElSeg(segEl);
|
|
var eventRange = _this.eventRange = seg.eventRange;
|
|
_this.dragging.minDistance = component2.context.options.eventDragMinDistance;
|
|
_this.dragging.setIgnoreMove(!_this.component.isValidSegDownEl(ev.origEvent.target) || ev.isTouch && _this.component.props.eventSelection !== eventRange.instance.instanceId);
|
|
};
|
|
_this.handleDragStart = function(ev) {
|
|
var context = _this.component.context;
|
|
var eventRange = _this.eventRange;
|
|
_this.relevantEvents = getRelevantEvents(context.getCurrentData().eventStore, _this.eventRange.instance.instanceId);
|
|
var segEl = _this.querySegEl(ev);
|
|
_this.draggingSegEl = segEl;
|
|
_this.draggingSeg = getElSeg(segEl);
|
|
context.calendarApi.unselect();
|
|
context.emitter.trigger("eventResizeStart", {
|
|
el: segEl,
|
|
event: new EventApi(context, eventRange.def, eventRange.instance),
|
|
jsEvent: ev.origEvent,
|
|
view: context.viewApi
|
|
});
|
|
};
|
|
_this.handleHitUpdate = function(hit, isFinal, ev) {
|
|
var context = _this.component.context;
|
|
var relevantEvents = _this.relevantEvents;
|
|
var initialHit = _this.hitDragging.initialHit;
|
|
var eventInstance = _this.eventRange.instance;
|
|
var mutation = null;
|
|
var mutatedRelevantEvents = null;
|
|
var isInvalid = false;
|
|
var interaction = {
|
|
affectedEvents: relevantEvents,
|
|
mutatedEvents: createEmptyEventStore(),
|
|
isEvent: true
|
|
};
|
|
if (hit) {
|
|
var disallowed = hit.componentId === initialHit.componentId && _this.isHitComboAllowed && !_this.isHitComboAllowed(initialHit, hit);
|
|
if (!disallowed) {
|
|
mutation = computeMutation(initialHit, hit, ev.subjectEl.classList.contains("fc-event-resizer-start"), eventInstance.range);
|
|
}
|
|
}
|
|
if (mutation) {
|
|
mutatedRelevantEvents = applyMutationToEventStore(relevantEvents, context.getCurrentData().eventUiBases, mutation, context);
|
|
interaction.mutatedEvents = mutatedRelevantEvents;
|
|
if (!isInteractionValid(interaction, hit.dateProfile, context)) {
|
|
isInvalid = true;
|
|
mutation = null;
|
|
mutatedRelevantEvents = null;
|
|
interaction.mutatedEvents = null;
|
|
}
|
|
}
|
|
if (mutatedRelevantEvents) {
|
|
context.dispatch({
|
|
type: "SET_EVENT_RESIZE",
|
|
state: interaction
|
|
});
|
|
} else {
|
|
context.dispatch({ type: "UNSET_EVENT_RESIZE" });
|
|
}
|
|
if (!isInvalid) {
|
|
enableCursor();
|
|
} else {
|
|
disableCursor();
|
|
}
|
|
if (!isFinal) {
|
|
if (mutation && isHitsEqual(initialHit, hit)) {
|
|
mutation = null;
|
|
}
|
|
_this.validMutation = mutation;
|
|
_this.mutatedRelevantEvents = mutatedRelevantEvents;
|
|
}
|
|
};
|
|
_this.handleDragEnd = function(ev) {
|
|
var context = _this.component.context;
|
|
var eventDef = _this.eventRange.def;
|
|
var eventInstance = _this.eventRange.instance;
|
|
var eventApi = new EventApi(context, eventDef, eventInstance);
|
|
var relevantEvents = _this.relevantEvents;
|
|
var mutatedRelevantEvents = _this.mutatedRelevantEvents;
|
|
context.emitter.trigger("eventResizeStop", {
|
|
el: _this.draggingSegEl,
|
|
event: eventApi,
|
|
jsEvent: ev.origEvent,
|
|
view: context.viewApi
|
|
});
|
|
if (_this.validMutation) {
|
|
var updatedEventApi = new EventApi(context, mutatedRelevantEvents.defs[eventDef.defId], eventInstance ? mutatedRelevantEvents.instances[eventInstance.instanceId] : null);
|
|
context.dispatch({
|
|
type: "MERGE_EVENTS",
|
|
eventStore: mutatedRelevantEvents
|
|
});
|
|
var eventChangeArg = {
|
|
oldEvent: eventApi,
|
|
event: updatedEventApi,
|
|
relatedEvents: buildEventApis(mutatedRelevantEvents, context, eventInstance),
|
|
revert: function() {
|
|
context.dispatch({
|
|
type: "MERGE_EVENTS",
|
|
eventStore: relevantEvents
|
|
});
|
|
}
|
|
};
|
|
context.emitter.trigger("eventResize", __assign(__assign({}, eventChangeArg), { el: _this.draggingSegEl, startDelta: _this.validMutation.startDelta || createDuration(0), endDelta: _this.validMutation.endDelta || createDuration(0), jsEvent: ev.origEvent, view: context.viewApi }));
|
|
context.emitter.trigger("eventChange", eventChangeArg);
|
|
} else {
|
|
context.emitter.trigger("_noEventResize");
|
|
}
|
|
_this.draggingSeg = null;
|
|
_this.relevantEvents = null;
|
|
_this.validMutation = null;
|
|
};
|
|
var component = settings.component;
|
|
var dragging = _this.dragging = new FeaturefulElementDragging(settings.el);
|
|
dragging.pointer.selector = ".fc-event-resizer";
|
|
dragging.touchScrollAllowed = false;
|
|
dragging.autoScroller.isEnabled = component.context.options.dragScroll;
|
|
var hitDragging = _this.hitDragging = new HitDragging(_this.dragging, interactionSettingsToStore(settings));
|
|
hitDragging.emitter.on("pointerdown", _this.handlePointerDown);
|
|
hitDragging.emitter.on("dragstart", _this.handleDragStart);
|
|
hitDragging.emitter.on("hitupdate", _this.handleHitUpdate);
|
|
hitDragging.emitter.on("dragend", _this.handleDragEnd);
|
|
return _this;
|
|
}
|
|
EventResizing2.prototype.destroy = function() {
|
|
this.dragging.destroy();
|
|
};
|
|
EventResizing2.prototype.querySegEl = function(ev) {
|
|
return elementClosest(ev.subjectEl, ".fc-event");
|
|
};
|
|
return EventResizing2;
|
|
}(Interaction);
|
|
function computeMutation(hit0, hit1, isFromStart, instanceRange) {
|
|
var dateEnv = hit0.context.dateEnv;
|
|
var date0 = hit0.dateSpan.range.start;
|
|
var date1 = hit1.dateSpan.range.start;
|
|
var delta = diffDates(date0, date1, dateEnv, hit0.largeUnit);
|
|
if (isFromStart) {
|
|
if (dateEnv.add(instanceRange.start, delta) < instanceRange.end) {
|
|
return { startDelta: delta };
|
|
}
|
|
} else if (dateEnv.add(instanceRange.end, delta) > instanceRange.start) {
|
|
return { endDelta: delta };
|
|
}
|
|
return null;
|
|
}
|
|
var UnselectAuto = function() {
|
|
function UnselectAuto2(context) {
|
|
var _this = this;
|
|
this.context = context;
|
|
this.isRecentPointerDateSelect = false;
|
|
this.matchesCancel = false;
|
|
this.matchesEvent = false;
|
|
this.onSelect = function(selectInfo) {
|
|
if (selectInfo.jsEvent) {
|
|
_this.isRecentPointerDateSelect = true;
|
|
}
|
|
};
|
|
this.onDocumentPointerDown = function(pev) {
|
|
var unselectCancel = _this.context.options.unselectCancel;
|
|
var downEl = getEventTargetViaRoot(pev.origEvent);
|
|
_this.matchesCancel = !!elementClosest(downEl, unselectCancel);
|
|
_this.matchesEvent = !!elementClosest(downEl, EventDragging.SELECTOR);
|
|
};
|
|
this.onDocumentPointerUp = function(pev) {
|
|
var context2 = _this.context;
|
|
var documentPointer2 = _this.documentPointer;
|
|
var calendarState = context2.getCurrentData();
|
|
if (!documentPointer2.wasTouchScroll) {
|
|
if (calendarState.dateSelection && !_this.isRecentPointerDateSelect) {
|
|
var unselectAuto = context2.options.unselectAuto;
|
|
if (unselectAuto && (!unselectAuto || !_this.matchesCancel)) {
|
|
context2.calendarApi.unselect(pev);
|
|
}
|
|
}
|
|
if (calendarState.eventSelection && !_this.matchesEvent) {
|
|
context2.dispatch({ type: "UNSELECT_EVENT" });
|
|
}
|
|
}
|
|
_this.isRecentPointerDateSelect = false;
|
|
};
|
|
var documentPointer = this.documentPointer = new PointerDragging(document);
|
|
documentPointer.shouldIgnoreMove = true;
|
|
documentPointer.shouldWatchScroll = false;
|
|
documentPointer.emitter.on("pointerdown", this.onDocumentPointerDown);
|
|
documentPointer.emitter.on("pointerup", this.onDocumentPointerUp);
|
|
context.emitter.on("select", this.onSelect);
|
|
}
|
|
UnselectAuto2.prototype.destroy = function() {
|
|
this.context.emitter.off("select", this.onSelect);
|
|
this.documentPointer.destroy();
|
|
};
|
|
return UnselectAuto2;
|
|
}();
|
|
var OPTION_REFINERS3 = {
|
|
fixedMirrorParent: identity
|
|
};
|
|
var LISTENER_REFINERS = {
|
|
dateClick: identity,
|
|
eventDragStart: identity,
|
|
eventDragStop: identity,
|
|
eventDrop: identity,
|
|
eventResizeStart: identity,
|
|
eventResizeStop: identity,
|
|
eventResize: identity,
|
|
drop: identity,
|
|
eventReceive: identity,
|
|
eventLeave: identity
|
|
};
|
|
var ExternalElementDragging = function() {
|
|
function ExternalElementDragging2(dragging, suppliedDragMeta) {
|
|
var _this = this;
|
|
this.receivingContext = null;
|
|
this.droppableEvent = null;
|
|
this.suppliedDragMeta = null;
|
|
this.dragMeta = null;
|
|
this.handleDragStart = function(ev) {
|
|
_this.dragMeta = _this.buildDragMeta(ev.subjectEl);
|
|
};
|
|
this.handleHitUpdate = function(hit, isFinal, ev) {
|
|
var dragging2 = _this.hitDragging.dragging;
|
|
var receivingContext = null;
|
|
var droppableEvent = null;
|
|
var isInvalid = false;
|
|
var interaction = {
|
|
affectedEvents: createEmptyEventStore(),
|
|
mutatedEvents: createEmptyEventStore(),
|
|
isEvent: _this.dragMeta.create
|
|
};
|
|
if (hit) {
|
|
receivingContext = hit.context;
|
|
if (_this.canDropElOnCalendar(ev.subjectEl, receivingContext)) {
|
|
droppableEvent = computeEventForDateSpan(hit.dateSpan, _this.dragMeta, receivingContext);
|
|
interaction.mutatedEvents = eventTupleToStore(droppableEvent);
|
|
isInvalid = !isInteractionValid(interaction, hit.dateProfile, receivingContext);
|
|
if (isInvalid) {
|
|
interaction.mutatedEvents = createEmptyEventStore();
|
|
droppableEvent = null;
|
|
}
|
|
}
|
|
}
|
|
_this.displayDrag(receivingContext, interaction);
|
|
dragging2.setMirrorIsVisible(isFinal || !droppableEvent || !document.querySelector(".fc-event-mirror"));
|
|
if (!isInvalid) {
|
|
enableCursor();
|
|
} else {
|
|
disableCursor();
|
|
}
|
|
if (!isFinal) {
|
|
dragging2.setMirrorNeedsRevert(!droppableEvent);
|
|
_this.receivingContext = receivingContext;
|
|
_this.droppableEvent = droppableEvent;
|
|
}
|
|
};
|
|
this.handleDragEnd = function(pev) {
|
|
var _a = _this, receivingContext = _a.receivingContext, droppableEvent = _a.droppableEvent;
|
|
_this.clearDrag();
|
|
if (receivingContext && droppableEvent) {
|
|
var finalHit = _this.hitDragging.finalHit;
|
|
var finalView = finalHit.context.viewApi;
|
|
var dragMeta = _this.dragMeta;
|
|
receivingContext.emitter.trigger("drop", __assign(__assign({}, buildDatePointApiWithContext(finalHit.dateSpan, receivingContext)), { draggedEl: pev.subjectEl, jsEvent: pev.origEvent, view: finalView }));
|
|
if (dragMeta.create) {
|
|
var addingEvents_1 = eventTupleToStore(droppableEvent);
|
|
receivingContext.dispatch({
|
|
type: "MERGE_EVENTS",
|
|
eventStore: addingEvents_1
|
|
});
|
|
if (pev.isTouch) {
|
|
receivingContext.dispatch({
|
|
type: "SELECT_EVENT",
|
|
eventInstanceId: droppableEvent.instance.instanceId
|
|
});
|
|
}
|
|
receivingContext.emitter.trigger("eventReceive", {
|
|
event: new EventApi(receivingContext, droppableEvent.def, droppableEvent.instance),
|
|
relatedEvents: [],
|
|
revert: function() {
|
|
receivingContext.dispatch({
|
|
type: "REMOVE_EVENTS",
|
|
eventStore: addingEvents_1
|
|
});
|
|
},
|
|
draggedEl: pev.subjectEl,
|
|
view: finalView
|
|
});
|
|
}
|
|
}
|
|
_this.receivingContext = null;
|
|
_this.droppableEvent = null;
|
|
};
|
|
var hitDragging = this.hitDragging = new HitDragging(dragging, interactionSettingsStore);
|
|
hitDragging.requireInitial = false;
|
|
hitDragging.emitter.on("dragstart", this.handleDragStart);
|
|
hitDragging.emitter.on("hitupdate", this.handleHitUpdate);
|
|
hitDragging.emitter.on("dragend", this.handleDragEnd);
|
|
this.suppliedDragMeta = suppliedDragMeta;
|
|
}
|
|
ExternalElementDragging2.prototype.buildDragMeta = function(subjectEl) {
|
|
if (typeof this.suppliedDragMeta === "object") {
|
|
return parseDragMeta(this.suppliedDragMeta);
|
|
}
|
|
if (typeof this.suppliedDragMeta === "function") {
|
|
return parseDragMeta(this.suppliedDragMeta(subjectEl));
|
|
}
|
|
return getDragMetaFromEl(subjectEl);
|
|
};
|
|
ExternalElementDragging2.prototype.displayDrag = function(nextContext, state) {
|
|
var prevContext = this.receivingContext;
|
|
if (prevContext && prevContext !== nextContext) {
|
|
prevContext.dispatch({ type: "UNSET_EVENT_DRAG" });
|
|
}
|
|
if (nextContext) {
|
|
nextContext.dispatch({ type: "SET_EVENT_DRAG", state });
|
|
}
|
|
};
|
|
ExternalElementDragging2.prototype.clearDrag = function() {
|
|
if (this.receivingContext) {
|
|
this.receivingContext.dispatch({ type: "UNSET_EVENT_DRAG" });
|
|
}
|
|
};
|
|
ExternalElementDragging2.prototype.canDropElOnCalendar = function(el, receivingContext) {
|
|
var dropAccept = receivingContext.options.dropAccept;
|
|
if (typeof dropAccept === "function") {
|
|
return dropAccept.call(receivingContext.calendarApi, el);
|
|
}
|
|
if (typeof dropAccept === "string" && dropAccept) {
|
|
return Boolean(elementMatches(el, dropAccept));
|
|
}
|
|
return true;
|
|
};
|
|
return ExternalElementDragging2;
|
|
}();
|
|
function computeEventForDateSpan(dateSpan, dragMeta, context) {
|
|
var defProps = __assign({}, dragMeta.leftoverProps);
|
|
for (var _i = 0, _a = context.pluginHooks.externalDefTransforms; _i < _a.length; _i++) {
|
|
var transform = _a[_i];
|
|
__assign(defProps, transform(dateSpan, dragMeta));
|
|
}
|
|
var _b = refineEventDef(defProps, context), refined = _b.refined, extra = _b.extra;
|
|
var def = parseEventDef(refined, extra, dragMeta.sourceId, dateSpan.allDay, context.options.forceEventDuration || Boolean(dragMeta.duration), context);
|
|
var start = dateSpan.range.start;
|
|
if (dateSpan.allDay && dragMeta.startTime) {
|
|
start = context.dateEnv.add(start, dragMeta.startTime);
|
|
}
|
|
var end = dragMeta.duration ? context.dateEnv.add(start, dragMeta.duration) : getDefaultEventEnd(dateSpan.allDay, start, context);
|
|
var instance = createEventInstance(def.defId, { start, end });
|
|
return { def, instance };
|
|
}
|
|
function getDragMetaFromEl(el) {
|
|
var str = getEmbeddedElData(el, "event");
|
|
var obj = str ? JSON.parse(str) : { create: false };
|
|
return parseDragMeta(obj);
|
|
}
|
|
config.dataAttrPrefix = "";
|
|
function getEmbeddedElData(el, name) {
|
|
var prefix = config.dataAttrPrefix;
|
|
var prefixedName = (prefix ? prefix + "-" : "") + name;
|
|
return el.getAttribute("data-" + prefixedName) || "";
|
|
}
|
|
var ExternalDraggable = function() {
|
|
function ExternalDraggable2(el, settings) {
|
|
var _this = this;
|
|
if (settings === void 0) {
|
|
settings = {};
|
|
}
|
|
this.handlePointerDown = function(ev) {
|
|
var dragging2 = _this.dragging;
|
|
var _a = _this.settings, minDistance = _a.minDistance, longPressDelay = _a.longPressDelay;
|
|
dragging2.minDistance = minDistance != null ? minDistance : ev.isTouch ? 0 : BASE_OPTION_DEFAULTS.eventDragMinDistance;
|
|
dragging2.delay = ev.isTouch ? longPressDelay != null ? longPressDelay : BASE_OPTION_DEFAULTS.longPressDelay : 0;
|
|
};
|
|
this.handleDragStart = function(ev) {
|
|
if (ev.isTouch && _this.dragging.delay && ev.subjectEl.classList.contains("fc-event")) {
|
|
_this.dragging.mirror.getMirrorEl().classList.add("fc-event-selected");
|
|
}
|
|
};
|
|
this.settings = settings;
|
|
var dragging = this.dragging = new FeaturefulElementDragging(el);
|
|
dragging.touchScrollAllowed = false;
|
|
if (settings.itemSelector != null) {
|
|
dragging.pointer.selector = settings.itemSelector;
|
|
}
|
|
if (settings.appendTo != null) {
|
|
dragging.mirror.parentNode = settings.appendTo;
|
|
}
|
|
dragging.emitter.on("pointerdown", this.handlePointerDown);
|
|
dragging.emitter.on("dragstart", this.handleDragStart);
|
|
new ExternalElementDragging(dragging, settings.eventData);
|
|
}
|
|
ExternalDraggable2.prototype.destroy = function() {
|
|
this.dragging.destroy();
|
|
};
|
|
return ExternalDraggable2;
|
|
}();
|
|
var InferredElementDragging = function(_super) {
|
|
__extends(InferredElementDragging2, _super);
|
|
function InferredElementDragging2(containerEl) {
|
|
var _this = _super.call(this, containerEl) || this;
|
|
_this.shouldIgnoreMove = false;
|
|
_this.mirrorSelector = "";
|
|
_this.currentMirrorEl = null;
|
|
_this.handlePointerDown = function(ev) {
|
|
_this.emitter.trigger("pointerdown", ev);
|
|
if (!_this.shouldIgnoreMove) {
|
|
_this.emitter.trigger("dragstart", ev);
|
|
}
|
|
};
|
|
_this.handlePointerMove = function(ev) {
|
|
if (!_this.shouldIgnoreMove) {
|
|
_this.emitter.trigger("dragmove", ev);
|
|
}
|
|
};
|
|
_this.handlePointerUp = function(ev) {
|
|
_this.emitter.trigger("pointerup", ev);
|
|
if (!_this.shouldIgnoreMove) {
|
|
_this.emitter.trigger("dragend", ev);
|
|
}
|
|
};
|
|
var pointer = _this.pointer = new PointerDragging(containerEl);
|
|
pointer.emitter.on("pointerdown", _this.handlePointerDown);
|
|
pointer.emitter.on("pointermove", _this.handlePointerMove);
|
|
pointer.emitter.on("pointerup", _this.handlePointerUp);
|
|
return _this;
|
|
}
|
|
InferredElementDragging2.prototype.destroy = function() {
|
|
this.pointer.destroy();
|
|
};
|
|
InferredElementDragging2.prototype.setIgnoreMove = function(bool) {
|
|
this.shouldIgnoreMove = bool;
|
|
};
|
|
InferredElementDragging2.prototype.setMirrorIsVisible = function(bool) {
|
|
if (bool) {
|
|
if (this.currentMirrorEl) {
|
|
this.currentMirrorEl.style.visibility = "";
|
|
this.currentMirrorEl = null;
|
|
}
|
|
} else {
|
|
var mirrorEl = this.mirrorSelector ? document.querySelector(this.mirrorSelector) : null;
|
|
if (mirrorEl) {
|
|
this.currentMirrorEl = mirrorEl;
|
|
mirrorEl.style.visibility = "hidden";
|
|
}
|
|
}
|
|
};
|
|
return InferredElementDragging2;
|
|
}(ElementDragging);
|
|
var ThirdPartyDraggable = function() {
|
|
function ThirdPartyDraggable2(containerOrSettings, settings) {
|
|
var containerEl = document;
|
|
if (containerOrSettings === document || containerOrSettings instanceof Element) {
|
|
containerEl = containerOrSettings;
|
|
settings = settings || {};
|
|
} else {
|
|
settings = containerOrSettings || {};
|
|
}
|
|
var dragging = this.dragging = new InferredElementDragging(containerEl);
|
|
if (typeof settings.itemSelector === "string") {
|
|
dragging.pointer.selector = settings.itemSelector;
|
|
} else if (containerEl === document) {
|
|
dragging.pointer.selector = "[data-event]";
|
|
}
|
|
if (typeof settings.mirrorSelector === "string") {
|
|
dragging.mirrorSelector = settings.mirrorSelector;
|
|
}
|
|
new ExternalElementDragging(dragging, settings.eventData);
|
|
}
|
|
ThirdPartyDraggable2.prototype.destroy = function() {
|
|
this.dragging.destroy();
|
|
};
|
|
return ThirdPartyDraggable2;
|
|
}();
|
|
var main4 = createPlugin({
|
|
componentInteractions: [DateClicking, DateSelecting, EventDragging, EventResizing],
|
|
calendarInteractions: [UnselectAuto],
|
|
elementDraggingImpl: FeaturefulElementDragging,
|
|
optionRefiners: OPTION_REFINERS3,
|
|
listenerRefiners: LISTENER_REFINERS
|
|
});
|
|
var main_default4 = main4;
|
|
|
|
// node_modules/@fullcalendar/google-calendar/main.js
|
|
var OPTION_REFINERS4 = {
|
|
googleCalendarApiKey: String
|
|
};
|
|
var EVENT_SOURCE_REFINERS2 = {
|
|
googleCalendarApiKey: String,
|
|
googleCalendarId: String,
|
|
googleCalendarApiBase: String,
|
|
extraParams: identity
|
|
};
|
|
var API_BASE = "https://www.googleapis.com/calendar/v3/calendars";
|
|
var eventSourceDef2 = {
|
|
parseMeta: function(refined) {
|
|
var googleCalendarId = refined.googleCalendarId;
|
|
if (!googleCalendarId && refined.url) {
|
|
googleCalendarId = parseGoogleCalendarId(refined.url);
|
|
}
|
|
if (googleCalendarId) {
|
|
return {
|
|
googleCalendarId,
|
|
googleCalendarApiKey: refined.googleCalendarApiKey,
|
|
googleCalendarApiBase: refined.googleCalendarApiBase,
|
|
extraParams: refined.extraParams
|
|
};
|
|
}
|
|
return null;
|
|
},
|
|
fetch: function(arg, onSuccess, onFailure) {
|
|
var _a = arg.context, dateEnv = _a.dateEnv, options = _a.options;
|
|
var meta = arg.eventSource.meta;
|
|
var apiKey = meta.googleCalendarApiKey || options.googleCalendarApiKey;
|
|
if (!apiKey) {
|
|
onFailure({
|
|
message: "Specify a googleCalendarApiKey. See http://fullcalendar.io/docs/google_calendar/"
|
|
});
|
|
} else {
|
|
var url = buildUrl(meta);
|
|
var extraParams = meta.extraParams;
|
|
var extraParamsObj = typeof extraParams === "function" ? extraParams() : extraParams;
|
|
var requestParams_1 = buildRequestParams2(arg.range, apiKey, extraParamsObj, dateEnv);
|
|
requestJson("GET", url, requestParams_1, function(body, xhr) {
|
|
if (body.error) {
|
|
onFailure({
|
|
message: "Google Calendar API: " + body.error.message,
|
|
errors: body.error.errors,
|
|
xhr
|
|
});
|
|
} else {
|
|
onSuccess({
|
|
rawEvents: gcalItemsToRawEventDefs(body.items, requestParams_1.timeZone),
|
|
xhr
|
|
});
|
|
}
|
|
}, function(message, xhr) {
|
|
onFailure({ message, xhr });
|
|
});
|
|
}
|
|
}
|
|
};
|
|
function parseGoogleCalendarId(url) {
|
|
var match;
|
|
if (/^[^/]+@([^/.]+\.)*(google|googlemail|gmail)\.com$/.test(url)) {
|
|
return url;
|
|
}
|
|
if ((match = /^https:\/\/www.googleapis.com\/calendar\/v3\/calendars\/([^/]*)/.exec(url)) || (match = /^https?:\/\/www.google.com\/calendar\/feeds\/([^/]*)/.exec(url))) {
|
|
return decodeURIComponent(match[1]);
|
|
}
|
|
return null;
|
|
}
|
|
function buildUrl(meta) {
|
|
var apiBase = meta.googleCalendarApiBase;
|
|
if (!apiBase) {
|
|
apiBase = API_BASE;
|
|
}
|
|
return apiBase + "/" + encodeURIComponent(meta.googleCalendarId) + "/events";
|
|
}
|
|
function buildRequestParams2(range, apiKey, extraParams, dateEnv) {
|
|
var params;
|
|
var startStr;
|
|
var endStr;
|
|
if (dateEnv.canComputeOffset) {
|
|
startStr = dateEnv.formatIso(range.start);
|
|
endStr = dateEnv.formatIso(range.end);
|
|
} else {
|
|
startStr = addDays(range.start, -1).toISOString();
|
|
endStr = addDays(range.end, 1).toISOString();
|
|
}
|
|
params = __assign(__assign({}, extraParams || {}), { key: apiKey, timeMin: startStr, timeMax: endStr, singleEvents: true, maxResults: 9999 });
|
|
if (dateEnv.timeZone !== "local") {
|
|
params.timeZone = dateEnv.timeZone;
|
|
}
|
|
return params;
|
|
}
|
|
function gcalItemsToRawEventDefs(items, gcalTimezone) {
|
|
return items.map(function(item) {
|
|
return gcalItemToRawEventDef(item, gcalTimezone);
|
|
});
|
|
}
|
|
function gcalItemToRawEventDef(item, gcalTimezone) {
|
|
var url = item.htmlLink || null;
|
|
if (url && gcalTimezone) {
|
|
url = injectQsComponent(url, "ctz=" + gcalTimezone);
|
|
}
|
|
return {
|
|
id: item.id,
|
|
title: item.summary,
|
|
start: item.start.dateTime || item.start.date,
|
|
end: item.end.dateTime || item.end.date,
|
|
url,
|
|
location: item.location,
|
|
description: item.description,
|
|
attachments: item.attachments || [],
|
|
extendedProps: (item.extendedProperties || {}).shared || {}
|
|
};
|
|
}
|
|
function injectQsComponent(url, component) {
|
|
return url.replace(/(\?.*?)?(#|$)/, function(whole, qs, hash) {
|
|
return (qs ? qs + "&" : "?") + component + hash;
|
|
});
|
|
}
|
|
var main5 = createPlugin({
|
|
eventSourceDefs: [eventSourceDef2],
|
|
optionRefiners: OPTION_REFINERS4,
|
|
eventSourceRefiners: EVENT_SOURCE_REFINERS2
|
|
});
|
|
var main_default5 = main5;
|
|
|
|
// node_modules/@fullcalendar/icalendar/main.js
|
|
var ICAL = __toModule(require_ical());
|
|
var IcalExpander = function() {
|
|
function IcalExpander3(opts) {
|
|
this.maxIterations = opts.maxIterations != null ? opts.maxIterations : 1e3;
|
|
this.skipInvalidDates = opts.skipInvalidDates != null ? opts.skipInvalidDates : false;
|
|
this.jCalData = ICAL.parse(opts.ics);
|
|
this.component = new ICAL.Component(this.jCalData);
|
|
this.events = this.component.getAllSubcomponents("vevent").map(function(vevent) {
|
|
return new ICAL.Event(vevent);
|
|
});
|
|
if (this.skipInvalidDates) {
|
|
this.events = this.events.filter(function(evt) {
|
|
try {
|
|
evt.startDate.toJSDate();
|
|
evt.endDate.toJSDate();
|
|
return true;
|
|
} catch (err) {
|
|
return false;
|
|
}
|
|
});
|
|
}
|
|
}
|
|
IcalExpander3.prototype.between = function(after, before) {
|
|
var _this = this;
|
|
function isEventWithinRange(startTime, endTime) {
|
|
return (!after || endTime >= after.getTime()) && (!before || startTime <= before.getTime());
|
|
}
|
|
function getTimes(eventOrOccurrence) {
|
|
var startTime = eventOrOccurrence.startDate.toJSDate().getTime();
|
|
var endTime = eventOrOccurrence.endDate.toJSDate().getTime();
|
|
if (eventOrOccurrence.endDate.isDate && endTime > startTime) {
|
|
endTime -= 1;
|
|
}
|
|
return { startTime, endTime };
|
|
}
|
|
var exceptions = [];
|
|
this.events.forEach(function(event) {
|
|
if (event.isRecurrenceException())
|
|
exceptions.push(event);
|
|
});
|
|
var ret = {
|
|
events: [],
|
|
occurrences: []
|
|
};
|
|
this.events.filter(function(e3) {
|
|
return !e3.isRecurrenceException();
|
|
}).forEach(function(event) {
|
|
var exdates = [];
|
|
event.component.getAllProperties("exdate").forEach(function(exdateProp) {
|
|
var exdate = exdateProp.getFirstValue();
|
|
exdates.push(exdate.toJSDate().getTime());
|
|
});
|
|
if (event.isRecurring()) {
|
|
var iterator = event.iterator();
|
|
var next = void 0;
|
|
var i3 = 0;
|
|
var _loop_1 = function() {
|
|
i3 += 1;
|
|
next = iterator.next();
|
|
if (next) {
|
|
var occurrence_1 = event.getOccurrenceDetails(next);
|
|
var _b = getTimes(occurrence_1), startTime_1 = _b.startTime, endTime_1 = _b.endTime;
|
|
var isOccurrenceExcluded = exdates.indexOf(startTime_1) !== -1;
|
|
var exception = exceptions.find(function(ex) {
|
|
return ex.uid === event.uid && ex.recurrenceId.toJSDate().getTime() === occurrence_1.startDate.toJSDate().getTime();
|
|
});
|
|
if (before && startTime_1 > before.getTime())
|
|
return "break";
|
|
if (isEventWithinRange(startTime_1, endTime_1)) {
|
|
if (exception) {
|
|
ret.events.push(exception);
|
|
} else if (!isOccurrenceExcluded) {
|
|
ret.occurrences.push(occurrence_1);
|
|
}
|
|
}
|
|
}
|
|
};
|
|
do {
|
|
var state_1 = _loop_1();
|
|
if (state_1 === "break")
|
|
break;
|
|
} while (next && (!_this.maxIterations || i3 < _this.maxIterations));
|
|
return;
|
|
}
|
|
var _a = getTimes(event), startTime = _a.startTime, endTime = _a.endTime;
|
|
if (isEventWithinRange(startTime, endTime))
|
|
ret.events.push(event);
|
|
});
|
|
return ret;
|
|
};
|
|
IcalExpander3.prototype.before = function(before) {
|
|
return this.between(void 0, before);
|
|
};
|
|
IcalExpander3.prototype.after = function(after) {
|
|
return this.between(after);
|
|
};
|
|
IcalExpander3.prototype.all = function() {
|
|
return this.between();
|
|
};
|
|
return IcalExpander3;
|
|
}();
|
|
var eventSourceDef3 = {
|
|
parseMeta: function(refined) {
|
|
if (refined.url && refined.format === "ics") {
|
|
return {
|
|
url: refined.url,
|
|
format: "ics"
|
|
};
|
|
}
|
|
return null;
|
|
},
|
|
fetch: function(arg, onSuccess, onFailure) {
|
|
var meta = arg.eventSource.meta;
|
|
var internalState = meta.internalState;
|
|
function handleICalEvents(errorMessage, iCalExpander, xhr) {
|
|
if (errorMessage) {
|
|
onFailure({ message: errorMessage, xhr });
|
|
} else {
|
|
onSuccess({ rawEvents: expandICalEvents(iCalExpander, arg.range), xhr });
|
|
}
|
|
}
|
|
if (!internalState || arg.isRefetch) {
|
|
internalState = meta.internalState = {
|
|
completed: false,
|
|
callbacks: [handleICalEvents],
|
|
errorMessage: "",
|
|
iCalExpander: null,
|
|
xhr: null
|
|
};
|
|
requestICal(meta.url, function(rawFeed, xhr) {
|
|
var iCalExpander = new IcalExpander({
|
|
ics: rawFeed,
|
|
skipInvalidDates: true
|
|
});
|
|
for (var _i = 0, _a = internalState.callbacks; _i < _a.length; _i++) {
|
|
var callback = _a[_i];
|
|
callback("", iCalExpander, xhr);
|
|
}
|
|
internalState.completed = true;
|
|
internalState.callbacks = [];
|
|
internalState.iCalExpander = iCalExpander;
|
|
internalState.xhr = xhr;
|
|
}, function(errorMessage, xhr) {
|
|
for (var _i = 0, _a = internalState.callbacks; _i < _a.length; _i++) {
|
|
var callback = _a[_i];
|
|
callback(errorMessage, null, xhr);
|
|
}
|
|
internalState.completed = true;
|
|
internalState.callbacks = [];
|
|
internalState.errorMessage = errorMessage;
|
|
internalState.xhr = xhr;
|
|
});
|
|
} else if (!internalState.completed) {
|
|
internalState.callbacks.push(handleICalEvents);
|
|
} else {
|
|
handleICalEvents(internalState.errorMessage, internalState.iCalExpander, internalState.xhr);
|
|
}
|
|
}
|
|
};
|
|
function requestICal(url, successCallback, failureCallback) {
|
|
var xhr = new XMLHttpRequest();
|
|
xhr.open("GET", url, true);
|
|
xhr.onload = function() {
|
|
if (xhr.status >= 200 && xhr.status < 400) {
|
|
successCallback(xhr.responseText, xhr);
|
|
} else {
|
|
failureCallback("Request failed", xhr);
|
|
}
|
|
};
|
|
xhr.onerror = function() {
|
|
return failureCallback("Request failed", xhr);
|
|
};
|
|
xhr.send(null);
|
|
}
|
|
function expandICalEvents(iCalExpander, range) {
|
|
var rangeStart = addDays(range.start, -1);
|
|
var rangeEnd = addDays(range.end, 1);
|
|
var iCalRes = iCalExpander.between(rangeStart, rangeEnd);
|
|
var expanded = [];
|
|
for (var _i = 0, _a = iCalRes.events; _i < _a.length; _i++) {
|
|
var iCalEvent = _a[_i];
|
|
expanded.push(__assign(__assign({}, buildNonDateProps(iCalEvent)), { start: iCalEvent.startDate.toString(), end: specifiesEnd(iCalEvent) && iCalEvent.endDate ? iCalEvent.endDate.toString() : null }));
|
|
}
|
|
for (var _b = 0, _c = iCalRes.occurrences; _b < _c.length; _b++) {
|
|
var iCalOccurence = _c[_b];
|
|
var iCalEvent = iCalOccurence.item;
|
|
expanded.push(__assign(__assign({}, buildNonDateProps(iCalEvent)), { start: iCalOccurence.startDate.toString(), end: specifiesEnd(iCalEvent) && iCalOccurence.endDate ? iCalOccurence.endDate.toString() : null }));
|
|
}
|
|
return expanded;
|
|
}
|
|
function buildNonDateProps(iCalEvent) {
|
|
return {
|
|
title: iCalEvent.summary,
|
|
url: extractEventUrl(iCalEvent),
|
|
extendedProps: {
|
|
location: iCalEvent.location,
|
|
organizer: iCalEvent.organizer,
|
|
description: iCalEvent.description
|
|
}
|
|
};
|
|
}
|
|
function extractEventUrl(iCalEvent) {
|
|
var urlProp = iCalEvent.component.getFirstProperty("url");
|
|
return urlProp ? urlProp.getFirstValue() : "";
|
|
}
|
|
function specifiesEnd(iCalEvent) {
|
|
return Boolean(iCalEvent.component.getFirstProperty("dtend")) || Boolean(iCalEvent.component.getFirstProperty("duration"));
|
|
}
|
|
var main6 = createPlugin({
|
|
eventSourceDefs: [eventSourceDef3]
|
|
});
|
|
var main_default6 = main6;
|
|
|
|
// src/calendar.ts
|
|
function renderCalendar(containerEl, eventSources, settings) {
|
|
const isMobile = window.innerWidth < 500;
|
|
const { eventClick, select, modifyEvent, eventMouseEnter } = settings || {};
|
|
const modifyEventCallback = modifyEvent && ((_0) => __async(this, [_0], function* ({
|
|
event,
|
|
oldEvent,
|
|
revert
|
|
}) {
|
|
const success = yield modifyEvent(event, oldEvent);
|
|
if (!success) {
|
|
revert();
|
|
}
|
|
}));
|
|
const cal = new Calendar(containerEl, {
|
|
plugins: [
|
|
main_default,
|
|
main_default2,
|
|
main_default3,
|
|
main_default4,
|
|
main_default5,
|
|
main_default6
|
|
],
|
|
googleCalendarApiKey: "AIzaSyDIiklFwJXaLWuT_4y6I9ZRVVsPuf4xGrk",
|
|
initialView: isMobile ? "timeGrid3Days" : "timeGridWeek",
|
|
nowIndicator: true,
|
|
scrollTimeReset: false,
|
|
headerToolbar: isMobile ? {
|
|
right: "today,prev,next",
|
|
left: "timeGrid3Days,timeGridDay,listWeek"
|
|
} : {
|
|
left: "prev,next today",
|
|
center: "title",
|
|
right: "dayGridMonth,timeGridWeek,timeGridDay,listWeek"
|
|
},
|
|
views: {
|
|
timeGridDay: {
|
|
type: "timeGrid",
|
|
duration: { days: 1 },
|
|
buttonText: isMobile ? "1" : "day"
|
|
},
|
|
timeGrid3Days: {
|
|
type: "timeGrid",
|
|
duration: { days: 3 },
|
|
buttonText: "3"
|
|
}
|
|
},
|
|
firstDay: settings == null ? void 0 : settings.firstDay,
|
|
eventSources,
|
|
eventClick,
|
|
selectable: select && true,
|
|
selectMirror: select && true,
|
|
select: select && ((info) => __async(this, null, function* () {
|
|
yield select(info.start, info.end, info.allDay);
|
|
info.view.calendar.unselect();
|
|
})),
|
|
editable: modifyEvent && true,
|
|
eventDrop: modifyEventCallback,
|
|
eventResize: modifyEventCallback,
|
|
eventMouseEnter
|
|
});
|
|
cal.render();
|
|
return cal;
|
|
}
|
|
|
|
// src/modal.ts
|
|
var import_obsidian3 = __toModule(require("obsidian"));
|
|
var React2 = __toModule(require_react());
|
|
var ReactDOM = __toModule(require_react_dom());
|
|
|
|
// src/components/EditEvent.tsx
|
|
var React = __toModule(require_react());
|
|
var import_react = __toModule(require_react());
|
|
function makeChangeListener(setState, fromString) {
|
|
return (e3) => setState(fromString(e3.target.value));
|
|
}
|
|
var DayChoice = ({ code, label, isSelected, onClick }) => /* @__PURE__ */ React.createElement("button", {
|
|
type: "button",
|
|
style: {
|
|
marginLeft: "0.25rem",
|
|
marginRight: "0.25rem",
|
|
padding: "0",
|
|
backgroundColor: isSelected ? "var(--interactive-accent)" : "var(--interactive-normal)",
|
|
color: isSelected ? "var(--text-on-accent)" : "var(--text-normal)",
|
|
borderStyle: "solid",
|
|
borderWidth: "1px",
|
|
borderRadius: "50%",
|
|
width: "25px",
|
|
height: "25px"
|
|
},
|
|
onClick: () => onClick(code)
|
|
}, /* @__PURE__ */ React.createElement("b", null, label[0]));
|
|
var DAY_MAP = {
|
|
U: "Sunday",
|
|
M: "Monday",
|
|
T: "Tuesday",
|
|
W: "Wednesday",
|
|
R: "Thursday",
|
|
F: "Friday",
|
|
S: "Saturday"
|
|
};
|
|
var DaySelect = ({
|
|
value: days,
|
|
onChange
|
|
}) => {
|
|
return /* @__PURE__ */ React.createElement("div", null, Object.entries(DAY_MAP).map(([code, label]) => /* @__PURE__ */ React.createElement(DayChoice, {
|
|
key: code,
|
|
code,
|
|
label,
|
|
isSelected: days.includes(code),
|
|
onClick: () => days.includes(code) ? onChange(days.filter((c3) => c3 !== code)) : onChange([code, ...days])
|
|
})));
|
|
};
|
|
var EditEvent = ({
|
|
initialEvent,
|
|
submit,
|
|
open,
|
|
deleteEvent,
|
|
calendars,
|
|
defaultCalendarIndex
|
|
}) => {
|
|
const [date, setDate] = (0, import_react.useState)(initialEvent ? initialEvent.type !== "recurring" ? initialEvent.date : initialEvent.startRecur || "" : "");
|
|
const [endDate, setEndDate] = (0, import_react.useState)(initialEvent && initialEvent.type === "single" ? initialEvent.endDate : void 0);
|
|
let initialStartTime = "";
|
|
let initialEndTime = "";
|
|
if (initialEvent && initialEvent.allDay === false) {
|
|
initialStartTime = initialEvent.startTime || "";
|
|
initialEndTime = initialEvent.endTime || "";
|
|
}
|
|
const [startTime, setStartTime] = (0, import_react.useState)(initialStartTime);
|
|
const [endTime, setEndTime] = (0, import_react.useState)(initialEndTime);
|
|
const [title, setTitle] = (0, import_react.useState)((initialEvent == null ? void 0 : initialEvent.title) || "");
|
|
const [isRecurring, setIsRecurring] = (0, import_react.useState)((initialEvent == null ? void 0 : initialEvent.type) === "recurring" || false);
|
|
const [endRecur, setEndRecur] = (0, import_react.useState)("");
|
|
const [daysOfWeek, setDaysOfWeek] = (0, import_react.useState)(((initialEvent == null ? void 0 : initialEvent.type) === "recurring" ? initialEvent.daysOfWeek : []) || []);
|
|
const [allDay, setAllDay] = (0, import_react.useState)((initialEvent == null ? void 0 : initialEvent.allDay) || false);
|
|
const [calendarIndex, setCalendarIndex] = (0, import_react.useState)(defaultCalendarIndex);
|
|
const titleRef = (0, import_react.useRef)(null);
|
|
(0, import_react.useEffect)(() => {
|
|
if (titleRef.current) {
|
|
titleRef.current.focus();
|
|
}
|
|
}, [titleRef]);
|
|
const handleSubmit = (e3) => __async(void 0, null, function* () {
|
|
e3.preventDefault();
|
|
yield submit(__spreadValues(__spreadValues(__spreadValues({}, { title }), allDay ? { allDay: true } : { allDay: false, startTime, endTime }), isRecurring ? {
|
|
type: "recurring",
|
|
daysOfWeek,
|
|
startRecur: date || void 0,
|
|
endRecur: endRecur || void 0
|
|
} : {
|
|
date,
|
|
endDate
|
|
}), calendarIndex);
|
|
});
|
|
return /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("div", null, /* @__PURE__ */ React.createElement("p", {
|
|
style: { float: "right" }
|
|
}, open && /* @__PURE__ */ React.createElement("button", {
|
|
onClick: open
|
|
}, "Open Note"))), /* @__PURE__ */ React.createElement("form", {
|
|
onSubmit: handleSubmit
|
|
}, /* @__PURE__ */ React.createElement("p", null, /* @__PURE__ */ React.createElement("input", {
|
|
ref: titleRef,
|
|
type: "text",
|
|
id: "title",
|
|
value: title,
|
|
placeholder: "Add title",
|
|
required: true,
|
|
onChange: makeChangeListener(setTitle, (x3) => x3)
|
|
})), /* @__PURE__ */ React.createElement("p", null, /* @__PURE__ */ React.createElement("select", {
|
|
id: "calendar",
|
|
value: calendarIndex,
|
|
onChange: makeChangeListener(setCalendarIndex, parseInt)
|
|
}, calendars.filter((cal) => cal.type === "local").map((cal, idx) => /* @__PURE__ */ React.createElement("option", {
|
|
key: idx,
|
|
value: idx
|
|
}, cal.directory)))), /* @__PURE__ */ React.createElement("p", null, !isRecurring && /* @__PURE__ */ React.createElement("input", {
|
|
type: "date",
|
|
id: "date",
|
|
value: date,
|
|
required: !isRecurring,
|
|
onChange: makeChangeListener(setDate, (x3) => x3)
|
|
}), allDay ? /* @__PURE__ */ React.createElement(React.Fragment, null) : /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement("input", {
|
|
type: "time",
|
|
id: "startTime",
|
|
value: startTime,
|
|
required: true,
|
|
onChange: makeChangeListener(setStartTime, (x3) => x3)
|
|
}), "-", /* @__PURE__ */ React.createElement("input", {
|
|
type: "time",
|
|
id: "endTime",
|
|
value: endTime,
|
|
required: true,
|
|
onChange: makeChangeListener(setEndTime, (x3) => x3)
|
|
}))), /* @__PURE__ */ React.createElement("p", null, /* @__PURE__ */ React.createElement("label", {
|
|
htmlFor: "allDay"
|
|
}, "All day event "), /* @__PURE__ */ React.createElement("input", {
|
|
id: "allDay",
|
|
checked: allDay,
|
|
onChange: (e3) => setAllDay(e3.target.checked),
|
|
type: "checkbox"
|
|
})), /* @__PURE__ */ React.createElement("p", null, /* @__PURE__ */ React.createElement("label", {
|
|
htmlFor: "recurring"
|
|
}, "Recurring Event "), /* @__PURE__ */ React.createElement("input", {
|
|
id: "recurring",
|
|
checked: isRecurring,
|
|
onChange: (e3) => setIsRecurring(e3.target.checked),
|
|
type: "checkbox"
|
|
})), isRecurring && /* @__PURE__ */ React.createElement(React.Fragment, null, /* @__PURE__ */ React.createElement(DaySelect, {
|
|
value: daysOfWeek,
|
|
onChange: setDaysOfWeek
|
|
}), /* @__PURE__ */ React.createElement("p", null, "Starts recurring", /* @__PURE__ */ React.createElement("input", {
|
|
type: "date",
|
|
id: "startDate",
|
|
value: date,
|
|
onChange: makeChangeListener(setDate, (x3) => x3)
|
|
}), "and stops recurring", /* @__PURE__ */ React.createElement("input", {
|
|
type: "date",
|
|
id: "endDate",
|
|
value: endRecur,
|
|
onChange: makeChangeListener(setEndRecur, (x3) => x3)
|
|
}))), /* @__PURE__ */ React.createElement("p", {
|
|
style: {
|
|
display: "flex",
|
|
justifyContent: "space-between",
|
|
width: "100%"
|
|
}
|
|
}, /* @__PURE__ */ React.createElement("button", {
|
|
type: "submit"
|
|
}, " Save Event "), /* @__PURE__ */ React.createElement("span", null, deleteEvent && /* @__PURE__ */ React.createElement("button", {
|
|
type: "button",
|
|
style: {
|
|
backgroundColor: "var(--interactive-normal)",
|
|
color: "var(--background-modifier-error)",
|
|
borderColor: "var(--background-modifier-error)",
|
|
borderWidth: "1px",
|
|
borderStyle: "solid"
|
|
},
|
|
onClick: deleteEvent
|
|
}, "Delete Event")))));
|
|
};
|
|
|
|
// src/frontmatter.ts
|
|
var import_luxon2 = __toModule(require_luxon());
|
|
var import_obsidian = __toModule(require("obsidian"));
|
|
|
|
// src/dateUtil.ts
|
|
var import_luxon = __toModule(require_luxon());
|
|
var parseTime = (time) => {
|
|
let parsed = import_luxon.DateTime.fromFormat(time, "h:mm a");
|
|
if (parsed.invalidReason) {
|
|
parsed = import_luxon.DateTime.fromFormat(time, "HH:mm");
|
|
}
|
|
return import_luxon.Duration.fromISOTime(parsed.toISOTime({
|
|
includeOffset: false,
|
|
includePrefix: false
|
|
}));
|
|
};
|
|
var normalizeTimeString = (time) => {
|
|
if (!time)
|
|
time = "";
|
|
return parseTime(time).toISOTime({
|
|
suppressMilliseconds: true,
|
|
includePrefix: false,
|
|
suppressSeconds: true
|
|
});
|
|
};
|
|
var add = (date, time) => {
|
|
let hours = time.hours;
|
|
let minutes = time.minutes;
|
|
return date.set({ hour: hours, minute: minutes });
|
|
};
|
|
var getTime2 = (date) => import_luxon.DateTime.fromJSDate(date).toISOTime({
|
|
suppressMilliseconds: true,
|
|
includeOffset: false,
|
|
suppressSeconds: true
|
|
});
|
|
var getDate = (date) => import_luxon.DateTime.fromJSDate(date).toISODate();
|
|
|
|
// src/frontmatter.ts
|
|
var DAYS = "UMTWRFS";
|
|
function dateEndpointsToFrontmatter(start, end, allDay) {
|
|
const date = getDate(start);
|
|
const endDate = getDate(end);
|
|
return __spreadValues({
|
|
type: "single",
|
|
date,
|
|
endDate: date !== endDate ? endDate : void 0,
|
|
allDay
|
|
}, allDay ? {} : {
|
|
startTime: getTime2(start),
|
|
endTime: getTime2(end)
|
|
});
|
|
}
|
|
function parseFrontmatter(id, frontmatter) {
|
|
let event = {
|
|
id,
|
|
title: frontmatter.title,
|
|
allDay: frontmatter.allDay
|
|
};
|
|
if (frontmatter.type === "recurring") {
|
|
event = __spreadProps(__spreadValues({}, event), {
|
|
daysOfWeek: frontmatter.daysOfWeek.map((c3) => DAYS.indexOf(c3)),
|
|
startRecur: frontmatter.startRecur,
|
|
endRecur: frontmatter.endRecur
|
|
});
|
|
if (!frontmatter.allDay) {
|
|
event = __spreadProps(__spreadValues({}, event), {
|
|
startTime: normalizeTimeString(frontmatter.startTime || ""),
|
|
endTime: frontmatter.endTime ? normalizeTimeString(frontmatter.endTime) : void 0
|
|
});
|
|
}
|
|
} else {
|
|
if (!frontmatter.allDay) {
|
|
event = __spreadProps(__spreadValues({}, event), {
|
|
start: add(import_luxon2.DateTime.fromISO(frontmatter.date), parseTime(frontmatter.startTime || "")).toISO(),
|
|
end: frontmatter.endTime ? add(import_luxon2.DateTime.fromISO(frontmatter.endDate || frontmatter.date), parseTime(frontmatter.endTime)).toISO() : void 0
|
|
});
|
|
} else {
|
|
event = __spreadProps(__spreadValues({}, event), {
|
|
start: frontmatter.date,
|
|
end: frontmatter.endDate || void 0
|
|
});
|
|
}
|
|
}
|
|
return event;
|
|
}
|
|
function eventApiToFrontmatter(event) {
|
|
const isRecurring = event.extendedProps.daysOfWeek !== void 0;
|
|
const startDate = getDate(event.start);
|
|
const endDate = getDate(event.end);
|
|
return __spreadValues(__spreadValues({
|
|
title: event.title
|
|
}, event.allDay ? { allDay: true } : {
|
|
allDay: false,
|
|
startTime: getTime2(event.start),
|
|
endTime: getTime2(event.end)
|
|
}), isRecurring ? {
|
|
type: "recurring",
|
|
daysOfWeek: event.extendedProps.daysOfWeek.map((i3) => DAYS[i3]),
|
|
startRecur: event.extendedProps.startRecur && getDate(event.extendedProps.startRecur),
|
|
endRecur: event.extendedProps.endRecur && getDate(event.extendedProps.endRecur)
|
|
} : __spreadValues({
|
|
type: "single",
|
|
date: startDate
|
|
}, startDate !== endDate ? { endDate } : {}));
|
|
}
|
|
var FRONTMATTER_SEPARATOR = "---";
|
|
function hasFrontmatter(page) {
|
|
return page.indexOf(FRONTMATTER_SEPARATOR) === 0 && page.slice(3).indexOf(FRONTMATTER_SEPARATOR) !== -1;
|
|
}
|
|
function extractFrontmatter(page) {
|
|
if (hasFrontmatter(page)) {
|
|
return page.split(FRONTMATTER_SEPARATOR)[1];
|
|
}
|
|
return null;
|
|
}
|
|
function extractPageContents(page) {
|
|
if (hasFrontmatter(page)) {
|
|
return page.split("---").slice(2).join("---");
|
|
} else {
|
|
return page;
|
|
}
|
|
}
|
|
function replaceFrontmatter(page, newFrontmatter) {
|
|
return `---
|
|
${newFrontmatter}---${extractPageContents(page)}`;
|
|
}
|
|
function stringifyYamlAtom(v3) {
|
|
let result = "";
|
|
if (Array.isArray(v3)) {
|
|
result += "[";
|
|
result += v3.map(stringifyYamlAtom).join(",");
|
|
result += "]";
|
|
} else {
|
|
result += `${v3}`;
|
|
}
|
|
return result;
|
|
}
|
|
function stringifyYamlLine(k2, v3) {
|
|
return `${String(k2)}: ${stringifyYamlAtom(v3)}`;
|
|
}
|
|
function modifyFrontmatter(vault, file, modifications) {
|
|
return __async(this, null, function* () {
|
|
var _a;
|
|
let page = yield vault.read(file);
|
|
const frontmatter = (_a = extractFrontmatter(page)) == null ? void 0 : _a.split("\n");
|
|
let newFrontmatter = [];
|
|
if (!frontmatter) {
|
|
newFrontmatter = Object.entries(modifications).filter(([k2, v3]) => v3 !== void 0).map(([k2, v3]) => stringifyYamlLine(k2, v3));
|
|
page = "\n" + page;
|
|
} else {
|
|
const linesAdded = new Set();
|
|
for (let i3 = 0; i3 < frontmatter.length; i3++) {
|
|
const line = frontmatter[i3];
|
|
const obj = (0, import_obsidian.parseYaml)(line);
|
|
if (!obj) {
|
|
continue;
|
|
}
|
|
const keys = Object.keys(obj);
|
|
if (keys.length !== 1) {
|
|
throw new Error("One YAML line parsed to multiple keys.");
|
|
}
|
|
const key = keys[0];
|
|
linesAdded.add(key);
|
|
const newVal = modifications[key];
|
|
if (newVal !== void 0) {
|
|
newFrontmatter.push(stringifyYamlLine(key, newVal));
|
|
} else {
|
|
newFrontmatter.push(line);
|
|
}
|
|
}
|
|
newFrontmatter.push(...Object.keys(modifications).filter((k2) => !linesAdded.has(k2)).filter((k2) => modifications[k2] !== void 0).map((k2) => stringifyYamlLine(k2, modifications[k2])));
|
|
}
|
|
const newPage = replaceFrontmatter(page, newFrontmatter.join("\n") + "\n");
|
|
yield vault.modify(file, newPage);
|
|
});
|
|
}
|
|
|
|
// src/models/Event.ts
|
|
function basenameFromEvent(event) {
|
|
switch (event.type) {
|
|
case "single":
|
|
case void 0:
|
|
return `${event.date} ${event.title}`;
|
|
case "recurring":
|
|
return `(Every ${event.daysOfWeek.join(",")}) ${event.title})`;
|
|
}
|
|
}
|
|
var _CalendarEvent = class {
|
|
constructor(cache, vault, data) {
|
|
this.cache = cache;
|
|
this.vault = vault;
|
|
this._data = data;
|
|
}
|
|
get idForCalendar() {
|
|
return this.PREFIX + _CalendarEvent.ID_SEPARATOR + this.identifier;
|
|
}
|
|
toCalendarEvent() {
|
|
return parseFrontmatter(this.idForCalendar, this.data);
|
|
}
|
|
get data() {
|
|
return __spreadValues({}, this._data);
|
|
}
|
|
addTo(calendar, source) {
|
|
calendar.addEvent(__spreadValues({
|
|
color: source.color || getComputedStyle(document.body).getPropertyValue("--interactive-accent"),
|
|
textColor: getComputedStyle(document.body).getPropertyValue("--text-on-accent")
|
|
}, this.toCalendarEvent()));
|
|
}
|
|
};
|
|
var CalendarEvent = _CalendarEvent;
|
|
CalendarEvent.ID_SEPARATOR = "::";
|
|
var EditableEvent = class extends CalendarEvent {
|
|
constructor(cache, vault, data) {
|
|
super(cache, vault, data);
|
|
}
|
|
get editable() {
|
|
return true;
|
|
}
|
|
};
|
|
var LocalEvent = class extends EditableEvent {
|
|
};
|
|
|
|
// src/models/NoteEvent.ts
|
|
var import_obsidian2 = __toModule(require("obsidian"));
|
|
|
|
// src/types.ts
|
|
var PLUGIN_SLUG = "full-calendar-plugin";
|
|
function validateFrontmatter(obj) {
|
|
if (obj === void 0) {
|
|
return null;
|
|
}
|
|
if (!obj.title) {
|
|
return null;
|
|
}
|
|
if (!obj.allDay && !obj.startTime) {
|
|
return null;
|
|
}
|
|
const timeInfo = obj.allDay ? { allDay: true } : {
|
|
allDay: false,
|
|
startTime: obj.startTime,
|
|
endTime: obj.endTime
|
|
};
|
|
if (obj.type === void 0 || obj.type === "single") {
|
|
if (!obj.date) {
|
|
return null;
|
|
}
|
|
return __spreadValues({
|
|
title: obj.title,
|
|
type: "single",
|
|
date: obj.date,
|
|
endDate: obj.endDate
|
|
}, timeInfo);
|
|
} else if (obj.type === "recurring") {
|
|
if (obj.daysOfWeek === void 0) {
|
|
return null;
|
|
}
|
|
return __spreadValues({
|
|
title: obj.title,
|
|
type: "recurring",
|
|
daysOfWeek: obj.daysOfWeek,
|
|
startRecur: obj.startRecur,
|
|
endRecur: obj.endRecur
|
|
}, timeInfo);
|
|
}
|
|
return null;
|
|
}
|
|
function makeDefaultPartialCalendarSource(type) {
|
|
if (type === "icloud") {
|
|
return {
|
|
type,
|
|
color: getComputedStyle(document.body).getPropertyValue("--interactive-accent").trim(),
|
|
url: "https://caldav.icloud.com"
|
|
};
|
|
}
|
|
return {
|
|
type,
|
|
color: getComputedStyle(document.body).getPropertyValue("--interactive-accent").trim()
|
|
};
|
|
}
|
|
var FCError = class {
|
|
constructor(message) {
|
|
this.message = message;
|
|
}
|
|
};
|
|
|
|
// src/models/NoteEvent.ts
|
|
var _NoteEvent = class extends LocalEvent {
|
|
get path() {
|
|
return `${this.directory}/${this.filename}`;
|
|
}
|
|
get identifier() {
|
|
return this.path;
|
|
}
|
|
get PREFIX() {
|
|
return _NoteEvent.ID_PREFIX;
|
|
}
|
|
constructor(cache, vault, data, { directory, filename }) {
|
|
super(cache, vault, data);
|
|
this.directory = directory;
|
|
this.filename = filename;
|
|
}
|
|
static create(cache, vault, directory, data) {
|
|
return __async(this, null, function* () {
|
|
const filename = `${directory}/${basenameFromEvent(data)}.md`;
|
|
if (vault.getAbstractFileByPath(filename)) {
|
|
throw new FCError(`File with name '${filename}' already exists`);
|
|
}
|
|
const file = yield vault.create(filename, "");
|
|
yield modifyFrontmatter(vault, file, data);
|
|
return new _NoteEvent(cache, vault, data, {
|
|
directory: file.parent.path,
|
|
filename: file.name
|
|
});
|
|
});
|
|
}
|
|
static upgrade(cache, vault, file, data) {
|
|
return __async(this, null, function* () {
|
|
yield modifyFrontmatter(vault, file, data);
|
|
return new _NoteEvent(cache, vault, data, {
|
|
directory: file.parent.path,
|
|
filename: file.name
|
|
});
|
|
});
|
|
}
|
|
static fromFile(cache, vault, file) {
|
|
var _a;
|
|
let data = validateFrontmatter((_a = cache.getFileCache(file)) == null ? void 0 : _a.frontmatter);
|
|
if (!data)
|
|
return null;
|
|
if (!data.title) {
|
|
data.title = file.basename;
|
|
}
|
|
return new _NoteEvent(cache, vault, data, {
|
|
directory: file.parent.path,
|
|
filename: file.name
|
|
});
|
|
}
|
|
static fromPath(cache, vault, path) {
|
|
const file = vault.getAbstractFileByPath(path);
|
|
if (!(file instanceof import_obsidian2.TFile)) {
|
|
throw new FCError(`File not found at path: ${path}`);
|
|
}
|
|
const event = this.fromFile(cache, vault, file);
|
|
if (!event) {
|
|
throw new FCError(`Could not construct event from file at path: ${path}`);
|
|
}
|
|
return event;
|
|
}
|
|
openIn(leaf) {
|
|
return __async(this, null, function* () {
|
|
yield leaf.openFile(this.file);
|
|
});
|
|
}
|
|
delete() {
|
|
return __async(this, null, function* () {
|
|
yield this.vault.delete(this.file);
|
|
});
|
|
}
|
|
get file() {
|
|
const file = this.vault.getAbstractFileByPath(this.path);
|
|
if (file instanceof import_obsidian2.TFile) {
|
|
return file;
|
|
} else {
|
|
throw new FCError(`Cannot find file for NoteEvent at path ${this.path}.`);
|
|
}
|
|
}
|
|
setDirectory(newDirectory) {
|
|
return __async(this, null, function* () {
|
|
if (this.directory.startsWith(newDirectory)) {
|
|
return;
|
|
}
|
|
let newPath = `${newDirectory}/${this.filename}`;
|
|
if (this.path === newPath) {
|
|
return;
|
|
}
|
|
if (this.vault.getAbstractFileByPath(newPath)) {
|
|
throw new FCError("Multiple events with the same name on the same date are not yet supported. Please rename your event before moving it.");
|
|
}
|
|
const file = this.file;
|
|
yield this.vault.rename(file, newPath);
|
|
this.directory = newDirectory;
|
|
});
|
|
}
|
|
setData(data) {
|
|
return __async(this, null, function* () {
|
|
let file = this.file;
|
|
let newFilename = `${basenameFromEvent(data)}.md`;
|
|
if (this.filename !== newFilename && this.vault.getAbstractFileByPath(`${file.parent.path}/${newFilename}`)) {
|
|
throw new FCError("Multiple events with the same name on the same date are not yet supported. Please rename your event before moving it.");
|
|
}
|
|
yield modifyFrontmatter(this.vault, file, data);
|
|
if (this.filename !== newFilename) {
|
|
this.filename = newFilename;
|
|
yield this.vault.rename(file, this.path);
|
|
}
|
|
this._data = data;
|
|
});
|
|
}
|
|
};
|
|
var NoteEvent = _NoteEvent;
|
|
NoteEvent.ID_PREFIX = "note";
|
|
|
|
// src/models/ICSEvent.ts
|
|
var _ICSEvent = class extends CalendarEvent {
|
|
constructor(cache, vault, data, id) {
|
|
super(cache, vault, data);
|
|
this.id = id;
|
|
}
|
|
get PREFIX() {
|
|
return _ICSEvent.ID_PREFIX;
|
|
}
|
|
get identifier() {
|
|
return this.id;
|
|
}
|
|
};
|
|
var ICSEvent = _ICSEvent;
|
|
ICSEvent.ID_PREFIX = "ics";
|
|
|
|
// src/models/CalDAVEvent.ts
|
|
var _CalDAVEvent = class extends CalendarEvent {
|
|
constructor(cache, vault, data, id) {
|
|
super(cache, vault, data);
|
|
this.id = id;
|
|
}
|
|
get PREFIX() {
|
|
return _CalDAVEvent.ID_PREFIX;
|
|
}
|
|
get identifier() {
|
|
return this.id;
|
|
}
|
|
};
|
|
var CalDAVEvent = _CalDAVEvent;
|
|
CalDAVEvent.ID_PREFIX = "caldav";
|
|
|
|
// src/models/index.ts
|
|
function eventFromCalendarId(cache, vault, id) {
|
|
return __async(this, null, function* () {
|
|
const [prefix, ...rest] = id.split("::");
|
|
const info = rest.join("::");
|
|
switch (prefix) {
|
|
case ICSEvent.ID_PREFIX:
|
|
case CalDAVEvent.ID_PREFIX:
|
|
throw new FCError("Cannot create instance of ICS event given its ID.");
|
|
case NoteEvent.ID_PREFIX:
|
|
return NoteEvent.fromPath(cache, vault, info);
|
|
}
|
|
});
|
|
}
|
|
|
|
// src/modal.ts
|
|
var EventModal = class extends import_obsidian3.Modal {
|
|
constructor(app, plugin, calendar, event) {
|
|
super(app);
|
|
this.plugin = plugin;
|
|
this.data = event;
|
|
this.calendar = calendar;
|
|
}
|
|
editInModal(input) {
|
|
return __async(this, null, function* () {
|
|
let frontmatter = null;
|
|
if (input instanceof EventApi) {
|
|
const event = yield eventFromCalendarId(this.app.metadataCache, this.app.vault, input.id);
|
|
if (event) {
|
|
this.data = event.data;
|
|
this.event = event;
|
|
this.open();
|
|
} else {
|
|
new import_obsidian3.Notice("Full Calendar: No frontmatter to edit for selected event.");
|
|
console.warn("Full Calendar: No frontmatter to edit for selected event.");
|
|
}
|
|
} else if (input instanceof import_obsidian3.TFile) {
|
|
const e3 = NoteEvent.fromFile(this.app.metadataCache, this.app.vault, input);
|
|
frontmatter = e3 == null ? void 0 : e3.data;
|
|
this.file = input;
|
|
this.data = frontmatter || { title: input.basename };
|
|
this.event = e3 || void 0;
|
|
this.open();
|
|
}
|
|
});
|
|
}
|
|
onOpen() {
|
|
return __async(this, null, function* () {
|
|
const { contentEl } = this;
|
|
yield this.plugin.loadSettings();
|
|
ReactDOM.render(React2.createElement(EditEvent, {
|
|
initialEvent: this.data,
|
|
submit: (data, calendarIndex) => __async(this, null, function* () {
|
|
const source = this.plugin.settings.calendarSources.filter((s3) => s3.type === "local")[calendarIndex];
|
|
if (source.type !== "local") {
|
|
new import_obsidian3.Notice("Sorry, remote sync is currently read-only.");
|
|
this.close();
|
|
return;
|
|
}
|
|
const directory = source.directory;
|
|
try {
|
|
if (this.file && !this.event) {
|
|
NoteEvent.upgrade(this.app.metadataCache, this.app.vault, this.file, data);
|
|
} else if (!this.event) {
|
|
NoteEvent.create(this.app.metadataCache, this.app.vault, directory, data);
|
|
} else {
|
|
if (this.event instanceof EditableEvent) {
|
|
yield this.event.setData(data);
|
|
if (this.event instanceof NoteEvent) {
|
|
yield this.event.setDirectory(directory);
|
|
}
|
|
}
|
|
}
|
|
} catch (e3) {
|
|
new import_obsidian3.Notice(e3.message);
|
|
} finally {
|
|
this.close();
|
|
}
|
|
}),
|
|
defaultCalendarIndex: this.plugin.settings.defaultCalendar,
|
|
calendars: this.plugin.settings.calendarSources,
|
|
open: this.event instanceof LocalEvent ? () => __async(this, null, function* () {
|
|
if (this.event instanceof LocalEvent) {
|
|
let leaf = this.app.workspace.getMostRecentLeaf();
|
|
yield this.event.openIn(leaf);
|
|
this.close();
|
|
}
|
|
}) : void 0,
|
|
deleteEvent: this.event instanceof LocalEvent ? () => __async(this, null, function* () {
|
|
if (this.event instanceof LocalEvent) {
|
|
yield this.event.delete();
|
|
this.close();
|
|
}
|
|
}) : void 0
|
|
}), contentEl);
|
|
});
|
|
}
|
|
onClose() {
|
|
const { contentEl } = this;
|
|
ReactDOM.unmountComponentAtNode(contentEl);
|
|
}
|
|
};
|
|
var ReactModal = class extends import_obsidian3.Modal {
|
|
constructor(app, onOpenCallback) {
|
|
super(app);
|
|
this.onOpenCallback = onOpenCallback;
|
|
}
|
|
onOpen() {
|
|
return __async(this, null, function* () {
|
|
const { contentEl } = this;
|
|
ReactDOM.render(yield this.onOpenCallback(), contentEl);
|
|
});
|
|
}
|
|
onClose() {
|
|
const { contentEl } = this;
|
|
ReactDOM.unmountComponentAtNode(contentEl);
|
|
}
|
|
};
|
|
|
|
// src/models/EventSource.ts
|
|
var import_obsidian5 = __toModule(require("obsidian"));
|
|
|
|
// vendor/fullcalendar-ical/ical-expander/IcalExpander.js
|
|
var ICAL2 = __toModule(require_ical());
|
|
var IcalExpander2 = class {
|
|
constructor(opts) {
|
|
this.maxIterations = opts.maxIterations != null ? opts.maxIterations : 1e3;
|
|
this.skipInvalidDates = opts.skipInvalidDates != null ? opts.skipInvalidDates : false;
|
|
this.jCalData = ICAL2.parse(opts.ics);
|
|
this.component = new ICAL2.Component(this.jCalData);
|
|
this.events = this.component.getAllSubcomponents("vevent").map((vevent) => new ICAL2.Event(vevent));
|
|
if (this.skipInvalidDates) {
|
|
this.events = this.events.filter((evt) => {
|
|
try {
|
|
evt.startDate.toJSDate();
|
|
evt.endDate.toJSDate();
|
|
return true;
|
|
} catch (err) {
|
|
return false;
|
|
}
|
|
});
|
|
}
|
|
}
|
|
between(after, before) {
|
|
function isEventWithinRange(startTime, endTime) {
|
|
return (!after || endTime >= after.getTime()) && (!before || startTime <= before.getTime());
|
|
}
|
|
function getTimes(eventOrOccurrence) {
|
|
const startTime = eventOrOccurrence.startDate.toJSDate().getTime();
|
|
let endTime = eventOrOccurrence.endDate.toJSDate().getTime();
|
|
if (eventOrOccurrence.endDate.isDate && endTime > startTime) {
|
|
endTime -= 1;
|
|
}
|
|
return { startTime, endTime };
|
|
}
|
|
const exceptions = [];
|
|
this.events.forEach((event) => {
|
|
if (event.isRecurrenceException())
|
|
exceptions.push(event);
|
|
});
|
|
const ret = {
|
|
events: [],
|
|
occurrences: []
|
|
};
|
|
this.events.filter((e3) => !e3.isRecurrenceException()).forEach((event) => {
|
|
const exdates = [];
|
|
event.component.getAllProperties("exdate").forEach((exdateProp) => {
|
|
const exdate = exdateProp.getFirstValue();
|
|
exdates.push(exdate.toJSDate().getTime());
|
|
});
|
|
if (event.isRecurring()) {
|
|
const iterator = event.iterator();
|
|
let next;
|
|
let i3 = 0;
|
|
do {
|
|
i3 += 1;
|
|
next = iterator.next();
|
|
if (next) {
|
|
const occurrence = event.getOccurrenceDetails(next);
|
|
const { startTime: startTime2, endTime: endTime2 } = getTimes(occurrence);
|
|
const isOccurrenceExcluded = exdates.indexOf(startTime2) !== -1;
|
|
const exception = exceptions.find((ex) => ex.uid === event.uid && ex.recurrenceId.toJSDate().getTime() === occurrence.startDate.toJSDate().getTime());
|
|
if (before && startTime2 > before.getTime())
|
|
break;
|
|
if (isEventWithinRange(startTime2, endTime2)) {
|
|
if (exception) {
|
|
ret.events.push(exception);
|
|
} else if (!isOccurrenceExcluded) {
|
|
ret.occurrences.push(occurrence);
|
|
}
|
|
}
|
|
}
|
|
} while (next && (!this.maxIterations || i3 < this.maxIterations));
|
|
return;
|
|
}
|
|
const { startTime, endTime } = getTimes(event);
|
|
if (isEventWithinRange(startTime, endTime))
|
|
ret.events.push(event);
|
|
});
|
|
return ret;
|
|
}
|
|
before(before) {
|
|
return this.between(void 0, before);
|
|
}
|
|
after(after) {
|
|
return this.between(after);
|
|
}
|
|
all() {
|
|
return this.between();
|
|
}
|
|
};
|
|
|
|
// vendor/fullcalendar-ical/icalendar.ts
|
|
function makeICalExpander(text) {
|
|
return new IcalExpander2({
|
|
ics: text,
|
|
skipInvalidDates: true
|
|
});
|
|
}
|
|
function expandICalEvents2(iCalExpander, range) {
|
|
let rangeStart = addDays(range.start, -1);
|
|
let rangeEnd = addDays(range.end, 1);
|
|
let iCalRes = iCalExpander.between(rangeStart, rangeEnd);
|
|
let expanded = [];
|
|
for (let iCalEvent of iCalRes.events) {
|
|
expanded.push(__spreadProps(__spreadValues({}, buildNonDateProps2(iCalEvent)), {
|
|
start: iCalEvent.startDate.toString(),
|
|
end: specifiesEnd2(iCalEvent) && iCalEvent.endDate ? iCalEvent.endDate.toString() : null
|
|
}));
|
|
}
|
|
for (let iCalOccurence of iCalRes.occurrences) {
|
|
let iCalEvent = iCalOccurence.item;
|
|
expanded.push(__spreadProps(__spreadValues({}, buildNonDateProps2(iCalEvent)), {
|
|
start: iCalOccurence.startDate.toString(),
|
|
end: specifiesEnd2(iCalEvent) && iCalOccurence.endDate ? iCalOccurence.endDate.toString() : null
|
|
}));
|
|
}
|
|
return expanded;
|
|
}
|
|
function buildNonDateProps2(iCalEvent) {
|
|
return {
|
|
title: iCalEvent.summary,
|
|
url: extractEventUrl2(iCalEvent),
|
|
extendedProps: {
|
|
location: iCalEvent.location,
|
|
organizer: iCalEvent.organizer,
|
|
description: iCalEvent.description
|
|
}
|
|
};
|
|
}
|
|
function extractEventUrl2(iCalEvent) {
|
|
let urlProp = iCalEvent.component.getFirstProperty("url");
|
|
return urlProp ? urlProp.getFirstValue() : "";
|
|
}
|
|
function specifiesEnd2(iCalEvent) {
|
|
return Boolean(iCalEvent.component.getFirstProperty("dtend")) || Boolean(iCalEvent.component.getFirstProperty("duration"));
|
|
}
|
|
|
|
// src/models/EventSource.ts
|
|
var import_color = __toModule(require_color());
|
|
var dav = __toModule(require_dav());
|
|
|
|
// src/transport.ts
|
|
var import_co = __toModule(require_co());
|
|
var import_dav = __toModule(require_dav());
|
|
var import_obsidian4 = __toModule(require("obsidian"));
|
|
var RequestBridge = class {
|
|
constructor(credentials) {
|
|
this.headers = {};
|
|
if (credentials) {
|
|
this.setRequestHeader("Authorization", "Basic " + this.encode(credentials));
|
|
}
|
|
}
|
|
encode(credentials) {
|
|
return window.btoa(credentials.username + ":" + credentials.password);
|
|
}
|
|
setRequestHeader(header, value) {
|
|
if (header.toLowerCase() == "content-type") {
|
|
this.contentType = value.toString();
|
|
} else {
|
|
this.headers[header] = value.toString();
|
|
}
|
|
}
|
|
};
|
|
var Basic = class extends import_dav.transport.Transport {
|
|
constructor(credentials) {
|
|
super(credentials);
|
|
}
|
|
send(request3, url, options) {
|
|
return (0, import_co.co)(function* () {
|
|
let sandbox = options && options.sandbox;
|
|
let transformRequest = request3.transformRequest;
|
|
let transformResponse = request3.transformResponse;
|
|
let onerror = request3.onerror;
|
|
let requestBridge = new RequestBridge(this.credentials);
|
|
if (sandbox)
|
|
sandbox.add(requestBridge);
|
|
if (transformRequest)
|
|
transformRequest(requestBridge);
|
|
let result;
|
|
try {
|
|
let response = (0, import_obsidian4.request)({
|
|
url,
|
|
method: request3.method,
|
|
contentType: requestBridge.contentType,
|
|
body: request3.requestData,
|
|
headers: requestBridge.headers
|
|
});
|
|
requestBridge.responseText = yield Promise.resolve(response);
|
|
result = transformResponse ? transformResponse(requestBridge) : requestBridge.responseText;
|
|
} catch (error) {
|
|
if (onerror)
|
|
onerror(error);
|
|
throw error;
|
|
}
|
|
return result;
|
|
}.bind(this));
|
|
}
|
|
};
|
|
|
|
// src/models/EventSource.ts
|
|
var EventSource = class {
|
|
};
|
|
var NoteSource = class extends EventSource {
|
|
constructor(vault, cache, info) {
|
|
super();
|
|
this.vault = vault;
|
|
this.cache = cache;
|
|
this.info = info;
|
|
}
|
|
getEventInputsFromPath(recursive, path) {
|
|
return __async(this, null, function* () {
|
|
const eventFolder = this.vault.getAbstractFileByPath(path || this.info.directory);
|
|
if (!(eventFolder instanceof import_obsidian5.TFolder)) {
|
|
return new FCError("Directory");
|
|
}
|
|
let events = [];
|
|
for (let file of eventFolder.children) {
|
|
if (file instanceof import_obsidian5.TFile) {
|
|
let event = NoteEvent.fromFile(this.cache, this.vault, file);
|
|
if (event) {
|
|
events.push(event.toCalendarEvent());
|
|
}
|
|
} else if (recursive) {
|
|
const childEvents = yield this.getEventInputsFromPath(recursive, file.path);
|
|
if (childEvents instanceof FCError) {
|
|
return childEvents;
|
|
}
|
|
events.push(...childEvents);
|
|
}
|
|
}
|
|
return events;
|
|
});
|
|
}
|
|
toApi(recursive = false) {
|
|
return __async(this, null, function* () {
|
|
const events = yield this.getEventInputsFromPath(recursive);
|
|
if (events instanceof FCError) {
|
|
return events;
|
|
}
|
|
return {
|
|
events,
|
|
textColor: getComputedStyle(document.body).getPropertyValue("--text-on-accent"),
|
|
color: this.info.color || getComputedStyle(document.body).getPropertyValue("--interactive-accent")
|
|
};
|
|
});
|
|
}
|
|
};
|
|
var IcsSource = class extends EventSource {
|
|
constructor(info) {
|
|
super();
|
|
this.info = info;
|
|
}
|
|
toApi() {
|
|
return __async(this, null, function* () {
|
|
let url = this.info.url;
|
|
if (url.startsWith("webcal")) {
|
|
url = "https" + url.slice("webcal".length);
|
|
}
|
|
let expander = null;
|
|
const getExpander = () => __async(this, null, function* () {
|
|
if (expander !== null) {
|
|
return expander;
|
|
}
|
|
try {
|
|
let text = yield (0, import_obsidian5.request)({
|
|
url,
|
|
method: "GET"
|
|
});
|
|
expander = makeICalExpander(text);
|
|
return expander;
|
|
} catch (e3) {
|
|
console.error(`Error loading calendar from ${url}`);
|
|
console.error(e3);
|
|
return new FCError(`There was an error loading a calendar. Check the console for full details.`);
|
|
}
|
|
});
|
|
return {
|
|
events: function(_0) {
|
|
return __async(this, arguments, function* ({ start, end }) {
|
|
const ical = yield getExpander();
|
|
if (ical instanceof FCError) {
|
|
throw new Error("Could not get calendar: " + ical.message);
|
|
}
|
|
const events = expandICalEvents2(ical, {
|
|
start,
|
|
end
|
|
});
|
|
return events;
|
|
});
|
|
},
|
|
editable: false,
|
|
textColor: getComputedStyle(document.body).getPropertyValue("--text-on-accent"),
|
|
color: this.info.color || getComputedStyle(document.body).getPropertyValue("--interactive-accent")
|
|
};
|
|
});
|
|
}
|
|
};
|
|
var RemoteSource = class extends EventSource {
|
|
constructor(info) {
|
|
super();
|
|
this.info = info;
|
|
}
|
|
importCalendars() {
|
|
return __async(this, null, function* () {
|
|
try {
|
|
let xhr = new Basic(new dav.Credentials({
|
|
username: this.info.username,
|
|
password: this.info.password
|
|
}));
|
|
let account = yield dav.createAccount({
|
|
xhr,
|
|
server: this.info.url,
|
|
loadObjects: false,
|
|
loadCollections: true
|
|
});
|
|
let colorRequest = dav.request.propfind({
|
|
props: [
|
|
{ name: "calendar-color", namespace: dav.ns.CALDAV_APPLE }
|
|
],
|
|
depth: "0"
|
|
});
|
|
return (yield Promise.all(account.calendars.map((calendar) => __async(this, null, function* () {
|
|
var _a;
|
|
if (!calendar.components.includes("VEVENT")) {
|
|
return null;
|
|
}
|
|
let colorResponse = yield xhr.send(colorRequest, calendar.url);
|
|
let color = (_a = colorResponse[0].props) == null ? void 0 : _a.calendarColor;
|
|
return __spreadProps(__spreadValues({}, this.info), {
|
|
type: "caldav",
|
|
name: calendar.displayName,
|
|
homeUrl: calendar.url,
|
|
color: color ? (0, import_color.default)(color).hex() : this.info.color
|
|
});
|
|
})))).filter((source) => source != null);
|
|
} catch (e3) {
|
|
console.error(`Error importing calendars from ${this.info.url}`);
|
|
console.error(e3);
|
|
return new FCError(`There was an error loading a calendar. Check the console for full details.`);
|
|
}
|
|
});
|
|
}
|
|
toApi() {
|
|
return __async(this, null, function* () {
|
|
let expanders = [];
|
|
const getExpanders = () => __async(this, null, function* () {
|
|
if (expanders.length) {
|
|
return expanders;
|
|
}
|
|
try {
|
|
let xhr = new Basic(new dav.Credentials({
|
|
username: this.info.username,
|
|
password: this.info.password
|
|
}));
|
|
let account = yield dav.createAccount({
|
|
xhr,
|
|
server: this.info.url
|
|
});
|
|
let calendar = account.calendars.find((calendar2) => calendar2.url === this.info.homeUrl);
|
|
if (!calendar) {
|
|
return [
|
|
new FCError(`There was an error loading a calendar event. Check the console for full details.`)
|
|
];
|
|
}
|
|
let events = yield dav.listCalendarObjects(calendar, {
|
|
xhr
|
|
});
|
|
expanders = events.map((vevent) => {
|
|
try {
|
|
return (vevent == null ? void 0 : vevent.calendarData) ? makeICalExpander(vevent.calendarData) : null;
|
|
} catch (e3) {
|
|
console.error("Unable to parse calendar");
|
|
console.error(e3);
|
|
new FCError(`There was an error loading a calendar event. Check the console for full details.`);
|
|
}
|
|
}).filter((expander) => !!expander);
|
|
return expanders;
|
|
} catch (e3) {
|
|
console.error(`Error loading calendar from ${this.info.url}`);
|
|
console.error(e3);
|
|
return [
|
|
new FCError(`There was an error loading a calendar. Check the console for full details.`)
|
|
];
|
|
}
|
|
});
|
|
return {
|
|
events: function(_0) {
|
|
return __async(this, arguments, function* ({ start, end }) {
|
|
const icals = yield getExpanders();
|
|
const events = icals.flatMap((ical) => {
|
|
if (ical instanceof FCError) {
|
|
console.error("Unable to parse calendar");
|
|
console.error(ical);
|
|
return null;
|
|
} else {
|
|
return expandICalEvents2(ical, {
|
|
start,
|
|
end
|
|
});
|
|
}
|
|
}).filter((e3) => !!e3);
|
|
return events;
|
|
});
|
|
},
|
|
editable: false,
|
|
textColor: getComputedStyle(document.body).getPropertyValue("--text-on-accent"),
|
|
color: this.info.color || getComputedStyle(document.body).getPropertyValue("--interactive-accent")
|
|
};
|
|
});
|
|
}
|
|
};
|
|
|
|
// src/settings.ts
|
|
var import_obsidian6 = __toModule(require("obsidian"));
|
|
|
|
// src/components/CalendarSetting.tsx
|
|
var React3 = __toModule(require_react());
|
|
function DirectorySetting({
|
|
source
|
|
}) {
|
|
let sourceWithDirectory = source;
|
|
return /* @__PURE__ */ React3.createElement("div", {
|
|
className: "setting-item-control"
|
|
}, /* @__PURE__ */ React3.createElement("input", {
|
|
disabled: true,
|
|
type: "text",
|
|
value: sourceWithDirectory.directory,
|
|
style: {
|
|
width: "100%",
|
|
marginLeft: 4,
|
|
marginRight: 4
|
|
}
|
|
}));
|
|
}
|
|
function UrlSetting({
|
|
source
|
|
}) {
|
|
let sourceWithUrl = source;
|
|
return /* @__PURE__ */ React3.createElement("div", {
|
|
className: "setting-item-control"
|
|
}, /* @__PURE__ */ React3.createElement("input", {
|
|
disabled: true,
|
|
type: "text",
|
|
value: sourceWithUrl.url,
|
|
style: {
|
|
width: "100%",
|
|
marginLeft: 4,
|
|
marginRight: 4
|
|
}
|
|
}));
|
|
}
|
|
function NameSetting({
|
|
source
|
|
}) {
|
|
let sourceWithName = source;
|
|
return /* @__PURE__ */ React3.createElement("div", {
|
|
className: "setting-item-control"
|
|
}, /* @__PURE__ */ React3.createElement("input", {
|
|
disabled: true,
|
|
type: "text",
|
|
value: sourceWithName.name,
|
|
style: {
|
|
width: "100%",
|
|
marginLeft: 4,
|
|
marginRight: 4
|
|
}
|
|
}));
|
|
}
|
|
function Username({
|
|
source
|
|
}) {
|
|
let sourceWithUsername = source;
|
|
return /* @__PURE__ */ React3.createElement("div", {
|
|
className: "setting-item-control"
|
|
}, /* @__PURE__ */ React3.createElement("input", {
|
|
disabled: true,
|
|
type: "text",
|
|
value: sourceWithUsername.username,
|
|
style: {
|
|
width: "100%",
|
|
marginLeft: 4,
|
|
marginRight: 4
|
|
}
|
|
}));
|
|
}
|
|
var CalendarSettingRow = ({
|
|
setting,
|
|
onColorChange,
|
|
deleteCalendar
|
|
}) => {
|
|
const isCalDAV = setting.type === "caldav" || setting.type === "icloud";
|
|
return /* @__PURE__ */ React3.createElement("div", {
|
|
className: "setting-item"
|
|
}, /* @__PURE__ */ React3.createElement("button", {
|
|
type: "button",
|
|
onClick: deleteCalendar,
|
|
style: { maxWidth: "15%" }
|
|
}, "\u2715"), setting.type === "local" ? /* @__PURE__ */ React3.createElement(DirectorySetting, {
|
|
source: setting
|
|
}) : /* @__PURE__ */ React3.createElement(UrlSetting, {
|
|
source: setting
|
|
}), isCalDAV && /* @__PURE__ */ React3.createElement(NameSetting, {
|
|
source: setting
|
|
}), isCalDAV && /* @__PURE__ */ React3.createElement(Username, {
|
|
source: setting
|
|
}), /* @__PURE__ */ React3.createElement("input", {
|
|
style: { maxWidth: "25%", minWidth: "3rem" },
|
|
type: "color",
|
|
value: setting.color,
|
|
onChange: (e3) => onColorChange(e3.target.value)
|
|
}));
|
|
};
|
|
var CalendarSettings = class extends React3.Component {
|
|
constructor(props) {
|
|
super(props);
|
|
this.state = { sources: props.sources, dirty: false };
|
|
}
|
|
addSource(source) {
|
|
this.setState((state, props) => ({
|
|
sources: [...state.sources, source],
|
|
dirty: true
|
|
}));
|
|
}
|
|
render() {
|
|
return /* @__PURE__ */ React3.createElement("div", {
|
|
style: { width: "100%" }
|
|
}, this.state.sources.map((s3, idx) => /* @__PURE__ */ React3.createElement(CalendarSettingRow, {
|
|
key: idx,
|
|
setting: s3,
|
|
onColorChange: (color) => this.setState((state, props) => ({
|
|
sources: [
|
|
...state.sources.slice(0, idx),
|
|
__spreadProps(__spreadValues({}, state.sources[idx]), { color }),
|
|
...state.sources.slice(idx + 1)
|
|
],
|
|
dirty: true
|
|
})),
|
|
deleteCalendar: () => this.setState((state, props) => ({
|
|
sources: [
|
|
...state.sources.slice(0, idx),
|
|
...state.sources.slice(idx + 1)
|
|
],
|
|
dirty: true
|
|
}))
|
|
})), /* @__PURE__ */ React3.createElement("div", {
|
|
className: "setting-item-control"
|
|
}, this.state.dirty && /* @__PURE__ */ React3.createElement("button", {
|
|
onClick: () => {
|
|
this.props.submit(this.state.sources.map((elt) => elt));
|
|
this.setState({ dirty: false });
|
|
},
|
|
style: {
|
|
backgroundColor: this.state.dirty ? "var(--interactive-accent)" : void 0,
|
|
color: this.state.dirty ? "var(--text-on-accent)" : void 0
|
|
}
|
|
}, this.state.dirty ? "Save" : "Settings Saved")));
|
|
}
|
|
};
|
|
|
|
// src/components/AddCalendarSource.tsx
|
|
var React4 = __toModule(require_react());
|
|
var import_react2 = __toModule(require_react());
|
|
function DirectorySelect({
|
|
source,
|
|
changeListener,
|
|
directories
|
|
}) {
|
|
const dirOptions = [...directories];
|
|
dirOptions.sort();
|
|
let sourceWithDirectory = source;
|
|
return /* @__PURE__ */ React4.createElement("div", {
|
|
className: "setting-item"
|
|
}, /* @__PURE__ */ React4.createElement("div", {
|
|
className: "setting-item-info"
|
|
}, /* @__PURE__ */ React4.createElement("div", {
|
|
className: "setting-item-name"
|
|
}, "Directory"), /* @__PURE__ */ React4.createElement("div", {
|
|
className: "setting-item-description"
|
|
}, "Directory to store events")), /* @__PURE__ */ React4.createElement("div", {
|
|
className: "setting-item-control"
|
|
}, /* @__PURE__ */ React4.createElement("select", {
|
|
required: true,
|
|
value: sourceWithDirectory.directory || "",
|
|
onChange: changeListener((x3) => __spreadProps(__spreadValues({}, sourceWithDirectory), {
|
|
directory: x3
|
|
}))
|
|
}, /* @__PURE__ */ React4.createElement("option", {
|
|
value: "",
|
|
disabled: true,
|
|
hidden: true
|
|
}, "Choose a directory"), dirOptions.map((o2, idx) => /* @__PURE__ */ React4.createElement("option", {
|
|
key: idx,
|
|
value: o2
|
|
}, o2)))));
|
|
}
|
|
function ColorPicker({
|
|
source,
|
|
changeListener
|
|
}) {
|
|
return /* @__PURE__ */ React4.createElement("div", {
|
|
className: "setting-item"
|
|
}, /* @__PURE__ */ React4.createElement("div", {
|
|
className: "setting-item-info"
|
|
}, /* @__PURE__ */ React4.createElement("div", {
|
|
className: "setting-item-name"
|
|
}, "Color"), /* @__PURE__ */ React4.createElement("div", {
|
|
className: "setting-item-description"
|
|
}, "The color of events on the calendar")), /* @__PURE__ */ React4.createElement("div", {
|
|
className: "setting-item-control"
|
|
}, /* @__PURE__ */ React4.createElement("input", {
|
|
required: true,
|
|
type: "color",
|
|
value: source.color,
|
|
style: { maxWidth: "25%", minWidth: "3rem" },
|
|
onChange: changeListener((x3) => __spreadProps(__spreadValues({}, source), { color: x3 }))
|
|
})));
|
|
}
|
|
function UrlInput({
|
|
source,
|
|
changeListener
|
|
}) {
|
|
let sourceWithUrl = source;
|
|
return /* @__PURE__ */ React4.createElement("div", {
|
|
className: "setting-item"
|
|
}, /* @__PURE__ */ React4.createElement("div", {
|
|
className: "setting-item-info"
|
|
}, /* @__PURE__ */ React4.createElement("div", {
|
|
className: "setting-item-name"
|
|
}, "Url"), /* @__PURE__ */ React4.createElement("div", {
|
|
className: "setting-item-description"
|
|
}, "Url of the server")), /* @__PURE__ */ React4.createElement("div", {
|
|
className: "setting-item-control"
|
|
}, /* @__PURE__ */ React4.createElement("input", {
|
|
required: true,
|
|
type: "text",
|
|
value: sourceWithUrl.url || "",
|
|
onChange: changeListener((x3) => __spreadProps(__spreadValues({}, sourceWithUrl), {
|
|
url: x3
|
|
}))
|
|
})));
|
|
}
|
|
function UsernameInput({
|
|
source,
|
|
changeListener
|
|
}) {
|
|
let sourceWithUsername = source;
|
|
return /* @__PURE__ */ React4.createElement("div", {
|
|
className: "setting-item"
|
|
}, /* @__PURE__ */ React4.createElement("div", {
|
|
className: "setting-item-info"
|
|
}, /* @__PURE__ */ React4.createElement("div", {
|
|
className: "setting-item-name"
|
|
}, "Username"), /* @__PURE__ */ React4.createElement("div", {
|
|
className: "setting-item-description"
|
|
}, "Username for the account")), /* @__PURE__ */ React4.createElement("div", {
|
|
className: "setting-item-control"
|
|
}, /* @__PURE__ */ React4.createElement("input", {
|
|
required: true,
|
|
type: "text",
|
|
value: sourceWithUsername.username || "",
|
|
onChange: changeListener((x3) => __spreadProps(__spreadValues({}, sourceWithUsername), {
|
|
username: x3
|
|
}))
|
|
})));
|
|
}
|
|
function PasswordInput({
|
|
source,
|
|
changeListener
|
|
}) {
|
|
let sourceWithPassword = source;
|
|
return /* @__PURE__ */ React4.createElement("div", {
|
|
className: "setting-item"
|
|
}, /* @__PURE__ */ React4.createElement("div", {
|
|
className: "setting-item-info"
|
|
}, /* @__PURE__ */ React4.createElement("div", {
|
|
className: "setting-item-name"
|
|
}, "Password"), /* @__PURE__ */ React4.createElement("div", {
|
|
className: "setting-item-description"
|
|
}, "Password for the account")), /* @__PURE__ */ React4.createElement("div", {
|
|
className: "setting-item-control"
|
|
}, /* @__PURE__ */ React4.createElement("input", {
|
|
required: true,
|
|
type: "password",
|
|
value: sourceWithPassword.password || "",
|
|
onChange: changeListener((x3) => __spreadProps(__spreadValues({}, sourceWithPassword), {
|
|
password: x3
|
|
}))
|
|
})));
|
|
}
|
|
var AddCalendarSource = ({
|
|
source,
|
|
directories,
|
|
submit
|
|
}) => {
|
|
const isCalDAV = source.type === "caldav" || source.type === "icloud";
|
|
const [setting, setSettingState] = (0, import_react2.useState)(source);
|
|
const [submitting, setSubmitingState] = (0, import_react2.useState)(false);
|
|
const [submitText, setSubmitText] = (0, import_react2.useState)(isCalDAV ? "Import Calendars" : "Add Calendar");
|
|
function makeChangeListener2(fromString) {
|
|
return (e3) => setSettingState(fromString(e3.target.value));
|
|
}
|
|
const handleSubmit = (e3) => __async(void 0, null, function* () {
|
|
e3.preventDefault();
|
|
if (!submitting) {
|
|
setSubmitingState(true);
|
|
setSubmitText(isCalDAV ? "Importing Calendars" : "Adding Calendar");
|
|
yield submit(setting);
|
|
}
|
|
});
|
|
return /* @__PURE__ */ React4.createElement("div", {
|
|
className: "vertical-tab-content"
|
|
}, /* @__PURE__ */ React4.createElement("form", {
|
|
onSubmit: handleSubmit
|
|
}, !isCalDAV && /* @__PURE__ */ React4.createElement(ColorPicker, {
|
|
source: setting,
|
|
changeListener: makeChangeListener2
|
|
}), source.type === "local" && /* @__PURE__ */ React4.createElement(DirectorySelect, {
|
|
source: setting,
|
|
changeListener: makeChangeListener2,
|
|
directories
|
|
}), source.type !== "local" && source.type !== "icloud" && /* @__PURE__ */ React4.createElement(UrlInput, {
|
|
source: setting,
|
|
changeListener: makeChangeListener2
|
|
}), isCalDAV && /* @__PURE__ */ React4.createElement(UsernameInput, {
|
|
source: setting,
|
|
changeListener: makeChangeListener2
|
|
}), isCalDAV && /* @__PURE__ */ React4.createElement(PasswordInput, {
|
|
source: setting,
|
|
changeListener: makeChangeListener2
|
|
}), /* @__PURE__ */ React4.createElement("div", {
|
|
className: "setting-item"
|
|
}, /* @__PURE__ */ React4.createElement("div", {
|
|
className: "setting-item-info"
|
|
}), /* @__PURE__ */ React4.createElement("div", {
|
|
className: "setting-control"
|
|
}, /* @__PURE__ */ React4.createElement("button", {
|
|
className: "mod-cta",
|
|
type: "submit",
|
|
disabled: submitting
|
|
}, submitText)))));
|
|
};
|
|
|
|
// src/settings.ts
|
|
var ReactDOM2 = __toModule(require_react_dom());
|
|
var import_react3 = __toModule(require_react());
|
|
var DEFAULT_SETTINGS = {
|
|
calendarSources: [],
|
|
defaultCalendar: 0,
|
|
recursiveLocal: false,
|
|
firstDay: 0
|
|
};
|
|
var WEEKDAYS = [
|
|
"Sunday",
|
|
"Monday",
|
|
"Tuesday",
|
|
"Wednesday",
|
|
"Thursday",
|
|
"Friday",
|
|
"Saturday"
|
|
];
|
|
function addCalendarButton(app, plugin, containerEl, submitCallback, listUsedDirectories) {
|
|
let dropdown;
|
|
const directories = app.vault.getAllLoadedFiles().filter((f3) => f3 instanceof import_obsidian6.TFolder).map((f3) => f3.path);
|
|
return new import_obsidian6.Setting(containerEl).setName("Calendars").setDesc("Add calendar").addDropdown((d3) => dropdown = d3.addOptions({
|
|
local: "Local",
|
|
icloud: "iCloud",
|
|
caldav: "CalDAV",
|
|
ical: "Remote (.ics format)"
|
|
})).addExtraButton((button) => {
|
|
button.setTooltip("Add Calendar");
|
|
button.setIcon("plus-with-circle");
|
|
button.onClick(() => {
|
|
let modal = new ReactModal(app, () => __async(this, null, function* () {
|
|
yield plugin.loadSettings();
|
|
const usedDirectories = (listUsedDirectories ? listUsedDirectories : () => plugin.settings.calendarSources.map((s3) => s3.type === "local" && s3.directory).filter((s3) => !!s3))();
|
|
return (0, import_react3.createElement)(AddCalendarSource, {
|
|
source: makeDefaultPartialCalendarSource(dropdown.getValue()),
|
|
directories: directories.filter((dir) => usedDirectories.indexOf(dir) === -1),
|
|
submit: (source) => __async(this, null, function* () {
|
|
if (source.type === "caldav" || source.type === "icloud") {
|
|
let sources = yield new RemoteSource(source).importCalendars();
|
|
if (sources instanceof FCError) {
|
|
new import_obsidian6.Notice(sources.message);
|
|
} else {
|
|
sources.forEach((source2) => submitCallback(source2));
|
|
}
|
|
} else {
|
|
submitCallback(source);
|
|
}
|
|
modal.close();
|
|
})
|
|
});
|
|
}));
|
|
modal.open();
|
|
});
|
|
});
|
|
}
|
|
var FullCalendarSettingTab = class extends import_obsidian6.PluginSettingTab {
|
|
constructor(app, plugin) {
|
|
super(app, plugin);
|
|
this.plugin = plugin;
|
|
}
|
|
display() {
|
|
return __async(this, null, function* () {
|
|
const { containerEl } = this;
|
|
containerEl.empty();
|
|
containerEl.createEl("h2", { text: "Events settings" });
|
|
new import_obsidian6.Setting(containerEl).setName("Recursive event folders").setDesc("Search through sub-folders for events").addToggle((toggle) => {
|
|
toggle.setValue(this.plugin.settings.recursiveLocal);
|
|
toggle.onChange((val) => __async(this, null, function* () {
|
|
this.plugin.settings.recursiveLocal = val;
|
|
yield this.plugin.saveSettings();
|
|
}));
|
|
});
|
|
new import_obsidian6.Setting(containerEl).setName("Starting Day of the Week").setDesc("Choose what day of the week to start.").addDropdown((dropdown) => {
|
|
WEEKDAYS.forEach((day, code) => {
|
|
dropdown.addOption(code.toString(), day);
|
|
});
|
|
dropdown.setValue(this.plugin.settings.firstDay.toString());
|
|
dropdown.onChange((codeAsString) => __async(this, null, function* () {
|
|
this.plugin.settings.firstDay = Number(codeAsString);
|
|
yield this.plugin.saveSettings();
|
|
}));
|
|
});
|
|
addCalendarButton(this.app, this.plugin, containerEl, (source) => __async(this, null, function* () {
|
|
sourceList.addSource(source);
|
|
}), () => sourceList.state.sources.map((s3) => s3.type === "local" && s3.directory).filter((s3) => !!s3));
|
|
const sourcesDiv = containerEl.createDiv();
|
|
sourcesDiv.style.display = "block";
|
|
let sourceList = ReactDOM2.render((0, import_react3.createElement)(CalendarSettings, {
|
|
sources: this.plugin.settings.calendarSources,
|
|
submit: (settings) => __async(this, null, function* () {
|
|
this.plugin.settings.calendarSources = settings;
|
|
yield this.plugin.saveSettings();
|
|
})
|
|
}), sourcesDiv);
|
|
});
|
|
}
|
|
};
|
|
|
|
// src/onboard.ts
|
|
function renderOnboarding(app, plugin, el) {
|
|
el.style.height = "100%";
|
|
const nocal = el.createDiv();
|
|
nocal.style.height = "100%";
|
|
nocal.style.display = "flex";
|
|
nocal.style.alignItems = "center";
|
|
nocal.style.justifyContent = "center";
|
|
const notice = nocal.createDiv();
|
|
notice.createEl("h1").textContent = "No calendar available";
|
|
notice.createEl("p").textContent = "Thanks for downloading Full Calendar! Create a calendar below to begin.";
|
|
const container = notice.createDiv();
|
|
container.style.position = "fixed";
|
|
addCalendarButton(app, plugin, container, (source) => __async(this, null, function* () {
|
|
const { calendarSources } = plugin.settings;
|
|
calendarSources.push(source);
|
|
yield plugin.saveSettings();
|
|
yield plugin.activateView();
|
|
}));
|
|
}
|
|
|
|
// src/view.ts
|
|
var FULL_CALENDAR_VIEW_TYPE = "full-calendar-view";
|
|
var CalendarView = class extends import_obsidian7.ItemView {
|
|
constructor(leaf, plugin) {
|
|
super(leaf);
|
|
this.plugin = plugin;
|
|
this.calendar = null;
|
|
this.cacheCallback = this.onCacheUpdate.bind(this);
|
|
}
|
|
getViewType() {
|
|
return FULL_CALENDAR_VIEW_TYPE;
|
|
}
|
|
getDisplayText() {
|
|
return "Calendar";
|
|
}
|
|
onCacheUpdate(file) {
|
|
var _a;
|
|
const source = this.plugin.settings.calendarSources.find((c3) => c3.type === "local" && file.path.startsWith(c3.directory));
|
|
const event = NoteEvent.fromFile(this.app.metadataCache, this.app.vault, file);
|
|
if (!event) {
|
|
return;
|
|
}
|
|
let calendarEvent = (_a = this.calendar) == null ? void 0 : _a.getEventById(event.idForCalendar);
|
|
if (this.calendar && source && event) {
|
|
if (calendarEvent) {
|
|
calendarEvent.remove();
|
|
}
|
|
event.addTo(this.calendar, source);
|
|
}
|
|
}
|
|
onOpen() {
|
|
return __async(this, null, function* () {
|
|
yield this.plugin.loadSettings();
|
|
const noteSourcePromises = this.plugin.settings.calendarSources.flatMap((s3) => s3.type === "local" ? [s3] : []).map((s3) => new NoteSource(this.app.vault, this.app.metadataCache, s3)).map((ns2) => ns2.toApi(this.plugin.settings.recursiveLocal));
|
|
const container = this.containerEl.children[1];
|
|
container.empty();
|
|
let calendarEl = container.createEl("div");
|
|
const noteSourceResults = yield Promise.all(noteSourcePromises);
|
|
const sources = noteSourceResults.flatMap((s3) => s3 instanceof FCError ? [] : [s3]);
|
|
if (sources.length === 0 && this.plugin.settings.calendarSources.filter((s3) => s3.type === "ical" || s3.type === "caldav" || s3.type === "icloud").length === 0) {
|
|
renderOnboarding(this.app, this.plugin, calendarEl);
|
|
return;
|
|
}
|
|
let errs = noteSourceResults.flatMap((s3) => s3 instanceof FCError ? [s3] : []);
|
|
for (const err of errs) {
|
|
new import_obsidian7.Notice(err.message);
|
|
}
|
|
this.calendar = renderCalendar(calendarEl, sources, {
|
|
eventClick: (info) => __async(this, null, function* () {
|
|
if (info.jsEvent.getModifierState("Control") || info.jsEvent.getModifierState("Meta")) {
|
|
let file = this.app.vault.getAbstractFileByPath(info.event.id);
|
|
if (file instanceof import_obsidian7.TFile) {
|
|
let leaf = this.app.workspace.getMostRecentLeaf();
|
|
yield leaf.openFile(file);
|
|
}
|
|
} else {
|
|
new EventModal(this.app, this.plugin, this.calendar).editInModal(info.event);
|
|
}
|
|
}),
|
|
select: (start, end, allDay) => __async(this, null, function* () {
|
|
const partialEvent = dateEndpointsToFrontmatter(start, end, allDay);
|
|
let modal = new EventModal(this.app, this.plugin, this.calendar, partialEvent);
|
|
modal.open();
|
|
}),
|
|
modifyEvent: (newEvent, oldEvent) => __async(this, null, function* () {
|
|
try {
|
|
const existingEvent = yield eventFromCalendarId(this.app.metadataCache, this.app.vault, oldEvent.id);
|
|
if (!existingEvent) {
|
|
return false;
|
|
}
|
|
const frontmatter = eventApiToFrontmatter(newEvent);
|
|
yield existingEvent.setData(frontmatter);
|
|
} catch (e3) {
|
|
new import_obsidian7.Notice(e3.message);
|
|
return false;
|
|
}
|
|
return true;
|
|
}),
|
|
eventMouseEnter: (info) => __async(this, null, function* () {
|
|
const event = yield eventFromCalendarId(this.app.metadataCache, this.app.vault, info.event.id);
|
|
if (event instanceof LocalEvent) {
|
|
this.app.workspace.trigger("hover-link", {
|
|
event: info.jsEvent,
|
|
source: PLUGIN_SLUG,
|
|
hoverParent: calendarEl,
|
|
targetEl: info.jsEvent.target,
|
|
linktext: event.path,
|
|
sourcePath: event.path
|
|
});
|
|
}
|
|
}),
|
|
firstDay: this.plugin.settings.firstDay
|
|
});
|
|
this.plugin.settings.calendarSources.flatMap((s3) => s3.type === "ical" ? [s3] : []).map((s3) => new IcsSource(s3)).map((s3) => s3.toApi()).forEach((resultPromise) => resultPromise.then((result) => {
|
|
var _a;
|
|
if (result instanceof FCError) {
|
|
new import_obsidian7.Notice(result.message);
|
|
} else {
|
|
(_a = this.calendar) == null ? void 0 : _a.addEventSource(result);
|
|
}
|
|
}));
|
|
this.plugin.settings.calendarSources.flatMap((s3) => s3.type === "caldav" || s3.type === "icloud" ? [s3] : []).map((s3) => new RemoteSource(s3)).map((s3) => s3.toApi()).forEach((resultPromise) => resultPromise.then((result) => {
|
|
var _a;
|
|
if (result instanceof FCError) {
|
|
new import_obsidian7.Notice(result.message);
|
|
} else {
|
|
(_a = this.calendar) == null ? void 0 : _a.addEventSource(result);
|
|
}
|
|
}));
|
|
this.registerEvent(this.app.metadataCache.on("changed", this.cacheCallback));
|
|
this.registerEvent(this.app.vault.on("delete", (file) => {
|
|
var _a;
|
|
if (file instanceof import_obsidian7.TFile) {
|
|
let id = NoteEvent.ID_PREFIX + CalendarEvent.ID_SEPARATOR + file.path;
|
|
const event = (_a = this.calendar) == null ? void 0 : _a.getEventById(id);
|
|
if (event) {
|
|
event.remove();
|
|
}
|
|
}
|
|
}));
|
|
this.registerEvent(this.app.vault.on("rename", (file, oldPath) => {
|
|
var _a;
|
|
const oldEvent = (_a = this.calendar) == null ? void 0 : _a.getEventById(NoteEvent.ID_PREFIX + CalendarEvent.ID_SEPARATOR + oldPath);
|
|
if (oldEvent) {
|
|
oldEvent.remove();
|
|
}
|
|
if (file instanceof import_obsidian7.TFile) {
|
|
this.onCacheUpdate(file);
|
|
}
|
|
}));
|
|
});
|
|
}
|
|
onResize() {
|
|
if (this.calendar) {
|
|
this.calendar.render();
|
|
}
|
|
}
|
|
onClose() {
|
|
return __async(this, null, function* () {
|
|
if (this.calendar) {
|
|
this.calendar.destroy();
|
|
this.calendar = null;
|
|
}
|
|
});
|
|
}
|
|
};
|
|
|
|
// src/main.ts
|
|
var FullCalendarPlugin = class extends import_obsidian8.Plugin {
|
|
constructor() {
|
|
super(...arguments);
|
|
this.settings = DEFAULT_SETTINGS;
|
|
this.renderCalendar = renderCalendar;
|
|
this.processFrontmatter = parseFrontmatter;
|
|
}
|
|
activateView() {
|
|
return __async(this, null, function* () {
|
|
this.app.workspace.detachLeavesOfType(FULL_CALENDAR_VIEW_TYPE);
|
|
yield this.app.workspace.getUnpinnedLeaf().setViewState({
|
|
type: FULL_CALENDAR_VIEW_TYPE,
|
|
active: true
|
|
});
|
|
this.app.workspace.revealLeaf(this.app.workspace.getLeavesOfType(FULL_CALENDAR_VIEW_TYPE)[0]);
|
|
});
|
|
}
|
|
onload() {
|
|
return __async(this, null, function* () {
|
|
yield this.loadSettings();
|
|
this.registerView(FULL_CALENDAR_VIEW_TYPE, (leaf) => new CalendarView(leaf, this));
|
|
this.addRibbonIcon("calendar-glyph", "Open Full Calendar", (_3) => {
|
|
this.activateView();
|
|
});
|
|
this.addSettingTab(new FullCalendarSettingTab(this.app, this));
|
|
this.addCommand({
|
|
id: "full-calendar-new-event",
|
|
name: "New Event",
|
|
callback: () => {
|
|
new EventModal(this.app, this, null).open();
|
|
}
|
|
});
|
|
this.addCommand({
|
|
id: "full-calendar-open",
|
|
name: "Open Calendar",
|
|
callback: () => {
|
|
this.activateView();
|
|
}
|
|
});
|
|
this.addCommand({
|
|
id: "full-calendar-upgrade-note",
|
|
name: "Upgrade note to event",
|
|
callback: () => {
|
|
const view = this.app.workspace.getActiveViewOfType(import_obsidian8.MarkdownView);
|
|
if (view) {
|
|
const file = view.file;
|
|
new EventModal(this.app, this, null).editInModal(file);
|
|
}
|
|
}
|
|
});
|
|
this.app.workspace.registerHoverLinkSource(PLUGIN_SLUG, {
|
|
display: "Full Calendar",
|
|
defaultMod: true
|
|
});
|
|
});
|
|
}
|
|
onunload() {
|
|
this.app.workspace.detachLeavesOfType(FULL_CALENDAR_VIEW_TYPE);
|
|
}
|
|
loadSettings() {
|
|
return __async(this, null, function* () {
|
|
this.settings = Object.assign({}, DEFAULT_SETTINGS, yield this.loadData());
|
|
});
|
|
}
|
|
saveSettings() {
|
|
return __async(this, null, function* () {
|
|
yield this.saveData(this.settings);
|
|
});
|
|
}
|
|
};
|
|
/*
|
|
object-assign
|
|
(c) Sindre Sorhus
|
|
@license MIT
|
|
*/
|
|
/*!
|
|
FullCalendar v5.10.1
|
|
Docs & License: https://fullcalendar.io/
|
|
(c) 2021 Adam Shaw
|
|
*/
|
|
/*! *****************************************************************************
|
|
Copyright (c) Microsoft Corporation.
|
|
|
|
Permission to use, copy, modify, and/or distribute this software for any
|
|
purpose with or without fee is hereby granted.
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
PERFORMANCE OF THIS SOFTWARE.
|
|
***************************************************************************** */
|
|
/*! https://mths.be/punycode v1.4.1 by @mathias */
|
|
/**
|
|
* Checks if an event is supported in the current execution environment.
|
|
*
|
|
* NOTE: This will not work correctly for non-generic events such as `change`,
|
|
* `reset`, `load`, `error`, and `select`.
|
|
*
|
|
* Borrows from Modernizr.
|
|
*
|
|
* @param {string} eventNameSuffix Event name, e.g. "click".
|
|
* @return {boolean} True if the event is supported.
|
|
* @internal
|
|
* @license Modernizr 3.0.0pre (Custom Build) | MIT
|
|
*/
|
|
/** @license React v0.20.2
|
|
* scheduler-tracing.development.js
|
|
*
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*/
|
|
/** @license React v0.20.2
|
|
* scheduler.development.js
|
|
*
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*/
|
|
/** @license React v17.0.2
|
|
* react-dom.development.js
|
|
*
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*/
|
|
/** @license React v17.0.2
|
|
* react.development.js
|
|
*
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*/
|