-module(simplejson@internal@query). -compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]). -define(FILEPATH, "src/simplejson/internal/query.gleam"). -export(['query'/3]). -if(?OTP_RELEASE >= 27). -define(MODULEDOC(Str), -moduledoc(Str)). -define(DOC(Str), -doc(Str)). -else. -define(MODULEDOC(Str), -compile([])). -define(DOC(Str), -compile([])). -endif. ?MODULEDOC(false). -file("src/simplejson/internal/query.gleam", 67). ?DOC(false). -spec get_descendants( list(simplejson@jsonvalue:json_value()), simplejson@jsonvalue:json_value() ) -> list(simplejson@jsonvalue:json_value()). get_descendants(List, Json) -> case Json of {json_object, D} -> New_list = maps:values(D), gleam@list:fold( New_list, lists:append(List, New_list), fun get_descendants/2 ); {json_array, D@1} -> New_list@1 = maps:values(D@1), gleam@list:fold( New_list@1, lists:append(List, New_list@1), fun get_descendants/2 ); _ -> List end. -file("src/simplejson/internal/query.gleam", 245). ?DOC(false). -spec compare_items( gleam@order:order(), simplejson@internal@jsonpath:compare_op() ) -> boolean(). compare_items(Order, Op) -> case Op of eq -> Order =:= eq; gt -> Order =:= gt; gte -> (Order =:= gt) orelse (Order =:= eq); lt -> Order =:= lt; lte -> (Order =:= lt) orelse (Order =:= eq); not_eq -> Order /= eq end. -file("src/simplejson/internal/query.gleam", 235). ?DOC(false). -spec compare_numbers( bigdecimal:big_decimal(), bigdecimal:big_decimal(), simplejson@internal@jsonpath:compare_op() ) -> boolean(). compare_numbers(N1, N2, Op) -> Order = bigdecimal:compare(N1, N2), compare_items(Order, Op). -file("src/simplejson/internal/query.gleam", 240). ?DOC(false). -spec compare_strings( binary(), binary(), simplejson@internal@jsonpath:compare_op() ) -> boolean(). compare_strings(S1, S2, Op) -> Order = gleam@string:compare(S1, S2), compare_items(Order, Op). -file("src/simplejson/internal/query.gleam", 210). ?DOC(false). -spec compare_types( simplejson@internal@jsonpath:type_value(), simplejson@internal@jsonpath:type_value(), simplejson@internal@jsonpath:compare_op() ) -> boolean(). compare_types(Tv1, Tv2, Op) -> case {Tv1, Tv2} of {{value_type, {number, N1}}, {value_type, {number, N2}}} -> compare_numbers(N1, N2, Op); {{value_type, {string, S1}}, {value_type, {string, S2}}} -> compare_strings(S1, S2, Op); {{value_type, null}, {value_type, null}} -> compare_items(eq, Op); {{value_type, {boolean, B1}}, {value_type, {boolean, B2}}} -> case B1 =:= B2 of true -> ((Op =:= eq) orelse (Op =:= gte)) orelse (Op =:= lte); false -> Op =:= not_eq end; {{value_type, {array, D1}}, {value_type, {array, D2}}} -> D1 =:= D2; {{value_type, {object, D1@1}}, {value_type, {object, D2@1}}} -> D1@1 =:= D2@1; {{value_type, nothing}, {value_type, nothing}} -> true; {_, _} -> case Op of not_eq -> true; _ -> false end end. -file("src/simplejson/internal/query.gleam", 329). ?DOC(false). -spec do_fix_regexp(binary(), binary(), boolean()) -> binary(). do_fix_regexp(Str, New_regexp, In_class) -> case Str of <<"\\["/utf8, Rest/binary>> -> do_fix_regexp(Rest, <>, In_class); <<"["/utf8, Rest@1/binary>> -> do_fix_regexp(Rest@1, <>, true); <<"\\]"/utf8, Rest@2/binary>> -> do_fix_regexp(Rest@2, <>, In_class); <<"]"/utf8, Rest@3/binary>> -> do_fix_regexp(Rest@3, <>, false); <<"\\\\"/utf8, Rest@4/binary>> -> do_fix_regexp(Rest@4, <>, In_class); <<"\\."/utf8, Rest@5/binary>> -> do_fix_regexp(Rest@5, <>, In_class); <<"."/utf8, Rest@6/binary>> -> case In_class of true -> do_fix_regexp( Rest@6, <>, In_class ); false -> do_fix_regexp( Rest@6, <>, In_class ) end; <<""/utf8>> -> New_regexp; X -> case gleam_stdlib:string_pop_grapheme(X) of {error, _} -> New_regexp; {ok, {Char, Rest@7}} -> do_fix_regexp( Rest@7, <>, In_class ) end end. -file("src/simplejson/internal/query.gleam", 320). ?DOC(false). -spec fix_regexp(binary()) -> gleam@regexp:regexp(). fix_regexp(Str) -> case gleam@regexp:from_string(do_fix_regexp(Str, <<""/utf8>>, false)) of {error, _} -> erlang:error(#{gleam_error => panic, message => <<"Invalid Regexp"/utf8>>, file => <>, module => <<"simplejson/internal/query"/utf8>>, function => <<"fix_regexp"/utf8>>, line => 324}); {ok, R} -> R end. -file("src/simplejson/internal/query.gleam", 412). ?DOC(false). -spec do_fn_count(simplejson@internal@jsonpath:type_value()) -> simplejson@internal@jsonpath:type_value(). do_fn_count(Arg) -> case Arg of {value_type, _} -> {value_type, nothing}; {logical_type, _} -> {value_type, nothing}; {nodes_type, L} -> _pipe = erlang:length(L), _pipe@1 = erlang:float(_pipe), _pipe@2 = bigdecimal:from_float(_pipe@1), _pipe@3 = {number, _pipe@2}, {value_type, _pipe@3} end. -file("src/simplejson/internal/query.gleam", 483). ?DOC(false). -spec jsonvalue_to_literal(simplejson@jsonvalue:json_value()) -> simplejson@internal@jsonpath:literal(). jsonvalue_to_literal(Jv) -> case Jv of {json_array, Arr} -> {array, Arr}; {json_object, Obj} -> {object, Obj}; {json_bool, Bool} -> {boolean, Bool}; json_null -> null; {json_number, {some, I}, _, _} -> Bd@1 = case bigdecimal:from_string(erlang:integer_to_binary(I)) of {ok, Bd} -> Bd; _assert_fail -> erlang:error(#{gleam_error => let_assert, message => <<"Pattern match failed, no pattern matched the value."/utf8>>, file => <>, module => <<"simplejson/internal/query"/utf8>>, function => <<"jsonvalue_to_literal"/utf8>>, line => 490, value => _assert_fail, start => 13443, 'end' => 13503, pattern_start => 13454, pattern_end => 13460}) end, {number, Bd@1}; {json_number, _, _, {some, S}} -> N@1 = case simplejson@internal@jsonpath:parse_literal_number(S) of {ok, {N, _}} -> N; _assert_fail@1 -> erlang:error(#{gleam_error => let_assert, message => <<"Pattern match failed, no pattern matched the value."/utf8>>, file => <>, module => <<"simplejson/internal/query"/utf8>>, function => <<"jsonvalue_to_literal"/utf8>>, line => 494, value => _assert_fail@1, start => 13590, 'end' => 13647, pattern_start => 13601, pattern_end => 13612}) end, N@1; {json_number, _, {some, F}, _} -> {number, bigdecimal:from_float(F)}; {json_string, Str} -> {string, Str}; {json_number, none, none, none} -> erlang:error(#{gleam_error => panic, message => <<"`panic` expression evaluated."/utf8>>, file => <>, module => <<"simplejson/internal/query"/utf8>>, function => <<"jsonvalue_to_literal"/utf8>>, line => 502}) end. -file("src/simplejson/internal/query.gleam", 353). ?DOC(false). -spec do_fn_match( simplejson@internal@jsonpath:type_value(), simplejson@internal@jsonpath:type_value() ) -> simplejson@internal@jsonpath:type_value(). do_fn_match(Arg1, Arg2) -> case {Arg1, Arg2} of {{value_type, {string, S}}, {value_type, {string, S2}}} -> {logical_type, gleam@regexp:check( fix_regexp(<<<<"^"/utf8, S2/binary>>/binary, "$"/utf8>>), S )}; {{nodes_type, [V1]}, {nodes_type, [V2]}} -> do_fn_match( {value_type, jsonvalue_to_literal(V1)}, {value_type, jsonvalue_to_literal(V2)} ); {{nodes_type, [V]}, _} -> do_fn_match({value_type, jsonvalue_to_literal(V)}, Arg2); {_, {nodes_type, [V@1]}} -> do_fn_match(Arg1, {value_type, jsonvalue_to_literal(V@1)}); {_, _} -> {logical_type, false} end. -file("src/simplejson/internal/query.gleam", 375). ?DOC(false). -spec do_fn_search( simplejson@internal@jsonpath:type_value(), simplejson@internal@jsonpath:type_value() ) -> simplejson@internal@jsonpath:type_value(). do_fn_search(Arg1, Arg2) -> case {Arg1, Arg2} of {{value_type, {string, S}}, {value_type, {string, S2}}} -> {logical_type, gleam@regexp:check(fix_regexp(S2), S)}; {{nodes_type, [V1]}, {nodes_type, [V2]}} -> do_fn_search( {value_type, jsonvalue_to_literal(V1)}, {value_type, jsonvalue_to_literal(V2)} ); {{nodes_type, [V]}, _} -> do_fn_search({value_type, jsonvalue_to_literal(V)}, Arg2); {_, {nodes_type, [V@1]}} -> do_fn_search(Arg1, {value_type, jsonvalue_to_literal(V@1)}); {_, _} -> {logical_type, false} end. -file("src/simplejson/internal/query.gleam", 397). ?DOC(false). -spec do_fn_value(simplejson@internal@jsonpath:type_value()) -> simplejson@internal@jsonpath:type_value(). do_fn_value(Arg) -> case Arg of {value_type, _} -> {value_type, nothing}; {logical_type, _} -> {value_type, nothing}; {nodes_type, L} -> case L of [V] -> {value_type, jsonvalue_to_literal(V)}; _ -> {value_type, nothing} end end. -file("src/simplejson/internal/query.gleam", 425). ?DOC(false). -spec do_fn_length(simplejson@internal@jsonpath:type_value()) -> simplejson@internal@jsonpath:type_value(). do_fn_length(Arg) -> case Arg of {value_type, {string, S}} -> _pipe = string:length(S), _pipe@1 = erlang:float(_pipe), _pipe@2 = bigdecimal:from_float(_pipe@1), _pipe@3 = {number, _pipe@2}, {value_type, _pipe@3}; {value_type, {array, A}} -> _pipe@4 = maps:size(A), _pipe@5 = erlang:float(_pipe@4), _pipe@6 = bigdecimal:from_float(_pipe@5), _pipe@7 = {number, _pipe@6}, {value_type, _pipe@7}; {value_type, {boolean, _}} -> {value_type, nothing}; {value_type, nothing} -> {value_type, nothing}; {value_type, null} -> {value_type, nothing}; {value_type, {number, _}} -> {value_type, nothing}; {value_type, {object, O}} -> _pipe@8 = maps:size(O), _pipe@9 = erlang:float(_pipe@8), _pipe@10 = bigdecimal:from_float(_pipe@9), _pipe@11 = {number, _pipe@10}, {value_type, _pipe@11}; {logical_type, _} -> {value_type, nothing}; {nodes_type, [L]} -> do_fn_length({value_type, jsonvalue_to_literal(L)}); {nodes_type, _} -> {value_type, nothing} end. -file("src/simplejson/internal/query.gleam", 506). ?DOC(false). -spec map_singular_query_to_query( list(simplejson@internal@jsonpath:singular_segment()) ) -> list(simplejson@internal@jsonpath:segment()). map_singular_query_to_query(Sq) -> gleam@list:map(Sq, fun(Segment) -> case Segment of {single_index, I} -> {child, [{index, I}]}; {single_name, N} -> {child, [{name, N}]} end end). -file("src/simplejson/internal/query.gleam", 593). ?DOC(false). -spec normalise(integer(), integer()) -> integer(). normalise(I, Len) -> case I >= 0 of true -> I; false -> Len + I end. -file("src/simplejson/internal/query.gleam", 575). ?DOC(false). -spec get_bounds(integer(), integer(), integer(), integer()) -> {integer(), integer()}. get_bounds(Start, End, Step, Len) -> Start@1 = normalise(Start, Len), End@1 = normalise(End, Len), case Step >= 0 of true -> Lower = gleam@int:min(gleam@int:max(Start@1, 0), Len), Upper = gleam@int:min(gleam@int:max(End@1, 0), Len), {Lower, Upper}; false -> Upper@1 = gleam@int:min(gleam@int:max(Start@1, -1), Len - 1), Lower@1 = gleam@int:min(gleam@int:max(End@1, -1), Len - 1), {Upper@1, Lower@1} end. -file("src/simplejson/internal/query.gleam", 515). ?DOC(false). -spec do_slice( simplejson@jsonvalue:json_value(), gleam@option:option(integer()), gleam@option:option(integer()), gleam@option:option(integer()) ) -> list(simplejson@jsonvalue:json_value()). do_slice(Json, Start, End, Step) -> case Json of {json_array, D} -> gleam@bool:guard( Step =:= {some, 0}, [], fun() -> Len = maps:size(D), Step@1 = gleam@option:unwrap(Step, 1), Start@1 = gleam@option:lazy_unwrap( Start, fun() -> case Step@1 >= 0 of true -> 0; false -> Len - 1 end end ), End@1 = gleam@option:lazy_unwrap( End, fun() -> case Step@1 >= 0 of true -> Len; false -> - Len - 1 end end ), {Start@2, End@2} = get_bounds(Start@1, End@1, Step@1, Len), Yielder = gleam@yielder:unfold( Start@2, fun(Acc) -> case gleam@int:compare(Step@1, 0) of gt -> case Acc < End@2 of true -> {next, Acc, Acc + Step@1}; false -> done end; lt -> case Acc > End@2 of true -> {next, Acc, Acc + Step@1}; false -> done end; eq -> erlang:error(#{gleam_error => panic, message => <<"`panic` expression evaluated."/utf8>>, file => <>, module => <<"simplejson/internal/query"/utf8>>, function => <<"do_slice"/utf8>>, line => 557}) end end ), L@1 = gleam@yielder:fold( Yielder, [], fun(L, Index) -> case gleam_stdlib:map_get(D, Index) of {error, _} -> L; {ok, V} -> [V | L] end end ), lists:reverse(L@1) end ); _ -> [] end. -file("src/simplejson/internal/query.gleam", 600). ?DOC(false). -spec do_index(simplejson@jsonvalue:json_value(), integer()) -> list(simplejson@jsonvalue:json_value()). do_index(Json, Index) -> case Json of {json_array, D} -> case Index >= 0 of true -> case gleam_stdlib:map_get(D, Index) of {ok, J} -> [J]; _ -> [] end; false -> Index@1 = maps:size(D) + Index, case Index@1 < 0 of true -> []; false -> case gleam_stdlib:map_get(D, Index@1) of {ok, J@1} -> [J@1]; _ -> [] end end end; _ -> [] end. -file("src/simplejson/internal/query.gleam", 628). ?DOC(false). -spec do_wildcard(simplejson@jsonvalue:json_value()) -> list(simplejson@jsonvalue:json_value()). do_wildcard(Json) -> case Json of {json_array, D} -> simplejson@internal@stringify:dict_to_ordered_list(D); {json_object, D@1} -> maps:values(D@1); _ -> [] end. -file("src/simplejson/internal/query.gleam", 636). ?DOC(false). -spec do_name(simplejson@jsonvalue:json_value(), binary()) -> list(simplejson@jsonvalue:json_value()). do_name(Json, Name) -> case Json of {json_object, D} -> case gleam_stdlib:map_get(D, Name) of {ok, V} -> [V]; _ -> [] end; _ -> [] end. -file("src/simplejson/internal/query.gleam", 131). ?DOC(false). -spec do_logical_expr( simplejson@jsonvalue:json_value(), simplejson@internal@jsonpath:logical_expression(), simplejson@jsonvalue:json_value() ) -> boolean(). do_logical_expr(Json, Expr, Absroot) -> gleam@list:fold_until( erlang:element(2, erlang:element(2, Expr)), false, fun(_, And_expr) -> case gleam@list:fold_until( erlang:element(2, And_expr), true, fun(_, Expr@1) -> case Expr@1 of {comparison, Cmp1, Cmp2, Cmpop} -> case do_comparison(Json, Cmp1, Cmp2, Cmpop, Absroot) of true -> {continue, true}; false -> {stop, false} end; {paren, Expr@2, Not} -> Cmp = do_logical_expr(Json, Expr@2, Absroot), Cmp@1 = case Not of false -> Cmp; true -> not Cmp end, case Cmp@1 of true -> {continue, true}; false -> {stop, false} end; {test, Expr@3, Not@1} -> case Expr@3 of {filter_query, Fq} -> {Root, Path@2} = case Fq of {relative, Path} -> {Json, Path}; {root, Path@1} -> {Absroot, Path@1} end, case {gleam@list:is_empty( query_to_list(Root, Path@2, Absroot) ), Not@1} of {true, false} -> {stop, false}; {false, false} -> {continue, true}; {false, true} -> {stop, false}; {true, true} -> {continue, true} end; {function_expr, Fe} -> case run_function(Json, Fe, Absroot) of {value_type, _} -> erlang:error(#{gleam_error => panic, message => <<"`panic` expression evaluated."/utf8>>, file => <>, module => <<"simplejson/internal/query"/utf8>>, function => <<"do_logical_expr"/utf8>>, line => 173}); {logical_type, Cmp@2} -> Cmp@3 = case Not@1 of false -> Cmp@2; true -> not Cmp@2 end, case Cmp@3 of true -> {continue, true}; false -> {stop, false} end; {nodes_type, _} -> erlang:error(#{gleam_error => panic, message => <<"`panic` expression evaluated."/utf8>>, file => <>, module => <<"simplejson/internal/query"/utf8>>, function => <<"do_logical_expr"/utf8>>, line => 184}) end end end end ) of true -> {stop, true}; false -> {continue, false} end end ). -file("src/simplejson/internal/query.gleam", 256). ?DOC(false). -spec run_function( simplejson@jsonvalue:json_value(), simplejson@internal@jsonpath:function_(), simplejson@jsonvalue:json_value() ) -> simplejson@internal@jsonpath:type_value(). run_function(Root, F, Absroot) -> {function, Deffn, Args} = F, Args@1 = gleam@list:map(Args, fun(A) -> case A of {function_arg, Fa} -> run_function(Root, Fa, Absroot); {literal_arg, L} -> {value_type, L}; {logical_arg, La} -> {logical_type, do_logical_expr(Root, La, Absroot)}; {query_arg, Qa} -> {Root@1, Qa@1} = case Qa of {root, Sq} -> {Absroot, Sq}; {relative, Sq@1} -> {Root, Sq@1} end, _pipe = query_to_list(Root@1, Qa@1, Absroot), {nodes_type, _pipe}; {query_singular_arg, Qa@2} -> {Root@2, Qa@3} = case Qa@2 of {root, Sq@2} -> {Absroot, Sq@2}; {relative, Sq@3} -> {Root, Sq@3} end, case query_to_list(Root@2, Qa@3, Absroot) of [V] -> {nodes_type, [V]}; _ -> {value_type, nothing} end end end), case Deffn of count -> case Args@1 of [Arg] -> do_fn_count(Arg); _ -> erlang:error(#{gleam_error => panic, message => <<"Invalid Length arguments"/utf8>>, file => <>, module => <<"simplejson/internal/query"/utf8>>, function => <<"run_function"/utf8>>, line => 289}) end; length -> case Args@1 of [Arg@1] -> do_fn_length(Arg@1); _ -> erlang:error(#{gleam_error => panic, message => <<"Invalid Length arguments"/utf8>>, file => <>, module => <<"simplejson/internal/query"/utf8>>, function => <<"run_function"/utf8>>, line => 295}) end; match -> case Args@1 of [A1, A2] -> do_fn_match(A1, A2); _ -> erlang:error(#{gleam_error => panic, message => <<"Invalid Match arguments"/utf8>>, file => <>, module => <<"simplejson/internal/query"/utf8>>, function => <<"run_function"/utf8>>, line => 301}) end; search -> case Args@1 of [A1@1, A2@1] -> do_fn_search(A1@1, A2@1); _ -> erlang:error(#{gleam_error => panic, message => <<"Invalid Search arguments"/utf8>>, file => <>, module => <<"simplejson/internal/query"/utf8>>, function => <<"run_function"/utf8>>, line => 307}) end; {unknown, _} -> {value_type, nothing}; value_of -> case Args@1 of [Arg@2] -> do_fn_value(Arg@2); _ -> erlang:error(#{gleam_error => panic, message => <<"Invalid Length arguments"/utf8>>, file => <>, module => <<"simplejson/internal/query"/utf8>>, function => <<"run_function"/utf8>>, line => 314}) end end. -file("src/simplejson/internal/query.gleam", 109). ?DOC(false). -spec do_filter( simplejson@jsonvalue:json_value(), simplejson@internal@jsonpath:logical_expression(), simplejson@jsonvalue:json_value() ) -> list(simplejson@jsonvalue:json_value()). do_filter(Json, Expr, Absroot) -> L = case Json of {json_array, D} -> simplejson@internal@stringify:dict_to_ordered_list(D); {json_object, D@1} -> maps:values(D@1); _ -> [] end, gleam@bool:guard( L =:= [], [], fun() -> _pipe = gleam@list:fold( L, [], fun(Res, Json@1) -> case do_logical_expr(Json@1, Expr, Absroot) of true -> [Json@1 | Res]; false -> Res end end ), lists:reverse(_pipe) end ). -file("src/simplejson/internal/query.gleam", 93). ?DOC(false). -spec do_selector( simplejson@jsonvalue:json_value(), simplejson@internal@jsonpath:selector(), simplejson@jsonvalue:json_value() ) -> list(simplejson@jsonvalue:json_value()). do_selector(Json, Selector, Absroot) -> case Selector of {filter, Expr} -> do_filter(Json, Expr, Absroot); {index, I} -> do_index(Json, I); {name, Name} -> do_name(Json, Name); {slice, Start, End, Step} -> do_slice(Json, Start, End, Step); wildcard -> do_wildcard(Json) end. -file("src/simplejson/internal/query.gleam", 81). ?DOC(false). -spec do_checks( simplejson@jsonvalue:json_value(), list(simplejson@internal@jsonpath:selector()), simplejson@jsonvalue:json_value() ) -> list(simplejson@jsonvalue:json_value()). do_checks(Json, Selectors, Absroot) -> gleam@list:fold( Selectors, [], fun(List, Selector) -> Found = do_selector(Json, Selector, Absroot), lists:append(List, Found) end ). -file("src/simplejson/internal/query.gleam", 55). ?DOC(false). -spec process_selectors( list(simplejson@internal@jsonpath:selector()), list(simplejson@jsonvalue:json_value()), simplejson@jsonvalue:json_value() ) -> list(simplejson@jsonvalue:json_value()). process_selectors(Selectors, Nodes, Absroot) -> gleam@list:fold( Nodes, [], fun(Arr, Node) -> Found = do_checks(Node, Selectors, Absroot), lists:append(Arr, Found) end ). -file("src/simplejson/internal/query.gleam", 40). ?DOC(false). -spec do_query( list(simplejson@jsonvalue:json_value()), simplejson@internal@jsonpath:segment(), simplejson@jsonvalue:json_value() ) -> list(simplejson@jsonvalue:json_value()). do_query(Json, Segment, Absroot) -> gleam@list:fold( Json, [], fun(Acc, J) -> Results = case Segment of {child, Selectors} -> process_selectors(Selectors, [J], Absroot); {descendant, Selectors@1} -> process_selectors( Selectors@1, get_descendants([J], J), Absroot ) end, lists:append(Acc, Results) end ). -file("src/simplejson/internal/query.gleam", 32). ?DOC(false). -spec query_to_list( simplejson@jsonvalue:json_value(), list(simplejson@internal@jsonpath:segment()), simplejson@jsonvalue:json_value() ) -> list(simplejson@jsonvalue:json_value()). query_to_list(Json, Path, Absroot) -> gleam@list:fold( Path, [Json], fun(Acc, Segment) -> do_query(Acc, Segment, Absroot) end ). -file("src/simplejson/internal/query.gleam", 26). ?DOC(false). -spec 'query'( simplejson@jsonvalue:json_value(), list(simplejson@internal@jsonpath:segment()), simplejson@jsonvalue:json_value() ) -> simplejson@jsonvalue:json_value(). 'query'(Json, Path, Absroot) -> _pipe = query_to_list(Json, Path, Absroot), _pipe@1 = simplejson@internal@parser:list_to_indexed_dict(_pipe), {json_array, _pipe@1}. -file("src/simplejson/internal/query.gleam", 456). ?DOC(false). -spec get_comparable( simplejson@jsonvalue:json_value(), simplejson@internal@jsonpath:comparable(), simplejson@jsonvalue:json_value() ) -> simplejson@internal@jsonpath:type_value(). get_comparable(Root, Cmp, Absroot) -> case Cmp of {function_expr_cmp, F} -> run_function(Root, F, Absroot); {literal, L} -> {value_type, L}; {query_cmp, Sq} -> {Root@1, Sq@3} = case Sq of {abs_query, Sq@1} -> {Absroot, Sq@1}; {rel_query, Sq@2} -> {Root, Sq@2} end, Jp = map_singular_query_to_query(Sq@3), case query_to_list(Root@1, Jp, Absroot) of [V] -> {value_type, jsonvalue_to_literal(V)}; [] -> {value_type, nothing}; _ -> erlang:error(#{gleam_error => panic, message => <<"`panic` expression evaluated."/utf8>>, file => <>, module => <<"simplejson/internal/query"/utf8>>, function => <<"get_comparable"/utf8>>, line => 477}) end end. -file("src/simplejson/internal/query.gleam", 198). ?DOC(false). -spec do_comparison( simplejson@jsonvalue:json_value(), simplejson@internal@jsonpath:comparable(), simplejson@internal@jsonpath:comparable(), simplejson@internal@jsonpath:compare_op(), simplejson@jsonvalue:json_value() ) -> boolean(). do_comparison(Root, Cmp1, Cmp2, Op, Absroot) -> Cmp1@1 = get_comparable(Root, Cmp1, Absroot), Cmp2@1 = get_comparable(Root, Cmp2, Absroot), compare_types(Cmp1@1, Cmp2@1, Op).