
    EjZX                       U d dl mZ d dlmZ d dlZd dlZd dlZd dl	m	Z
 ddlmZ ddlmZ ddlmZ ddlmZ dd	lmZ dd
lmZ ddlmZ ddlmZ dTdZej        rd dlmZ  eddej                  Zn ej        dd          Z G d dej        e                   ZdZd Zd!Z G d" d#ej                   Z! G d$ d%          Z" G d& d'e"          Z# G d( d)e"          Z$ G d* d+e"          Z%e#e%e$d,Z&d-e'd.<    ej        d/d%0          Z(	 dUdVd5Z)ej*        dWd9            Z+ej*        dXd<            Z+ej*        dYd?            Z+ej*        dZdA            Z+dZdBZ+d[dEZ,d\dKZ-d]dMZ.d^dOZ/d_dPZ0d`dSZ1dS )a    )annotationsN)gettext   )Argument)Command)Context)Group)Option)	Parameter)ParameterSource)echoclir   ctx_argscabc.MutableMapping[str, t.Any]	prog_namestrcomplete_varinstructionreturnt.Literal[0, 1]c                j   |                     d          \  }}}t          |          }|dS  || |||          }|dk    r7t          |                                                                d           dS |dk    r5t          |                                                                           dS dS )	a   Perform shell completion for the given CLI program.

    :param cli: Command being called.
    :param ctx_args: Extra arguments to pass to
        ``cli.make_context``.
    :param prog_name: Name of the executable in the shell.
    :param complete_var: Name of the environment variable that holds
        the completion instruction.
    :param instruction: Value of ``complete_var`` with the completion
        instruction and shell, in the form ``instruction_shell``.
    :return: Status code to exit with.
    _Nr   sourceF)nlr   complete)	partitionget_completion_classr   r   encoder   )	r   r   r   r   r   shellr   comp_clscomps	            P/wd/license_services/venv/lib/python3.11/site-packages/click/shell_completion.pyshell_completer#      s    & (11#66E1k#E**Hq8C9l;;D hT[[]]!!##....qj  T]]__##%%&&&q1    )TypeVar
_ValueT_coT)	covariantdefault)r'   c                  ,    e Zd ZdZdZ	 	 dddZddZdS )CompletionItema)  Represents a completion value and metadata about the value. The
    default metadata is ``type`` to indicate special shell handling,
    and ``help`` if a shell supports showing a help string next to the
    value.

    Arbitrary parameters can be passed when creating the object, and
    accessed using ``item.attr``. If an attribute wasn't passed,
    accessing it returns ``None``.

    :param value: The completion suggestion.
    :param type: Tells the shell script to provide special completion
        support for the type. Click uses ``"dir"`` and ``"file"``.
    :param help: String shown next to the value if supported.
    :param kwargs: Arbitrary metadata. The built-in implementations
        don't use this, but custom type completions paired with custom
        shell support could use it.
    valuetypehelp_infoplainNr,   r&   r-   r   r.   
str | Nonekwargst.Anyr   Nonec                >    || _         || _        || _        || _        d S Nr+   )selfr,   r-   r.   r2   s        r"   __init__zCompletionItem.__init__X   s$     "'
	 $	


r$   namec                6    | j                             |          S r6   )r/   get)r7   r9   s     r"   __getattr__zCompletionItem.__getattr__d   s    z~~d###r$   )r0   N)
r,   r&   r-   r   r.   r1   r2   r3   r   r4   )r9   r   r   r3   )__name__
__module____qualname____doc__	__slots__r8   r<    r$   r"   r*   r*   C   sZ         $ 3I
 	
 
 
 
 
$ $ $ $ $ $r$   r*   a  %(complete_func)s() {
    local IFS=$'\n'
    local response

    response=$(env COMP_WORDS="${COMP_WORDS[*]}" COMP_CWORD=$COMP_CWORD %(complete_var)s=bash_complete $1)

    for completion in $response; do
        IFS=',' read type value <<< "$completion"

        if [[ $type == 'dir' ]]; then
            COMPREPLY=()
            compopt -o dirnames
        elif [[ $type == 'file' ]]; then
            COMPREPLY=()
            compopt -o default
        elif [[ $type == 'plain' ]]; then
            COMPREPLY+=($value)
        fi
    done

    return 0
}

%(complete_func)s_setup() {
    complete -o nosort -F %(complete_func)s %(prog_name)s
}

%(complete_func)s_setup;
a  #compdef %(prog_name)s

%(complete_func)s() {
    local -a completions
    local -a completions_with_descriptions
    local -a response
    (( ! $+commands[%(prog_name)s] )) && return 1

    response=("${(@f)$(env COMP_WORDS="${words[*]}" COMP_CWORD=$((CURRENT-1)) %(complete_var)s=zsh_complete %(prog_name)s)}")

    for type key descr in ${response}; do
        if [[ "$type" == "plain" ]]; then
            if [[ "$descr" == "_" ]]; then
                completions+=("$key")
            else
                completions_with_descriptions+=("$key":"$descr")
            fi
        elif [[ "$type" == "dir" ]]; then
            _path_files -/
        elif [[ "$type" == "file" ]]; then
            _path_files -f
        fi
    done

    if [ -n "$completions_with_descriptions" ]; then
        _describe -V unsorted completions_with_descriptions -U
    fi

    if [ -n "$completions" ]; then
        compadd -U -V unsorted -a completions
    fi
}

if [[ $zsh_eval_context[-1] == loadautofunc ]]; then
    # autoload from fpath, call function directly
    %(complete_func)s "$@"
else
    # eval/source/. command, register function for later
    compdef %(complete_func)s %(prog_name)s
fi
af  function %(complete_func)s;
    set -l response (env %(complete_var)s=fish_complete COMP_WORDS=(commandline -cp) COMP_CWORD=(commandline -t) %(prog_name)s);

    for completion in $response;
        set -l metadata (string split "," $completion);

        if test $metadata[1] = "dir";
            __fish_complete_directories $metadata[2];
        else if test $metadata[1] = "file";
            __fish_complete_path $metadata[2];
        else if test $metadata[1] = "plain";
            echo $metadata[2];
        end;
    end;
end;

complete --no-files --command %(prog_name)s --arguments "(%(complete_func)s)";
c                  .    e Zd ZU ded<   ded<   ded<   dS )_SourceVarsDictr   complete_funcr   r   N)r=   r>   r?   __annotations__rB   r$   r"   rD   rD      s1         NNNNNr$   rD   c                      e Zd ZU dZded<   	 ded<   	 ded<   ded<   d	ed
<   d	ed<   ddZed d            Zd!dZd dZ	d"dZ
d#dZd$dZd dZdS )%ShellCompletea  Base class for providing shell completion support. A subclass for
    a given shell will override attributes and methods to implement the
    completion instructions (``source`` and ``complete``).

    :param cli: Command being called.
    :param prog_name: Name of the executable in the shell.
    :param complete_var: Name of the environment variable that holds
        the completion instruction.

    .. versionadded:: 8.0
    t.ClassVar[str]r9   source_templater   r   r   r   r   r   r   r   r4   c                >    || _         || _        || _        || _        d S r6   )r   r   r   r   )r7   r   r   r   r   s        r"   r8   zShellComplete.__init__   s'      "(r$   c                    t          j        dd| j                            dd          t           j                  }d| dS )zQThe name of the shell function defined by the completion
        script.
        z\W* -r   )flags_completion)resubr   replaceASCII)r7   	safe_names     r"   	func_namezShellComplete.func_name  sA    
 F62t~'='=c3'G'GrxXXX	)9))))r$   rD   c                ,    | j         | j        | j        dS )zVars for formatting :attr:`source_template`.

        By default this provides ``complete_func``, ``complete_var``,
        and ``prog_name``.
        )rE   r   r   )rV   r   r   r7   s    r"   source_varszShellComplete.source_vars	  s#     "^ -
 
 	
r$   c                :    | j         |                                 z  S )zProduce the shell script that defines the completion
        function. By default this ``%``-style formats
        :attr:`source_template` with the dict returned by
        :meth:`source_vars`.
        )rJ   rY   rX   s    r"   r   zShellComplete.source  s     #d&6&6&8&888r$   tuple[list[str], str]c                    t           )zUse the env vars defined by the shell script to return a
        tuple of ``args, incomplete``. This must be implemented by
        subclasses.
        NotImplementedErrorrX   s    r"   get_completion_argsz!ShellComplete.get_completion_args  s
    
 "!r$   args	list[str]
incompletelist[CompletionItem[str]]c                    t          | j        | j        | j        |          }t	          |||          \  }}|                    ||          S )aT  Determine the context and last complete command or parameter
        from the complete args. Call that object's ``shell_complete``
        method to get the completions for the incomplete value.

        :param args: List of complete args before the incomplete value.
        :param incomplete: Value being completed. May be empty.
        )_resolve_contextr   r   r   _resolve_incompleter#   )r7   r`   rb   ctxobjs        r"   get_completionszShellComplete.get_completions$  sH     txMM-c4DDZ!!#z222r$   itemCompletionItem[str]c                    t           )zFormat a completion item into the form recognized by the
        shell script. This must be implemented by subclasses.

        :param item: Completion item to format.
        r]   r7   rj   s     r"   format_completionzShellComplete.format_completion2  s
     "!r$   c                                                       \  }}                     ||          } fd|D             }d                    |          S )zProduce the completion data to send back to the shell.

        By default this calls :meth:`get_completion_args`, gets the
        completions, then calls :meth:`format_completion` for each
        completion.
        c                :    g | ]}                     |          S rB   )rn   ).0rj   r7   s     r"   
