{
"version": 3,
"sources": ["../../../../src/lib/shapes/shared/ShapeFill.tsx"],
"sourcesContent": ["import {\n\tHASH_PATTERN_ZOOM_NAMES,\n\tTLDefaultColorStyle,\n\tTLDefaultColorTheme,\n\tTLDefaultFillStyle,\n\tgetDefaultColorTheme,\n\tuseEditor,\n\tuseIsDarkMode,\n\tuseValue,\n} from '@tldraw/editor'\nimport React from 'react'\n\nexport interface ShapeFillProps {\n\td: string\n\tfill: TLDefaultFillStyle\n\tcolor: TLDefaultColorStyle\n\ttheme: TLDefaultColorTheme\n}\n\nexport function useDefaultColorTheme() {\n\treturn getDefaultColorTheme({ isDarkMode: useIsDarkMode() })\n}\n\nexport const ShapeFill = React.memo(function ShapeFill({ theme, d, color, fill }: ShapeFillProps) {\n\tswitch (fill) {\n\t\tcase 'none': {\n\t\t\treturn null\n\t\t}\n\t\tcase 'solid': {\n\t\t\treturn \n\t\t}\n\t\tcase 'semi': {\n\t\t\treturn \n\t\t}\n\t\tcase 'pattern': {\n\t\t\treturn \n\t\t}\n\t}\n})\n\nconst PatternFill = function PatternFill({ d, color, theme }: ShapeFillProps) {\n\tconst editor = useEditor()\n\tconst zoomLevel = useValue('zoomLevel', () => editor.zoomLevel, [editor])\n\n\tconst intZoom = Math.ceil(zoomLevel)\n\tconst teenyTiny = editor.zoomLevel <= 0.18\n\n\treturn (\n\t\t<>\n\t\t\t\n\t\t\t\n\t\t>\n\t)\n}\n\nexport function getShapeFillSvg({ d, color, fill, theme }: ShapeFillProps) {\n\tif (fill === 'none') {\n\t\treturn\n\t}\n\n\tif (fill === 'pattern') {\n\t\tconst gEl = document.createElementNS('http://www.w3.org/2000/svg', 'g')\n\t\tconst path1El = document.createElementNS('http://www.w3.org/2000/svg', 'path')\n\t\tpath1El.setAttribute('d', d)\n\t\tpath1El.setAttribute('fill', theme[color].pattern)\n\n\t\tconst path2El = document.createElementNS('http://www.w3.org/2000/svg', 'path')\n\t\tpath2El.setAttribute('d', d)\n\t\tpath2El.setAttribute('fill', `url(#hash_pattern)`)\n\n\t\tgEl.appendChild(path1El)\n\t\tgEl.appendChild(path2El)\n\t\treturn gEl\n\t}\n\n\tconst path = document.createElementNS('http://www.w3.org/2000/svg', 'path')\n\tpath.setAttribute('d', d)\n\n\tswitch (fill) {\n\t\tcase 'semi': {\n\t\t\tpath.setAttribute('fill', theme.solid)\n\t\t\tbreak\n\t\t}\n\t\tcase 'solid': {\n\t\t\t{\n\t\t\t\tpath.setAttribute('fill', theme[color].semi)\n\t\t\t}\n\t\t\tbreak\n\t\t}\n\t}\n\n\treturn path\n}\n\nexport function getSvgWithShapeFill(foregroundPath: SVGElement, backgroundPath?: SVGElement) {\n\tif (backgroundPath) {\n\t\t// If there is a fill element, return a group containing the fill and the path\n\t\tconst g = document.createElementNS('http://www.w3.org/2000/svg', 'g')\n\t\tg.appendChild(backgroundPath)\n\t\tg.appendChild(foregroundPath)\n\t\treturn g\n\t} else {\n\t\t// Otherwise, just return the path\n\t\treturn foregroundPath\n\t}\n}\n"],
"mappings": "AA6BU,SAmBR,UAnBQ,KAmBR,YAnBQ;AA7BV;AAAA,EACC;AAAA,EAIA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AACP,OAAO,WAAW;AASX,SAAS,uBAAuB;AACtC,SAAO,qBAAqB,EAAE,YAAY,cAAc,EAAE,CAAC;AAC5D;AAEO,MAAM,YAAY,MAAM,KAAK,SAASA,WAAU,EAAE,OAAO,GAAG,OAAO,KAAK,GAAmB;AACjG,UAAQ,MAAM;AAAA,IACb,KAAK,QAAQ;AACZ,aAAO;AAAA,IACR;AAAA,IACA,KAAK,SAAS;AACb,aAAO,oBAAC,UAAK,MAAM,MAAM,KAAK,EAAE,MAAM,GAAM;AAAA,IAC7C;AAAA,IACA,KAAK,QAAQ;AACZ,aAAO,oBAAC,UAAK,MAAM,MAAM,OAAO,GAAM;AAAA,IACvC;AAAA,IACA,KAAK,WAAW;AACf,aAAO,oBAAC,eAAY,OAAc,OAAc,MAAY,GAAM;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