package net.miginfocom.layout;

import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.Collection;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.TreeSet;
import java.util.WeakHashMap;
import java.util.Map.Entry;

public final class Grid {
   public static final boolean TEST_GAPS = true;
   private static final Float[] GROW_100;
   private static final DimConstraint DOCK_DIM_CONSTRAINT;
   private static final int MAX_GRID = 30000;
   private static final int MAX_DOCK_GRID = 32767;
   private static final ResizeConstraint GAP_RC_CONST;
   private static final ResizeConstraint GAP_RC_CONST_PUSH;
   private static final CC DEF_CC;
   private final LC lc;
   private final ContainerWrapper container;
   private final LinkedHashMap<Integer, Grid.Cell> grid = new LinkedHashMap();
   private HashMap<Integer, BoundSize> wrapGapMap = null;
   private final TreeSet<Integer> rowIndexes = new TreeSet();
   private final TreeSet<Integer> colIndexes = new TreeSet();
   private final AC rowConstr;
   private final AC colConstr;
   private Grid.FlowSizeSpec colFlowSpecs = null;
   private Grid.FlowSizeSpec rowFlowSpecs = null;
   private final ArrayList<Grid.LinkedDimGroup>[] colGroupLists;
   private final ArrayList<Grid.LinkedDimGroup>[] rowGroupLists;
   private int[] width = null;
   private int[] height = null;
   private ArrayList<int[]> debugRects = null;
   private HashMap<String, Boolean> linkTargetIDs = null;
   private final int dockOffY;
   private final int dockOffX;
   private final Float[] pushXs;
   private final Float[] pushYs;
   private final ArrayList<LayoutCallback> callbackList;
   private static WeakHashMap<Object, int[][]>[] PARENT_ROWCOL_SIZES_MAP;
   private static WeakHashMap<Object, ArrayList<Grid.WeakCell>> PARENT_GRIDPOS_MAP;

   public Grid(ContainerWrapper var1, LC var2, AC var3, AC var4, Map<ComponentWrapper, CC> var5, ArrayList<LayoutCallback> var6) {
      this.lc = var2;
      this.rowConstr = var3;
      this.colConstr = var4;
      this.container = var1;
      this.callbackList = var6;
      int var7 = var2.getWrapAfter() != 0 ? var2.getWrapAfter() : (var2.isFlowX() ? var4 : var3).getConstaints().length;
      ComponentWrapper[] var8 = var1.getComponents();
      boolean var9 = false;
      boolean var10 = false;
      boolean var11 = false;
      boolean var12 = false;
      int[] var13 = new int[2];
      ArrayList var14 = new ArrayList(2);
      DimConstraint[] var15 = (var2.isFlowX() ? var3 : var4).getConstaints();
      int var16 = 0;
      int var17 = 0;
      int[] var18 = null;
      LinkHandler.clearTemporaryBounds(var1.getLayout());
      int var19 = 0;

      Grid.CompWrap var25;
      while(var19 < var8.length) {
         ComponentWrapper var20 = var8[var19];
         CC var21 = getCC(var20, var5);
         this.addLinkIDs(var21);
         int var22 = var20.isVisible() ? -1 : (var21.getHideMode() != -1 ? var21.getHideMode() : var2.getHideMode());
         if (var22 == 3) {
            this.setLinkedBounds(var20, var21, var20.getX(), var20.getY(), var20.getWidth(), var20.getHeight(), var21.isExternal());
            ++var19;
         } else {
            if (var21.getHorizontal().getSizeGroup() != null) {
               ++var16;
            }

            if (var21.getVertical().getSizeGroup() != null) {
               ++var17;
            }

            UnitValue[] var23 = this.getPos(var20, var21);
            BoundSize[] var24 = this.getCallbackSize(var20);
            Grid.Cell var26;
            if (var23 != null || var21.isExternal()) {
               var25 = new Grid.CompWrap(var20, var21, var22, var23, var24);
               var26 = (Grid.Cell)this.grid.get((Object)null);
               if (var26 == null) {
                  this.grid.put((Object)null, new Grid.Cell(var25));
               } else {
                  var26.compWraps.add(var25);
               }

               if (!var21.isBoundsInGrid() || var21.isExternal()) {
                  this.setLinkedBounds(var20, var21, var20.getX(), var20.getY(), var20.getWidth(), var20.getHeight(), var21.isExternal());
                  ++var19;
                  continue;
               }
            }

            if (var21.getDockSide() != -1) {
               if (var18 == null) {
                  var18 = new int[]{-32767, -32767, 32767, 32767};
               }

               this.addDockingCell(var18, var21.getDockSide(), new Grid.CompWrap(var20, var21, var22, var23, var24));
               ++var19;
            } else {
               Boolean var52 = var21.getFlowX();
               var26 = null;
               if (var21.isNewline()) {
                  this.wrap(var13, var21.getNewlineGapSize());
               } else if (var12) {
                  this.wrap(var13, (BoundSize)null);
               }

               var12 = false;
               boolean var27 = var2.isNoGrid() || ((DimConstraint)LayoutUtil.getIndexSafe(var15, var2.isFlowX() ? var13[1] : var13[0])).isNoGrid();
               int var28 = var21.getCellX();
               int var29 = var21.getCellY();
               if ((var28 < 0 || var29 < 0) && !var27 && var21.getSkip() == 0) {
                  while(!this.isCellFree(var13[1], var13[0], var14)) {
                     if (Math.abs(this.increase(var13, 1)) >= var7) {
                        this.wrap(var13, (BoundSize)null);
                     }
                  }
               } else {
                  if (var28 >= 0 && var29 >= 0) {
                     if (var29 >= 0) {
                        var13[0] = var28;
                        var13[1] = var29;
                     } else if (var2.isFlowX()) {
                        var13[0] = var28;
                     } else {
                        var13[1] = var28;
                     }
                  }

                  var26 = this.getCell(var13[1], var13[0]);
               }

               int var30 = 0;

               int var31;
               for(var31 = var21.getSkip(); var30 < var31; ++var30) {
                  do {
                     if (Math.abs(this.increase(var13, 1)) >= var7) {
                        this.wrap(var13, (BoundSize)null);
                     }
                  } while(!this.isCellFree(var13[1], var13[0], var14));
               }

               if (var26 == null) {
                  var30 = Math.min(var27 && var2.isFlowX() ? 2097051 : var21.getSpanX(), 30000 - var13[0]);
                  var31 = Math.min(var27 && !var2.isFlowX() ? 2097051 : var21.getSpanY(), 30000 - var13[1]);
                  var26 = new Grid.Cell(var30, var31, var52 != null ? var52 : var2.isFlowX());
                  this.setCell(var13[1], var13[0], var26);
                  if (var30 > 1 || var31 > 1) {
                     var14.add(new int[]{var13[0], var13[1], var30, var31});
                  }
               }

               boolean var59 = false;
               var31 = var27 ? 2097051 : var21.getSplit() - 1;
               boolean var32 = false;

               for(boolean var33 = (var2.isFlowX() ? var21.getSpanX() : var21.getSpanY()) == 2097051; var31 >= 0 && var19 < var8.length; --var31) {
                  ComponentWrapper var34 = var8[var19];
                  CC var35 = getCC(var34, var5);
                  this.addLinkIDs(var35);
                  boolean var36 = var34.isVisible();
                  var22 = var36 ? -1 : (var35.getHideMode() != -1 ? var35.getHideMode() : var2.getHideMode());
                  if (!var35.isExternal() && var22 != 3) {
                     var10 |= (var36 || var22 > 1) && var35.getPushX() != null;
                     var11 |= (var36 || var22 > 1) && var35.getPushY() != null;
                     if (var35 != var21) {
                        if (var35.isNewline() || !var35.isBoundsInGrid() || var35.getDockSide() != -1) {
                           break;
                        }

                        if (var31 > 0 && var35.getSkip() > 0) {
                           var32 = true;
                           break;
                        }

                        var23 = this.getPos(var34, var35);
                        var24 = this.getCallbackSize(var34);
                     }

                     Grid.CompWrap var37 = new Grid.CompWrap(var34, var35, var22, var23, var24);
                     var26.compWraps.add(var37);
                     Grid.Cell.access$476(var26, var35.getTag() != null ? 1 : 0);
                     var9 |= var26.hasTagged;
                     if (var35 != var21) {
                        if (var35.getHorizontal().getSizeGroup() != null) {
                           ++var16;
                        }

                        if (var35.getVertical().getSizeGroup() != null) {
                           ++var17;
                        }
                     }

                     ++var19;
                     if (var35.isWrap() || var33 && var31 == 0) {
                        if (var35.isWrap()) {
                           this.wrap(var13, var35.getWrapGapSize());
                        } else {
                           var12 = true;
                        }

                        var59 = true;
                        break;
                     }
                  } else {
                     ++var19;
                     ++var31;
                  }
               }

               if (!var59 && !var27) {
                  int var61 = var2.isFlowX() ? var26.spanx : var26.spany;
                  if (Math.abs(var2.isFlowX() ? var13[0] : var13[1]) + var61 >= var7) {
                     var12 = true;
                  } else {
                     this.increase(var13, var32 ? var61 - 1 : var61);
                  }
               }
            }
         }
      }

      HashMap var38;
      HashMap var39;
      ArrayList var41;
      Iterator var46;
      Grid.Cell var47;
      Grid.CompWrap var49;
      int var50;
      String var53;
      String var56;
      if (var16 > 0 || var17 > 0) {
         var39 = var16 > 0 ? new HashMap(var16) : null;
         var38 = var17 > 0 ? new HashMap(var17) : null;
         var41 = new ArrayList(Math.max(var16, var17));
         var46 = this.grid.values().iterator();

         while(var46.hasNext()) {
            var47 = (Grid.Cell)var46.next();

            for(var50 = 0; var50 < var47.compWraps.size(); ++var50) {
               var25 = (Grid.CompWrap)var47.compWraps.get(var50);
               var56 = var25.cc.getHorizontal().getSizeGroup();
               var53 = var25.cc.getVertical().getSizeGroup();
               if (var56 != null || var53 != null) {
                  if (var56 != null && var39 != null) {
                     addToSizeGroup(var39, var56, var25.horSizes);
                  }

                  if (var53 != null && var38 != null) {
                     addToSizeGroup(var38, var53, var25.verSizes);
                  }

                  var41.add(var25);
               }
            }
         }

         var46 = var41.iterator();

         while(var46.hasNext()) {
            var49 = (Grid.CompWrap)var46.next();
            if (var39 != null) {
               var49.setSizes((int[])var39.get(var49.cc.getHorizontal().getSizeGroup()), true);
            }

            if (var38 != null) {
               var49.setSizes((int[])var38.get(var49.cc.getVertical().getSizeGroup()), false);
            }
         }
      }

      if (var16 > 0 || var17 > 0) {
         var39 = var16 > 0 ? new HashMap(var16) : null;
         var38 = var17 > 0 ? new HashMap(var17) : null;
         var41 = new ArrayList(Math.max(var16, var17));
         var46 = this.grid.values().iterator();

         while(var46.hasNext()) {
            var47 = (Grid.Cell)var46.next();

            for(var50 = 0; var50 < var47.compWraps.size(); ++var50) {
               var25 = (Grid.CompWrap)var47.compWraps.get(var50);
               var56 = var25.cc.getHorizontal().getSizeGroup();
               var53 = var25.cc.getVertical().getSizeGroup();
               if (var56 != null || var53 != null) {
                  if (var56 != null && var39 != null) {
                     addToSizeGroup(var39, var56, var25.horSizes);
                  }

                  if (var53 != null && var38 != null) {
                     addToSizeGroup(var38, var53, var25.verSizes);
                  }

                  var41.add(var25);
               }
            }
         }

         var46 = var41.iterator();

         while(var46.hasNext()) {
            var49 = (Grid.CompWrap)var46.next();
            if (var39 != null) {
               var49.setSizes((int[])var39.get(var49.cc.getHorizontal().getSizeGroup()), true);
            }

            if (var38 != null) {
               var49.setSizes((int[])var38.get(var49.cc.getVertical().getSizeGroup()), false);
            }
         }
      }

      if (var9) {
         sortCellsByPlatform(this.grid.values(), var1);
      }

      boolean var43 = LayoutUtil.isLeftToRight(var2, var1);
      Iterator var40 = this.grid.values().iterator();

      while(var40.hasNext()) {
         Grid.Cell var44 = (Grid.Cell)var40.next();
         ArrayList var48 = var44.compWraps;
         int var51 = 0;

         for(var50 = var48.size() - 1; var51 <= var50; ++var51) {
            var25 = (Grid.CompWrap)var48.get(var51);
            ComponentWrapper var57 = var51 > 0 ? ((Grid.CompWrap)var48.get(var51 - 1)).comp : null;
            ComponentWrapper var54 = var51 < var50 ? ((Grid.CompWrap)var48.get(var51 + 1)).comp : null;
            String var55 = getCC(var25.comp, var5).getTag();
            CC var58 = var57 != null ? getCC(var57, var5) : null;
            CC var60 = var54 != null ? getCC(var54, var5) : null;
            var25.calcGaps(var57, var58, var54, var60, var55, var44.flowx, var43);
         }
      }

      this.dockOffX = getDockInsets(this.colIndexes);
      this.dockOffY = getDockInsets(this.rowIndexes);
      int var42 = 0;

      int var45;
      for(var45 = var3.getCount(); var42 < var45; ++var42) {
         this.rowIndexes.add(var42);
      }

      var42 = 0;

      for(var45 = var4.getCount(); var42 < var45; ++var42) {
         this.colIndexes.add(var42);
      }

      this.colGroupLists = this.divideIntoLinkedGroups(false);
      this.rowGroupLists = this.divideIntoLinkedGroups(true);
      this.pushXs = !var10 && !var2.isFillX() ? null : this.getDefaultPushWeights(false);
      this.pushYs = !var11 && !var2.isFillY() ? null : this.getDefaultPushWeights(true);
      if (LayoutUtil.isDesignTime(var1)) {
         saveGrid(var1, this.grid);
      }

   }

