@bagelink/vue 0.0.600 → 0.0.605

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -112,12 +112,21 @@ function getPaddingObject(padding) {
112
112
  };
113
113
  }
114
114
  function rectToClientRect$1(rect) {
115
+ const {
116
+ x: x2,
117
+ y: y2,
118
+ width,
119
+ height
120
+ } = rect;
115
121
  return {
116
- ...rect,
117
- top: rect.y,
118
- left: rect.x,
119
- right: rect.x + rect.width,
120
- bottom: rect.y + rect.height
122
+ width,
123
+ height,
124
+ top: y2,
125
+ left: x2,
126
+ right: x2 + width,
127
+ bottom: y2 + height,
128
+ x: x2,
129
+ y: y2
121
130
  };
122
131
  }
123
132
  function computeCoordsFromPlacement(_ref, placement, rtl) {
@@ -288,9 +297,10 @@ async function detectOverflow$1(state2, options) {
288
297
  strategy
289
298
  }));
290
299
  const rect = elementContext === "floating" ? {
291
- ...rects.floating,
292
300
  x: x2,
293
- y: y2
301
+ y: y2,
302
+ width: rects.floating.width,
303
+ height: rects.floating.height
294
304
  } : rects.reference;
295
305
  const offsetParent = await (platform2.getOffsetParent == null ? void 0 : platform2.getOffsetParent(elements.floating));
296
306
  const offsetScale = await (platform2.isElement == null ? void 0 : platform2.isElement(offsetParent)) ? await (platform2.getScale == null ? void 0 : platform2.getScale(offsetParent)) || {
@@ -501,10 +511,12 @@ const flip$2 = function(options) {
501
511
  return {};
502
512
  }
503
513
  const side = getSide$1(placement);
514
+ const initialSideAxis = getSideAxis(initialPlacement);
504
515
  const isBasePlacement = getSide$1(initialPlacement) === initialPlacement;
505
516
  const rtl = await (platform2.isRTL == null ? void 0 : platform2.isRTL(elements.floating));
506
517
  const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement$1(initialPlacement)] : getExpandedPlacements(initialPlacement));
