{"version":3,"file":"CspNonceProvider-DCyEpeWS.cjs","sources":["../src/components/CspNonce/CspNonceProvider.tsx"],"sourcesContent":["'use client';\n\nimport { createContext, useContext } from 'react';\nimport type { CspNonceProviderProps } from './CspNonce.types';\n\nconst CspNonceContext = createContext<string | undefined>(undefined);\n\n/**\n * Supplies the page's CSP nonce to every scoped `<style>` element Canny-UI\n * emits: responsive `sx` on `Box` and on `withSx`-based components (e.g.\n * `Divider`), `CannyLoader`'s keyframes, and the styles Radix overlays inject\n * (the `Select` viewport's scrollbar rule and the scroll lock of every\n * overlay). Under a nonce-based `style-src` / `style-src-elem` policy the\n * browser blocks those elements unless they carry the nonce. Mount once near\n * the root, with the nonce from the response's Content-Security-Policy\n * header. Without a provider the elements render exactly as before (no nonce\n * attribute).\n */\nexport function CspNonceProvider({ nonce, children }: CspNonceProviderProps) {\n  // Radix overlays (Dialog, Select, Menu, …) lock body scroll through\n  // react-remove-scroll, whose style singleton reads its nonce from the\n  // `__webpack_nonce__` global — its documented integration point — not from\n  // React context. Set it in the render body so it exists before any overlay\n  // mounts, and only in the browser: a module global set during SSR would\n  // leak one request's nonce into the next.\n  if (typeof window !== 'undefined' && nonce) {\n    (globalThis as { __webpack_nonce__?: string }).__webpack_nonce__ = nonce;\n  }\n  return <CspNonceContext.Provider value={nonce}>{children}</CspNonceContext.Provider>;\n}\n\n/** The nonce from the nearest `CspNonceProvider`, or `undefined` outside one. */\nexport function useCspNonce(): string | undefined {\n  return useContext(CspNonceContext);\n}\n"],"names":["CspNonceContext","createContext","CspNonceProvider","nonce","children","useCspNonce","useContext"],"mappings":"kFAKMA,EAAkBC,EAAAA,cAAkC,MAAS,EAa5D,SAASC,EAAiB,CAAE,MAAAC,EAAO,SAAAC,GAAmC,CAO3E,OAAI,OAAO,OAAW,KAAeD,IAClC,WAA8C,kBAAoBA,SAE7DH,EAAgB,SAAhB,CAAyB,MAAOG,EAAQ,SAAAC,EAAS,CAC3D,CAGO,SAASC,GAAkC,CAChD,OAAOC,EAAAA,WAAWN,CAAe,CACnC"}