
    nh                     @    d Z ddlZddlZddlmZ ddlmZmZ defdZ	y)z
Unified getchar implementation for all platforms.

Combines approaches from:
- Textual (Unix/Linux): Copyright (c) 2023 Textualize Inc., MIT License
- Click (Windows fallback): Copyright 2014 Pallets, BSD-3-Clause License
    N)getincrementaldecoder)OptionalTextIOreturnc                     t         j                  dk(  r	 ddl} | j                  } |       }|dv r| |       z  }|S |g}d}t        |      |k  r[| j                         rK |       }|dv rn?|j                  |       |dk(  r
t               t        |      |k  r| j                         rKdj                  |      }d|v r
t               |S ddl}ddl}d}	t         j                  j                         st        d	      }	|	j!                         }
nt         j                  j!                         }
	 |j#                  |
      }	 |j#                  |
      }||j$                  xx   |j&                  |j(                  z  |j*                  z  |j,                  z   z  cc<   ||j.                  xx   |j0                  |j2                  z  |j4                  z  |j6                  z  |j8                  z   z  cc<   d||j:                     |j<                  <   |j?                  |
|j@                  |       tC        j
                  |
d      } tE        d
             }|jG                  |d      }d|v r
t               ||j?                  |
|j@                  |       t         jH                  jK                          |	|	jM                          S S # t        $ r" t         j                  j                  d      cY S w xY w# |j?                  |
|j@                  |       t         jH                  jK                          |	|	jM                          w w xY w# |jN                  $ r" t         j                  j                  d      cY S w xY w)a.  
    Read input from stdin with support for longer pasted text.

    On Windows:
    - Uses msvcrt for native Windows console input
    - Handles special keys that send two-byte sequences
    - Reads up to 4096 characters for paste support

    On Unix/Linux:
    - Uses Textual's approach with manual termios configuration
    - Reads up to 4096 bytes with proper UTF-8 decoding
    - Provides fine-grained terminal control

    Returns:
        str: The input character(s) read from stdin

    Raises:
        KeyboardInterrupt: When CTRL+C is pressed
    win32r   N   )    ài    z/dev/ttyzutf-8T)final)(sysplatformmsvcrtImportErrorstdinreadgetwchlenkbhitappendKeyboardInterruptjointermiosttyisattyopenfileno	tcgetattrLFLAGECHOICANONIEXTENISIGIFLAGIXONIXOFFICRNLINLCRIGNCRCCVMIN	tcsetattrTCSANOWosr   decodestdoutflushcloseerror)r   funcrvchars	max_chars	next_charresultr   r   ffdattrs_beforenewattrraw_datadecoders                  g/var/www/pru.catia.catastroantioquia-mas.com/tasa/lib/python3.12/site-packages/rich_toolkit/_getchar.pygetcharrC      s   ( ||w	% }} V !!$&LBI 	 %j9$I ,,LL# F"')) %j9$  V#%% 	" yy!Z AB!!#B<	%",,R0L4!++B/ 		"LL7>>1GNNBW\\Q' " 		"LLmm$mm$ mm$ mm	$' " 12- !!"goow? 772x0 9/8: = V#+-- !!"goo|D

  "=GGI !c  	%99>>!$$	%\ !!"goo|D

  "=GGI ! }} 	%99>>!$$	%s>   K  .M  D1K. 1AM  (K+*K+.AL>>M .M21M2)
__doc__r0   r   codecsr   typingr   r   strrC        rB   <module>rJ      s&    
 
 ( #N% N%rI   