507
- if (!specifiedFallbackPlacements && fallbackAxisSideDirection !== "none") {
518
+ const hasFallbackAxisSideDirection = fallbackAxisSideDirection !== "none";
519
+ if (!specifiedFallbackPlacements && hasFallbackAxisSideDirection) {
508
520
  fallbackPlacements.push(...getOppositeAxisPlacements(initialPlacement, flipAlignment, fallbackAxisSideDirection, rtl));
509
521
  }
510
522
  const placements2 = [initialPlacement, ...fallbackPlacements];
@@ -541,8 +553,16 @@ const flip$2 = function(options) {
541
553
  if (!resetPlacement) {
542
554
  switch (fallbackStrategy) {
543
555
  case "bestFit": {
544
- var _overflowsData$map$so;
545
- const placement2 = (_overflowsData$map$so = overflowsData.map((d2) => [d2.placement, d2.overflows.filter((overflow2) => overflow2 > 0).reduce((acc, overflow2) => acc + overflow2, 0)]).sort((a2, b2) => a2[1] - b2[1])[0]) == null ? void 0 : _overflowsData$map$so[0];
556
+ var _overflowsData$filter2;
557
+ const placement2 = (_overflowsData$filter2 = overflowsData.filter((d2) => {
558
+ if (hasFallbackAxisSideDirection) {
559
+ const currentSideAxis = getSideAxis(d2.placement);
560
+ return currentSideAxis === initialSideAxis || // Create a bias to the `y` side axis due to horizontal
561
+ // reading directions favoring greater width.
562
+ currentSideAxis === "y";
563
+ }
564
+ return true;
565
+ }).map((d2) => [d2.placement, d2.overflows.filter((overflow2) => overflow2 > 0).reduce((acc, overflow2) => acc + overflow2, 0)]).sort((a2, b2) => a2[1] - b2[1])[0]) == null ? void 0 : _overflowsData$filter2[0];
546
566
  if (placement2) {
547
567
  resetPlacement = placement2;
548
568
  }
@@ -737,16 +757,16 @@ const size = function(options) {
737
757
  widthSide = side;
738
758
  heightSide = alignment === "end" ? "top" : "bottom";
739
759
  }
740
- const overflowAvailableHeight = height - overflow[heightSide];
741
- const overflowAvailableWidth = width - overflow[widthSide];
760
+ const maximumClippingHeight = height - overflow.top - overflow.bottom;
761
+ const maximumClippingWidth = width - overflow.left - overflow.right;
762
+ const overflowAvailableHeight = min$3(height - overflow[heightSide], maximumClippingHeight);
763
+ const overflowAvailableWidth = min$3(width - overflow[widthSide], maximumClippingWidth);
742
764
  const noShift = !state2.middlewareData.shift;
743
765
  let availableHeight = overflowAvailableHeight;
744
766
  let availableWidth = overflowAvailableWidth;
745
767
  if (isYAxis) {
746
- const maximumClippingWidth = width - overflow.left - overflow.right;
747
768
  availableWidth = alignment || noShift ? min$3(overflowAvailableWidth, maximumClippingWidth) : maximumClippingWidth;
748
769
  } else {
749
- const maximumClippingHeight = height - overflow.top - overflow.bottom;
750
770
  availableHeight = alignment || noShift ? min$3(overflowAvailableHeight, maximumClippingHeight) : maximumClippingHeight;
751
771
  }
752
772
  if (noShift && !alignment) {
@@ -3383,7 +3403,6 @@ const defaults$1 = {
3383
3403
  utils$1.forEach(["delete", "get", "head", "post", "put", "patch"], (method) => {
3384
3404
  defaults$1.headers[method] = {};
3385
3405
  });
3386
- const defaults$2 = defaults$1;
3387
3406
  const ignoreDuplicateOf = utils$1.toObjectSet([
3388
3407
  "age",
3389
3408
  "authorization",
@@ -3645,11 +3664,10 @@ utils$1.reduceDescriptors(AxiosHeaders.prototype, ({ value }, key) => {
3645
3664
  };
3646
3665
  });
3647
3666
  utils$1.freezeMethods(AxiosHeaders);
3648
- const AxiosHeaders$1 = AxiosHeaders;
3649
3667
  function transformData(fns, response) {
3650
- const config = this || defaults$2;
3668
+ const config = this || defaults$1;
3651
3669
  const context = response || config;
3652
- const headers = AxiosHeaders$1.from(context.headers);
3670
+ const headers = AxiosHeaders.from(context.headers);
3653
3671
  let data2 = context.data;
3654
3672
  utils$1.forEach(fns, function transform(fn3) {
3655
3673
  data2 = fn3.call(config, data2, headers.normalize(), response ? response.status : void 0);
@@ -3848,7 +3866,7 @@ function buildFullPath(baseURL, requestedURL) {
3848
3866
  }
3849
3867
  return requestedURL;
3850
3868
  }
3851
- const headersToObject = (thing) => thing instanceof AxiosHeaders$1 ? { ...thing } : thing;
3869
+ const headersToObject = (thing) => thing instanceof AxiosHeaders ? { ...thing } : thing;
3852
3870
  function mergeConfig(config1, config2) {
3853
3871
  config2 = config2 || {};
3854
3872
  const config = {};
@@ -3929,7 +3947,7 @@ function mergeConfig(config1, config2) {
3929
3947
  const resolveConfig = (config) => {
3930
3948
  const newConfig = mergeConfig({}, config);
3931
3949
  let { data: data2, withXSRFToken, xsrfHeaderName, xsrfCookieName, headers, auth } = newConfig;
3932
- newConfig.headers = headers = AxiosHeaders$1.from(headers);
3950
+ newConfig.headers = headers = AxiosHeaders.from(headers);
3933
3951
  newConfig.url = buildURL(buildFullPath(newConfig.baseURL, newConfig.url), config.params, config.paramsSerializer);
3934
3952
  if (auth) {
3935
3953
  headers.set(
@@ -3962,7 +3980,7 @@ const xhrAdapter = isXHRAdapterSupported && function(config) {
3962
3980
  return new Promise(function dispatchXhrRequest(resolve, reject3) {
3963
3981
  const _config = resolveConfig(config);
3964
3982
  let requestData = _config.data;
3965
- const requestHeaders = AxiosHeaders$1.from(_config.headers).normalize();
3983
+ const requestHeaders = AxiosHeaders.from(_config.headers).normalize();
3966
3984
  let { responseType } = _config;
3967
3985
  let onCanceled;
3968
3986
  function done() {
@@ -3980,7 +3998,7 @@ const xhrAdapter = isXHRAdapterSupported && function(config) {
3980
3998
  if (!request) {
3981
3999
  return;
3982
4000
  }
3983
- const responseHeaders = AxiosHeaders$1.from(
4001
+ const responseHeaders = AxiosHeaders.from(
3984
4002
  "getAllResponseHeaders" in request && request.getAllResponseHeaders()
3985
4003
  );
3986
4004
  const responseData = !responseType || responseType === "text" || responseType === "json" ? request.responseText : request.response;
@@ -4296,7 +4314,7 @@ const fetchAdapter = isFetchSupported && (async (config) => {
4296
4314
  return await new Promise((resolve, reject3) => {
4297
4315
  settle(resolve, reject3, {
4298
4316
  data: responseData,
4299
- headers: AxiosHeaders$1.from(response.headers),
4317
+ headers: AxiosHeaders.from(response.headers),
4300
4318
  status: response.status,
4301
4319
  statusText: response.statusText,
4302
4320
  config,
@@ -4378,7 +4396,7 @@ function throwIfCancellationRequested(config) {
4378
4396
  }
4379
4397
  function dispatchRequest(config) {
4380
4398
  throwIfCancellationRequested(config);
4381
- config.headers = AxiosHeaders$1.from(config.headers);
4399
+ config.headers = AxiosHeaders.from(config.headers);
4382
4400
  config.data = transformData.call(
4383
4401
  config,
4384
4402
  config.transformRequest
@@ -4386,7 +4404,7 @@ function dispatchRequest(config) {
4386
4404
  if (["post", "put", "patch"].indexOf(config.method) !== -1) {
4387
4405
  config.headers.setContentType("application/x-www-form-urlencoded", false);
4388
4406
  }
4389
- const adapter = adapters.getAdapter(config.adapter || defaults$2.adapter);
4407
+ const adapter = adapters.getAdapter(config.adapter || defaults$1.adapter);
4390
4408
  return adapter(config).then(function onAdapterResolution(response) {
4391
4409
  throwIfCancellationRequested(config);
4392
4410
  response.data = transformData.call(
@@ -4394,7 +4412,7 @@ function dispatchRequest(config) {
4394
4412
  config.transformResponse,
4395
4413
  response
4396
4414
  );
4397
- response.headers = AxiosHeaders$1.from(response.headers);
4415
+ response.headers = AxiosHeaders.from(response.headers);
4398
4416
  return response;
4399
4417
  }, function onAdapterRejection(reason) {
4400
4418
  if (!isCancel(reason)) {
@@ -4405,7 +4423,7 @@ function dispatchRequest(config) {
4405
4423
  config.transformResponse,
4406
4424
  reason.response
4407
4425
  );
4408
- reason.response.headers = AxiosHeaders$1.from(reason.response.headers);
4426
+ reason.response.headers = AxiosHeaders.from(reason.response.headers);
4409
4427
  }
4410
4428
  }
4411
4429
  return Promise.reject(reason);
@@ -4544,7 +4562,7 @@ class Axios {
4544
4562
  delete headers[method];
4545
4563
  }
4546
4564
  );
4547
- config.headers = AxiosHeaders$1.concat(contextHeaders, headers);
4565
+ config.headers = AxiosHeaders.concat(contextHeaders, headers);
4548
4566
  const requestInterceptorChain = [];
4549
4567
  let synchronousRequestInterceptors = true;
4550
4568
  this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) {
@@ -4628,7 +4646,6 @@ utils$1.forEach(["post", "put", "patch"], function forEachMethodWithData(method)
4628
4646
  Axios.prototype[method] = generateHTTPMethod();
4629
4647
  Axios.prototype[method + "Form"] = generateHTTPMethod(true);
4630
4648
  });
4631
- const Axios$1 = Axios;
4632
4649
  class CancelToken {
4633
4650
  constructor(executor) {
4634
4651
  if (typeof executor !== "function") {
@@ -4715,7 +4732,6 @@ class CancelToken {
4715
4732
  };
4716
4733
  }
4717
4734
  }
4718
- const CancelToken$1 = CancelToken;
4719
4735
  function spread(callback) {
4720
4736
  return function wrap2(arr) {
4721
4737
  return callback.apply(null, arr);
@@ -4792,21 +4808,20 @@ const HttpStatusCode = {
4792
4808
  Object.entries(HttpStatusCode).forEach(([key, value]) => {
4793
4809
  HttpStatusCode[value] = key;
4794
4810
  });
4795
- const HttpStatusCode$1 = HttpStatusCode;
4796
4811
  function createInstance(defaultConfig2) {
4797
- const context = new Axios$1(defaultConfig2);
4798
- const instance = bind$2(Axios$1.prototype.request, context);
4799
- utils$1.extend(instance, Axios$1.prototype, context, { allOwnKeys: true });
4812
+ const context = new Axios(defaultConfig2);
4813
+ const instance = bind$2(Axios.prototype.request, context);
4814
+ utils$1.extend(instance, Axios.prototype, context, { allOwnKeys: true });
4800
4815
  utils$1.extend(instance, context, null, { allOwnKeys: true });
4801
4816
  instance.create = function create(instanceConfig) {
4802
4817
  return createInstance(mergeConfig(defaultConfig2, instanceConfig));
4803
4818
  };
4804
4819
  return instance;
4805
4820
  }
4806
- const axios$1 = createInstance(defaults$2);
4807
- axios$1.Axios = Axios$1;
4821
+ const axios$1 = createInstance(defaults$1);
4822
+ axios$1.Axios = Axios;
4808
4823
  axios$1.CanceledError = CanceledError;
4809
- axios$1.CancelToken = CancelToken$1;
4824
+ axios$1.CancelToken = CancelToken;
4810
4825
  axios$1.isCancel = isCancel;
4811
4826
  axios$1.VERSION = VERSION;
4812
4827
  axios$1.toFormData = toFormData;
@@ -4818,10 +4833,10 @@ axios$1.all = function all(promises) {
4818
4833
  axios$1.spread = spread;
4819
4834
  axios$1.isAxiosError = isAxiosError;
4820
4835
  axios$1.mergeConfig = mergeConfig;
4821
- axios$1.AxiosHeaders = AxiosHeaders$1;
4836
+ axios$1.AxiosHeaders = AxiosHeaders;
4822
4837
  axios$1.formToJSON = (thing) => formDataToJSON(utils$1.isHTMLForm(thing) ? new FormData(thing) : thing);
4823
4838
  axios$1.getAdapter = adapters.getAdapter;
4824
- axios$1.HttpStatusCode = HttpStatusCode$1;
4839
+ axios$1.HttpStatusCode = HttpStatusCode;
4825
4840
  axios$1.default = axios$1;
4826
4841
  var __defProp = Object.defineProperty;
4827
4842
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
@@ -5065,7 +5080,11 @@ class Bagel {
5065
5080
  this._setAuthorization();
5066
5081
  const formData = new FormData();
5067
5082
  formData.append("file", file);
5068
- const { data: data2 } = await axios.post("/static_files/upload", formData, {
5083
+ let url = "/static_files/upload";
5084
+ console.log(options == null ? void 0 : options.topic);
5085
+ if (options == null ? void 0 : options.topic)
5086
+ url = `/static_files/upload?topic=${options.topic}`;
5087
+ const { data: data2 } = await axios.post(url, formData, {
5069
5088
  headers: {
5070
5089
  "Content-Type": "multipart/form-data"
5071
5090
  },
@@ -5245,7 +5264,8 @@ function debounce$2(fn3, delay = 500) {
5245
5264
  timeout = setTimeout(fn3, delay);
5246
5265
  }
5247
5266
  function keyToLabel(key) {
5248
- return (key == null ? void 0 : key.split("_").map((k2) => k2.charAt(0).toUpperCase() + k2.slice(1)).join(" ")) || key;
5267
+ if (key === void 0) return key;
5268
+ return key.split("_").map((k2) => k2.charAt(0).toUpperCase() + k2.slice(1)).join(" ") || key;
5249
5269
  }
5250
5270
  async function copyText(text, cb) {
5251
5271
  await navigator.clipboard.writeText(text);
@@ -5399,6 +5419,15 @@ function useBglSchema({ schema, showFields, data: data2 } = {}) {
5399
5419
  }
5400
5420
  return getFallbackSchema(data2, showFields);
5401
5421
  }
5422
+ function useLocalStorage(key, initialValue) {
5423
+ const storedValue = localStorage.getItem(key);
5424
+ const initial = storedValue ? JSON.parse(storedValue) : initialValue;
5425
+ const value = vue.ref(initial);
5426
+ vue.watch(() => value.value, (val) => {
5427
+ localStorage.setItem(key, JSON.stringify(val));
5428
+ }, { immediate: true, deep: true });
5429
+ return value;
5430
+ }
5402
5431
  const _sfc_main$O = /* @__PURE__ */ vue.defineComponent({
5403
5432
  __name: "MaterialIcon",
5404
5433
  props: {
@@ -6034,7 +6063,7 @@ function toValue(r2) {
6034
6063
  const isClient = typeof window !== "undefined" && typeof document !== "undefined";
6035
6064
  typeof WorkerGlobalScope !== "undefined" && globalThis instanceof WorkerGlobalScope;
6036
6065
  function getLifeCycleTarget(target) {
6037
- return target || vue.getCurrentInstance();
6066
+ return vue.getCurrentInstance();
6038
6067
  }
6039
6068
  function tryOnMounted(fn3, sync = true, target) {
6040
6069
  const instance = getLifeCycleTarget();
@@ -6330,7 +6359,7 @@ function useVerticalVirtualList(options, list) {
6330
6359
  containerRef
6331
6360
  };
6332
6361
  }
6333
- const _withScopeId$3 = (n2) => (vue.pushScopeId("data-v-73d79ea6"), n2 = n2(), vue.popScopeId(), n2);
6362
+ const _withScopeId$3 = (n2) => (vue.pushScopeId("data-v-84e79d8d"), n2 = n2(), vue.popScopeId(), n2);
6334
6363
  const _hoisted_1$C = {
6335
6364
  key: 0,
6336
6365
  class: "loading-table-wrapper z-99 h-100 w-100 absolute inset"
@@ -6364,7 +6393,7 @@ const _sfc_main$F = /* @__PURE__ */ vue.defineComponent({
6364
6393
  emits: /* @__PURE__ */ vue.mergeModels(["update:selectedItems", "orderBy", "select"], ["update:loading", "update:itemHeight"]),
6365
6394
  setup(__props, { emit: __emit }) {
6366
6395
  vue.useCssVars((_ctx) => ({
6367
- "59d71ad2": vue.unref(computedItemHiehgt)
6396
+ "2438e78c": vue.unref(computedItemHiehgt)
6368
6397
  }));
6369
6398
  const props2 = __props;
6370
6399
  const emit2 = __emit;
@@ -6465,7 +6494,11 @@ const _sfc_main$F = /* @__PURE__ */ vue.defineComponent({
6465
6494
  }
6466
6495
  function toggleSelectItem(item) {
6467
6496
  if (!computedSelectedItems.value.length) {
6468
- emit2("select", item);
6497
+ const obj = { ...item };
6498
+ Object.keys(obj).forEach((key) => {
6499
+ if (key.startsWith("_transformed_")) delete obj[key];
6500
+ });
6501
+ emit2("select", obj);
6469
6502
  return;
6470
6503
  }
6471
6504
  const index2 = computedSelectedItems.value.indexOf(item.id);
@@ -6565,7 +6598,7 @@ const _sfc_main$F = /* @__PURE__ */ vue.defineComponent({
6565
6598
  };
6566
6599
  }
6567
6600
  });
6568
- const TableSchema = /* @__PURE__ */ _export_sfc(_sfc_main$F, [["__scopeId", "data-v-73d79ea6"]]);
6601
+ const TableSchema = /* @__PURE__ */ _export_sfc(_sfc_main$F, [["__scopeId", "data-v-84e79d8d"]]);
6569
6602
  const _sfc_main$E = {};
6570
6603
  const _hoisted_1$B = { class: "flex space-between" };
6571
6604
  function _sfc_render$1(_ctx, _cache) {
@@ -6608,16 +6641,23 @@ const _hoisted_2$s = {
6608
6641
  const _hoisted_3$i = { class: "key" };
6609
6642
  const _hoisted_4$c = { class: "m-0" };
6610
6643
  const _hoisted_5$c = { key: 1 };
6611
- const _hoisted_6$7 = { class: "key" };
6612
- const _hoisted_7$3 = { class: "m-0" };
6613
- const _hoisted_8$1 = { class: "vlue" };
6614
- const _hoisted_9$1 = { class: "m-0" };
6644
+ const _hoisted_6$7 = {
6645
+ key: 0,
6646
+ class: "data-row"
6647
+ };
6648
+ const _hoisted_7$3 = { class: "key" };
6649
+ const _hoisted_8$1 = { class: "m-0" };
6650
+ const _hoisted_9$1 = {
6651
+ key: 0,
6652
+ class: "m-0"
6653
+ };
6615
6654
  const _sfc_main$C = /* @__PURE__ */ vue.defineComponent({
6616
6655
  __name: "DataPreview",
6617
6656
  props: /* @__PURE__ */ vue.mergeModels({
6618
6657
  showFields: {},
6619
6658
  schema: {},
6620
- title: {}
6659
+ title: {},
6660
+ excludeUnset: { type: Boolean }
6621
6661
  }, {
6622
6662
  "data": { default: {} },
6623
6663
  "dataModifiers": {}
@@ -6626,12 +6666,25 @@ const _sfc_main$C = /* @__PURE__ */ vue.defineComponent({
6626
6666
  setup(__props) {
6627
6667
  const props2 = __props;
6628
6668
  const itemData = vue.useModel(__props, "data");
6629
- const computedSchema = vue.computed(
6630
- () => getFallbackSchema(
6631
- [itemData.value],
6632
- props2.showFields
6633
- )
6634
- );
6669
+ function dataTransform(dataValue) {
6670
+ if (!dataValue) return dataValue;
6671
+ if (Array.isArray(dataValue)) return dataValue.map(dataTransform);
6672
+ if (typeof dataValue === "object") {
6673
+ Object.keys(dataValue).forEach((key) => {
6674
+ dataValue[key] = dataTransform(dataValue[key]);
6675
+ });
6676
+ }
6677
+ if (typeof dataValue === "string" && /\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}/.test(dataValue)) {
6678
+ const date2 = new Date(dataValue);
6679
+ return date2.toDateString();
6680
+ }
6681
+ return dataValue;
6682
+ }
6683
+ function isUnset(value) {
6684
+ if (!props2.excludeUnset) return false;
6685
+ return value === void 0 || value === null || value === "" || value.length === 0;
6686
+ }
6687
+ const computedSchema = vue.computed(() => getFallbackSchema([itemData.value], props2.showFields));
6635
6688
  return (_ctx, _cache) => {
6636
6689
  var _a2;
6637
6690
  return __props.data ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_1$A, [
@@ -6659,17 +6712,16 @@ const _sfc_main$C = /* @__PURE__ */ vue.defineComponent({
6659
6712
  }), 128)),
6660
6713
  !((_a2 = _ctx.schema) == null ? void 0 : _a2.length) ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_5$c, [
6661
6714
  (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(computedSchema.value, ({ id, label }) => {
6662
- return vue.openBlock(), vue.createElementBlock("div", {
6663
- key: id,
6664
- class: "data-row"
6665
- }, [
6666
- vue.createElementVNode("div", _hoisted_6$7, [
6667
- vue.createElementVNode("p", _hoisted_7$3, vue.toDisplayString(label), 1)
6668
- ]),
6669
- vue.createElementVNode("div", _hoisted_8$1, [
6670
- vue.createElementVNode("p", _hoisted_9$1, vue.toDisplayString(itemData.value[id ?? ""]), 1)
6671
- ])
6672
- ]);
6715
+ return vue.openBlock(), vue.createElementBlock(vue.Fragment, { key: id }, [
6716
+ !isUnset(itemData.value[id]) ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_6$7, [
6717
+ vue.createElementVNode("div", _hoisted_7$3, [
6718
+ vue.createElementVNode("p", _hoisted_8$1, vue.toDisplayString(label), 1)
6719
+ ]),
6720
+ vue.createElementVNode("div", null, [
6721
+ id ? (vue.openBlock(), vue.createElementBlock("p", _hoisted_9$1, vue.toDisplayString(dataTransform(itemData.value[id])), 1)) : vue.createCommentVNode("", true)
6722
+ ])
6723
+ ])) : vue.createCommentVNode("", true)
6724
+ ], 64);
6673
6725
  }), 128))
6674
6726
  ])) : vue.createCommentVNode("", true),
6675
6727
  vue.renderSlot(_ctx.$slots, "footer", {}, void 0, true)
@@ -6677,7 +6729,7 @@ const _sfc_main$C = /* @__PURE__ */ vue.defineComponent({
6677
6729
  };
6678
6730
  }
6679
6731
  });
6680
- const DataPreview = /* @__PURE__ */ _export_sfc(_sfc_main$C, [["__scopeId", "data-v-792f7ec0"]]);
6732
+ const DataPreview = /* @__PURE__ */ _export_sfc(_sfc_main$C, [["__scopeId", "data-v-d1cbc45f"]]);
6681
6733
  const _hoisted_1$z = {
6682
6734
  key: 0,
6683
6735
  class: "card_label"
@@ -17278,12 +17330,7 @@ function eachDayOfInterval(interval, options) {
17278
17330
  const endTime = reversed ? +startDate : +endDate;
17279
17331
  const currentDate = reversed ? endDate : startDate;
17280
17332
  currentDate.setHours(0, 0, 0, 0);
17281
- let step = (options == null ? void 0 : options.step) ?? 1;
17282
- if (!step) return [];
17283
- if (step < 0) {
17284
- step = -step;
17285
- reversed = !reversed;
17286
- }
17333
+ let step = 1;
17287
17334
  const dates = [];
17288
17335
  while (+currentDate <= endTime) {
17289
17336
  dates.push(toDate(currentDate));
@@ -17306,12 +17353,7 @@ function eachQuarterOfInterval(interval, options) {
17306
17353
  let reversed = +startDate > +endDate;
17307
17354
  const endTime = reversed ? +startOfQuarter(startDate) : +startOfQuarter(endDate);
17308
17355
  let currentDate = reversed ? startOfQuarter(endDate) : startOfQuarter(startDate);
17309
- let step = (options == null ? void 0 : options.step) ?? 1;
17310
- if (!step) return [];
17311
- if (step < 0) {
17312
- step = -step;
17313
- reversed = !reversed;
17314
- }
17356
+ let step = 1;
17315
17357
  const dates = [];
17316
17358
  while (+currentDate <= endTime) {
17317
17359
  dates.push(toDate(currentDate));
@@ -26157,10 +26199,8 @@ function isScrolledPast(el, elSide, parentSide) {
26157
26199
  var parent = getParentAutoScrollElement(el, true), elSideVal = getRect(el)[elSide];
26158
26200
  while (parent) {
26159
26201
  var parentSideVal = getRect(parent)[parentSide], visible = void 0;
26160
- if (parentSide === "top" || parentSide === "left") {
26202
+ {
26161
26203
  visible = elSideVal >= parentSideVal;
26162
- } else {
26163
- visible = elSideVal <= parentSideVal;
26164
26204
  }
26165
26205
  if (!visible) return parent;
26166
26206
  if (parent === getWindowScrollingElement()) break;
@@ -28858,7 +28898,7 @@ const _sfc_main$f = /* @__PURE__ */ vue.defineComponent({
28858
28898
  }
28859
28899
  });
28860
28900
  const RadioPillsInput = /* @__PURE__ */ _export_sfc(_sfc_main$f, [["__scopeId", "data-v-681173be"]]);
28861
- const _withScopeId$2 = (n2) => (vue.pushScopeId("data-v-5409803c"), n2 = n2(), vue.popScopeId(), n2);
28901
+ const _withScopeId$2 = (n2) => (vue.pushScopeId("data-v-6716fd45"), n2 = n2(), vue.popScopeId(), n2);
28862
28902
  const _hoisted_1$j = { class: "bagel-input" };
28863
28903
  const _hoisted_2$e = {
28864
28904
  key: 0,
@@ -29102,7 +29142,7 @@ const _sfc_main$e = /* @__PURE__ */ vue.defineComponent({
29102
29142
  };
29103
29143
  }
29104
29144
  });
29105
- const $el = /* @__PURE__ */ _export_sfc(_sfc_main$e, [["__scopeId", "data-v-5409803c"]]);
29145
+ const $el = /* @__PURE__ */ _export_sfc(_sfc_main$e, [["__scopeId", "data-v-6716fd45"]]);
29106
29146
  const _withScopeId$1 = (n2) => (vue.pushScopeId("data-v-eceeebfb"), n2 = n2(), vue.popScopeId(), n2);
29107
29147
  const _hoisted_1$i = ["title"];
29108
29148
  const _hoisted_2$d = /* @__PURE__ */ _withScopeId$1(() => /* @__PURE__ */ vue.createElementVNode("span", { class: "slider round" }, null, -1));
@@ -29535,7 +29575,7 @@ class Fragment {
29535
29575
  /**
29536
29576
  Find the index and inner offset corresponding to a given relative
29537
29577
  position in this fragment. The result object will be reused
29538
- (overwritten) the next time the function is called. (Not public.)
29578
+ (overwritten) the next time the function is called. @internal
29539
29579
  */
29540
29580
  findIndex(pos, round2 = -1) {
29541
29581
  if (pos == 0)
@@ -29741,7 +29781,9 @@ let Mark$1 = class Mark2 {
29741
29781
  let type3 = schema.marks[json.type];
29742
29782
  if (!type3)
29743
29783
  throw new RangeError(`There is no mark type ${json.type} in this schema`);
29744
- return type3.create(json.attrs);
29784
+ let mark = type3.create(json.attrs);
29785
+ type3.checkAttrs(mark.attrs);
29786
+ return mark;
29745
29787
  }
29746
29788
  /**
29747
29789
  Test whether two sets of marks are identical.
@@ -29875,8 +29917,6 @@ function removeRange(content, from2, to2) {
29875
29917
  function insertInto(content, dist, insert, parent) {
29876
29918
  let { index: index2, offset: offset2 } = content.findIndex(dist), child = content.maybeChild(index2);
29877
29919
  if (offset2 == dist || child.isText) {
29878
- if (parent && !parent.canReplace(index2, index2, insert))
29879
- return null;
29880
29920
  return content.cut(0, dist).append(insert).append(content.cut(dist));
29881
29921
  }
29882
29922
  let inner = insertInto(child.content, dist - offset2 - 1, insert);
@@ -30238,17 +30278,28 @@ class ResolvedPos {
30238
30278
  @internal
30239
30279
  */
30240
30280
  static resolveCached(doc2, pos) {
30241
- for (let i2 = 0; i2 < resolveCache.length; i2++) {
30242
- let cached2 = resolveCache[i2];
30243
- if (cached2.pos == pos && cached2.doc == doc2)
30244
- return cached2;
30281
+ let cache = resolveCache.get(doc2);
30282
+ if (cache) {
30283
+ for (let i2 = 0; i2 < cache.elts.length; i2++) {
30284
+ let elt = cache.elts[i2];
30285
+ if (elt.pos == pos)
30286
+ return elt;
30287
+ }
30288
+ } else {
30289
+ resolveCache.set(doc2, cache = new ResolveCache());
30245
30290
  }
30246
- let result2 = resolveCache[resolveCachePos] = ResolvedPos.resolve(doc2, pos);
30247
- resolveCachePos = (resolveCachePos + 1) % resolveCacheSize;
30291
+ let result2 = cache.elts[cache.i] = ResolvedPos.resolve(doc2, pos);
30292
+ cache.i = (cache.i + 1) % resolveCacheSize;
30248
30293
  return result2;
30249
30294
  }
30250
30295
  }
30251
- let resolveCache = [], resolveCachePos = 0, resolveCacheSize = 12;
30296
+ class ResolveCache {
30297
+ constructor() {
30298
+ this.elts = [];
30299
+ this.i = 0;
30300
+ }
30301
+ }
30302
+ const resolveCacheSize = 12, resolveCache = /* @__PURE__ */ new WeakMap();
30252
30303
  class NodeRange {
30253
30304
  /**
30254
30305
  Construct a node range. `$from` and `$to` should point into the
@@ -30634,13 +30685,17 @@ let Node$3 = class Node2 {
30634
30685
  }
30635
30686
  /**
30636
30687
  Check whether this node and its descendants conform to the
30637
- schema, and raise error when they do not.
30688
+ schema, and raise an exception when they do not.
30638
30689
  */
30639
30690
  check() {
30640
30691
  this.type.checkContent(this.content);
30692
+ this.type.checkAttrs(this.attrs);
30641
30693
  let copy2 = Mark$1.none;
30642
- for (let i2 = 0; i2 < this.marks.length; i2++)
30643
- copy2 = this.marks[i2].addToSet(copy2);
30694
+ for (let i2 = 0; i2 < this.marks.length; i2++) {
30695
+ let mark = this.marks[i2];
30696
+ mark.type.checkAttrs(mark.attrs);
30697
+ copy2 = mark.addToSet(copy2);
30698
+ }
30644
30699
  if (!Mark$1.sameSet(copy2, this.marks))
30645
30700
  throw new RangeError(`Invalid collection of marks for node ${this.type.name}: ${this.marks.map((m2) => m2.type.name)}`);
30646
30701
  this.content.forEach((node) => node.check());
@@ -30666,7 +30721,7 @@ let Node$3 = class Node2 {
30666
30721
  static fromJSON(schema, json) {
30667
30722
  if (!json)
30668
30723
  throw new RangeError("Invalid input for Node.fromJSON");
30669
- let marks = null;
30724
+ let marks = void 0;
30670
30725
  if (json.marks) {
30671
30726
  if (!Array.isArray(json.marks))
30672
30727
  throw new RangeError("Invalid mark data for Node.fromJSON");
@@ -30678,7 +30733,9 @@ let Node$3 = class Node2 {
30678
30733
  return schema.text(json.text, marks);
30679
30734
  }
30680
30735
  let content = Fragment.fromJSON(schema, json.content);
30681
- return schema.nodeType(json.type).create(json.attrs, content, marks);
30736
+ let node = schema.nodeType(json.type).create(json.attrs, content, marks);
30737
+ node.type.checkAttrs(node.attrs);
30738
+ return node;
30682
30739
  }
30683
30740
  };
30684
30741
  Node$3.prototype.text = void 0;
@@ -31160,6 +31217,16 @@ function computeAttrs(attrs, value) {
31160
31217
  }
31161
31218
  return built;
31162
31219
  }
31220
+ function checkAttrs(attrs, values3, type3, name) {
31221
+ for (let name2 in values3)
31222
+ if (!(name2 in attrs))
31223
+ throw new RangeError(`Unsupported attribute ${name2} for ${type3} of type ${name2}`);
31224
+ for (let name2 in attrs) {
31225
+ let attr = attrs[name2];
31226
+ if (attr.validate)
31227
+ attr.validate(values3[name2]);
31228
+ }
31229
+ }
31163
31230
  function initAttrs(attrs) {
31164
31231
  let result2 = /* @__PURE__ */ Object.create(null);
31165
31232
  if (attrs)
@@ -31289,7 +31356,7 @@ let NodeType$1 = class NodeType2 {
31289
31356
  }
31290
31357
  /**
31291
31358
  Returns true if the given fragment is valid content for this node
31292
- type with the given attributes.
31359
+ type.
31293
31360
  */
31294
31361
  validContent(content) {
31295
31362
  let result2 = this.contentMatch.matchFragment(content);
@@ -31310,6 +31377,12 @@ let NodeType$1 = class NodeType2 {
31310
31377
  throw new RangeError(`Invalid content for node ${this.name}: ${content.toString().slice(0, 50)}`);
31311
31378
  }
31312
31379
  /**
31380
+ @internal
31381
+ */
31382
+ checkAttrs(attrs) {
31383
+ checkAttrs(this.attrs, attrs, "node", this.name);
31384
+ }
31385
+ /**
31313
31386
  Check whether the given mark type is allowed in this node.
31314
31387
  */
31315
31388
  allowsMarkType(markType) {
@@ -31359,10 +31432,19 @@ let NodeType$1 = class NodeType2 {
31359
31432
  return result2;
31360
31433
  }
31361
31434
  };
31435
+ function validateType(type3) {
31436
+ let types = type3.split("|");
31437
+ return (value) => {
31438
+ let name = value === null ? "null" : typeof value;
31439
+ if (types.indexOf(name) < 0)
31440
+ throw new RangeError(`Expected value of type ${types}, got ${name}`);
31441
+ };
31442
+ }
31362
31443
  class Attribute {
31363
31444
  constructor(options) {
31364
31445
  this.hasDefault = Object.prototype.hasOwnProperty.call(options, "default");
31365
31446
  this.default = options.default;
31447
+ this.validate = typeof options.validate == "string" ? validateType(options.validate) : options.validate;
31366
31448
  }
31367
31449
  get isRequired() {
31368
31450
  return !this.hasDefault;
@@ -31421,6 +31503,12 @@ class MarkType {
31421
31503
  return set2[i2];
31422
31504
  }
31423
31505
  /**
31506
+ @internal
31507
+ */
31508
+ checkAttrs(attrs) {
31509
+ checkAttrs(this.attrs, attrs, "mark", this.name);
31510
+ }
31511
+ /**
31424
31512
  Queries whether a given mark type is
31425
31513
  [excluded](https://prosemirror.net/docs/ref/#model.MarkSpec.excludes) by this one.
31426
31514
  */
@@ -31433,6 +31521,7 @@ class Schema {
31433
31521
  Construct a schema from a schema [specification](https://prosemirror.net/docs/ref/#model.SchemaSpec).
31434
31522
  */
31435
31523
  constructor(spec) {
31524
+ this.linebreakReplacement = null;
31436
31525
  this.cached = /* @__PURE__ */ Object.create(null);
31437
31526
  let instanceSpec = this.spec = {};
31438
31527
  for (let prop3 in spec)
@@ -31446,6 +31535,13 @@ class Schema {
31446
31535
  let type3 = this.nodes[prop3], contentExpr = type3.spec.content || "", markExpr = type3.spec.marks;
31447
31536
  type3.contentMatch = contentExprCache[contentExpr] || (contentExprCache[contentExpr] = ContentMatch.parse(contentExpr, this.nodes));
31448
31537
  type3.inlineContent = type3.contentMatch.inlineContent;
31538
+ if (type3.spec.linebreakReplacement) {
31539
+ if (this.linebreakReplacement)
31540
+ throw new RangeError("Multiple linebreak nodes defined");
31541
+ if (!type3.isInline || !type3.isLeaf)
31542
+ throw new RangeError("Linebreak replacement nodes must be inline leaf nodes");
31543
+ this.linebreakReplacement = type3;
31544
+ }
31449
31545
  type3.markSet = markExpr == "_" ? null : markExpr ? gatherMarks(this, markExpr.split(" ")) : markExpr == "" || !type3.inlineContent ? [] : null;
31450
31546
  }
31451
31547
  for (let prop3 in this.marks) {
@@ -31530,6 +31626,12 @@ function gatherMarks(schema, marks) {
31530
31626
  }
31531
31627
  return found2;
31532
31628
  }
31629
+ function isTagRule(rule) {
31630
+ return rule.tag != null;
31631
+ }
31632
+ function isStyleRule(rule) {
31633
+ return rule.style != null;
31634
+ }
31533
31635
  class DOMParser {
31534
31636
  /**
31535
31637
  Create a parser that targets the given schema, using the given
@@ -31540,11 +31642,16 @@ class DOMParser {
31540
31642
  this.rules = rules;
31541
31643
  this.tags = [];
31542
31644
  this.styles = [];
31645
+ let matchedStyles = this.matchedStyles = [];
31543
31646
  rules.forEach((rule) => {
31544
- if (rule.tag)
31647
+ if (isTagRule(rule)) {
31545
31648
  this.tags.push(rule);
31546
- else if (rule.style)
31649
+ } else if (isStyleRule(rule)) {
31650
+ let prop3 = /[^=]*/.exec(rule.style)[0];
31651
+ if (matchedStyles.indexOf(prop3) < 0)
31652
+ matchedStyles.push(prop3);
31547
31653
  this.styles.push(rule);
31654
+ }
31548
31655
  });
31549
31656
  this.normalizeLists = !this.tags.some((r2) => {
31550
31657
  if (!/^(ul|ol)\b/.test(r2.tag) || !r2.node)
@@ -31804,10 +31911,10 @@ class ParseContext {
31804
31911
  this.addElement(dom);
31805
31912
  }
31806
31913
  withStyleRules(dom, f2) {
31807
- let style2 = dom.getAttribute("style");
31808
- if (!style2)
31914
+ let style2 = dom.style;
31915
+ if (!style2 || !style2.length)
31809
31916
  return f2();
31810
- let marks = this.readStyles(parseStyles(style2));
31917
+ let marks = this.readStyles(dom.style);
31811
31918
  if (!marks)
31812
31919
  return;
31813
31920
  let [addMarks, removeMarks] = marks, top2 = this.top;
@@ -31901,27 +32008,30 @@ class ParseContext {
31901
32008
  // had a rule with `ignore` set.
31902
32009
  readStyles(styles) {
31903
32010
  let add2 = Mark$1.none, remove2 = Mark$1.none;
31904
- for (let i2 = 0; i2 < styles.length; i2 += 2) {
31905
- for (let after = void 0; ; ) {
31906
- let rule = this.parser.matchStyle(styles[i2], styles[i2 + 1], this, after);
31907
- if (!rule)
31908
- break;
31909
- if (rule.ignore)
31910
- return null;
31911
- if (rule.clearMark) {
31912
- this.top.pendingMarks.concat(this.top.activeMarks).forEach((m2) => {
31913
- if (rule.clearMark(m2))
31914
- remove2 = m2.addToSet(remove2);
31915
- });
31916
- } else {
31917
- add2 = this.parser.schema.marks[rule.mark].create(rule.attrs).addToSet(add2);
31918
- }
31919
- if (rule.consuming === false)
31920
- after = rule;
31921
- else
31922
- break;
32011
+ if (styles.length)
32012
+ for (let i2 = 0; i2 < this.parser.matchedStyles.length; i2++) {
32013
+ let name = this.parser.matchedStyles[i2], value = styles.getPropertyValue(name);
32014
+ if (value)
32015
+ for (let after = void 0; ; ) {
32016
+ let rule = this.parser.matchStyle(name, value, this, after);
32017
+ if (!rule)
32018
+ break;
32019
+ if (rule.ignore)
32020
+ return null;
32021
+ if (rule.clearMark) {
32022
+ this.top.pendingMarks.concat(this.top.activeMarks).forEach((m2) => {
32023
+ if (rule.clearMark(m2))
32024
+ remove2 = m2.addToSet(remove2);
32025
+ });
32026
+ } else {
32027
+ add2 = this.parser.schema.marks[rule.mark].create(rule.attrs).addToSet(add2);
32028
+ }
32029
+ if (rule.consuming === false)
32030
+ after = rule;
32031
+ else
32032
+ break;
32033
+ }
31923
32034
  }
31924
- }
31925
32035
  return [add2, remove2];
31926
32036
  }
31927
32037
  // Look up a handler for the given node. If none are found, return
@@ -32190,12 +32300,6 @@ function normalizeList(dom) {
32190
32300
  function matches(dom, selector2) {
32191
32301
  return (dom.matches || dom.msMatchesSelector || dom.webkitMatchesSelector || dom.mozMatchesSelector).call(dom, selector2);
32192
32302
  }
32193
- function parseStyles(style2) {
32194
- let re2 = /\s*([\w-]+)\s*:\s*([^;]+)/g, m2, result2 = [];
32195
- while (m2 = re2.exec(style2))
32196
- result2.push(m2[1], m2[2].trim());
32197
- return result2;
32198
- }
32199
32303
  function copy$2(obj) {
32200
32304
  let copy2 = {};
32201
32305
  for (let prop3 in obj)
@@ -32286,7 +32390,7 @@ class DOMSerializer {
32286
32390
  @internal
32287
32391
  */
32288
32392
  serializeNodeInner(node, options) {
32289
- let { dom, contentDOM } = DOMSerializer.renderSpec(doc$1(options), this.nodes[node.type.name](node));
32393
+ let { dom, contentDOM } = renderSpec(doc$1(options), this.nodes[node.type.name](node), null, node.attrs);
32290
32394
  if (contentDOM) {
32291
32395
  if (node.isLeaf)
32292
32396
  throw new RangeError("Content hole not allowed in a leaf node spec");
@@ -32317,7 +32421,7 @@ class DOMSerializer {
32317
32421
  */
32318
32422
  serializeMark(mark, inline, options = {}) {
32319
32423
  let toDOM = this.marks[mark.type.name];
32320
- return toDOM && DOMSerializer.renderSpec(doc$1(options), toDOM(mark, inline));
32424
+ return toDOM && renderSpec(doc$1(options), toDOM(mark, inline), null, mark.attrs);
32321
32425
  }
32322
32426
  /**
32323
32427
  Render an [output spec](https://prosemirror.net/docs/ref/#model.DOMOutputSpec) to a DOM node. If
@@ -32325,48 +32429,7 @@ class DOMSerializer {
32325
32429
  node with the hole.
32326
32430
  */
32327
32431
  static renderSpec(doc2, structure, xmlNS = null) {
32328
- if (typeof structure == "string")
32329
- return { dom: doc2.createTextNode(structure) };
32330
- if (structure.nodeType != null)
32331
- return { dom: structure };
32332
- if (structure.dom && structure.dom.nodeType != null)
32333
- return structure;
32334
- let tagName = structure[0], space = tagName.indexOf(" ");
32335
- if (space > 0) {
32336
- xmlNS = tagName.slice(0, space);
32337
- tagName = tagName.slice(space + 1);
32338
- }
32339
- let contentDOM;
32340
- let dom = xmlNS ? doc2.createElementNS(xmlNS, tagName) : doc2.createElement(tagName);
32341
- let attrs = structure[1], start2 = 1;
32342
- if (attrs && typeof attrs == "object" && attrs.nodeType == null && !Array.isArray(attrs)) {
32343
- start2 = 2;
32344
- for (let name in attrs)
32345
- if (attrs[name] != null) {
32346
- let space2 = name.indexOf(" ");
32347
- if (space2 > 0)
32348
- dom.setAttributeNS(name.slice(0, space2), name.slice(space2 + 1), attrs[name]);
32349
- else
32350
- dom.setAttribute(name, attrs[name]);
32351
- }
32352
- }
32353
- for (let i2 = start2; i2 < structure.length; i2++) {
32354
- let child = structure[i2];
32355
- if (child === 0) {
32356
- if (i2 < structure.length - 1 || i2 > start2)
32357
- throw new RangeError("Content hole must be the only child of its parent node");
32358
- return { dom, contentDOM: dom };
32359
- } else {
32360
- let { dom: inner, contentDOM: innerContent } = DOMSerializer.renderSpec(doc2, child, xmlNS);
32361
- dom.appendChild(inner);
32362
- if (innerContent) {
32363
- if (contentDOM)
32364
- throw new RangeError("Multiple content holes");
32365
- contentDOM = innerContent;
32366
- }
32367
- }
32368
- }
32369
- return { dom, contentDOM };
32432
+ return renderSpec(doc2, structure, xmlNS);
32370
32433
  }
32371
32434
  /**
32372
32435
  Build a serializer using the [`toDOM`](https://prosemirror.net/docs/ref/#model.NodeSpec.toDOM)
@@ -32404,6 +32467,84 @@ function gatherToDOM(obj) {
32404
32467
  function doc$1(options) {
32405
32468
  return options.document || window.document;
32406
32469
  }
32470
+ const suspiciousAttributeCache = /* @__PURE__ */ new WeakMap();
32471
+ function suspiciousAttributes(attrs) {
32472
+ let value = suspiciousAttributeCache.get(attrs);
32473
+ if (value === void 0)
32474
+ suspiciousAttributeCache.set(attrs, value = suspiciousAttributesInner(attrs));
32475
+ return value;
32476
+ }
32477
+ function suspiciousAttributesInner(attrs) {
32478
+ let result2 = null;
32479
+ function scan(value) {
32480
+ if (value && typeof value == "object") {
32481
+ if (Array.isArray(value)) {
32482
+ if (typeof value[0] == "string") {
32483
+ if (!result2)
32484
+ result2 = [];
32485
+ result2.push(value);
32486
+ } else {
32487
+ for (let i2 = 0; i2 < value.length; i2++)
32488
+ scan(value[i2]);
32489
+ }
32490
+ } else {
32491
+ for (let prop3 in value)
32492
+ scan(value[prop3]);
32493
+ }
32494
+ }
32495
+ }
32496
+ scan(attrs);
32497
+ return result2;
32498
+ }
32499
+ function renderSpec(doc2, structure, xmlNS, blockArraysIn) {
32500
+ if (typeof structure == "string")
32501
+ return { dom: doc2.createTextNode(structure) };
32502
+ if (structure.nodeType != null)
32503
+ return { dom: structure };
32504
+ if (structure.dom && structure.dom.nodeType != null)
32505
+ return structure;
32506
+ let tagName = structure[0], suspicious;
32507
+ if (typeof tagName != "string")
32508
+ throw new RangeError("Invalid array passed to renderSpec");
32509
+ if (blockArraysIn && (suspicious = suspiciousAttributes(blockArraysIn)) && suspicious.indexOf(structure) > -1)
32510
+ throw new RangeError("Using an array from an attribute object as a DOM spec. This may be an attempted cross site scripting attack.");
32511
+ let space = tagName.indexOf(" ");
32512
+ if (space > 0) {
32513
+ xmlNS = tagName.slice(0, space);
32514
+ tagName = tagName.slice(space + 1);
32515
+ }
32516
+ let contentDOM;
32517
+ let dom = xmlNS ? doc2.createElementNS(xmlNS, tagName) : doc2.createElement(tagName);
32518
+ let attrs = structure[1], start2 = 1;
32519
+ if (attrs && typeof attrs == "object" && attrs.nodeType == null && !Array.isArray(attrs)) {
32520
+ start2 = 2;
32521
+ for (let name in attrs)
32522
+ if (attrs[name] != null) {
32523
+ let space2 = name.indexOf(" ");
32524
+ if (space2 > 0)
32525
+ dom.setAttributeNS(name.slice(0, space2), name.slice(space2 + 1), attrs[name]);
32526
+ else
32527
+ dom.setAttribute(name, attrs[name]);
32528
+ }
32529
+ }
32530
+ for (let i2 = start2; i2 < structure.length; i2++) {
32531
+ let child = structure[i2];
32532
+ if (child === 0) {
32533
+ if (i2 < structure.length - 1 || i2 > start2)
32534
+ throw new RangeError("Content hole must be the only child of its parent node");
32535
+ return { dom, contentDOM: dom };
32536
+ } else {
32537
+ let { dom: inner, contentDOM: innerContent } = renderSpec(doc2, child, xmlNS, blockArraysIn);
32538
+ dom.appendChild(inner);
32539
+ if (innerContent) {
32540
+ if (contentDOM)
32541
+ throw new RangeError("Multiple content holes");
32542
+ contentDOM = innerContent;
32543
+ }
32544
+ }
32545
+ }
32546
+ return { dom, contentDOM };
32547
+ }
32407
32548
  const lower16 = 65535;
32408
32549
  const factor16 = Math.pow(2, 16);
32409
32550
  function makeRecover(index2, offset2) {
@@ -33063,7 +33204,8 @@ class ReplaceAroundStep extends Step$1 {
33063
33204
  }
33064
33205
  map(mapping) {
33065
33206
  let from2 = mapping.mapResult(this.from, 1), to2 = mapping.mapResult(this.to, -1);
33066
- let gapFrom = mapping.map(this.gapFrom, -1), gapTo = mapping.map(this.gapTo, 1);
33207
+ let gapFrom = this.from == this.gapFrom ? from2.pos : mapping.map(this.gapFrom, -1);
33208
+ let gapTo = this.to == this.gapTo ? to2.pos : mapping.map(this.gapTo, 1);
33067
33209
  if (from2.deletedAcross && to2.deletedAcross || gapFrom < from2.pos || gapTo > to2.pos)
33068
33210
  return null;
33069
33211
  return new ReplaceAroundStep(from2.pos, to2.pos, gapFrom, gapTo, this.slice, this.insert, this.structure);
@@ -33176,7 +33318,7 @@ function removeMark(tr2, from2, to2, mark) {
33176
33318
  });
33177
33319
  matched.forEach((m2) => tr2.step(new RemoveMarkStep(m2.from, m2.to, m2.style)));
33178
33320
  }
33179
- function clearIncompatible(tr2, pos, parentType, match2 = parentType.contentMatch) {
33321
+ function clearIncompatible(tr2, pos, parentType, match2 = parentType.contentMatch, clearNewlines = true) {
33180
33322
  let node = tr2.doc.nodeAt(pos);
33181
33323
  let replSteps = [], cur = pos + 1;
33182
33324
  for (let i2 = 0; i2 < node.childCount; i2++) {
@@ -33189,7 +33331,7 @@ function clearIncompatible(tr2, pos, parentType, match2 = parentType.contentMatc
33189
33331
  for (let j2 = 0; j2 < child.marks.length; j2++)
33190
33332
  if (!parentType.allowsMarkType(child.marks[j2].type))
33191
33333
  tr2.step(new RemoveMarkStep(cur, end2, child.marks[j2]));
33192
- if (child.isText && !parentType.spec.code) {
33334
+ if (clearNewlines && child.isText && parentType.whitespace != "pre") {
33193
33335
  let m2, newline = /\r?\n|\r/g, slice4;
33194
33336
  while (m2 = newline.exec(child.text)) {
33195
33337
  if (!slice4)
@@ -33298,14 +33440,45 @@ function setBlockType$1(tr2, from2, to2, type3, attrs) {
33298
33440
  let mapFrom = tr2.steps.length;
33299
33441
  tr2.doc.nodesBetween(from2, to2, (node, pos) => {
33300
33442
  if (node.isTextblock && !node.hasMarkup(type3, attrs) && canChangeType(tr2.doc, tr2.mapping.slice(mapFrom).map(pos), type3)) {
33301
- tr2.clearIncompatible(tr2.mapping.slice(mapFrom).map(pos, 1), type3);
33443
+ let convertNewlines = null;
33444
+ if (type3.schema.linebreakReplacement) {
33445
+ let pre = type3.whitespace == "pre", supportLinebreak = !!type3.contentMatch.matchType(type3.schema.linebreakReplacement);
33446
+ if (pre && !supportLinebreak)
33447
+ convertNewlines = false;
33448
+ else if (!pre && supportLinebreak)
33449
+ convertNewlines = true;
33450
+ }
33451
+ if (convertNewlines === false)
33452
+ replaceLinebreaks(tr2, node, pos, mapFrom);
33453
+ clearIncompatible(tr2, tr2.mapping.slice(mapFrom).map(pos, 1), type3, void 0, convertNewlines === null);
33302
33454
  let mapping = tr2.mapping.slice(mapFrom);
33303
33455
  let startM = mapping.map(pos, 1), endM = mapping.map(pos + node.nodeSize, 1);
33304
33456
  tr2.step(new ReplaceAroundStep(startM, endM, startM + 1, endM - 1, new Slice(Fragment.from(type3.create(attrs, null, node.marks)), 0, 0), 1, true));
33457
+ if (convertNewlines === true)
33458
+ replaceNewlines(tr2, node, pos, mapFrom);
33305
33459
  return false;
33306
33460
  }
33307
33461
  });
33308
33462
  }
33463
+ function replaceNewlines(tr2, node, pos, mapFrom) {
33464
+ node.forEach((child, offset2) => {
33465
+ if (child.isText) {
33466
+ let m2, newline = /\r?\n|\r/g;
33467
+ while (m2 = newline.exec(child.text)) {
33468
+ let start2 = tr2.mapping.slice(mapFrom).map(pos + 1 + offset2 + m2.index);
33469
+ tr2.replaceWith(start2, start2 + 1, node.type.schema.linebreakReplacement.create());
33470
+ }
33471
+ }
33472
+ });
33473
+ }
33474
+ function replaceLinebreaks(tr2, node, pos, mapFrom) {
33475
+ node.forEach((child, offset2) => {
33476
+ if (child.type == child.type.schema.linebreakReplacement) {
33477
+ let start2 = tr2.mapping.slice(mapFrom).map(pos + 1 + offset2);
33478
+ tr2.replaceWith(start2, start2 + 1, node.type.schema.text("\n"));
33479
+ }
33480
+ });
33481
+ }
33309
33482
  function canChangeType(doc2, pos, type3) {
33310
33483
  let $pos = doc2.resolve(pos), index2 = $pos.index();
33311
33484
  return $pos.parent.canReplaceWith(index2, index2 + 1, type3);
@@ -35071,6 +35244,9 @@ const textRange = function(node, from2, to2) {
35071
35244
  range2.setStart(node, from2 || 0);
35072
35245
  return range2;
35073
35246
  };
35247
+ const clearReusedRange = function() {
35248
+ reusedRange = null;
35249
+ };
35074
35250
  const isEquivalentPosition = function(node, off2, targetNode, targetOff) {
35075
35251
  return targetNode && (scanFor(node, off2, targetNode, targetOff, -1) || scanFor(node, off2, targetNode, targetOff, 1));
35076
35252
  };
@@ -35098,6 +35274,40 @@ function scanFor(node, off2, targetNode, targetOff, dir) {
35098
35274
  function nodeSize(node) {
35099
35275
  return node.nodeType == 3 ? node.nodeValue.length : node.childNodes.length;
35100
35276
  }
35277
+ function textNodeBefore$1(node, offset2) {
35278
+ for (; ; ) {
35279
+ if (node.nodeType == 3 && offset2)
35280
+ return node;
35281
+ if (node.nodeType == 1 && offset2 > 0) {
35282
+ if (node.contentEditable == "false")
35283
+ return null;
35284
+ node = node.childNodes[offset2 - 1];
35285
+ offset2 = nodeSize(node);
35286
+ } else if (node.parentNode && !hasBlockDesc(node)) {
35287
+ offset2 = domIndex(node);
35288
+ node = node.parentNode;
35289
+ } else {
35290
+ return null;
35291
+ }
35292
+ }
35293
+ }
35294
+ function textNodeAfter$1(node, offset2) {
35295
+ for (; ; ) {
35296
+ if (node.nodeType == 3 && offset2 < node.nodeValue.length)
35297
+ return node;
35298
+ if (node.nodeType == 1 && offset2 < node.childNodes.length) {
35299
+ if (node.contentEditable == "false")
35300
+ return null;
35301
+ node = node.childNodes[offset2];
35302
+ offset2 = 0;
35303
+ } else if (node.parentNode && !hasBlockDesc(node)) {
35304
+ offset2 = domIndex(node) + 1;
35305
+ node = node.parentNode;
35306
+ } else {
35307
+ return null;
35308
+ }
35309
+ }
35310
+ }
35101
35311
  function isOnEdge(node, offset2, parent) {
35102
35312
  for (let atStart = offset2 == 0, atEnd = offset2 == nodeSize(node); atStart || atEnd; ) {
35103
35313
  if (node == parent)
@@ -35169,6 +35379,14 @@ const android = /Android \d/.test(agent);
35169
35379
  const webkit = !!doc && "webkitFontSmoothing" in doc.documentElement.style;
35170
35380
  const webkit_version = webkit ? +(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent) || [0, 0])[1] : 0;
35171
35381
  function windowRect(doc2) {
35382
+ let vp = doc2.defaultView && doc2.defaultView.visualViewport;
35383
+ if (vp)
35384
+ return {
35385
+ left: 0,
35386
+ right: vp.width,
35387
+ top: 0,
35388
+ bottom: vp.height
35389
+ };
35172
35390
  return {
35173
35391
  left: 0,
35174
35392
  right: doc2.documentElement.clientWidth,
@@ -35370,14 +35588,14 @@ function posFromCaret(view, node, offset2, coords) {
35370
35588
  let desc = view.docView.nearestDesc(cur, true);
35371
35589
  if (!desc)
35372
35590
  return null;
35373
- if (desc.dom.nodeType == 1 && (desc.node.isBlock && desc.parent && !sawBlock || !desc.contentDOM)) {
35591
+ if (desc.dom.nodeType == 1 && (desc.node.isBlock && desc.parent || !desc.contentDOM)) {
35374
35592
  let rect = desc.dom.getBoundingClientRect();
35375
- if (desc.node.isBlock && desc.parent && !sawBlock) {
35376
- sawBlock = true;
35377
- if (rect.left > coords.left || rect.top > coords.top)
35593
+ if (desc.node.isBlock && desc.parent) {
35594
+ if (!sawBlock && rect.left > coords.left || rect.top > coords.top)
35378
35595
  outsideBlock = desc.posBefore;
35379
- else if (rect.right < coords.left || rect.bottom < coords.top)
35596
+ else if (!sawBlock && rect.right < coords.left || rect.bottom < coords.top)
35380
35597
  outsideBlock = desc.posAfter;
35598
+ sawBlock = true;
35381
35599
  }
35382
35600
  if (!desc.contentDOM && outsideBlock < 0 && !desc.node.isText) {
35383
35601
  let before = desc.node.isBlock ? coords.top < (rect.top + rect.bottom) / 2 : coords.left < (rect.left + rect.right) / 2;
@@ -35992,6 +36210,9 @@ class ViewDesc {
35992
36210
  get ignoreForCoords() {
35993
36211
  return false;
35994
36212
  }
36213
+ isText(text) {
36214
+ return false;
36215
+ }
35995
36216
  }
35996
36217
  class WidgetViewDesc extends ViewDesc {
35997
36218
  constructor(parent, widget, view, pos) {
@@ -36230,8 +36451,7 @@ class NodeViewDesc extends ViewDesc {
36230
36451
  let { from: from2, to: to2 } = view.state.selection;
36231
36452
  if (!(view.state.selection instanceof TextSelection) || from2 < pos || to2 > pos + this.node.content.size)
36232
36453
  return null;
36233
- let sel = view.domSelectionRange();
36234
- let textNode = nearbyTextNode(sel.focusNode, sel.focusOffset);
36454
+ let textNode = view.input.compositionNode;
36235
36455
  if (!textNode || !this.dom.contains(textNode.parentNode))
36236
36456
  return null;
36237
36457
  if (this.node.inlineContent) {
@@ -36297,10 +36517,11 @@ class NodeViewDesc extends ViewDesc {
36297
36517
  }
36298
36518
  // Remove selected node marking from this node.
36299
36519
  deselectNode() {
36300
- if (this.nodeDOM.nodeType == 1)
36520
+ if (this.nodeDOM.nodeType == 1) {
36301
36521
  this.nodeDOM.classList.remove("ProseMirror-selectednode");
36302
- if (this.contentDOM || !this.node.type.spec.draggable)
36303
- this.dom.removeAttribute("draggable");
36522
+ if (this.contentDOM || !this.node.type.spec.draggable)
36523
+ this.dom.removeAttribute("draggable");
36524
+ }
36304
36525
  }
36305
36526
  get domAtom() {
36306
36527
  return this.node.isAtom;
@@ -36366,6 +36587,9 @@ class TextViewDesc extends NodeViewDesc {
36366
36587
  get domAtom() {
36367
36588
  return false;
36368
36589
  }
36590
+ isText(text) {
36591
+ return this.node.text == text;
36592
+ }
36369
36593
  }
36370
36594
  class TrailingHackViewDesc extends ViewDesc {
36371
36595
  parseRule() {
@@ -36881,23 +37105,6 @@ function iosHacks(dom) {
36881
37105
  dom.style.cssText = oldCSS;
36882
37106
  }
36883
37107
  }
36884
- function nearbyTextNode(node, offset2) {
36885
- for (; ; ) {
36886
- if (node.nodeType == 3)
36887
- return node;
36888
- if (node.nodeType == 1 && offset2 > 0) {
36889
- if (node.childNodes.length > offset2 && node.childNodes[offset2].nodeType == 3)
36890
- return node.childNodes[offset2];
36891
- node = node.childNodes[offset2 - 1];
36892
- offset2 = nodeSize(node);
36893
- } else if (node.nodeType == 1 && offset2 < node.childNodes.length) {
36894
- node = node.childNodes[offset2];
36895
- offset2 = 0;
36896
- } else {
36897
- return null;
36898
- }
36899
- }
36900
- }
36901
37108
  function findTextInFragment(frag, text, from2, to2) {
36902
37109
  for (let i2 = 0, pos = 0; i2 < frag.childCount && pos <= to2; ) {
36903
37110
  let child = frag.child(i2++), childStart = pos;
@@ -37472,7 +37679,7 @@ function serializeForClipboard(view, slice4) {
37472
37679
  if (firstChild && firstChild.nodeType == 1)
37473
37680
  firstChild.setAttribute("data-pm-slice", `${openStart} ${openEnd}${wrappers ? ` -${wrappers}` : ""} ${JSON.stringify(context)}`);
37474
37681
  let text = view.someProp("clipboardTextSerializer", (f2) => f2(slice4, view)) || slice4.content.textBetween(0, slice4.content.size, "\n\n");
37475
- return { dom: wrap2, text };
37682
+ return { dom: wrap2, text, slice: slice4 };
37476
37683
  }
37477
37684
  function parseFromClipboard(view, text, html, plainText, $context) {
37478
37685
  let inCode = $context.parent.type.spec.code;
@@ -37692,6 +37899,7 @@ class InputState {
37692
37899
  this.lastTouch = 0;
37693
37900
  this.lastAndroidDelete = 0;
37694
37901
  this.composing = false;
37902
+ this.compositionNode = null;
37695
37903
  this.composingTimeout = -1;
37696
37904
  this.compositionNodes = [];
37697
37905
  this.compositionEndedAt = -2e8;
@@ -37819,8 +38027,7 @@ function updateSelection(view, selection, origin2) {
37819
38027
  if (!view.focused)
37820
38028
  view.focus();
37821
38029
  let tr2 = view.state.tr.setSelection(selection);
37822
- if (origin2 == "pointer")
37823
- tr2.setMeta("pointer", true);
38030
+ tr2.setMeta("pointer", true);
37824
38031
  view.dispatch(tr2);
37825
38032
  }
37826
38033
  function selectClickedLeaf(view, inside) {
@@ -37828,7 +38035,7 @@ function selectClickedLeaf(view, inside) {
37828
38035
  return false;
37829
38036
  let $pos = view.state.doc.resolve(inside), node = $pos.nodeAfter;
37830
38037
  if (node && node.isAtom && NodeSelection.isSelectable(node)) {
37831
- updateSelection(view, new NodeSelection($pos), "pointer");
38038
+ updateSelection(view, new NodeSelection($pos));
37832
38039
  return true;
37833
38040
  }
37834
38041
  return false;
@@ -37851,7 +38058,7 @@ function selectClickedNode(view, inside) {
37851
38058
  }
37852
38059
  }
37853
38060
  if (selectAt != null) {
37854
- updateSelection(view, NodeSelection.create(view.state.doc, selectAt), "pointer");
38061
+ updateSelection(view, NodeSelection.create(view.state.doc, selectAt));
37855
38062
  return true;
37856
38063
  } else {
37857
38064
  return false;
@@ -37872,7 +38079,7 @@ function defaultTripleClick(view, inside, event) {
37872
38079
  let doc2 = view.state.doc;
37873
38080
  if (inside == -1) {
37874
38081
  if (doc2.inlineContent) {
37875
- updateSelection(view, TextSelection.create(doc2, 0, doc2.content.size), "pointer");
38082
+ updateSelection(view, TextSelection.create(doc2, 0, doc2.content.size));
37876
38083
  return true;
37877
38084
  }
37878
38085
  return false;
@@ -37882,9 +38089,9 @@ function defaultTripleClick(view, inside, event) {
37882
38089
  let node = i2 > $pos.depth ? $pos.nodeAfter : $pos.node(i2);
37883
38090
  let nodePos = $pos.before(i2);
37884
38091
  if (node.inlineContent)
37885
- updateSelection(view, TextSelection.create(doc2, nodePos + 1, nodePos + 1 + node.content.size), "pointer");
38092
+ updateSelection(view, TextSelection.create(doc2, nodePos + 1, nodePos + 1 + node.content.size));
37886
38093
  else if (NodeSelection.isSelectable(node))
37887
- updateSelection(view, NodeSelection.create(doc2, nodePos), "pointer");
38094
+ updateSelection(view, NodeSelection.create(doc2, nodePos));
37888
38095
  else
37889
38096
  continue;
37890
38097
  return true;
@@ -37941,7 +38148,7 @@ class MouseDown {
37941
38148
  }
37942
38149
  const target = flushed ? null : event.target;
37943
38150
  const targetDesc = target ? view.docView.nearestDesc(target, true) : null;
37944
- this.target = targetDesc ? targetDesc.dom : null;
38151
+ this.target = targetDesc && targetDesc.dom.nodeType == 1 ? targetDesc.dom : null;
37945
38152
  let { selection } = view.state;
37946
38153
  if (event.button == 0 && targetNode.type.spec.draggable && targetNode.type.spec.selectable !== false || selection instanceof NodeSelection && selection.from <= targetPos && selection.to > targetPos)
37947
38154
  this.mightDrag = {
@@ -38001,7 +38208,7 @@ class MouseDown {
38001
38208
  // thus doesn't get a reaction from ProseMirror. This
38002
38209
  // works around that.
38003
38210
  chrome && !this.view.state.selection.visible && Math.min(Math.abs(pos.pos - this.view.state.selection.from), Math.abs(pos.pos - this.view.state.selection.to)) <= 2)) {
38004
- updateSelection(this.view, Selection$1.near(this.view.state.doc.resolve(pos.pos)), "pointer");
38211
+ updateSelection(this.view, Selection$1.near(this.view.state.doc.resolve(pos.pos)));
38005
38212
  event.preventDefault();
38006
38213
  } else {
38007
38214
  setSelectionOrigin(this.view, "pointer");
@@ -38073,6 +38280,7 @@ editHandlers.compositionend = (view, event) => {
38073
38280
  view.input.composing = false;
38074
38281
  view.input.compositionEndedAt = event.timeStamp;
38075
38282
  view.input.compositionPendingChanges = view.domObserver.pendingRecords().length ? view.input.compositionID : 0;
38283
+ view.input.compositionNode = null;
38076
38284
  if (view.input.compositionPendingChanges)
38077
38285
  Promise.resolve().then(() => view.domObserver.flush());
38078
38286
  view.input.compositionID++;
@@ -38092,6 +38300,26 @@ function clearComposition(view) {
38092
38300
  while (view.input.compositionNodes.length > 0)
38093
38301
  view.input.compositionNodes.pop().markParentsDirty();
38094
38302
  }
38303
+ function findCompositionNode(view) {
38304
+ let sel = view.domSelectionRange();
38305
+ if (!sel.focusNode)
38306
+ return null;
38307
+ let textBefore = textNodeBefore$1(sel.focusNode, sel.focusOffset);
38308
+ let textAfter = textNodeAfter$1(sel.focusNode, sel.focusOffset);
38309
+ if (textBefore && textAfter && textBefore != textAfter) {
38310
+ let descAfter = textAfter.pmViewDesc, lastChanged = view.domObserver.lastChangedTextNode;
38311
+ if (textBefore == lastChanged || textAfter == lastChanged)
38312
+ return lastChanged;
38313
+ if (!descAfter || !descAfter.isText(textAfter.nodeValue)) {
38314
+ return textAfter;
38315
+ } else if (view.input.compositionNode == textAfter) {
38316
+ let descBefore = textBefore.pmViewDesc;
38317
+ if (!(!descBefore || !descBefore.isText(textBefore.nodeValue)))
38318
+ return textAfter;
38319
+ }
38320
+ }
38321
+ return textBefore || textAfter;
38322
+ }
38095
38323
  function timestampFromCustomEvent() {
38096
38324
  let event = document.createEvent("Event");
38097
38325
  event.initEvent("event", true, true);
@@ -38226,7 +38454,8 @@ handlers.dragstart = (view, _event) => {
38226
38454
  if (desc && desc.node.type.spec.draggable && desc != view.docView)
38227
38455
  node = NodeSelection.create(view.state.doc, desc.posBefore);
38228
38456
  }
38229
- let slice4 = (node || view.state.selection).content(), { dom, text } = serializeForClipboard(view, slice4);
38457
+ let draggedSlice = (node || view.state.selection).content();
38458
+ let { dom, text, slice: slice4 } = serializeForClipboard(view, draggedSlice);
38230
38459
  event.dataTransfer.clearData();
38231
38460
  event.dataTransfer.setData(brokenClipboardAPI ? "Text" : "text/html", dom.innerHTML);
38232
38461
  event.dataTransfer.effectAllowed = "copyMove";
@@ -38646,9 +38875,6 @@ class DecorationSet {
38646
38875
  return this;
38647
38876
  return local.length || children2.length ? new DecorationSet(local, children2) : empty$1;
38648
38877
  }
38649
- /**
38650
- @internal
38651
- */
38652
38878
  forChild(offset2, node) {
38653
38879
  if (this == empty$1)
38654
38880
  return this;
@@ -39002,6 +39228,7 @@ class DOMObserver {
39002
39228
  this.currentSelection = new SelectionState();
39003
39229
  this.onCharData = null;
39004
39230
  this.suppressingSelectionUpdates = false;
39231
+ this.lastChangedTextNode = null;
39005
39232
  this.observer = window.MutationObserver && new window.MutationObserver((mutations) => {
39006
39233
  for (let i2 = 0; i2 < mutations.length; i2++)
39007
39234
  this.queue.push(mutations[i2]);
@@ -39127,14 +39354,21 @@ class DOMObserver {
39127
39354
  }
39128
39355
  }
39129
39356
  }
39130
- if (gecko && added.length > 1) {
39357
+ if (gecko && added.length) {
39131
39358
  let brs = added.filter((n2) => n2.nodeName == "BR");
39132
39359
  if (brs.length == 2) {
39133
- let a2 = brs[0], b2 = brs[1];
39360
+ let [a2, b2] = brs;
39134
39361
  if (a2.parentNode && a2.parentNode.parentNode == b2.parentNode)
39135
39362
  b2.remove();
39136
39363
  else
39137
39364
  a2.remove();
39365
+ } else {
39366
+ let { focusNode } = this.currentSelection;
39367
+ for (let br2 of brs) {
39368
+ let parent = br2.parentNode;
39369
+ if (parent && parent.nodeName == "LI" && (!focusNode || blockParent(view, focusNode) != parent))
39370
+ br2.remove();
39371
+ }
39138
39372
  }
39139
39373
  }
39140
39374
  let readSel = null;
@@ -39166,8 +39400,12 @@ class DOMObserver {
39166
39400
  if (!desc || desc.ignoreMutation(mut))
39167
39401
  return null;
39168
39402
  if (mut.type == "childList") {
39169
- for (let i2 = 0; i2 < mut.addedNodes.length; i2++)
39170
- added.push(mut.addedNodes[i2]);
39403
+ for (let i2 = 0; i2 < mut.addedNodes.length; i2++) {
39404
+ let node = mut.addedNodes[i2];
39405
+ added.push(node);
39406
+ if (node.nodeType == 3)
39407
+ this.lastChangedTextNode = node;
39408
+ }
39171
39409
  if (desc.contentDOM && desc.contentDOM != desc.dom && !desc.contentDOM.contains(mut.target))
39172
39410
  return { from: desc.posBefore, to: desc.posAfter };
39173
39411
  let prev = mut.previousSibling, next = mut.nextSibling;
@@ -39188,6 +39426,7 @@ class DOMObserver {
39188
39426
  } else if (mut.type == "attributes") {
39189
39427
  return { from: desc.posAtStart - desc.border, to: desc.posAtEnd + desc.border };
39190
39428
  } else {
39429
+ this.lastChangedTextNode = mut.target;
39191
39430
  return {
39192
39431
  from: desc.posAtStart,
39193
39432
  to: desc.posAtEnd,
@@ -39214,7 +39453,20 @@ function checkCSS(view) {
39214
39453
  cssCheckWarned = true;
39215
39454
  }
39216
39455
  }
39217
- function safariShadowSelectionRange(view) {
39456
+ function rangeToSelectionRange(view, range2) {
39457
+ let anchorNode = range2.startContainer, anchorOffset = range2.startOffset;
39458
+ let focusNode = range2.endContainer, focusOffset = range2.endOffset;
39459
+ let currentAnchor = view.domAtPos(view.state.selection.anchor);
39460
+ if (isEquivalentPosition(currentAnchor.node, currentAnchor.offset, focusNode, focusOffset))
39461
+ [anchorNode, anchorOffset, focusNode, focusOffset] = [focusNode, focusOffset, anchorNode, anchorOffset];
39462
+ return { anchorNode, anchorOffset, focusNode, focusOffset };
39463
+ }
39464
+ function safariShadowSelectionRange(view, selection) {
39465
+ if (selection.getComposedRanges) {
39466
+ let range2 = selection.getComposedRanges(view.root)[0];
39467
+ if (range2)
39468
+ return rangeToSelectionRange(view, range2);
39469
+ }
39218
39470
  let found2;
39219
39471
  function read2(event) {
39220
39472
  event.preventDefault();
@@ -39224,12 +39476,15 @@ function safariShadowSelectionRange(view) {
39224
39476
  view.dom.addEventListener("beforeinput", read2, true);
39225
39477
  document.execCommand("indent");
39226
39478
  view.dom.removeEventListener("beforeinput", read2, true);
39227
- let anchorNode = found2.startContainer, anchorOffset = found2.startOffset;
39228
- let focusNode = found2.endContainer, focusOffset = found2.endOffset;
39229
- let currentAnchor = view.domAtPos(view.state.selection.anchor);
39230
- if (isEquivalentPosition(currentAnchor.node, currentAnchor.offset, focusNode, focusOffset))
39231
- [anchorNode, anchorOffset, focusNode, focusOffset] = [focusNode, focusOffset, anchorNode, anchorOffset];
39232
- return { anchorNode, anchorOffset, focusNode, focusOffset };
39479
+ return found2 ? rangeToSelectionRange(view, found2) : null;
39480
+ }
39481
+ function blockParent(view, node) {
39482
+ for (let p2 = node.parentNode; p2 && p2 != view.dom; p2 = p2.parentNode) {
39483
+ let desc = view.docView.nearestDesc(p2, true);
39484
+ if (desc && desc.node.isBlock)
39485
+ return p2;
39486
+ }
39487
+ return null;
39233
39488
  }
39234
39489
  function parseBetween(view, from_, to_) {
39235
39490
  let { node: parent, fromOffset, toOffset, from: from2, to: to2 } = view.docView.parseRange(from_, to_);
@@ -39349,10 +39604,6 @@ function readDOMChange(view, from2, to2, typeOver, addedNodes) {
39349
39604
  return;
39350
39605
  }
39351
39606
  }
39352
- if (chrome && view.cursorWrapper && parse2.sel && parse2.sel.anchor == view.cursorWrapper.deco.from && parse2.sel.head == parse2.sel.anchor) {
39353
- let size2 = change.endB - change.start;
39354
- parse2.sel = { anchor: parse2.sel.anchor + size2, head: parse2.sel.anchor + size2 };
39355
- }
39356
39607
  view.input.domChangeCount++;
39357
39608
  if (view.state.selection.from < view.state.selection.to && change.start == change.endB && view.state.selection instanceof TextSelection) {
39358
39609
  if (change.start > view.state.selection.from && change.start <= view.state.selection.from + 2 && view.state.selection.from >= parse2.from) {
@@ -39376,7 +39627,7 @@ function readDOMChange(view, from2, to2, typeOver, addedNodes) {
39376
39627
  view.input.lastIOSEnter = 0;
39377
39628
  return;
39378
39629
  }
39379
- if (view.state.selection.anchor > change.start && looksLikeJoin(doc2, change.start, change.endA, $from, $to) && view.someProp("handleKeyDown", (f2) => f2(view, keyEvent(8, "Backspace")))) {
39630
+ if (view.state.selection.anchor > change.start && looksLikeBackspace(doc2, change.start, change.endA, $from, $to) && view.someProp("handleKeyDown", (f2) => f2(view, keyEvent(8, "Backspace")))) {
39380
39631
  if (android && chrome)
39381
39632
  view.domObserver.suppressSelectionUpdates();
39382
39633
  return;
@@ -39460,12 +39711,18 @@ function isMarkChange(cur, prev) {
39460
39711
  if (Fragment.from(updated).eq(cur))
39461
39712
  return { mark, type: type3 };
39462
39713
  }
39463
- function looksLikeJoin(old, start2, end2, $newStart, $newEnd) {
39464
- if (!$newStart.parent.isTextblock || // The content must have shrunk
39465
- end2 - start2 <= $newEnd.pos - $newStart.pos || // newEnd must point directly at or after the end of the block that newStart points into
39466
- skipClosingAndOpening($newStart, true, false) < $newEnd.pos)
39714
+ function looksLikeBackspace(old, start2, end2, $newStart, $newEnd) {
39715
+ if (
39716
+ // The content must have shrunk
39717
+ end2 - start2 <= $newEnd.pos - $newStart.pos || // newEnd must point directly at or after the end of the block that newStart points into
39718
+ skipClosingAndOpening($newStart, true, false) < $newEnd.pos
39719
+ )
39467
39720
  return false;
39468
39721
  let $start = old.resolve(start2);
39722
+ if (!$newStart.parent.isTextblock) {
39723
+ let after = $start.nodeAfter;
39724
+ return after != null && end2 == start2 + after.nodeSize;
39725
+ }
39469
39726
  if ($start.parentOffset < $start.parent.content.size || !$start.parent.isTextblock)
39470
39727
  return false;
39471
39728
  let $next = old.resolve(skipClosingAndOpening($start, true, true));
@@ -39654,8 +39911,10 @@ class EditorView {
39654
39911
  let forceSelUpdate = updateDoc && (ie$1 || chrome) && !this.composing && !prev.selection.empty && !state2.selection.empty && selectionContextChanged(prev.selection, state2.selection);
39655
39912
  if (updateDoc) {
39656
39913
  let chromeKludge = chrome ? this.trackWrites = this.domSelectionRange().focusNode : null;
39914
+ if (this.composing)
39915
+ this.input.compositionNode = findCompositionNode(this);
39657
39916
  if (redraw || !this.docView.update(state2.doc, outerDeco, innerDeco, this)) {
39658
- this.docView.updateOuterDeco([]);
39917
+ this.docView.updateOuterDeco(outerDeco);
39659
39918
  this.docView.destroy();
39660
39919
  this.docView = docViewDesc(state2.doc, outerDeco, innerDeco, this.dom, this);
39661
39920
  }
@@ -39914,6 +40173,7 @@ class EditorView {
39914
40173
  }
39915
40174
  this.docView.destroy();
39916
40175
  this.docView = null;
40176
+ clearReusedRange();
39917
40177
  }
39918
40178
  /**
39919
40179
  This is true when the view has been
@@ -39949,7 +40209,8 @@ class EditorView {
39949
40209
  @internal
39950
40210
  */
39951
40211
  domSelectionRange() {
39952
- return safari && this.root.nodeType === 11 && deepActiveElement(this.dom.ownerDocument) == this.dom ? safariShadowSelectionRange(this) : this.domSelection();
40212
+ let sel = this.domSelection();
40213
+ return safari && this.root.nodeType === 11 && deepActiveElement(this.dom.ownerDocument) == this.dom && safariShadowSelectionRange(this, sel) || sel;
39953
40214
  }
39954
40215
  /**
39955
40216
  @internal
@@ -40940,7 +41201,8 @@ function getAttributesFromExtensions(extensions) {
40940
41201
  const context = {
40941
41202
  name: extension.name,
40942
41203
  options: extension.options,
40943
- storage: extension.storage
41204
+ storage: extension.storage,
41205
+ extensions: nodeAndMarkExtensions
40944
41206
  };
40945
41207
  const addGlobalAttributes = getExtensionField(extension, "addGlobalAttributes", context);
40946
41208
  if (!addGlobalAttributes) {
@@ -41066,7 +41328,7 @@ function fromString(value) {
41066
41328
  return value;
41067
41329
  }
41068
41330
  function injectExtensionAttributesToParseRule(parseRule, extensionAttributes) {
41069
- if (parseRule.style) {
41331
+ if ("style" in parseRule) {
41070
41332
  return parseRule;
41071
41333
  }
41072
41334
  return {
@@ -41131,6 +41393,7 @@ function getSchemaByResolvedExtensions(extensions, editor) {
41131
41393
  selectable: callOrReturn(getExtensionField(extension, "selectable", context)),
41132
41394
  draggable: callOrReturn(getExtensionField(extension, "draggable", context)),
41133
41395
  code: callOrReturn(getExtensionField(extension, "code", context)),
41396
+ whitespace: callOrReturn(getExtensionField(extension, "whitespace", context)),
41134
41397
  defining: callOrReturn(getExtensionField(extension, "defining", context)),
41135
41398
  isolating: callOrReturn(getExtensionField(extension, "isolating", context)),
41136
41399
  attrs: Object.fromEntries(extensionAttributes.map((extensionAttribute) => {
@@ -41686,7 +41949,7 @@ class ExtensionManager {
41686
41949
  const plugins2 = [];
41687
41950
  const addKeyboardShortcuts = getExtensionField(extension, "addKeyboardShortcuts", context);
41688
41951
  let defaultBindings = {};
41689
- if (extension.type === "mark" && extension.config.exitable) {
41952
+ if (extension.type === "mark" && getExtensionField(extension, "exitable", context)) {
41690
41953
  defaultBindings.ArrowRight = () => Mark.handleExit({ editor, mark: extension });
41691
41954
  }
41692
41955
  if (addKeyboardShortcuts) {
@@ -41834,14 +42097,10 @@ function mergeDeep(target, source) {
41834
42097
  const output = { ...target };
41835
42098
  if (isPlainObject(target) && isPlainObject(source)) {
41836
42099
  Object.keys(source).forEach((key) => {
41837
- if (isPlainObject(source[key])) {
41838
- if (!(key in target)) {
41839
- Object.assign(output, { [key]: source[key] });
41840
- } else {
41841
- output[key] = mergeDeep(target[key], source[key]);
41842
- }
42100
+ if (isPlainObject(source[key]) && isPlainObject(target[key])) {
42101
+ output[key] = mergeDeep(target[key], source[key]);
41843
42102
  } else {
41844
- Object.assign(output, { [key]: source[key] });
42103
+ output[key] = source[key];
41845
42104
  }
41846
42105
  });
41847
42106
  }
@@ -41880,13 +42139,14 @@ class Extension {
41880
42139
  return new Extension(config);
41881
42140
  }
41882
42141
  configure(options = {}) {
41883
- const extension = this.extend();
42142
+ const extension = this.extend({
42143
+ ...this.config,
42144
+ addOptions: () => {
42145
+ return mergeDeep(this.options, options);
42146
+ }
42147
+ });
42148
+ extension.name = this.name;
41884
42149
  extension.parent = this.parent;
41885
- extension.options = mergeDeep(this.options, options);
41886
- extension.storage = callOrReturn(getExtensionField(extension, "addStorage", {
41887
- name: extension.name,
41888
- options: extension.options
41889
- }));
41890
42150
  return extension;
41891
42151
  }
41892
42152
  extend(extendedConfig = {}) {
@@ -41894,7 +42154,7 @@ class Extension {
41894
42154
  extension.parent = this;
41895
42155
  this.child = extension;
41896
42156
  extension.name = extendedConfig.name ? extendedConfig.name : extension.parent.name;
41897
- if (extendedConfig.defaultOptions) {
42157
+ if (extendedConfig.defaultOptions && Object.keys(extendedConfig.defaultOptions).length > 0) {
41898
42158
  console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${extension.name}".`);
41899
42159
  }
41900
42160
  extension.options = callOrReturn(getExtensionField(extension, "addOptions", {
@@ -42278,13 +42538,47 @@ function createNodeFromContent(content, schema, options) {
42278
42538
  }
42279
42539
  return schema.nodeFromJSON(content);
42280
42540
  } catch (error) {
42541
+ if (options.errorOnInvalidContent) {
42542
+ throw new Error("[tiptap error]: Invalid JSON content", { cause: error });
42543
+ }
42281
42544
  console.warn("[tiptap warn]: Invalid content.", "Passed value:", content, "Error:", error);
42282
42545
  return createNodeFromContent("", schema, options);
42283
42546
  }
42284
42547
  }
42285
42548
  if (isTextContent) {
42286
- const parser = DOMParser.fromSchema(schema);
42287
- return options.slice ? parser.parseSlice(elementFromString(content), options.parseOptions).content : parser.parse(elementFromString(content), options.parseOptions);
42549
+ let schemaToUse = schema;
42550
+ let hasInvalidContent = false;
42551
+ let invalidContent = "";
42552
+ if (options.errorOnInvalidContent) {
42553
+ schemaToUse = new Schema({
42554
+ topNode: schema.spec.topNode,
42555
+ marks: schema.spec.marks,
42556
+ // Prosemirror's schemas are executed such that: the last to execute, matches last
42557
+ // This means that we can add a catch-all node at the end of the schema to catch any content that we don't know how to handle
42558
+ nodes: schema.spec.nodes.append({
42559
+ __tiptap__private__unknown__catch__all__node: {
42560
+ content: "inline*",
42561
+ group: "block",
42562
+ parseDOM: [
42563
+ {
42564
+ tag: "*",
42565
+ getAttrs: (e) => {
42566
+ hasInvalidContent = true;
42567
+ invalidContent = typeof e === "string" ? e : e.outerHTML;
42568
+ return null;
42569
+ }
42570
+ }
42571
+ ]
42572
+ }
42573
+ })
42574
+ });
42575
+ }
42576
+ const parser = DOMParser.fromSchema(schemaToUse);
42577
+ const response = options.slice ? parser.parseSlice(elementFromString(content), options.parseOptions).content : parser.parse(elementFromString(content), options.parseOptions);
42578
+ if (options.errorOnInvalidContent && hasInvalidContent) {
42579
+ throw new Error("[tiptap error]: Invalid HTML content", { cause: new Error(`Invalid element found: ${invalidContent}`) });
42580
+ }
42581
+ return response;
42288
42582
  }
42289
42583
  return createNodeFromContent("", schema, options);
42290
42584
  }
@@ -42307,9 +42601,10 @@ function selectionToInsertionEnd(tr2, startLen, bias) {
42307
42601
  tr2.setSelection(Selection$1.near(tr2.doc.resolve(end2), bias));
42308
42602
  }
42309
42603
  const isFragment = (nodeOrFragment) => {
42310
- return nodeOrFragment.toString().startsWith("<");
42604
+ return !("type" in nodeOrFragment);
42311
42605
  };
42312
42606
  const insertContentAt = (position, value, options) => ({ tr: tr2, dispatch, editor }) => {
42607
+ var _a2;
42313
42608
  if (dispatch) {
42314
42609
  options = {
42315
42610
  parseOptions: {},
@@ -42318,14 +42613,17 @@ const insertContentAt = (position, value, options) => ({ tr: tr2, dispatch, edit
42318
42613
  applyPasteRules: false,
42319
42614
  ...options
42320
42615
  };
42321
- const content = createNodeFromContent(value, editor.schema, {
42322
- parseOptions: {
42323
- preserveWhitespace: "full",
42324
- ...options.parseOptions
42325
- }
42326
- });
42327
- if (content.toString() === "<>") {
42328
- return true;
42616
+ let content;
42617
+ try {
42618
+ content = createNodeFromContent(value, editor.schema, {
42619
+ parseOptions: {
42620
+ preserveWhitespace: "full",
42621
+ ...options.parseOptions
42622
+ },
42623
+ errorOnInvalidContent: (_a2 = options.errorOnInvalidContent) !== null && _a2 !== void 0 ? _a2 : editor.options.enableContentCheck
42624
+ });
42625
+ } catch (e) {
42626
+ return false;
42329
42627
  }
42330
42628
  let { from: from2, to: to2 } = typeof position === "number" ? { from: position, to: position } : { from: position.from, to: position.to };
42331
42629
  let isOnlyTextContent = true;
@@ -42382,7 +42680,7 @@ const joinBackward = () => ({ state: state2, dispatch }) => {
42382
42680
  const joinForward = () => ({ state: state2, dispatch }) => {
42383
42681
  return joinForward$1(state2, dispatch);
42384
42682
  };
42385
- const joinItemBackward = () => ({ tr: tr2, state: state2, dispatch }) => {
42683
+ const joinItemBackward = () => ({ state: state2, dispatch, tr: tr2 }) => {
42386
42684
  try {
42387
42685
  const point2 = joinPoint(state2.doc, state2.selection.$from.pos, -1);
42388
42686
  if (point2 === null || point2 === void 0) {
@@ -42393,7 +42691,7 @@ const joinItemBackward = () => ({ tr: tr2, state: state2, dispatch }) => {
42393
42691
  dispatch(tr2);
42394
42692
  }
42395
42693
  return true;
42396
- } catch {
42694
+ } catch (e) {
42397
42695
  return false;
42398
42696
  }
42399
42697
  };
@@ -42611,16 +42909,32 @@ const selectTextblockEnd = () => ({ state: state2, dispatch }) => {
42611
42909
  const selectTextblockStart = () => ({ state: state2, dispatch }) => {
42612
42910
  return selectTextblockStart$1(state2, dispatch);
42613
42911
  };
42614
- function createDocument(content, schema, parseOptions = {}) {
42615
- return createNodeFromContent(content, schema, { slice: false, parseOptions });
42912
+ function createDocument(content, schema, parseOptions = {}, options = {}) {
42913
+ return createNodeFromContent(content, schema, {
42914
+ slice: false,
42915
+ parseOptions,
42916
+ errorOnInvalidContent: options.errorOnInvalidContent
42917
+ });
42616
42918
  }
42617
- const setContent$1 = (content, emitUpdate = false, parseOptions = {}) => ({ tr: tr2, editor, dispatch }) => {
42919
+ const setContent$1 = (content, emitUpdate = false, parseOptions = {}, options = {}) => ({ editor, tr: tr2, dispatch, commands: commands2 }) => {
42920
+ var _a2, _b;
42618
42921
  const { doc: doc2 } = tr2;
42619
- const document2 = createDocument(content, editor.schema, parseOptions);
42922
+ if (parseOptions.preserveWhitespace !== "full") {
42923
+ const document2 = createDocument(content, editor.schema, parseOptions, {
42924
+ errorOnInvalidContent: (_a2 = options.errorOnInvalidContent) !== null && _a2 !== void 0 ? _a2 : editor.options.enableContentCheck
42925
+ });
42926
+ if (dispatch) {
42927
+ tr2.replaceWith(0, doc2.content.size, document2).setMeta("preventUpdate", !emitUpdate);
42928
+ }
42929
+ return true;
42930
+ }
42620
42931
  if (dispatch) {
42621
- tr2.replaceWith(0, doc2.content.size, document2).setMeta("preventUpdate", !emitUpdate);
42932
+ tr2.setMeta("preventUpdate", !emitUpdate);
42622
42933
  }
42623
- return true;
42934
+ return commands2.insertContentAt({ from: 0, to: doc2.content.size }, content, {
42935
+ parseOptions,
42936
+ errorOnInvalidContent: (_b = options.errorOnInvalidContent) !== null && _b !== void 0 ? _b : editor.options.enableContentCheck
42937
+ });
42624
42938
  };
42625
42939
  function getMarkAttributes(state2, typeOrName) {
42626
42940
  const type3 = getMarkType(typeOrName, state2.schema);
@@ -42823,10 +43137,11 @@ function isList(name, extensions) {
42823
43137
  return group.split(" ").includes("list");
42824
43138
  }
42825
43139
  function isNodeEmpty(node) {
42826
- var _a2;
42827
- const defaultContent = (_a2 = node.type.createAndFill()) === null || _a2 === void 0 ? void 0 : _a2.toJSON();
42828
- const content = node.toJSON();
42829
- return JSON.stringify(defaultContent) === JSON.stringify(content);
43140
+ const defaultContent = node.type.createAndFill();
43141
+ if (!defaultContent) {
43142
+ return false;
43143
+ }
43144
+ return node.eq(defaultContent);
42830
43145
  }
42831
43146
  function isNodeSelection(value) {
42832
43147
  return value instanceof NodeSelection;
@@ -43341,14 +43656,14 @@ var commands = /* @__PURE__ */ Object.freeze({
43341
43656
  forEach,
43342
43657
  insertContent,
43343
43658
  insertContentAt,
43344
- joinUp,
43345
- joinDown,
43346
43659
  joinBackward,
43660
+ joinDown,
43347
43661
  joinForward,
43348
43662
  joinItemBackward,
43349
43663
  joinItemForward,
43350
43664
  joinTextblockBackward,
43351
43665
  joinTextblockForward,
43666
+ joinUp,
43352
43667
  keyboardShortcut,
43353
43668
  lift,
43354
43669
  liftEmptyBlock,
@@ -43545,13 +43860,16 @@ const Tabindex = Extension.create({
43545
43860
  new Plugin({
43546
43861
  key: new PluginKey("tabindex"),
43547
43862
  props: {
43548
- attributes: this.editor.isEditable ? { tabindex: "0" } : {}
43863
+ attributes: () => this.editor.isEditable ? { tabindex: "0" } : {}
43549
43864
  }
43550
43865
  })
43551
43866
  ];
43552
43867
  }
43553
43868
  });
43554
43869
  class NodePos {
43870
+ get name() {
43871
+ return this.node.type.name;
43872
+ }
43555
43873
  constructor(pos, editor, isBlock = false, node = null) {
43556
43874
  this.currentNode = null;
43557
43875
  this.actualDepth = null;
@@ -43560,9 +43878,6 @@ class NodePos {
43560
43878
  this.editor = editor;
43561
43879
  this.currentNode = node;
43562
43880
  }
43563
- get name() {
43564
- return this.node.type.name;
43565
- }
43566
43881
  get node() {
43567
43882
  return this.currentNode || this.resolvedPos.node();
43568
43883
  }
@@ -43794,7 +44109,7 @@ img.ProseMirror-separator {
43794
44109
  opacity: 0
43795
44110
  }`;
43796
44111
  function createStyleTag(style2, nonce, suffix) {
43797
- const tiptapStyleTag = document.querySelector(`style[data-tiptap-style${suffix ? `-${suffix}` : ""}]`);
44112
+ const tiptapStyleTag = document.querySelector(`style[data-tiptap-style${""}]`);
43798
44113
  if (tiptapStyleTag !== null) {
43799
44114
  return tiptapStyleTag;
43800
44115
  }
@@ -43802,7 +44117,7 @@ function createStyleTag(style2, nonce, suffix) {
43802
44117
  if (nonce) {
43803
44118
  styleNode.setAttribute("nonce", nonce);
43804
44119
  }
43805
- styleNode.setAttribute(`data-tiptap-style${suffix ? `-${suffix}` : ""}`, "");
44120
+ styleNode.setAttribute(`data-tiptap-style${""}`, "");
43806
44121
  styleNode.innerHTML = style2;
43807
44122
  document.getElementsByTagName("head")[0].appendChild(styleNode);
43808
44123
  return styleNode;
@@ -43826,6 +44141,7 @@ let Editor$1 = class Editor2 extends EventEmitter {
43826
44141
  enableInputRules: true,
43827
44142
  enablePasteRules: true,
43828
44143
  enableCoreExtensions: true,
44144
+ enableContentCheck: false,
43829
44145
  onBeforeCreate: () => null,
43830
44146
  onCreate: () => null,
43831
44147
  onUpdate: () => null,
@@ -43833,7 +44149,10 @@ let Editor$1 = class Editor2 extends EventEmitter {
43833
44149
  onTransaction: () => null,
43834
44150
  onFocus: () => null,
43835
44151
  onBlur: () => null,
43836
- onDestroy: () => null
44152
+ onDestroy: () => null,
44153
+ onContentError: ({ error }) => {
44154
+ throw error;
44155
+ }
43837
44156
  };
43838
44157
  this.isCapturingTransaction = false;
43839
44158
  this.capturedTransaction = null;
@@ -43843,6 +44162,7 @@ let Editor$1 = class Editor2 extends EventEmitter {
43843
44162
  this.createSchema();
43844
44163
  this.on("beforeCreate", this.options.onBeforeCreate);
43845
44164
  this.emit("beforeCreate", { editor: this });
44165
+ this.on("contentError", this.options.onContentError);
43846
44166
  this.createView();
43847
44167
  this.injectCSS();
43848
44168
  this.on("create", this.options.onCreate);
@@ -43996,7 +44316,23 @@ let Editor$1 = class Editor2 extends EventEmitter {
43996
44316
  * Creates a ProseMirror view.
43997
44317
  */
43998
44318
  createView() {
43999
- const doc2 = createDocument(this.options.content, this.schema, this.options.parseOptions);
44319
+ let doc2;
44320
+ try {
44321
+ doc2 = createDocument(this.options.content, this.schema, this.options.parseOptions, { errorOnInvalidContent: this.options.enableContentCheck });
44322
+ } catch (e) {
44323
+ if (!(e instanceof Error) || !["[tiptap error]: Invalid JSON content", "[tiptap error]: Invalid HTML content"].includes(e.message)) {
44324
+ throw e;
44325
+ }
44326
+ this.emit("contentError", {
44327
+ editor: this,
44328
+ error: e,
44329
+ disableCollaboration: () => {
44330
+ this.options.extensions = this.options.extensions.filter((extension) => extension.name !== "collaboration");
44331
+ this.createExtensionManager();
44332
+ }
44333
+ });
44334
+ doc2 = createDocument(this.options.content, this.schema, this.options.parseOptions, { errorOnInvalidContent: false });
44335
+ }
44000
44336
  const selection = resolveFocusPosition(doc2, this.options.autofocus);
44001
44337
  this.view = new EditorView(this.options.element, {
44002
44338
  ...this.options.editorProps,
@@ -44234,7 +44570,8 @@ function nodeInputRule(config) {
44234
44570
  tr2.insertText(lastChar, start2 + match2[0].length - 1);
44235
44571
  tr2.replaceWith(matchStart, end2, newNode);
44236
44572
  } else if (match2[0]) {
44237
- tr2.insert(start2 - 1, config.type.create(attributes)).delete(tr2.mapping.map(start2), tr2.mapping.map(end2));
44573
+ const insertionStart = config.type.isInline ? start2 : start2 - 1;
44574
+ tr2.insert(insertionStart, config.type.create(attributes)).delete(tr2.mapping.map(start2), tr2.mapping.map(end2));
44238
44575
  }
44239
44576
  tr2.scrollIntoView();
44240
44577
  }
@@ -44319,20 +44656,22 @@ class Mark {
44319
44656
  return new Mark(config);
44320
44657
  }
44321
44658
  configure(options = {}) {
44322
- const extension = this.extend();
44323
- extension.options = mergeDeep(this.options, options);
44324
- extension.storage = callOrReturn(getExtensionField(extension, "addStorage", {
44325
- name: extension.name,
44326
- options: extension.options
44327
- }));
44659
+ const extension = this.extend({
44660
+ ...this.config,
44661
+ addOptions: () => {
44662
+ return mergeDeep(this.options, options);
44663
+ }
44664
+ });
44665
+ extension.name = this.name;
44666
+ extension.parent = this.parent;
44328
44667
  return extension;
44329
44668
  }
44330
44669
  extend(extendedConfig = {}) {
44331
- const extension = new Mark({ ...this.config, ...extendedConfig });
44670
+ const extension = new Mark(extendedConfig);
44332
44671
  extension.parent = this;
44333
44672
  this.child = extension;
44334
44673
  extension.name = extendedConfig.name ? extendedConfig.name : extension.parent.name;
44335
- if (extendedConfig.defaultOptions) {
44674
+ if (extendedConfig.defaultOptions && Object.keys(extendedConfig.defaultOptions).length > 0) {
44336
44675
  console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${extension.name}".`);
44337
44676
  }
44338
44677
  extension.options = callOrReturn(getExtensionField(extension, "addOptions", {
@@ -44398,20 +44737,22 @@ let Node$2 = class Node3 {
44398
44737
  return new Node3(config);
44399
44738
  }
44400
44739
  configure(options = {}) {
44401
- const extension = this.extend();
44402
- extension.options = mergeDeep(this.options, options);
44403
- extension.storage = callOrReturn(getExtensionField(extension, "addStorage", {
44404
- name: extension.name,
44405
- options: extension.options
44406
- }));
44740
+ const extension = this.extend({
44741
+ ...this.config,
44742
+ addOptions: () => {
44743
+ return mergeDeep(this.options, options);
44744
+ }
44745
+ });
44746
+ extension.name = this.name;
44747
+ extension.parent = this.parent;
44407
44748
  return extension;
44408
44749
  }
44409
44750
  extend(extendedConfig = {}) {
44410
- const extension = new Node3({ ...this.config, ...extendedConfig });
44751
+ const extension = new Node3(extendedConfig);
44411
44752
  extension.parent = this;
44412
44753
  this.child = extension;
44413
44754
  extension.name = extendedConfig.name ? extendedConfig.name : extension.parent.name;
44414
- if (extendedConfig.defaultOptions) {
44755
+ if (extendedConfig.defaultOptions && Object.keys(extendedConfig.defaultOptions).length > 0) {
44415
44756
  console.warn(`[tiptap warn]: BREAKING CHANGE: "defaultOptions" is deprecated. Please use "addOptions" instead. Found in extension: "${extension.name}".`);
44416
44757
  }
44417
44758
  extension.options = callOrReturn(getExtensionField(extension, "addOptions", {
@@ -44946,14 +45287,12 @@ const CodeBlock = Node$2.create({
44946
45287
  if (!text || !language) {
44947
45288
  return false;
44948
45289
  }
44949
- const { tr: tr2 } = view.state;
44950
- if (view.state.selection.from === view.state.doc.nodeSize - (1 + view.state.selection.$to.depth * 2)) {
44951
- tr2.insert(view.state.selection.from - 1, this.type.create({ language }));
44952
- } else {
44953
- tr2.replaceSelectionWith(this.type.create({ language }));
45290
+ const { tr: tr2, schema } = view.state;
45291
+ const textNode = schema.text(text.replace(/\r\n?/g, "\n"));
45292
+ tr2.replaceSelectionWith(this.type.create({ language }, textNode));
45293
+ if (tr2.selection.$from.parent.type !== this.type) {
45294
+ tr2.setSelection(TextSelection.near(tr2.doc.resolve(Math.max(0, tr2.selection.from - 2))));
44954
45295
  }
44955
- tr2.setSelection(TextSelection.near(tr2.doc.resolve(Math.max(0, tr2.selection.from - 2))));
44956
- tr2.insertText(text.replace(/\r\n?/g, "\n"));
44957
45296
  tr2.setMeta("paste", true);
44958
45297
  view.dispatch(tr2);
44959
45298
  return true;
@@ -45869,13 +46208,13 @@ function applyTransaction(history2, state2, tr2, options) {
45869
46208
  return history2;
45870
46209
  } else if (appended && appended.getMeta(historyKey)) {
45871
46210
  if (appended.getMeta(historyKey).redo)
45872
- return new HistoryState(history2.done.addTransform(tr2, void 0, options, mustPreserveItems(state2)), history2.undone, rangesFor(tr2.mapping.maps[tr2.steps.length - 1]), history2.prevTime, history2.prevComposition);
46211
+ return new HistoryState(history2.done.addTransform(tr2, void 0, options, mustPreserveItems(state2)), history2.undone, rangesFor(tr2.mapping.maps), history2.prevTime, history2.prevComposition);
45873
46212
  else
45874
46213
  return new HistoryState(history2.done, history2.undone.addTransform(tr2, void 0, options, mustPreserveItems(state2)), null, history2.prevTime, history2.prevComposition);
45875
46214
  } else if (tr2.getMeta("addToHistory") !== false && !(appended && appended.getMeta("addToHistory") === false)) {
45876
46215
  let composition = tr2.getMeta("composition");
45877
46216
  let newGroup = history2.prevTime == 0 || !appended && history2.prevComposition != composition && (history2.prevTime < (tr2.time || 0) - options.newGroupDelay || !isAdjacentTo(tr2, history2.prevRanges));
45878
- let prevRanges = appended ? mapRanges(history2.prevRanges, tr2.mapping) : rangesFor(tr2.mapping.maps[tr2.steps.length - 1]);
46217
+ let prevRanges = appended ? mapRanges(history2.prevRanges, tr2.mapping) : rangesFor(tr2.mapping.maps);
45879
46218
  return new HistoryState(history2.done.addTransform(tr2, newGroup ? state2.selection.getBookmark() : void 0, options, mustPreserveItems(state2)), Branch.empty, prevRanges, tr2.time, composition == null ? history2.prevComposition : composition);
45880
46219
  } else if (rebased = tr2.getMeta("rebased")) {
45881
46220
  return new HistoryState(history2.done.rebased(tr2, rebased), history2.undone.rebased(tr2, rebased), mapRanges(history2.prevRanges, tr2.mapping), history2.prevTime, history2.prevComposition);
@@ -45896,9 +46235,10 @@ function isAdjacentTo(transform, prevRanges) {
45896
46235
  });
45897
46236
  return adjacent;
45898
46237
  }
45899
- function rangesFor(map4) {
46238
+ function rangesFor(maps) {
45900
46239
  let result2 = [];
45901
- map4.forEach((_from, _to, from2, to2) => result2.push(from2, to2));
46240
+ for (let i2 = maps.length - 1; i2 >= 0 && result2.length == 0; i2--)
46241
+ maps[i2].forEach((_from, _to, from2, to2) => result2.push(from2, to2));
45902
46242
  return result2;
45903
46243
  }
45904
46244
  function mapRanges(ranges, mapping) {
@@ -45912,16 +46252,16 @@ function mapRanges(ranges, mapping) {
45912
46252
  }
45913
46253
  return result2;
45914
46254
  }
45915
- function histTransaction(history2, state2, dispatch, redo2) {
46255
+ function histTransaction(history2, state2, redo2) {
45916
46256
  let preserveItems = mustPreserveItems(state2);
45917
46257
  let histOptions = historyKey.get(state2).spec.config;
45918
46258
  let pop = (redo2 ? history2.undone : history2.done).popEvent(state2, preserveItems);
45919
46259
  if (!pop)
45920
- return;
46260
+ return null;
45921
46261
  let selection = pop.selection.resolve(pop.transform.doc);
45922
46262
  let added = (redo2 ? history2.done : history2.undone).addTransform(pop.transform, state2.selection.getBookmark(), histOptions, preserveItems);
45923
46263
  let newHist = new HistoryState(redo2 ? added : pop.remaining, redo2 ? pop.remaining : added, null, 0, -1);
45924
- dispatch(pop.transform.setSelection(selection).setMeta(historyKey, { redo: redo2, historyState: newHist }).scrollIntoView());
46264
+ return pop.transform.setSelection(selection).setMeta(historyKey, { redo: redo2, historyState: newHist });
45925
46265
  }
45926
46266
  let cachedPreserveItems = false, cachedPreserveItemsPlugins = null;
45927
46267
  function mustPreserveItems(state2) {
@@ -45969,22 +46309,21 @@ function history(config = {}) {
45969
46309
  }
45970
46310
  });
45971
46311
  }
45972
- const undo = (state2, dispatch) => {
45973
- let hist = historyKey.getState(state2);
45974
- if (!hist || hist.done.eventCount == 0)
45975
- return false;
45976
- if (dispatch)
45977
- histTransaction(hist, state2, dispatch, false);
45978
- return true;
45979
- };
45980
- const redo = (state2, dispatch) => {
45981
- let hist = historyKey.getState(state2);
45982
- if (!hist || hist.undone.eventCount == 0)
45983
- return false;
45984
- if (dispatch)
45985
- histTransaction(hist, state2, dispatch, true);
45986
- return true;
45987
- };
46312
+ function buildCommand(redo2, scroll) {
46313
+ return (state2, dispatch) => {
46314
+ let hist = historyKey.getState(state2);
46315
+ if (!hist || (redo2 ? hist.undone : hist.done).eventCount == 0)
46316
+ return false;
46317
+ if (dispatch) {
46318
+ let tr2 = histTransaction(hist, state2, redo2);
46319
+ if (tr2)
46320
+ dispatch(scroll ? tr2.scrollIntoView() : tr2);
46321
+ }
46322
+ return true;
46323
+ };
46324
+ }
46325
+ const undo = buildCommand(false, true);
46326
+ const redo = buildCommand(true, true);
45988
46327
  const History = Extension.create({
45989
46328
  name: "history",
45990
46329
  addOptions() {
@@ -46036,10 +46375,20 @@ const HorizontalRule = Node$2.create({
46036
46375
  addCommands() {
46037
46376
  return {
46038
46377
  setHorizontalRule: () => ({ chain, state: state2 }) => {
46039
- const { $to: $originTo } = state2.selection;
46378
+ const { selection } = state2;
46379
+ const { $from: $originFrom, $to: $originTo } = selection;
46040
46380
  const currentChain = chain();
46041
- if ($originTo.parentOffset === 0) {
46042
- currentChain.insertContentAt(Math.max($originTo.pos - 2, 0), { type: this.name });
46381
+ if ($originFrom.parentOffset === 0) {
46382
+ currentChain.insertContentAt({
46383
+ from: Math.max($originFrom.pos - 1, 0),
46384
+ to: $originTo.pos
46385
+ }, {
46386
+ type: this.name
46387
+ });
46388
+ } else if (isNodeSelection(selection)) {
46389
+ currentChain.insertContentAt($originTo.pos, {
46390
+ type: this.name
46391
+ });
46043
46392
  } else {
46044
46393
  currentChain.insertContent({ type: this.name });
46045
46394
  }
@@ -46425,11 +46774,11 @@ const StarterKit = Extension.create({
46425
46774
  addExtensions() {
46426
46775
  var _a2, _b, _c, _d, _e2, _f, _g, _h, _j, _k, _l2, _m, _o, _p, _q, _r2, _s, _t2;
46427
46776
  const extensions = [];
46428
- if (this.options.blockquote !== false) {
46429
- extensions.push(Blockquote.configure((_a2 = this.options) === null || _a2 === void 0 ? void 0 : _a2.blockquote));
46430
- }
46431
46777
  if (this.options.bold !== false) {
46432
- extensions.push(Bold.configure((_b = this.options) === null || _b === void 0 ? void 0 : _b.bold));
46778
+ extensions.push(Bold.configure((_a2 = this.options) === null || _a2 === void 0 ? void 0 : _a2.bold));
46779
+ }
46780
+ if (this.options.blockquote !== false) {
46781
+ extensions.push(Blockquote.configure((_b = this.options) === null || _b === void 0 ? void 0 : _b.blockquote));
46433
46782
  }
46434
46783
  if (this.options.bulletList !== false) {
46435
46784
  extensions.push(BulletList.configure((_c = this.options) === null || _c === void 0 ? void 0 : _c.bulletList));
@@ -49236,7 +49585,7 @@ class BubbleMenuView {
49236
49585
  }
49237
49586
  update(view, oldState) {
49238
49587
  const { state: state2 } = view;
49239
- const hasValidSelection = state2.selection.$from.pos !== state2.selection.$to.pos;
49588
+ const hasValidSelection = state2.selection.from !== state2.selection.to;
49240
49589
  if (this.updateDelay > 0 && hasValidSelection) {
49241
49590
  this.handleDebouncedUpdate(view, oldState);
49242
49591
  return;
@@ -52281,9 +52630,6 @@ function createColGroup(node, cellMinWidth, overrideCol, overrideValue) {
52281
52630
  return { colgroup, tableWidth, tableMinWidth };
52282
52631
  }
52283
52632
  function createCell(cellType, cellContent) {
52284
- if (cellContent) {
52285
- return cellType.createChecked(null, cellContent);
52286
- }
52287
52633
  return cellType.createAndFill();
52288
52634
  }
52289
52635
  function getTableNodeTypes(schema) {
@@ -52305,12 +52651,12 @@ function createTable$1(schema, rowsCount, colsCount, withHeaderRow, cellContent)
52305
52651
  const headerCells = [];
52306
52652
  const cells = [];
52307
52653
  for (let index2 = 0; index2 < colsCount; index2 += 1) {
52308
- const cell = createCell(types.cell, cellContent);
52654
+ const cell = createCell(types.cell);
52309
52655
  if (cell) {
52310
52656
  cells.push(cell);
52311
52657
  }
52312
52658
  if (withHeaderRow) {
52313
- const headerCell = createCell(types.header_cell, cellContent);
52659
+ const headerCell = createCell(types.header_cell);
52314
52660
  if (headerCell) {
52315
52661
  headerCells.push(headerCell);
52316
52662
  }
@@ -52388,7 +52734,7 @@ const Table = Node$2.create({
52388
52734
  insertTable: ({ rows = 3, cols = 3, withHeaderRow = true } = {}) => ({ tr: tr2, dispatch, editor }) => {
52389
52735
  const node = createTable$1(editor.schema, rows, cols, withHeaderRow);
52390
52736
  if (dispatch) {
52391
- const offset2 = tr2.selection.anchor + 1;
52737
+ const offset2 = tr2.selection.from + 1;
52392
52738
  tr2.replaceSelectionWith(node).scrollIntoView().setSelection(TextSelection.near(tr2.doc.resolve(offset2)));
52393
52739
  }
52394
52740
  return true;
@@ -52865,18 +53211,7 @@ function _typeof$1(obj) {
52865
53211
  return obj2 && "function" == typeof Symbol && obj2.constructor === Symbol && obj2 !== Symbol.prototype ? "symbol" : typeof obj2;
52866
53212
  }, _typeof$1(obj);
52867
53213
  }
52868
- function _defineProperties$2(target, props2) {
52869
- for (var i2 = 0; i2 < props2.length; i2++) {
52870
- var descriptor = props2[i2];
52871
- descriptor.enumerable = descriptor.enumerable || false;
52872
- descriptor.configurable = true;
52873
- if ("value" in descriptor) descriptor.writable = true;
52874
- Object.defineProperty(target, descriptor.key, descriptor);
52875
- }
52876
- }
52877
53214
  function _createClass$2(Constructor, protoProps, staticProps) {
52878
- if (protoProps) _defineProperties$2(Constructor.prototype, protoProps);
52879
- if (staticProps) _defineProperties$2(Constructor, staticProps);
52880
53215
  Object.defineProperty(Constructor, "prototype", { writable: false });
52881
53216
  return Constructor;
52882
53217
  }
@@ -53053,7 +53388,6 @@ function _defineProperties$1(target, props2) {
53053
53388
  }
53054
53389
  function _createClass$1(Constructor, protoProps, staticProps) {
53055
53390
  if (protoProps) _defineProperties$1(Constructor.prototype, protoProps);
53056
- if (staticProps) _defineProperties$1(Constructor, staticProps);
53057
53391
  Object.defineProperty(Constructor, "prototype", { writable: false });
53058
53392
  return Constructor;
53059
53393
  }
@@ -53695,10 +54029,10 @@ var DIGITS = {
53695
54029
  function parseDigit(character) {
53696
54030
  return DIGITS[character];
53697
54031
  }
53698
- function _createForOfIteratorHelperLoose$4(o2, allowArrayLike) {
54032
+ function _createForOfIteratorHelperLoose$3(o2, allowArrayLike) {
53699
54033
  var it2 = typeof Symbol !== "undefined" && o2[Symbol.iterator] || o2["@@iterator"];
53700
54034
  if (it2) return (it2 = it2.call(o2)).next.bind(it2);
53701
- if (Array.isArray(o2) || (it2 = _unsupportedIterableToArray$5(o2)) || allowArrayLike && o2 && typeof o2.length === "number") {
54035
+ if (Array.isArray(o2) || (it2 = _unsupportedIterableToArray$4(o2)) || allowArrayLike) {
53702
54036
  if (it2) o2 = it2;
53703
54037
  var i2 = 0;
53704
54038
  return function() {
@@ -53708,15 +54042,15 @@ function _createForOfIteratorHelperLoose$4(o2, allowArrayLike) {
53708
54042
  }
53709
54043
  throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
53710
54044
  }
53711
- function _unsupportedIterableToArray$5(o2, minLen) {
54045
+ function _unsupportedIterableToArray$4(o2, minLen) {
53712
54046
  if (!o2) return;
53713
- if (typeof o2 === "string") return _arrayLikeToArray$5(o2, minLen);
54047
+ if (typeof o2 === "string") return _arrayLikeToArray$4(o2, minLen);
53714
54048
  var n2 = Object.prototype.toString.call(o2).slice(8, -1);
53715
54049
  if (n2 === "Object" && o2.constructor) n2 = o2.constructor.name;
53716
54050
  if (n2 === "Map" || n2 === "Set") return Array.from(o2);
53717
- if (n2 === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n2)) return _arrayLikeToArray$5(o2, minLen);
54051
+ if (n2 === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n2)) return _arrayLikeToArray$4(o2, minLen);
53718
54052
  }
53719
- function _arrayLikeToArray$5(arr, len) {
54053
+ function _arrayLikeToArray$4(arr, len) {
53720
54054
  if (len == null || len > arr.length) len = arr.length;
53721
54055
  for (var i2 = 0, arr2 = new Array(len); i2 < len; i2++) {
53722
54056
  arr2[i2] = arr[i2];
@@ -53725,7 +54059,7 @@ function _arrayLikeToArray$5(arr, len) {
53725
54059
  }
53726
54060
  function parseIncompletePhoneNumber(string2) {
53727
54061
  var result2 = "";
53728
- for (var _iterator = _createForOfIteratorHelperLoose$4(string2.split("")), _step; !(_step = _iterator()).done; ) {
54062
+ for (var _iterator = _createForOfIteratorHelperLoose$3(string2.split("")), _step; !(_step = _iterator()).done; ) {
53729
54063
  var character = _step.value;
53730
54064
  result2 += parsePhoneNumberCharacter(character, result2) || "";
53731
54065
  }
@@ -53734,55 +54068,12 @@ function parseIncompletePhoneNumber(string2) {
53734
54068
  function parsePhoneNumberCharacter(character, prevParsedCharacters, emitEvent) {
53735
54069
  if (character === "+") {
53736
54070
  if (prevParsedCharacters) {
53737
- if (typeof emitEvent === "function") {
53738
- emitEvent("end");
53739
- }
53740
54071
  return;
53741
54072
  }
53742
54073
  return "+";
53743
54074
  }
53744
54075
  return parseDigit(character);
53745
54076
  }
53746
- function _createForOfIteratorHelperLoose$3(o2, allowArrayLike) {
53747
- var it2 = typeof Symbol !== "undefined" && o2[Symbol.iterator] || o2["@@iterator"];
53748
- if (it2) return (it2 = it2.call(o2)).next.bind(it2);
53749
- if (Array.isArray(o2) || (it2 = _unsupportedIterableToArray$4(o2)) || allowArrayLike && o2 && typeof o2.length === "number") {
53750
- if (it2) o2 = it2;
53751
- var i2 = 0;
53752
- return function() {
53753
- if (i2 >= o2.length) return { done: true };
53754
- return { done: false, value: o2[i2++] };
53755
- };
53756
- }
53757
- throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
53758
- }
53759
- function _unsupportedIterableToArray$4(o2, minLen) {
53760
- if (!o2) return;
53761
- if (typeof o2 === "string") return _arrayLikeToArray$4(o2, minLen);
53762
- var n2 = Object.prototype.toString.call(o2).slice(8, -1);
53763
- if (n2 === "Object" && o2.constructor) n2 = o2.constructor.name;
53764
- if (n2 === "Map" || n2 === "Set") return Array.from(o2);
53765
- if (n2 === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n2)) return _arrayLikeToArray$4(o2, minLen);
53766
- }
53767
- function _arrayLikeToArray$4(arr, len) {
53768
- if (len == null || len > arr.length) len = arr.length;
53769
- for (var i2 = 0, arr2 = new Array(len); i2 < len; i2++) {
53770
- arr2[i2] = arr[i2];
53771
- }
53772
- return arr2;
53773
- }
53774
- function mergeArrays(a2, b2) {
53775
- var merged = a2.slice();
53776
- for (var _iterator = _createForOfIteratorHelperLoose$3(b2), _step; !(_step = _iterator()).done; ) {
53777
- var element = _step.value;
53778
- if (a2.indexOf(element) < 0) {
53779
- merged.push(element);
53780
- }
53781
- }
53782
- return merged.sort(function(a3, b3) {
53783
- return a3 - b3;
53784
- });
53785
- }
53786
54077
  function checkNumberLength(nationalNumber, metadata2) {
53787
54078
  return checkNumberLengthForType(nationalNumber, void 0, metadata2);
53788
54079
  }
@@ -53792,17 +54083,6 @@ function checkNumberLengthForType(nationalNumber, type3, metadata2) {
53792
54083
  if (!possible_lengths) {
53793
54084
  return "IS_POSSIBLE";
53794
54085
  }
53795
- if (type3 === "FIXED_LINE_OR_MOBILE") {
53796
- if (!metadata2.type("FIXED_LINE")) {
53797
- return checkNumberLengthForType(nationalNumber, "MOBILE", metadata2);
53798
- }
53799
- var mobile_type = metadata2.type("MOBILE");
53800
- if (mobile_type) {
53801
- possible_lengths = mergeArrays(possible_lengths, mobile_type.possibleLengths());
53802
- }
53803
- } else if (type3 && !type_info) {
53804
- return "INVALID_LENGTH";
53805
- }
53806
54086
  var actual_length = nationalNumber.length;
53807
54087
  var minimum_length = possible_lengths[0];
53808
54088
  if (minimum_length === actual_length) {
@@ -53867,7 +54147,7 @@ function matchesEntirely(text, regular_expression) {
53867
54147
  function _createForOfIteratorHelperLoose$2(o2, allowArrayLike) {
53868
54148
  var it2 = typeof Symbol !== "undefined" && o2[Symbol.iterator] || o2["@@iterator"];
53869
54149
  if (it2) return (it2 = it2.call(o2)).next.bind(it2);
53870
- if (Array.isArray(o2) || (it2 = _unsupportedIterableToArray$3(o2)) || allowArrayLike && o2 && typeof o2.length === "number") {
54150
+ if (Array.isArray(o2) || (it2 = _unsupportedIterableToArray$3(o2)) || allowArrayLike) {
53871
54151
  if (it2) o2 = it2;
53872
54152
  var i2 = 0;
53873
54153
  return function() {
@@ -53967,8 +54247,6 @@ function applyInternationalSeparatorStyle(formattedNumber) {
53967
54247
  var FIRST_GROUP_PATTERN = /(\$\d)/;
53968
54248
  function formatNationalNumberUsingFormat(number2, format2, _ref) {
53969
54249
  var useInternationalFormat = _ref.useInternationalFormat, withNationalPrefix = _ref.withNationalPrefix;
53970
- _ref.carrierCode;
53971
- _ref.metadata;
53972
54250
  var formattedNumber = number2.replace(new RegExp(format2.pattern()), useInternationalFormat ? format2.internationalFormat() : (
53973
54251
  // This library doesn't use `domestic_carrier_code_formatting_rule`,
53974
54252
  // because that one is only used when formatting phone numbers
@@ -54014,7 +54292,7 @@ function formatRFC3966(_ref) {
54014
54292
  function _createForOfIteratorHelperLoose$1(o2, allowArrayLike) {
54015
54293
  var it2 = typeof Symbol !== "undefined" && o2[Symbol.iterator] || o2["@@iterator"];
54016
54294
  if (it2) return (it2 = it2.call(o2)).next.bind(it2);
54017
- if (Array.isArray(o2) || (it2 = _unsupportedIterableToArray$2(o2)) || allowArrayLike && o2 && typeof o2.length === "number") {
54295
+ if (Array.isArray(o2) || (it2 = _unsupportedIterableToArray$2(o2)) || allowArrayLike) {
54018
54296
  if (it2) o2 = it2;
54019
54297
  var i2 = 0;
54020
54298
  return function() {
@@ -54210,7 +54488,6 @@ function _defineProperties(target, props2) {
54210
54488
  }
54211
54489
  function _createClass(Constructor, protoProps, staticProps) {
54212
54490
  if (protoProps) _defineProperties(Constructor.prototype, protoProps);
54213
- if (staticProps) _defineProperties(Constructor, staticProps);
54214
54491
  Object.defineProperty(Constructor, "prototype", { writable: false });
54215
54492
  return Constructor;
54216
54493
  }
@@ -54507,7 +54784,7 @@ function extractCountryCallingCode(number2, country, callingCode, metadata2) {
54507
54784
  function _createForOfIteratorHelperLoose(o2, allowArrayLike) {
54508
54785
  var it2 = typeof Symbol !== "undefined" && o2[Symbol.iterator] || o2["@@iterator"];
54509
54786
  if (it2) return (it2 = it2.call(o2)).next.bind(it2);
54510
- if (Array.isArray(o2) || (it2 = _unsupportedIterableToArray$1(o2)) || allowArrayLike && o2 && typeof o2.length === "number") {
54787
+ if (Array.isArray(o2) || (it2 = _unsupportedIterableToArray$1(o2)) || allowArrayLike) {
54511
54788
  if (it2) o2 = it2;
54512
54789
  var i2 = 0;
54513
54790
  return function() {
@@ -54561,14 +54838,8 @@ function getCountryByNationalNumber(nationalPhoneNumber, _ref) {
54561
54838
  return matchingCountries[0];
54562
54839
  }
54563
54840
  }
54564
- var USE_NON_GEOGRAPHIC_COUNTRY_CODE = false;
54565
54841
  function getCountryByCallingCode(callingCode, _ref) {
54566
54842
  var nationalPhoneNumber = _ref.nationalNumber, defaultCountry = _ref.defaultCountry, metadata2 = _ref.metadata;
54567
- if (USE_NON_GEOGRAPHIC_COUNTRY_CODE) {
54568
- if (metadata2.isNonGeographicCallingCode(callingCode)) {
54569
- return "001";
54570
- }
54571
- }
54572
54843
  var possibleCountries = metadata2.getCountryCodesForCallingCode(callingCode);
54573
54844
  if (!possibleCountries) {
54574
54845
  return;
@@ -57402,7 +57673,7 @@ const bisectCenter = bisector(number$2).center;
57402
57673
  function extent(values3, valueof) {
57403
57674
  let min2;
57404
57675
  let max2;
57405
- if (valueof === void 0) {
57676
+ {
57406
57677
  for (const value of values3) {
57407
57678
  if (value != null) {
57408
57679
  if (min2 === void 0) {
@@ -57413,18 +57684,6 @@ function extent(values3, valueof) {
57413
57684
  }
57414
57685
  }
57415
57686
  }
57416
- } else {
57417
- let index2 = -1;
57418
- for (let value of values3) {
57419
- if ((value = valueof(value, ++index2, values3)) != null) {
57420
- if (min2 === void 0) {
57421
- if (value >= value) min2 = max2 = value;
57422
- } else {
57423
- if (min2 > value) min2 = value;
57424
- if (max2 < value) max2 = value;
57425
- }
57426
- }
57427
- }
57428
57687
  }
57429
57688
  return [min2, max2];
57430
57689
  }
@@ -63390,4 +63649,5 @@ exports.useBglSchema = useBglSchema;
63390
63649
  exports.useEscape = useEscape;
63391
63650
  exports.useI18nT = useI18nT;
63392
63651
  exports.useLang = useLang;
63652
+ exports.useLocalStorage = useLocalStorage;
63393
63653
  exports.useModal = useModal;