-module(agnostic@vdom@patch). -compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]). -define(FILEPATH, "src/agnostic/vdom/patch.gleam"). -export([new/4, replace_text/1, replace_raw_content/1, replace_raw_node/1, update/2, move/2, remove/1, replace/2, insert/2, is_empty/1, add_parent/2, to_json/3]). -export_type([patch/1, change/1]). -type patch(IZE) :: {patch, integer(), list(integer()), integer(), list(change(IZE)), list(patch(IZE))}. -type change(IZF) :: {replace_text, integer(), binary()} | {replace_raw_content, integer(), agnostic@vdom@vnode:raw_content()} | {replace_raw_node, integer(), agnostic@vdom@vnode:element(IZF)} | {update, integer(), list(agnostic@vdom@vattr:attribute(IZF)), list(agnostic@vdom@vattr:attribute(IZF))} | {move, integer(), binary(), integer()} | {replace, integer(), integer(), agnostic@vdom@vnode:element(IZF)} | {remove, integer(), integer()} | {insert, integer(), list(agnostic@vdom@vnode:element(IZF)), integer()}. -file("src/agnostic/vdom/patch.gleam", 80). -spec new(integer(), integer(), list(change(IZG)), list(patch(IZG))) -> patch(IZG). new(Index, Removed, Changes, Children) -> {patch, Index, [], Removed, Changes, Children}. -file("src/agnostic/vdom/patch.gleam", 91). -spec replace_text(binary()) -> change(any()). replace_text(Content) -> {replace_text, 0, Content}. -file("src/agnostic/vdom/patch.gleam", 97). -spec replace_raw_content(agnostic@vdom@vnode:raw_content()) -> change(any()). replace_raw_content(Content) -> {replace_raw_content, 1, Content}. -file("src/agnostic/vdom/patch.gleam", 103). -spec replace_raw_node(agnostic@vdom@vnode:element(IZQ)) -> change(IZQ). replace_raw_node(With) -> {replace_raw_node, 7, With}. -file("src/agnostic/vdom/patch.gleam", 109). -spec update( list(agnostic@vdom@vattr:attribute(IZT)), list(agnostic@vdom@vattr:attribute(IZT)) ) -> change(IZT). update(Added, Removed) -> {update, 2, Added, Removed}. -file("src/agnostic/vdom/patch.gleam", 118). -spec move(binary(), integer()) -> change(any()). move(Key, Before) -> {move, 3, Key, Before}. -file("src/agnostic/vdom/patch.gleam", 124). -spec remove(integer()) -> change(any()). remove(Index) -> {remove, 4, Index}. -file("src/agnostic/vdom/patch.gleam", 130). -spec replace(integer(), agnostic@vdom@vnode:element(JAD)) -> change(JAD). replace(Index, With) -> {replace, 5, Index, With}. -file("src/agnostic/vdom/patch.gleam", 139). -spec insert(list(agnostic@vdom@vnode:element(JAG)), integer()) -> change(JAG). insert(Children, Before) -> {insert, 6, Children, Before}. -file("src/agnostic/vdom/patch.gleam", 148). -spec is_empty(patch(any())) -> boolean(). is_empty(Patch) -> case Patch of {patch, _, _, 0, [], []} -> true; _ -> false end. -file("src/agnostic/vdom/patch.gleam", 157). -spec add_parent(patch(JAM), integer()) -> patch(JAM). add_parent(Child, Index) -> {patch, Index, [erlang:element(2, Child) | erlang:element(3, Child)], erlang:element(4, Child), erlang:element(5, Child), erlang:element(6, Child)}. -file("src/agnostic/vdom/patch.gleam", 251). -spec insert_to_json( integer(), list(agnostic@vdom@vnode:element(JDN)), integer(), agnostic@internals@mutable_map:mutable_map(fun(() -> agnostic@vdom@vnode:element(JDN)), agnostic@vdom@vnode:element(JDN)), fun((agnostic@vdom@vnode:raw_content()) -> binary()) ) -> gleam@json:json(). insert_to_json(Kind, Children, Before, Memos, Serialize_raw_content) -> _pipe = agnostic@internals@json_object_builder:tagged(Kind), _pipe@1 = agnostic@internals@json_object_builder:int( _pipe, <<"before"/utf8>>, Before ), _pipe@2 = agnostic@internals@json_object_builder:list( _pipe@1, <<"children"/utf8>>, Children, fun(Child) -> agnostic@vdom@vnode:to_json(Child, Memos, Serialize_raw_content) end ), agnostic@internals@json_object_builder:build(_pipe@2). -file("src/agnostic/vdom/patch.gleam", 242). -spec replace_to_json( integer(), integer(), agnostic@vdom@vnode:element(JDP), agnostic@internals@mutable_map:mutable_map(fun(() -> agnostic@vdom@vnode:element(JDP)), agnostic@vdom@vnode:element(JDP)), fun((agnostic@vdom@vnode:raw_content()) -> binary()) ) -> gleam@json:json(). replace_to_json(Kind, Index, With, Memos, Serialize_raw_content) -> _pipe = agnostic@internals@json_object_builder:tagged(Kind), _pipe@1 = agnostic@internals@json_object_builder:int( _pipe, <<"index"/utf8>>, Index ), _pipe@2 = agnostic@internals@json_object_builder:json( _pipe@1, <<"with"/utf8>>, (agnostic@vdom@vnode:to_json(With, Memos, Serialize_raw_content)) ), agnostic@internals@json_object_builder:build(_pipe@2). -file("src/agnostic/vdom/patch.gleam", 236). -spec remove_to_json(integer(), integer()) -> gleam@json:json(). remove_to_json(Kind, Index) -> _pipe = agnostic@internals@json_object_builder:tagged(Kind), _pipe@1 = agnostic@internals@json_object_builder:int( _pipe, <<"index"/utf8>>, Index ), agnostic@internals@json_object_builder:build(_pipe@1). -file("src/agnostic/vdom/patch.gleam", 229). -spec move_to_json(integer(), binary(), integer()) -> gleam@json:json(). move_to_json(Kind, Key, Before) -> _pipe = agnostic@internals@json_object_builder:tagged(Kind), _pipe@1 = agnostic@internals@json_object_builder:string( _pipe, <<"key"/utf8>>, Key ), _pipe@2 = agnostic@internals@json_object_builder:int( _pipe@1, <<"before"/utf8>>, Before ), agnostic@internals@json_object_builder:build(_pipe@2). -file("src/agnostic/vdom/patch.gleam", 222). -spec update_to_json( integer(), list(agnostic@vdom@vattr:attribute(any())), list(agnostic@vdom@vattr:attribute(any())) ) -> gleam@json:json(). update_to_json(Kind, Added, Removed) -> _pipe = agnostic@internals@json_object_builder:tagged(Kind), _pipe@1 = agnostic@internals@json_object_builder:list( _pipe, <<"added"/utf8>>, Added, fun agnostic@vdom@vattr:to_json/1 ), _pipe@2 = agnostic@internals@json_object_builder:list( _pipe@1, <<"removed"/utf8>>, Removed, fun agnostic@vdom@vattr:to_json/1 ), agnostic@internals@json_object_builder:build(_pipe@2). -file("src/agnostic/vdom/patch.gleam", 214). -spec replace_raw_node_to_json( integer(), agnostic@vdom@vnode:element(JDY), agnostic@internals@mutable_map:mutable_map(fun(() -> agnostic@vdom@vnode:element(JDY)), agnostic@vdom@vnode:element(JDY)), fun((agnostic@vdom@vnode:raw_content()) -> binary()) ) -> gleam@json:json(). replace_raw_node_to_json(Kind, With, Memos, Serialize_raw_content) -> _pipe = agnostic@internals@json_object_builder:tagged(Kind), _pipe@1 = agnostic@internals@json_object_builder:json( _pipe, <<"with"/utf8>>, (agnostic@vdom@vnode:to_json(With, Memos, Serialize_raw_content)) ), agnostic@internals@json_object_builder:build(_pipe@1). -file("src/agnostic/vdom/patch.gleam", 208). -spec replace_raw_content_to_json(integer(), JAZ, fun((JAZ) -> binary())) -> gleam@json:json(). replace_raw_content_to_json(Kind, Content, Serialize_raw_content) -> _pipe = agnostic@internals@json_object_builder:tagged(Kind), _pipe@1 = agnostic@internals@json_object_builder:string( _pipe, <<"content"/utf8>>, Serialize_raw_content(Content) ), agnostic@internals@json_object_builder:build(_pipe@1). -file("src/agnostic/vdom/patch.gleam", 202). -spec replace_text_to_json(integer(), binary()) -> gleam@json:json(). replace_text_to_json(Kind, Content) -> _pipe = agnostic@internals@json_object_builder:tagged(Kind), _pipe@1 = agnostic@internals@json_object_builder:string( _pipe, <<"content"/utf8>>, Content ), agnostic@internals@json_object_builder:build(_pipe@1). -file("src/agnostic/vdom/patch.gleam", 181). -spec change_to_json( change(JAS), agnostic@internals@mutable_map:mutable_map(fun(() -> agnostic@vdom@vnode:element(JAS)), agnostic@vdom@vnode:element(JAS)), fun((agnostic@vdom@vnode:raw_content()) -> binary()) ) -> gleam@json:json(). change_to_json(Change, Memos, Serialize_raw_content) -> case Change of {replace_text, Kind, Content} -> replace_text_to_json(Kind, Content); {replace_raw_content, Kind@1, Content@1} -> replace_raw_content_to_json( Kind@1, Content@1, Serialize_raw_content ); {replace_raw_node, Kind@2, With} -> replace_raw_node_to_json(Kind@2, With, Memos, Serialize_raw_content); {update, Kind@3, Added, Removed} -> update_to_json(Kind@3, Added, Removed); {move, Kind@4, Key, Before} -> move_to_json(Kind@4, Key, Before); {remove, Kind@5, Index} -> remove_to_json(Kind@5, Index); {replace, Kind@6, Index@1, With@1} -> replace_to_json( Kind@6, Index@1, With@1, Memos, Serialize_raw_content ); {insert, Kind@7, Children, Before@1} -> insert_to_json( Kind@7, Children, Before@1, Memos, Serialize_raw_content ) end. -file("src/agnostic/vdom/patch.gleam", 163). -spec to_json( patch(JAP), agnostic@internals@mutable_map:mutable_map(fun(() -> agnostic@vdom@vnode:element(JAP)), agnostic@vdom@vnode:element(JAP)), fun((agnostic@vdom@vnode:raw_content()) -> binary()) ) -> gleam@json:json(). to_json(Patch, Memos, Serialize_raw_content) -> _pipe = agnostic@internals@json_object_builder:new(), _pipe@1 = agnostic@internals@json_object_builder:list( _pipe, <<"path"/utf8>>, erlang:element(3, Patch), fun gleam@json:int/1 ), _pipe@2 = agnostic@internals@json_object_builder:int( _pipe@1, <<"index"/utf8>>, erlang:element(2, Patch) ), _pipe@3 = agnostic@internals@json_object_builder:int( _pipe@2, <<"removed"/utf8>>, erlang:element(4, Patch) ), _pipe@4 = agnostic@internals@json_object_builder:list( _pipe@3, <<"changes"/utf8>>, erlang:element(5, Patch), fun(Change) -> change_to_json(Change, Memos, Serialize_raw_content) end ), _pipe@5 = agnostic@internals@json_object_builder:list( _pipe@4, <<"children"/utf8>>, erlang:element(6, Patch), fun(Child) -> to_json(Child, Memos, Serialize_raw_content) end ), agnostic@internals@json_object_builder:build(_pipe@5).