   private static CC getCC(ComponentWrapper var0, Map<ComponentWrapper, CC> var1) {
      CC var2 = (CC)var1.get(var0);
      return var2 != null ? var2 : DEF_CC;
   }

   private void addLinkIDs(CC var1) {
      String[] var2 = var1.getLinkTargets();
      String[] var3 = var2;
      int var4 = var2.length;

      for(int var5 = 0; var5 < var4; ++var5) {
         String var6 = var3[var5];
         if (this.linkTargetIDs == null) {
            this.linkTargetIDs = new HashMap();
         }

         this.linkTargetIDs.put(var6, (Object)null);
      }

   }

   public void invalidateContainerSize() {
      this.colFlowSpecs = null;
   }

   public boolean layout(int[] var1, UnitValue var2, UnitValue var3, boolean var4, boolean var5) {
      if (var4) {
         this.debugRects = new ArrayList();
      }

      this.checkSizeCalcs();
      this.resetLinkValues(true, true);
      this.layoutInOneDim(var1[2], var2, false, this.pushXs);
      this.layoutInOneDim(var1[3], var3, true, this.pushYs);
      HashMap var6 = null;
      HashMap var7 = null;
      int var8 = this.container.getComponentCount();
      boolean var9 = false;
      if (var8 > 0) {
         for(int var10 = 0; var10 < (this.linkTargetIDs != null ? 2 : 1); ++var10) {
            int var12 = 0;

            boolean var11;
            do {
               var11 = false;
               Iterator var13 = this.grid.values().iterator();

               while(var13.hasNext()) {
                  Grid.Cell var14 = (Grid.Cell)var13.next();
                  ArrayList var15 = var14.compWraps;
                  int var16 = 0;

                  for(int var17 = var15.size(); var16 < var17; ++var16) {
                     Grid.CompWrap var18 = (Grid.CompWrap)var15.get(var16);
                     if (var10 == 0) {
                        var11 |= this.doAbsoluteCorrections(var18, var1);
                        if (!var11) {
                           if (var18.cc.getHorizontal().getEndGroup() != null) {
                              var6 = addToEndGroup(var6, var18.cc.getHorizontal().getEndGroup(), var18.x + var18.w);
                           }

                           if (var18.cc.getVertical().getEndGroup() != null) {
                              var7 = addToEndGroup(var7, var18.cc.getVertical().getEndGroup(), var18.y + var18.h);
                           }
                        }

                        if (this.linkTargetIDs != null && (this.linkTargetIDs.containsKey("visual") || this.linkTargetIDs.containsKey("container"))) {
                           var9 = true;
                        }
                     }

                     if (this.linkTargetIDs == null || var10 == 1) {
                        if (var18.cc.getHorizontal().getEndGroup() != null) {
                           var18.w = (Integer)var6.get(var18.cc.getHorizontal().getEndGroup()) - var18.x;
                        }

                        if (var18.cc.getVertical().getEndGroup() != null) {
                           var18.h = (Integer)var7.get(var18.cc.getVertical().getEndGroup()) - var18.y;
                        }

                        var18.x = var1[0];
                        var18.y = var1[1];
                        var9 |= var18.transferBounds(var5 && !var9);
                        if (this.callbackList != null) {
                           Iterator var19 = this.callbackList.iterator();

                           while(var19.hasNext()) {
                              LayoutCallback var20 = (LayoutCallback)var19.next();
                              var20.correctBounds(var18.comp);
                           }
                        }
                     }
                  }
               }

               this.clearGroupLinkBounds();
               ++var12;
               if (var12 > (var8 << 3) + 10) {
                  System.err.println("Unstable cyclic dependency in absolute linked values!");
                  break;
               }
            } while(var11);
         }
      }

      if (var4) {
         Iterator var21 = this.grid.values().iterator();

         while(var21.hasNext()) {
            Grid.Cell var22 = (Grid.Cell)var21.next();
            ArrayList var23 = var22.compWraps;
            int var24 = 0;

            for(int var25 = var23.size(); var24 < var25; ++var24) {
               Grid.CompWrap var26 = (Grid.CompWrap)var23.get(var24);
               Grid.LinkedDimGroup var27 = getGroupContaining(this.colGroupLists, var26);
               Grid.LinkedDimGroup var28 = getGroupContaining(this.rowGroupLists, var26);
               if (var27 != null && var28 != null) {
                  this.debugRects.add(new int[]{var27.lStart + var1[0] - (var27.fromEnd ? var27.lSize : 0), var28.lStart + var1[1] - (var28.fromEnd ? var28.lSize : 0), var27.lSize, var28.lSize});
               }
            }
         }
      }

      return var9;
   }

   public void paintDebug() {
      if (this.debugRects != null) {
         this.container.paintDebugOutline();
         ArrayList var1 = new ArrayList();
         int var2 = 0;

         for(int var3 = this.debugRects.size(); var2 < var3; ++var2) {
            int[] var4 = (int[])this.debugRects.get(var2);
            if (!var1.contains(var4)) {
               this.container.paintDebugCell(var4[0], var4[1], var4[2], var4[3]);
               var1.add(var4);
            }
         }

         Iterator var7 = this.grid.values().iterator();

         while(var7.hasNext()) {
            Grid.Cell var8 = (Grid.Cell)var7.next();
            ArrayList var9 = var8.compWraps;
            int var5 = 0;

            for(int var6 = var9.size(); var5 < var6; ++var5) {
               ((Grid.CompWrap)var9.get(var5)).comp.paintDebugOutline();
            }
         }
      }

   }

   public ContainerWrapper getContainer() {
      return this.container;
   }

   public final int[] getWidth() {
      this.checkSizeCalcs();
      return (int[])this.width.clone();
   }

   public final int[] getHeight() {
      this.checkSizeCalcs();
      return (int[])this.height.clone();
   }

   private void checkSizeCalcs() {
      if (this.colFlowSpecs == null) {
         this.colFlowSpecs = this.calcRowsOrColsSizes(true);
         this.rowFlowSpecs = this.calcRowsOrColsSizes(false);
         this.width = this.getMinPrefMaxSumSize(true);
         this.height = this.getMinPrefMaxSumSize(false);
         if (this.linkTargetIDs == null) {
            this.resetLinkValues(false, true);
         } else {
            this.layout(new int[4], (UnitValue)null, (UnitValue)null, false, false);
            this.resetLinkValues(false, false);
         }

         this.adjustSizeForAbsolute(true);
         this.adjustSizeForAbsolute(false);
      }

   }

   private UnitValue[] getPos(ComponentWrapper var1, CC var2) {
      UnitValue[] var3 = null;
      if (this.callbackList != null) {
         for(int var4 = 0; var4 < this.callbackList.size() && var3 == null; ++var4) {
            var3 = ((LayoutCallback)this.callbackList.get(var4)).getPosition(var1);
         }
      }

      UnitValue[] var7 = var2.getPos();
      if (var3 != null && var7 != null) {
         for(int var5 = 0; var5 < 4; ++var5) {
            UnitValue var6 = var3[var5];
            if (var6 != null) {
               var7[var5] = var6;
            }
         }

         return var7;
      } else {
         return var3 != null ? var3 : var7;
      }
   }

   private BoundSize[] getCallbackSize(ComponentWrapper var1) {
      if (this.callbackList != null) {
         Iterator var2 = this.callbackList.iterator();

         while(var2.hasNext()) {
            LayoutCallback var3 = (LayoutCallback)var2.next();
            BoundSize[] var4 = var3.getSize(var1);
            if (var4 != null) {
               return var4;
            }
         }
      }

      return null;
   }

   private static int getDockInsets(TreeSet<Integer> var0) {
      int var1 = 0;

      for(Iterator var2 = var0.iterator(); var2.hasNext(); ++var1) {
         Integer var3 = (Integer)var2.next();
         if (var3 >= -30000) {
            break;
         }
      }

      return var1;
   }

