@nous-excalidraw/excalidraw 0.18.0-beta → 0.18.0-beta.3

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.
@@ -1,7 +1,7 @@
1
1
  // <define:import.meta.env>
2
- var define_import_meta_env_default = { MODE: "development", VITE_APP_BACKEND_V2_GET_URL: "https://json-dev.excalidraw.com/api/v2/", VITE_APP_BACKEND_V2_POST_URL: "https://json-dev.excalidraw.com/api/v2/post/", VITE_APP_LIBRARY_URL: "https://libraries.excalidraw.com", VITE_APP_LIBRARY_BACKEND: "https://us-central1-excalidraw-room-persistence.cloudfunctions.net/libraries", VITE_APP_WS_SERVER_URL: "http://localhost:3002", VITE_APP_PLUS_LP: "https://plus.excalidraw.com", VITE_APP_PLUS_APP: "http://localhost:3000", VITE_APP_AI_BACKEND: "http://localhost:3016", VITE_APP_FIREBASE_CONFIG: '{"apiKey":"AIzaSyCMkxA60XIW8KbqMYL7edC4qT5l4qHX2h8","authDomain":"excalidraw-oss-dev.firebaseapp.com","projectId":"excalidraw-oss-dev","storageBucket":"excalidraw-oss-dev.appspot.com","messagingSenderId":"664559512677","appId":"1:664559512677:web:a385181f2928d328a7aa8c"}', VITE_APP_DEV_DISABLE_LIVE_RELOAD: "", VITE_APP_ENABLE_TRACKING: "true", FAST_REFRESH: "false", VITE_APP_PORT: "3001", VITE_APP_DEBUG_ENABLE_TEXT_CONTAINER_BOUNDING_BOX: "", VITE_APP_COLLAPSE_OVERLAY: "true", VITE_APP_ENABLE_ESLINT: "true", VITE_APP_ENABLE_PWA: "false", VITE_APP_PLUS_EXPORT_PUBLIC_KEY: "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAm2g5T+Rub6Kbf1Mf57t0\n7r2zeHuVg4dla3r5ryXMswtzz6x767octl6oLThn33mQsPSy3GKglFZoCTXJR4ij\nba8SxB04sL/N8eRrKja7TFWjCVtRwTTfyy771NYYNFVJclkxHyE5qw4m27crHF1y\nUNWEjuqNMi/lwAErS9fFa2oJlWyT8U7zzv/5kQREkxZI6y9v0AF3qcbsy2731FnD\ns9ChJvOUW9toIab2gsIdrKW8ZNpu084ZFVKb6LNjvIXI1Se4oMTHeszXzNptzlot\nkdxxjOoaQMAyfljFSot1F1FlU6MQlag7UnFGvFjRHN1JI5q4K+n3a67DX+TMyRqS\nHQIDAQAB", VITE_APP_DISABLE_PREVENT_UNLOAD: "", PKG_NAME: "@nous-excalidraw/excalidraw", PKG_VERSION: "0.18.0", DEV: true };
2
+ var define_import_meta_env_default = { MODE: "development", VITE_APP_BACKEND_V2_GET_URL: "https://json-dev.excalidraw.com/api/v2/", VITE_APP_BACKEND_V2_POST_URL: "https://json-dev.excalidraw.com/api/v2/post/", VITE_APP_LIBRARY_URL: "https://libraries.excalidraw.com", VITE_APP_LIBRARY_BACKEND: "https://us-central1-excalidraw-room-persistence.cloudfunctions.net/libraries", VITE_APP_WS_SERVER_URL: "http://localhost:3002", VITE_APP_PLUS_LP: "https://plus.excalidraw.com", VITE_APP_PLUS_APP: "http://localhost:3000", VITE_APP_AI_BACKEND: "http://localhost:3016", VITE_APP_FIREBASE_CONFIG: '{"apiKey":"AIzaSyCMkxA60XIW8KbqMYL7edC4qT5l4qHX2h8","authDomain":"excalidraw-oss-dev.firebaseapp.com","projectId":"excalidraw-oss-dev","storageBucket":"excalidraw-oss-dev.appspot.com","messagingSenderId":"664559512677","appId":"1:664559512677:web:a385181f2928d328a7aa8c"}', VITE_APP_DEV_DISABLE_LIVE_RELOAD: "", VITE_APP_ENABLE_TRACKING: "true", FAST_REFRESH: "false", VITE_APP_PORT: "3001", VITE_APP_DEBUG_ENABLE_TEXT_CONTAINER_BOUNDING_BOX: "", VITE_APP_COLLAPSE_OVERLAY: "true", VITE_APP_ENABLE_ESLINT: "true", VITE_APP_ENABLE_PWA: "false", VITE_APP_PLUS_EXPORT_PUBLIC_KEY: "MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAm2g5T+Rub6Kbf1Mf57t0\n7r2zeHuVg4dla3r5ryXMswtzz6x767octl6oLThn33mQsPSy3GKglFZoCTXJR4ij\nba8SxB04sL/N8eRrKja7TFWjCVtRwTTfyy771NYYNFVJclkxHyE5qw4m27crHF1y\nUNWEjuqNMi/lwAErS9fFa2oJlWyT8U7zzv/5kQREkxZI6y9v0AF3qcbsy2731FnD\ns9ChJvOUW9toIab2gsIdrKW8ZNpu084ZFVKb6LNjvIXI1Se4oMTHeszXzNptzlot\nkdxxjOoaQMAyfljFSot1F1FlU6MQlag7UnFGvFjRHN1JI5q4K+n3a67DX+TMyRqS\nHQIDAQAB", VITE_APP_DISABLE_PREVENT_UNLOAD: "", PKG_NAME: "@nous-excalidraw/excalidraw", PKG_VERSION: "0.18.0-beta", DEV: true };
3
3
 
