{
  "version": 3,
  "sources": ["../../src/document/components/chrome/properties/utils/imageFill.ts", "../../src/document/models/CanvasTree/traits/utils/hasReplicaOverrides.ts"],
  "sourcesContent": ["import type { AssetSize } from \"@framerjs/assets\"\nimport { parseAssetReference } from \"@framerjs/assets\"\nimport type { CanvasNode } from \"document/models/CanvasTree/index.ts\"\nimport { isFrameNode } from \"document/models/CanvasTree/nodes/utils/nodeCheck.ts\"\nimport type { WithFill, WithOptionalFill } from \"document/models/CanvasTree/traits/WithFill.ts\"\nimport { hasFocalPoint, withOptionalFill } from \"document/models/CanvasTree/traits/WithFill.ts\"\nimport type { WithIntrinsicSize } from \"document/models/CanvasTree/traits/WithIntrinsicSize.ts\"\nimport { createAssetReferenceForUploadImageResult } from \"document/utils/createAssetReferenceFromImageUpload.ts\"\nimport { isString } from \"utils/typeChecks.ts\"\nimport { imageSizeToNonZero } from \"web/lib/images/image.ts\"\nimport type { ImageUploadResult } from \"web/pages/project/lib/UploadService.ts\"\nimport type { TilingBackgroundPatternPresetName } from \"../rows/FillImagePatternPresetsRow/presetOptions.ts\"\n\nexport type FillUpdate = Partial<WithFill> & Partial<WithOptionalFill & Partial<WithIntrinsicSize>>\n\nexport function applyImageFillToNode(\n\tnode: CanvasNode & (WithFill | WithOptionalFill),\n\tuploadedImage: ImageUploadResult,\n\tpresetName?: TilingBackgroundPatternPresetName,\n\tpreferredSize?: AssetSize,\n): void {\n\tconst { imageSize, originalFilename } = uploadedImage\n\n\tconst currentSize = isString(node.fillImage) ? parseAssetReference(node.fillImage)?.preferredSize : undefined\n\n\tconst assetReference = createAssetReferenceForUploadImageResult(\n\t\tuploadedImage,\n\t\tpreferredSize ?? currentSize,\n\t\tpresetName,\n\t)\n\n\tconst update: FillUpdate = {\n\t\tfillType: \"image\",\n\t\tfillImage: assetReference,\n\t\tfillImageOriginalName: originalFilename,\n\t\t// No imageSizeToNonZero because guessing here isn't helpful\n\t\tfillImagePixelWidth: imageSize.naturalWidth,\n\t\tfillImagePixelHeight: imageSize.naturalHeight,\n\t\t...focalPointResetUpdates(node),\n\t}\n\n\tif (withOptionalFill(node) && node.fillEnabled === false) {\n\t\tupdate.fillEnabled = true\n\t}\n\n\tif (isFrameNode(node)) {\n\t\t// Non-zero as to have something visible\n\t\tconst { nonZeroNaturalWidth, nonZeroNaturalHeight } = imageSizeToNonZero(imageSize)\n\t\tupdate.intrinsicWidth = nonZeroNaturalWidth\n\t\tupdate.intrinsicHeight = nonZeroNaturalHeight\n\t}\n\n\tnode.set(update)\n}\n\n/**\n * Returns a node update with the `fillImagePositionX` and `fillImagePositionY` properties set to `undefined` if the node has a focal point.\n */\nfunction focalPointResetUpdates(\n\tnode: CanvasNode & WithFill,\n): Pick<WithFill, \"fillImagePositionX\" | \"fillImagePositionY\"> | undefined {\n\tif (!hasFocalPoint(node)) return undefined\n\n\treturn {\n\t\tfillImagePositionX: undefined,\n\t\tfillImagePositionY: undefined,\n\t}\n}\n", "import type { TraitType } from \"../TraitType.ts\"\nimport { traitTypeMap } from \"../TraitType.ts\"\n\n// Check if the replica has overrides of the given trait types/keys.\n// If specific traitTypeKeys are given, it will ignore the trait types and just check the keys.\nexport function hasReplicaOverrides(\n\toverrideKeys: Set<string>,\n\ttraitTypes: readonly TraitType[] | undefined,\n\ttraitTypeKeys: readonly string[] | undefined,\n): boolean {\n\tif (!traitTypes && !traitTypeKeys) return false\n\n\tfor (const overrideKey of overrideKeys) {\n\t\tconst overriddenTrait = traitTypeMap[overrideKey]\n\n\t\tif (traitTypeKeys) {\n\t\t\tif (traitTypeKeys.includes(overrideKey)) return true\n\t\t} else if (traitTypes && overriddenTrait && traitTypes.includes(overriddenTrait)) {\n\t\t\treturn true\n\t\t}\n\t}\n\n\treturn false\n}\n"],
  "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;AAeO,SAAS,qBACf,MACA,eACA,YACA,eACO;AACP,QAAM,EAAE,WAAW,iBAAiB,IAAI;AAExC,QAAM,cAAc,SAAS,KAAK,SAAS,IAAI,oBAAo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