<listcomp>z*ShellComplete.complete.<locals>.<listcomp>C  s'    DDDt%%d++DDDr$   
)r_   ri   join)r7   r`   rb   completionsouts   `    r"   r   zShellComplete.complete:  sY      3355j**4<<DDDDDDDyy~~r$   N)
r   r   r   r   r   r   r   r   r   r4   r   r   )r   rD   r   r[   )r`   ra   rb   r   r   rc   rj   rk   r   r   )r=   r>   r?   r@   rF   r8   propertyrV   rY   r   r_   ri   rn   r   rB   r$   r"   rH   rH      s        
 
 
 %$$$ LLL----NNN
) 
) 
) 
) * * * X*

 

 

 

9 9 9 9" " " "3 3 3 3" " " "
 
 
 
 
 
r$   rH   c                  j     e Zd ZU dZdZded<   eZded<   edd            Z	d fd
Z
ddZddZ xZS )BashCompletezShell completion for Bash.bashrI   r9   rJ   r   r4   c                    dd l } dd l}|                     d          }|d }nL|                    |dddg|j                  }t          j        d|j                                                  }|M|	                                \  }}|dk     s|dk    r&|dk     r"t          t          d	          d
           d S d S d S t          t          d          d
           d S )Nr   r}   z--norcz-czecho "${BASH_VERSION}")stdoutz^(\d+)\.(\d+)\.\d+4zCShell completion is not supported for Bash versions older than 4.4.T)errz@Couldn't detect Bash version, shell completion is not supported.)shutil
subprocesswhichrunPIPErQ   searchr   decodegroupsr   r   )r   r   bash_exematchoutputmajorminors          r"   _check_versionzBashComplete._check_versionM  s&   <<''EE^^8T+CD! $  F I3V]5I5I5K5KLLE <<>>LE5s{{esllus{{4        +l{{ TUU     r$   r   c                l    |                                   t                                                      S r6   )r   superr   )r7   	__class__s    r"   r   zBashComplete.sourcen  s)    ww~~r$   r[   c                    t          t          j        d                   }t          t          j        d                   }|d|         }	 ||         }n# t          $ r d}Y nw xY w||fS N
COMP_WORDS
COMP_CWORDr   rM   split_arg_stringosenvironint
IndexErrorr7   cwordscwordr`   rb   s        r"   r_   z BashComplete.get_completion_argsr  x    !"*\":;;BJ|,--ag	JJ 	 	 	JJJ	 Z   
A A"!A"rj   CompletionItem[t.Any]c                $    |j          d|j         S )N,)r-   r,   rm   s     r"   rn   zBashComplete.format_completion~  s    )**dj***r$   )r   r4   rw   rx   )rj   r   r   r   )r=   r>   r?   r@   r9   rF   _SOURCE_BASHrJ   staticmethodr   r   r_   rn   __classcell__)r   s   @r"   r|   r|   G  s         $$"D""""'3O3333   \@           
  
  
  
 + + + + + + + +r$   r|   c                  @    e Zd ZU dZdZded<   eZded<   ddZddZ	dS )ZshCompletezShell completion for Zsh.zshrI   r9   rJ   r   r[   c                    t          t          j        d                   }t          t          j        d                   }|d|         }	 ||         }n# t          $ r d}Y nw xY w||fS r   r   r   s        r"   r_   zZshComplete.get_completion_args  r   r   rj   rk   r   c                    |j         pd}|dk    r|j                            dd          n|j        }|j         d| d| S )Nr   :z\:rs   )r.   r,   rS   r-   )r7   rj   help_r,   s       r"   rn   zZshComplete.format_completion  sT    	 S 383,,
""3...DJ)//u/////r$   Nrx   ry   )
r=   r>   r?   r@   r9   rF   _SOURCE_ZSHrJ   r_   rn   rB   r$   r"   r   r     sf         ##!D!!!!'2O2222
  
  
  
 0 0 0 0 0 0r$   r   c                  @    e Zd ZU dZdZded<   eZded<   ddZddZ	dS )FishCompletezShell completion for Fish.fishrI   r9   rJ   r   r[   c                    t          t          j        d                   }t          j        d         }|rt          |          d         }|dd          }|r"|r |d         |k    r|                                 ||fS )Nr   r   r   r   )r   r   r   pop)r7   r   rb   r`   s       r"   r_   z FishComplete.get_completion_args  s    !"*\":;;Z-
 	9)*55a8Jabbz  	$ 	48z#9#9HHJJJZr$   rj   rk   r   c                    |j         rC|j                             dd                              dd          }|j         d|j         d| S |j         d|j         S )z
        .. versionchanged:: 8.4.2
            Escape newlines and replace tabs with spaces in the help text to
            fix completion errors with multi-line help strings.
        rs   z\n	 r   )r.   rS   r-   r,   )r7   rj   r   s      r"   rn   zFishComplete.format_completion  sm     9 	8I%%dE22::4EEEi77$*77777)**dj***r$   Nrx   ry   )
r=   r>   r?   r@   r9   rF   _SOURCE_FISHrJ   r_   rn   rB   r$   r"   r   r     sf         $$"D""""'3O3333       + + + + + +r$   r   )r}   r   r   z't.Final[dict[str, type[ShellComplete]]]_available_shells_ShellCompleteT)boundclstype[_ShellCompleteT]r9   r1   c                ,    || j         }| t          |<   | S )am  Register a :class:`ShellComplete` subclass under the given name.
    The name will be provided by the completion instruction environment
    variable during completion.

    :param cls: The completion class that will handle completion for the
        shell.
    :param name: Name to register the class under. Defaults to the
        class's ``name`` attribute.
    )r9   r   )r   r9   s     r"   add_completion_classr     s      |x!dJr$   r   t.Literal['bash']type[BashComplete]c                    d S r6   rB   r   s    r"   r   r         JM#r$   t.Literal['fish']type[FishComplete]c                    d S r6   rB   r   s    r"   r   r     r   r$   t.Literal['zsh']type[ZshComplete]c                    d S r6   rB   r   s    r"   r   r     s    HKr$   type[ShellComplete] | Nonec                    d S r6   rB   r   s    r"   r   r     s    DGCr$   c                6    t                               |           S )zLook up a registered :class:`ShellComplete` subclass by the name
    provided by the completion instruction environment variable. If the
    name isn't registered, returns ``None``.

    :param shell: Name the class is registered under.
    )r   r;   r   s    r"   r   r     s       '''r$   stringra   c                    ddl }|                     | d          }d|_        d|_        g }	 |D ]}|                    |           n*# t          $ r |                    |j                   Y nw xY w|S )a  Split an argument string as with :func:`shlex.split`, but don't
    fail if the string is incomplete. Ignores a missing closing quote or
    incomplete escape sequence and uses the partial token as-is.

    .. code-block:: python

        split_arg_string("example 'my file")
        ["example", "my file"]

        split_arg_string("example my\")
        ["example", "my"]

    :param string: String to split.

    .. versionchanged:: 8.2
        Moved to ``shell_completion`` from ``parser``.
    r   NT)posixrM   )shlexwhitespace_split
