The Barbary Wars were two wars fought at different times over the same reasons between the United States, Sweden and the Barbary states (the de jure possessions of the Ottoman Empire, but de facto independent, Tunis, Algiers, and Tripoli) of North Africa in the late 18th and early 19th centuries.
The options are: attack the pirates, limit pirates' actions, buy peace, and avoid the pirates.
The Americans have no idea that there were pirates in North America seaports because Britain and France paid for America before 1783. In 1785, the pirates started to take American an ships and sailors and Yusuf demanded a high price for Jefferson to pay for the ships ($4000 per ship) and sailors ($1400 per sailor). Congress only willing to contribute $200 and Jefferson refused to the offer, so the Barbary states declared war on America.