4
4
  export {
5
5
  define_import_meta_env_default
6
6
  };
7
- //# sourceMappingURL=chunk-JHTRI4CR.js.map
7
+ //# sourceMappingURL=chunk-ED35ZZUZ.js.map
@@ -2,6 +2,6 @@
2
2
  "version": 3,
3
3
  "sources": ["<define:import.meta.env>"],
4
4
  "sourcesContent": [""],
5
- "mappings": ";AAAA,uCAAC,MAAO,eAAc,6BAA8B,2CAA0C,8BAA+B,gDAA+C,sBAAuB,oCAAmC,0BAA2B,gFAA+E,wBAAyB,yBAAwB,kBAAmB,+BAA8B,mBAAoB,yBAAwB,qBAAsB,yBAAwB,0BAA2B,mRAA0S,kCAAmC,IAAG,0BAA2B,QAAO,cAAe,SAAQ,eAAgB,QAAO,mDAAoD,IAAG,2BAA4B,QAAO,wBAAyB,QAAO,qBAAsB,SAAQ,iCAAkC,wZAAuZ,iCAAkC,IAAG,UAAW,+BAA8B,aAAc,UAAS,KAAM,KAAI;",
5
+ "mappings": ";AAAA,uCAAC,MAAO,eAAc,6BAA8B,2CAA0C,8BAA+B,gDAA+C,sBAAuB,oCAAmC,0BAA2B,gFAA+E,wBAAyB,yBAAwB,kBAAmB,+BAA8B,mBAAoB,yBAAwB,qBAAsB,yBAAwB,0BAA2B,mRAA0S,kCAAmC,IAAG,0BAA2B,QAAO,cAAe,SAAQ,eAAgB,QAAO,mDAAoD,IAAG,2BAA4B,QAAO,wBAAyB,QAAO,qBAAsB,SAAQ,iCAAkC,wZAAuZ,iCAAkC,IAAG,UAAW,+BAA8B,aAAc,eAAc,KAAM,KAAI;",
6
6
  "names": []
7
7
  }
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  define_import_meta_env_default
3
- } from "./chunk-JHTRI4CR.js";
3
+ } from "./chunk-ED35ZZUZ.js";
4
4
  import {
5
5
  __publicField
6
6
  } from "./chunk-XDFCUUT6.js";