   private boolean setLinkedBounds(ComponentWrapper var1, CC var2, int var3, int var4, int var5, int var6, boolean var7) {
      String var8 = var2.getId() != null ? var2.getId() : var1.getLinkId();
      if (var8 == null) {
         return false;
      } else {
         String var9 = null;
         int var10 = var8.indexOf(46);
         if (var10 != -1) {
            var9 = var8.substring(0, var10);
            var8 = var8.substring(var10 + 1);
         }

         Object var11 = this.container.getLayout();
         boolean var12 = false;
         if (var7 || this.linkTargetIDs != null && this.linkTargetIDs.containsKey(var8)) {
            var12 = LinkHandler.setBounds(var11, var8, var3, var4, var5, var6, !var7, false);
         }

         if (var9 != null && (var7 || this.linkTargetIDs != null && this.linkTargetIDs.containsKey(var9))) {
            if (this.linkTargetIDs == null) {
               this.linkTargetIDs = new HashMap(4);
            }

            this.linkTargetIDs.put(var9, Boolean.TRUE);
            var12 |= LinkHandler.setBounds(var11, var9, var3, var4, var5, var6, !var7, true);
         }

         return var12;
      }
   }

   private int increase(int[] var1, int var2) {
      return this.lc.isFlowX() ? (var1[0] += var2) : (var1[1] += var2);
   }

   private void wrap(int[] var1, BoundSize var2) {
      boolean var3 = this.lc.isFlowX();
      var1[0] = var3 ? 0 : var1[0] + 1;
      var1[1] = var3 ? var1[1] + 1 : 0;
      if (var2 != null) {
         if (this.wrapGapMap == null) {
            this.wrapGapMap = new HashMap(8);
         }

         this.wrapGapMap.put(var1[var3 ? 1 : 0], var2);
      }

      if (var3) {
         this.rowIndexes.add(var1[1]);
      } else {
         this.colIndexes.add(var1[0]);
      }

   }

   private static void sortCellsByPlatform(Collection<Grid.Cell> var0, ContainerWrapper var1) {
      String var2 = PlatformDefaults.getButtonOrder();
      String var3 = var2.toLowerCase();
      int var4 = PlatformDefaults.convertToPixels(1.0F, "u", true, 0.0F, var1, (ComponentWrapper)null);
      if (var4 == -87654312) {
         throw new IllegalArgumentException("'unrelated' not recognized by PlatformDefaults!");
      } else {
         int[] var5 = new int[]{var4, var4, -2147471302};
         int[] var6 = new int[]{0, 0, -2147471302};
         Iterator var7 = var0.iterator();

         while(true) {
            Grid.Cell var8;
            do {
               if (!var7.hasNext()) {
                  return;
               }

               var8 = (Grid.Cell)var7.next();
            } while(!var8.hasTagged);

            Grid.CompWrap var9 = null;
            boolean var10 = false;
            boolean var11 = false;
            ArrayList var12 = new ArrayList(var8.compWraps.size());
            int var13 = 0;

            for(int var14 = var3.length(); var13 < var14; ++var13) {
               char var15 = var3.charAt(var13);
               if (var15 != '+' && var15 != '_') {
                  String var16 = PlatformDefaults.getTagForChar(var15);
                  if (var16 != null) {
                     int var17 = 0;

                     for(int var18 = var8.compWraps.size(); var17 < var18; ++var17) {
                        Grid.CompWrap var19 = (Grid.CompWrap)var8.compWraps.get(var17);
                        if (var16.equals(var19.cc.getTag())) {
                           if (Character.isUpperCase(var2.charAt(var13))) {
                              int var20 = PlatformDefaults.getMinimumButtonWidth().getPixels(0.0F, var1, var19.comp);
                              if (var20 > var19.horSizes[0]) {
                                 var19.horSizes[0] = var20;
                              }

                              correctMinMax(var19.horSizes);
                           }

                           var12.add(var19);
                           if (var10) {
                              (var9 != null ? var9 : var19).mergeGapSizes(var5, var8.flowx, var9 == null);
                              if (var11) {
                                 var19.forcedPushGaps = 1;
                                 var10 = false;
                                 var11 = false;
                              }
                           }

                           if (var15 == 'u') {
                              var10 = true;
                           }

                           var9 = var19;
                        }
                     }
                  }
               } else {
                  var10 = true;
                  if (var15 == '+') {
                     var11 = true;
                  }
               }
            }

            if (var12.size() > 0) {
               Grid.CompWrap var21 = (Grid.CompWrap)var12.get(var12.size() - 1);
               if (var10) {
                  var21.mergeGapSizes(var5, var8.flowx, false);
                  if (var11) {
                     var21.forcedPushGaps = 2;
                  }
               }

               if (var21.cc.getHorizontal().getGapAfter() == null) {
                  var21.setGaps(var6, 3);
               }

               var21 = (Grid.CompWrap)var12.get(0);
               if (var21.cc.getHorizontal().getGapBefore() == null) {
                  var21.setGaps(var6, 1);
               }
            }

            if (var8.compWraps.size() == var12.size()) {
               var8.compWraps.clear();
            } else {
               var8.compWraps.removeAll(var12);
            }

            var8.compWraps.addAll(var12);
         }
      }
   }

   private Float[] getDefaultPushWeights(boolean var1) {
      ArrayList[] var2 = var1 ? this.rowGroupLists : this.colGroupLists;
      Float[] var3 = GROW_100;
      int var4 = 0;

      for(int var5 = 1; var4 < var2.length; var5 += 2) {
         ArrayList var6 = var2[var4];
         Float var7 = null;
         Iterator var8 = var6.iterator();

         while(var8.hasNext()) {
            Grid.LinkedDimGroup var9 = (Grid.LinkedDimGroup)var8.next();

            for(int var10 = 0; var10 < var9._compWraps.size(); ++var10) {
               Grid.CompWrap var11 = (Grid.CompWrap)var9._compWraps.get(var10);
               int var12 = var11.comp.isVisible() ? -1 : (var11.cc.getHideMode() != -1 ? var11.cc.getHideMode() : this.lc.getHideMode());
               Float var13 = var12 < 2 ? (var1 ? var11.cc.getPushY() : var11.cc.getPushX()) : null;
               if (var7 == null || var13 != null && var13 > var7) {
                  var7 = var13;
               }
            }
         }

         if (var7 != null) {
            if (var3 == GROW_100) {
               var3 = new Float[(var2.length << 1) + 1];
            }

            var3[var5] = var7;
         }

         ++var4;
      }

      return var3;
   }

   private void clearGroupLinkBounds() {
      if (this.linkTargetIDs != null) {
         Iterator var1 = this.linkTargetIDs.entrySet().iterator();

         while(var1.hasNext()) {
            Entry var2 = (Entry)var1.next();
            if (var2.getValue() == Boolean.TRUE) {
               LinkHandler.clearBounds(this.container.getLayout(), (String)var2.getKey());
            }
         }

      }
   }

   private void resetLinkValues(boolean var1, boolean var2) {
      Object var3 = this.container.getLayout();
      if (var2) {
         LinkHandler.clearTemporaryBounds(var3);
      }

      boolean var4 = !this.hasDocks();
      int var5 = var1 ? this.lc.getWidth().constrain(this.container.getWidth(), (float)getParentSize(this.container, true), this.container) : 0;
      int var6 = var1 ? this.lc.getHeight().constrain(this.container.getHeight(), (float)getParentSize(this.container, false), this.container) : 0;
      int var7 = LayoutUtil.getInsets(this.lc, 0, var4).getPixels(0.0F, this.container, (ComponentWrapper)null);
      int var8 = LayoutUtil.getInsets(this.lc, 1, var4).getPixels(0.0F, this.container, (ComponentWrapper)null);
      int var9 = var5 - var7 - LayoutUtil.getInsets(this.lc, 2, var4).getPixels(0.0F, this.container, (ComponentWrapper)null);
      int var10 = var6 - var8 - LayoutUtil.getInsets(this.lc, 3, var4).getPixels(0.0F, this.container, (ComponentWrapper)null);
      LinkHandler.setBounds(var3, "visual", var7, var8, var9, var10, true, false);
      LinkHandler.setBounds(var3, "container", 0, 0, var5, var6, true, false);
   }

   private static Grid.LinkedDimGroup getGroupContaining(ArrayList<Grid.LinkedDimGroup>[] var0, Grid.CompWrap var1) {
      ArrayList[] var2 = var0;
      int var3 = var0.length;

      for(int var4 = 0; var4 < var3; ++var4) {
         ArrayList var5 = var2[var4];
         int var6 = 0;

         for(int var7 = var5.size(); var6 < var7; ++var6) {
            ArrayList var8 = ((Grid.LinkedDimGroup)var5.get(var6))._compWraps;
            int var9 = 0;

            for(int var10 = var8.size(); var9 < var10; ++var9) {
               if (var8.get(var9) == var1) {
                  return (Grid.LinkedDimGroup)var5.get(var6);
               }
            }
         }
      }

      return null;
   }

   private boolean doAbsoluteCorrections(Grid.CompWrap var1, int[] var2) {
      boolean var3 = false;
      int[] var4 = this.getAbsoluteDimBounds(var1, var2[2], true);
      if (var4 != null) {
         var1.setDimBounds(var4[0], var4[1], true);
      }

      var4 = this.getAbsoluteDimBounds(var1, var2[3], false);
      if (var4 != null) {
         var1.setDimBounds(var4[0], var4[1], false);
      }

      if (this.linkTargetIDs != null) {
         var3 = this.setLinkedBounds(var1.comp, var1.cc, var1.x, var1.y, var1.w, var1.h, false);
      }

      return var3;
   }

   private void adjustSizeForAbsolute(boolean var1) {
      int[] var2 = var1 ? this.width : this.height;
      Grid.Cell var3 = (Grid.Cell)this.grid.get((Object)null);
      if (var3 != null && var3.compWraps.size() != 0) {
         ArrayList var4 = var3.compWraps;
         int var5 = 0;
         int var6 = 0;

         for(int var7 = var3.compWraps.size(); var6 < var7 + 3; ++var6) {
            boolean var8 = false;

            for(int var9 = 0; var9 < var7; ++var9) {
               Grid.CompWrap var10 = (Grid.CompWrap)var4.get(var9);
               int[] var11 = this.getAbsoluteDimBounds(var10, 0, var1);
               int var12 = var11[0] + var11[1];
               if (var5 < var12) {
                  var5 = var12;
               }

               if (this.linkTargetIDs != null) {
                  var8 |= this.setLinkedBounds(var10.comp, var10.cc, var11[0], var11[0], var11[1], var11[1], false);
               }
            }

            if (!var8) {
               break;
            }

            var5 = 0;
            this.clearGroupLinkBounds();
         }

         var5 += LayoutUtil.getInsets(this.lc, var1 ? 3 : 2, !this.hasDocks()).getPixels(0.0F, this.container, (ComponentWrapper)null);
         if (var2[0] < var5) {
            var2[0] = var5;
         }

         if (var2[1] < var5) {
            var2[1] = var5;
         }

      }
   }

