I just went through this twice in the last 3 years.
The insurance company receives the repair bill and looks up the book value of the vehicle. If the repair exceeds 80% of the book value, they will consider it a total loss, a.k.a "totaled".
Then they begin a detailed "Actual Cash Value" assessment, what it would have sold for minutes before the damage occurred. They will try to find 8 vehicles for sale in your area of the same model/year/condition and +/-10% odometer with prices in an acceptable range of the book price. The distance from your town gets expanded if necessary until they have at least 5, and average the for-sale prices to come up with the ACA. That is what they will offer you. You do have the right to supply supplemental information, pictures, receipts, your own market research if you disagree and try to come to a better settlement.
I did my own research and my number was within 2% of their actual offer.
If it's your own insurance, they will subtract your collision deductible.
If you want to keep the vehicle, they will subtract a "book salvage value".
If you have a lean against the vehicle, they will pay out the settlement to the lien holder, and the leinholder then gives you the remainder, if any.
If you keep the vehicle you still have to go through retitling paperwork to get it branded as SALVAGE.
Many states will allow you to upgrade the title to REBUILT after the repairs are complete. This requires an application and paperwork submitted for parts/labor and any vin stamped pieces used must have accompanying paperwork, to prove you are not committing fraud, a safety inspection and a VIN inspection, and the application to upgrade the title is approved.