@@ -5089,7 +5089,7 @@ var parseFileContents = async (blob) => {
5089
5089
  let contents;
5090
5090
  if (blob.type === MIME_TYPES6.png) {
5091
5091
  try {
5092
- return await (await import("./data/image-E7XPI3XF.js")).decodePngMetadata(blob);
5092
+ return await (await import("./data/image-3Y7D3VR4.js")).decodePngMetadata(blob);
5093
5093
  } catch (error) {
5094
5094
  if (error.message === "INVALID") {
5095
5095
  throw new ImageSceneDataError(
@@ -5523,4 +5523,4 @@ export {
5523
5523
  createFile,
5524
5524
  normalizeFile
5525
5525
  };
5526
- //# sourceMappingURL=chunk-A4DEDEZ5.js.map
5526
+ //# sourceMappingURL=chunk-FKBWMG5J.js.map
@@ -1,4 +1,4 @@
1
- import "../../chunk-JHTRI4CR.js";
1
+ import "../../chunk-ED35ZZUZ.js";
2
2
  import "../../chunk-XDFCUUT6.js";
3
3
 
4
4
  // components/TTDDialog/CodeMirrorEditor.tsx
@@ -256,4 +256,4 @@ var CodeMirrorEditor_default = CodeMirrorEditor;
256
256
  export {
257
257
  CodeMirrorEditor_default as default
258
258
  };
259
- //# sourceMappingURL=CodeMirrorEditor-EJU7XIUQ.js.map
259
+ //# sourceMappingURL=CodeMirrorEditor-6AT2I7WX.js.map
@@ -2,12 +2,12 @@ import {
2
2
  decodePngMetadata,
3
3
  encodePngMetadata,
4
4
  getTEXtChunk
5
- } from "../chunk-A4DEDEZ5.js";
6
- import "../chunk-JHTRI4CR.js";
5
+ } from "../chunk-FKBWMG5J.js";
6
+ import "../chunk-ED35ZZUZ.js";
7
7
  import "../chunk-XDFCUUT6.js";
8
8
  export {
9
9
  decodePngMetadata,
10
10
  encodePngMetadata,
11
11
  getTEXtChunk
12
12
  };
13
- //# sourceMappingURL=image-E7XPI3XF.js.map
13
+ //# sourceMappingURL=image-3Y7D3VR4.js.map
package/dist/dev/index.js CHANGED
@@ -65,10 +65,10 @@ import {
65
65
  serializeAsJSON,
66
66
  serializeLibraryAsJSON,
67
67
  strokeRectWithRotation_simple
68
- } from "./chunk-A4DEDEZ5.js";
68
+ } from "./chunk-FKBWMG5J.js";
69
69
  import {
70
70
  define_import_meta_env_default
71
- } from "./chunk-JHTRI4CR.js";
71
+ } from "./chunk-ED35ZZUZ.js";
72
72
  import {
73
73
  en_default
74
74
  } from "./chunk-4JOINNOK.js";
@@ -9630,7 +9630,7 @@ var exportCanvas = async (type, elements, appState, files, {
9630
9630
  let blob = canvasToBlob(tempCanvas);
9631
9631
  if (appState.exportEmbedScene) {
9632
9632
  blob = blob.then(
9633
- (blob2) => import("./data/image-E7XPI3XF.js").then(
9633
+ (blob2) => import("./data/image-3Y7D3VR4.js").then(
9634
9634
  ({ encodePngMetadata: encodePngMetadata2 }) => encodePngMetadata2({
9635
9635
  blob: blob2,
9636
9636
  metadata: serializeAsJSON(elements, appState, files, "local")
@@ -25846,6 +25846,151 @@ var MobileMenu = ({
25846
25846
  // components/PasteChartDialog.tsx
25847
25847
  import React31, { useLayoutEffect as useLayoutEffect5, useRef as useRef26, useState as useState29 } from "react";
25848
25848
  import { newTextElement as newTextElement3 } from "@nous-excalidraw/element";
25849
+
25850
+ // ../utils/src/withinBounds.ts
25851
+ import { arrayToMap as arrayToMap24 } from "@nous-excalidraw/common";
25852
+ import { getElementBounds as getElementBounds4 } from "@nous-excalidraw/element";
25853
+ import {
25854
+ isArrowElement as isArrowElement10,
25855
+ isExcalidrawElement as isExcalidrawElement3,
25856
+ isFreeDrawElement as isFreeDrawElement4,
25857
+ isLinearElement as isLinearElement9,
25858
+ isTextElement as isTextElement11
25859
+ } from "@nous-excalidraw/element";
25860
+ import {
25861
+ rangeIncludesValue,
25862
+ pointFrom as pointFrom27,
25863
+ pointRotateRads as pointRotateRads18,
25864
+ rangeInclusive as rangeInclusive2
25865
+ } from "@nous-excalidraw/math";
25866
+ var getNonLinearElementRelativePoints = (element) => {
25867
+ if (element.type === "diamond") {
25868
+ return [
25869
+ pointFrom27(element.width / 2, 0),
25870
+ pointFrom27(element.width, element.height / 2),
25871
+ pointFrom27(element.width / 2, element.height),
25872
+ pointFrom27(0, element.height / 2)
25873
+ ];
25874
+ }
25875
+ return [
25876
+ pointFrom27(0, 0),
25877
+ pointFrom27(0 + element.width, 0),
25878
+ pointFrom27(0 + element.width, element.height),
25879
+ pointFrom27(0, element.height)
25880
+ ];
25881
+ };
25882
+ var getElementRelativePoints = (element) => {
25883
+ if (isLinearElement9(element) || isFreeDrawElement4(element)) {
25884
+ return element.points;
25885
+ }
25886
+ return getNonLinearElementRelativePoints(element);
25887
+ };
25888
+ var getMinMaxPoints = (points) => {
25889
+ const ret = points.reduce(
25890
+ (limits, [x, y]) => {
25891
+ limits.minY = Math.min(limits.minY, y);
25892
+ limits.minX = Math.min(limits.minX, x);
25893
+ limits.maxX = Math.max(limits.maxX, x);
25894
+ limits.maxY = Math.max(limits.maxY, y);
25895
+ return limits;
25896
+ },
25897
+ {
25898
+ minX: Infinity,
25899
+ minY: Infinity,
25900
+ maxX: -Infinity,
25901
+ maxY: -Infinity,
25902
+ cx: 0,
25903
+ cy: 0
25904
+ }
25905
+ );
25906
+ ret.cx = (ret.maxX + ret.minX) / 2;
25907
+ ret.cy = (ret.maxY + ret.minY) / 2;
25908
+ return ret;
25909
+ };
25910
+ var getRotatedBBox = (element) => {
25911
+ const points = getElementRelativePoints(element);
25912
+ const { cx, cy } = getMinMaxPoints(points);
25913
+ const centerPoint = pointFrom27(cx, cy);
25914
+ const rotatedPoints = points.map(
25915
+ (p) => pointRotateRads18(p, centerPoint, element.angle)
25916
+ );
25917
+ const { minX, minY, maxX, maxY } = getMinMaxPoints(rotatedPoints);
25918
+ return [
25919
+ minX + element.x,
25920
+ minY + element.y,
25921
+ maxX + element.x,
25922
+ maxY + element.y
25923
+ ];
25924
+ };
25925
+ var isElementInsideBBox = (element, bbox, eitherDirection = false) => {
25926
+ const elementBBox = getRotatedBBox(element);
25927
+ const elementInsideBbox = bbox[0] <= elementBBox[0] && bbox[2] >= elementBBox[2] && bbox[1] <= elementBBox[1] && bbox[3] >= elementBBox[3];
25928
+ if (!eitherDirection) {
25929
+ return elementInsideBbox;
25930
+ }
25931
+ if (elementInsideBbox) {
25932
+ return true;
25933
+ }
25934
+ return elementBBox[0] <= bbox[0] && elementBBox[2] >= bbox[2] && elementBBox[1] <= bbox[1] && elementBBox[3] >= bbox[3];
25935
+ };
25936
+ var elementPartiallyOverlapsWithOrContainsBBox = (element, bbox) => {
25937
+ const elementBBox = getRotatedBBox(element);
25938
+ return (rangeIncludesValue(elementBBox[0], rangeInclusive2(bbox[0], bbox[2])) || rangeIncludesValue(
25939
+ bbox[0],
25940
+ rangeInclusive2(elementBBox[0], elementBBox[2])
25941
+ )) && (rangeIncludesValue(elementBBox[1], rangeInclusive2(bbox[1], bbox[3])) || rangeIncludesValue(
25942
+ bbox[1],
25943
+ rangeInclusive2(elementBBox[1], elementBBox[3])
25944
+ ));
25945
+ };
25946
+ var elementsOverlappingBBox = ({
25947
+ elements,
25948
+ bounds,
25949
+ type,
25950
+ errorMargin = 0
25951
+ }) => {
25952
+ if (isExcalidrawElement3(bounds)) {
25953
+ bounds = getElementBounds4(bounds, arrayToMap24(elements));
25954
+ }
25955
+ const adjustedBBox = [
25956
+ bounds[0] - errorMargin,
25957
+ bounds[1] - errorMargin,
25958
+ bounds[2] + errorMargin,
25959
+ bounds[3] + errorMargin
25960
+ ];
25961
+ const includedElementSet = /* @__PURE__ */ new Set();
25962
+ for (const element of elements) {
25963
+ if (includedElementSet.has(element.id)) {
25964
+ continue;
25965
+ }
25966
+ const isOverlaping = type === "overlap" ? elementPartiallyOverlapsWithOrContainsBBox(element, adjustedBBox) : type === "inside" ? isElementInsideBBox(element, adjustedBBox) : isElementInsideBBox(element, adjustedBBox, true);
25967
+ if (isOverlaping) {
25968
+ includedElementSet.add(element.id);
25969
+ if (element.boundElements) {
25970
+ for (const boundElement of element.boundElements) {
25971
+ includedElementSet.add(boundElement.id);
25972
+ }
25973
+ }
25974
+ if (isTextElement11(element) && element.containerId) {
25975
+ includedElementSet.add(element.containerId);
25976
+ }
25977
+ if (isArrowElement10(element)) {
25978
+ if (element.startBinding) {
25979
+ includedElementSet.add(element.startBinding.elementId);
25980
+ }
25981
+ if (element.endBinding) {
25982
+ includedElementSet.add(element.endBinding?.elementId);
25983
+ }
25984
+ }
25985
+ }
25986
+ }
25987
+ return elements.filter((element) => includedElementSet.has(element.id));
25988
+ };
25989
+
25990
+ // ../utils/src/index.ts
25991
+ import { getCommonBounds as getCommonBounds6 } from "@nous-excalidraw/element";
25992
+
25993
+ // components/PasteChartDialog.tsx
25849
25994
  import { jsx as jsx95, jsxs as jsxs54 } from "react/jsx-runtime";
25850
25995
  var getChartTypeLabel = (chartType) => {
25851
25996
  switch (chartType) {
@@ -25893,8 +26038,9 @@ var ChartPreviewBtn = (props) => {
25893
26038
  viewBackgroundColor: "#fff",
25894
26039
  exportWithDarkMode: theme === "dark"
25895
26040
  },
25896
- files: {},
25897
- skipInliningFonts: true
26041
+ files: null,
26042
+ // files
26043
+ exportPadding: 0
25898
26044
  });
25899
26045
  svg.querySelector(".style-fonts")?.remove();
25900
26046
  previewNode.replaceChildren();
@@ -25944,8 +26090,8 @@ var PlainTextPreviewBtn = (props) => {
25944
26090
  viewBackgroundColor: "#fff",
25945
26091
  exportWithDarkMode: theme === "dark"
25946
26092
  },
25947
- files: {},
25948
- skipInliningFonts: true
26093
+ files: null,
26094
+ exportPadding: 0
25949
26095
  });
25950
26096
  svg.querySelector(".style-fonts")?.remove();
25951
26097
  previewNode.replaceChildren();
@@ -27633,7 +27779,7 @@ import {
27633
27779
  getFontString as getFontString10
27634
27780
  } from "@nous-excalidraw/common";
27635
27781
  import { newTextElement as newTextElement4 } from "@nous-excalidraw/element";
27636
- import { isTextElement as isTextElement11, isFrameLikeElement as isFrameLikeElement10 } from "@nous-excalidraw/element";
27782
+ import { isTextElement as isTextElement12, isFrameLikeElement as isFrameLikeElement10 } from "@nous-excalidraw/element";
27637
27783
  import { getDefaultFrameName } from "@nous-excalidraw/element/frame";
27638
27784
  import { Fragment as Fragment18, jsx as jsx115, jsxs as jsxs67 } from "react/jsx-runtime";
27639
27785
  var searchQueryAtom = atom("");
@@ -27962,7 +28108,7 @@ var MatchListBase = (props) => {
27962
28108
  [props.matches]
27963
28109
  );
27964
28110
  const textMatches = useMemo9(
27965
- () => props.matches.items.filter((match) => isTextElement11(match.element)),
28111
+ () => props.matches.items.filter((match) => isTextElement12(match.element)),
27966
28112
  [props.matches]
27967
28113
  );
27968
28114
  return /* @__PURE__ */ jsxs67("div", { children: [
@@ -28165,7 +28311,7 @@ var handleSearch = debounce2(
28165
28311
  }
28166
28312
  const elements = app.scene.getNonDeletedElements();
28167
28313
  const texts = elements.filter(
28168
- (el) => isTextElement11(el)
28314
+ (el) => isTextElement12(el)
28169
28315
  );
28170
28316
  const frames = elements.filter(
28171
28317
  (el) => isFrameLikeElement10(el)
@@ -28335,7 +28481,7 @@ var TTDDialogInput = ({
28335
28481
  setShowSpinner(true);
28336
28482
  }
28337
28483
  }, SPINNER_DELAY_MS);
28338
- import("./components/TTDDialog/CodeMirrorEditor-EJU7XIUQ.js").then((mod) => {
28484
+ import("./components/TTDDialog/CodeMirrorEditor-6AT2I7WX.js").then((mod) => {
28339
28485
  if (!cancelled) {
28340
28486
  setEditorState({ type: "ready", component: mod.default });
28341
28487
  }
@@ -28810,151 +28956,6 @@ import {
28810
28956
  THEME as THEME15
28811
28957
  } from "@nous-excalidraw/common";
28812
28958
  import { convertToExcalidrawElements } from "@nous-excalidraw/element";
28813
-
28814
- // ../utils/src/withinBounds.ts
28815
- import { arrayToMap as arrayToMap24 } from "@nous-excalidraw/common";
28816
- import { getElementBounds as getElementBounds4 } from "@nous-excalidraw/element";
28817
- import {
28818
- isArrowElement as isArrowElement10,
28819
- isExcalidrawElement as isExcalidrawElement3,
28820
- isFreeDrawElement as isFreeDrawElement4,
28821
- isLinearElement as isLinearElement9,
28822
- isTextElement as isTextElement12
28823
- } from "@nous-excalidraw/element";
28824
- import {
28825
- rangeIncludesValue,
28826
- pointFrom as pointFrom27,
28827
- pointRotateRads as pointRotateRads18,
28828
- rangeInclusive as rangeInclusive2
28829
- } from "@nous-excalidraw/math";
28830
- var getNonLinearElementRelativePoints = (element) => {
28831
- if (element.type === "diamond") {
28832
- return [
28833
- pointFrom27(element.width / 2, 0),
28834
- pointFrom27(element.width, element.height / 2),
28835
- pointFrom27(element.width / 2, element.height),
28836
- pointFrom27(0, element.height / 2)
28837
- ];
28838
- }
28839
- return [
28840
- pointFrom27(0, 0),
28841
- pointFrom27(0 + element.width, 0),
28842
- pointFrom27(0 + element.width, element.height),
28843
- pointFrom27(0, element.height)
28844
- ];
28845
- };
28846
- var getElementRelativePoints = (element) => {
28847
- if (isLinearElement9(element) || isFreeDrawElement4(element)) {
28848
- return element.points;
28849
- }
28850
- return getNonLinearElementRelativePoints(element);
28851
- };
28852
- var getMinMaxPoints = (points) => {
28853
- const ret = points.reduce(
28854
- (limits, [x, y]) => {
28855
- limits.minY = Math.min(limits.minY, y);
28856
- limits.minX = Math.min(limits.minX, x);
28857
- limits.maxX = Math.max(limits.maxX, x);
28858
- limits.maxY = Math.max(limits.maxY, y);
28859
- return limits;
28860
- },
28861
- {
28862
- minX: Infinity,
28863
- minY: Infinity,
28864
- maxX: -Infinity,
28865
- maxY: -Infinity,
28866
- cx: 0,
28867
- cy: 0
28868
- }
28869
- );
28870
- ret.cx = (ret.maxX + ret.minX) / 2;
28871
- ret.cy = (ret.maxY + ret.minY) / 2;
28872
- return ret;
28873
- };
28874
- var getRotatedBBox = (element) => {
28875
- const points = getElementRelativePoints(element);
28876
- const { cx, cy } = getMinMaxPoints(points);
28877
- const centerPoint = pointFrom27(cx, cy);
28878
- const rotatedPoints = points.map(
28879
- (p) => pointRotateRads18(p, centerPoint, element.angle)
28880
- );
28881
- const { minX, minY, maxX, maxY } = getMinMaxPoints(rotatedPoints);
28882
- return [
28883
- minX + element.x,
28884
- minY + element.y,
28885
- maxX + element.x,
28886
- maxY + element.y
28887
- ];
28888
- };
28889
- var isElementInsideBBox = (element, bbox, eitherDirection = false) => {
28890
- const elementBBox = getRotatedBBox(element);
28891
- const elementInsideBbox = bbox[0] <= elementBBox[0] && bbox[2] >= elementBBox[2] && bbox[1] <= elementBBox[1] && bbox[3] >= elementBBox[3];
28892
- if (!eitherDirection) {
28893
- return elementInsideBbox;
28894
- }
28895
- if (elementInsideBbox) {
28896
- return true;
28897
- }
28898
- return elementBBox[0] <= bbox[0] && elementBBox[2] >= bbox[2] && elementBBox[1] <= bbox[1] && elementBBox[3] >= bbox[3];
28899
- };
28900
- var elementPartiallyOverlapsWithOrContainsBBox = (element, bbox) => {
28901
- const elementBBox = getRotatedBBox(element);
28902
- return (rangeIncludesValue(elementBBox[0], rangeInclusive2(bbox[0], bbox[2])) || rangeIncludesValue(
28903
- bbox[0],
28904
- rangeInclusive2(elementBBox[0], elementBBox[2])
28905
- )) && (rangeIncludesValue(elementBBox[1], rangeInclusive2(bbox[1], bbox[3])) || rangeIncludesValue(
28906
- bbox[1],
28907
- rangeInclusive2(elementBBox[1], elementBBox[3])
28908
- ));
28909
- };
28910
- var elementsOverlappingBBox = ({
28911
- elements,
28912
- bounds,
28913
- type,
28914
- errorMargin = 0
28915
- }) => {
28916
- if (isExcalidrawElement3(bounds)) {
28917
- bounds = getElementBounds4(bounds, arrayToMap24(elements));
28918
- }
28919
- const adjustedBBox = [
28920
- bounds[0] - errorMargin,
28921
- bounds[1] - errorMargin,
28922
- bounds[2] + errorMargin,
28923
- bounds[3] + errorMargin
28924
- ];
28925
- const includedElementSet = /* @__PURE__ */ new Set();
28926
- for (const element of elements) {
28927
- if (includedElementSet.has(element.id)) {
28928
- continue;
28929
- }
28930
- const isOverlaping = type === "overlap" ? elementPartiallyOverlapsWithOrContainsBBox(element, adjustedBBox) : type === "inside" ? isElementInsideBBox(element, adjustedBBox) : isElementInsideBBox(element, adjustedBBox, true);
28931
- if (isOverlaping) {
28932
- includedElementSet.add(element.id);
28933
- if (element.boundElements) {
28934
- for (const boundElement of element.boundElements) {
28935
- includedElementSet.add(boundElement.id);
28936
- }
28937
- }
28938
- if (isTextElement12(element) && element.containerId) {
28939
- includedElementSet.add(element.containerId);
28940
- }
28941
- if (isArrowElement10(element)) {
28942
- if (element.startBinding) {
28943
- includedElementSet.add(element.startBinding.elementId);
28944
- }
28945
- if (element.endBinding) {
28946
- includedElementSet.add(element.endBinding?.elementId);
28947
- }
28948
- }
28949
- }
28950
- }
28951
- return elements.filter((element) => includedElementSet.has(element.id));
28952
- };
28953
-
28954
- // ../utils/src/index.ts
28955
- import { getCommonBounds as getCommonBounds6 } from "@nous-excalidraw/element";
28956
-
28957
- // components/TTDDialog/common.ts
28958
28959
  var resetPreview = ({
28959
28960
  canvasRef,
28960
28961
  setError