(1) As used in this section, the term:
(a) “Convicted” means a determination of guilt which is the result of a trial or the entry of a plea of guilty or nolo contendere, regardless of whether adjudication is withheld.
(b) “Habitual misdemeanor offender” means a defendant who is before the court for sentencing for a specified misdemeanor offense and who has previously been convicted, as an adult, of four or more specified misdemeanor offenses which meet the following criteria:
1. The offenses, in relation to each other and the misdemeanor before the court for sentencing, are separate offenses that are not part of the same criminal transaction or episode.
2. The offenses were committed within 1 year of the date that the misdemeanor before the court for sentencing was committed.
(c) “Specified misdemeanor offense” means those misdemeanor offenses described in chapter 741, chapter 784, chapter 790, chapter 796, chapter 800, chapter 806, chapter 810, chapter 812, chapter 817, chapter 831, chapter 832, chapter 843, chapter 856, chapter 893, or chapter 901.
(d) “Imprisonment” means incarceration in a county jail operated by the county or a private vendor.
(2) If the court finds that a defendant before the court for sentencing for a misdemeanor is a habitual misdemeanor offender, the court shall, unless the court makes a finding that an alternative disposition is in the best interests of the community and defendant, sentence the defendant as a habitual misdemeanor offender and impose one of the following sentences:
(a) A term of imprisonment of not less than 6 months, but not to exceed 1 year;
(b) Commitment to a residential treatment program for not less than 6 months, but not to exceed 364 days, provided that the treatment program is operated by the county or a private vendor with which the county has contracted to operate such program, or by a private vendor under contract with the state or licensed by the state to operate such program, and provided that any referral to a residential treatment facility is in accordance with the assessment criteria for residential treatment established by the Department of Children and Families, and that residential treatment beds are available or other community-based treatment program or a combination of residential and community-based program; or
(c) Detention for not less than 6 months, but not to exceed 364 days, to a designated residence, if the detention is supervised or monitored by the county or by a private vendor with which the county has contracted to supervise or monitor the detention.
The court may not sentence a defendant under this subsection if the misdemeanor offense before the court for sentencing has been reclassified as a felony as a result of any prior qualifying misdemeanor.