local l_script_FirstAncestor_0 = script:FindFirstAncestor("TerrainEditor");
local v1 = require(l_script_FirstAncestor_0.Packages.DraggerFramework.Utility.Signal);
local _ = require(l_script_FirstAncestor_0.Src.Types);
local v3 = {};
v3.__index = v3;
v3.new = function(v4, v5)
    local v6 = setmetatable({
        _region = {
            Region = {
                transform = v4,
                size = v5
            }
        }
    }, v3);
    v6.SelectionChanged = v1.new();
    return v6;
end;
v3.SetRegion = function(v7, v8)
    v7._region.Region = {
        size = v8.Size,
        transform = v8.Transform
    };
end;
v3.SetRegionSignal = function(v9, v10)
    v9:SetRegion(v10);
    v9.SelectionChanged:Fire();
end;
v3.Set = function(_)
end;
v3.Get = function(v12)
    return {
        v12._region
    };
end;
return v3;


local v0 = {};
v0.__index = v0;
v0.new = function(v1, v2)
    return (setmetatable({
        _region = v2[1],
        _draggerContext = v1
    }, v0));
end;
v0.isEmpty = function(_)
    return false;
end;
v0.getBoundingBox = function(v4)
    if not v4._draggerContext:shouldUseLocalSpace() then
        return v4._region.Region.transform, Vector3.new(), v4._region.Region.size;
    else
        return v4._region.Region.transform, Vector3.new(), v4._region.Region.size;
    end;
end;
v0.doesContainItem = function(_, _)
    return true;
end;
v0.isDynamic = function(_)
    return false;
end;
return v0;


local v0 = {};
v0.__index = v0;
v0.new = function(v1, ...)
    return (setmetatable({
        _draggerContext = v1
    }, v0));
