/** A signer class that proxies requests to another signer that isn't created yet */
export class ProxySigner {
    upstream;
    error;
    _signer;
    get signer() {
        if (!this._signer)
            throw new Error(this.error || "Missing signer");
        return this._signer;
    }
    get nip04() {
        if (!this.signer.nip04)
            throw new Error("Signer does not support nip04");
        return this.signer.nip04;
    }
    get nip44() {
        if (!this.signer.nip44)
            throw new Error("Signer does not support nip44");
        return this.signer.nip44;
    }
    constructor(upstream, error) {
        this.upstream = upstream;
        this.error = error;
        this.upstream.subscribe((signer) => (this._signer = signer));
    }
    async signEvent(template) {
        return this.signer.signEvent(template);
    }
    async getPublicKey() {
        return this.signer.getPublicKey();
    }
}
