content: [manifest]
  version = "0.1.0"
  dump_lua = true
  priority = 0
  
  # Add JoyousSpring generate_ui
  [[patches]]
  [patches.pattern]
  target = "functions/common_events.lua"
  pattern = '''
  --Fill all remaining info if this is the main desc
  '''
  position = 'before'
  match_indent = true
  payload = '''
  if card and card.ability and (type(card.ability.extra) == "table" and
      card.ability.extra.joyous_spring or card.ability.joy_extra_values and next(card.ability.joy_extra_values)) then
      JoyousSpring.generate_info_ui(_c, info_queue, card, desc_nodes, specific_vars, full_UI_table)
  end
  '''
  
  # Customize sell cost
  [[patches]]
  [patches.pattern]
  target = "card.lua"
  pattern = "if self.area and self.ability.couponed and (self.area == G.shop_jokers or self.area == G.shop_booster) then self.cost = 0 end"
  position = 'before'
  match_indent = true
  payload = '''
  if JoyousSpring then JoyousSpring.set_cost(self) end
  '''
  
  # Fix dollar bonus name text
  [[patches]]
  [patches.pattern]
  target = "functions/common_events.lua"
  pattern = "elseif string.find(config.name, 'joker') then"
  position = 'before'
  match_indent = true
  payload = '''
  elseif string.find(config.name, 'joker') and JoyousSpring and JoyousSpring.is_monster_card(config.card) then
      local joy_loc_string = localize{type = 'name_text', set = config.card.config.center.set, key = config.card.config.center.key}
      table.insert(left_text, {n=G.UIT.O, config={object = DynaText({string = joy_loc_string, colours = {JoyousSpring.get_name_color(config.card.config.center.key) or G.C.JOY.NORMAL}, shadow = true, pop_in = 0, scale = (0.6*scale)- 0.006 * #joy_loc_string, silent = true})}})
  '''
  
  # Consumable box
  [[patches]]
  [patches.pattern]
  target = 'functions/UI_definitions.lua'
  match_indent = true
  position = 'before'
  pattern = '''
  if multi_boxes[1] then
  '''
  payload = '''
  if not card.debuff and card.joy_transfer_text and type(card.ability.extra) == "table" and (card.ability.extra.joyous_spring or {}).material_effects and next(card.ability.extra.joyous_spring.material_effects) then
      --ret_val.nodes[1].nodes[1].nodes[1].config.padding = 0.01
  else
      local joy_desc_rows = ret_val.nodes[1].nodes[1].nodes[1]
      if AUT.joy_consumable then
          for i=1, #joy_desc_rows.nodes do -- find the main box
              if joy_desc_rows.nodes[i] and joy_desc_rows.nodes[i].config and joy_desc_rows.nodes[i].config.main_box_flag then
                  table.insert(joy_desc_rows.nodes, i, desc_from_rows(AUT.joy_consumable))
                  break
              end
          end
      end
  end
  '''
  
  # Better info_queue layout
  [[patches]]
  [patches.pattern]
  target = "functions/UI_definitions.lua"
  pattern = "local nodes_per_col = math.ceil(#info_boxes/cols)"
  position = 'before'
  match_indent = true
  payload = '''
  if JoyousSpring.is_monster_card(card) then cols = card.area and card.area == G.shop_jokers and math.ceil(#info_boxes/2) or 1 end
  '''
  
  [[patches]]
  [patches.pattern]
  target = "functions/UI_definitions.lua"
  pattern = '''
  info_tip_from_rows(v, v.name),
      }}
  }}
  '''
  position = 'after'
  match_indent = true
  payload = '''
  if JoyousSpring.is_from_joyousspring(card) then
      info_boxes[#info_boxes].config.align = JoyousSpring.is_monster_card(card) and (card.area and card.area == G.shop_jokers and "tm" or ((card.T.x > G.ROOM.T.w * 0.4) and "cr" or "cl")) or "cm"
      info_boxes[#info_boxes].nodes[1].config.align = JoyousSpring.is_monster_card(card) and (card.area and card.area == G.shop_jokers and "tm" or ((card.T.x > G.ROOM.T.w * 0.4) and "cr" or "cl")) or "cm"
  end
  '''
  
  [[patches]]
  [patches.pattern]
  target = "functions/UI_definitions.lua"
  pattern = '''table.insert(info_cols, {n=G.UIT.C, config = {align="cm"}, nodes = col})'''
  position = 'after'
  match_indent = true
  payload = '''
  if JoyousSpring.is_from_joyousspring(card) then
      info_cols[#info_cols].config.align = card.area and card.area == G.shop_jokers and "tm" or "cm"
  end
  '''
  
  # More info for info_queue layout and transferred ability text
  [[patches]]
  [patches.pattern]
  target = "functions/UI_definitions.lua"
  pattern = "info_boxes = {{n=G.UIT.R, config = {align=\"cm\", padding = 0.05, card_pos = card.T.x }, nodes = info_cols}}"
  position = 'after'
  match_indent = true
  payload = '''
  info_boxes[1].config.card = card
  
  if card and not card.debuff and type(card.ability) == "table" and type(card.ability.extra) == "table" and (card.ability.extra.joyous_spring or {}).material_effects and next(card.ability.extra.joyous_spring.material_effects) then
      local modNodes = {}
  
      modNodes[#modNodes + 1] = {}
      local loc_vars = { background_colour = G.C.CLEAR, text_colour = G.C.WHITE }
      localize { type = 'descriptions', key = "joy_tooltip_transferred", set = 'Other', nodes = modNodes[#modNodes], scale = loc_vars.scale, text_colour = loc_vars.text_colour }
      modNodes[#modNodes] = desc_from_rows(modNodes[#modNodes])
      modNodes[#modNodes].config.colour = loc_vars.background_colour or modNodes[#modNodes].config.colour
  
      badges = {
          {n=G.UIT.C, config={align = "cm", padding = 0.03}, nodes=badges},
          {n=G.UIT.C, config={align = "cl", padding = 0.03}, nodes=modNodes},
      }
  end
  '''
  
  # Nicer display for Jokers with long names
  [[patches]]
  [patches.pattern]
  target = "functions/misc_functions.lua"
  pattern = "if args.type == 'name' then"
  position = 'after'
  match_indent = true
  payload = '''
  if JoyousSpring.main_card_ui then
      args.maxw = 9999999999
  end
  '''
  