Which territory existed as an independent republic before becoming a state?