
    Vg                     f    d dl Z d dlZd dlmZ d dlmZ d dlmZmZ ddlm	Z	 dZ
dZ G d	 d
e	      Zy)    N)ceil)ascii_uppercase)DictOptional   )BaseProviderTen_GBc                   <   e Zd ZU dZej
                  D  ci c]  }|t        t        |      dz         c}}}} Ze	eef   e
d<   dZee
d<   dZee
d<   defd	Zdefd
ZdefdZdefdZddedefdZddededefdZ	 	 	 ddee   dededefdZyc c}}}} w )Providera  Implement default bank provider for Faker.

    .. important::
       Bank codes, account numbers, and other ID's generated by this provider
       are only valid in form, i.e. they conform to some standard/format, are
       of the expected lengths, and have valid checksums (where applicable).
       Results generated that turn out to be valid in real life are purely
       coincidental.

    Sources:

    - https://en.wikipedia.org/wiki/International_Bank_Account_Number
    - https://www.theswiftcodes.com/swift-code-checker/
    7   ALPHAz????#############bban_formatGBcountry_codereturnc                 0   | j                  dd      }| j                  d      }|d| }|D cg c]  }t        |       }}d|d   |d   z   |d   z   z  d	|d   |d
   z   |d	   z   z  z   |d   z   |d   z   }t        |dz        dz  |z
  }| | S c c}w )z'Generate an ABA routing transit number.      )minmaxz######02   r            r      
   )
random_intnumerifyintr   )selffed_numrandaband	chk_digits          ^/var/www/html/hubwallet-dev/venv/lib/python3.12/site-packages/faker/providers/bank/__init__.pyr$   zProvider.aba"   s    //aR/0}}X&TF# !!SV!!1!qt+,qAaD1Q4K!A$4F/GG!A$NQRSTQUU	R(2-	9	yk""	 "s   Bc                     | j                   S )z=Generate the bank provider's ISO 3166-1 alpha-2 country code.)r   )r!   s    r(   bank_countryzProvider.bank_country/   s           c                 n     t        j                  d fd j                        } j                  |      S )z,Generate a Basic Bank Account Number (BBAN).z\?c                 .    j                  t              S N)random_elementr   )xr!   s    r(   <lambda>zProvider.bban.<locals>.<lambda>5   s    t':':?'K r+   )resubr   r   )r!   temps   ` r(   bbanzProvider.bban3   s+    vveKTM]M]^}}T""r+   c                       j                         }| j                  z   dz   }t        dj                   fd|D                    }d|dz  z
  }t	        |      j                  d      } j                  |z   |z   S )z5Generate an International Bank Account Number (IBAN).00 c              3   V   K   | ]   }j                   j                  ||       " y wr.   )r   get).0cr!   s     r(   	<genexpr>z Provider.iban.<locals>.<genexpr>=   s      AaTZZ^^Aq1As   &)b   a   r   )r5   r   r    joinstrzfill)r!   r5   checkcheck_s   `   r(   ibanzProvider.iban8   st    yy{t(((4/RWWA5AABv{#F!!!$  5(4//r+   use_datasetc                 (    | j                  d|      S )a6  Generate an 8-digit SWIFT code.

        This method uses |swift| under the hood with the ``length`` argument set
        to ``8`` and with the ``primary`` argument omitted. All 8-digit SWIFT
        codes already refer to the primary branch/office.

        :sample:
        :sample: use_dataset=True
           )lengthrF   swift)r!   rF   s     r(   swift8zProvider.swift8C   s     zzz<<r+   primaryc                 *    | j                  d||      S )ax  Generate an 11-digit SWIFT code.

        This method uses |swift| under the hood with the ``length`` argument set
        to ``11``. If ``primary`` is set to ``True``, the SWIFT code will always
        end with ``'XXX'``. All 11-digit SWIFT codes use this convention to
        refer to the primary branch/office.

        :sample:
        :sample: use_dataset=True
           )rI   rM   rF   rJ   )r!   rM   rF   s      r(   swift11zProvider.swift11O   s     zzW+zNNr+   NrI   c                    || j                  d      }|dvrt        d      |r(t        | d      r| j                  | j                        }n!| j	                  dt
        j                        }|r(t        | d      r| j                  | j                        }n2| j	                  dt
        j                  t
        j                  z         }|dk(  r|| j                  z   |z   S |rd	}n\|r(t        | d
      r| j                  | j                        }n2| j	                  dt
        j                  t
        j                  z         }|| j                  z   |z   |z   S )a{  Generate a SWIFT code.

        SWIFT codes, reading from left to right, are composed of a 4 alphabet
        character bank code, a 2 alphabet character country code, a 2
        alphanumeric location code, and an optional 3 alphanumeric branch code.
        This means SWIFT codes can only have 8 or 11 characters, so the value of
        ``length`` can only be ``None`` or the integers ``8`` or ``11``. If the
        value is ``None``, then a value of ``8`` or ``11`` will randomly be
        assigned.

        Because all 8-digit SWIFT codes already refer to the primary branch or
        office, the ``primary`` argument only has an effect if the value of
        ``length`` is ``11``. If ``primary`` is ``True`` and ``length`` is
        ``11``, the 11-digit SWIFT codes generated will always end in ``'XXX'``
        to denote that they belong to primary branches/offices.

        For extra authenticity, localized providers may opt to include SWIFT
        bank codes, location codes, and branch codes used in their respective
        locales. If ``use_dataset`` is ``True``, this method will generate SWIFT
        codes based on those locale-specific codes if included. If those codes
        were not included, then it will behave as if ``use_dataset`` were
        ``False``, and in that mode, all those codes will just be randomly
        generated as per the specification.

        :sample:
        :sample: length=8
        :sample: length=8, use_dataset=True
        :sample: length=11
        :sample: length=11, primary=True
        :sample: length=11, use_dataset=True
        :sample: length=11, primary=True, use_dataset=True
        )rH   rO   zlength can only be 8 or 11swift_bank_codesz????)lettersswift_location_codesz??rH   XXXswift_branch_codesz???)r/   AssertionErrorhasattrrR   lexifystringr   rT   digitsr   rV   )r!   rI   rM   rF   	bank_codelocation_codebranch_codes          r(   rK   zProvider.swift\   s1   L >((1F  !=>>74);<!001F1FGIFF4J4JKI74)?@!%!4!4T5N5N!OM KKf6L6Lv}}6\K]MQ;t000=@@KWT+?@--d.E.EFK++eV5K5Kfmm5[+\K4,,,}<{JJr+   )F)FF)NFF)__name__
__module____qualname____doc__rZ   r   rA   ordr   r   __annotations__r   r   r$   r*   r5   rE   boolrL   rP   r   r    rK   )r;   r<   rA   rc   s   0000r(   r   r      s     ;A:P:PQQQQCFRK 00QE4S>Q*K*L##S #!c !#c #
	0c 	0
=$ 
=3 
=Ot O$ O3 O !%!	?K?K ?K 	?K
 
?K} Rs   B
r   )r2   rZ   mathr   r   typingr   r   r8   r   	localizeddefault_localer    r+   r(   <module>rk      s1    	   " ! 	MK| MKr+   