{"ast":null,"code":"import * as React from 'react';\nimport { getStyleStr } from './utils';\n/**\n * Base size of the canvas, 1 for parallel layout and 2 for alternate layout\n * Only alternate layout is currently supported\n */\nexport const BaseSize = 2;\nexport const FontGap = 3;\n// Prevent external hidden elements from adding accent styles\nconst emphasizedStyle = {\n visibility: 'visible !important'\n};\nexport default function useWatermark(markStyle) {\n const [watermarkMap] = React.useState(() => new Map());\n const appendWatermark = (base64Url, markWidth, container) => {\n if (container) {\n if (!watermarkMap.get(container)) {\n const newWatermarkEle = document.createElement('div');\n watermarkMap.set(container, newWatermarkEle);\n }\n const watermarkEle = watermarkMap.get(container);\n watermarkEle.setAttribute('style', getStyleStr(Object.assign(Object.assign(Object.assign({}, markStyle), {\n backgroundImage: `url('${base64Url}')`,\n backgroundSize: `${Math.floor(markWidth)}px`\n }), emphasizedStyle)));\n // Prevents using the browser `Hide Element` to hide watermarks\n watermarkEle.removeAttribute('class');\n if (watermarkEle.parentElement !== container) {\n container.append(watermarkEle);\n }\n }\n return watermarkMap.get(container);\n };\n const removeWatermark = container => {\n const watermarkEle = watermarkMap.get(container);\n if (watermarkEle && container) {\n container.removeChild(watermarkEle);\n }\n watermarkMap.delete(container);\n };\n const isWatermarkEle = ele => Array.from(watermarkMap.values()).includes(ele);\n return [appendWatermark, removeWatermark, isWatermarkEle];\n}","map":{"version":3,"names":["React","getStyleStr","BaseSize","FontGap","emphasizedStyle","visibility","useWatermark","markStyle","watermarkMap","useState","Map","appendWatermark","base64Url","markWidth","container","get","newWatermarkEle","document","createElement","set","watermarkEle","setAttribute","Object","assign","backgroundImage","backgroundSize","Math","floor","removeAttribute","parentElement","append","removeWatermark","removeChild","delete","isWatermarkEle","ele","Array","from","values","includes"],"sources":["C:/Users/Аришина)/Desktop/promo/node_modules/antd/es/watermark/useWatermark.js"],"sourcesContent":["import * as React from 'react';\nimport { getStyleStr } from './utils';\n/**\n * Base size of the canvas, 1 for parallel layout and 2 for alternate layout\n * Only alternate layout is currently supported\n */\nexport const BaseSize = 2;\nexport const FontGap = 3;\n// Prevent external hidden elements from adding accent styles\nconst emphasizedStyle = {\n visibility: 'visible !important'\n};\nexport default function useWatermark(markStyle) {\n const [watermarkMap] = React.useState(() => new Map());\n const appendWatermark = (base64Url, markWidth, container) => {\n if (container) {\n if (!watermarkMap.get(container)) {\n const newWatermarkEle = document.createElement('div');\n watermarkMap.set(container, newWatermarkEle);\n }\n const watermarkEle = watermarkMap.get(container);\n watermarkEle.setAttribute('style', getStyleStr(Object.assign(Object.assign(Object.assign({}, markStyle), {\n backgroundImage: `url('${base64Url}')`,\n backgroundSize: `${Math.floor(markWidth)}px`\n }), emphasizedStyle)));\n // Prevents using the browser `Hide Element` to hide watermarks\n watermarkEle.removeAttribute('class');\n if (watermarkEle.parentElement !== container) {\n container.append(watermarkEle);\n }\n }\n return watermarkMap.get(container);\n };\n const removeWatermark = container => {\n const watermarkEle = watermarkMap.get(container);\n if (watermarkEle && container) {\n container.removeChild(watermarkEle);\n }\n watermarkMap.delete(container);\n };\n const isWatermarkEle = ele => Array.from(watermarkMap.values()).includes(ele);\n return [appendWatermark, removeWatermark, isWatermarkEle];\n}"],"mappings":"AAAA,OAAO,KAAKA,KAAK,MAAM,OAAO;AAC9B,SAASC,WAAW,QAAQ,SAAS;AACrC;AACA;AACA;AACA;AACA,OAAO,MAAMC,QAAQ,GAAG,CAAC;AACzB,OAAO,MAAMC,OAAO,GAAG,CAAC;AACxB;AACA,MAAMC,eAAe,GAAG;EACtBC,UAAU,EAAE;AACd,CAAC;AACD,eAAe,SAASC,YAAYA,CAACC,SAAS,EAAE;EAC9C,MAAM,CAACC,YAAY,CAAC,GAAGR,KAAK,CAACS,QAAQ,CAAC,MAAM,IAAIC,GAAG,CAAC,CAAC,CAAC;EACtD,MAAMC,eAAe,GAAGA,CAACC,SAAS,EAAEC,SAAS,EAAEC,SAAS,KAAK;IAC3D,IAAIA,SAAS,EAAE;MACb,IAAI,CAACN,YAAY,CAACO,GAAG,CAACD,SAAS,CAA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