   private int[] getAbsoluteDimBounds(Grid.CompWrap var1, int var2, boolean var3) {
      if (var1.cc.isExternal()) {
         return var3 ? new int[]{var1.comp.getX(), var1.comp.getWidth()} : new int[]{var1.comp.getY(), var1.comp.getHeight()};
      } else {
         int[] var4 = this.lc.isVisualPadding() ? var1.comp.getVisualPadding() : null;
         UnitValue[] var5 = var1.cc.getPadding();
         if (var1.pos == null && var4 == null && var5 == null) {
            return null;
         } else {
            int var6 = var3 ? var1.x : var1.y;
            int var7 = var3 ? var1.w : var1.h;
            UnitValue var8;
            if (var1.pos != null) {
               var8 = var1.pos != null ? var1.pos[var3 ? 0 : 1] : null;
               UnitValue var9 = var1.pos != null ? var1.pos[var3 ? 2 : 3] : null;
               int var10 = var1.getSize(0, var3);
               int var11 = var1.getSize(2, var3);
               var7 = Math.min(Math.max(var1.getSize(1, var3), var10), var11);
               if (var8 != null) {
                  var6 = var8.getPixels(var8.getUnit() == 12 ? (float)var7 : (float)var2, this.container, var1.comp);
                  if (var9 != null) {
                     var7 = Math.min(Math.max((var3 ? var1.x + var1.w : var1.y + var1.h) - var6, var10), var11);
                  }
               }

               if (var9 != null) {
                  if (var8 != null) {
                     var7 = Math.min(Math.max(var9.getPixels((float)var2, this.container, var1.comp) - var6, var10), var11);
                  } else {
                     var6 = var9.getPixels((float)var2, this.container, var1.comp) - var7;
                  }
               }
            }

            if (var5 != null) {
               var8 = var5[var3 ? 1 : 0];
               int var13 = var8 != null ? var8.getPixels((float)var2, this.container, var1.comp) : 0;
               var6 += var13;
               var8 = var5[var3 ? 3 : 2];
               var7 += -var13 + (var8 != null ? var8.getPixels((float)var2, this.container, var1.comp) : 0);
            }

            if (var4 != null) {
               int var12 = var4[var3 ? 1 : 0];
               var6 += var12;
               var7 += -var12 + var4[var3 ? 3 : 2];
            }

            return new int[]{var6, var7};
         }
      }
   }

   private void layoutInOneDim(int var1, UnitValue var2, boolean var3, Float[] var4) {
      boolean var10000;
      label104: {
         label103: {
            if (var3) {
               if (!this.lc.isTopToBottom()) {
                  break label103;
               }
            } else if (!LayoutUtil.isLeftToRight(this.lc, this.container)) {
               break label103;
            }

            var10000 = false;
            break label104;
         }

         var10000 = true;
      }

      boolean var5 = var10000;
      DimConstraint[] var6 = (var3 ? this.rowConstr : this.colConstr).getConstaints();
      Grid.FlowSizeSpec var7 = var3 ? this.rowFlowSpecs : this.colFlowSpecs;
      ArrayList[] var8 = var3 ? this.rowGroupLists : this.colGroupLists;
      int[] var9 = LayoutUtil.calculateSerial(var7.sizes, var7.resConstsInclGaps, var4, 1, var1);
      if (LayoutUtil.isDesignTime(this.container)) {
         TreeSet var10 = var3 ? this.rowIndexes : this.colIndexes;
         int[] var11 = new int[var10.size()];
         int var12 = 0;

         Integer var14;
         for(Iterator var13 = var10.iterator(); var13.hasNext(); var11[var12++] = var14) {
            var14 = (Integer)var13.next();
         }

         putSizesAndIndexes(this.container.getComponent(), var9, var11, var3);
      }

      int var21 = var2 != null ? var2.getPixels((float)(var1 - LayoutUtil.sum(var9)), this.container, (ComponentWrapper)null) : 0;
      if (var5) {
         var21 = var1 - var21;
      }

      for(int var22 = 0; var22 < var8.length; ++var22) {
         ArrayList var23 = var8[var22];
         int var24 = var22 - (var3 ? this.dockOffY : this.dockOffX);
         int var25 = var22 << 1;
         int var15 = var25 + 1;
         var21 += var5 ? -var9[var25] : var9[var25];
         DimConstraint var16 = var24 >= 0 ? var6[var24 >= var6.length ? var6.length - 1 : var24] : DOCK_DIM_CONSTRAINT;
         int var17 = var9[var15];

         Grid.LinkedDimGroup var19;
         int var20;
         for(Iterator var18 = var23.iterator(); var18.hasNext(); var19.layout(var16, var21, var20, var19.span)) {
            var19 = (Grid.LinkedDimGroup)var18.next();
            var20 = var17;
            if (var19.span > 1) {
               var20 = LayoutUtil.sum(var9, var15, Math.min((var19.span << 1) - 1, var9.length - var15 - 1));
            }
         }

         var21 += var5 ? -var17 : var17;
      }

   }

   private static void addToSizeGroup(HashMap<String, int[]> var0, String var1, int[] var2) {
      int[] var3 = (int[])var0.get(var1);
      if (var3 == null) {
         var0.put(var1, new int[]{var2[0], var2[1], var2[2]});
      } else {
         var3[0] = Math.max(var2[0], var3[0]);
         var3[1] = Math.max(var2[1], var3[1]);
         var3[2] = Math.min(var2[2], var3[2]);
      }

   }

   private static HashMap<String, Integer> addToEndGroup(HashMap<String, Integer> var0, String var1, int var2) {
      if (var1 != null) {
         if (var0 == null) {
            var0 = new HashMap(2);
         }

         Integer var3 = (Integer)var0.get(var1);
         if (var3 == null || var2 > var3) {
            var0.put(var1, var2);
         }
      }

      return var0;
   }

   private Grid.FlowSizeSpec calcRowsOrColsSizes(boolean var1) {
      ArrayList[] var2 = var1 ? this.colGroupLists : this.rowGroupLists;
      Float[] var3 = var1 ? this.pushXs : this.pushYs;
      int var4 = var1 ? this.container.getWidth() : this.container.getHeight();
      BoundSize var5 = var1 ? this.lc.getWidth() : this.lc.getHeight();
      if (!var5.isUnset()) {
         var4 = var5.constrain(var4, (float)getParentSize(this.container, var1), this.container);
      }

      DimConstraint[] var6 = (var1 ? this.colConstr : this.rowConstr).getConstaints();
      TreeSet var7 = var1 ? this.colIndexes : this.rowIndexes;
      int[][] var8 = new int[var7.size()][];
      HashMap var9 = new HashMap(2);
      DimConstraint[] var10 = new DimConstraint[var7.size()];
      Iterator var11 = var7.iterator();

      int var12;
      for(var12 = 0; var12 < var8.length; ++var12) {
         int var13 = (Integer)var11.next();
         int[] var14 = new int[3];
         if (var13 >= -30000 && var13 <= 30000) {
            var10[var12] = var6[var13 >= var6.length ? var6.length - 1 : var13];
         } else {
            var10[var12] = DOCK_DIM_CONSTRAINT;
         }

         ArrayList var15 = var2[var12];
         int[] var16 = new int[]{getTotalGroupsSizeParallel(var15, 0, false), getTotalGroupsSizeParallel(var15, 1, false), 2097051};
         correctMinMax(var16);
         BoundSize var17 = var10[var12].getSize();

         for(int var18 = 0; var18 <= 2; ++var18) {
            int var19 = var16[var18];
            UnitValue var20 = var17.getSize(var18);
            if (var20 != null) {
               int var21 = var20.getUnit();
               if (var21 == 14) {
                  var19 = var16[1];
               } else if (var21 == 13) {
                  var19 = var16[0];
               } else if (var21 == 15) {
                  var19 = var16[2];
               } else {
                  var19 = var20.getPixels((float)var4, this.container, (ComponentWrapper)null);
               }
            } else if (var13 >= -30000 && var13 <= 30000 && var19 == 0) {
               var19 = LayoutUtil.isDesignTime(this.container) ? LayoutUtil.getDesignTimeEmptySize() : 0;
            }

            var14[var18] = var19;
         }

         correctMinMax(var14);
         addToSizeGroup(var9, var10[var12].getSizeGroup(), var14);
         var8[var12] = var14;
      }

      if (var9.size() > 0) {
         for(var12 = 0; var12 < var8.length; ++var12) {
            if (var10[var12].getSizeGroup() != null) {
               var8[var12] = (int[])var9.get(var10[var12].getSizeGroup());
            }
         }
      }

      ResizeConstraint[] var22 = getRowResizeConstraints(var10);
      boolean[] var23 = new boolean[var10.length + 1];
      int[][] var24 = this.getRowGaps(var10, var4, var1, var23);
      Grid.FlowSizeSpec var25 = mergeSizesGapsAndResConstrs(var22, var23, var8, var24);
      this.adjustMinPrefForSpanningComps(var10, var3, var25, var2);
      return var25;
   }

   private static int getParentSize(ComponentWrapper var0, boolean var1) {
      ContainerWrapper var2 = var0.getParent();
      return var2 != null ? (var1 ? var0.getWidth() : var0.getHeight()) : 0;
   }

   private int[] getMinPrefMaxSumSize(boolean var1) {
      int[][] var2 = var1 ? this.colFlowSpecs.sizes : this.rowFlowSpecs.sizes;
      int[] var3 = new int[3];
      BoundSize var4 = var1 ? this.lc.getWidth() : this.lc.getHeight();

      for(int var5 = 0; var5 < var2.length; ++var5) {
         if (var2[var5] != null) {
            int[] var6 = var2[var5];

            for(int var7 = 0; var7 <= 2; ++var7) {
               if (var4.getSize(var7) != null) {
                  if (var5 == 0) {
                     var3[var7] = var4.getSize(var7).getPixels((float)getParentSize(this.container, var1), this.container, (ComponentWrapper)null);
                  }
               } else {
                  int var8 = var6[var7];
                  if (var8 != -2147471302) {
                     if (var7 == 1) {
                        int var9 = var6[2];
                        if (var9 != -2147471302 && var9 < var8) {
                           var8 = var9;
                        }

                        var9 = var6[0];
                        if (var9 > var8) {
                           var8 = var9;
                        }
                     }

                     var3[var7] += var8;
                  }

                  if (var6[2] == -2147471302 || var3[2] > 2097051) {
                     var3[2] = 2097051;
                  }
               }
            }
         }
      }

      correctMinMax(var3);
      return var3;
   }