commentersappend
ValueErrortoken)r   r   lexrv   r   s        r"   r   r     s    $ LLL
++fD+
)
)CCCN
C 	 	EJJu	    	

39	 Js   A $A/.A/rg   r   paramr   boolc                N   t          |t                    sdS | j                            |j                  }|j        dk    pd|                     |j                  t          j        up>|j        dk    o3t          |t          t          f          ot          |          |j        k     S )zDetermine if the given parameter is an argument that can still
    accept values.

    :param ctx: Invocation context for the command represented by the
        parsed complete args.
    :param param: Argument object being checked.
    Fr   r   )
isinstancer   paramsr;   r9   nargsget_parameter_sourcer   COMMANDLINEtuplelistlen)rg   r   r,   s      r"   _is_incomplete_argumentr     s     eX&& uJNN5:&&Er 	
##EJ//7RR	
 K!O )55$-00)E

U[(r$   r,   c                ,    |sdS |d         }|| j         v S )z5Check if the value looks like the start of an option.Fr   )_opt_prefixes)rg   r,   cs      r"   _start_of_optionr   6  s&     uaA!!!r$   r`   c                    t          |t                    sdS |j        s|j        rdS d}t	          t          |                    D ])\  }}|dz   |j        k    r nt          | |          r|} n*|duo||j        v S )zDetermine if the given parameter is an option that needs a value.

    :param args: List of complete args before the incomplete value.
    :param param: Option object being checked.
    FNr   )	r   r
   is_flagcount	enumeratereversedr   r   opts)rg   r`   r   last_optionindexargs         r"   _is_incomplete_optionr   ?  s     eV$$ u}  uK//  
s19u{""EC%% 	KE	 d"@{ej'@@r$   c           	        d|d<    | j         ||                                fi |5 }|j        |j        z   }|r|j        }t          |t                    r|j        sm|                    ||          \  }}}||cddd           S |                     |||d          5 }|}|j        |j        z   }ddd           n# 1 swxY w Y   n|}|rh|                    ||          \  }}}||cddd           S |                     |||ddd          5 }	|	}|j        }ddd           n# 1 swxY w Y   |h|}g |j        |j        }nn|ddd           n# 1 swxY w Y   |S )a`  Produce the context hierarchy starting with the command and
    traversing the complete arguments. This only follows the commands,
    it doesn't trigger input prompts or callbacks.

    :param cli: Command being called.
    :param prog_name: Name of the executable in the shell.
    :param args: List of complete args before the incomplete value.
    Tresilient_parsingN)parentr   F)r   allow_extra_argsallow_interspersed_argsr   )	make_contextcopy_protected_argsr`   commandr   r	   chainresolve_command)
r   r   r   r`   rg   r   r9   cmdsub_ctxsub_sub_ctxs
             r"   re   re   X  s    %)H !		)TYY[[	=	=H	=	= )"SX- &	kG'5)) #}  E&-&=&=c4&H&HOD#t{") ) ) ) ) ) ) ) ))d3$ *   > %"2SX=	> > > > > > > > > > > > > > > "G 0*1*A*A#t*L*Lc4;#&3) ) ) ) ) ) ) )6 !--  #&-149.2 .   	0 )&1G#*<D	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0 	0  0" "CDW4Dw|DDDM  &	) ) ) ) ) ) ) ) ) ) ) ) ) ) )V Jsf   AEE B>2E>C	EC	%E8E
