/*
 * 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 = ["M4 0a1 1 0 0 1 .117 1.993L4 2H2v12h2a1 1 0 0 1 .993.883L5 15a1 1 0 0 1-.883.993L4 16H1a1 1 0 0 1-.993-.883L0 15V1A1 1 0 0 1 .883.007L1 0zm11 0a1 1 0 0 1 .993.883L16 1v14a1 1 0 0 1-.883.993L15 16h-3a1 1 0 0 1-.117-1.993L12 14h2V2h-2a1 1 0 0 1-.993-.883L11 1a1 1 0 0 1 .883-.993L12 0zM6.5 3c-.646 0-1.151.205-1.416.725-.117.23-.16.477-.176.692a5 5 0 0 0-.001.622c.017.421.028 1.808-.04 2.024a.5.5 0 0 1-.126.214.8.8 0 0 1-.362.184C4.156 7.523 4 7.745 4 8s.156.477.379.539a.8.8 0 0 1 .362.184.5.5 0 0 1 .126.214c.068.216.057 1.603.04 2.024a5 5 0 0 0 0 .622c.017.215.06.461.177.692.265.52.77.725 1.416.725.276 0 .5-.249.5-.556 0-.306-.224-.555-.5-.555-.467 0-.533-.135-.544-.159l-.001-.001a.7.7 0 0 1-.051-.24 4 4 0 0 1 .005-.558c.015-.34.036-1.93-.097-2.358A1.6 1.6 0 0 0 5.505 8c.146-.174.244-.371.307-.573.133-.427.112-2.017.097-2.358l-.003-.08a4 4 0 0 1-.002-.478.7.7 0 0 1 .05-.24l.002-.001c.011-.024.077-.159.544-.159.276 0 .5-.249.5-.555S6.776 3 6.5 3m3 0c.646 0 1.152.205 1.416.725.117.23.16.477.176.692.017.213.009.434.001.622-.017.421-.027 1.808.04 2.024.027.09.067.157.126.214.063.06.17.13.362.184.223.062.379.284.379.539s-.156.477-.379.539a.8.8 0 0 0-.362.184.5.5 0 0 0-.126.214c-.067.216-.057 1.603-.04 2.024.008.188.016.409 0 .622-.017.215-.06.461-.177.692-.264.52-.77.725-1.416.725-.276 0-.5-.249-.5-.556 0-.306.224-.555.5-.555.467 0 .533-.135.544-.159l.001-.001a.7.7 0 0 0 .051-.24c.01-.132.006-.284-.002-.478l-.003-.08c-.015-.34-.036-1.93.097-2.358A1.6 1.6 0 0 1 10.495 8a1.6 1.6 0 0 1-.307-.573c-.133-.427-.112-2.017-.097-2.358l.003-.08c.008-.194.012-.346.002-.478a.7.7 0 0 0-.05-.24l-.002-.001c-.011-.024-.077-.159-.544-.159-.276 0-.5-.249-.5-.555S9.224 3 9.5 3"] as readonly string[];

/** Path data for the 20px grid; matches {@link generate-icon-paths.mjs} / `<Icon />` from core. */
const PATHS_20 = ["M19 0a1 1 0 0 1 .993.883L20 1v18a1 1 0 0 1-.883.993L19 20h-4a1 1 0 0 1-.117-1.993L15 18h3V2h-3a1 1 0 0 1-.993-.883L14 1a1 1 0 0 1 .883-.993L15 0zM5 0a1 1 0 0 1 .117 1.993L5 2H2v16h3a1 1 0 0 1 .993.883L6 19a1 1 0 0 1-.883.993L5 20H1a1 1 0 0 1-.993-.883L0 19V1A1 1 0 0 1 .883.007L1 0zm3.103 4A1.563 1.563 0 0 0 6.54 5.563v2.473c0 .38-.194.734-.514.94l-.718.46a.67.67 0 0 0 0 1.127l.718.46c.32.206.514.56.514.94v2.474c0 .863.7 1.563 1.563 1.563h.344a.67.67 0 0 0 0-1.34h-.345a.223.223 0 0 1-.224-.223v-2.473a2.46 2.46 0 0 0-.98-1.965 2.46 2.46 0 0 0 .98-1.963V5.563a.223.223 0 0 1 .224-.224h.344a.67.67 0 0 0 0-1.339zm3.607 0c.864 0 1.563.7 1.563 1.563v2.473c0 .38.195.734.515.94l.717.46a.67.67 0 0 1 0 1.127l-.718.46a1.12 1.12 0 0 0-.513.94v2.474A1.563 1.563 0 0 1 11.711 16h-.344a.67.67 0 0 1 0-1.34h.344a.223.223 0 0 0 .224-.223v-2.473c0-.777.366-1.502.98-1.965a2.46 2.46 0 0 1-.98-1.963V5.563a.224.224 0 0 0-.224-.224h-.344a.67.67 0 0 1 0-1.339z"] as readonly string[];

export const ArrayObject: 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="array-object" ref={ref} {...props}>
            {paths.map((d, i) => (
                <path key={i} d={d} fillRule="evenodd" />
            ))}
        </SVGIconContainer>
    );
});
ArrayObject.displayName = `Blueprint6.Icon.ArrayObject`;
export default ArrayObject;
