How Does the State/Province Autocomplete Field Work in Address Doctype?

I’ve noticed that when adding an address in the Address doctype, the State/Province field is an autocomplete field. When I select “India” as the country, it automatically shows a list of states.

Can someone explain how this functionality works? I couldn’t find any related code in the JavaScript file. How is the State/Province field populated based on the selected country?

Thanks in advance for any insights!

It’s a long structure code.

Reference:

@NCP Thanks for your response. I will check the flow

@NCP I want to add same like this, but not for states.
i need to add it for districts.
if user select one state, i need to show districts of that state.
how can i do this, can you pls suggest me?

For testing, i added one custom value in STATE_NUMBERS, but that is not reflecting. Why??
@NCP

Migrate the site and build the app. (check the all configuration)

@NCP would it be possible to implement for another specific country without alternating the code?