   private static ResizeConstraint[] getRowResizeConstraints(DimConstraint[] var0) {
      ResizeConstraint[] var1 = new ResizeConstraint[var0.length];

      for(int var2 = 0; var2 < var1.length; ++var2) {
         var1[var2] = var0[var2].resize;
      }

      return var1;
   }

   private static ResizeConstraint[] getComponentResizeConstraints(ArrayList<Grid.CompWrap> var0, boolean var1) {
      ResizeConstraint[] var2 = new ResizeConstraint[var0.size()];

      for(int var3 = 0; var3 < var2.length; ++var3) {
         CC var4 = ((Grid.CompWrap)var0.get(var3)).cc;
         var2[var3] = var4.getDimConstraint(var1).resize;
         int var5 = var4.getDockSide();
         if (var1) {
            if (var5 != 0 && var5 != 2) {
               continue;
            }
         } else if (var5 != 1 && var5 != 3) {
            continue;
         }

         ResizeConstraint var6 = var2[var3];
         var2[var3] = new ResizeConstraint(var6.shrinkPrio, var6.shrink, var6.growPrio, ResizeConstraint.WEIGHT_100);
      }

      return var2;
   }

   private static boolean[] getComponentGapPush(ArrayList<Grid.CompWrap> var0, boolean var1) {
      boolean[] var2 = new boolean[var0.size() + 1];

      for(int var3 = 0; var3 < var2.length; ++var3) {
         boolean var4 = var3 > 0 && ((Grid.CompWrap)var0.get(var3 - 1)).isPushGap(var1, false);
         if (!var4 && var3 < var2.length - 1) {
            var4 = ((Grid.CompWrap)var0.get(var3)).isPushGap(var1, true);
         }

         var2[var3] = var4;
      }

      return var2;
   }

   private int[][] getRowGaps(DimConstraint[] var1, int var2, boolean var3, boolean[] var4) {
      BoundSize var5 = var3 ? this.lc.getGridGapX() : this.lc.getGridGapY();
      if (var5 == null) {
         var5 = var3 ? PlatformDefaults.getGridGapX() : PlatformDefaults.getGridGapY();
      }

      int[] var6 = var5.getPixelSizes((float)var2, this.container, (ComponentWrapper)null);
      boolean var7 = !this.hasDocks();
      UnitValue var8 = LayoutUtil.getInsets(this.lc, var3 ? 1 : 0, var7);
      UnitValue var9 = LayoutUtil.getInsets(this.lc, var3 ? 3 : 2, var7);
      int[][] var10 = new int[var1.length + 1][];
      int var11 = 0;

      for(int var12 = 0; var11 < var10.length; ++var11) {
         DimConstraint var13 = var11 > 0 ? var1[var11 - 1] : null;
         DimConstraint var14 = var11 < var1.length ? var1[var11] : null;
         boolean var15 = var13 == DOCK_DIM_CONSTRAINT || var13 == null;
         boolean var16 = var14 == DOCK_DIM_CONSTRAINT || var14 == null;
         if (!var15 || !var16) {
            BoundSize var17 = this.wrapGapMap != null && var3 != this.lc.isFlowX() ? (BoundSize)this.wrapGapMap.get(var12++) : null;
            if (var17 == null) {
               int[] var18 = var13 != null ? var13.getRowGaps(this.container, (BoundSize)null, var2, false) : null;
               int[] var19 = var14 != null ? var14.getRowGaps(this.container, (BoundSize)null, var2, true) : null;
               int var20;
               if (var15 && var19 == null && var8 != null) {
                  var20 = var8.getPixels((float)var2, this.container, (ComponentWrapper)null);
                  var10[var11] = new int[]{var20, var20, var20};
               } else if (var16 && var18 == null && var8 != null) {
                  var20 = var9.getPixels((float)var2, this.container, (ComponentWrapper)null);
                  var10[var11] = new int[]{var20, var20, var20};
               } else {
                  var10[var11] = var19 != var18 ? mergeSizes(var19, var18) : new int[]{var6[0], var6[1], var6[2]};
               }

               if (var13 != null && var13.isGapAfterPush() || var14 != null && var14.isGapBeforePush()) {
                  var4[var11] = true;
               }
            } else {
               if (var17.isUnset()) {
                  var10[var11] = new int[]{var6[0], var6[1], var6[2]};
               } else {
                  var10[var11] = var17.getPixelSizes((float)var2, this.container, (ComponentWrapper)null);
               }

               var4[var11] = var17.getGapPush();
            }
         }
      }

      return var10;
   }

   private static int[][] getGaps(ArrayList<Grid.CompWrap> var0, boolean var1) {
      int var2 = var0.size();
      int[][] var3 = new int[var2 + 1][];
      var3[0] = ((Grid.CompWrap)var0.get(0)).getGaps(var1, true);

      for(int var4 = 0; var4 < var2; ++var4) {
         int[] var5 = ((Grid.CompWrap)var0.get(var4)).getGaps(var1, false);
         int[] var6 = var4 < var2 - 1 ? ((Grid.CompWrap)var0.get(var4 + 1)).getGaps(var1, true) : null;
         var3[var4 + 1] = mergeSizes(var5, var6);
      }

      return var3;
   }

   private boolean hasDocks() {
      return this.dockOffX > 0 || this.dockOffY > 0 || (Integer)this.rowIndexes.last() > 30000 || (Integer)this.colIndexes.last() > 30000;
   }

   private void adjustMinPrefForSpanningComps(DimConstraint[] var1, Float[] var2, Grid.FlowSizeSpec var3, ArrayList<Grid.LinkedDimGroup>[] var4) {
      label68:
      for(int var5 = var4.length - 1; var5 >= 0; --var5) {
         ArrayList var6 = var4[var5];
         Iterator var7 = var6.iterator();

         while(true) {
            Grid.LinkedDimGroup var8;
            do {
               if (!var7.hasNext()) {
                  continue label68;
               }

               var8 = (Grid.LinkedDimGroup)var7.next();
            } while(var8.span == 1);

            int[] var9 = var8.getMinPrefMax();

            for(int var10 = 0; var10 <= 1; ++var10) {
               int var11 = var9[var10];
               if (var11 != -2147471302) {
                  int var12 = 0;
                  int var13 = (var5 << 1) + 1;
                  int var14 = Math.min(var8.span << 1, var3.sizes.length - var13) - 1;

                  int var15;
                  int var16;
                  for(var15 = var13; var15 < var13 + var14; ++var15) {
                     var16 = var3.sizes[var15][var10];
                     if (var16 != -2147471302) {
                        var12 += var16;
                     }
                  }

                  if (var12 < var11 && var14 > 0) {
                     var15 = 0;

                     for(var16 = 0; var15 < 4 && var16 < var11; ++var15) {
                        var16 = var3.expandSizes(var1, var2, var11, var13, var14, var10, var15);
                     }
                  }
               }
            }
         }
      }

   }

   private ArrayList<Grid.LinkedDimGroup>[] divideIntoLinkedGroups(boolean var1) {
      boolean var10000;
      label186: {
         label185: {
            if (var1) {
               if (!this.lc.isTopToBottom()) {
                  break label185;
               }
            } else if (!LayoutUtil.isLeftToRight(this.lc, this.container)) {
               break label185;
            }

            var10000 = false;
            break label186;
         }

         var10000 = true;
      }

      boolean var2 = var10000;
      TreeSet var3 = var1 ? this.rowIndexes : this.colIndexes;
      TreeSet var4 = var1 ? this.colIndexes : this.rowIndexes;
      DimConstraint[] var5 = (var1 ? this.rowConstr : this.colConstr).getConstaints();
      ArrayList[] var6 = new ArrayList[var3.size()];
      int var7 = 0;
      Iterator var8 = var3.iterator();

      label178:
      while(var8.hasNext()) {
         int var9 = (Integer)var8.next();
         DimConstraint var10;
         if (var9 >= -30000 && var9 <= 30000) {
            var10 = var5[var9 >= var5.length ? var5.length - 1 : var9];
         } else {
            var10 = DOCK_DIM_CONSTRAINT;
         }

         ArrayList var11 = new ArrayList(2);
         var6[var7++] = var11;
         Iterator var12 = var4.iterator();

         while(true) {
            while(true) {
               Integer var13;
               Grid.Cell var14;
               do {
                  do {
                     if (!var12.hasNext()) {
                        continue label178;
                     }

                     var13 = (Integer)var12.next();
                     var14 = var1 ? this.getCell(var9, var13) : this.getCell(var13, var9);
                  } while(var14 == null);
               } while(var14.compWraps.size() == 0);

               int var15 = var1 ? var14.spany : var14.spanx;
               if (var15 > 1) {
                  var15 = convertSpanToSparseGrid(var9, var15, var3);
               }

               boolean var16 = var14.flowx == var1;
               int var17;
               if (!var16 && var14.compWraps.size() > 1 || var15 > 1) {
                  var17 = var16 ? 1 : 0;
                  Grid.LinkedDimGroup var26 = new Grid.LinkedDimGroup("p," + var13, var15, var17, !var1, var2);
                  var26.setCompWraps(var14.compWraps);
                  var11.add(var26);
               } else {
                  for(var17 = 0; var17 < var14.compWraps.size(); ++var17) {
                     Grid.CompWrap var18 = (Grid.CompWrap)var14.compWraps.get(var17);
                     boolean var19 = var1 && this.lc.isTopToBottom() && var10.getAlignOrDefault(!var1) == UnitValue.BASELINE_IDENTITY;
                     boolean var20 = var1 && var18.isBaselineAlign(var19);
                     String var21 = var20 ? "baseline" : null;
                     boolean var22 = false;
                     int var23 = 0;

                     for(int var24 = var11.size() - 1; var23 <= var24; ++var23) {
                        Grid.LinkedDimGroup var25 = (Grid.LinkedDimGroup)var11.get(var23);
                        if (var25.linkCtx == var21 || var21 != null && var21.equals(var25.linkCtx)) {
                           var25.addCompWrap(var18);
                           var22 = true;
                           break;
                        }
                     }

                     if (!var22) {
                        var23 = var20 ? 2 : 1;
                        Grid.LinkedDimGroup var27 = new Grid.LinkedDimGroup(var21, 1, var23, !var1, var2);
                        var27.addCompWrap(var18);
                        var11.add(var27);
                     }
                  }
               }
            }
         }
      }

      return var6;
   }

   private static int convertSpanToSparseGrid(int var0, int var1, TreeSet<Integer> var2) {
      int var3 = var0 + var1;
      int var4 = 1;
      Iterator var5 = var2.iterator();

      while(var5.hasNext()) {
         Integer var6 = (Integer)var5.next();
         if (var6 > var0) {
            if (var6 >= var3) {
               break;
            }

            ++var4;
         }
      }

      return var4;
   }

   private boolean isCellFree(int var1, int var2, ArrayList<int[]> var3) {
      if (this.getCell(var1, var2) != null) {
         return false;
      } else {
         Iterator var4 = var3.iterator();

         int[] var5;
         do {
            if (!var4.hasNext()) {
               return true;
            }

            var5 = (int[])var4.next();
         } while(var5[0] > var2 || var5[1] > var1 || var5[0] + var5[2] <= var2 || var5[1] + var5[3] <= var1);

         return false;
      }
   }

