This happened to me, a US citizen, when I was returning to the US from Europe. They stopped me and asked me to hand over my electronics with passwords. I refused and they told me I had to sit in the room by myself until I gave them my electronics. I asked for a lawyer and they told me I am not entitled to a lawyer because I had not fully entered the US yet. After over an hour I finally gave them my electronics and passwords. After CBP gave the electronics back to me I threw them away.