-module(og_image@style). -compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]). -define(FILEPATH, "src/og_image/style.gleam"). -export([kebab_to_camel/1, to_json/1]). -if(?OTP_RELEASE >= 27). -define(MODULEDOC(Str), -moduledoc(Str)). -define(DOC(Str), -doc(Str)). -else. -define(MODULEDOC(Str), -compile([])). -define(DOC(Str), -compile([])). -endif. -file("src/og_image/style.gleam", 18). -spec capitalize(binary()) -> binary(). capitalize(S) -> case gleam_stdlib:string_pop_grapheme(S) of {ok, {First, Rest}} -> <<(string:uppercase(First))/binary, Rest/binary>>; {error, _} -> S end. -file("src/og_image/style.gleam", 6). ?DOC(" Convert kebab-case CSS property to camelCase\n"). -spec kebab_to_camel(binary()) -> binary(). kebab_to_camel(Property) -> _pipe = Property, _pipe@1 = gleam@string:split(_pipe, <<"-"/utf8>>), _pipe@2 = gleam@list:index_map(_pipe@1, fun(Part, Index) -> case Index of 0 -> Part; _ -> capitalize(Part) end end), erlang:list_to_binary(_pipe@2). -file("src/og_image/style.gleam", 26). ?DOC(" Convert a list of CSS style tuples to a JSON object\n"). -spec to_json(list({binary(), binary()})) -> gleam@json:json(). to_json(Styles) -> _pipe = Styles, _pipe@1 = gleam@list:map( _pipe, fun(Pair) -> {Property, Value} = Pair, {kebab_to_camel(Property), gleam@json:string(Value)} end ), gleam@json:object(_pipe@1).