{"version":3,"file":"utils.mjs","sources":["../../../../../../packages/components/watermark/src/utils.ts"],"sourcesContent":["import type { CSSProperties } from 'vue';\n\n/** converting camel-cased strings to be lowercase and link it with Separato */\nexport function toLowercaseSeparator(key: string) {\n  return key.replace(/([A-Z])/g, '-$1').toLowerCase();\n}\n\nexport function getStyleStr(style: CSSProperties): string {\n  return Object.keys(style).map((key: keyof CSSProperties) => `${toLowercaseSeparator(key)}: ${style[key]};`).join(' ');\n}\n\n/** Returns the ratio of the device's physical pixel resolution to the css pixel resolution */\nexport function getPixelRatio() {\n  return window.devicePixelRatio || 1;\n}\n\n/** Rotate with the watermark as the center point */\nexport function rotateWatermark(\n  ctx: CanvasRenderingContext2D,\n  rotateX: number,\n  rotateY: number,\n  rotate: number,\n) {\n  ctx.translate(rotateX, rotateY);\n  ctx.rotate((Math.PI / 180) * Number(rotate));\n  ctx.translate(-rotateX, -rotateY);\n}\n\n/** Whether to re-render the watermark */\nexport function reRendering(mutation: MutationRecord, watermarkElement?: HTMLElement) {\n  let flag = false;\n  // Whether to delete the watermark node\n  if (mutation.removedNodes.length && watermarkElement)\n    flag = Array.from(mutation.removedNodes).includes(watermarkElement);\n\n  // Whether the watermark dom property value has been modified\n  if (mutation.type === 'attributes' && mutation.target === watermarkElement)\n    flag = true;\n\n  return flag;\n}\n"],"names":[],"mappings":"AAGO,SAAS,qBAAqB,GAAa,EAAA;AAChD,EAAA,OAAO,GAAI,CAAA,OAAA,CAAQ,UAAY,EAAA,KAAK,EAAE,WAAY,EAAA,CAAA;AACpD,CAAA;AAEO,SAAS,YAAY,KAA8B,EAAA;AACxD,EAAA,OAAO,OAAO,IAAK,CAAA,KAAK,EAAE,GAAI,CAAA,CAAC,QAA6B,CAAG,EAAA,oBAAA,CAAqB,GAAG,CAAC,KAAK,KAAM,CAAA,GAAG,CAAC,CAAG,CAAA,CAAA,CAAA,CAAE,KAAK,GAAG,CAAA,CAAA;AACtH,CAAA;AAGO,SAAS,aAAgB,GAAA;AAC9B,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