   private Grid.Cell getCell(int var1, int var2) {
      return (Grid.Cell)this.grid.get((var1 << 16) + var2);
   }

   private void setCell(int var1, int var2, Grid.Cell var3) {
      if (var2 >= 0 && var1 >= 0) {
         if (var2 <= 30000 && var1 <= 30000) {
            this.rowIndexes.add(var1);
            this.colIndexes.add(var2);
            this.grid.put((var1 << 16) + var2, var3);
         } else {
            throw new IllegalArgumentException("Cell position out of bounds. Out of cells. row: " + var1 + ", col: " + var2);
         }
      } else {
         throw new IllegalArgumentException("Cell position cannot be negative. row: " + var1 + ", col: " + var2);
      }
   }

   private void addDockingCell(int[] var1, int var2, Grid.CompWrap var3) {
      int var6 = 1;
      int var7 = 1;
      int var10000;
      int var10003;
      int var4;
      int var5;
      switch(var2) {
      case 0:
      case 2:
         if (var2 == 0) {
            var10003 = var1[0];
            var10000 = var1[0];
            var1[0] = var10003 + 1;
         } else {
            var10003 = var1[2];
            var10000 = var1[2];
            var1[2] = var10003 - 1;
         }

         var4 = var10000;
         var5 = var1[1];
         var6 = var1[3] - var1[1] + 1;
         this.colIndexes.add(var1[3]);
         break;
      case 1:
      case 3:
         if (var2 == 1) {
            var10003 = var1[1];
            var10000 = var1[1];
            var1[1] = var10003 + 1;
         } else {
            var10003 = var1[3];
            var10000 = var1[3];
            var1[3] = var10003 - 1;
         }

         var5 = var10000;
         var4 = var1[0];
         var7 = var1[2] - var1[0] + 1;
         this.rowIndexes.add(var1[2]);
         break;
      default:
         throw new IllegalArgumentException("Internal error 123.");
      }

      this.rowIndexes.add(var4);
      this.colIndexes.add(var5);
      this.grid.put((var4 << 16) + var5, new Grid.Cell(var3, var6, var7, var6 > 1));
   }

   private static void layoutBaseline(ContainerWrapper var0, ArrayList<Grid.CompWrap> var1, DimConstraint var2, int var3, int var4, int var5, int var6) {
      int[] var7 = getBaselineAboveBelow(var1, var5, true);
      int var8 = var7[0] + var7[1];
      CC var9 = ((Grid.CompWrap)var1.get(0)).cc;
      UnitValue var10 = var9.getVertical().getAlign();
      if (var6 == 1 && var10 == null) {
         var10 = var2.getAlignOrDefault(false);
      }

      if (var10 == UnitValue.BASELINE_IDENTITY) {
         var10 = UnitValue.CENTER;
      }

      int var11 = var3 + var7[0] + (var10 != null ? Math.max(0, var10.getPixels((float)(var4 - var8), var0, (ComponentWrapper)null)) : 0);
      int var12 = 0;

      for(int var13 = var1.size(); var12 < var13; ++var12) {
         Grid.CompWrap var14 = (Grid.CompWrap)var1.get(var12);
         var14.y = var11;
         if (var14.y + var14.h > var3 + var4) {
            var14.h = var3 + var4 - var14.y;
         }
      }

   }

   private static void layoutSerial(ContainerWrapper var0, ArrayList<Grid.CompWrap> var1, DimConstraint var2, int var3, int var4, boolean var5, int var6, boolean var7) {
      Grid.FlowSizeSpec var8 = mergeSizesGapsAndResConstrs(getComponentResizeConstraints(var1, var5), getComponentGapPush(var1, var5), getComponentSizes(var1, var5), getGaps(var1, var5));
      Float[] var9 = var2.isFill() ? GROW_100 : null;
      int[] var10 = LayoutUtil.calculateSerial(var8.sizes, var8.resConstsInclGaps, var9, 1, var4);
      setCompWrapBounds(var0, var10, var1, var2.getAlignOrDefault(var5), var3, var4, var5, var7);
   }

   private static void setCompWrapBounds(ContainerWrapper var0, int[] var1, ArrayList<Grid.CompWrap> var2, UnitValue var3, int var4, int var5, boolean var6, boolean var7) {
      int var8 = LayoutUtil.sum(var1);
      CC var9 = ((Grid.CompWrap)var2.get(0)).cc;
      UnitValue var10 = correctAlign(var9, var3, var6, var7);
      int var11 = var4;
      int var12 = var5 - var8;
      int var13;
      if (var12 > 0 && var10 != null) {
         var13 = Math.min(var12, Math.max(0, var10.getPixels((float)var12, var0, (ComponentWrapper)null)));
         var11 = var4 + (var7 ? -var13 : var13);
      }

      var13 = 0;
      int var14 = 0;

      for(int var15 = var2.size(); var13 < var15; ++var13) {
         Grid.CompWrap var16 = (Grid.CompWrap)var2.get(var13);
         if (var7) {
            var11 -= var1[var14++];
            var16.setDimBounds(var11 - var1[var14], var1[var14], var6);
            var11 -= var1[var14++];
         } else {
            var11 += var1[var14++];
            var16.setDimBounds(var11, var1[var14], var6);
            var11 += var1[var14++];
         }
      }

   }

   private static void layoutParallel(ContainerWrapper var0, ArrayList<Grid.CompWrap> var1, DimConstraint var2, int var3, int var4, boolean var5, boolean var6) {
      int[][] var7 = new int[var1.size()][];

      for(int var8 = 0; var8 < var7.length; ++var8) {
         Grid.CompWrap var9 = (Grid.CompWrap)var1.get(var8);
         DimConstraint var10 = var9.cc.getDimConstraint(var5);
         ResizeConstraint[] var11 = new ResizeConstraint[]{var9.isPushGap(var5, true) ? GAP_RC_CONST_PUSH : GAP_RC_CONST, var10.resize, var9.isPushGap(var5, false) ? GAP_RC_CONST_PUSH : GAP_RC_CONST};
         int[][] var12 = new int[][]{var9.getGaps(var5, true), var5 ? var9.horSizes : var9.verSizes, var9.getGaps(var5, false)};
         Float[] var13 = var2.isFill() ? GROW_100 : null;
         var7[var8] = LayoutUtil.calculateSerial(var12, var11, var13, 1, var4);
      }

      UnitValue var14 = var2.getAlignOrDefault(var5);
      setCompWrapBounds(var0, var7, var1, var14, var3, var4, var5, var6);
   }

   private static void setCompWrapBounds(ContainerWrapper var0, int[][] var1, ArrayList<Grid.CompWrap> var2, UnitValue var3, int var4, int var5, boolean var6, boolean var7) {
      for(int var8 = 0; var8 < var1.length; ++var8) {
         Grid.CompWrap var9 = (Grid.CompWrap)var2.get(var8);
         UnitValue var10 = correctAlign(var9.cc, var3, var6, var7);
         int[] var11 = var1[var8];
         int var12 = var11[0];
         int var13 = var11[1];
         int var14 = var11[2];
         int var15 = var7 ? var4 - var12 : var4 + var12;
         int var16 = var5 - var13 - var12 - var14;
         if (var16 > 0 && var10 != null) {
            int var17 = Math.min(var16, Math.max(0, var10.getPixels((float)var16, var0, (ComponentWrapper)null)));
            var15 += var7 ? -var17 : var17;
         }

         var9.setDimBounds(var7 ? var15 - var13 : var15, var13, var6);
      }

   }

   private static UnitValue correctAlign(CC var0, UnitValue var1, boolean var2, boolean var3) {
      UnitValue var4 = (var2 ? var0.getHorizontal() : var0.getVertical()).getAlign();
      if (var4 == null) {
         var4 = var1;
      }

      if (var4 == UnitValue.BASELINE_IDENTITY) {
         var4 = UnitValue.CENTER;
      }

      if (var3) {
         if (var4 == UnitValue.LEFT) {
            var4 = UnitValue.RIGHT;
         } else if (var4 == UnitValue.RIGHT) {
            var4 = UnitValue.LEFT;
         }
      }

      return var4;
   }

   private static int[] getBaselineAboveBelow(ArrayList<Grid.CompWrap> var0, int var1, boolean var2) {
      int var3 = -32768;
      int var4 = -32768;
      int var5 = 0;

      for(int var6 = var0.size(); var5 < var6; ++var5) {
         Grid.CompWrap var7 = (Grid.CompWrap)var0.get(var5);
         int var8 = var7.getSize(var1, false);
         if (var8 >= 2097051) {
            return new int[]{1048525, 1048525};
         }

         int var9 = var7.getBaseline(var1);
         int var10 = var9 + var7.getGapBefore(var1, false);
         var3 = Math.max(var10, var3);
         var4 = Math.max(var8 - var9 + var7.getGapAfter(var1, false), var4);
         if (var2) {
            var7.setDimBounds(-var9, var8, false);
         }
      }

      return new int[]{var3, var4};
   }

   private static int getTotalSizeParallel(ArrayList<Grid.CompWrap> var0, int var1, boolean var2) {
      int var3 = var1 == 2 ? 2097051 : 0;
      int var4 = 0;

      for(int var5 = var0.size(); var4 < var5; ++var4) {
         Grid.CompWrap var6 = (Grid.CompWrap)var0.get(var4);
         int var7 = var6.getSizeInclGaps(var1, var2);
         if (var7 >= 2097051) {
            return 2097051;
         }

         if (var1 == 2) {
            if (var7 >= var3) {
               continue;
            }
         } else if (var7 <= var3) {
            continue;
         }

         var3 = var7;
      }

      return constrainSize(var3);
   }

   private static int getTotalSizeSerial(ArrayList<Grid.CompWrap> var0, int var1, boolean var2) {
      int var3 = 0;
      int var4 = 0;
      int var5 = var0.size();

      for(int var6 = 0; var4 < var5; ++var4) {
         Grid.CompWrap var7 = (Grid.CompWrap)var0.get(var4);
         int var8 = var7.getGapBefore(var1, var2);
         if (var8 > var6) {
            var3 += var8 - var6;
         }

         var3 += var7.getSize(var1, var2);
         var3 += var6 = var7.getGapAfter(var1, var2);
         if (var3 >= 2097051) {
            return 2097051;
         }
      }

      return constrainSize(var3);
   }

   private static int getTotalGroupsSizeParallel(ArrayList<Grid.LinkedDimGroup> var0, int var1, boolean var2) {
      int var3 = var1 == 2 ? 2097051 : 0;
      int var4 = 0;

      for(int var5 = var0.size(); var4 < var5; ++var4) {
         Grid.LinkedDimGroup var6 = (Grid.LinkedDimGroup)var0.get(var4);
         if (var2 || var6.span == 1) {
            int var7 = var6.getMinPrefMax()[var1];
            if (var7 >= 2097051) {
               return 2097051;
            }

            if (var1 == 2) {
               if (var7 >= var3) {
                  continue;
               }
            } else if (var7 <= var3) {
               continue;
            }

            var3 = var7;
         }
      }

      return constrainSize(var3);
   }

