/* eslint-disable */
/* =========================================================
   TEO Logo — inline React SVG components.
   Inlined (rather than <img src>) so the logo can never 404
   regardless of how the page is served (file://, sub-path
   server, Launch preview panel, etc.).
   Both variants accept `height` and `color` props; `color`
   defaults match the variant name (light = white, dark = navy).
   ========================================================= */

// The four-vesica TEO mark, intrinsic viewBox 62 x 67.14
const TeoMark = ({ height = 28, color = 'currentColor', style }) => (
  <svg
    xmlns="http://www.w3.org/2000/svg"
    viewBox="0 0 62 67.14"
    height={height}
    style={{ display:'block', ...style }}
    fill={color}
    fillRule="evenodd"
    aria-hidden="true"
  >
    <path d="M58.3,19.29c0-5.11-1.36-10.15-3.92-14.58l-.14-.25h-.29c-10.45,0-19.64,5.53-24.78,13.82C24.01,9.98,14.81,4.44,4.34,4.44h-.29l-.14.25C1.35,9.11,0,14.15,0,19.29s1.37,10.09,3.77,14.33c-2.4,4.23-3.77,9.12-3.77,14.33s1.35,10.18,3.91,14.6l.14.25h.29c10.47,0,19.67-5.54,24.82-13.84,5.15,8.29,14.34,13.83,24.8,13.83h.29l.14-.25c2.55-4.41,3.91-9.46,3.91-14.59s-1.37-10.09-3.77-14.33c2.4-4.23,3.77-9.12,3.77-14.33ZM53.66,5.46c2.39,4.22,3.64,8.99,3.64,13.83s-1.22,9.36-3.36,13.33c-5-8.06-13.83-13.52-23.93-13.82,4.92-7.92,13.67-13.24,23.64-13.34ZM53.38,33.61c-4.77,8.03-13.41,13.5-23.33,13.81,2.22-4.11,3.48-8.82,3.48-13.81s-1.26-9.7-3.48-13.81c9.92.31,18.56,5.78,23.33,13.81ZM1,19.29c0-4.86,1.26-9.64,3.63-13.85,9.99.1,18.75,5.42,23.68,13.36-10.11.29-18.95,5.75-23.95,13.82-2.14-3.97-3.36-8.51-3.36-13.33ZM28.28,19.8c-2.22,4.11-3.48,8.82-3.48,13.81s1.26,9.7,3.49,13.81c-9.93-.3-18.59-5.78-23.36-13.81,4.77-8.04,13.42-13.51,23.36-13.81ZM4.63,61.78c-2.38-4.2-3.63-8.98-3.63-13.84s1.22-9.36,3.36-13.33c5.01,8.07,13.84,13.53,23.95,13.82-4.93,7.94-13.69,13.25-23.68,13.36ZM25.8,33.61c0-4.82,1.22-9.37,3.37-13.34,2.15,3.97,3.37,8.52,3.37,13.34s-1.22,9.37-3.37,13.34c-2.15-3.97-3.37-8.52-3.37-13.34ZM57.3,47.94c0,4.86-1.25,9.63-3.63,13.83-9.98-.1-18.73-5.42-23.66-13.35,10.1-.3,18.92-5.75,23.93-13.82,2.14,3.97,3.36,8.51,3.36,13.33Z" />
  </svg>
);

