/* eslint-env node */
import { ImageResponse } from '@vercel/og'
export const config = {
  runtime: 'edge'
}

export default async function image(req) {
  const { searchParams } = new URL(req.url)
  const hasTitle = searchParams.has('title')
  const title = hasTitle ? searchParams.get('title')?.slice(0, 100) : 'OpenLLM Documentation'

  return new ImageResponse(
    (
      <div
        style={{
          height: '100%',
          width: '100%',
          display: 'flex',
          flexDirection: 'column',
          alignItems: 'flex-start',
          justifyContent: 'center',
          padding: 80,
          backgroundColor: '#030303',
          backgroundImage: 'radial-gradient(circle at 25px 25px, #333 2%, transparent 0%), radial-gradient(circle at 75px 75px, #333 2%, transparent 0%)',
          backgroundSize: '100px 100px',
          backgroundPosition: '-30px -10px',
          fontWeight: 600,
          color: 'white'
        }}
      >
        <svg style={{ position: 'absolute', top: 70, left: 80 }} height="40" viewBox="0 0 373 60" xmlns="http://www.w3.org/2000/svg" fill="white">
          <path d="m59.56,3.16c-.11-.35-.26-.69-.45-.99-.23-.37-.5-.71-.82-1-.05-.05-.11-.1-.16-.14-.39-.32-.83-.58-1.31-.76s-1-.27-1.55-.27H14.94c-.09,0-.18,0-.27,0-.03,0-.05,0-.08,0-.07,0-.13.01-.2.02-.03,0-.06,0-.08.01-.08.01-.15.02-.23.04-.01,0-.02,0-.03,0-.09.02-.17.04-.26.06-.02,0-.05.01-.07.02-.06.02-.12.04-.19.06-.03,0-.05.02-.08.03-.07.02-.13.05-.2.08-.02,0-.03.01-.05.02-.08.03-.16.07-.24.11-.02,0-.04.02-.06.03-.06.03-.12.06-.18.09-.02.01-.05.03-.07.04-.06.03-.12.07-.17.11-.02.01-.03.02-.05.03-.07.05-.14.1-.21.15-.01.01-.03.02-.04.03-.06.04-.11.09-.16.13-.02.02-.04.03-.06.05-.05.04-.1.09-.15.13-.02.01-.03.03-.05.04-.03.03-.05.05-.08.08,0,0,0,0,0,0L1.12,10.91c-.72.72-1.12,1.69-1.12,2.7v42.57c0,2.11,1.71,3.82,3.82,3.82h42.57c1.01,0,1.99-.4,2.7-1.12l9.52-11.05c.17-.19.33-.4.47-.62,0,0,.01-.02.02-.02.03-.04.05-.09.08-.13,0-.02.02-.03.03-.05.02-.04.04-.08.06-.12.01-.02.02-.04.03-.07.02-.04.04-.08.05-.12.01-.03.02-.05.03-.08.02-.04.03-.07.05-.11.01-.03.02-.06.03-.09.01-.04.03-.07.04-.11.01-.03.02-.06.03-.09.01-.04.02-.07.03-.11,0-.03.02-.07.03-.1,0-.03.02-.07.03-.1,0-.04.02-.07.02-.11,0-.03.02-.07.02-.1,0-.04.01-.08.02-.12,0-.03.01-.06.02-.1,0-.04.01-.08.02-.13,0-.03,0-.06.01-.09,0-.05,0-.1.01-.14,0-.03,0-.05,0-.08,0-.07,0-.15,0-.22V4.5h0c0-.47-.07-.91-.2-1.34Zm-4.3-1.81c.54,0,1.05.14,1.5.38.22.12.43.27.62.44.04.03.07.07.11.1.07.07.14.15.2.22.06.08.12.16.18.24.34.5.54,1.11.54,1.76v40.33c0,.09,0,.18-.01.27,0,.01,0,.02,0,.03,0,.08-.02.17-.03.25,0,.01,0,.02,0,.04-.02.08-.03.16-.06.24,0,0,0,.02,0,.03-.02.08-.05.16-.08.24,0,0,0,0,0,0-.1.26-.23.5-.38.71h0c-.05.08-.11.15-.17.22-.04.04-.07.08-.11.12,0,0,0,0,0,0-.04.04-.07.08-.11.11,0,0,0,0,0,0-.04.04-.08.07-.12.11,0,0,0,0,0,0-.21.18-.44.33-.7.45,0,0-.01,0-.02,0-.04.02-.09.04-.13.06-.01,0-.02,0-.04.01-.04.02-.08.03-.12.04-.02,0-.03.01-.05.02-.04.01-.07.02-.11.03-.02,0-.04.01-.05.02-.03,0-.07.02-.1.03-.02,0-.04,0-.06.01-.03,0-.07.01-.1.02-.02,0-.04,0-.06.01-.04,0-.07.01-.11.02-.02,0-.04,0-.06,0-.04,0-.08,0-.12.01-.02,0-.03,0-.05,0-.06,0-.11,0-.17,0H14.94c-.87,0-1.66-.35-2.23-.92-.14-.14-.27-.3-.38-.47-.28-.42-.47-.91-.52-1.44-.01-.11-.02-.21-.02-.32V4.5c0-.06,0-.12,0-.18,0-.02,0-.04,0-.06,0-.04,0-.08.01-.12,0-.02,0-.04,0-.06,0-.04.01-.07.02-.11,0-.02,0-.04.01-.06,0-.04.01-.07.02-.11,0-.02,0-.04.01-.06.01-.04.02-.08.03-.12,0-.01,0-.03.01-.04.03-.11.07-.22.12-.32,0,0,0,0,0,0,.02-.05.04-.1.07-.15,0,0,0-.02.01-.02.02-.04.04-.09.07-.13,0,0,0-.02.01-.03.02-.04.05-.08.08-.13,0,0,0-.01.01-.02.03-.05.06-.09.09-.14,0,0,0,0,0,0,.17-.24.38-.45.61-.63.2-.16.42-.29.65-.39,0,0,0,0,.01,0,.07-.03.15-.06.23-.09,0,0,.01,0,.02,0,.15-.05.31-.09.47-.12.01,0,.03,0,.04,0,.08-.01.15-.02.23-.03.01,0,.03,0,.04,0,.08,0,.16-.01.25-.01h40.33Z" />
          <g>
            <circle cx="40.54" cy="24.66" r="2.74" />
            <circle cx="29.67" cy="24.66" r="2.74" />
          </g>
          <path
            d="M 289.083 46.203 L 288.423 46.863 L 280.503 46.863 L 279.843 46.203 L 279.843 20.463 L 279.183 20.463 L 268.623 46.203 L 267.963 46.863 L 260.703 46.863 L 260.043 46.203 L 249.483 20.463 L 248.823 20.463 L 248.823 46.203 L 248.163 46.863 L 240.243 46.863 L 239.583 46.203 L 239.583 1.323 L 240.243 0.663 L 250.143 0.663 L 250.803 1.323 L 264.003 33.663 L 264.663 33.663 L 277.863 1.323 L 278.523 0.663 L 288.423 0.663 L 289.083 1.323 L 289.083 46.203 Z M 157.083 46.203 L 156.423 46.863 L 148.503 46.863 L 147.843 46.203 L 147.843 27.063 A 9.504 9.504 0 0 0 147.624 24.942 C 147.237 23.261 146.306 21.954 144.574 21.405 A 6.64 6.64 0 0 0 142.563 21.123 C 138.845 21.123 136.41 22.832 135.6 26.595 A 14.825 14.825 0 0 0 135.303 29.703 L 135.303 46.203 L 134.643 46.863 L 126.723 46.863 L 126.063 46.203 L 126.063 14.523 L 126.723 13.863 L 133.983 13.863 L 134.643 14.523 L 135.303 16.503 L 135.963 16.503 C 137.035 15.43 138.979 13.922 142.149 13.394 A 14.552 14.552 0 0 1 144.543 13.203 C 150.174 13.203 154.136 15.872 155.957 20.26 A 15.995 15.995 0 0 1 157.083 26.403 L 157.083 46.203 Z M 196.683 46.203 L 196.023 46.863 L 166.323 46.863 L 165.663 46.203 L 165.663 1.323 L 166.323 0.663 L 174.243 0.663 L 174.903 1.323 L 174.903 38.283 L 175.563 38.943 L 196.023 38.943 L 196.683 39.603 L 196.683 46.203 Z M 233.643 46.203 L 232.983 46.863 L 203.283 46.863 L 202.623 46.203 L 202.623 1.323 L 203.283 0.663 L 211.203 0.663 L 211.863 1.323 L 211.863 38.283 L 212.523 38.943 L 232.983 38.943 L 233.643 39.603 L 233.643 46.203 Z M 61.383 16.503 A 10.855 10.855 0 0 1 65.339 13.985 A 13.327 13.327 0 0 1 69.963 13.203 A 13.467 13.467 0 0 1 77.875 15.729 C 80.198 17.396 82.071 19.843 83.221 22.933 A 21.239 21.239 0 0 1 84.483 30.363 A 24.331 24.331 0 0 1 84.419 32.132 C 84.217 34.909 83.538 37.375 82.493 39.475 A 13.867 13.867 0 0 1 69.963 47.523 A 14.252 14.252 0 0 1 68.838 47.478 C 65.957 47.25 63.076 46.15 61.383 44.223 L 60.723 44.223 L 60.723 59.403 L 60.063 60.063 L 52.143 60.063 L 51.483 59.403 L 51.483 14.523 L 52.143 13.863 L 59.403 13.863 L 60.063 14.523 L 60.723 16.503 L 61.383 16.503 Z M 74.715 34.547 A 15.037 15.037 0 0 0 75.243 30.363 C 75.243 26.238 74.034 22.919 70.988 21.664 A 7.832 7.832 0 0 0 67.983 21.123 C 64.229 21.123 62.143 23.124 61.251 26.179 A 15.037 15.037 0 0 0 60.723 30.363 C 60.723 34.488 61.931 37.807 64.978 39.062 A 7.832 7.832 0 0 0 67.983 39.603 C 71.737 39.603 73.823 37.601 74.715 34.547 Z M 118.803 37.623 A 11.13 11.13 0 0 1 118.53 38.832 C 117.436 42.686 113.876 47.523 104.943 47.523 A 19.831 19.831 0 0 1 99.708 46.862 C 96.245 45.917 93.607 44.011 91.757 41.496 A 18.68 18.68 0 0 1 88.443 30.363 A 23.169 23.169 0 0 1 88.602 27.634 C 89.553 19.616 94.78 13.203 104.283 13.203 A 18.458 18.458 0 0 1 108.27 13.62 C 116.172 15.365 120.123 22.37 120.123 30.363 L 120.123 33.003 L 119.463 33.663 L 99.003 33.663 L 98.343 34.323 A 3.127 3.127 0 0 0 98.402 34.885 C 98.665 36.296 99.879 38.794 103.215 39.444 A 9.017 9.017 0 0 0 104.943 39.603 C 106.923 39.603 108.903 38.943 109.563 37.623 L 110.223 36.963 L 118.143 36.963 L 118.803 37.623 Z M 109.563 27.063 L 110.223 26.403 C 110.223 25.81 109.69 22.015 105.745 21.255 A 7.717 7.717 0 0 0 104.283 21.123 A 7.919 7.919 0 0 0 103.055 21.214 C 98.897 21.866 98.343 25.798 98.343 26.403 L 99.003 27.063 L 109.563 27.063 Z M 44.883 23.763 A 30.343 30.343 0 0 1 44.282 29.875 C 42.882 36.684 39.086 42.045 33.427 44.998 A 23.532 23.532 0 0 1 22.443 47.523 C 8.583 47.523 0.003 37.623 0.003 23.763 A 30.343 30.343 0 0 1 0.604 17.651 C 2.004 10.842 5.8 5.481 11.459 2.528 A 23.532 23.532 0 0 1 22.443 0.003 C 36.303 0.003 44.883 9.903 44.883 23.763 Z M 34.501 31.018 A 21.772 21.772 0 0 0 35.643 23.763 A 22.28 22.28 0 0 0 34.7 17.104 C 33.623 13.675 31.637 10.998 28.802 9.441 A 13.039 13.039 0 0 0 22.443 7.923 C 16.343 7.923 12.245 11.259 10.385 16.508 A 21.772 21.772 0 0 0 9.243 23.763 A 22.28 22.28 0 0 0 10.186 30.422 C 11.263 33.851 13.249 36.528 16.084 38.085 A 13.039 13.039 0 0 0 22.443 39.603 C 28.543 39.603 32.641 36.267 34.501 31.018 Z"
            vectorEffect="non-scaling-stroke"
            transform="translate(70, 2.5)"
          />
        </svg>
        <p
          style={{
            position: 'absolute',
            bottom: 70,
            left: 80,
            margin: 0,
            fontSize: 30,
            letterSpacing: -1
          }}
        >
          Fine-tune, serve and deploy LLMs in production.
        </p>
        <h1
          style={{
            fontSize: 82,
            margin: '0 0 40px -2px',
            lineHeight: 1.1,
            textShadow: '0 2px 30px #000',
            letterSpacing: -4,
            backgroundImage: 'linear-gradient(90deg, #fff 40%, #aaa)',
            backgroundClip: 'text',
            '-webkit-background-clip': 'text',
            color: 'transparent'
          }}
        >
          {title}
        </h1>
      </div>
    ),
    {
      width: 1200,
      height: 630
    }
  )
}
