
    ~h                    r    d dl mZ d dlZddZ	 	 	 d	 	 	 	 	 	 	 	 	 d	dZd
dZ	 	 	 	 d	 	 	 	 	 	 	 	 	 	 	 ddZy)    )annotationsNc                    | j                  di       }|j                  |d      }|| S || d<   || j                  dg       v r*| d   j                  |       | d   s| j                  d       | S )zwReturn a new schema with *param* removed from `properties`, `required`,
    and (if no longer referenced) `$defs`.
    
propertiesNrequired)getpopremove)schemaparampropsremoveds       Y/opt/mcp/mcp-sentiment/venv/lib/python3.12/site-packages/fastmcp/utilities/json_schema.py_prune_paramr      sy     JJ|R(Eiit$G !F<

:r**z!!%(j!JJz"M    c                    t               dfd |        rL| j                  di       }t        |      D ]  }|vs|j                  |        |s| j                  dd       | S )zaWalk the schema and optionally prune titles, unused definitions, and additionalProperties: false.c                   t        | t              rrU| j                  d      }t        |t              r4|j	                  d      r#j                  |j                  d      d          rd| v r| j                  d       r%| j                  dd       du r| j                  d       | j                         D ]
  } |        y t        | t              r| D ]
  } |        y y )Nz$refz#/$defs//titleadditionalPropertiesF)

isinstancedictr   str
startswithaddsplitr   valueslist)noderefvprune_additional_properties
prune_defsprune_titles	used_defswalks      r   r&   z_walk_and_prune.<locals>.walk&   s    dD!hhv&c3'CNN:,FMM#))C."45 4! ,HH3T:eC/0 [[] Q d# Q $r   z$defsN)r   objectreturnNone)setr   r   r   )r
   r#   r$   r"   defsdef_namer%   r&   s    ```  @@r   _walk_and_pruner-      ss     %I 8 	L zz'2&T
 	#Hy("	# JJw%Mr   c                P    | j                  dd      du r| j                  d       | S )z;Remove additionalProperties from the schema if it is False.r   NF)r   r   )r
   s    r   _prune_additional_propertiesr/   P   s(    zz($/58

)*Mr   c                    t        j                  |       } |xs g D ]  }t        | |      }  |s|s|rt        | |||      } | S )a  
    Remove the given parameters from the schema.

    Args:
        schema: The schema to compress
        prune_params: List of parameter names to remove from properties
        prune_defs: Whether to remove unused definitions
        prune_additional_properties: Whether to remove additionalProperties: false
        prune_titles: Whether to remove title fields from the schema
    )r   )r#   r$   r"   )copydeepcopyr   r-   )r
   prune_paramsr#   r"   r$   r   s         r   compress_schemar4   W   s[    $ ]]6"F # 3fE23 \%@ !%(C	
 Mr   )r
   r   r   r   r(   r   )FFF)
r
   r   r#   boolr$   r5   r"   r5   r(   r   )r
   r   r(   r   )NTTF)r
   r   r3   zlist[str] | Noner#   r5   r"   r5   r$   r5   r(   r   )
__future__r   r1   r   r-   r/   r4    r   r   <module>r8      s    " . (-	222 2 "&	2
 
2j &*(,!!"! ! "&	!
 ! 
!r   