end;
v0.beginDrag = function(v2, v3, _)
    assert(#v3 == 1, "Expected selection to have length 1");
    local v5 = v3[1];
    v2._transform = v5.Region.transform;
    v2._size = v5.Region.size;
end;
v0.updateDrag = function(v6, v7)
    v6._draggerContext.updateRegion(v7 * v6._transform, v6._size);
    return v7;
end;
v0.endDrag = function(_)
end;
v0.render = function(_, _)
end;
return v0;


return function(v0, v1, _)
    assert(v0.getMouseTarget == nil, "You accidentally called schema:addUndoWaypoint intead of schema.addUndoWaypoint");
    v0.addWaypoint(v1);
end;


return function(_, _, v2)
    if v2.ClickedItem then
        return "Ready";
    else
        return "DragSelecting";
    end;
end;


local l_script_FirstAncestor_0 = script:FindFirstAncestor("TerrainEditor");
return require(l_script_FirstAncestor_0.Packages.Dash).join(require(l_script_FirstAncestor_0.Packages.DraggerSchemaTemplate.DraggerSchema), {
    addUndoWaypoint = require(script.addUndoWaypoint),
    dispatchWorldClick = require(script.dispatchWorldClick),
    endBoxSelect = require(script.endBoxSelect),
    getNextSelectables = require(script.getNextSelectables),
    isExclusiveSelectable = require(script.isExclusiveSelectable),
    ExtrudeHandlesImplementation = require(script.ExtrudeHandlesImplementation),
    getMouseTarget = require(script.getMouseTarget),
    Selection = require(script.Selection),
    SelectionInfo = require(script.SelectionInfo),
    TransformHandlesImplementation = require(script.TransformHandlesImplementation),
    updateBoxSelect = require(script.updateBoxSelect)
});


local function _(v0)
    local v1 = v0.Position / 4;
    return (Vector3.new(math.floor(v1.X) * 4, math.floor(v1.Y) * 4, math.floor(v1.Z) * 4));
end;
return function(v3, v4, v5)
    local v6 = v3:viewportPointToRay(Vector2.new(v4.X, v4.Y));
    local v7 = v3:viewportPointToRay(Vector2.new(v5.X, v5.Y));
    local v8 = workspace:Raycast(v6.Origin, v6.Direction * 4096);
    local v9 = workspace:Raycast(v7.Origin, v7.Direction * 4096);
    if v8 and v9 then
        if not v3.selectionOnDragPoint then
            v3.selectionOnDragPoint = v8;
        end;
        local v10 = v3.selectionOnDragPoint.Position / 4;
        local v11 = Vector3.new(math.floor(v10.X) * 4, math.floor(v10.Y) * 4, math.floor(v10.Z) * 4);
        v10 = v9.Position / 4;
        local v12 = Vector3.new(math.floor(v10.X) * 4, math.floor(v10.Y) * 4, math.floor(v10.Z) * 4);
        v10 = v11:Min(v12);
        local v13 = v12:Max(v11);
        v3.updateSelectionOnDrag({
            Size = (v13 - v10):Max((Vector3.new(4, 4, 4))),
            Transform = CFrame.new((v13 + v10) / 2)
        });
        return ;
    else
        return ;
    end;
end;


local l_script_FirstAncestor_0 = script:FindFirstAncestor("TerrainEditor");
local v1 = require(l_script_FirstAncestor_0.Src.Util.ApplyById);
local v2 = require(l_script_FirstAncestor_0.Src.Types);
local l_Category_0 = v2.Category;
local l_Biome_0 = v2.Biome;
local l_BiomeSettings_0 = v2.BiomeSettings;
local l_Storage_0 = v2.Storage;
local l_BiomeSettings_1 = l_Category_0.BiomeSettings;
local v8 = require(l_script_FirstAncestor_0.Src.Flags.getFFlagTerrainEditorErrorHandling);
return {
    Storage = {
        [l_BiomeSettings_0.Biomes] = l_Storage_0.LocalPersistent,
        [l_BiomeSettings_0.BiomeBlending] = l_Storage_0.LocalPersistent,
        [l_BiomeSettings_0.BiomeSize] = l_Storage_0.LocalPersistent,
        [l_BiomeSettings_0.Caves] = l_Storage_0.LocalPersistent,
        [l_BiomeSettings_0.Seed] = l_Storage_0.LocalPersistent,
        [l_BiomeSettings_0.Generate] = l_Storage_0.LocalPersistent
    },
    Generator = function(v9, v10, _, v12)
        local l_Localization_0 = v9.Localization;
        local v14 = {};
        for v15, _ in l_Biome_0, nil, nil do
            v14[v15] = l_Localization_0:getText("Biomes", v15);
        end;
        return v1(v9, {
            {
                Id = l_BiomeSettings_0.Biomes,
                Schema = {
                    Items = l_Biome_0,
                    Labels = v14,
                    Type = "MultiSelection"
                },
                Validate = if not v8() then nil else function(v17)
                    local v18 = false;
                    for _, v20 in v17, nil, nil do
                        v18 = v18 or v20;
                    end;
                    if v18 then
                        return Enum.PropertyStatus.Ok, "";
                    else
                        return Enum.PropertyStatus.Error, l_Localization_0:getText("BiomeWarning", "NoBiomesSelected");
                    end;
                end
            },
            {
                Id = l_BiomeSettings_0.BiomeBlending,
                Schema = {
                    Type = "Slider",
                    Min = 0,
                    Max = 1,
                    ShowInput = true,
                    SnapIncrement = 0.001
                }
            },
            {
                Id = l_BiomeSettings_0.Caves,
                Schema = {
                    Type = "Checkbox"
                }
            },
            {
                Id = l_BiomeSettings_0.BiomeSize,
                Schema = {
                    Type = "Number"
                },
                Validate = if not v8() then nil else function(v21)
                    if tonumber(v21) then
                        return Enum.PropertyStatus.Ok, "";
                    else
                        return Enum.PropertyStatus.Error, l_Localization_0:getText("NumberWarning", "InvalidNumber");
                    end;
                end
            },
            {
                Id = l_BiomeSettings_0.Seed,
                Schema = {
                    Type = "Number"
                },
                Validate = if not v8() then nil else function(v22)
                    if tonumber(v22) then
                        return Enum.PropertyStatus.Ok, "";
                    else
                        return Enum.PropertyStatus.Error, l_Localization_0:getText("NumberWarning", "InvalidNumber");
                    end;
                end
            },
            {
                Id = l_BiomeSettings_0.Generate,
                Layout = Enum.FillDirection.Vertical,
                Schema = {
                    Label = l_Localization_0:getText(l_BiomeSettings_1, l_BiomeSettings_0.Generate),
                    Type = "Button"
                }
            }
        }, {
            Category = l_BiomeSettings_1,
            Data = v10,
            Overrides = v12
        });
    end
};


local l_script_FirstAncestor_0 = script:FindFirstAncestor("TerrainEditor");
local v1 = require(l_script_FirstAncestor_0.Src.Types);
local v2 = require(l_script_FirstAncestor_0.Src.Util.getItems);
local v3 = require(l_script_FirstAncestor_0.Src.Util.ApplyById);
local l_BrushSettings_0 = v1.BrushSettings;
local l_BrushMode_0 = v1.BrushMode;
local l_Category_0 = v1.Category;
local l_EnumType_0 = v1.EnumType;
local l_FlattenPlane_0 = v1.FlattenPlane;
local l_PlaneLock_0 = v1.PlaneLock;
local l_Storage_0 = v1.Storage;
local l_BrushSettings_1 = l_Category_0.BrushSettings;
local v12 = require(l_script_FirstAncestor_0.Src.Flags.getFFlagTerrainEditorWaterAutofill);
return {
    Storage = {
        [l_BrushSettings_0.BrushMode] = l_Storage_0.LocalPersistent,
        [l_BrushSettings_0.BrushShape] = l_Storage_0.LocalPersistent,
        [l_BrushSettings_0.BrushSize] = l_Storage_0.LocalPersistent,
        [l_BrushSettings_0.Strength] = l_Storage_0.LocalPersistent,
        [l_BrushSettings_0.FixedYPlane] = l_Storage_0.LocalPersistent,
        [l_BrushSettings_0.FlattenPlane] = l_Storage_0.LocalPersistent,
        [l_BrushSettings_0.FlattenMode] = l_Storage_0.LocalPersistent,
        [l_BrushSettings_0.PivotPosition] = l_Storage_0.LocalPersistent,
        [l_BrushSettings_0.PlaneLock] = l_Storage_0.Global,
        [l_BrushSettings_0.ManualPlaneLock] = l_Storage_0.Global,
        [l_BrushSettings_0.PlaneTransform] = l_Storage_0.Global,
        [l_BrushSettings_0.Snapping] = l_Storage_0.LocalPersistent,
        [l_BrushSettings_0.State] = l_Storage_0.LocalSession,
        [l_BrushSettings_0.IgnoreWater] = l_Storage_0.LocalPersistent,
        [l_BrushSettings_0.IgnoreParts] = l_Storage_0.LocalPersistent,
        [l_BrushSettings_0.PullTerrain] = l_Storage_0.LocalPersistent,
        [l_BrushSettings_0.TemporarySmooth] = l_Storage_0.LocalSession,
        [l_BrushSettings_0.WaterAutofill] = l_Storage_0.LocalPersistent
    },
    Generator = function(v13, v14, _, v16)
        local l_Localization_0 = v13.Localization;
        local l_Stylizer_0 = v13.Stylizer;
        local l_v3_0 = v3;
        local l_v13_0 = v13;
        local v21 = {};
        local v22 = {
            Id = l_BrushSettings_0.BrushMode,
            Schema = {
                Type = "SingleSelectButton",
                Items = v2(l_Localization_0, nil, l_EnumType_0.BrushMode)
            }
        };
        local v23 = {
            Height = 52,
            Id = l_BrushSettings_0.BrushShape,
            Schema = {
                Type = "SingleSelectButton",
                Items = v2(nil, l_Stylizer_0, l_EnumType_0.BrushShape)
            }
        };
        local v24 = {
            Height = 52,
            Id = l_BrushSettings_0.FlattenMode,
            Schema = {
                Type = "SingleSelectButton",
                Items = v2(nil, l_Stylizer_0, l_EnumType_0.FlattenMode)
            }
        };
        local v25 = {
            Id = l_BrushSettings_0.BrushSize,
            Schema = {
                Shape = v14[l_BrushSettings_0.BrushShape],
                Type = "BrushSize"
            }
        };
        local v26 = {
            Id = l_BrushSettings_0.Strength,
            Schema = {
                Type = "Slider",
                Min = 0,
                Max = 1,
                ShowInput = true,
                SnapIncrement = 0.01
            }
        };
        local v27 = {
            Id = l_BrushSettings_0.PivotPosition,
            Schema = {
                Type = "SingleSelectButton",
                Items = v2(l_Localization_0, nil, l_EnumType_0.PivotPosition)
            }
        };
        local v28 = {
            Id = l_BrushSettings_0.Snapping,
            Schema = {
                Type = "SingleSelectButton",
                Items = v2(l_Localization_0, nil, l_EnumType_0.Snapping)
            }
        };
        local v29 = {
            Id = l_BrushSettings_0.FlattenPlane,
            Schema = {
                Type = "SingleSelectButton",
                Items = v2(l_Localization_0, nil, l_EnumType_0.FlattenPlane)
            }
        };
        local v30 = {
            Hidden = v14[l_BrushSettings_0.FlattenPlane] == l_FlattenPlane_0.Auto,
            Id = l_BrushSettings_0.FixedYPlane,
            Schema = {
                Type = "Number"
            }
        };
        local v31 = {
            Id = l_BrushSettings_0.PlaneLock,
            Schema = {
                Type = "SingleSelectButton",
                Items = v2(l_Localization_0, nil, l_EnumType_0.PlaneLock)
            }
        };
        local v32 = {
            Hidden = v14[l_BrushSettings_0.PlaneLock] ~= l_PlaneLock_0.Manual,
            Id = l_BrushSettings_0.ManualPlaneLock,
            Schema = {
                ApplyLabel = l_Localization_0:getText(l_Category_0.BrushSettings, "Apply"),
                EditLabel = l_Localization_0:getText(l_Category_0.BrushSettings, "Edit"),
                OnReset = function()
                end,
                Type = "PlaneLock"
            }
        };
        local v33 = {
            DataId = l_BrushSettings_0.PlaneTransform,
            Id = l_BrushSettings_0.PlanePosition
        };
        local v34 = true;
        if v14[l_BrushSettings_0.PlaneLock] == l_PlaneLock_0.Manual then
            v34 = not v14[l_BrushSettings_0.ManualPlaneLock];
        end;
        v33.Hidden = v34;
        v33.Schema = {
            Type = "Vector",
            Components = {
                "X",
                "Y",
                "Z"
            },
            GetValue = function(v35)
                return v14[l_BrushSettings_0.PlaneTransform].Rotation + Vector3.new(v35[1], v35[2], v35[3]);
            end,
            GetComponents = function(v36)
                local l_Position_0 = v36.Position;
                return {
                    l_Position_0.X,
                    l_Position_0.Y,
                    l_Position_0.Z
                };
            end
        };
        v33.Value = v14[l_BrushSettings_0.PlaneTransform];
        v34 = {
            DataId = l_BrushSettings_0.PlaneTransform,
            Id = l_BrushSettings_0.PlaneRotation
        };
        local v38 = true;
        if v14[l_BrushSettings_0.PlaneLock] == l_PlaneLock_0.Manual then
            v38 = not v14[l_BrushSettings_0.ManualPlaneLock];
        end;
        v34.Hidden = v38;
        v34.Schema = {
            Type = "Vector",
            Components = {
                "X",
                "Y",
                "Z"
            },
            GetValue = function(v39)
                return CFrame.fromEulerAnglesXYZ(math.rad(v39[1]), math.rad(v39[2]), (math.rad(v39[3]))) + v14[l_BrushSettings_0.PlaneTransform].Position;
            end,
            GetComponents = function(v40)
                local v41, v42, v43 = v40:ToEulerAnglesXYZ();
                return {
                    math.deg(v41),
                    math.deg(v42),
                    (math.deg(v43))
                };
            end
        };
        v34.Value = v14[l_BrushSettings_0.PlaneTransform];
        v38 = {
            Id = l_BrushSettings_0.IgnoreWater,
            Schema = {
                Type = "Checkbox"
            }
        };
        local v44 = {
            Id = l_BrushSettings_0.IgnoreParts,
            Schema = {
                Type = "Checkbox"
            }
        };
        local v45 = {
            Hidden = not v12() or v14[l_BrushSettings_0.BrushMode] == l_BrushMode_0.Add,
            Id = l_BrushSettings_0.WaterAutofill,
            Schema = {
                Type = "Checkbox"
            }
        };
        setlist { ['R008[1 to 16]'] = 'R009 to R024' };
        return l_v3_0(l_v13_0, v21, {
            Category = l_BrushSettings_1,
            Data = v14,
            Overrides = v16
        });
    end
};


local l_script_FirstAncestor_0 = script:FindFirstAncestor("TerrainEditor");
local v1 = require(l_script_FirstAncestor_0.Src.Util.ApplyById);
local v2 = require(l_script_FirstAncestor_0.Src.Types);
local l_Category_0 = v2.Category;
local l_BuildSettings_0 = v2.BuildSettings;
local _ = v2.EnumType;
local l_Storage_0 = v2.Storage;
local l_TerrainType_0 = v2.TerrainType;
local v8 = require(l_script_FirstAncestor_0.Src.Resources.Constants);
local _ = require(l_script_FirstAncestor_0.Src.Util.getItems);
local l_BuildSettings_1 = l_Category_0.BuildSettings;
local v11 = {
    Storage = {
        [l_BuildSettings_0.AdvancedNoise] = l_Storage_0.LocalPersistent,
        [l_BuildSettings_0.NoiseStrength] = l_Storage_0.LocalPersistent,
        [l_BuildSettings_0.BankSize] = l_Storage_0.LocalPersistent,
        [l_BuildSettings_0.BlendingEdge] = l_Storage_0.LocalPersistent,
        [l_BuildSettings_0.CliffSlope] = l_Storage_0.LocalPersistent,
        [l_BuildSettings_0.Confirm] = l_Storage_0.LocalSession,
        [l_BuildSettings_0.CraterDepth] = l_Storage_0.LocalPersistent,
        [l_BuildSettings_0.CraterRadius] = l_Storage_0.LocalPersistent,
        [l_BuildSettings_0.FillBottom] = l_Storage_0.LocalPersistent,
        [l_BuildSettings_0.NoiseScale] = l_Storage_0.LocalPersistent,
        [l_BuildSettings_0.Material] = l_Storage_0.LocalSession,
        [l_BuildSettings_0.Offset] = l_Storage_0.LocalPersistent,
        [l_BuildSettings_0.PlacementMode] = l_Storage_0.LocalSession,
        [l_BuildSettings_0.Position] = l_Storage_0.LocalPersistent,
        [l_BuildSettings_0.RimHeight] = l_Storage_0.LocalPersistent,
        [l_BuildSettings_0.Rotation] = l_Storage_0.LocalPersistent,
        [l_BuildSettings_0.Seed] = l_Storage_0.LocalPersistent,
        [l_BuildSettings_0.Size] = l_Storage_0.LocalPersistent,
        [l_BuildSettings_0.SnapToVoxels] = l_Storage_0.LocalSession,
        [l_BuildSettings_0.TerrainType] = l_Storage_0.Global,
        [l_BuildSettings_0.TopRadius] = l_Storage_0.LocalPersistent,
        [l_BuildSettings_0.Transform] = l_Storage_0.LocalPersistent,
        [l_BuildSettings_0.WaterLevel] = l_Storage_0.LocalPersistent,
        [l_BuildSettings_0.Material] = l_Storage_0.LocalSession,
        [l_BuildSettings_0.MaterialLUT] = l_Storage_0.LocalSession
    }
};
local v12 = {
    Type = "DelayedSlider",
    Min = 0,
    Max = 1,
    ShowInput = true,
    SnapIncrement = 0.01
};
v11.Generator = function(v13, v14, _, v16)
    local l_Localization_0 = v13.Localization;
    return v1(v13, {
        {
            Id = l_BuildSettings_0.TerrainType,
            Layout = Enum.FillDirection.Vertical,
            Schema = {
                Type = "TerrainType"
            }
        },
        {
            DataId = l_BuildSettings_0.Transform,
            Hidden = false,
            Id = l_BuildSettings_0.Position,
            Schema = {
                Type = "Vector",
                Components = {
                    "X",
                    "Y",
                    "Z"
                },
                GetValue = function(v18)
                    return v14[l_BuildSettings_0.Transform].Rotation + Vector3.new(v18[1], v18[2], v18[3]);
                end,
                GetComponents = function(v19)
                    local l_Position_0 = v19.Position;
                    return {
                        l_Position_0.X,
                        l_Position_0.Y,
                        l_Position_0.Z
                    };
                end
            },
            Value = v14[l_BuildSettings_0.Transform]
        },
        {
            Id = l_BuildSettings_0.Size,
            Schema = {
                Type = "Vector",
                Components = {
                    "X",
                    "Y",
                    "Z"
                },
                GetValue = function(v21)
                    return (Vector3.new(v21[1], v21[2], v21[3]));
                end,
                GetComponents = function(v22)
                    return {
                        v22.X,
                        v22.Y,
                        v22.Z
                    };
                end
            },
            Validate = function(v23)
                if not (v23.X >= 4 and v23.Y >= 4) or v23.Z < 4 then
                    return Enum.PropertyStatus.Error, l_Localization_0:getText("SelectionWarning", "Size");
                elseif v8.MaxBuildRegion ^ 3 < (v23.X * v23.Y) * v23.Z then
                    return Enum.PropertyStatus.Error, l_Localization_0:getText("SelectionWarning", "SizeMax");
                else
                    return Enum.PropertyStatus.Ok, "";
                end;
            end
        },
        {
            Id = l_BuildSettings_0.CraterDepth,
            Schema = v12
        },
        {
            Id = l_BuildSettings_0.CraterRadius,
            Schema = v12
        },
        {
            Id = l_BuildSettings_0.TopRadius,
            Schema = v12
        },
        {
            Id = l_BuildSettings_0.FillBottom,
            Schema = v12
        },
        {
            Id = l_BuildSettings_0.WaterLevel,
            Schema = v12
        },
        {
            Id = l_BuildSettings_0.BankSize,
            Schema = v12
        },
        {
            Id = l_BuildSettings_0.RimHeight,
            Schema = v12
        },
        {
            Id = l_BuildSettings_0.CliffSlope,
            Schema = {
                Type = "DelayedSlider",
                Min = 0,
                Max = 90,
                ShowInput = true,
                SnapIncrement = 1
            }
        },
        {
            Id = l_BuildSettings_0.NoiseScale,
            Schema = v12
        },
        {
            Id = l_BuildSettings_0.NoiseStrength,
            Schema = v12
        },
        {
            Children = {
                {
                    Id = l_BuildSettings_0.Offset,
                    Schema = {
                        Type = "Vector",
                        Components = {
                            "X",
                            "Y"
                        },
                        GetValue = function(v24)
                            return Vector2.new(v24[1], v24[2]);
                        end,
                        GetComponents = function(v25)
                            return {
                                v25.X,
                                v25.Y
                            };
                        end
                    }
                },
                {
                    Id = l_BuildSettings_0.Rotation,
                    Schema = {
                        Type = "DelayedSlider",
                        Min = 0,
                        Max = 360,
                        ShowInput = true,
                        SnapIncrement = 1
                    }
                },
                {
                    Id = l_BuildSettings_0.Seed,
                    Schema = {
                        Type = "Number"
                    }
                }
            },
            Id = l_BuildSettings_0.AdvancedNoise,
            Schema = {
                Text = "",
                Type = "Label"
            },
            Value = v14[l_BuildSettings_0.TerrainType] ~= l_TerrainType_0.None and true or nil
        },
        {
            Id = l_BuildSettings_0.Material,
            Schema = {
                Height = not v14[l_BuildSettings_0.Size] and 1 or v14[l_BuildSettings_0.Size].Y,
                Type = "MaterialRanges"
            }
        },
        {
            Id = l_BuildSettings_0.BlendingEdge,
            Schema = v12
        },
        {
            Id = l_BuildSettings_0.Confirm,
            Layout = Enum.FillDirection.Vertical,
            Schema = {
                CanConfirm = false,
                CanRegenerate = false,
                Label = l_Localization_0:getText(l_BuildSettings_1, l_BuildSettings_0.Confirm),
                Type = "ConfirmGeneration"
            },
            Value = true
        }
    }, {
        Category = l_BuildSettings_1,
        Data = v14,
        Overrides = v16
    });
end;
return v11;


local l_script_FirstAncestor_0 = script:FindFirstAncestor("TerrainEditor");
local v1 = require(l_script_FirstAncestor_0.Src.Util.ApplyById);
local v2 = require(l_script_FirstAncestor_0.Src.Types);
local l_Category_0 = v2.Category;
local l_ClearSettings_0 = v2.ClearSettings;
local l_Storage_0 = v2.Storage;
local l_ClearSettings_1 = l_Category_0.ClearSettings;
return {
    Storage = {
        [l_ClearSettings_0.Clear] = l_Storage_0.LocalSession
    },
    Generator = function(v7, v8, _, v10)
        return v1(v7, {
            {
                Id = l_ClearSettings_0.Clear,
                Layout = Enum.FillDirection.Vertical,
                Schema = {
                    Label = v7.Localization:getText(l_Category_0.ClearSettings, "ClearButtonLabel"),
                    Type = "Button"
                }
            }
        }, {
            Category = l_ClearSettings_1,
            Data = v8,
            Overrides = v10
        });
    end
};


local l_script_FirstAncestor_0 = script:FindFirstAncestor("TerrainEditor");
local v1 = require(l_script_FirstAncestor_0.Src.Types);
local v2 = require(l_script_FirstAncestor_0.Src.Util.ApplyById);
local l_Category_0 = v1.Category;
local l_HeightmapSettings_0 = v1.HeightmapSettings;
local l_ImageType_0 = v1.ImageType;
local l_Storage_0 = v1.Storage;
local v7 = require(l_script_FirstAncestor_0.Src.Flags.getFFlagTerrainEditorHeightmapFixes);
local l_HeightmapSettings_1 = l_Category_0.HeightmapSettings;
return {
    Storage = {
        [l_HeightmapSettings_0.Colormap] = l_Storage_0.LocalSession,
        [l_HeightmapSettings_0.Heightmap] = l_Storage_0.LocalSession,
        [l_HeightmapSettings_0.Import] = l_Storage_0.LocalSession,
        [l_HeightmapSettings_0.DefaultMaterial] = l_Storage_0.LocalPersistent
    },
    Generator = function(v9, v10, _, v12)
        local l_Localization_0 = v9.Localization;
        return v2(v9, {
            {
                Id = l_HeightmapSettings_0.Heightmap,
                Schema = {
                    ImageType = if not v7() then nil else l_ImageType_0.Heightmap,
                    Type = "Image"
                },
                Validate = function(v14)
                    if v14.Error ~= "" then
                        return Enum.PropertyStatus.Error, l_Localization_0:getText("ImportWarning", "FailedImport", {
                            Error = v14.Error
                        });
                    else
                        if v14.Image then
                            if not v14.Image.ChannelInfo.DiscardedChannels then
                                if v14.Image.Preview.Error then
                                    return Enum.PropertyStatus.Warning, l_Localization_0:getText("ImportWarning", "FailedPreview", {
                                        Error = v14.Image.Preview.Error
                                    });
                                end;
                            else
                                return Enum.PropertyStatus.Warning, l_Localization_0:getText("ImportWarning", "DiscardedChannels");
                            end;
                        end;
                        return Enum.PropertyStatus.Ok, "";
                    end;
                end
            },
            {
                Id = l_HeightmapSettings_0.Colormap,
                Schema = {
                    ImageType = if not v7() then nil else l_ImageType_0.Colormap,
                    Type = "Image"
                },
                Validate = function(v15)
                    if v15.Error ~= "" then
                        return Enum.PropertyStatus.Error, l_Localization_0:getText("ImportWarning", "FailedImport", {
                            Error = v15.Error
                        });
                    elseif not v15.Image or not v15.Image.Preview.Error then
                        return Enum.PropertyStatus.Ok, "";
                    else
                        return Enum.PropertyStatus.Warning, l_Localization_0:getText("ImportWarning", "FailedPreview", {
                            Error = v15.Image.Preview.Error
                        });
                    end;
                end
            },
            {
                Id = l_HeightmapSettings_0.DefaultMaterial,
                Layout = Enum.FillDirection.Vertical,
                Schema = {
                    AllowAir = false,
                    Type = "Material"
                }
            },
            {
                Disabled = not v10[l_HeightmapSettings_0.Heightmap] or not v10[l_HeightmapSettings_0.Heightmap].Image,
                Id = l_HeightmapSettings_0.Import,
                Layout = Enum.FillDirection.Vertical,
                Schema = {
                    Label = l_Localization_0:getText(l_HeightmapSettings_1, l_HeightmapSettings_0.Import),
                    Type = "Button"
                }
            }
        }, {
            Category = l_HeightmapSettings_1,
            Data = v10,
            Overrides = v12
        });
    end
};


local l_script_FirstAncestor_0 = script:FindFirstAncestor("TerrainEditor");
local v1 = require(l_script_FirstAncestor_0.Src.Types);
local v2 = require(l_script_FirstAncestor_0.Src.Util.getItems);
local v3 = require(l_script_FirstAncestor_0.Src.Util.ApplyById);
local l_Category_0 = v1.Category;
local l_EnumType_0 = v1.EnumType;
local l_FillMode_0 = v1.FillMode;
local l_MaterialMode_0 = v1.MaterialMode;
local l_MaterialSettings_0 = v1.MaterialSettings;
local l_Storage_0 = v1.Storage;
local l_Tool_0 = v1.Tool;
local l_MaterialSettings_1 = l_Category_0.MaterialSettings;
local v12 = require(l_script_FirstAncestor_0.Src.Flags.getFFlagTerrainEditorAirSourceMaterial);
return {
    Storage = {
        [l_MaterialSettings_0.AutoMaterial] = l_Storage_0.LocalPersistent,
        [l_MaterialSettings_0.FillMode] = l_Storage_0.LocalPersistent,
        [l_MaterialSettings_0.MaterialMode] = l_Storage_0.LocalPersistent,
        [l_MaterialSettings_0.SourceMaterial] = l_Storage_0.LocalPersistent,
        [l_MaterialSettings_0.TargetMaterial] = l_Storage_0.LocalPersistent
    },
    Generator = function(v13, v14, v15, v16)
        local l_Localization_0 = v13.Localization;
        local l_v3_0 = v3;
        local l_v13_0 = v13;
        local v20 = {};
        local v21 = {
            Id = l_MaterialSettings_0.AutoMaterial,
            Schema = {
                Type = "Checkbox"
            }
        };
        local v22 = {
            Id = l_MaterialSettings_0.MaterialMode,
            Schema = {
                Type = "SingleSelectButton",
                Items = v2(l_Localization_0, nil, l_EnumType_0.MaterialMode)
            }
        };
        local v23 = {
            Id = l_MaterialSettings_0.FillMode,
            Schema = {
                Type = "SingleSelectButton",
                Items = v2(l_Localization_0, nil, l_EnumType_0.FillMode)
            }
        };
        local v24 = {
            Hidden = v14[l_MaterialSettings_0.AutoMaterial],
            Id = l_MaterialSettings_0.SourceMaterial,
            Layout = Enum.FillDirection.Vertical,
            Schema = {
                AllowAir = v12(),
                Type = "Material"
            }
        };
        local v25 = {};
        local v26;
        if v14[l_MaterialSettings_0.MaterialMode] ~= nil then
            v26 = false;
            if not (v14[l_MaterialSettings_0.MaterialMode] == l_MaterialMode_0.Paint) then
                goto label0;
            end;
        end;
        v26 = true;
        if v14[l_MaterialSettings_0.FillMode] ~= nil then
            v26 = v14[l_MaterialSettings_0.FillMode] == l_FillMode_0.Fill;
        end;
        ::label0::;
        v25.Hidden = v26;
        v25.Id = l_MaterialSettings_0.TargetMaterial;
        v25.Layout = Enum.FillDirection.Vertical;
        v25.Schema = {
            AllowAir = true,
            Type = "Material"
        };
        v26 = {
            Hidden = v15 ~= l_Tool_0.Paint,
            Id = l_MaterialSettings_0.Apply,
            Layout = Enum.FillDirection.Vertical,
            Label = if v14[l_MaterialSettings_0.MaterialMode] or v14[l_MaterialSettings_0.FillMode] then l_Localization_0:getText(l_MaterialSettings_1, v14[l_MaterialSettings_0.MaterialMode] or v14[l_MaterialSettings_0.FillMode]) else nil,
            Schema = {
                Label = if v14[l_MaterialSettings_0.MaterialMode] or v14[l_MaterialSettings_0.FillMode] then l_Localization_0:getText(l_MaterialSettings_1, v14[l_MaterialSettings_0.MaterialMode] or v14[l_MaterialSettings_0.FillMode]) else nil,
                Type = "Button"
            }
        };
        setlist { ['R007[1 to 6]'] = 'R008 to R013' };
        return l_v3_0(l_v13_0, v20, {
            Category = l_MaterialSettings_1,
            Data = v14,
            Overrides = v16
        });
    end
};


local l_script_FirstAncestor_0 = script:FindFirstAncestor("TerrainEditor");
local v1 = require(l_script_FirstAncestor_0.Src.Util.ApplyById);
local v2 = require(l_script_FirstAncestor_0.Src.Types);
local l_Category_0 = v2.Category;
local l_SeaLevelSettings_0 = v2.SeaLevelSettings;
local l_Storage_0 = v2.Storage;
local v6 = require(l_script_FirstAncestor_0.Src.Resources.Constants);
local l_SeaLevelSettings_1 = l_Category_0.SeaLevelSettings;
local v8 = require(l_script_FirstAncestor_0.Src.Util.getWithinTerrainBounds);
local v9 = require(l_script_FirstAncestor_0.Src.Flags.getFFlagTerrainEditorErrorHandling);
return {
    Storage = {
        [l_SeaLevelSettings_0.Evaporate] = l_Storage_0.LocalSession,
        [l_SeaLevelSettings_0.Create] = l_Storage_0.LocalSession,
        [l_SeaLevelSettings_0.Size] = l_Storage_0.LocalPersistent,
        [l_SeaLevelSettings_0.SnapToVoxels] = l_Storage_0.LocalPersistent,
        [l_SeaLevelSettings_0.Transform] = l_Storage_0.LocalPersistent
    },
    Generator = function(v10, v11, _, v13)
        local l_Localization_0 = v10.Localization;
        return v1(v10, {
            {
                Id = l_SeaLevelSettings_0.Size,
                Schema = {
                    Type = "Vector",
                    Components = {
                        "X",
                        "Y",
                        "Z"
                    },
                    GetValue = function(v15)
                        return (Vector3.new(v15[1], v15[2], v15[3]));
                    end,
                    GetComponents = function(v16)
                        return {
                            v16.X,
                            v16.Y,
                            v16.Z
                        };
                    end
                },
                Validate = function(v17)
                    if not (v17.X >= 4 and v17.Y >= 4) or v17.Z < 4 then
                        return Enum.PropertyStatus.Error, l_Localization_0:getText("SelectionWarning", "Size");
                    elseif not (v6.MaxRegion >= v17.X and v6.MaxRegion >= v17.Y) or v6.MaxRegion < v17.Z then
                        return Enum.PropertyStatus.Error, l_Localization_0:getText("SelectionWarning", "SizeMax");
                    else
                        return Enum.PropertyStatus.Ok, "";
                    end;
                end,
                Value = v11[l_SeaLevelSettings_0.Size]
            },
            {
                DataId = l_SeaLevelSettings_0.Transform,
                Hidden = false,
                Id = l_SeaLevelSettings_0.Position,
                Schema = {
                    Type = "Vector",
                    Components = {
                        "X",
                        "Y",
                        "Z"
                    },
                    GetValue = function(v18)
                        return v11[l_SeaLevelSettings_0.Transform].Rotation + Vector3.new(v18[1], v18[2], v18[3]);
                    end,
                    GetComponents = function(v19)
                        local l_Position_0 = v19.Position;
                        return {
                            l_Position_0.X,
                            l_Position_0.Y,
                            l_Position_0.Z
                        };
                    end
                },
                Validate = if not v9() then nil else function(v21)
                    if v8(v21, v10.Tool:getPayload()[l_SeaLevelSettings_1][l_SeaLevelSettings_0.Size]) then
                        return Enum.PropertyStatus.Ok, "";
                    else
                        return Enum.PropertyStatus.Error, l_Localization_0:getText("SelectionWarning", "OutOfBounds");
                    end;
                end,
                Value = v11[l_SeaLevelSettings_0.Transform]
            },
            {
                Id = l_SeaLevelSettings_0.SnapToVoxels,
                Schema = {
                    Type = "Checkbox"
                }
            },
            {
                Id = l_SeaLevelSettings_0.Evaporate,
                Layout = Enum.FillDirection.Vertical,
                Schema = {
                    Label = l_Localization_0:getText(l_SeaLevelSettings_1, l_SeaLevelSettings_0.Evaporate),
                    Type = "Button"
                }
            },
            {
                Id = l_SeaLevelSettings_0.Create,
                Layout = Enum.FillDirection.Vertical,
                Schema = {
                    Label = l_Localization_0:getText(l_SeaLevelSettings_1, l_SeaLevelSettings_0.Create),
                    Type = "Button"
                }
            }
        }, {
            Category = l_SeaLevelSettings_1,
            Data = v11,
            Overrides = v13
        });
    end
};


local l_script_FirstAncestor_0 = script:FindFirstAncestor("TerrainEditor");
local v1 = require(l_script_FirstAncestor_0.Src.Util.ApplyById);
local v2 = require(l_script_FirstAncestor_0.Src.Types);
local l_Category_0 = v2.Category;
local l_SelectionSettings_0 = v2.SelectionSettings;
local l_Storage_0 = v2.Storage;
local v6 = require(l_script_FirstAncestor_0.Src.Resources.Constants);
local v7 = require(l_script_FirstAncestor_0.Src.Util.getWithinTerrainBounds);
local v8 = require(l_script_FirstAncestor_0.Src.Flags.getFFlagTerrainEditorErrorHandling);
local l_SelectionSettings_1 = l_Category_0.SelectionSettings;
return {
    Storage = {
        [l_SelectionSettings_0.Size] = l_Storage_0.Global,
        [l_SelectionSettings_0.Position] = l_Storage_0.Global,
        [l_SelectionSettings_0.Transform] = l_Storage_0.Global,
        [l_SelectionSettings_0.SnapToVoxels] = l_Storage_0.Global
    },
    Generator = function(v10, v11, _, v13)
        local l_Localization_0 = v10.Localization;
        return v1(v10, {
            {
                Id = l_SelectionSettings_0.Size,
                Schema = {
                    Type = "Vector",
                    Components = {
                        "X",
                        "Y",
                        "Z"
                    },
                    GetValue = function(v15)
                        return (Vector3.new(v15[1], v15[2], v15[3]));
                    end,
                    GetComponents = function(v16)
                        return {
                            v16.X,
                            v16.Y,
                            v16.Z
                        };
                    end
                },
                Validate = function(v17)
                    if not (v17.X >= 4 and v17.Y >= 4) or v17.Z < 4 then
                        return Enum.PropertyStatus.Error, l_Localization_0:getText("SelectionWarning", "Size");
                    elseif not (v6.MaxRegion >= v17.X and v6.MaxRegion >= v17.Y) or v6.MaxRegion < v17.Z then
                        return Enum.PropertyStatus.Error, l_Localization_0:getText("SelectionWarning", "SizeMax");
                    else
                        return Enum.PropertyStatus.Ok, "";
                    end;
                end
            },
            {
                DataId = l_SelectionSettings_0.Transform,
                Hidden = false,
                Id = l_SelectionSettings_0.Position,
                Schema = {
                    Type = "Vector",
                    Components = {
                        "X",
                        "Y",
                        "Z"
                    },
                    GetValue = function(v18)
                        return v11[l_SelectionSettings_0.Transform].Rotation + Vector3.new(v18[1], v18[2], v18[3]);
                    end,
                    GetComponents = function(v19)
                        local l_Position_0 = v19.Position;
                        return {
                            l_Position_0.X,
                            l_Position_0.Y,
                            l_Position_0.Z
                        };
                    end
                },
                Validate = if not v8() then nil else function(v21)
                    if v7(v21, v10.Tool:getPayload()[l_SelectionSettings_1][l_SelectionSettings_0.Size]) then
                        return Enum.PropertyStatus.Ok, "";
                    else
                        return Enum.PropertyStatus.Error, l_Localization_0:getText("SelectionWarning", "OutOfBounds");
                    end;
                end,
                Value = v11[l_SelectionSettings_0.Transform]
            },
            {
                DataId = l_SelectionSettings_0.Transform,
                Id = l_SelectionSettings_0.Rotation,
                Schema = {
                    Type = "Vector",
                    Components = {
                        "X",
                        "Y",
                        "Z"
                    },
                    GetValue = function(v22)
                        return CFrame.fromEulerAnglesXYZ(math.rad(v22[1]), math.rad(v22[2]), (math.rad(v22[3]))) + v11[l_SelectionSettings_0.Transform].Position;
                    end,
                    GetComponents = function(v23)
                        local v24, v25, v26 = v23:ToEulerAnglesXYZ();
                        return {
                            math.deg(v24),
                            math.deg(v25),
                            (math.deg(v26))
                        };
                    end
                },
                Value = v11[l_SelectionSettings_0.Transform]
            },
            {
                Id = l_SelectionSettings_0.SnapToVoxels,
                Schema = {
                    Type = "Checkbox"
                }
            }
        }, {
            Category = l_SelectionSettings_1,
            Data = v11,
            Overrides = v13
        });
    end
};


local l_script_FirstAncestor_0 = script:FindFirstAncestor("TerrainEditor");
local v1 = require(l_script_FirstAncestor_0.Src.Util.ApplyById);
local v2 = require(l_script_FirstAncestor_0.Src.Types);
local l_Category_0 = v2.Category;
local l_TransformSettings_0 = v2.TransformSettings;
local l_Storage_0 = v2.Storage;
local v6 = require(l_script_FirstAncestor_0.Src.Resources.Constants);
local l_TransformSettings_1 = l_Category_0.TransformSettings;
local v8 = require(l_script_FirstAncestor_0.Src.Util.getWithinTerrainBounds);
local v9 = require(l_script_FirstAncestor_0.Src.Flags.getFFlagTerrainEditorErrorHandling);
return {
    Storage = {
        [l_TransformSettings_0.Apply] = l_Storage_0.LocalSession,
        [l_TransformSettings_0.ForcePreview] = l_Storage_0.LocalSession,
        [l_TransformSettings_0.LiveEdit] = l_Storage_0.LocalPersistent,
        [l_TransformSettings_0.MergeEmpty] = l_Storage_0.LocalPersistent,
        [l_TransformSettings_0.OperationSource] = l_Storage_0.LocalPersistent,
        [l_TransformSettings_0.Position] = l_Storage_0.Global,
        [l_TransformSettings_0.Size] = l_Storage_0.Global,
        [l_TransformSettings_0.SnapToVoxels] = l_Storage_0.Global,
        [l_TransformSettings_0.TerrainRegion] = l_Storage_0.Global,
        [l_TransformSettings_0.TerrainRegionBuffer] = l_Storage_0.Global,
        [l_TransformSettings_0.TerrainRegionBufferSize] = l_Storage_0.Global,
        [l_TransformSettings_0.TerrainRegionBufferTransform] = l_Storage_0.Global,
        [l_TransformSettings_0.TerrainRegionSize] = l_Storage_0.Global,
        [l_TransformSettings_0.TerrainRegionTransform] = l_Storage_0.Global,
        [l_TransformSettings_0.Transform] = l_Storage_0.Global,
        [l_TransformSettings_0.TransformMode] = l_Storage_0.Global
    },
    Generator = function(v10, v11, _, v13)
        local l_Localization_0 = v10.Localization;
        return v1(v10, {
            {
                Id = l_TransformSettings_0.Size,
                Schema = {
                    Type = "Vector",
                    Components = {
                        "X",
                        "Y",
                        "Z"
                    },
                    GetValue = function(v15)
                        return (Vector3.new(v15[1], v15[2], v15[3]));
                    end,
                    GetComponents = function(v16)
                        return {
                            v16.X,
                            v16.Y,
                            v16.Z
                        };
                    end
                },
                Validate = function(v17)
                    if not (v17.X >= 4 and v17.Y >= 4) or v17.Z < 4 then
                        return Enum.PropertyStatus.Error, l_Localization_0:getText("SelectionWarning", "Size");
                    elseif not (v6.MaxRegion >= v17.X and v6.MaxRegion >= v17.Y) or v6.MaxRegion < v17.Z then
                        return Enum.PropertyStatus.Error, l_Localization_0:getText("SelectionWarning", "SizeMax");
                    else
                        return Enum.PropertyStatus.Ok, "";
                    end;
                end
            },
            {
                DataId = l_TransformSettings_0.Transform,
                Id = l_TransformSettings_0.Position,
                Hidden = false,
                Schema = {
                    Type = "Vector",
                    Components = {
                        "X",
                        "Y",
                        "Z"
                    },
                    GetValue = function(v18)
                        return v11[l_TransformSettings_0.Transform].Rotation + Vector3.new(v18[1], v18[2], v18[3]);
                    end,
                    GetComponents = function(v19)
                        local l_Position_0 = v19.Position;
                        return {
                            l_Position_0.X,
                            l_Position_0.Y,
                            l_Position_0.Z
                        };
                    end
                },
                Value = v11[l_TransformSettings_0.Transform]
            },
            {
                DataId = l_TransformSettings_0.Transform,
                Id = l_TransformSettings_0.Rotation,
                Schema = {
                    Type = "Vector",
                    Components = {
                        "X",
                        "Y",
                        "Z"
                    },
                    GetValue = function(v21)
                        return CFrame.fromEulerAnglesXYZ(math.rad(v21[1]), math.rad(v21[2]), (math.rad(v21[3]))) + v11[l_TransformSettings_0.Transform].Position;
                    end,
                    GetComponents = function(v22)
                        local v23, v24, v25 = v22:ToEulerAnglesXYZ();
                        return {
                            math.deg(v23),
                            math.deg(v24),
                            (math.deg(v25))
                        };
                    end
                },
                Validate = if not v9() then nil else function(v26)
                    if v8(v26, v10.Tool:getPayload()[l_TransformSettings_1][l_TransformSettings_0.Size]) then
                        return Enum.PropertyStatus.Ok, "";
                    else
                        return Enum.PropertyStatus.Error, l_Localization_0:getText("SelectionWarning", "OutOfBounds");
                    end;
                end,
                Value = v11[l_TransformSettings_0.Transform]
            },
            {
                Id = l_TransformSettings_0.MergeEmpty,
                Schema = {
                    Type = "Checkbox"
                }
            },
            {
                Id = l_TransformSettings_0.LiveEdit,
                Schema = {
                    Type = "Checkbox"
                }
            },
            {
                Id = l_TransformSettings_0.SnapToVoxels,
                Schema = {
                    Type = "Checkbox"
                }
            },
            {
                Id = l_TransformSettings_0.Apply,
                Layout = Enum.FillDirection.Vertical,
                Schema = {
                    Label = l_Localization_0:getText(l_TransformSettings_1, l_TransformSettings_0.Apply),
                    Type = "Button"
                }
            }
        }, {
            Category = l_TransformSettings_1,
            Data = v11,
            Overrides = v13
        });
    end
};


local l_script_FirstAncestor_0 = script:FindFirstAncestor("TerrainEditor");
local v1 = require(l_script_FirstAncestor_0.Src.Util.ApplyById);
local v2 = require(l_script_FirstAncestor_0.Src.Types);
local l_Category_0 = v2.Category;
local l_Storage_0 = v2.Storage;
local l_UpgradeSettings_0 = v2.UpgradeSettings;
local l_UpgradeSettings_1 = l_Category_0.UpgradeSettings;
local l_game_FastString_0 = game:GetFastString("Shorelines_LearnMoreUrl");
return {
    Storage = {
        [l_UpgradeSettings_0.Shorelines] = l_Storage_0.LocalSession
    },
    Generator = function(v8, v9, _, v11)
        return v1(v8, {
            {
                Id = l_UpgradeSettings_0.Shorelines,
                Schema = {
                    Id = l_UpgradeSettings_0.Shorelines,
                    Type = "Upgrade",
                    URL = l_game_FastString_0
                }
            }
        }, {
            Category = l_UpgradeSettings_1,
            Data = v9,
            Overrides = v11
        });
    end
};


local l_script_FirstAncestor_0 = script:FindFirstAncestor("TerrainEditor");
local v1 = require(l_script_FirstAncestor_0.Src.Flags.getFFlagTerrainEditorGenerationFeature);
local l_Category_0 = require(l_script_FirstAncestor_0.Src.Types).Category;
return {
    [l_Category_0.BiomeSettings] = require(script.Biome),
    [l_Category_0.BrushSettings] = require(script.Brush),
    [l_Category_0.BuildSettings] = if not v1() then nil else require(script.Build),
    [l_Category_0.ClearSettings] = require(script.Clear),
    [l_Category_0.HeightmapSettings] = require(script.Heightmap),
    [l_Category_0.MaterialSettings] = require(script.Material),
    [l_Category_0.SeaLevelSettings] = require(script.SeaLevel),
    [l_Category_0.SelectionSettings] = require(script.Selection),
    [l_Category_0.TransformSettings] = require(script.Transform),
    [l_Category_0.UpgradeSettings] = require(script.Upgrade)
};


local l_script_FirstAncestor_0 = script:FindFirstAncestor("TerrainEditor");
local v1 = require(script.Parent.BaseStamp);
local l_VoxelResolution_0 = require(l_script_FirstAncestor_0.Src.Resources.Constants).VoxelResolution;
local v3 = require(l_script_FirstAncestor_0.Src.Types);
local l_BuildSettings_0 = v3.BuildSettings;
local l_Category_0 = v3.Category;
local l_TerrainType_0 = v3.TerrainType;
local v7 = require(l_script_FirstAncestor_0.Src.Util.Generation.FractalNoise)(4, 3, 0.35);
local v8 = v1:new(l_TerrainType_0.Arctic);
v8.init = function(v9, v10, v11)
    v1.init(v9, v10, v11);
    return v9;
end;
v8.generateNoiseMap = function(v12)
    local v13 = v12._payload[l_Category_0.BuildSettings][l_BuildSettings_0.NoiseScale];
    local v14 = v12._payload[l_Category_0.BuildSettings][l_BuildSettings_0.AdvancedNoise].Children[l_BuildSettings_0.Offset];
    local v15 = v12._payload[l_Category_0.BuildSettings][l_BuildSettings_0.AdvancedNoise].Children[l_BuildSettings_0.Seed];
    v12._noiseMap = table.create(v12._rotatedSliceX * v12._rotatedSliceZ, 0);
    if v13 > 0 then
        local v16 = 50 / v13;
        for v17 = 1, v12._rotatedSliceX do
            for v18 = 1, v12._rotatedSliceZ do
                local v19 = v12:getSliceIndex(v17, v18);
                local v20 = v7((v17 * l_VoxelResolution_0 + l_VoxelResolution_0 / 2) + v14.X, (v18 * l_VoxelResolution_0 + l_VoxelResolution_0 / 2) + v14.Y, v15, v16);
                v12._noiseMap[v19] = v20 * v20;
            end;
        end;
    end;
end;
v8.getHeightFromNoise = function(v21, v22, v23, v24)
    return (math.clamp(v24 + (v21._sliceY * v23) * v22, 1, v21._sliceY));
end;
v8.generateHeightMap = function(v25)
    local v26 = v25._payload[l_Category_0.BuildSettings][l_BuildSettings_0.NoiseStrength];
    v25:createHeightMapWithNoise(v26, v25._sliceY * (1 - v26));
end;
return v8;


local l_script_FirstAncestor_0 = script:FindFirstAncestor("TerrainEditor");
local l_VoxelResolution_0 = require(l_script_FirstAncestor_0.Src.Resources.Constants).VoxelResolution;
local v2 = require(l_script_FirstAncestor_0.Src.Types);
local l_BuildSettings_0 = v2.BuildSettings;
local l_Category_0 = v2.Category;
local l_Generation_0 = l_script_FirstAncestor_0.Src.Util.Generation;
local v6 = require(l_Generation_0.GetBlendingFactorMap);
local v7 = require(l_Generation_0.GetMaterial);
local v8 = require(l_Generation_0.RotatePointInRectangle);
local v9 = require(l_script_FirstAncestor_0.Src.Flags.getFFlagTerrainEditorDebugMode);
local _ = Enum.Material.Ground;
local v11 = {};
local l_StarterGui_0 = game:GetService("StarterGui");
v11.__index = v11;
v11.new = function(v13, v14)
    local v15 = {
        _terrainType = v14
    };
    setmetatable(v15, v13);
    v13.__index = v13;
    return v15;
end;
v11.init = function(v16, v17, v18)
    v16._services = v18;
    v16._payload = v17;
    v16:setupRegion();
    return v16;
end;
v11.update = function(v19, v20, v21)
    local v22 = if not v21 then nil else v21[l_Category_0.BuildSettings];
    if ((v22 and v22[l_BuildSettings_0.OperationSource] == "Gizmo") and v22[l_BuildSettings_0.Transform] == v19._payload[l_Category_0.BuildSettings][l_BuildSettings_0.Transform]) and v22[l_BuildSettings_0.Size] == v19._payload[l_Category_0.BuildSettings][l_BuildSettings_0.Size] then
        return ;
    else
        v19._payload = v20;
        local v23 = true;
        local v24 = false;
        local v25 = false;
        local v26 = v19._payload[l_Category_0.BuildSettings][l_BuildSettings_0.AdvancedNoise].Children[l_BuildSettings_0.Rotation];
        if v22 then
            if not (not v22[l_BuildSettings_0.Transform] and not v22[l_BuildSettings_0.Size]) then
                local l_Size_0 = v19._region.Size;
                v19:revertRegion(v19._region);
                v19:setupRegion();
                if l_Size_0 ~= v19._region.Size then
                    v24 = true;
                end;
            end;
            local v28 = v22[l_BuildSettings_0.BlendingEdge];
            if v28 then
                v19:updateBlendingFactorMap(v28);
            end;
            v25 = not not v22[l_BuildSettings_0.AdvancedNoise] and if (v22[l_BuildSettings_0.AdvancedNoise].Children and v22[l_BuildSettings_0.AdvancedNoise].Children[l_BuildSettings_0.Rotation]) and v19._addRotationY then v19._rotationY ~= v26 else false;
            if not (not ((((v25 or v22[l_BuildSettings_0.Transform] and not v24) or v22[l_BuildSettings_0.BlendingEdge]) or v22[l_BuildSettings_0.Material]) or v22[l_BuildSettings_0.MaterialLUT]) and not v22[l_BuildSettings_0.WaterLevel]) then
                v23 = false;
            end;
        end;
        v19._addBlending = v19._payload[l_Category_0.BuildSettings][l_BuildSettings_0.BlendingEdge] > 0;
        v19._rotationY = v26;
        if (not (v19._addRotationY or not v26) and v26 > 0) and v26 < 360 then
            v19._addRotationY = true;
        end;
        v19._rotatedXOffset = not v19._addRotationY and 0 or math.floor((v19._rotatedSlice - v19._sliceX) / 2);
        v19._rotatedZOffset = not v19._addRotationY and 0 or math.floor((v19._rotatedSlice - v19._sliceZ) / 2);
        v19._rotatedSliceX = if not v19._addRotationY then v19._sliceX else v19._rotatedSlice;
        v19._rotatedSliceZ = if not v19._addRotationY then v19._sliceZ else v19._rotatedSlice;
        v19:generateStamp(v23, v25);
        return ;
    end;
end;
v11.getTerrainType = function(v29)
    return v29._terrainType;
end;
v11.setupRegion = function(v30)
    local l_Position_0 = v30._payload[l_Category_0.BuildSettings][l_BuildSettings_0.Transform].Position;
    local v32 = v30._payload[l_Category_0.BuildSettings][l_BuildSettings_0.Size] / 2;
    v30._region = Region3.new(l_Position_0 - v32, l_Position_0 + v32);
    v30._region = v30._region:ExpandToGrid(l_VoxelResolution_0);
    v30._sliceX = v30._region.Size.X / l_VoxelResolution_0;
    v30._sliceY = v30._region.Size.Y / l_VoxelResolution_0;
    v30._sliceZ = v30._region.Size.Z / l_VoxelResolution_0;
    v30._rotatedSlice = math.ceil((math.sqrt(v30._sliceX ^ 2 + v30._sliceZ ^ 2)));
    v30:cacheRegion(v30._region);
    v30:updateBlendingFactorMap(v30._payload[l_Category_0.BuildSettings][l_BuildSettings_0.BlendingEdge]);
end;
v11.getIndex = function(v33, v34, v35)
    return v33._sliceZ * (v34 - 1) + v35;
end;
v11.getRotatedIndex = function(v36, v37, v38)
    return v36._rotatedSlice * (v37 - 1) + v38;
end;
v11.getSliceIndex = function(v39, v40, v41)
    if not v39._addRotationY then
        return v39:getIndex(v40, v41);
    else
        return v39:getRotatedIndex(v40, v41);
    end;
end;
v11.getRotatedIndexWithOffset = function(v42, v43, v44)
    return v42:getSliceIndex(v43 + v42._rotatedXOffset, v44 + v42._rotatedZOffset);
end;
v11.generateStamp = function(v45, v46, v47)
    if not v45._region or v45._region.Size == Vector3.zero then
        return ;
    else
        if v46 then
            debug.profilebegin("TG_GenerateNoise");
            v45:generateNoiseMap();
            debug.profileend();
            debug.profilebegin("TG_GenerateHeight");
            v45:generateHeightMap();
            debug.profileend();
        end;
        if not (not v45._addRotationY or not v46 and not v47) then
            debug.profilebegin("TG_RotateHeight");
            v45:generateRotatedHeightMap();
            debug.profileend();
        end;
        debug.profilebegin("TG_BlendHeight");
        v45:blendHeightMap();
        debug.profileend();
        debug.profilebegin("TG_GenerateOccupancyMap");
        v45:generateOccupancyMap();
        debug.profileend();
        debug.profilebegin("TG_GenerateSlopeMap");
        v45:generateSlopeMap();
        debug.profileend();
        debug.profilebegin("TG_GenerateMaterial");
        v45:generateMaterialMap();
        debug.profileend();
        debug.profilebegin("TG_BlendMaterialMap");
        v45:blendMaterialMap();
        debug.profileend();
        debug.profilebegin("TG_PostProcessing");
        v45:postProcessing();
        debug.profileend();
        if v9() then
            v45:debugDraw();
        end;
        v45._services.Terrain:WriteVoxels(v45._region, l_VoxelResolution_0, v45._materialMap, v45._occupancyMap);
        return ;
    end;
end;
v11.generateNoiseMap = function(v48)
    v48._noiseMap = table.create(v48._rotatedSliceX * v48._rotatedSliceZ, 0);
end;
v11.getHeightFromNoise = function(v49, v50, v51, v52)
    return (math.clamp(v52 + (v49._sliceY * v51) * v50, 0, v49._sliceY));
end;
v11.createHeightMapWithNoise = function(v53, ...)
    local v54 = v53._sliceX * v53._sliceZ;
    if not v53._heightMap or #v53._heightMap ~= v54 then
        v53._heightMap = table.create(v54, 0);
    end;
    if not v53._addRotationY then
        if v9() and v54 ~= #v53._noiseMap then
            warn("NoiseMap has wrong size");
        end;
        for v55 = 1, v54 do
            v53._heightMap[v55] = v53:getHeightFromNoise(v53._noiseMap[v55], ...);
        end;
        return ;
    else
        local v56 = v53._rotatedSlice * v53._rotatedSlice;
        if not v53._outterHeightMap or #v53._outterHeightMap ~= v56 then
            v53._outterHeightMap = table.create(v56, 0);
        end;
        if v9() and v56 ~= #v53._noiseMap then
            warn("NoiseMap has wrong size");
        end;
        for v57 = 1, v56 do
            v53._outterHeightMap[v57] = v53:getHeightFromNoise(v53._noiseMap[v57], ...);
        end;
        return ;
    end;
end;
v11.generateHeightMap = function(v58)
    local v59 = v58._payload[l_Category_0.BuildSettings][l_BuildSettings_0.NoiseStrength] / 2;
    v58:createHeightMapWithNoise(v59, v58._sliceY * (1 - v59));
end;
v11.generateRotatedHeightMap = function(v60)
    local v61 = v8(v60._sliceX, v60._sliceZ, (math.rad(v60._rotationY)));
    for v62 = 1, v60._sliceX do
        for v63 = 1, v60._sliceZ do
            local v64, v65 = v61(v62 - 0.5, v63 - 0.5);
            v60._heightMap[v60:getIndex(v62, v63)] = v60._outterHeightMap[v60:getRotatedIndex(math.clamp(math.floor(v64 + v60._rotatedXOffset), 1, v60._rotatedSlice), (math.clamp(math.floor(v65 + v60._rotatedZOffset), 1, v60._rotatedSlice)))];
        end;
    end;
end;
v11.generateSlopeMap = function(v66)
    v66._slopeMap = table.create(v66._sliceX * v66._sliceZ, 0);
    v66._minNeighborHeight = table.create(v66._sliceX * v66._sliceZ, 0);
    local v67 = {
        {
            -1,
            0
        },
        {
            1,
            0
        },
        {
            0,
            -1
        },
        {
            0,
            1
        },
        {
            -1,
            -1
        },
        {
            -1,
            1
        },
        {
            1,
            -1
        },
        {
            1,
            1
        }
    };
    for v68 = 1, v66._sliceX do
        for v69 = 1, v66._sliceZ do
            local v70 = v66:getIndex(v68, v69);
            local v71 = v66._heightMap[v70];
            local v72 = math.floor(v71);
            local v73 = 0;
            local v74 = 0;
            local v75 = 0;
            local v76 = 0;
            local v77 = 0;
            local v78 = 0;
            v66._minNeighborHeight[v70] = v72;
            for _, v80 in v67, nil, nil do
                local v81 = v68 + v80[1];
                local v82 = v69 + v80[2];
                local v83 = false;
                if v81 > 0 then
                    v83 = false;
                    if v81 <= v66._sliceX then
                        v83 = false;
                        if v82 > 0 then
                            v83 = v82 <= v66._sliceZ;
                        end;
                    end;
                end;
                local v84 = not v83 and 0 or v66._heightMap[v66:getIndex(v81, v82)];
                v66._minNeighborHeight[v70] = math.min(v66._minNeighborHeight[v70], (math.floor(v84)));
                if v83 then
                    if v80[1] == 0 then
                        v73 = v73 + math.abs(v84 - v71);
                        v74 = v74 + 1;
                    elseif v80[2] == 0 then
                        v75 = v75 + math.abs(v84 - v71);
                        v76 = v76 + 1;
                    else
                        v77 = v77 + math.abs(v84 - v71);
                        v78 = v78 + 1;
                    end;
                end;
            end;
            v73 = v74 == 0 and 0 or v73 / v74;
            v75 = v76 == 0 and 0 or v75 / v76;
            v77 = v78 == 0 and 0 or v77 / v78;
            v66._slopeMap[v70] = math.atan((math.sqrt(((v73 * v73 + v75 * v75) + v77 * v77) / 4)));
        end;
    end;
end;
v11.generateOccupancyMap = function(v85)
    if v9() and v85._sliceX * v85._sliceZ ~= #v85._heightMap then
        warn("HeightMap has wrong size Can't generate OccupancyMap.");
    end;
    v85._occupancyMap = table.create(v85._sliceX);
    for v86 = 1, v85._sliceX do
        v85._occupancyMap[v86] = table.create(v85._sliceY);
        for v87 = 1, v85._sliceY do
            v85._occupancyMap[v86][v87] = table.create(v85._sliceZ, 0);
        end;
    end;
    for v88 = 1, v85._sliceX do
        local v89 = v85._occupancyMap[v88];
        for v90 = 1, v85._sliceZ do
            local v91 = v85._heightMap[v85:getIndex(v88, v90)];
            local v92 = math.floor(v91);
            for v93 = 1, v92 do
                v89[v93][v90] = 1;
            end;
            if v91 - v92 > 0 then
                v89[math.min(v92 + 1, v85._sliceY)][v90] = v91 - v92;
            end;
        end;
    end;
end;
v11.generateMaterialMap = function(v94)
    local v95 = v94._payload[l_Category_0.BuildSettings][l_BuildSettings_0.MaterialLUT];
    v94._materialMap = table.create(v94._sliceX);
    for v96 = 1, v94._sliceX do
        v94._materialMap[v96] = table.create(v94._sliceY);
        for v97 = 1, v94._sliceY do
            v94._materialMap[v96][v97] = table.create(v94._sliceZ, v95.fallbackMaterial);
        end;
    end;
    for v98 = 1, v94._sliceX do
        local v99 = v94._materialMap[v98];
        for v100 = 1, v94._sliceZ do
            local v101 = v94:getIndex(v98, v100);
            local v102 = math.max(1, v94._minNeighborHeight[v101] - 1);
            local v103 = math.min(math.ceil(v94._heightMap[v101]), v94._sliceY);
            local l_v95_SlopeIndex_0 = v95:GetSlopeIndex(v94._slopeMap[v101]);
            if not v94._fillBottomPositions or not v94._fillBottomPositions[v101] then
                for v105 = v102, v103 do
                    v99[v105][v100] = v95:GetValueByIndex(v105, v94._sliceY, l_v95_SlopeIndex_0);
                end;
            else
                for v106 = 1, v94._sliceY do
                    v99[v106][v100] = v95.fillMaterial;
                end;
            end;
        end;
    end;
end;
v11.fillInternalMaterial = function(v107)
    local v108 = v107._payload[l_Category_0.BuildSettings][l_BuildSettings_0.MaterialLUT];
    for v109 = 1, v107._sliceX do
        local v110 = v107._materialMap[v109];
        for v111 = 1, v107._sliceZ do
            local v112 = v107:getIndex(v109, v111);
            local v113 = v107._minNeighborHeight[v112] - 2;
            if v113 >= 1 then
                local l_v108_SlopeIndex_0 = v108:GetSlopeIndex(v107._slopeMap[v112]);
                if not (v107._fillBottomPositions and v107._fillBottomPositions[v112]) then
                    for v115 = 1, v113 do
                        v110[v115][v111] = v108:GetValueByIndex(v115, v107._sliceY, l_v108_SlopeIndex_0);
                    end;
                end;
            end;
        end;
    end;
    v107._services.Terrain:WriteVoxels(v107._region, l_VoxelResolution_0, v107._materialMap, v107._occupancyMap);
end;
v11.updateBlendingFactorMap = function(v116, v117)
    v116._blendingFactorMap = table.create(v116._sliceX * v116._sliceZ, 0);
    if v117 > 0 then
        v116._blendingFactorMap = v6(Vector2.new(v116._sliceX, v116._sliceZ), {
            CurveWidth = 1,
            Distance = (1 - v117) * 0.9,
            PreserveDistance = 0.7 - v117 / 5,
            PreserveRatio = 0,
            RoundCorner = 1
        });
    end;
end;
v11.blendHeightMap = function(v118)
    if v9() and #v118._heightmapCache ~= #v118._heightMap then
        warn("HeightMap has wrong size Can't blend height maps.");
    end;
    for v119 = 1, #v118._heightMap do
        local v120 = v118._heightMap[v119];
        local v121 = v118._heightmapCache[v119];
        if not (not v121 or not v120) and v120 < v121 then
            v120 = v121;
            v118._heightMap[v119] = v121;
            v118._blendingFactorMap[v119] = 1;
        elseif v118._addBlending then
            local v122 = v118._blendingFactorMap[v119];
            v118._heightMap[v119] = (1 - v122) * v120 + v122 * v121;
        end;
        v118._heightMap[v119] = math.clamp(v118._heightMap[v119], 0, v118._sliceY);
    end;
end;
v11.blendMaterialMap = function(v123)
    local v124 = {
        BlendingFactor = 0,
        EdgePosition = 0.8,
        Width = 0.2
    };
    for v125 = 1, v123._sliceX do
        for v126 = 1, v123._sliceZ do
            local v127 = v123:getIndex(v125, v126);
            local v128 = math.max(1, v123._minNeighborHeight[v127] - 1);
            local v129 = math.min(math.ceil(v123._heightMap[v127]), v123._sliceY);
            v124.BlendingFactor = v123._blendingFactorMap[v127];
            for v130 = v128, v129 do
                local v131 = v123._materialMap[v125][v130][v126];
                local v132 = v123._materialCache[v125][v130][v126];
                if v132 ~= Enum.Material.Air then
                    v123._materialMap[v125][v130][v126] = v7.Blend(v131, v132, v124);
                end;
            end;
        end;
    end;
end;
v11.postProcessing = function(_)
end;
v11.commit = function(v134)
    v134:fillInternalMaterial();
    v134:clearRegionCache();
end;
v11.destroy = function(v135)
    v135:revertRegion(v135._region);
    v135:clearRegionCache();
end;
v11.cacheRegion = function(v136, v137)
    local v138, v139 = v136._services.Terrain:ReadVoxels(v137, l_VoxelResolution_0);
    v136._materialCache = v138;
    v136._occupancyCache = v139;
    v136._heightmapCache = table.create(v136._sliceX * v136._sliceZ, 0);
    for v140 = 1, v136._sliceX do
        for v141 = 1, v136._sliceZ do
            local v142 = v136:getIndex(v140, v141);
            for v143 = v136._sliceY, 1, -1 do
                if v136._occupancyCache[v140][v143][v141] ~= 0 and v136._materialCache[v140][v143][v141] ~= Enum.Material.Air then
                    v136._heightmapCache[v142] = (v143 - 1) + v136._occupancyCache[v140][v143][v141];
                    break;
                end;
            end;
        end;
    end;
end;
v11.revertRegion = function(v144, v145)
    if not ((not v145 or not v144._materialCache) or not v144._occupancyCache) then
        v144._services.Terrain:WriteVoxels(v145, l_VoxelResolution_0, v144._materialCache, v144._occupancyCache);
    end;
end;
v11.clearRegionCache = function(v146)
    local v147 = nil;
    local v148 = nil;
    v146._materialCache = v147;
    v146._occupancyCache = v148;
    v146._heightmapCache = nil;
end;
v11.debugDrawArray = function(v149, v150, v151, v152)
    local l_TG_DEBUG_DRAW_UI_0 = l_StarterGui_0:FindFirstChild("TG_DEBUG_DRAW_UI");
    local l_l_TG_DEBUG_DRAW_UI_0_FirstChild_0 = l_TG_DEBUG_DRAW_UI_0:FindFirstChild(v150 .. "Frame");
    if not l_l_TG_DEBUG_DRAW_UI_0_FirstChild_0 then
        l_l_TG_DEBUG_DRAW_UI_0_FirstChild_0 = Instance.new("Frame");
        l_l_TG_DEBUG_DRAW_UI_0_FirstChild_0.Name = v150 .. "Frame";
        l_l_TG_DEBUG_DRAW_UI_0_FirstChild_0.Parent = l_TG_DEBUG_DRAW_UI_0;
        l_l_TG_DEBUG_DRAW_UI_0_FirstChild_0.AutomaticSize = Enum.AutomaticSize.XY;
        local l_UIListLayout_0 = Instance.new("UIListLayout");
        l_UIListLayout_0.Parent = l_l_TG_DEBUG_DRAW_UI_0_FirstChild_0;
        l_UIListLayout_0.FillDirection = Enum.FillDirection.Horizontal;
    end;
    if not l_l_TG_DEBUG_DRAW_UI_0_FirstChild_0:FindFirstChild(v150 .. "Text") then
        local l_TextLabel_0 = Instance.new("TextLabel");
        l_TextLabel_0.Name = v150 .. "Text";
        l_TextLabel_0.Parent = l_l_TG_DEBUG_DRAW_UI_0_FirstChild_0;
        l_TextLabel_0.Text = v150;
        l_TextLabel_0.Size = UDim2.new(0, 150, 0, 20);
    end;
    local v157 = v150 .. "Label";
    local l_l_l_TG_DEBUG_DRAW_UI_0_FirstChild_0_FirstChild_0 = l_l_TG_DEBUG_DRAW_UI_0_FirstChild_0:FindFirstChild(v157);
    if not l_l_l_TG_DEBUG_DRAW_UI_0_FirstChild_0_FirstChild_0 then
        l_l_l_TG_DEBUG_DRAW_UI_0_FirstChild_0_FirstChild_0 = Instance.new("ImageLabel");
        l_l_l_TG_DEBUG_DRAW_UI_0_FirstChild_0_FirstChild_0.Name = v157;
        l_l_l_TG_DEBUG_DRAW_UI_0_FirstChild_0_FirstChild_0.Position = UDim2.new(0, 0, 0, 0);
        l_l_l_TG_DEBUG_DRAW_UI_0_FirstChild_0_FirstChild_0.BackgroundTransparency = 1;
        l_l_l_TG_DEBUG_DRAW_UI_0_FirstChild_0_FirstChild_0.Parent = l_l_TG_DEBUG_DRAW_UI_0_FirstChild_0;
    end;
    local l_l_l_l_TG_DEBUG_DRAW_UI_0_FirstChild_0_FirstChild_0_FirstChild_0 = l_l_l_TG_DEBUG_DRAW_UI_0_FirstChild_0_FirstChild_0:FindFirstChild(v150);
    if not l_l_l_l_TG_DEBUG_DRAW_UI_0_FirstChild_0_FirstChild_0_FirstChild_0 then
        l_l_l_l_TG_DEBUG_DRAW_UI_0_FirstChild_0_FirstChild_0_FirstChild_0 = Instance.new("EditableImage");
        l_l_l_l_TG_DEBUG_DRAW_UI_0_FirstChild_0_FirstChild_0_FirstChild_0.Name = v150;
    end;
    l_l_l_l_TG_DEBUG_DRAW_UI_0_FirstChild_0_FirstChild_0_FirstChild_0:Resize(Vector2.new(v149._sliceX, v149._sliceZ));
    l_l_l_TG_DEBUG_DRAW_UI_0_FirstChild_0_FirstChild_0.Size = UDim2.new(0, v149._sliceX, 0, v149._sliceZ);
    local v160 = table.create((v149._sliceX * v149._sliceZ) * 4, 1);
    for v161 = 1, l_l_l_l_TG_DEBUG_DRAW_UI_0_FirstChild_0_FirstChild_0_FirstChild_0.Size.X do
        for v162 = 1, l_l_l_l_TG_DEBUG_DRAW_UI_0_FirstChild_0_FirstChild_0_FirstChild_0.Size.Y do
            local v163 = v149:getIndex(v161, v162);
            local v164 = 1 + (((v162 - 1) * l_l_l_l_TG_DEBUG_DRAW_UI_0_FirstChild_0_FirstChild_0_FirstChild_0.Size.X + v161) - 1) * 4;
            local v165 = v151[v163] / v152;
            v160[v164] = v165;
            v160[v164 + 1] = v165;
            v160[v164 + 2] = v165;
        end;
    end;
    l_l_l_l_TG_DEBUG_DRAW_UI_0_FirstChild_0_FirstChild_0_FirstChild_0:WritePixels(Vector2.zero, l_l_l_l_TG_DEBUG_DRAW_UI_0_FirstChild_0_FirstChild_0_FirstChild_0.Size, v160);
    l_l_l_l_TG_DEBUG_DRAW_UI_0_FirstChild_0_FirstChild_0_FirstChild_0.Parent = l_l_l_TG_DEBUG_DRAW_UI_0_FirstChild_0_FirstChild_0;
    l_l_l_TG_DEBUG_DRAW_UI_0_FirstChild_0_FirstChild_0.Size = UDim2.new(0, 200, 0, 200);
end;
v11.debugDraw = function(v166)
    if not l_StarterGui_0:FindFirstChild("TG_DEBUG_DRAW_UI") then
        local l_ScreenGui_0 = Instance.new("ScreenGui");
        l_ScreenGui_0.Name = "TG_DEBUG_DRAW_UI";
        l_ScreenGui_0.Parent = l_StarterGui_0;
        Instance.new("UIListLayout").Parent = l_ScreenGui_0;
    end;
    v166:debugDrawArray("Noisemap", v166._noiseMap, 1, 0);
    v166:debugDrawArray("Heightmap", v166._heightMap, v166._sliceY);
    v166:debugDrawArray("NeighborHeightMap", v166._minNeighborHeight, v166._sliceY);
    v166:debugDrawArray("SlopeMap", v166._slopeMap, 1.5707963267948966);
    v166:debugDrawArray("Blending", v166._blendingFactorMap, 1);
end;
return v11;


local l_script_FirstAncestor_0 = script:FindFirstAncestor("TerrainEditor");
local v1 = require(script.Parent.MountainBaseStamp);
local v2 = require(l_script_FirstAncestor_0.Src.Types);
local l_BuildSettings_0 = v2.BuildSettings;
local l_Category_0 = v2.Category;
local v5 = v1:new(v2.TerrainType.Crater);
v5.init = function(v6, v7, v8)
    v1.init(v6, v7, v8);
    return v6;
end;
v5.generateNoiseMap = function(v9)
    local v10 = v9._payload[l_Category_0.BuildSettings][l_BuildSettings_0.NoiseScale];
    local v11 = v9._payload[l_Category_0.BuildSettings][l_BuildSettings_0.NoiseStrength];
    local v12 = v9._payload[l_Category_0.BuildSettings][l_BuildSettings_0.FillBottom];
    local v13 = v9._payload[l_Category_0.BuildSettings][l_BuildSettings_0.RimHeight];
    if v12 and v13 then
        local v14 = {
            center2d = Vector2.new(0.5, 0.5),
            hillWidth = 0.2,
            hillHeight = 1.7
        };
        v9._noiseMap = table.create(v9._rotatedSliceX * v9._rotatedSliceZ, 0);
        v9._fillBottomPositions = table.create(v9._sliceX * v9._sliceZ, false);
        for v15 = 1, v9._rotatedSliceX do
            local v16 = v15 - v9._rotatedXOffset;
            for v17 = 1, v9._rotatedSliceZ do
                v9._noiseMap[v9:getSliceIndex(v15, v17)] = v9:getGaussianHillHeight(v16, v17 - v9._rotatedZOffset, v14, nil);
            end;
        end;
        if v10 > 0 and v11 > 0 then
            v9:addErosion();
        end;
        local v18 = 1 - ((1 - v13) * 0.25 + 0.5);
        local v19 = 1 - v12;
        for v20 = 1, v9._sliceX do
            for v21 = 1, v9._sliceZ do
                local v22 = v9:getRotatedIndexWithOffset(v20, v21);
                local v23 = v9._noiseMap[v22];
                if v18 < v23 then
                    v9._noiseMap[v22] = v18 - (1 - (1 - math.clamp(if v19 > 0 then (v23 - v18) / v19 else 0, 0, 1)) ^ 4) * v19;
                    v9._fillBottomPositions[v9:getIndex(v20, v21)] = true;
                end;
            end;
        end;
        return ;
    else
        warn("Missing parameters");
        return ;
    end;
end;
v5.getHeightFromNoise = function(v24, v25, v26, v27)
    return (math.clamp(v24._sliceY * (v27 + math.clamp(v25, -1, v26)), 1, v24._sliceY));
end;
v5.generateHeightMap = function(v28)
    local v29 = v28._payload[l_Category_0.BuildSettings][l_BuildSettings_0.RimHeight] or 0;
    v28:createHeightMapWithNoise((1 + v29) * 0.25, (1 - v29) * 0.25 + 0.5);
end;
v5.blendHeightMap = function(v30)
    for v31 = 1, #v30._heightMap do
        local v32 = v30._heightMap[v31];
        local v33 = v30._heightmapCache[v31];
        if v32 < v33 then
            if not v30._fillBottomPositions[v31] then
                v32 = v33;
                v30._heightMap[v31] = v33;
                v30._blendingFactorMap[v31] = 1;
            else
                v33 = v32;
                v30._heightmapCache[v31] = v32;
                v30._blendingFactorMap[v31] = 0;
            end;
        end;
        if v30._addBlending then
            local v34 = v30._blendingFactorMap[v31];
            v30._heightMap[v31] = (1 - v34) * v32 + v34 * v33;
        end;
    end;
end;
return v5;


local l_script_FirstAncestor_0 = script:FindFirstAncestor("TerrainEditor");
local v1 = require(script.Parent.BaseStamp);
local l_VoxelResolution_0 = require(l_script_FirstAncestor_0.Src.Resources.Constants).VoxelResolution;
local v3 = require(l_script_FirstAncestor_0.Src.Types);
local l_BuildSettings_0 = v3.BuildSettings;
local l_Category_0 = v3.Category;
local l_TerrainType_0 = v3.TerrainType;
local l_Generation_0 = l_script_FirstAncestor_0.Src.Util.Generation;
local v8 = require(l_Generation_0.FractalNoise);
local v9 = require(l_Generation_0.Filter);
local v10 = v8(1, 1, 1);
local v11 = v1:new(l_TerrainType_0.Desert);
v11.init = function(v12, v13, v14)
    v1.init(v12, v13, v14);
    return v12;
end;
v11.generateNoiseMap = function(v15)
    local v16 = v15._payload[l_Category_0.BuildSettings][l_BuildSettings_0.NoiseScale];
    local v17 = v15._payload[l_Category_0.BuildSettings][l_BuildSettings_0.AdvancedNoise].Children[l_BuildSettings_0.Offset];
    local v18 = v15._payload[l_Category_0.BuildSettings][l_BuildSettings_0.AdvancedNoise].Children[l_BuildSettings_0.Seed];
    v15._noiseMap = table.create(v15._rotatedSliceX * v15._rotatedSliceZ, 0);
    if v16 > 0 then
        local v19 = 50 / v16;
        for v20 = 1, v15._rotatedSliceX do
            for v21 = 1, v15._rotatedSliceZ do
                v15._noiseMap[v15:getSliceIndex(v20, v21)] = v9.Ridge(v10((v20 * l_VoxelResolution_0 + l_VoxelResolution_0 / 2) + v17.X, (v21 * l_VoxelResolution_0 + l_VoxelResolution_0 / 2) + v17.Y, v18, v19) * 0.5 + 0.5) / 2;
            end;
        end;
    end;
end;
v11.getHeightFromNoise = function(v22, v23, v24, v25)
    return (math.clamp(v25 + (v22._sliceY * v24) * v23, 1, v22._sliceY));
end;
v11.generateHeightMap = function(v26)
    local v27 = v26._payload[l_Category_0.BuildSettings][l_BuildSettings_0.NoiseStrength];
    v26:createHeightMapWithNoise(v27, v26._sliceY * (1 - v27));
end;
return v11;


local l_script_FirstAncestor_0 = script:FindFirstAncestor("TerrainEditor");
local v1 = require(script.Parent.BaseStamp);
local l_VoxelResolution_0 = require(l_script_FirstAncestor_0.Src.Resources.Constants).VoxelResolution;
local v3 = require(l_script_FirstAncestor_0.Src.Types);
local l_BuildSettings_0 = v3.BuildSettings;
local l_Category_0 = v3.Category;
local l_TerrainType_0 = v3.TerrainType;
local v7 = require(l_script_FirstAncestor_0.Src.Flags.getFFlagTerrainGenerationFixLakeNoiseRatio);
local v8 = if not v7() then {
    BOTTOM_AMPLITUDE = 0.5,
    BOTTOM_FREQUENCY = 50,
    SHAPE_AMPLITUDE = 0.3,
    SHAPE_FREQUENCY = 10,
    SIDE_AMPLITUDE = 0.1,
    SIDE_FREQUENCY = 100
} else {
    BOTTOM_AMPLITUDE = 0.5,
    BOTTOM_FREQUENCY = 0.125,
    SHAPE_AMPLITUDE = 0.15,
    SHAPE_FREQUENCY = 0.025,
    SIDE_AMPLITUDE = 0.1,
    SIDE_FREQUENCY = 0.25
};
local v9 = Vector2.new(0.5, 0.5);
local v10 = v1:new(l_TerrainType_0.Lake);
v10.init = function(v11, v12, v13)
    v1.init(v11, v12, v13);
    return v11;
end;
v10.getLakeHeight = function(v14, v15, v16, v17)
    local l_width_0 = v16.width;
    local l_bankSize_0 = v16.bankSize;
    local l_slope_0 = v16.slope;
    local l_regionSize_0 = v16.regionSize;
    local l_amplitude_0 = v17.amplitude;
    local l_frequency_0 = v17.frequency;
    local l_offset_0 = v17.offset;
    local v25 = v17.seed or 12345;
    local v26 = v25 * 1.5 + 17;
    local v27 = Vector2.new(v15.X / v14._sliceX, v15.Y / v14._sliceZ);
    local v28 = if not v7() then v27 + l_offset_0 else Vector2.new(v15.X * l_VoxelResolution_0 + l_VoxelResolution_0 / 2, v15.Y * l_VoxelResolution_0 + l_VoxelResolution_0 / 2) + l_offset_0;
    local l_magnitude_0 = (v27 - v9).magnitude;
    l_width_0 = math.min(l_width_0, 0.45);
    local v30 = l_magnitude_0 + (math.clamp(math.noise((l_frequency_0 * v8.SHAPE_FREQUENCY) * v28.X, (l_frequency_0 * v8.SHAPE_FREQUENCY) * v28.Y, v25), -1, 1) * l_amplitude_0) * v8.SHAPE_AMPLITUDE;
    if v30 > 0.5 then
        return 0;
    else
        local v31 = math.tan((l_slope_0 * 3.141592653589793) / 180) * (math.min(l_regionSize_0.X, l_regionSize_0.Z) / l_regionSize_0.Y);
        local v32 = -v31 * (v30 - l_width_0);
        local v33 = (l_bankSize_0 * v31) * l_width_0;
        if v33 < v32 then
            v32 = (-v31 * 4) * (v30 - (-(v33 / v31) + l_width_0)) + v33;
            if v32 > 1 then
                return 1 - (math.noise((l_frequency_0 * v8.BOTTOM_FREQUENCY) * v28.X, (l_frequency_0 * v8.BOTTOM_FREQUENCY) * v28.Y, v26) * l_amplitude_0) * v8.BOTTOM_AMPLITUDE;
            else
                v32 = v32 + (math.noise((l_frequency_0 * v8.SIDE_FREQUENCY) * v28.X, (l_frequency_0 * v8.SIDE_FREQUENCY) * v28.Y, v26) * l_amplitude_0) * v8.SIDE_AMPLITUDE;
            end;
        end;
        return v32;
    end;
end;
v10.generateNoiseMap = function(v34)
    local v35 = v34._payload[l_Category_0.BuildSettings][l_BuildSettings_0.NoiseScale];
    local v36 = v34._payload[l_Category_0.BuildSettings][l_BuildSettings_0.NoiseStrength];
    local v37 = v34._payload[l_Category_0.BuildSettings][l_BuildSettings_0.AdvancedNoise].Children[l_BuildSettings_0.Offset];
    local v38 = v34._payload[l_Category_0.BuildSettings][l_BuildSettings_0.AdvancedNoise].Children[l_BuildSettings_0.Seed];
    local v39 = v34._payload[l_Category_0.BuildSettings][l_BuildSettings_0.BankSize];
    if v39 then
        v34._noiseMap = table.create(v34._rotatedSliceX * v34._rotatedSliceZ, 0);
        for v40 = 1, v34._sliceX do
            for v41 = 1, v34._sliceZ do
                local v42 = v34:getRotatedIndexWithOffset(v40, v41);
                if not ((v40 ~= 1 and v40 ~= v34._sliceX) and v41 ~= 1) or v41 == v34._sliceZ then
                    v34._noiseMap[v42] = 0;
                else
                    v34._noiseMap[v42] = v34:getLakeHeight(Vector2.new(v40, v41), {
                        bankSize = v39,
                        regionSize = v34._region.Size,
                        slope = 22,
                        width = 0.45
                    }, {
                        frequency = v35,
                        amplitude = v36,
                        offset = v37,
                        seed = v38
                    });
                end;
            end;
        end;
        return ;
    else
        warn("BankSize not provided");
        return ;
    end;
end;
v10.getHeightFromNoise = function(v43, v44)
    return (math.clamp(v43._sliceY * (1 - math.clamp(v44, -1, 1)), 1, v43._sliceY));
end;
v10.generateHeightMap = function(v45)
    v45:createHeightMapWithNoise();
end;
v10.blendHeightMap = function(v46)
    for v47 = 1, #v46._heightMap do
        local v48 = v46._heightMap[v47];
        local v49 = v46._heightmapCache[v47];
        if v48 < v49 then
            v49 = v48;
            v46._heightmapCache[v47] = v48;
            v46._blendingFactorMap[v47] = 0;
        end;
        if v46._addBlending then
            local v50 = v46._blendingFactorMap[v47];
            v46._heightMap[v47] = (1 - v50) * v48 + v50 * v49;
        end;
    end;
end;
v10.postProcessing = function(v51)
    local v52 = v51._payload[l_Category_0.BuildSettings][l_BuildSettings_0.WaterLevel];
    if v52 and v52 > 0 then
        for v53 = 1, v51._sliceY do
            if v53 / v51._sliceY < v52 then
                for v54 = 1, v51._sliceX do
                    for v55 = 1, v51._sliceZ do
                        local v56 = v51:getIndex(v54, v55);
                        local v57 = true;
                        if v51._materialMap[v54][v53][v55] ~= Enum.Material.Air then
                            v57 = v51._occupancyMap[v54][v53][v55] == 0;
                        end;
                        if not (not (v51._blendingFactorMap[v56] <= 0) or not v57) then
                            v51._materialMap[v54][v53][v55] = Enum.Material.Water;
                            v51._occupancyMap[v54][v53][v55] = 1;
                        end;
                    end;
                end;
            else
                break;
            end;
        end;
    end;
end;
return v10;


local l_script_FirstAncestor_0 = script:FindFirstAncestor("TerrainEditor");
local v1 = require(script.Parent.MountainBaseStamp);
local v2 = require(l_script_FirstAncestor_0.Src.Types);
local l_BuildSettings_0 = v2.BuildSettings;
local l_Category_0 = v2.Category;
local l_TerrainType_0 = v2.TerrainType;
local v6 = require(l_script_FirstAncestor_0.Src.Util.Generation.GetBlendingFactorMap);
local v7 = v1:new(l_TerrainType_0.Mesa);
v7.init = function(v8, v9, v10)
    v1.init(v8, v9, v10);
    return v8;
end;
v7.generateNoiseMap = function(v11)
    local v12 = v11._payload[l_Category_0.BuildSettings][l_BuildSettings_0.NoiseScale];
    local v13 = v11._payload[l_Category_0.BuildSettings][l_BuildSettings_0.NoiseStrength];
    local v14 = v11._payload[l_Category_0.BuildSettings][l_BuildSettings_0.AdvancedNoise].Children[l_BuildSettings_0.Offset];
    local v15 = v11._payload[l_Category_0.BuildSettings][l_BuildSettings_0.AdvancedNoise].Children[l_BuildSettings_0.Seed];
    local v16 = v11._payload[l_Category_0.BuildSettings][l_BuildSettings_0.CliffSlope];
    local v17 = v11._payload[l_Category_0.BuildSettings][l_BuildSettings_0.TopRadius];
    local v18 = v11._payload[l_Category_0.BuildSettings][l_BuildSettings_0.RimHeight];
    v11._noiseMap = table.create(v11._sliceX * v11._sliceZ, 0);
    if v17 and v18 then
        local v19 = {
            center2d = Vector2.new(0.5, 0.5),
            hillWidth = 0.2,
            hillHeight = 1 + v17 * 1.2
        };
        local v20 = {
            frequency = v12 / 5,
            amplitude = (v13 * 0.16) * 3,
            offset = v14,
            seed = v15
        };
        local v21 = v12 > 0 and v13 > 0;
        local v22 = if not v21 then nil else table.create(v11._rotatedSliceX * v11._rotatedSliceZ, 0);
        v11._noiseMap = table.create(v11._rotatedSliceX * v11._rotatedSliceZ, 0);
        for v23 = 1, v11._rotatedSliceX do
            local v24 = v23 - v11._rotatedXOffset;
            for v25 = 1, v11._rotatedSliceZ do
                local v26 = v25 - v11._rotatedZOffset;
                local v27 = v11:getGaussianHillHeight(v24, v26, v19, nil);
                local v28 = v11:getSliceIndex(v23, v25);
                v11._noiseMap[v28] = v27;
                if v21 then
                    v22[v28] = v11:getGaussianHillHeight(v24, v26, v19, v20) - v27;
                end;
            end;
        end;
        if v21 then
            v11:addErosion();
            for v29 = 1, #v11._noiseMap do
                local l__noiseMap_0 = v11._noiseMap;
                l__noiseMap_0[v29] = l__noiseMap_0[v29] + v22[v29] * v11._noiseMap[v29];
            end;
        end;
        local v31 = false;
        if v17 > 0 then
            v31 = v18 > 0;
        end;
        if v31 then
            for v32 = 1, v11._rotatedSliceX do
                for v33 = 1, v11._rotatedSliceZ do
                    local v34 = v11:getSliceIndex(v32, v33);
                    if v11._noiseMap[v34] < 1 then
                        if v16 == 90 then
                            local l__noiseMap_1 = v11._noiseMap;
                            l__noiseMap_1[v34] = l__noiseMap_1[v34] - v18 * v11._noiseMap[v34];
                        elseif v16 == 0 then
                            v11._noiseMap[v34] = 1;
                        else
                            local v36 = 1 - v18;
                            local v37 = math.tan((v16 * 3.141592653589793) / 180);
                            local v38 = v37 * (v11._noiseMap[v34] - 1) + 1;
                            if v36 <= v38 then
                                v11._noiseMap[v34] = v38;
                            else
                                v11._noiseMap[v34] = (v36 / ((v36 - 1) / v37 + 1)) * v11._noiseMap[v34];
                            end;
                        end;
                    end;
                end;
            end;
        end;
        return ;
    else
        warn("Missing parameters");
        return ;
    end;
end;
v7.getHeightFromNoise = function(v39, v40)
    return (math.clamp(v39._sliceY * math.clamp(v40, -1, 1), 0, v39._sliceY));
end;
v7.generateHeightMap = function(v41)
    v41:createHeightMapWithNoise();
end;
v7.updateBlendingFactorMap = function(v42, v43)
    v42._blendingFactorMap = table.create(v42._sliceX * v42._sliceZ, 0);
    if v43 > 0 then
        v42._blendingFactorMap = v6(Vector2.new(v42._sliceX, v42._sliceZ), {
            CurveWidth = 1,
            Distance = (1 - v43) * 0.9,
            PreserveDistance = 0.5 - v43 / 5,
            PreserveRatio = 0,
            RoundCorner = 1
        });
    end;
end;
return v7;


local l_script_FirstAncestor_0 = script:FindFirstAncestor("TerrainEditor");
local v1 = require(script.Parent.BaseStamp);
local l_VoxelResolution_0 = require(l_script_FirstAncestor_0.Src.Resources.Constants).VoxelResolution;
local v3 = require(l_script_FirstAncestor_0.Src.Types);
local l_BuildSettings_0 = v3.BuildSettings;
local l_Category_0 = v3.Category;
local l_TerrainType_0 = v3.TerrainType;
local v7 = Vector2.new(0.5, 0.5);
local v8 = v1:new(l_TerrainType_0.None);
v8.init = function(v9, v10, v11)
    v1.init(v9, v10, v11);
    return v9;
end;
v8.getGaussianHillHeight = function(v12, v13, v14, v15, v16)
    local v17 = v15.centerPosPercent or v7;
    local l_hillHeight_0 = v15.hillHeight;
    local l_hillWidth_0 = v15.hillWidth;
    local l_magnitude_0 = (Vector2.new(v13 / v12._sliceX, v14 / v12._sliceZ) - v17).magnitude;
    local v21 = 0;
    if v16 then
        local l_frequency_0 = v16.frequency;
        local l_amplitude_0 = v16.amplitude;
        local l_offset_0 = v16.offset;
        v21 = l_amplitude_0 * math.noise(l_frequency_0 * (v13 + l_offset_0.X), l_frequency_0 * (v14 + l_offset_0.Y), v16.seed or 12345);
    end;
    local v25 = l_magnitude_0 + v21;
    return l_hillHeight_0 * math.exp(-(v25 * v25) / ((2 * l_hillWidth_0) * l_hillWidth_0));
end;
v8.getHeightGradient = function(v26, v27, v28, v29)
    return (v29[v26:getSliceIndex(v27, v28)] - v29[v26:getSliceIndex(math.clamp(v27 - 1, 1, v26._rotatedSliceX), v28)]) / l_VoxelResolution_0, (v29[v26:getSliceIndex(v27, v28)] - v29[v26:getSliceIndex(v27, (math.clamp(v28 - 1, 1, v26._rotatedSliceZ)))]) / l_VoxelResolution_0;
end;
v8.addErosion = function(v30)
    local v31 = v30._payload[l_Category_0.BuildSettings][l_BuildSettings_0.NoiseScale];
    local v32 = v30._payload[l_Category_0.BuildSettings][l_BuildSettings_0.NoiseStrength];
    local v33 = v30._payload[l_Category_0.BuildSettings][l_BuildSettings_0.AdvancedNoise].Children[l_BuildSettings_0.Offset];
    local v34 = v30._payload[l_Category_0.BuildSettings][l_BuildSettings_0.AdvancedNoise].Children[l_BuildSettings_0.Seed];
    local v35 = {
        0.003,
        0.008,
        0.016,
        0.04
    };
    local v36 = {
        0.1,
        0.05,
        0.02,
        0.0125
    };
    local v37 = v31 * 10;
    local l_Noise_0 = Instance.new("Noise");
    l_Noise_0.NoiseType = Enum.NoiseType.SimplexGabor;
    l_Noise_0.Seed = v34;
    local v39 = table.create(#v30._noiseMap, 0);
    for v40 = 1, 4 do
        for v41 = 1, #v39 do
            v39[v41] = v30._noiseMap[v41];
        end;
        for v42 = 1, v30._rotatedSliceX do
            for v43 = 1, v30._rotatedSliceZ do
                local v44 = (Vector3.new((v42 * l_VoxelResolution_0 + l_VoxelResolution_0 / 2) + v33.X, v34, (v43 * l_VoxelResolution_0 + l_VoxelResolution_0 / 2) + v33.Y) * v35[v40]) * v37;
                local v45, v46 = v30:getHeightGradient(v42, v43, v39);
                local v47 = l_Noise_0:SampleDirectional(v44, Vector3.new(-v46, 0, v45) * 2000) * (v36[v40] * v32);
                local v48 = v30:getSliceIndex(v42, v43);
                local l__noiseMap_0 = v30._noiseMap;
                l__noiseMap_0[v48] = l__noiseMap_0[v48] + v47;
            end;
        end;
    end;
end;
return v8;


local l_script_FirstAncestor_0 = script:FindFirstAncestor("TerrainEditor");
local v1 = require(script.Parent.MountainBaseStamp);
local v2 = require(l_script_FirstAncestor_0.Src.Types);
local l_BuildSettings_0 = v2.BuildSettings;
local l_Category_0 = v2.Category;
local l_TerrainType_0 = v2.TerrainType;
local v6 = require(l_script_FirstAncestor_0.Src.Util.Generation.GetBlendingFactorMap);
local v7 = v1:new(l_TerrainType_0.Mountain);
v7.init = function(v8, v9, v10)
    v1.init(v8, v9, v10);
    return v8;
end;
v7.generateNoiseMap = function(v11)
    local v12 = v11._payload[l_Category_0.BuildSettings][l_BuildSettings_0.NoiseScale];
    local v13 = v11._payload[l_Category_0.BuildSettings][l_BuildSettings_0.NoiseStrength];
    local v14 = v11._payload[l_Category_0.BuildSettings][l_BuildSettings_0.AdvancedNoise].Children[l_BuildSettings_0.Offset];
    local v15 = v11._payload[l_Category_0.BuildSettings][l_BuildSettings_0.AdvancedNoise].Children[l_BuildSettings_0.Seed];
    local v16 = {
        hillWidth = 0.2,
        hillHeight = 0.85
    };
    local v17 = {
        frequency = v12 / 5,
        amplitude = (v13 * 0.16) * 2,
        offset = v14,
        seed = v15
    };
    local v18 = v12 > 0 and v13 > 0;
    local v19 = if not v18 then nil else table.create(v11._rotatedSliceX * v11._rotatedSliceZ, 0);
    v11._noiseMap = table.create(v11._rotatedSliceX * v11._rotatedSliceZ, 0);
    for v20 = 1, v11._rotatedSliceX do
        local v21 = v20 - v11._rotatedXOffset;
        for v22 = 1, v11._rotatedSliceZ do
            local v23 = v22 - v11._rotatedZOffset;
            local v24 = v11:getGaussianHillHeight(v21, v23, v16, nil);
            local v25 = v11:getSliceIndex(v20, v22);
            v11._noiseMap[v25] = v24;
            if v18 then
                v19[v25] = v11:getGaussianHillHeight(v21, v23, v16, v17) - v24;
            end;
        end;
    end;
    if v18 then
        v11:addErosion();
        for v26 = 1, #v11._noiseMap do
            local l__noiseMap_0 = v11._noiseMap;
            l__noiseMap_0[v26] = l__noiseMap_0[v26] + v19[v26];
        end;
        return ;
    else
        return ;
    end;
end;
v7.getHeightFromNoise = function(v28, v29)
    return (math.clamp(v28._sliceY * math.clamp(v29, -1, 1), 0, v28._sliceY));
end;
v7.generateHeightMap = function(v30)
    v30:createHeightMapWithNoise();
end;
v7.updateBlendingFactorMap = function(v31, v32)
    v31._blendingFactorMap = table.create(v31._sliceX * v31._sliceZ, 0);
    if v32 > 0 then
        v31._blendingFactorMap = v6(Vector2.new(v31._sliceX, v31._sliceZ), {
            CurveWidth = 1,
            Distance = (1 - v32) * 0.9,
            PreserveDistance = 0.5 - v32 / 5,
            PreserveRatio = 0,
            RoundCorner = 1
        });
    end;
end;
return v7;


local l_script_FirstAncestor_0 = script:FindFirstAncestor("TerrainEditor");
local v1 = require(script.Parent.BaseStamp);
local l_VoxelResolution_0 = require(l_script_FirstAncestor_0.Src.Resources.Constants).VoxelResolution;
local v3 = require(l_script_FirstAncestor_0.Src.Types);
local l_BuildSettings_0 = v3.BuildSettings;
local l_Category_0 = v3.Category;
local l_TerrainType_0 = v3.TerrainType;
local v7 = require(l_script_FirstAncestor_0.Src.Util.Generation.FractalNoise)(3, 2, 0.35);
local v8 = v1:new(l_TerrainType_0.Plain);
v8.init = function(v9, v10, v11)
    v1.init(v9, v10, v11);
    return v9;
end;
v8.generateNoiseMap = function(v12)
    local v13 = v12._payload[l_Category_0.BuildSettings][l_BuildSettings_0.NoiseScale];
    local v14 = v12._payload[l_Category_0.BuildSettings][l_BuildSettings_0.AdvancedNoise].Children[l_BuildSettings_0.Offset];
    local v15 = v12._payload[l_Category_0.BuildSettings][l_BuildSettings_0.AdvancedNoise].Children[l_BuildSettings_0.Seed];
    v12._noiseMap = table.create(v12._rotatedSliceX * v12._rotatedSliceZ, 0);
    if v13 > 0 then
        local v16 = 50 / v13;
        for v17 = 1, v12._rotatedSliceX do
            for v18 = 1, v12._rotatedSliceZ do
                v12._noiseMap[v12:getSliceIndex(v17, v18)] = v7((v17 * l_VoxelResolution_0 + l_VoxelResolution_0 / 2) + v14.X, (v18 * l_VoxelResolution_0 + l_VoxelResolution_0 / 2) + v14.Y, v15, v16);
            end;
        end;
    end;
end;
return v8;