// Full wordmark (mark + "TEO" lettering), intrinsic viewBox 232.45 x 67.14
const TeoWordmark = ({ height = 28, color = 'currentColor', style }) => (
  <svg
    xmlns="http://www.w3.org/2000/svg"
    viewBox="0 0 232.45 67.14"
    height={height}
    style={{ display:'block', ...style }}
    fill={color}
    fillRule="evenodd"
    aria-hidden="true"
  >
    <g>
      <path d="M69.11,1.44h50.94v7.11h-21.42v57.24h-8.1V8.55h-21.42V1.44Z" />
      <path d="M123.56,1.44h45.45v7.11h-37.35v20.34h33.93v6.84h-33.93v22.59h38.43v7.47h-46.53V1.44Z" />
      <path d="M169.46,33.57c0-19.26,12.06-33.57,31.5-33.57s31.5,14.31,31.5,33.57-12.06,33.57-31.5,33.57-31.5-14.31-31.5-33.57ZM224.17,33.57c0-15.12-8.1-26.55-23.22-26.55s-23.22,11.43-23.22,26.55,8.1,26.46,23.22,26.46,23.22-11.34,23.22-26.46Z" />
    </g>
    <path d="M58.3,19.29c0-5.11-1.36-10.15-3.92-14.58l-.14-.25h-.29c-10.45,0-19.64,5.53-24.78,13.82C24.01,9.98,14.81,4.44,4.34,4.44h-.29l-.14.25C1.35,9.11,0,14.15,0,19.29s1.37,10.09,3.77,14.33c-2.4,4.23-3.77,9.12-3.77,14.33s1.35,10.18,3.91,14.6l.14.25h.29c10.47,0,19.67-5.54,24.82-13.84,5.15,8.29,14.34,13.83,24.8,13.83h.29l.14-.25c2.55-4.41,3.91-9.46,3.91-14.59s-1.37-10.09-3.77-14.33c2.4-4.23,3.77-9.12,3.77-14.33ZM53.66,5.46c2.39,4.22,3.64,8.99,3.64,13.83s-1.22,9.36-3.36,13.33c-5-8.06-13.83-13.52-23.93-13.82,4.92-7.92,13.67-13.24,23.64-13.34ZM53.38,33.61c-4.77,8.03-13.41,13.5-23.33,13.81,2.22-4.11,3.48-8.82,3.48-13.81s-1.26-9.7-3.48-13.81c9.92.31,18.56,5.78,23.33,13.81ZM1,19.29c0-4.86,1.26-9.64,3.63-13.85,9.99.1,18.75,5.42,23.68,13.36-10.11.29-18.95,5.75-23.95,13.82-2.14-3.97-3.36-8.51-3.36-13.33ZM28.28,19.8c-2.22,4.11-3.48,8.82-3.48,13.81s1.26,9.7,3.49,13.81c-9.93-.3-18.59-5.78-23.36-13.81,4.77-8.04,13.42-13.51,23.36-13.81ZM4.63,61.78c-2.38-4.2-3.63-8.98-3.63-13.84s1.22-9.36,3.36-13.33c5.01,8.07,13.84,13.53,23.95,13.82-4.93,7.94-13.69,13.25-23.68,13.36ZM25.8,33.61c0-4.82,1.22-9.37,3.37-13.34,2.15,3.97,3.37,8.52,3.37,13.34s-1.22,9.37-3.37,13.34c-2.15-3.97-3.37-8.52-3.37-13.34ZM57.3,47.94c0,4.86-1.25,9.63-3.63,13.83-9.98-.1-18.73-5.42-23.66-13.35,10.1-.3,18.92-5.75,23.93-13.82,2.14,3.97,3.36,8.51,3.36,13.33Z" />
  </svg>
);

// Partner co-brand mark (e.g. Teltonika), driven by window.TENANT.brand.partner.
// variant 'dark' => logo for dark surfaces (white); 'light' => logo for white surfaces (blue).
// Falls back SVG -> PNG -> text so it renders sensibly before the asset is uploaded.
const PartnerMark = ({ variant = 'dark', height = 20, style }) => {
  const p = (window.TENANT && window.TENANT.brand && window.TENANT.brand.partner) || null;
  if (!p) return null;
  const svg = variant === 'light' ? p.logoOnLight    : p.logoOnDark;
  const png = variant === 'light' ? p.logoOnLightPng : p.logoOnDarkPng;
  const [src, setSrc] = React.useState(svg || png || null);
  const onErr = () => { setSrc(prev => (prev === svg && png) ? png : null); };
  if (!src) {
    return (
      <span style={{
        fontFamily:'IBM Plex Sans, sans-serif', fontWeight:700, letterSpacing:'0.05em',
        fontSize: Math.round(height * 0.72), lineHeight:1,
        color: variant === 'light' ? '#1B2A6B' : '#FFFFFF', ...style
      }}>TELTONIKA</span>
    );
  }
  return <img src={src} alt={p.name + ' logo'} onError={onErr}
    style={{ display:'block', height, width:'auto', ...style }} />;
};

// Sidebar co-brand lockup: "Deployed for" + partner mark (white on the dark rail).
const CoBrand = ({ style }) => {
  const p = (window.TENANT && window.TENANT.brand && window.TENANT.brand.partner) || null;
  if (!p) return null;
  return (
    <div style={{ display:'flex', flexDirection:'column', alignItems:'flex-start', gap:8, ...style }}>
      <span style={{ fontSize:10, letterSpacing:'0.14em', textTransform:'uppercase', color:'rgba(255,255,255,.4)' }}>Deployed for</span>
      <PartnerMark variant="dark" height={18} style={{ marginLeft:0 }} />
    </div>
  );
};

Object.assign(window, { TeoMark, TeoWordmark, PartnerMark, CoBrand });