   private static int[][] getComponentSizes(ArrayList<Grid.CompWrap> var0, boolean var1) {
      int[][] var2 = new int[var0.size()][];

      for(int var3 = 0; var3 < var2.length; ++var3) {
         Grid.CompWrap var4 = (Grid.CompWrap)var0.get(var3);
         var2[var3] = var1 ? var4.horSizes : var4.verSizes;
      }

      return var2;
   }

   private static Grid.FlowSizeSpec mergeSizesGapsAndResConstrs(ResizeConstraint[] var0, boolean[] var1, int[][] var2, int[][] var3) {
      int[][] var4 = new int[(var2.length << 1) + 1][];
      ResizeConstraint[] var5 = new ResizeConstraint[var4.length];
      var4[0] = var3[0];
      int var6 = 0;

      for(int var7 = 1; var6 < var2.length; var7 += 2) {
         var5[var7] = var0[var6];
         var4[var7] = var2[var6];
         var4[var7 + 1] = var3[var6 + 1];
         if (var4[var7 - 1] != null) {
            var5[var7 - 1] = var1[var6 < var1.length ? var6 : var1.length - 1] ? GAP_RC_CONST_PUSH : GAP_RC_CONST;
         }

         if (var6 == var2.length - 1 && var4[var7 + 1] != null) {
            var5[var7 + 1] = var1[var6 + 1 < var1.length ? var6 + 1 : var1.length - 1] ? GAP_RC_CONST_PUSH : GAP_RC_CONST;
         }

         ++var6;
      }

      for(var6 = 0; var6 < var4.length; ++var6) {
         if (var4[var6] == null) {
            var4[var6] = new int[3];
         }
      }

      return new Grid.FlowSizeSpec(var4, var5);
   }

   private static int[] mergeSizes(int[] var0, int[] var1) {
      if (var0 == null) {
         return var1;
      } else if (var1 == null) {
         return var0;
      } else {
         int[] var2 = new int[var0.length];

         for(int var3 = 0; var3 < var2.length; ++var3) {
            var2[var3] = mergeSizes(var0[var3], var1[var3], true);
         }

         return var2;
      }
   }

   private static int mergeSizes(int var0, int var1, boolean var2) {
      if (var0 != -2147471302 && var0 != var1) {
         if (var1 == -2147471302) {
            return var0;
         } else {
            return var2 != var0 > var1 ? var1 : var0;
         }
      } else {
         return var1;
      }
   }

   private static int constrainSize(int var0) {
      return var0 > 0 ? (var0 < 2097051 ? var0 : 2097051) : 0;
   }

   private static void correctMinMax(int[] var0) {
      if (var0[0] > var0[2]) {
         var0[0] = var0[2];
      }

      if (var0[1] < var0[0]) {
         var0[1] = var0[0];
      }

      if (var0[1] > var0[2]) {
         var0[1] = var0[2];
      }

   }

   private static Float[] extractSubArray(DimConstraint[] var0, Float[] var1, int var2, int var3) {
      Float[] var4;
      int var5;
      if (var1 != null && var1.length >= var2 + var3) {
         var4 = new Float[var3];

         for(var5 = 0; var5 < var3; ++var5) {
            var4[var5] = var1[var2 + var5];
         }

         return var4;
      } else {
         var4 = new Float[var3];

         for(var5 = var2 + var3 - 1; var5 >= 0; var5 -= 2) {
            int var6 = var5 >> 1;
            if (var0[var6] != DOCK_DIM_CONSTRAINT) {
               var4[var5 - var2] = ResizeConstraint.WEIGHT_100;
               return var4;
            }
         }

         return var4;
      }
   }

   private static synchronized void putSizesAndIndexes(Object var0, int[] var1, int[] var2, boolean var3) {
      if (PARENT_ROWCOL_SIZES_MAP == null) {
         PARENT_ROWCOL_SIZES_MAP = new WeakHashMap[]{new WeakHashMap(4), new WeakHashMap(4)};
      }

      PARENT_ROWCOL_SIZES_MAP[var3 ? 0 : 1].put(var0, new int[][]{var2, var1});
   }

   static synchronized int[][] getSizesAndIndexes(Object var0, boolean var1) {
      return PARENT_ROWCOL_SIZES_MAP == null ? (int[][])null : (int[][])((int[][])PARENT_ROWCOL_SIZES_MAP[var1 ? 0 : 1].get(var0));
   }

   private static synchronized void saveGrid(ComponentWrapper var0, LinkedHashMap<Integer, Grid.Cell> var1) {
      if (PARENT_GRIDPOS_MAP == null) {
         PARENT_GRIDPOS_MAP = new WeakHashMap();
      }

      ArrayList var2 = new ArrayList(var1.size());
      Iterator var3 = var1.entrySet().iterator();

      while(true) {
         Grid.Cell var5;
         Integer var6;
         do {
            if (!var3.hasNext()) {
               PARENT_GRIDPOS_MAP.put(var0.getComponent(), var2);
               return;
            }

            Entry var4 = (Entry)var3.next();
            var5 = (Grid.Cell)var4.getValue();
            var6 = (Integer)var4.getKey();
         } while(var6 == null);

         int var7 = var6 & '\uffff';
         int var8 = var6 >> 16;
         Iterator var9 = var5.compWraps.iterator();

         while(var9.hasNext()) {
            Grid.CompWrap var10 = (Grid.CompWrap)var9.next();
            var2.add(new Grid.WeakCell(var10.comp.getComponent(), var7, var8, var5.spanx, var5.spany));
         }
      }
   }

   static synchronized HashMap<Object, int[]> getGridPositions(Object var0) {
      ArrayList var1 = PARENT_GRIDPOS_MAP != null ? (ArrayList)PARENT_GRIDPOS_MAP.get(var0) : null;
      if (var1 == null) {
         return null;
      } else {
         HashMap var2 = new HashMap();
         Iterator var3 = var1.iterator();

         while(var3.hasNext()) {
            Grid.WeakCell var4 = (Grid.WeakCell)var3.next();
            Object var5 = var4.componentRef.get();
            if (var5 != null) {
               var2.put(var5, new int[]{var4.x, var4.y, var4.spanX, var4.spanY});
            }
         }

         return var2;
      }
   }

   static {
      GROW_100 = new Float[]{ResizeConstraint.WEIGHT_100};
      DOCK_DIM_CONSTRAINT = new DimConstraint();
      DOCK_DIM_CONSTRAINT.setGrowPriority(0);
      GAP_RC_CONST = new ResizeConstraint(200, ResizeConstraint.WEIGHT_100, 50, (Float)null);
      GAP_RC_CONST_PUSH = new ResizeConstraint(200, ResizeConstraint.WEIGHT_100, 50, ResizeConstraint.WEIGHT_100);
      DEF_CC = new CC();
      PARENT_ROWCOL_SIZES_MAP = null;
      PARENT_GRIDPOS_MAP = null;
   }

   private static class WeakCell {
      private final WeakReference<Object> componentRef;
      private final int x;
      private final int y;
      private final int spanX;
      private final int spanY;

      private WeakCell(Object var1, int var2, int var3, int var4, int var5) {
         this.componentRef = new WeakReference(var1);
         this.x = var2;
         this.y = var3;
         this.spanX = var4;
         this.spanY = var5;
      }

      // $FF: synthetic method
      WeakCell(Object var1, int var2, int var3, int var4, int var5, Object var6) {
         this(var1, var2, var3, var4, var5);
      }
   }

   private static final class FlowSizeSpec {
      private final int[][] sizes;
      private final ResizeConstraint[] resConstsInclGaps;

      private FlowSizeSpec(int[][] var1, ResizeConstraint[] var2) {
         this.sizes = var1;
         this.resConstsInclGaps = var2;
      }

      private int expandSizes(DimConstraint[] var1, Float[] var2, int var3, int var4, int var5, int var6, int var7) {
         ResizeConstraint[] var8 = new ResizeConstraint[var5];
         int[][] var9 = new int[var5][];

         int[] var11;
         int var12;
         for(int var10 = 0; var10 < var5; ++var10) {
            var11 = this.sizes[var10 + var4];
            var9[var10] = new int[]{var11[var6], var11[1], var11[2]};
            if (var7 <= 1 && var10 % 2 == 0) {
               var12 = var10 + var4 - 1 >> 1;
               DimConstraint var13 = (DimConstraint)LayoutUtil.getIndexSafe(var1, var12);
               BoundSize var14 = var13.getSize();
               if (var6 == 0 && var14.getMin() != null && var14.getMin().getUnit() != 13 || var6 == 1 && var14.getPreferred() != null && var14.getPreferred().getUnit() != 14) {
                  continue;
               }
            }

            var8[var10] = (ResizeConstraint)LayoutUtil.getIndexSafe(this.resConstsInclGaps, var10 + var4);
         }

         Float[] var15 = var7 != 1 && var7 != 3 ? null : Grid.extractSubArray(var1, var2, var4, var5);
         var11 = LayoutUtil.calculateSerial(var9, var8, var15, 1, var3);
         var12 = 0;

         for(int var16 = 0; var16 < var5; ++var16) {
            int var17 = var11[var16];
            this.sizes[var16 + var4][var6] = var17;
            var12 += var17;
         }

         return var12;
      }

      // $FF: synthetic method
      FlowSizeSpec(int[][] var1, ResizeConstraint[] var2, Object var3) {
         this(var1, var2);
      }
   }

   private static final class CompWrap {
      private final ComponentWrapper comp;
      private final CC cc;
      private final UnitValue[] pos;
      private int[][] gaps;
      private final int[] horSizes;
      private final int[] verSizes;
      private int x;
      private int y;
      private int w;
      private int h;
      private int forcedPushGaps;

      private CompWrap(ComponentWrapper var1, CC var2, int var3, UnitValue[] var4, BoundSize[] var5) {
         this.horSizes = new int[3];
         this.verSizes = new int[3];
         this.x = -2147471302;
         this.y = -2147471302;
         this.w = -2147471302;
         this.h = -2147471302;
         this.forcedPushGaps = 0;
         this.comp = var1;
         this.cc = var2;
         this.pos = var4;
         if (var3 <= 0) {
            BoundSize var6 = var5 != null && var5[0] != null ? var5[0] : var2.getHorizontal().getSize();
            BoundSize var7 = var5 != null && var5[1] != null ? var5[1] : var2.getVertical().getSize();
            int var8 = -1;
            int var9 = -1;
            if (this.comp.getWidth() > 0 && this.comp.getHeight() > 0) {
               var9 = this.comp.getHeight();
               var8 = this.comp.getWidth();
            }

            for(int var10 = 0; var10 <= 2; ++var10) {
               this.horSizes[var10] = this.getSize(var6, var10, true, var9);
               this.verSizes[var10] = this.getSize(var7, var10, false, var8 > 0 ? var8 : this.horSizes[var10]);
            }

            Grid.correctMinMax(this.horSizes);
            Grid.correctMinMax(this.verSizes);
         }

         if (var3 > 1) {
            this.gaps = new int[4][];

            for(int var11 = 0; var11 < this.gaps.length; ++var11) {
               this.gaps[var11] = new int[3];
            }
         }

      }

