/*
 * Copyright 2024 Palantir Technologies, Inc. All rights reserved.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import * as React from "react";
import type { SVGIconProps } from "../../svgIconProps";
import { IconSize } from "../../iconTypes";
import { SVGIconContainer } from "../../svgIconContainer";

/** Path data for the 16px grid; matches {@link generate-icon-paths.mjs} / `<Icon />` from core. */
const PATHS_16 = ["M2 1a1 1 0 0 1 1-1h7l5 5v10a1 1 0 0 1-1 1h-2.518A2.5 2.5 0 0 0 12 14.5q-.002-.267-.053-.5H13V6H9V2H4v8.514a2.6 2.6 0 0 0-.492.5A2.34 2.34 0 0 0 2 10.046zm5.491 14.988L7.5 16h-.018zM1.5 11a1.42 1.42 0 0 0-1.035.426c-.262.268-.41.626-.46 1.008L0 12.467V14.5c0 .76.655 1.5 1.5 1.5A1.5 1.5 0 0 0 3 14.5a.5.5 0 0 0-1 0 .5.5 0 0 1-.5.5c-.26 0-.5-.26-.5-.5v-1.964a.75.75 0 0 1 .18-.412A.42.42 0 0 1 1.5 12c.173 0 .264.048.321.104.066.064.146.197.184.466a.5.5 0 1 0 .99-.14c-.057-.406-.2-.773-.474-1.04-.28-.275-.642-.39-1.021-.39M4 12.5c0-.76.655-1.5 1.5-1.5A1.5 1.5 0 0 1 7 12.5a.5.5 0 0 1-1 0 .5.5 0 0 0-.5-.5c-.26 0-.5.26-.5.5 0 .092.028.154.129.236.126.103.31.188.575.308l.027.011c.23.104.533.239.773.434.274.225.496.55.496 1.011 0 .76-.655 1.5-1.5 1.5A1.5 1.5 0 0 1 4 14.5a.5.5 0 0 1 1 0 .5.5 0 0 0 .5.5c.26 0 .5-.26.5-.5 0-.092-.028-.154-.129-.236-.126-.103-.31-.188-.575-.308l-.027-.011c-.23-.104-.533-.239-.773-.434C4.222 13.286 4 12.96 4 12.5M9.5 11c-.845 0-1.5.74-1.5 1.5 0 .46.222.786.496 1.01.24.196.543.331.773.435l.027.011c.266.12.45.205.575.308.1.082.129.144.129.236 0 .24-.24.5-.5.5a.5.5 0 0 1-.5-.5.5.5 0 0 0-1 0A1.5 1.5 0 0 0 9.5 16c.845 0 1.5-.74 1.5-1.5 0-.46-.222-.786-.496-1.01-.24-.196-.543-.331-.773-.435l-.027-.011c-.266-.12-.45-.205-.575-.308-.1-.082-.129-.144-.129-.236 0-.24.24-.5.5-.5a.5.5 0 0 1 .5.5.5.5 0 0 0 1 0A1.5 1.5 0 0 0 9.5 11"] as readonly string[];

/** Path data for the 20px grid; matches {@link generate-icon-paths.mjs} / `<Icon />` from core. */
const PATHS_20 = ["M3 1a1 1 0 0 1 1-1h9l6 6v13a1 1 0 0 1-1 1h-3.708c.4-.44.708-1.042.708-1.75q0-.13-.012-.25H17V7h-5V2H5v11.72l-.04.035c-.164.141-.32.308-.458.497a2.7 2.7 0 0 0-.546-.605A2.8 2.8 0 0 0 3 13.142zM2 14c-.518 0-.982.158-1.34.463A1.93 1.93 0 0 0 0 15.75v2.5c0 .492.26.933.613 1.238C.97 19.797 1.46 20 2 20c1.015 0 2-.702 2-1.75a.5.5 0 0 0-1 0c0 .333-.358.75-1 .75a1.13 1.13 0 0 1-.734-.27c-.19-.163-.266-.347-.266-.48v-2.5a.84.84 0 0 1 .308-.526C1.463 15.092 1.69 15 2 15c.334 0 .55.081.69.196.139.113.26.304.317.638a.5.5 0 0 0 .986-.168c-.086-.51-.3-.943-.67-1.244C2.957 14.122 2.494 14 2 14m3.613.512A2.13 2.13 0 0 1 7 14c1.015 0 2 .702 2 1.75a.5.5 0 0 1-1 0c0-.333-.358-.75-1-.75-.289 0-.549.11-.734.27-.19.163-.266.347-.266.48 0 .121.049.229.25.366.221.15.533.27.925.416l.03.01c.353.132.776.29 1.107.516.362.245.688.623.688 1.192 0 .492-.26.933-.613 1.238A2.13 2.13 0 0 1 7 20c-1.015 0-2-.702-2-1.75a.5.5 0 0 1 1 0c0 .333.358.75 1 .75.289 0 .549-.11.734-.27.19-.163.266-.347.266-.48 0-.121-.049-.229-.25-.366-.288-.195-.632-.306-.955-.427-.353-.131-.776-.289-1.107-.515C5.326 16.697 5 16.32 5 15.75c0-.492.26-.933.613-1.238M12 14c-.54 0-1.03.203-1.387.512-.353.305-.613.746-.613 1.238 0 .57.326.947.688 1.192.331.226.754.384 1.107.515.323.12.667.232.955.427.201.137.25.245.25.366 0 .133-.076.317-.266.48A1.13 1.13 0 0 1 12 19c-.642 0-1-.417-1-.75a.5.5 0 0 0-1 0c0 1.048.985 1.75 2 1.75.54 0 1.03-.203 1.387-.512.353-.305.613-.746.613-1.238 0-.57-.326-.947-.688-1.192-.331-.226-.754-.384-1.107-.515l-.03-.011c-.392-.146-.704-.266-.925-.416-.201-.137-.25-.245-.25-.366 0-.133.076-.317.266-.48.185-.16.445-.27.734-.27.642 0 1 .417 1 .75a.5.5 0 0 0 1 0c0-1.048-.985-1.75-2-1.75"] as readonly string[];

export const CssStyle: React.FC<SVGIconProps> = React.forwardRef<any, SVGIconProps>((props, ref) => {
    const isLarge = (props.size ?? IconSize.STANDARD) >= IconSize.LARGE;
    const paths = isLarge ? PATHS_20 : PATHS_16;
    return (
        <SVGIconContainer iconName="css-style" ref={ref} {...props}>
            {paths.map((d, i) => (
                <path key={i} d={d} fillRule="evenodd" />
            ))}
        </SVGIconContainer>
    );
});
CssStyle.displayName = `Blueprint6.Icon.CssStyle`;
export default CssStyle;
