{
  "version": 3,
  "sources": ["../../src/lib/Tldraw.tsx"],
  "sourcesContent": ["import {\n\tCanvas,\n\tEditor,\n\tErrorScreen,\n\tLoadingScreen,\n\tStoreSnapshot,\n\tTLOnMountHandler,\n\tTLRecord,\n\tTLStore,\n\tTLStoreWithStatus,\n\tTldrawEditor,\n\tTldrawEditorBaseProps,\n\tTldrawEditorProps,\n\tassert,\n\tuseEditor,\n\tuseShallowArrayIdentity,\n\tuseShallowObjectIdentity,\n} from '@bigbluebutton/editor'\nimport { useCallback, useDebugValue, useLayoutEffect, useMemo, useRef } from 'react'\nimport { TldrawHandles } from './canvas/TldrawHandles'\nimport { TldrawHoveredShapeIndicator } from './canvas/TldrawHoveredShapeIndicator'\nimport { TldrawScribble } from './canvas/TldrawScribble'\nimport { TldrawSelectionBackground } from './canvas/TldrawSelectionBackground'\nimport { TldrawSelectionForeground } from './canvas/TldrawSelectionForeground'\nimport {\n\tTLExternalContentProps,\n\tregisterDefaultExternalContentHandlers,\n} from './defaultExternalContentHandlers'\nimport { defaultShapeTools } from './defaultShapeTools'\nimport { defaultShapeUtils } from './defaultShapeUtils'\nimport { registerDefaultSideEffects } from './defaultSideEffects'\nimport { defaultTools } from './defaultTools'\nimport { TldrawUi, TldrawUiProps } from './ui/TldrawUi'\nimport { ContextMenu } from './ui/components/ContextMenu'\nimport { usePreloadAssets } from './ui/hooks/usePreloadAssets'\nimport { useDefaultEditorAssetsWithOverrides } from './utils/static-assets/assetUrls'\n\n/** @public */\nexport type TldrawProps = TldrawEditorBaseProps &\n\t(\n\t\t| {\n\t\t\t\tstore: TLStore | TLStoreWithStatus\n\t\t  }\n\t\t| {\n\t\t\t\tstore?: undefined\n\t\t\t\tpersistenceKey?: string\n\t\t\t\tsessionId?: string\n\t\t\t\tdefaultName?: string\n\t\t\t\t/**\n\t\t\t\t * A snapshot to load for the store's initial data / schema.\n\t\t\t\t */\n\t\t\t\tsnapshot?: StoreSnapshot<TLRecord>\n\t\t  }\n\t) &\n\tTldrawUiProps &\n\tPartial<TLExternalContentProps>\n\n/** @public */\nexport function Tldraw(props: TldrawProps) {\n\tconst {\n\t\tchildren,\n\t\tmaxImageDimension,\n\t\tmaxAssetSize,\n\t\tacceptedImageMimeTypes,\n\t\tacceptedVideoMimeTypes,\n\t\tonMount,\n\t\t...rest\n\t} = props\n\n\tconst components = useShallowObjectIdentity(rest.components ?? {})\n\tconst shapeUtils = useShallowArrayIdentity(rest.shapeUtils ?? [])\n\tconst tools = useShallowArrayIdentity(rest.tools ?? [])\n\n\tconst withDefaults: TldrawEditorProps = {\n\t\tinitialState: 'select',\n\t\t...rest,\n\t\tcomponents: useMemo(\n\t\t\t() => ({\n\t\t\t\tScribble: TldrawScribble,\n\t\t\t\tCollaboratorScribble: TldrawScribble,\n\t\t\t\tSelectionForeground: TldrawSelectionForeground,\n\t\t\t\tSelectionBackground: TldrawSelectionBackground,\n\t\t\t\tHandles: TldrawHandles,\n\t\t\t\tHoveredShapeIndicator: TldrawHoveredShapeIndicator,\n\t\t\t\t...components,\n\t\t\t}),\n\t\t\t[components]\n\t\t),\n\t\tshapeUtils: useMemo(() => [...defaultShapeUtils, ...shapeUtils], [shapeUtils]),\n\t\ttools: useMemo(() => [...defaultTools, ...defaultShapeTools, ...tools], [tools]),\n\t}\n\n\tconst assets = useDefaultEditorAssetsWithOverrides(rest.assetUrls)\n\n\tconst { done: preloadingComplete, error: preloadingError } = usePreloadAssets(assets)\n\n\tif (preloadingError) {\n\t\treturn <ErrorScreen>Could not load assets. Please refresh the page.</ErrorScreen>\n\t}\n\n\tif (!preloadingComplete) {\n\t\treturn <LoadingScreen>Loading assets...</LoadingScreen>\n\t}\n\n\treturn (\n\t\t<TldrawEditor {...withDefaults}>\n\t\t\t<TldrawUi {...withDefaults}>\n\t\t\t\t<ContextMenu>\n\t\t\t\t\t<Canvas />\n\t\t\t\t</ContextMenu>\n\t\t\t\t<InsideOfEditorContext\n\t\t\t\t\tmaxImageDimension={maxImageDimension}\n\t\t\t\t\tmaxAssetSize={maxAssetSize}\n\t\t\t\t\tacceptedImageMimeTypes={acceptedImageMimeTypes}\n\t\t\t\t\tacceptedVideoMimeTypes={acceptedVideoMimeTypes}\n\t\t\t\t\tonMount={onMount}\n\t\t\t\t/>\n\t\t\t\t{children}\n\t\t\t</TldrawUi>\n\t\t</TldrawEditor>\n\t)\n}\n\n// We put these hooks into a component here so that they can run inside of the context provided by TldrawEditor.\nfunction InsideOfEditorContext({\n\tmaxImageDimension = 1000,\n\tmaxAssetSize = 10 * 1024 * 1024, // 10mb\n\tacceptedImageMimeTypes = ['image/jpeg', 'image/png', 'image/gif', 'image/svg+xml'],\n\tacceptedVideoMimeTypes = ['video/mp4', 'video/quicktime'],\n\tonMount,\n}: Partial<TLExternalContentProps & { onMount: TLOnMountHandler }>) {\n\tconst editor = useEditor()\n\n\tconst onMountEvent = useEvent((editor: Editor) => {\n\t\tconst unsubs: (void | (() => void) | undefined)[] = []\n\n\t\tunsubs.push(...registerDefaultSideEffects(editor))\n\n\t\t// for content handling, first we register the default handlers...\n\t\tregisterDefaultExternalContentHandlers(editor, {\n\t\t\tmaxImageDimension,\n\t\t\tmaxAssetSize,\n\t\t\tacceptedImageMimeTypes,\n\t\t\tacceptedVideoMimeTypes,\n\t\t})\n\n\t\t// ...then we run the onMount prop, which may override the above\n\t\tunsubs.push(onMount?.(editor))\n\n\t\treturn () => {\n\t\t\tunsubs.forEach((fn) => fn?.())\n\t\t}\n\t})\n\n\tuseLayoutEffect(() => {\n\t\tif (editor) return onMountEvent?.(editor)\n\t}, [editor, onMountEvent])\n\n\treturn null\n}\n\n// duped from tldraw editor\nfunction useEvent<Args extends Array<unknown>, Result>(\n\thandler: (...args: Args) => Result\n): (...args: Args) => Result {\n\tconst handlerRef = useRef<(...args: Args) => Result>()\n\n\tuseLayoutEffect(() => {\n\t\thandlerRef.current = handler\n\t})\n\n\tuseDebugValue(handler)\n\n\treturn useCallback((...args: Args) => {\n\t\tconst fn = handlerRef.current\n\t\tassert(fn,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