D)E)D-	-E0D-	1EE Erb   tuple[Command | Parameter, str]c                   |dk    rd}nBd|v r>t          | |          r.|                    d          \  }}}|                    |           d|vrt          | |          r	| j        |fS | j                            |           }|D ]}t          | ||          r||fc S |D ]}t          | |          r||fc S | j        |fS )ah  Find the Click object that will handle the completion of the
    incomplete value. Return the object and the incomplete value.

    :param ctx: Invocation context for the command represented by
        the parsed complete args.
    :param args: List of complete args before the incomplete value.
    :param incomplete: Value being completed. May be empty.
    =rM   z--)r   r   r   r   
get_paramsr   r   )rg   r`   rb   r9   r   r   r   s          r"   rf   rf     s    S

	
		/Z@@	(22377aD 4,S*=={J&&[##C((F  % % dE22 	%*$$$$	%
  % %"3.. 	%*$$$$	%
 ;
""r$   )r   r   r   r   r   r   r   r   r   r   r   r   r6   )r   r   r9   r1   r   r   )r   r   r   r   )r   r   r   r   )r   r   r   r   )r   r   r   r   )r   r   r   ra   )rg   r   r   r   r   r   )rg   r   r,   r   r   r   )rg   r   r`   ra   r   r   r   r   )
r   r   r   r   r   r   r`   ra   r   r   )rg   r   r`   ra   rb   r   r   r  )2
__future__r   collections.abcabccabcr   rQ   typingtr   r   corer   r   r   r	   r
   r   r   utilsr   r#   TYPE_CHECKINGtyping_extensionsr%   Anyr&   Genericr*   r   r   r   	TypedDictrD   rH   r|   r   r   r   rF   r   r   overloadr   r   r   r   r   re   rf   rB   r$   r"   <module>r     s   " " " " " " "       				 				                                                     ! ! ! ! ! !      $ $ $ $N ? 9)))))) quEEEJJ<4888J"$ "$ "$ "$ "$QYz* "$ "$ "$LL*X.    ak   l l l l l l l l^8+ 8+ 8+ 8+ 8+= 8+ 8+ 8+v!0 !0 !0 !0 !0- !0 !0 !0H"+ "+ "+ "+ "+= "+ "+ "+L > >      !)-_EEE 48    (  M M M  M M M M  M K K K  K G G G  G( ( ( (" " " "J   ." " " "A A A A2: : : :z,# ,# ,# ,# ,# ,#r$   