HEX
Server: nginx/1.24.0
System: Linux nowruzgan 6.8.0-57-generic #59-Ubuntu SMP PREEMPT_DYNAMIC Sat Mar 15 17:40:59 UTC 2025 x86_64
User: babak (1000)
PHP: 8.3.6
Disabled: NONE
Upload Files
File: /var/dev/nowruzgan/admin/node_modules/safevalues/internals/style_sheet_impl.mjs
/**
 * @license
 * SPDX-License-Identifier: Apache-2.0
 */
import '../environment/dev';
import { ensureTokenIsValid, secretToken } from './secrets';
/**
 * A complete CSS style sheet, safe to use in style contexts in an HTML document
 * or DOM APIs.
 */
export class SafeStyleSheet {
    // @ts-ignore: error TS6133: 'brand' is declared but its value is never read.
    brand; // To prevent structural typing.
}
/** Implementation for `SafeStyleSheet` */
class StyleSheetImpl extends SafeStyleSheet {
    privateDoNotAccessOrElseWrappedStyleSheet;
    constructor(styleSheet, token) {
        super();
        if (process.env.NODE_ENV !== 'production') {
            ensureTokenIsValid(token);
        }
        this.privateDoNotAccessOrElseWrappedStyleSheet = styleSheet;
    }
    toString() {
        return this.privateDoNotAccessOrElseWrappedStyleSheet;
    }
}
/**
 * Builds a new `SafeStyleSheet` from the given string, without enforcing
 * safety guarantees. This shouldn't be exposed to application developers, and
 * must only be used as a step towards safe builders or safe constants.
 */
export function createStyleSheet(styleSheet) {
    return new StyleSheetImpl(styleSheet, secretToken);
}
/**
 * Checks if the given value is a `SafeStyleSheet` instance.
 */
export function isStyleSheet(value) {
    return value instanceof StyleSheetImpl;
}
/**
 * Returns the string value of the passed `SafeStyleSheet` object while
 * ensuring it has the correct type.
 */
export function unwrapStyleSheet(value) {
    if (value instanceof StyleSheetImpl) {
        return value.privateDoNotAccessOrElseWrappedStyleSheet;
    }
    else {
        let message = '';
        if (process.env.NODE_ENV !== 'production') {
            message = 'Unexpected type when unwrapping SafeStyleSheet';
        }
        throw new Error(message);
    }
}