// VPS-flyt: plan → OS/lokasjon/vertsnavn → handlevogn. Ingen domenesteg.
import React, { useState } from 'react';
const NS = window.STWORDER;
const HOSTNAME_RE = /^([a-z0-9-]+\.)*[a-z0-9-]+(\.[a-zæøå]{2,})?$/i;
function Field({ label, hint, children }) {
return (
);
}
function VpsConfigurator({ plan }) {
const { useI18n, nok, Btn, StepHeading, localName } = NS.ui;
const { t, lang } = useI18n();
const [os, setOs] = useState(NS.data.vpsOs[0]);
const [loc, setLoc] = useState(NS.data.vpsLocations[0].id);
const [hostname, setHostname] = useState('');
const [cycle, setCycle] = useState('monthly');
const hostnameOk = hostname.trim() === '' || HOSTNAME_RE.test(hostname.trim());
const due = NS.store.cyclePrice(plan.monthly, cycle);
const location = NS.data.vpsLocations.find((l) => l.id === loc);
function add() {
NS.store.add({
type: 'vps',
planId: plan.id,
name: plan.name,
cycle,
monthly: plan.monthly,
os,
location: loc,
hostname: hostname.trim() || null,
});
NS.bus.emit('cart:open');
}
const selectCls = 'w-full rounded-lg border border-gray-300 bg-white px-3 py-2.5 text-sm text-navy outline-none focus:border-brand';
return (