      private int getSize(BoundSize var1, int var2, boolean var3, int var4) {
         if (var1 != null && var1.getSize(var2) != null) {
            ContainerWrapper var5 = this.comp.getParent();
            return var1.getSize(var2).getPixels(var3 ? (float)var5.getWidth() : (float)var5.getHeight(), var5, this.comp);
         } else {
            switch(var2) {
            case 0:
               return var3 ? this.comp.getMinimumWidth(var4) : this.comp.getMinimumHeight(var4);
            case 1:
               return var3 ? this.comp.getPreferredWidth(var4) : this.comp.getPreferredHeight(var4);
            default:
               return var3 ? this.comp.getMaximumWidth(var4) : this.comp.getMaximumHeight(var4);
            }
         }
      }

      private void calcGaps(ComponentWrapper var1, CC var2, ComponentWrapper var3, CC var4, String var5, boolean var6, boolean var7) {
         ContainerWrapper var8 = this.comp.getParent();
         int var9 = var8.getWidth();
         int var10 = var8.getHeight();
         BoundSize var11 = var1 != null ? (var6 ? var2.getHorizontal() : var2.getVertical()).getGapAfter() : null;
         BoundSize var12 = var3 != null ? (var6 ? var4.getHorizontal() : var4.getVertical()).getGapBefore() : null;
         this.mergeGapSizes(this.cc.getVertical().getComponentGaps(var8, this.comp, var11, var6 ? null : var1, var5, var10, 0, var7), false, true);
         this.mergeGapSizes(this.cc.getHorizontal().getComponentGaps(var8, this.comp, var11, var6 ? var1 : null, var5, var9, 1, var7), true, true);
         this.mergeGapSizes(this.cc.getVertical().getComponentGaps(var8, this.comp, var12, var6 ? null : var3, var5, var10, 2, var7), false, false);
         this.mergeGapSizes(this.cc.getHorizontal().getComponentGaps(var8, this.comp, var12, var6 ? var3 : null, var5, var9, 3, var7), true, false);
      }

      private void setDimBounds(int var1, int var2, boolean var3) {
         if (var3) {
            this.x = var1;
            this.w = var2;
         } else {
            this.y = var1;
            this.h = var2;
         }

      }

      private boolean isPushGap(boolean var1, boolean var2) {
         if (var1 && ((var2 ? 1 : 2) & this.forcedPushGaps) != 0) {
            return true;
         } else {
            DimConstraint var3 = this.cc.getDimConstraint(var1);
            BoundSize var4 = var2 ? var3.getGapBefore() : var3.getGapAfter();
            return var4 != null && var4.getGapPush();
         }
      }

      private boolean transferBounds(boolean var1) {
         this.comp.setBounds(this.x, this.y, this.w, this.h);
         if (var1 && this.w != this.horSizes[1]) {
            BoundSize var2 = this.cc.getVertical().getSize();
            if (var2.getPreferred() == null && this.comp.getPreferredHeight(-1) != this.verSizes[1]) {
               return true;
            }
         }

         return false;
      }

      private void setSizes(int[] var1, boolean var2) {
         if (var1 != null) {
            int[] var3 = var2 ? this.horSizes : this.verSizes;
            var3[0] = var1[0];
            var3[1] = var1[1];
            var3[2] = var1[2];
         }
      }

      private void setGaps(int[] var1, int var2) {
         if (this.gaps == null) {
            this.gaps = new int[][]{null, null, null, null};
         }

         this.gaps[var2] = var1;
      }

      private void mergeGapSizes(int[] var1, boolean var2, boolean var3) {
         if (this.gaps == null) {
            this.gaps = new int[][]{null, null, null, null};
         }

         if (var1 != null) {
            int var4 = this.getGapIx(var2, var3);
            int[] var5 = this.gaps[var4];
            if (var5 == null) {
               var5 = new int[]{0, 0, 2097051};
               this.gaps[var4] = var5;
            }

            var5[0] = Math.max(var1[0], var5[0]);
            var5[1] = Math.max(var1[1], var5[1]);
            var5[2] = Math.min(var1[2], var5[2]);
         }
      }

      private int getGapIx(boolean var1, boolean var2) {
         return var1 ? (var2 ? 1 : 3) : (var2 ? 0 : 2);
      }

      private int getSizeInclGaps(int var1, boolean var2) {
         return this.filter(var1, this.getGapBefore(var1, var2) + this.getSize(var1, var2) + this.getGapAfter(var1, var2));
      }

      private int getSize(int var1, boolean var2) {
         return this.filter(var1, var2 ? this.horSizes[var1] : this.verSizes[var1]);
      }

      private int getGapBefore(int var1, boolean var2) {
         int[] var3 = this.getGaps(var2, true);
         return var3 != null ? this.filter(var1, var3[var1]) : 0;
      }

      private int getGapAfter(int var1, boolean var2) {
         int[] var3 = this.getGaps(var2, false);
         return var3 != null ? this.filter(var1, var3[var1]) : 0;
      }

      private int[] getGaps(boolean var1, boolean var2) {
         return this.gaps[this.getGapIx(var1, var2)];
      }

      private int filter(int var1, int var2) {
         if (var2 == -2147471302) {
            return var1 != 2 ? 0 : 2097051;
         } else {
            return Grid.constrainSize(var2);
         }
      }

      private boolean isBaselineAlign(boolean var1) {
         Float var2 = this.cc.getVertical().getGrow();
         if (var2 != null && var2.intValue() != 0) {
            return false;
         } else {
            boolean var10000;
            label23: {
               UnitValue var3 = this.cc.getVertical().getAlign();
               if (var3 != null) {
                  if (var3 != UnitValue.BASELINE_IDENTITY) {
                     break label23;
                  }
               } else if (!var1) {
                  break label23;
               }

               if (this.comp.hasBaseline()) {
                  var10000 = true;
                  return var10000;
               }
            }

            var10000 = false;
            return var10000;
         }
      }

      private int getBaseline(int var1) {
         return this.comp.getBaseline(this.getSize(var1, true), this.getSize(var1, false));
      }

      // $FF: synthetic method
      CompWrap(ComponentWrapper var1, CC var2, int var3, UnitValue[] var4, BoundSize[] var5, Object var6) {
         this(var1, var2, var3, var4, var5);
      }
   }

   private static class LinkedDimGroup {
      private static final int TYPE_SERIAL = 0;
      private static final int TYPE_PARALLEL = 1;
      private static final int TYPE_BASELINE = 2;
      private final String linkCtx;
      private final int span;
      private final int linkType;
      private final boolean isHor;
      private final boolean fromEnd;
      private ArrayList<Grid.CompWrap> _compWraps;
      private int[] sizes;
      private int lStart;
      private int lSize;

      private LinkedDimGroup(String var1, int var2, int var3, boolean var4, boolean var5) {
         this._compWraps = new ArrayList(4);
         this.sizes = null;
         this.lStart = 0;
         this.lSize = 0;
         this.linkCtx = var1;
         this.span = var2;
         this.linkType = var3;
         this.isHor = var4;
         this.fromEnd = var5;
      }

      private void addCompWrap(Grid.CompWrap var1) {
         this._compWraps.add(var1);
         this.sizes = null;
      }

      private void setCompWraps(ArrayList<Grid.CompWrap> var1) {
         if (this._compWraps != var1) {
            this._compWraps = var1;
            this.sizes = null;
         }

      }

      private void layout(DimConstraint var1, int var2, int var3, int var4) {
         this.lStart = var2;
         this.lSize = var3;
         if (this._compWraps.size() != 0) {
            ContainerWrapper var5 = ((Grid.CompWrap)this._compWraps.get(0)).comp.getParent();
            if (this.linkType == 1) {
               Grid.layoutParallel(var5, this._compWraps, var1, var2, var3, this.isHor, this.fromEnd);
            } else if (this.linkType == 2) {
               Grid.layoutBaseline(var5, this._compWraps, var1, var2, var3, 1, var4);
            } else {
               Grid.layoutSerial(var5, this._compWraps, var1, var2, var3, this.isHor, var4, this.fromEnd);
            }

         }
      }

      private int[] getMinPrefMax() {
         if (this.sizes == null && this._compWraps.size() > 0) {
            this.sizes = new int[3];

            for(int var1 = 0; var1 <= 1; ++var1) {
               if (this.linkType == 1) {
                  this.sizes[var1] = Grid.getTotalSizeParallel(this._compWraps, var1, this.isHor);
               } else if (this.linkType == 2) {
                  int[] var2 = Grid.getBaselineAboveBelow(this._compWraps, var1, false);
                  this.sizes[var1] = var2[0] + var2[1];
               } else {
                  this.sizes[var1] = Grid.getTotalSizeSerial(this._compWraps, var1, this.isHor);
               }
            }

            this.sizes[2] = 2097051;
         }

         return this.sizes;
      }

      // $FF: synthetic method
      LinkedDimGroup(String var1, int var2, int var3, boolean var4, boolean var5, Object var6) {
         this(var1, var2, var3, var4, var5);
      }
   }

   private static class Cell {
      private final int spanx;
      private final int spany;
      private final boolean flowx;
      private final ArrayList<Grid.CompWrap> compWraps;
      private boolean hasTagged;

      private Cell(Grid.CompWrap var1) {
         this(var1, 1, 1, true);
      }

      private Cell(int var1, int var2, boolean var3) {
         this((Grid.CompWrap)null, var1, var2, var3);
      }

      private Cell(Grid.CompWrap var1, int var2, int var3, boolean var4) {
         this.compWraps = new ArrayList(1);
         this.hasTagged = false;
         if (var1 != null) {
            this.compWraps.add(var1);
         }

         this.spanx = var2;
         this.spany = var3;
         this.flowx = var4;
      }

      // $FF: synthetic method
      Cell(Grid.CompWrap var1, Object var2) {
         this(var1);
      }

      // $FF: synthetic method
      Cell(int var1, int var2, boolean var3, Object var4) {
         this(var1, var2, var3);
      }

      // $FF: synthetic method
      static boolean access$476(Grid.Cell var0, int var1) {
         return var0.hasTagged = (boolean)((byte)(var0.hasTagged | var1));
      }

      // $FF: synthetic method
      Cell(Grid.CompWrap var1, int var2, int var3, boolean var4, Object var5) {
         this(var1, var2, var3, var4);
      }
   }
}
