local l_script_FirstAncestor_0 = script:FindFirstAncestor("TerrainEditor");
local v1 = require(l_script_FirstAncestor_0.Packages.Dash);
local v2 = require(script.Parent.BaseTool);
local v3 = require(l_script_FirstAncestor_0.Src.Flags.getFFlagTerrainEditorTimeStatistic);
local v4 = require(l_script_FirstAncestor_0.Src.Flags.getFFlagTerrainEditorErrorHandling);
local l_Util_0 = l_script_FirstAncestor_0.Src.Util;
local v6 = require(l_Util_0.AnalyticsHelper);
local v7 = require(l_Util_0.ConvertTransformToRegion);
local v8 = require(l_Util_0.hasCorrectAspectRatio);
local v9 = require(l_Util_0.hasCorrectScaling);
local v10 = require(l_script_FirstAncestor_0.Src.Util.Operations.ImportOperation);
local v11 = require(l_script_FirstAncestor_0.Src.Resources.Constants);
local v12 = require(l_script_FirstAncestor_0.Src.Types);
local l_Category_0 = v12.Category;
local l_Gizmo_0 = v12.Gizmo;
local l_HeightmapSettings_0 = v12.HeightmapSettings;
local l_SelectionSettings_0 = v12.SelectionSettings;
local l_Tab_0 = v12.Tab;
local l_Tool_0 = v12.Tool;
local v19 = v2:new(l_Tool_0.Import, l_Tab_0.Create, {
    {
        Defaults = {},
        Id = l_Category_0.SelectionSettings
    },
    {
        Defaults = {
            [l_HeightmapSettings_0.Colormap] = {
                Error = ""
            },
            [l_HeightmapSettings_0.DefaultMaterial] = Enum.Material.Grass,
            [l_HeightmapSettings_0.Heightmap] = {
                Error = ""
            },
            [l_HeightmapSettings_0.Import] = true
        },
        Id = l_Category_0.HeightmapSettings
    }
}, {
    {
        Id = l_Gizmo_0.Region,
        Schema = {
            Type = l_Gizmo_0.Region,
            Wireframe = false,
            Rotation = false
        }
    }
});
v19.startOperation = function(v20, v21)
    if v4() then
        v2.startOperation(v20, v21);
    end;
    local v22 = v20:getPayload();
    local v23 = v20._localization:getText("Operations", "ImportName");
    local v24 = v20._localization:getText("Operations", "ImportDescription");
    v20._region = v7(v22[l_Category_0.SelectionSettings][l_SelectionSettings_0.Transform], v22[l_Category_0.SelectionSettings][l_SelectionSettings_0.Size], true);
    v20._terrainRegion = v20._services.Terrain:CopyRegion(v20._region);
    v20._operation = v10(v23, v24, v20._services);
    v20._operationFinishedConnection = v20._operation.Finished:Connect(function()
        if not v3() then
            if not v20._operation:wasCanceled() then
                if v4() then
                    v20._isRunning = false;
                end;
                v20._analytics:report("RegionProperties", v6.getRegionPayload(v20:getPayload(), v20._operation:getTimeTaken(), l_Tool_0.Import));
                v20._analytics:report("Usage", l_Tool_0.Import, 1);
                if v20._operationFinishedConnection then
                    v20._operationFinishedConnection:Disconnect();
                    v20._operationFinishedConnection = nil;
                end;
            end;
            return ;
        else
            v20:finishOperation();
            return ;
        end;
    end);
    v20._operation:start(v1.join({
        Payload = v22
    }, v21));
    v20.OnOperationChanged:Fire();
end;
v19.init = function(v25, v26, v27)
    v2.init(v25, v26, v27);
    local v28 = v25:getPayload()[l_Category_0.SelectionSettings][l_SelectionSettings_0.Size];
    local v33 = {
        [l_Category_0.SelectionSettings] = {
            [l_SelectionSettings_0.Size] = {
                Validate = function(v29)
                    if not (v29.X >= v11.VoxelResolution and v29.Y >= v11.VoxelResolution) or v29.Z < v11.VoxelResolution then
                        return Enum.PropertyStatus.Error, v25._localization:getText("SelectionWarning", "Size");
                    elseif v11.MaxImportVolume < (v29.X * v29.Y) * v29.Z then
                        return Enum.PropertyStatus.Error, v25._localization:getText("ImportWarning", "Volume");
                    else
                        local l_Image_0 = v25._sessionUserSettings[l_Category_0.HeightmapSettings][l_HeightmapSettings_0.Heightmap].Image;
                        if l_Image_0 then
                            local v31, v32 = v8(l_Image_0, v29);
                            if v31 then
                                if v9(l_Image_0, v29) then
                                    return Enum.PropertyStatus.Ok, "";
                                else
                                    return Enum.PropertyStatus.Warning, v25._localization:getText("ImportWarning", "Scaling", {
                                        ImageWidth = l_Image_0.Width,
                                        ImageHeight = l_Image_0.Height,
                                        RegionWidth = v29.X,
                                        RegionHeight = v29.Z
                                    });
                                end;
                            else
                                return Enum.PropertyStatus.Warning, v25._localization:getText("ImportWarning", "AspectRatio", {
                                    ImageAspectRatio = v32,
                                    RegionWidth = v29.X,
                                    RegionHeight = v29.Z
                                });
                            end;
                        else
                            return Enum.PropertyStatus.Ok, "";
                        end;
                    end;
                end
            }
        }
    };
    local l_HeightmapSettings_1 = l_Category_0.HeightmapSettings;
    local v35 = {};
    local l_Import_0 = l_HeightmapSettings_0.Import;
    local v37 = {};
    local v38;
    if v4() then
        v38 = nil;
    else
        v38 = not v25._sessionUserSettings[l_Category_0.HeightmapSettings][l_HeightmapSettings_0.Heightmap].Image;
        if not v38 then
            v38 = true;
            if v11.MaxImportVolume >= (v28.X * v28.Y) * v28.Z then
                v38 = true;
                if v28.X >= v11.VoxelResolution then
                    v38 = true;
                    if v28.Y >= v11.VoxelResolution then
                        v38 = v28.Z < v11.VoxelResolution;
                    end;
                end;
            end;
        end;
    end;
    v37.Disabled = v38;
    v37.Hidden = false;
    v37.Label = "";
    v37.Schema = {
        OnClick = function()
            v25:startOperation();
        end
    };
    v35[l_Import_0] = v37;
    v33[l_HeightmapSettings_1] = v35;
    v25._overrides = v33;
end;
v19.operation = function(v39)
    return v39._operation;
end;
if v4() then
    v19.setDisabledState = function(v40)
        local v41 = v40:hasError();
        if v40._overrides[l_Category_0.HeightmapSettings][l_HeightmapSettings_0.Import].Disabled ~= v41 then
            v40._overrides[l_Category_0.HeightmapSettings][l_HeightmapSettings_0.Import].Disabled = v41;
            v40.OnInternalsChanged:Fire();
        end;
    end;
end;
v19.saveForm = function(v42, v43)
    v2.saveForm(v42, v43);
    if not v4() then
        local v44 = v42:getPayload()[l_Category_0.SelectionSettings][l_SelectionSettings_0.Size];
        local v45 = not v42._sessionUserSettings[l_Category_0.HeightmapSettings][l_HeightmapSettings_0.Heightmap].Image;
        if not v45 then
            v45 = true;
            if v11.MaxImportVolume >= (v44.X * v44.Y) * v44.Z then
                v45 = true;
                if v44.X >= v11.VoxelResolution then
                    v45 = true;
                    if v44.Y >= v11.VoxelResolution then
                        v45 = v44.Z < v11.VoxelResolution;
                    end;
                end;
            end;
        end;
        if v42._overrides[l_Category_0.HeightmapSettings][l_HeightmapSettings_0.Import].Disabled ~= v45 then
            v42._overrides[l_Category_0.HeightmapSettings][l_HeightmapSettings_0.Import].Disabled = v45;
            v42.OnGizmoChanged:Fire();
        end;
        return ;
    else
        v42:setDisabledState();
        return ;
    end;
end;
v19.activate = function(v46)
    v2.activate(v46);
    if not v4() then
        local v47 = v46:getPayload()[l_Category_0.SelectionSettings][l_SelectionSettings_0.Size];
        local v48 = v46._overrides[l_Category_0.HeightmapSettings][l_HeightmapSettings_0.Import];
        local v49 = not v46._sessionUserSettings[l_Category_0.HeightmapSettings][l_HeightmapSettings_0.Heightmap].Image;
        if not v49 then
            v49 = true;
            if v11.MaxImportVolume >= (v47.X * v47.Y) * v47.Z then
                v49 = true;
                if v47.X >= v11.VoxelResolution then
                    v49 = true;
                    if v47.Y >= v11.VoxelResolution then
                        v49 = v47.Z < v11.VoxelResolution;
                    end;
                end;
            end;
        end;
        v48.Disabled = v49;
        v46.OnGizmoChanged:Fire();
    end;
    v46._analytics:report("Activated", l_Tool_0.Import);
end;
return v19;


local l_script_FirstAncestor_0 = script:FindFirstAncestor("TerrainEditor");
local v1 = require(l_script_FirstAncestor_0.Packages.Dash);
local v2 = require(script.Parent.BaseTool);
local v3 = require(l_script_FirstAncestor_0.Src.Flags.getFFlagTerrainEditorTimeStatistic);
local v4 = require(l_script_FirstAncestor_0.Src.Flags.getFFlagTerrainEditorErrorHandling);
local v5 = require(l_script_FirstAncestor_0.Src.Types);
local l_Category_0 = v5.Category;
local l_FillMode_0 = v5.FillMode;
local l_Gizmo_0 = v5.Gizmo;
local l_MaterialSettings_0 = v5.MaterialSettings;
local l_SeaLevelSettings_0 = v5.SeaLevelSettings;
local l_SelectionSettings_0 = v5.SelectionSettings;
local l_Tab_0 = v5.Tab;
local l_Tool_0 = v5.Tool;
local l_Util_0 = l_script_FirstAncestor_0.Src.Util;
local v15 = require(l_Util_0.AnalyticsHelper);
local v16 = require(l_Util_0.Operations.FillOperation);
local v17 = v2:new(l_Tool_0.SeaLevel, l_Tab_0.Edit, {
    {
        Defaults = {
            [l_SeaLevelSettings_0.Size] = Vector3.new(64, 32, 64),
            [l_SeaLevelSettings_0.SnapToVoxels] = true,
            [l_SeaLevelSettings_0.Transform] = CFrame.new()
        },
        Id = l_Category_0.SeaLevelSettings
    }
}, {
    {
        Id = l_Gizmo_0.Region,
        Schema = {
            Type = l_Gizmo_0.Region,
            Wireframe = false,
            Rotation = false
        }
    }
});
v17.startOperation = function(v18, v19)
    if v4() then
        v2.startOperation(v18, v19);
    end;
    v18._operation:start(v19);
    v18.OnOperationChanged:Fire();
end;
v17.create = function(v20, v21)
    local v22 = v20:getPayload();
    v22 = {
        [l_Category_0.MaterialSettings] = {
            [l_MaterialSettings_0.FillMode] = l_FillMode_0.Replace,
            [l_MaterialSettings_0.SourceMaterial] = Enum.Material.Air,
            [l_MaterialSettings_0.TargetMaterial] = Enum.Material.Water
        },
        [l_Category_0.SelectionSettings] = {
            [l_SelectionSettings_0.Size] = v22[l_Category_0.SeaLevelSettings][l_SeaLevelSettings_0.Size],
            [l_SelectionSettings_0.Transform] = v22[l_Category_0.SeaLevelSettings][l_SeaLevelSettings_0.Transform]
        }
    };
    v20._operation = v16(v20._localization:getText("Operations", "CreateName"), v20._localization:getText("Operations", "CreateDescription"), v20._services);
    v20._operationFinishedConnection = v20._operation.Finished:Connect(function()
        if not v3() then
            if not v20._operation:wasCanceled() then
                v20._analytics:report("RegionProperties", v15.getRegionPayload(v20:getPayload(), v20._operation:getTimeTaken(), l_Tool_0.SeaLevel));
                v20._analytics:report("Usage", l_Tool_0.SeaLevel, 1);
                if v20._operationFinishedConnection then
                    v20._operationFinishedConnection:Disconnect();
                    v20._operationFinishedConnection = nil;
                end;
            end;
            return ;
        else
            v20:finishOperation();
            return ;
        end;
    end);
    v20:startOperation(v1.join({
        Payload = v22
    }, v21));
end;
v17.evaporate = function(v23, v24)
    local v25 = v23:getPayload();
    v25 = {
        [l_Category_0.MaterialSettings] = {
            [l_MaterialSettings_0.FillMode] = l_FillMode_0.Replace,
            [l_MaterialSettings_0.SourceMaterial] = Enum.Material.Water,
            [l_MaterialSettings_0.TargetMaterial] = Enum.Material.Air
        },
        [l_Category_0.SelectionSettings] = {
            [l_SelectionSettings_0.Size] = v25[l_Category_0.SeaLevelSettings][l_SeaLevelSettings_0.Size],
            [l_SelectionSettings_0.Transform] = v25[l_Category_0.SeaLevelSettings][l_SeaLevelSettings_0.Transform]
        }
    };
    v23._operation = v16(v23._localization:getText("Operations", "EvaporateName"), v23._localization:getText("Operations", "EvaporateDescription"), v23._services);
    v23:startOperation(v1.join({
        Payload = v25
    }, v24));
end;
v17.init = function(v26, v27, v28)
    v2.init(v26, v27, v28);
    v26._overrides = {
        [l_Category_0.SeaLevelSettings] = {
            [l_SeaLevelSettings_0.Evaporate] = {
                Hidden = false,
                Label = "",
                Schema = {
                    OnClick = function()
                        v26:evaporate();
                    end
                },
                Value = true
            },
            [l_SeaLevelSettings_0.Create] = {
                Hidden = false,
                Label = "",
                Schema = {
                    OnClick = function()
                        v26:create();
                    end
                },
                Value = true
            }
        }
    };
end;
if v4() then
    v17.setDisabledState = function(v29)
        local v30 = v29:hasError();
        if v29._overrides[l_Category_0.SeaLevelSettings][l_SeaLevelSettings_0.Evaporate].Disabled ~= v30 and v29._overrides[l_Category_0.SeaLevelSettings][l_SeaLevelSettings_0.Create].Disabled ~= v30 then
            v29._overrides[l_Category_0.SeaLevelSettings][l_SeaLevelSettings_0.Evaporate].Disabled = v30;
            v29._overrides[l_Category_0.SeaLevelSettings][l_SeaLevelSettings_0.Create].Disabled = v30;
            v29.OnInternalsChanged:Fire();
        end;
    end;
end;
v17.operation = function(v31)
    return v31._operation;
end;
v17.activate = function(v32)
    v2.activate(v32);
    v32._analytics:report("Activated", l_Tool_0.SeaLevel);
end;
return v17;


local l_script_FirstAncestor_0 = script:FindFirstAncestor("TerrainEditor");
local v1 = require(script.Parent.BaseTool);
local v2 = require(l_script_FirstAncestor_0.Src.Types);
local l_Category_0 = v2.Category;
local l_FillMode_0 = v2.FillMode;
local l_Gizmo_0 = v2.Gizmo;
local l_MaterialSettings_0 = v2.MaterialSettings;
local l_PluginAction_0 = v2.PluginAction;
local l_SelectionSettings_0 = v2.SelectionSettings;
local l_Tab_0 = v2.Tab;
local l_Tool_0 = v2.Tool;
local l_TransformMode_0 = v2.TransformMode;
local l_TransformSettings_0 = v2.TransformSettings;
local l_Util_0 = l_script_FirstAncestor_0.Src.Util;
local v14 = require(l_Util_0.ConvertTransformToRegion);
local v15 = require(l_Util_0.Operations.FillOperation);
local v16 = require(l_Util_0.SettingsHelper);
local v17 = require(l_script_FirstAncestor_0.Src.Flags.getFFlagTerrainEditorErrorHandling);
local v18 = v1:new(l_Tool_0.Select, l_Tab_0.Edit, {
    {
        Defaults = {},
        Id = l_Category_0.SelectionSettings
    }
}, {
    {
        Id = l_Gizmo_0.Region,
        Schema = {
            Type = l_Gizmo_0.Region,
            Wireframe = true,
            Rotation = false
        }
    }
});
v18.fillAir = function(v19, v20)
    local v21 = v19:getPayload();
    v21 = {
        [l_Category_0.MaterialSettings] = {
            [l_MaterialSettings_0.FillMode] = l_FillMode_0.Fill,
            [l_MaterialSettings_0.SourceMaterial] = Enum.Material.Air
        },
        [l_Category_0.SelectionSettings] = {
            [l_SelectionSettings_0.Size] = v21[l_Category_0.SelectionSettings][l_SelectionSettings_0.Size],
            [l_SelectionSettings_0.Transform] = v21[l_Category_0.SelectionSettings][l_SelectionSettings_0.Transform]
        }
    };
    v19._operation = v15(v19._localization:getText("Operations", (("%*Name"):format(v20))), v19._localization:getText("Operations", (("%*Description"):format(v20))), v19._services);
    v19._operation:start({
        Payload = v21
    });
end;
v18.copy = function(v22)
    if not v17() or not v22:hasError() then
        local v23 = v16.Get(l_Category_0.SelectionSettings, v22._pluginController, v22._persistentUserSettings);
        v22._analytics:report("Activated", "Copy");
        v16.Set(l_Category_0.TransformSettings, v22._pluginController, {
            [l_TransformSettings_0.TerrainRegionBuffer] = v22._services.Terrain:CopyRegion(v14(v23[l_SelectionSettings_0.Transform], v23[l_SelectionSettings_0.Size], true)),
            [l_TransformSettings_0.TerrainRegionBufferSize] = v23[l_SelectionSettings_0.Size],
            [l_TransformSettings_0.TerrainRegionBufferTransform] = v23[l_SelectionSettings_0.Transform]
        });
        return ;
    else
        return ;
    end;
end;
v18.delete = function(v24)
    if not v17() or not v24:hasError() then
        v24._analytics:report("Activated", "Delete");
        v24:fillAir("Delete");
        return ;
    else
        return ;
    end;
end;
v18.cut = function(v25)
    if not v17() or not v25:hasError() then
        local v26 = v16.Get(l_Category_0.SelectionSettings, v25._pluginController, v25._persistentUserSettings);
        v25._analytics:report("Activated", "Cut");
        local v27 = v25._services.Terrain:CopyRegion(v14(v26[l_SelectionSettings_0.Transform], v26[l_SelectionSettings_0.Size], true));
        v25:fillAir("Cut");
        v16.Set(l_Category_0.TransformSettings, v25._pluginController, {
            [l_TransformSettings_0.TerrainRegionBuffer] = v27,
            [l_TransformSettings_0.TerrainRegionBufferSize] = v26[l_SelectionSettings_0.Size],
            [l_TransformSettings_0.TerrainRegionBufferTransform] = v26[l_SelectionSettings_0.Transform]
        });
        return ;
    else
        return ;
    end;
end;
v18.paste = function(v28)
    if not v17() or not v28:hasError() then
        local v29 = v16.Get(l_Category_0.TransformSettings, v28._pluginController, v28._persistentUserSettings);
        v28._analytics:report("Activated", "Paste");
        if v29[l_TransformSettings_0.TerrainRegionBuffer] then
            v16.Set(l_Category_0.TransformSettings, v28._pluginController, {
                [l_TransformSettings_0.TransformMode] = l_TransformMode_0.Paste
            });
            v28._toolController.selectTool(l_Tool_0.Transform);
        end;
        return ;
    else
        return ;
    end;
end;
v18.duplicate = function(v30)
    if not v17() or not v30:hasError() then
        local v31 = v16.Get(l_Category_0.SelectionSettings, v30._pluginController, v30._persistentUserSettings);
        v30._analytics:report("Activated", "Duplicate");
        v16.Set(l_Category_0.TransformSettings, v30._pluginController, {
            [l_TransformSettings_0.TerrainRegion] = v30._services.Terrain:CopyRegion(v14(v31[l_SelectionSettings_0.Transform], v31[l_SelectionSettings_0.Size], true)),
            [l_TransformSettings_0.TerrainRegionSize] = v31[l_SelectionSettings_0.Size],
            [l_TransformSettings_0.TerrainRegionTransform] = v31[l_SelectionSettings_0.Transform],
            [l_TransformSettings_0.TransformMode] = l_TransformMode_0.Duplicate
        });
        v30._toolController.selectTool(l_Tool_0.Transform);
        return ;
    else
        return ;
    end;
end;
v18.operation = function(v32)
    return v32._operation;
end;
v18.activate = function(v33)
    v1.activate(v33);
    v33._pluginActions = {
        [l_PluginAction_0.CopySelected] = function()
            v33:copy();
        end,
        [l_PluginAction_0.CutSelected] = function()
            v33:cut();
        end,
        [l_PluginAction_0.DeleteSelected] = function()
            v33:delete();
        end,
        [l_PluginAction_0.PasteSelected] = function()
            v33:paste();
        end,
        [l_PluginAction_0.DuplicateSelected] = function()
            v33:duplicate();
        end
    };
    v33._connections = {};
    for v34, v35 in v33._pluginActions, nil, nil do
        v33._connections[v34] = v33._shortcutController:Connect(v34, v35);
        v33._shortcutController:Enable(v34);
    end;
    v33._selection = v33._services.Selection:Get() or {};
    v33._services.Selection:Set({});
    if not v33._onSelectionChanged then
        v33._onSelectionChanged = v33._services.Selection.SelectionChanged:Connect(function()
            if not v33._pluginController:getEnabled() then
                v33._selection = v33._services.Selection:Get() or {};
                return ;
            else
                task.defer(function()
                    v33._services.Selection:Set({});
                end);
                return ;
            end;
        end);
    end;
    v33._analytics:report("Activated", l_Tool_0.Select);
end;
v18.deactivate = function(v36)
    if v36._onSelectionChanged then
        v36._onSelectionChanged:Disconnect();
        v36._onSelectionChanged = nil;
    end;
    v36._services.Selection:Set(v36._selection);
    v1.deactivate(v36);
    for v37 in v36._pluginActions, nil, nil do
        v36._shortcutController:Disable(v37);
    end;
    for _, v39 in v36._connections, nil, nil do
        v39:Disconnect();
    end;
    v36._connections = nil;
end;
return v18;


local l_script_FirstAncestor_0 = script:FindFirstAncestor("TerrainEditor");
local v1 = require(l_script_FirstAncestor_0.Packages.Dash);
local v2 = require(script.Parent.BaseTool);
local v3 = require(l_script_FirstAncestor_0.Src.Types);
local l_Category_0 = v3.Category;
local l_Gizmo_0 = v3.Gizmo;
local l_Note_0 = v3.Note;
local l_OperationSource_0 = v3.OperationSource;
local l_PluginAction_0 = v3.PluginAction;
local l_SelectionSettings_0 = v3.SelectionSettings;
local l_TransformMode_0 = v3.TransformMode;
local l_TransformSettings_0 = v3.TransformSettings;
local l_Tab_0 = v3.Tab;
local l_Tool_0 = v3.Tool;
local l_Util_0 = l_script_FirstAncestor_0.Src.Util;
local v15 = require(l_Util_0.AnalyticsHelper);
local v16 = require(l_Util_0.ApplyTransform);
local v17 = require(l_Util_0.ConvertTransformToRegion);
local v18 = require(l_Util_0.getWithinTerrainBounds);
local v19 = require(l_Util_0.SettingsHelper);
local v20 = require(l_Util_0.Operations.TransformOperation);
local l_game_FastInt_0 = game:GetFastInt("SmoothTerrainMaxCppRegion");
local v22 = require(l_script_FirstAncestor_0.Src.Flags.getFFlagTerrainEditorTimeStatistic);
local v23 = require(l_script_FirstAncestor_0.Src.Flags.getFFlagTerrainEditorErrorHandling);
local v24 = require(l_script_FirstAncestor_0.Src.Flags.getFFlagTerrainEditorDisabledFixes);
local v25 = require(l_script_FirstAncestor_0.Src.Flags.getFFlagTerrainEditorCopyPasteFix);
local v26 = v2:new(l_Tool_0.Transform, l_Tab_0.Edit, {
    {
        Defaults = {
            [l_TransformSettings_0.MergeEmpty] = false,
            [l_TransformSettings_0.LiveEdit] = true,
            [l_TransformSettings_0.ForcePreview] = false,
            [l_TransformSettings_0.TransformMode] = l_TransformMode_0.Move
        },
        Id = l_Category_0.TransformSettings
    }
}, {
    {
        Id = l_Gizmo_0.Region,
        Schema = {
            Type = l_Gizmo_0.Region,
            Color = Color3.new(0, 0, 1),
            Wireframe = true,
            Rotation = true
        }
    }
});
v26.startOperation = function(v27, v28)
    if v23() then
        v2.startOperation(v27, v28);
    end;
    local v29 = v27:getPayload();
    v29[l_Category_0.SelectionSettings] = v19.Get(l_Category_0.SelectionSettings, v27._pluginController, v27._persistentUserSettings[l_Category_0.SelectionSettings]);
    local v30 = v29[l_Category_0.TransformSettings][l_TransformSettings_0.TransformMode];
    v27._operation = v20(v27._localization:getText("Operations", (("%*Name"):format(v30))), v27._localization:getText("Operations", (("%*Description"):format(v30))), v27._services);
    local v31 = v29[l_Category_0.TransformSettings][l_TransformSettings_0.Size];
    local v32 = v29[l_Category_0.TransformSettings][l_TransformSettings_0.Transform];
    local function v35(v33, v34)
        if not (v31 == v33) or v32.Rotation ~= CFrame.new() then
            return false;
        else
            v27._services.Terrain:PasteRegion(v34:Clone(), v17(v32, v31, true).Min, v29[l_Category_0.TransformSettings][l_TransformSettings_0.MergeEmpty]);
            return true;
        end;
    end;
    if v30 == l_TransformMode_0.Move then
        if v35(v29[l_Category_0.SelectionSettings][l_SelectionSettings_0.Size], v29[l_Category_0.TransformSettings][l_TransformSettings_0.TerrainRegion]) then
            return ;
        end;
    elseif v30 == l_TransformMode_0.Paste then
        if v35(v29[l_Category_0.TransformSettings][l_TransformSettings_0.TerrainRegionBufferSize], v29[l_Category_0.TransformSettings][l_TransformSettings_0.TerrainRegionBuffer]) then
            return ;
        end;
    elseif not (not (not (v30 ~= l_TransformMode_0.Import) or v30 == l_TransformMode_0.Duplicate) or not v35(v29[l_Category_0.TransformSettings][l_TransformSettings_0.TerrainRegionSize], v29[l_Category_0.TransformSettings][l_TransformSettings_0.TerrainRegion])) then
        return ;
    end;
    v27._operationFinishedConnection = v27._operation.Finished:Connect(function()
        if not v22() then
            if not v27._operation:wasCanceled() then
                v27._analytics:report("RegionProperties", v15.getRegionPayload(v27:getPayload(), v27._operation:getTimeTaken(), l_Tool_0.Transform));
                v27._analytics:report("Usage", l_Tool_0.Transform, 1);
                if v27._operationFinishedConnection then
                    v27._operationFinishedConnection:Disconnect();
                    v27._operationFinishedConnection = nil;
                end;
            end;
        else
            v27:finishOperation();
            if v24() then
                v27._toolController.selectTool(l_Tool_0.Select);
                return ;
            end;
        end;
    end);
    v27._operation:start(v1.join({
        Payload = v29
    }, v28));
    v27.OnOperationChanged:Fire();
end;
v26.init = function(v36, v37, v38)
    v2.init(v36, v37, v38);
    v36._overrides = {
        [l_Category_0.TransformSettings] = {
            [l_TransformSettings_0.Rotation] = {
                Hidden = false
            },
            [l_TransformSettings_0.Apply] = {
                Hidden = not v36._persistentUserSettings[l_Category_0.TransformSettings][l_TransformSettings_0.ForcePreview] and v36._persistentUserSettings[l_Category_0.TransformSettings][l_TransformSettings_0.LiveEdit],
                Label = "",
                Schema = {
                    OnClick = function()
                        v36:startOperation();
                    end
                },
                Value = true
            }
        }
    };
end;
v26.getValues = function(v39)
    return v19.Get(l_Category_0.SelectionSettings, v39._pluginController, v39._persistentUserSettings[l_Category_0.SelectionSettings], v39._sessionUserSettings[l_Category_0.SelectionSettings]), (v19.Get(l_Category_0.TransformSettings, v39._pluginController, v39._persistentUserSettings[l_Category_0.TransformSettings], v39._sessionUserSettings[l_Category_0.TransformSettings]));
end;
v26.checkSize = function(v40, v41, v42, v43, v44)
    local v45 = v17(v41, v42);
    local v46 = v45.Max - v45.Min;
    local v47 = l_game_FastInt_0 < (v46.X * v46.Y) * v46.Z;
    if not (not v23() or not v40:hasError()) then
        v47 = true;
    end;
    if not (not v43 or not v44) then
        local v48 = v17(v43, v44);
        local v49 = v48.Max - v48.Min;
        v47 = v47 or l_game_FastInt_0 < (v49.X * v49.Y) * v49.Z;
        if not (not v23() or not v40:hasError()) then
            v47 = true;
        end;
    end;
    v40:setPayload({
        [l_Category_0.TransformSettings] = {
            [l_TransformSettings_0.ForcePreview] = v47
        }
    });
    return v47;
end;
if v23() then
    v26.hasError = function(v50)
        local v51, _ = v50:getValues();
        return v2.hasError(v50) or not v18(v51[l_SelectionSettings_0.Transform], v51[l_SelectionSettings_0.Size]);
    end;
    v26.setDisabledState = function(v53)
        local v54 = v53:hasError();
        if v53._overrides[l_Category_0.TransformSettings][l_TransformSettings_0.Apply].Disabled ~= v54 then
            v53._overrides[l_Category_0.TransformSettings][l_TransformSettings_0.Apply].Disabled = v54;
            v53.OnInternalsChanged:Fire();
        end;
    end;
end;
v26.activate = function(v55)
    local v56, v57 = v55:getValues();
    local v58 = v56[l_SelectionSettings_0.Size];
    local v59 = v56[l_SelectionSettings_0.SnapToVoxels];
    local v60 = v56[l_SelectionSettings_0.Transform];
    local v61 = v57[l_SelectionSettings_0.TransformMode];
    v55:checkSize(v60, v58);
    local v62 = nil;
    if v61 == l_TransformMode_0.Move then
        v62 = v55._services.Terrain:CopyRegion(v17(v60, v58, true));
        v62.Parent = v55._services.CoreGui;
    end;
    v55._applyConnection = v55._shortcutController:Connect(l_PluginAction_0.Apply, function()
        if not v55._live then
            v55:startOperation();
            return ;
        else
            return ;
        end;
    end);
    v55._shortcutController:Enable(l_PluginAction_0.Apply);
    v55:setPayload({
        [l_Category_0.TransformSettings] = {
            [l_TransformSettings_0.Size] = v58,
            [l_TransformSettings_0.SnapToVoxels] = v59,
            [l_TransformSettings_0.Transform] = v60,
            [l_TransformSettings_0.TerrainRegion] = v62
        }
    });
    v55._region = v17(v60, v58);
    v55._regionOriginal = v17(v60, v58);
    v55._terrainBackup = v55._services.Terrain:CopyRegion(v55._region);
    v55._terrainOriginal = v55._services.Terrain:CopyRegion(if not v25() then v55._region else v55._regionOriginal);
    v55._analytics:report("Activated", l_Tool_0.Transform);
    v55:updateValues();
    if v23() then
        v2.activate(v55);
    end;
end;
v26.gizmos = function(v63)
    local v64 = v2.gizmos(v63);
    for _, v66 in v64, nil, nil do
        if v66.Id == l_Gizmo_0.Region then
            v66.Value[l_Category_0.SelectionSettings] = v19.Get(l_Category_0.SelectionSettings, v63._pluginController, v63._persistentUserSettings[l_Category_0.SelectionSettings]);
        end;
    end;
    return v64;
end;
v26.operation = function(v67)
    return v67._operation;
end;
v26.note = function(v68)
    return v68._note;
end;
v26.deactivate = function(v69)
    v2.deactivate(v69);
    v69._applyConnection:Disconnect();
    v69._shortcutController:Disable(l_PluginAction_0.Apply);
    v19.Set(l_Category_0.TransformSettings, v69._pluginController, {
        TransformMode = l_TransformMode_0.Move
    });
end;
v26.saveGizmos = function(v70, v71)
    v2.saveGizmos(v70, v71);
    v70:updateValues();
end;
v26.saveForm = function(v72, v73)
    v2.saveForm(v72, v73);
    v72:updateValues();
end;
v26.updateMode = function(v74)
    local _, v76 = v74:getValues();
    local v77 = not v76[l_TransformSettings_0.ForcePreview] and v76[l_TransformSettings_0.LiveEdit];
    if v74._overrides[l_Category_0.TransformSettings][l_TransformSettings_0.Apply].Hidden ~= v77 then
        v74._note = if not v77 then l_Note_0.Transform else nil;
        v74.OnNoteChanged:Fire();
        v74._overrides[l_Category_0.TransformSettings][l_TransformSettings_0.Apply].Hidden = v77;
        task.spawn(function()
            v74.OnFormChanged:Fire();
        end);
    end;
    if not v77 then
        if v74._live then
            v74._services.Terrain:PasteRegion(v74._terrainOriginal, v74._regionOriginal.Min, true);
            v74._services.Terrain:PasteRegion(v74._terrainBackup, v74._region.Min, true);
        end;
    elseif not v74._live then
        v74._services.Terrain:PasteRegion(v74._terrainOriginal, v74._regionOriginal.Min, true);
        v74._services.Terrain:PasteRegion(v74._terrainBackup, v74._region.Min, true);
    end;
    v74._live = v77;
    return not v74._live;
end;
v26.updateValues = function(v78)
    local v79, v80 = v78:getValues();
    v78:checkSize(v79[l_SelectionSettings_0.Transform], v79[l_SelectionSettings_0.Size], v80[l_TransformSettings_0.Transform], v80[l_TransformSettings_0.Size]);
    if not v78:updateMode() then
        if v80[l_TransformSettings_0.OperationSource] == l_OperationSource_0.History then
            return ;
        else
            v78:transform(v79, v80);
            return ;
        end;
    else
        return ;
    end;
end;
v26.transform = function(v81, v82, v83)
    local v84 = v83[l_SelectionSettings_0.TransformMode];
    local v85 = v83[l_TransformSettings_0.Size];
    local v86 = v83[l_TransformSettings_0.Transform];
    local v87 = if not not v25() and v84 == l_TransformMode_0.Paste then v83[l_TransformSettings_0.TransformRegionBufferSize] else v82[l_SelectionSettings_0.Size];
    local v88 = v82[l_SelectionSettings_0.Transform];
    local v89 = v17(v86, v85);
    local v90 = os.clock();
    v81._services.Terrain:PasteRegion(v81._terrainBackup, v81._region.Min, true);
    v81._terrainBackup = v81._services.Terrain:CopyRegion(v89);
    v81._region = v89;
    local v91 = v83[l_TransformSettings_0.MergeEmpty];
    local v92 = nil;
    if v84 == l_TransformMode_0.Move then
        v92 = v83[l_TransformSettings_0.TerrainRegion]:Clone();
        if v91 then
            v81._services.Terrain:SetMaterialInTransform(v86, v85, Enum.Material.Air);
        end;
        v81._services.Terrain:SetMaterialInTransform(v88, v87, Enum.Material.Air);
    elseif v84 == l_TransformMode_0.Paste then
        v92 = v83[l_TransformSettings_0.TerrainRegionBuffer]:Clone();
        if v91 then
            v81._services.Terrain:SetMaterialInTransform(v86, v85, Enum.Material.Air);
        end;
    elseif not (v84 ~= l_TransformMode_0.Duplicate) or v84 == l_TransformMode_0.Import then
        v92 = v83[l_TransformSettings_0.TerrainRegion]:Clone();
        if v91 then
            v81._services.Terrain:SetMaterialInTransform(v86, v85, Enum.Material.Air);
        end;
    else
        return ;
    end;
    local l_v16_0 = v16;
    local l_Terrain_0 = v81._services.Terrain;
    local l_v92_0 = v92;
    local l_v86_0 = v86;
    local l_v85_0 = v85;
    local v98 = false;
    if v86.Rotation == v88.Rotation then
        v98 = v85 == v87;
    end;
    l_v16_0(l_Terrain_0, l_v92_0, l_v86_0, l_v85_0, v98);
    v81._time = os.clock() - v90;
    if v22() then
        l_v16_0 = v15.NormalizeRegionTimer(v90, v85);
        if l_v16_0 then
            v81._totalTime = (v81._totalTime or 0) + l_v16_0;
            v81._count = not v81._count and 1 or v81._count + 1;
        end;
    end;
    if os.clock() - v90 > 5 then
        v81:setPayload({
            [l_Category_0.TransformSettings] = {
                [l_TransformSettings_0.LiveEdit] = false
            }
        });
    end;
end;
v26.reportAnalytics = function(v99)
    local _, v101 = v99:getValues();
    if not (not (not v101[l_TransformSettings_0.ForcePreview] and v101[l_TransformSettings_0.LiveEdit]) or not v99._time) then
        v99._analytics:report("RegionProperties", v15.getRegionPayload(v99:getPayload(), v99._time, l_Tool_0.Transform));
        v99._analytics:report("Usage", l_Tool_0.Transform, 1);
        if not (not v22() or not v99._count) then
            v99._analytics:report("Performance", l_Tool_0.Transform, v99._totalTime / v99._count);
        end;
        v99._time = nil;
    end;
end;
return v26;


return {
    if not require(script:FindFirstAncestor("TerrainEditor").Src.Flags.getFFlagTerrainEditorGenerationFeature)() then nil else require(script.RegionBuild),
    require(script.RegionImport),
    require(script.RegionGenerate),
    require(script.Clear),
    require(script.RegionSelect),
    require(script.RegionTransform),
    require(script.RegionFill),
    require(script.RegionSeaLevel),
    require(script.BrushDraw),
    require(script.BrushSculpt),
    require(script.BrushSmooth),
    require(script.BrushPaint),
    require(script.BrushFlatten),
    require(script.Empty)
};


return {
    Biome = {
        Arctic = "Arctic",
        Canyons = "Canyons",
        Dunes = "Dunes",
        Hills = "Hills",
        Lavascape = "Lavascape",
        Marsh = "Marsh",
        Mountains = "Mountains",
        Plains = "Plains",
        Water = "Water"
    }
};


return {
    DialogOption = {
        Cancel = "Cancel",
        Pause = "Pause",
        Resume = "Resume"
    },
    OperationSource = {
        Gizmo = "Gizmo",
        History = "History"
    },
    PluginAction = {
        Apply = "Apply",
        CopySelected = "CopySelected",
        CutSelected = "CutSelected",
        DeleteSelected = "DeleteSelected",
        DuplicateSelected = "DuplicateSelected",
        EditPlane = "EditPlane",
        PasteSelected = "PasteSelected",
        Quit = "Quit"
    },
    TransformMode = {
        Duplicate = "Duplicate",
        Import = "Import",
        Move = "Move",
        Paste = "Paste",
        Stamp = "Stamp"
    },
    ImageType = {
        Colormap = "Colormap",
        Heightmap = "Heightmap"
    }
};


local v0 = {};
local v1 = {};
local v2 = {
    Add = "Add",
    Subtract = "Subtract"
};
v1.BrushMode = "BrushMode";
v0.BrushMode = v2;
local v3 = {
    Sphere = "Sphere",
    Cube = "Cube",
    Cylinder = "Cylinder"
};
v1.BrushShape = "BrushShape";
v0.BrushShape = v3;
local v4 = {
    Fill = "Fill",
    Replace = "Replace"
};
v1.FillMode = "FillMode";
v0.FillMode = v4;
local v5 = {
    Erode = "Erode",
    Grow = "Grow",
    Both = "Both"
};
v1.FlattenMode = "FlattenMode";
v0.FlattenMode = v5;
local v6 = {
    Auto = "Auto",
    Fixed = "Fixed"
};
v1.FlattenPlane = "FlattenPlane";
v0.FlattenPlane = v6;
local v7 = {
    Bottom = "Bottom",
    Center = "Center",
    Top = "Top"
};
v1.PivotPosition = "PivotPosition";
v0.PivotPosition = v7;
local v8 = {
    Auto = "Auto",
    Off = "Off",
    Manual = "Manual"
};
v1.PlaneLock = "PlaneLock";
v0.PlaneLock = v8;
local v9 = {
    Paint = "Paint",
    Replace = "Replace"
};
v1.MaterialMode = "MaterialMode";
v0.MaterialMode = v9;
local v10 = {
    Stud = "Stud",
    Percentage = "Percentage"
};
v1.MaterialUnit = "MaterialUnit";
v0.MaterialUnit = v10;
local v11 = {
    Off = "Off",
    Voxel = "Voxel"
};
v1.Snapping = "Snapping";
v0.Snapping = v11;
local v12 = {
    Arctic = "Arctic",
    Crater = "Crater",
    Desert = "Desert",
    Lake = "Lake",
    Mesa = "Mesa",
    Mountain = "Mountain",
    Plain = "Plain",
    Volcano = "Volcano",
    None = "None"
};
v1.TerrainType = "TerrainType";
v0.TerrainType = v12;
local v13 = {
    [v1.BrushMode] = {
        v2.Add,
        v2.Subtract
    },
    [v1.BrushShape] = {
        v3.Sphere,
        v3.Cube,
        v3.Cylinder
    },
    [v1.FillMode] = {
        v4.Fill,
        v4.Replace
    },
    [v1.FlattenPlane] = {
        v6.Auto,
        v6.Fixed
    },
    [v1.FlattenMode] = {
        v5.Erode,
        v5.Grow,
        v5.Both
    },
    [v1.PivotPosition] = {
        v7.Bottom,
        v7.Center,
        v7.Top
    },
    [v1.PlaneLock] = {
        v8.Off,
        v8.Auto,
        v8.Manual
    },
    [v1.MaterialMode] = {
        v9.Paint,
        v9.Replace
    },
    [v1.MaterialUnit] = {
        v10.Stud,
        v10.Percentage
    },
    [v1.Snapping] = {
        v11.Off,
        v11.Voxel
    },
    [v1.TerrainType] = {
        v12.Plain,
        v12.Arctic,
        v12.Desert,
        v12.Mountain,
        v12.Volcano,
        v12.Mesa,
        v12.Crater,
        v12.Lake,
        v12.None
    }
};
for v14, v15 in v0, nil, nil do
    assert(v13[v14], (("Expected editor enum index for %*"):format(v14)));
    for _, v17 in v15, nil, nil do
        assert(table.find(v13[v14], v17), (("Expected index for enum value %*.%*"):format(v14, v17)));
    end;
end;
v0.EnumTypeIndices = v13;
v0.EnumType = v1;
return v0;


local l_script_FirstAncestor_0 = script:FindFirstAncestor("TerrainEditor");
local _ = require(l_script_FirstAncestor_0.Src.Types.Generation);
local _ = require(l_script_FirstAncestor_0.Src.Types.PublicEnums);
local _ = require(l_script_FirstAncestor_0.Src.Types.PrivateEnums);
local _ = require(l_script_FirstAncestor_0.Src.Types.Tools);
local v5 = {};
local v6 = {};
v5.Category = v6;
v5.BiomeSettings = {
    Biomes = "Biomes",
    BiomeBlending = "BiomeBlending",
    BiomeSize = "BiomeSize",
    Caves = "Caves",
    Seed = "Seed",
    Generate = "Generate"
};
v6.BiomeSettings = "BiomeSettings";
v5.BrushSettings = {
    BrushMode = "BrushMode",
    BrushSize = "BrushSize",
    BrushShape = "BrushShape",
    FixedYPlane = "FixedYPlane",
    FixedYPlanePosition = "FixedYPlanePosition",
    FlattenMode = "FlattenMode",
    FlattenPlane = "FlattenPlane",
    IgnoreParts = "IgnoreParts",
    IgnoreWater = "IgnoreWater",
    ManualPlaneLock = "ManualPlaneLock",
    PivotPosition = "PivotPosition",
    PlaneLock = "PlaneLock",
    PlanePosition = "PlanePosition",
    PlaneRotation = "PlaneRotation",
    PlaneTransform = "PlaneTransform",
    PullTerrain = "PullTerrain",
    Snapping = "Snapping",
    State = "State",
    Strength = "Strength",
    TemporarySmooth = "TemporarySmooth",
    WaterAutofill = "WaterAutofill"
};
v6.BrushSettings = "BrushSettings";
v5.ElevationSettings = {
    Unit = "Unit",
    Elevation = "Elevation",
    Material = "Material",
    Slope = "Slope",
    FillMaterial = "FillMaterial"
};
v6.ElevationSettings = "ElevationSettings";
v5.AdditionalSettings = {
    FallbackMaterial = "FallbackMaterial"
};
v6.AdditionalSettings = "AdditionalSettings";
v5.BuildSettings = {
    AdvancedNoise = "AdvancedNoise",
    BankSize = "BankSize",
    BlendingEdge = "BlendingEdge",
    CliffSlope = "CliffSlope",
    Confirm = "Confirm",
    CraterDepth = "CraterDepth",
    CraterRadius = "CraterRadius",
    FillBottom = "FillBottom",
    Material = "Material",
    MaterialLUT = "MaterialLUT",
    NoiseScale = "NoiseScale",
    NoiseStrength = "NoiseStrength",
    Offset = "Offset",
    OperationSource = "OperationSource",
    PlacementMode = "PlacementMode",
    Position = "Position",
    RimHeight = "RimHeight",
    Rotation = "Rotation",
    Seed = "Seed",
    Size = "Size",
    SnapToVoxels = "SnapToVoxels",
    TerrainType = "TerrainType",
    TopRadius = "TopRadius",
    Transform = "Transform",
    WaterLevel = "WaterLevel"
};
v6.BuildSettings = "BuildSettings";
v5.ClearSettings = {
    Clear = "Clear"
};
v6.ClearSettings = "ClearSettings";
v5.HeightmapSettings = {
    Heightmap = "Heightmap",
    Colormap = "Colormap",
    DefaultMaterial = "DefaultMaterial",
    Import = "Import"
};
v6.HeightmapSettings = "HeightmapSettings";
v5.MaterialSettings = {
    Apply = "Apply",
    AutoMaterial = "AutoMaterial",
    FillMode = "FillMode",
    MaterialMode = "MaterialMode",
    SourceMaterial = "SourceMaterial",
    TargetMaterial = "TargetMaterial"
};
v6.MaterialSettings = "MaterialSettings";
v5.SeaLevelSettings = {
    Create = "Create",
    Evaporate = "Evaporate",
    OperationSource = "OperationSource",
    Position = "Position",
    Size = "Size",
    SnapToVoxels = "SnapToVoxels",
    Transform = "Transform"
};
v6.SeaLevelSettings = "SeaLevelSettings";
v5.SelectionSettings = {
    OperationSource = "OperationSource",
    Position = "Position",
    Rotation = "Rotation",
    Size = "Size",
    SnapToVoxels = "SnapToVoxels",
    Transform = "Transform",
    TransformMode = "TransformMode"
};
v6.SelectionSettings = "SelectionSettings";
v5.TransformSettings = {
    Apply = "Apply",
    ForcePreview = "ForcePreview",
    LiveEdit = "LiveEdit",
    MergeEmpty = "MergeEmpty",
    OperationSource = "OperationSource",
    Position = "Position",
    Rotation = "Rotation",
    Size = "Size",
    SnapToVoxels = "SnapToVoxels",
    TerrainRegion = "TerrainRegion",
    TerrainRegionSize = "TerrainRegionSize",
    TerrainRegionTransform = "TerrainRegionTransform",
    TerrainRegionBuffer = "TerrainRegionBuffer",
    TerrainRegionBufferSize = "TerrainRegionBufferSize",
    TerrainRegionBufferTransform = "TerrainRegionBufferTransform",
    Transform = "Transform",
    TransformMode = "TransformMode"
};
v6.TransformSettings = "TransformSettings";
v5.UpgradeSettings = {
    Shorelines = "Shorelines"
};
v6.UpgradeSettings = "UpgradeSettings";
v5.Gizmo = {
    Brush = "Brush",
    Note = "Note",
    Placement = "Placement",
    Plane = "Plane",
    Region = "Region"
};
v5.Note = {
    Transform = "Transform"
};
v5.Storage = {
    Global = "Global",
    LocalPersistent = "LocalPersistent",
    LocalSession = "LocalSession"
};
return v5;


return {
    Tab = {
        Create = "Create",
        Edit = "Edit",
        None = "None"
    },
    Tool = {
        Build = "Build",
        Clear = "Clear",
        Draw = "Draw",
        Empty = "Empty",
        Fill = "Fill",
        Flatten = "Flatten",
        Generate = "Generate",
        Import = "Import",
        Mock = "Mock",
        Paint = "Paint",
        SeaLevel = "SeaLevel",
        Select = "Select",
        Sculpt = "Sculpt",
        Smooth = "Smooth",
        Transform = "Transform"
    },
    GenerationTool = {
        Mountain = "Mountain"
    }
};


local l_script_FirstAncestor_0 = script:FindFirstAncestor("TerrainEditor");
local _ = require(l_script_FirstAncestor_0.Src.Resources.AnalyticsHandlers);
local v2 = require(l_script_FirstAncestor_0.Src.Resources.Constants);
local v3 = require(l_script_FirstAncestor_0.Src.Types);
local l_BrushSettings_0 = v3.BrushSettings;
local l_Category_0 = v3.Category;
local l_FillMode_0 = v3.FillMode;
local l_MaterialMode_0 = v3.MaterialMode;
local l_MaterialSettings_0 = v3.MaterialSettings;
local l_SeaLevelSettings_0 = v3.SeaLevelSettings;
local l_SelectionSettings_0 = v3.SelectionSettings;
local l_Tool_0 = v3.Tool;
local l_TransformSettings_0 = v3.TransformSettings;
return {
    getBrushPayload = function(v13, v14, v15)
        return {
            averageTime = v14,
            height = v13[l_Category_0.BrushSettings][l_BrushSettings_0.BrushSize].Height,
            locked = not not v13[l_Category_0.BrushSettings][l_BrushSettings_0.BrushSize].Locked or false,
            shape = v13[l_Category_0.BrushSettings][l_BrushSettings_0.BrushShape],
            size = v13[l_Category_0.BrushSettings][l_BrushSettings_0.BrushSize].Size,
            strength = v13[l_Category_0.BrushSettings][l_BrushSettings_0.Strength],
            tool = v15
        };
    end,
    getMaterialPayload = function(v16, v17)
        local v18 = v16[l_Category_0.MaterialSettings][l_MaterialSettings_0.AutoMaterial];
        local v19 = true;
        if v16[l_Category_0.MaterialSettings][l_MaterialSettings_0.FillMode] ~= l_FillMode_0.Replace then
            v19 = v16[l_Category_0.MaterialSettings][l_MaterialSettings_0.MaterialMode] == l_MaterialMode_0.Replace;
        end;
        local v20 = v16[l_Category_0.MaterialSettings][l_MaterialSettings_0.SourceMaterial];
        return {
            autoMaterial = v18,
            replace = v19,
            material = if v18 then nil else if not v19 then v20 else v16[l_Category_0.MaterialSettings][l_MaterialSettings_0.TargetMaterial],
            secondaryMaterial = if v18 then nil else if not v19 then nil else v20,
            tool = v17
        };
    end,
    getRegionPayload = function(v21, v22, v23)
        local v24 = if v23 == l_Tool_0.SeaLevel then v21[l_Category_0.SeaLevelSettings][l_SeaLevelSettings_0.Size] else if v23 == l_Tool_0.Transform then v21[l_Category_0.TransformSettings][l_TransformSettings_0.Size] else v21[l_Category_0.SelectionSettings][l_SelectionSettings_0.Size];
        local v25 = if v23 == l_Tool_0.SeaLevel then v21[l_Category_0.SeaLevelSettings][l_SeaLevelSettings_0.Transform] else if v23 == l_Tool_0.Transform then v21[l_Category_0.TransformSettings][l_TransformSettings_0.Transform] else v21[l_Category_0.SelectionSettings][l_SelectionSettings_0.Transform];
        return {
            averageTime = v22,
            position = v25.Position,
            rotation = v25.Rotation,
            size = v24,
            tool = v23
        };
    end,
    NormalizeBrushTimer = function(v26, v27, v28)
        local v29 = os.clock() - v26;
        local v30 = (v27 * v27) * v28;
        local v31 = (v29 * (v2.BrushNormalization ^ 3 / v30)) * 1000;
        if v30 < v2.BrushNormalizationMinVolume then
            return nil;
        elseif v2.SpikeThreshold < v31 then
            return v2.SpikeThreshold;
        else
            return v31;
        end;
    end,
    NormalizeDepthFirstSearch = function(v32, v33)
        return ((os.clock() - v32) * (v2.BrushNormalization ^ 2 / v33)) * 1000;
    end,
    NormalizeRegionTimer = function(v34, v35)
        local v36 = os.clock() - v34;
        local v37 = (v35.X * v35.Y) * v35.Z;
        local v38 = (v36 * (v2.RegionNormalization ^ 3 / v37)) * 1000;
        if v37 < v2.BrushNormalizationMinVolume then
            return nil;
        elseif v2.SpikeThreshold < v38 then
            return v2.SpikeThreshold;
        else
            return v38;
        end;
    end
};


local l_script_FirstAncestor_0 = script:FindFirstAncestor("TerrainEditor");
local v1 = require(l_script_FirstAncestor_0.Packages.Framework);
local _ = require(l_script_FirstAncestor_0.Src.Types);
local v3 = require(l_script_FirstAncestor_0.Src.Flags.getFFlagTerrainEditorGenerationFeature);
local v4 = require(l_script_FirstAncestor_0.Src.Flags.getFFlagTerrainEditorErrorHandling);
local v5 = require(l_script_FirstAncestor_0.Src.Flags.getFFlagTerrainEditorCompactMode);
local l_deepJoin_0 = v1.Util.deepJoin;
local v7 = require(l_script_FirstAncestor_0.Packages.Dash);
local function v8(v9, v10, v11)
    local l_Localization_0 = v9.Localization;
    local v13 = {};
    for v14, v15 in v10, nil, nil do
        local l_Id_0 = v15.Id;
        if (not v3() or not v15.Children) or not v11.Data[l_Id_0] then
            v13[v14] = v7.join({
                Hidden = v11.Data[l_Id_0] == nil,
                Label = l_Localization_0:getText(v11.Category, l_Id_0),
                Layout = if (((not not v5() and v15.Schema.Type ~= "Checkbox") and v15.Schema.Type ~= "Number") and v15.Schema.Type ~= "Button") and v9.Tool:getShouldBeCompact() then Enum.FillDirection.Vertical else nil,
                Value = v11.Data[l_Id_0]
            }, v15);
        else
            v13[v14] = v7.join({
                Hidden = v11.Data[l_Id_0] == nil,
                Label = l_Localization_0:getText(v11.Category, l_Id_0),
                Layout = if (((not not v5() and v15.Schema.Type ~= "Checkbox") and v15.Schema.Type ~= "Number") and v15.Schema.Type ~= "Button") and v9.Tool:getShouldBeCompact() then Enum.FillDirection.Vertical else nil,
                Value = v11.Data[l_Id_0].Value
            }, v15);
            v13[v14].Children = v8(v9, v15.Children, {
                Category = v11.Category,
                Data = v11.Data[l_Id_0].Children,
                Overrides = if not v11.Overrides[l_Id_0] then {} else v11.Overrides[l_Id_0].Children
            });
        end;
        if v11.Overrides[l_Id_0] then
            v13[v14] = l_deepJoin_0(v13[v14], v11.Overrides[l_Id_0]);
            if v11.Overrides[l_Id_0].Schema then
                v13[v14].Schema = v7.join(v13[v14].Schema, v11.Overrides[l_Id_0].Schema);
            end;
        end;
        if not (not v4() or not v13[v14].Validate) then
            local v17 = v9.Tool:getValidateFunction(v11.Category, l_Id_0);
            if not v17 then
                local l_Validate_0 = v13[v14].Validate;
                local function v22(v19)
                    local v20, v21 = l_Validate_0(v19);
                    if v20 == Enum.PropertyStatus.Error then
                        v9.Tool:reportError(v11.Category, l_Id_0, v19);
                        return v20, v21;
                    else
                        v9.Tool:clearError(v11.Category, l_Id_0);
                        return v20, v21;
                    end;
                end;
                v9.Tool:setValidateFunction(v11.Category, l_Id_0, v22);
                v13[v14].Validate = v22;
            else
                v13[v14].Validate = v17;
            end;
        end;
    end;
    return v13;
end;
return v8;


local l_script_FirstAncestor_0 = script:FindFirstAncestor("TerrainEditor");
local v1 = require(l_script_FirstAncestor_0.Src.Util.getPlaneIntersection);
local v2 = require(l_script_FirstAncestor_0.Src.Types);
local l_BrushSettings_0 = v2.BrushSettings;
local l_Category_0 = v2.Category;
local l_PlaneLock_0 = v2.PlaneLock;
return function(v6, v7, v8)
    local l_Position_0 = v8.Origin.Position;
    local v10 = v6[l_Category_0.BrushSettings][l_BrushSettings_0.PlaneTransform];
    local l_Direction_0 = v8.UnitRay.Direction;
    if v6[l_Category_0.BrushSettings][l_BrushSettings_0.PlaneLock] == l_PlaneLock_0.Auto then
        local l_LookVector_0 = v7.LookVector;
        local v13 = v1(l_Position_0, l_Direction_0, v7.Position, l_LookVector_0);
        return {
            Distance = (v13 - l_Position_0).Magnitude,
            Normal = l_LookVector_0,
            Position = v13
        };
    elseif v6[l_Category_0.BrushSettings][l_BrushSettings_0.PlaneLock] == l_PlaneLock_0.Manual then
        local v14 = v1(l_Position_0, l_Direction_0, v10.Position, v10.LookVector);
        return {
            Distance = (v14 - l_Position_0).Magnitude,
            Normal = v10.LookVector,
            Position = v14
        };
    else
        return nil;
    end;
end;


local v0 = require(script:FindFirstAncestor("TerrainEditor").Src.Util.ConvertTransformToRegion);
return function(v1, v2, v3, v4, v5)
    if not v5 then
        v2:ApplyTransform(v3.Rotation, v4);
    end;
    v1:PasteRegion(v2, v0(v3, v4).Min, false);
end;


local l_script_FirstAncestor_0 = script:FindFirstAncestor("TerrainEditor");
local l_Generation_0 = l_script_FirstAncestor_0.Src.Util.Generation;
local v2 = require(l_Generation_0.Filter);
local _ = require(l_Generation_0.Perlin);
local v4 = require(l_Generation_0.ProcessPerlin);
local _ = require(l_script_FirstAncestor_0.Src.Types);
return function(v6, v7)
    return function(v8, v9, _)
        local l_X_0 = v8.X;
        local l_Y_0 = v8.Y;
        local l_Z_0 = v8.Z;
        local v14 = Vector3.new(l_X_0, 0, l_Z_0);
        local l_WaterLevel_0 = v7.WaterLevel;
        local v16 = v2.Ridge((v4(v6(Vector3.new(l_X_0 + v6(v14, 5, 8) * 5, l_Y_0 / 8, l_Z_0 + v6(v14, 9, 8) * 5), 2, 20))));
        local v17 = v4(v6(Vector3.new(l_X_0, l_Y_0 / 4, l_Z_0), 436, 2));
        local v18 = v2.Threshold(v16, 0.8, 0.1);
        local v19 = v4(v6(v14, 6, 74)) - 0.5;
        local _ = nil;
        return ((0.55 + (v16 * 0.05) * v19) + if v19 < 0 then 1 + v19 * 0.5 < v16 and -0.17 or 0 else ((v18 * 0.1) * v17) * v19) + v4(v6(v14, 123, 25)) * 0.025, if 1 - v9 < l_WaterLevel_0 - 0.1 then Enum.Material.Glacier else if (v18 > 0.6 and v19 > 0.1) and v17 > 0.5 then Enum.Material.Glacier else Enum.Material.Snow, Enum.Material.Glacier;
    end;
end;


local l_script_FirstAncestor_0 = script:FindFirstAncestor("TerrainEditor");
local l_Generation_0 = l_script_FirstAncestor_0.Src.Util.Generation;
local v2 = require(l_Generation_0.Filter);
local _ = require(l_Generation_0.NoisySeed);
local _ = require(l_Generation_0.Perlin);
local v5 = require(l_Generation_0.ProcessPerlin);
local _ = require(l_script_FirstAncestor_0.Src.Types);
return function(v7, v8, v9)
    local v10 = {
        Enum.Material.Rock,
        Enum.Material.Mud,
        Enum.Material.Sand,
        Enum.Material.Sand,
        Enum.Material.Sandstone,
        Enum.Material.Sandstone,
        Enum.Material.Sandstone,
        Enum.Material.Sandstone,
        Enum.Material.Sandstone,
        Enum.Material.Sandstone
    };
    return function(v11, v12, _)
        local l_X_0 = v11.X;
        local l_Y_0 = v11.Y;
        local l_Z_0 = v11.Z;
        local v17 = Vector3.new(l_X_0, 0, l_Z_0);
        local l_WaterLevel_0 = v9.WaterLevel;
        local v19 = v2.RidgeFlipped(v5(v7(v17, 2, 200)));
        local v20 = v2.RidgeFlipped(v5(v7(Vector3.new(l_X_0 + v7(v17, 5, 20) * 20, 0, l_Z_0 + v7(v17, 9, 20) * 20), 2, 200)));
        local v21 = v2.Threshold(v20, 0, 0.05);
        return ((((((((((0.42 + v5(v7(v11, 2, 70)) * 0.05) + v19 * 0.05) + v21 * 0.04) + v2.Threshold(v20, 0.05, 0) * 0.08) + v2.Threshold(v20, 0.05, 0.075) * 0.04) + v2.Threshold(v20, 0.125, 0) * 0.01) + v2.Threshold(v20, 0.0575, 0.2725) * 0.01) + v2.Threshold(v19, 0.33, 0.12) * 0.06) + v2.Threshold(v20, 0.45, 0) * 0.14) + v2.Threshold(v20, 0.45, 0.04) * 0.025) + v2.Threshold(v20, 0.49, 0) * 0.02, if 1 - v12 < l_WaterLevel_0 + 0.015 then Enum.Material.Sand else if v21 > 0 and v21 < 1 then Enum.Material.Sand else Enum.Material.Sandstone, v10[math.ceil((1 - v8((Vector3.new(1, l_Y_0, 2)))) * 10)];
    end;
end;


local l_script_FirstAncestor_0 = script:FindFirstAncestor("TerrainEditor");
local l_Generation_0 = l_script_FirstAncestor_0.Src.Util.Generation;
local v2 = require(l_Generation_0.Filter);
local _ = require(l_Generation_0.Perlin);
local v4 = require(l_Generation_0.ProcessPerlin);
local _ = require(l_script_FirstAncestor_0.Src.Types);
return function(v6, _)
    return function(v8, _, _)
        local l_X_0 = v8.X;
        local l_Z_0 = v8.Z;
        local v13 = Vector3.new(l_X_0, 0, l_Z_0);
        local v14 = v4(v6(v13, 227, 20)) * 24;
        return 0.4 + 0.1 * (v2.Ridge(v4(v6(v13, 201, 40))) + v2.Ridge(v4(v6(Vector3.new(l_X_0 / 10 + v14, 0, l_Z_0 + v14), 200, 48)))), Enum.Material.Sand, Enum.Material.Sandstone;
    end;
end;


local l_script_FirstAncestor_0 = script:FindFirstAncestor("TerrainEditor");
local l_Generation_0 = l_script_FirstAncestor_0.Src.Util.Generation;
local v2 = require(l_Generation_0.Filter);
local _ = require(l_Generation_0.Perlin);
local v4 = require(l_Generation_0.ProcessPerlin);
local _ = require(l_script_FirstAncestor_0.Src.Types);
return function(v6, v7)
    return function(v8, v9, _)
        local _ = v8.X;
        local _ = v8.Y;
        local l_Z_0 = v8.Z;
        local l_WaterLevel_0 = v7.WaterLevel;
        local v15 = v2.RidgeFlipped(v4(v6(Vector3.new(v4(v6(v8, 17, 20)) * 20, 0, l_Z_0 + v4(v6(v8, 19, 20)) * 20), 2, 200))) ^ 0.5;
        local v16 = v4(v6(v8, 3, 60));
        local v17 = (0.48 + v16 * 0.05) + ((0.05 + v16 * 0.1) + v4(v6(v8, 4, 25)) * 0.125) * v15;
        local v18 = (1 - v9) * 0.9 + v15 * 0.1;
        return v17, if v18 < l_WaterLevel_0 - 0.015 then Enum.Material.Mud else if v18 < l_WaterLevel_0 then Enum.Material.Ground else Enum.Material.Grass, Enum.Material.Slate;
    end;
end;


local l_script_FirstAncestor_0 = script:FindFirstAncestor("TerrainEditor");
local l_Generation_0 = l_script_FirstAncestor_0.Src.Util.Generation;
local v2 = require(l_Generation_0.Filter);
local _ = require(l_Generation_0.Perlin);
local v4 = require(l_Generation_0.ProcessPerlin);
local _ = require(l_script_FirstAncestor_0.Src.Types);
return function(v6, v7)
    return function(v8, v9, _)
        local l_X_0 = v8.X;
        local l_Y_0 = v8.Y;
        local l_Z_0 = v8.Z;
        local l_WaterLevel_0 = v7.WaterLevel;
        local v15 = l_X_0 + v6(Vector3.new(l_X_0, l_Y_0 * 0.25, l_Z_0), 21, 8) * 5;
        local v16 = l_Y_0 + v6(Vector3.new(l_X_0, l_Y_0 * 0.25, l_Z_0), 22, 8) * 5;
        local v17 = l_Z_0 + v6(Vector3.new(l_X_0, l_Y_0 * 0.25, l_Z_0), 23, 8) * 5;
        local v18 = Vector3.new(v15, v16, v17);
        local v19 = v2.Ridge(v4(v6(Vector3.new(v15 + v6(v8, 22, 30) * 30, v16, v17 + v6(v8, 24, 30) * 30), 2, 120)));
        local v20 = v2.Ridge(v4(v6(v18, 3, 40))) * (v19 * 0.25 + 0.75);
        local v21 = v2.Ridge(v4(v6(v18, 4, 20))) * (v20 * 0.25 + 0.75);
        local v22 = v2.Threshold(v4(v6(v8, 9, 40)), 0.25, 0.5) * v4(v6(v8, 10, 60));
        local v23 = math.max(0, ((1 - v2.Threshold(v19, 0.975, 0)) - v2.Threshold(v20, 0.925, 0)) - v2.Threshold(v21, 0.9, 0));
        local v24 = v2.Threshold(v4(v6((CFrame.Angles(0.7, 0.7, 0) * Vector3.new(v15, v16, v17)) / Vector3.new(40, 300, 30), 123, 1)), 0.6, 0.4);
        local v25 = ((((l_WaterLevel_0 + 0.02) + (v23 * (0.5 + v22 * 0.5)) * 0.02) + v22 * 0.05) + v24 * 0.3) + ((not (l_WaterLevel_0 + 0.01 >= 1 - v9) or v24 > 0) and 0.04 or 0);
        local v26 = if v24 > 0 then Enum.Material.Rock else if v23 < 1 then Enum.Material.CrackedLava else Enum.Material.Basalt;
        return v25, if v26 == Enum.Material.CrackedLava and 1 - v9 < l_WaterLevel_0 then Enum.Material.Basalt else v26, v26;
    end;
end;


local l_script_FirstAncestor_0 = script:FindFirstAncestor("TerrainEditor");
local l_Generation_0 = l_script_FirstAncestor_0.Src.Util.Generation;
local v2 = require(l_Generation_0.Filter);
local _ = require(l_Generation_0.Perlin);
local v4 = require(l_Generation_0.ProcessPerlin);
local _ = require(l_script_FirstAncestor_0.Src.Types);
return function(v6, v7)
    return function(v8, v9, _)
        local l_X_0 = v8.X;
        local _ = v8.Y;
        local l_Z_0 = v8.Z;
        local v14 = Vector3.new(l_X_0, 0, l_Z_0);
        local l_WaterLevel_0 = v7.WaterLevel;
        local v16 = v4(v6(Vector3.new((l_X_0 + v6(v14, 5, 7) * 10) + v6(v14, 6, 30) * 50, 0, (l_Z_0 + v6(v14, 9, 7) * 10) + v6(v14, 10, 30) * 50), 2, 70));
        local v17 = v2.Threshold(v16, 0.65, 0);
        return (((l_WaterLevel_0 - 0.04) + (v16 * v17) * 0.025) + v4(v6(v8, 4, 100)) * 0.035) + v4(v6(v8, 3, 20)) * 0.025, if v17 >= 1 then Enum.Material.Grass else if 1 - v9 < l_WaterLevel_0 - 0.01 then Enum.Material.Mud else if 1 - v9 < l_WaterLevel_0 + 0.01 then Enum.Material.Ground else Enum.Material.Grass, Enum.Material.Slate;
    end;
end;


local l_script_FirstAncestor_0 = script:FindFirstAncestor("TerrainEditor");
local l_Generation_0 = l_script_FirstAncestor_0.Src.Util.Generation;
local v2 = require(l_Generation_0.Filter);
local v3 = require(l_Generation_0.Fractalize);
local _ = require(l_Generation_0.Perlin);
local v5 = require(l_Generation_0.ProcessPerlin);
local _ = require(l_script_FirstAncestor_0.Src.Types);
return function(v7, v8)
    local function v11(v9, v10)
        return v2.Ridge(v5(v7(v9, 100 + v10, (1 / v10) * 160)));
    end;
    return function(v12, v13, _)
        local l_X_0 = v12.X;
        local l_Y_0 = v12.Y;
        local l_Z_0 = v12.Z;
        local l_WaterLevel_0 = v8.WaterLevel;
        return (-0.4 + v3(v11, Vector3.new(l_X_0, l_Y_0 / 20, l_Z_0), {
            Samples = 8,
            Scale = 0.65
        }) * 1.2) + v2.RidgeFlipped(v5(v7(Vector3.new(l_X_0 + v5(v7(v12, 17, 20)) * 20, 0, l_Z_0 + v5(v7(v12, 19, 20)) * 20), 2, 200))) * 0.2, if v13 < 0.275 then Enum.Material.Snow else if v13 < 0.35 then Enum.Material.Rock else if v13 < 0.4 then Enum.Material.Ground else if 1 - v13 < l_WaterLevel_0 then Enum.Material.Rock else if 1 - v13 < l_WaterLevel_0 + 0.01 then Enum.Material.Mud else if 1 - v13 < l_WaterLevel_0 + 0.015 then Enum.Material.Ground else Enum.Material.Grass, Enum.Material.Rock;
    end;
end;


local l_script_FirstAncestor_0 = script:FindFirstAncestor("TerrainEditor");
local l_Generation_0 = l_script_FirstAncestor_0.Src.Util.Generation;
local v2 = require(l_Generation_0.Filter);
local _ = require(l_Generation_0.Perlin);
local v4 = require(l_Generation_0.ProcessPerlin);
local _ = require(l_script_FirstAncestor_0.Src.Types);
return function(v6, v7)
    return function(v8, v9, _)
        local l_X_0 = v8.X;
        local l_Y_0 = v8.Y;
        local l_Z_0 = v8.Z;
        local l_WaterLevel_0 = v7.WaterLevel;
        local v15 = v2.RidgeFlipped(v4(v6(Vector3.new(l_X_0 + v4(v6(v8, 17, 40)) * 25, 0, l_Z_0 + v4(v6(v8, 19, 40)) * 25), 2, 200)));
        local v16 = v2.Threshold(v15, 0.01, 0);
        local v17 = v2.Threshold(v2.RidgeFlipped(v4(v6(Vector3.new(l_X_0, 0, l_Z_0), 101, 7))), 0.3, 0.7) * v2.Threshold(v4(v6(Vector3.new(l_X_0, 0, l_Z_0), 102, 50)), 0.6, 0.05);
        local v18 = (((0.5 + v4(v6(v8, 2, 100)) * 0.02) + v15 * 0.05) + v17 * 0.05) + v16 * 0.005;
        local v19 = (1 - (l_Y_0 - 1) / (v7.MapHeight - 1)) * 0.5 + v18 * 0.5;
        local v20 = false;
        if 0.5 - v7.SurfaceThickness * 0.4 < v19 then
            v20 = v19 < 0.5 + v7.SurfaceThickness * 0.4;
        end;
        return v18, if v17 > 0 then Enum.Material.Rock else if v20 then if v20 and v16 <= 0 then Enum.Material.Water else if 1 - v9 < l_WaterLevel_0 - 0.01 then Enum.Material.Sand else Enum.Material.Grass else Enum.Material.Mud, v17 > 0 and Enum.Material.Rock or Enum.Material.Sandstone;
    end;
end;


local l_script_FirstAncestor_0 = script:FindFirstAncestor("TerrainEditor");
local l_Generation_0 = l_script_FirstAncestor_0.Src.Util.Generation;
local _ = require(l_Generation_0.Perlin);
local v3 = require(l_Generation_0.ProcessPerlin);
local _ = require(l_script_FirstAncestor_0.Src.Types);
return function(v5, _)
    return function(v7, v8, _)
        return 0.36 + v3(v5(v7, 2, 50)) * 0.08, if 1 - v8 < 0.44 then Enum.Material.Slate else Enum.Material.Sand, Enum.Material.Rock;
    end;
end;


local l_script_FirstAncestor_0 = script:FindFirstAncestor("TerrainEditor");
local v1 = require(script.Arctic);
local v2 = require(script.Canyons);
local v3 = require(script.Dunes);
local v4 = require(script.Hills);
local v5 = require(script.Lavascape);
local v6 = require(script.Marsh);
local v7 = require(script.Mountains);
local v8 = require(script.Plains);
local v9 = require(script.Water);
local l_Generation_0 = l_script_FirstAncestor_0.Src.Util.Generation;
local _ = require(l_Generation_0.NoisySeed);
local _ = require(l_Generation_0.Perlin);
local l_Biome_0 = require(l_script_FirstAncestor_0.Src.Types).Biome;
return function(v14, v15, v16)
    return {
        [l_Biome_0.Arctic] = v1(v14, v16),
        [l_Biome_0.Canyons] = v2(v14, v15, v16),
        [l_Biome_0.Dunes] = v3(v14, v16),
        [l_Biome_0.Hills] = v4(v14, v16),
        [l_Biome_0.Lavascape] = v5(v14, v16),
        [l_Biome_0.Marsh] = v6(v14, v16),
        [l_Biome_0.Mountains] = v7(v14, v16),
        [l_Biome_0.Plains] = v8(v14, v16),
        [l_Biome_0.Water] = v9(v14, v16)
    };
end;


return function(v0, v1, v2, v3, v4)
    local l_Air_0 = Enum.Material.Air;
    local v6 = {};
    for v7 = -1, 1 do
        for v8 = -1, 1 do
            for v9 = -1, 1 do
                local v10 = v0 + v7;
                local v11 = v1 + v8;
                local v12 = v2 + v9;
                if ((((v10 > 0 and v10 <= v4.X) and v11 > 0) and v11 <= v4.Y) and v12 > 0) and v12 <= v4.Z then
                    local v13 = v3[v10][v11][v12];
                    if v13 ~= Enum.Material.Air then
                        v6[v13] = (v6[v13] or 0) + 1;
                        if v6[v13] > 0 then
                            l_Air_0 = v13;
                        end;
                    end;
                end;
            end;
        end;
    end;
    if l_Air_0 ~= Enum.Material.Air then
        return l_Air_0;
    else
        return nil;
    end;
end;


local l_VoxelResolution_0 = require(script:FindFirstAncestor("TerrainEditor").Src.Resources.Constants).VoxelResolution;
return function(v1, v2)
    return (math.clamp((v2 - v1) / l_VoxelResolution_0, 0, 1));
end;


return function(v0, v1)
    return (math.cos(math.min(1, v0 / v1) * 1.5707963267948966));
end;


return function(v0, v1)
    local v2 = -1;
    local v3 = 0;
    for v4, v5 in v0, nil, nil do
        for v6, v7 in v5, nil, nil do
            for v8, v9 in v7, nil, nil do
                if v9 == Enum.Material.Water then
                    local v10 = v1[v4][v6][v8];
                    if v2 < v6 then
                        v2 = v6;
                        v3 = v1[v4][v6][v8];
                    elseif v6 == v2 and v3 < v10 then
                        v3 = v10;
                    end;
                end;
            end;
        end;
    end;
    return v2, v3;
end;


local v0 = require(script:FindFirstAncestor("TerrainEditor").Src.Resources.Constants);
return function(v1, v2, v3)
    local v4 = Vector3.new(v2, v3 * 0.5, v2);
    local v5 = v1 - v4;
    local v6 = v1 + v4;
    return Vector3.new(math.floor(v5.X / v0.VoxelResolution), math.floor(v5.Y / v0.VoxelResolution), (math.floor(v5.Z / v0.VoxelResolution))) * v0.VoxelResolution, Vector3.new(math.ceil(v6.X / v0.VoxelResolution), math.ceil(v6.Y / v0.VoxelResolution), (math.ceil(v6.Z / v0.VoxelResolution))) * v0.VoxelResolution;
end;


return function(v0)
    local v1 = {};
    for v2, v3 in v0, nil, nil do
        if typeof(v3) == "Vector3" then
            v1[("%*X"):format(v2)] = v3.X;
            v1[("%*Y"):format(v2)] = v3.Y;
            v1[("%*Z"):format(v2)] = v3.Z;
        elseif typeof(v3) == "EnumItem" then
            v1[v2] = v3.Name;
        else
            v1[v2] = v3;
        end;
    end;
    return v1;
end;


local l_PivotPosition_0 = require(script:FindFirstAncestor("TerrainEditor").Src.Types).PivotPosition;
return function(v1, v2, v3)
    local v4 = v3 / 2;
    if v1 == l_PivotPosition_0.Top then
        return (Vector3.new(v2.X, v2.Y - v4, v2.Z));
    elseif v1 == l_PivotPosition_0.Bottom then
        return (Vector3.new(v2.X, v2.Y + v4, v2.Z));
    else
        return v2;
    end;
end;


local l_script_FirstAncestor_0 = script:FindFirstAncestor("TerrainEditor");
local v1 = require(l_script_FirstAncestor_0.Src.Util.getBoundingBox);
local v2 = require(l_script_FirstAncestor_0.Src.Flags.getFFlagTerrainEditorErrorHandling);
return function(v3, v4, v5)
    local v6 = nil;
    local v7 = nil;
    if not v2() then
        local v8 = {
            Vector3.new(v4.X / 2, v4.Y / 2, v4.Z / 2),
            Vector3.new(-v4.X / 2, v4.Y / 2, v4.Z / 2),
            Vector3.new(v4.X / 2, -v4.Y / 2, v4.Z / 2),
            Vector3.new(v4.X / 2, v4.Y / 2, -v4.Z / 2),
            Vector3.new(-v4.X / 2, -v4.Y / 2, v4.Z / 2),
            Vector3.new(-v4.X / 2, v4.Y / 2, -v4.Z / 2),
            Vector3.new(v4.X / 2, -v4.Y / 2, -v4.Z / 2),
            (Vector3.new(-v4.X / 2, -v4.Y / 2, -v4.Z / 2))
        };
        v6 = Vector3.new(math.huge, math.huge, math.huge);
        v7 = Vector3.new(-math.huge, -math.huge, -math.huge);
        for _, v10 in v8, nil, nil do
            local v11 = if not v5 then v3 * v10 else v3.Position + v10;
            v6 = Vector3.new(math.min(v6.X, v11.X), math.min(v6.Y, v11.Y), (math.min(v6.Z, v11.Z)));
            v7 = Vector3.new(math.max(v7.X, v11.X), math.max(v7.Y, v11.Y), (math.max(v7.Z, v11.Z)));
        end;
    else
        local v12, v13 = v1(v3, v4, v5);
        v6 = v12;
        v7 = v13;
    end;
    return (Region3int16.new(Vector3int16.new(math.floor(v6.X / 4), math.floor(v6.Y / 4), (math.floor(v6.Z / 4))), Vector3int16.new(math.ceil(v7.X / 4), math.ceil(v7.Y / 4), (math.ceil(v7.Z / 4)))));
end;


local v0 = require(script.Parent.Parent.Parent.Src.Util.ConvertTransformToRegion);
local function _(v1)
    return (Vector3.new(math.floor(v1.X), math.floor(v1.Y), (math.floor(v1.Z))));
end;
local function _(v3)
    return (Vector3.new(math.ceil(v3.X), math.ceil(v3.Y), (math.ceil(v3.Z))));
end;
return function(v5, v6)
    local v7 = {};
    local v8 = {};
    local v9 = v0(v5, v6);
    local v10 = Vector3.new(v9.Min.X, v9.Min.Y, v9.Min.Z);
    local v11 = Vector3.new(v9.Max.X, v9.Max.Y, v9.Max.Z);
    local v12 = v10 / 400;
    local v13 = Vector3.new(math.floor(v12.X), math.floor(v12.Y), (math.floor(v12.Z))) * 400;
    local v14 = v11 / 400;
    local v15 = Vector3.new(math.ceil(v14.X), math.ceil(v14.Y), (math.ceil(v14.Z))) * 400;
    v12 = Region3int16.new(Vector3int16.new(v13.X, v13.Y, v13.Z), Vector3int16.new(v15.X, v15.Y, v15.Z));
    for v16 = v12.Min.X, v12.Max.X, 400 do
        for v17 = v12.Min.Y, v12.Max.Y, 400 do
            for v18 = v12.Min.Z, v12.Max.Z, 400 do
                local v19 = Vector3.new(v16, v17, v18):Max(v10);
                local v20 = Vector3.new(v16 + 400, v17 + 400, v18 + 400):Min(v11);
                if (v20.X > v19.X and v20.Y > v19.Y) and v20.Z > v19.Z then
                    table.insert(v7, Region3int16.new(Vector3int16.new(v19.X, v19.Y, v19.Z) - v9.Min, Vector3int16.new(v20.X, v20.Y, v20.Z) - v9.Min));
                    table.insert(v8, (Vector3int16.new(v19.X, v19.Y, v19.Z)));
                end;
            end;
        end;
    end;
    return v7, v8;
end;


return function(v0, v1, v2, v3)
    local l_Air_0 = Enum.Material.Air;
    local v5 = {};
    for v6 = -1, 1 do
        for v7 = -1, 1 do
            for v8 = -1, 1 do
                local v9 = v1 + Vector3.new(v6, v7, v8);
                if ((((v9.X > 0 and v9.X <= v2.X) and v9.Y > 0) and v9.Y <= v2.Y) and v9.Z > 0) and v9.Z <= v2.Z then
                    local v10 = v0[v9.X][v9.Y][v9.Z];
                    if v10 ~= Enum.Material.Air and (not v3 or v10 ~= Enum.Material.Water) then
                        v5[v10] = (v5[v10] or 0) + 1;
                        if v5[v10] > 0 then
                            l_Air_0 = v10;
                        end;
                    end;
                end;
            end;
        end;
    end;
    if l_Air_0 ~= Enum.Material.Air and (not v3 or l_Air_0 ~= Enum.Material.Water) then
        return l_Air_0;
    else
        return nil;
    end;
end;


local l_script_FirstAncestor_0 = script:FindFirstAncestor("TerrainEditor");
local v1 = require(l_script_FirstAncestor_0.Src.Resources.Constants);
local l_BrushShape_0 = require(l_script_FirstAncestor_0.Src.Types).BrushShape;
return function(v3, v4, v5, v6)
    local v7 = 1;
    local v8 = 1;
    if v4 > 2 then
        if v5 == l_BrushShape_0.Sphere then
            local v9 = math.sqrt((v3.X * v3.X + v3.Y * v3.Y) + v3.Z * v3.Z);
            return math.max(0, (math.min(1, (v6 - v9) / v1.VoxelResolution))), (math.cos((math.min(1, v9 / v6) * 3.141592653589793) * 0.5));
        elseif v5 == l_BrushShape_0.Cylinder then
            local v10 = math.sqrt(v3.X * v3.X + v3.Z * v3.Z);
            v8 = math.cos((math.min(1, v10 / v6) * 3.141592653589793) * 0.5);
            v7 = math.max(0, (math.min(1, (v6 - v10) / v1.VoxelResolution)));
        end;
    end;
    return v7, v8;
end;


local l_Workspace_0 = game:GetService("Workspace");
local v1 = require(script.Parent.Parent.Parent.Packages.TestLoader);
local v2 = v1.hasInternalPermission();
local v3 = v1.isCli();
local function _(v4, v5)
    local v6 = v5 or false;
    return function()
        local l_TerrainEditorFlags_0 = l_Workspace_0:FindFirstChild("TerrainEditorFlags");
        if l_TerrainEditorFlags_0 and l_TerrainEditorFlags_0:FindFirstChild(v4) then
            return l_TerrainEditorFlags_0[v4].Value;
        else
            return v6;
        end;
    end;
end;
local v9 = {};
local v10 = v3 or false;
local v11 = "RunningUnderCLI";
local l_v11_0 = v11 --[[ copy: 9 -> 11 ]];
local l_v10_0 = v10 --[[ copy: 8 -> 12 ]];
v9.RunningUnderCLI = function()
    local l_TerrainEditorFlags_1 = l_Workspace_0:FindFirstChild("TerrainEditorFlags");
    if l_TerrainEditorFlags_1 and l_TerrainEditorFlags_1:FindFirstChild(l_v11_0) then
        return l_TerrainEditorFlags_1[l_v11_0].Value;
    else
        return l_v10_0;
    end;
end;
v10 = "RunTests";
v11 = false;
local l_v10_1 = v10 --[[ copy: 8 -> 13 ]];
local l_v11_1 = v11 --[[ copy: 9 -> 14 ]];
v9.RunTests = function()
    local l_TerrainEditorFlags_2 = l_Workspace_0:FindFirstChild("TerrainEditorFlags");
    if l_TerrainEditorFlags_2 and l_TerrainEditorFlags_2:FindFirstChild(l_v10_1) then
        return l_TerrainEditorFlags_2[l_v10_1].Value;
    else
        return l_v11_1;
    end;
end;
v10 = "LogTestsQuiet";
v11 = false;
local l_v10_2 = v10 --[[ copy: 8 -> 15 ]];
local l_v11_2 = v11 --[[ copy: 9 -> 16 ]];
v9.LogTestsQuiet = function()
    local l_TerrainEditorFlags_3 = l_Workspace_0:FindFirstChild("TerrainEditorFlags");
    if l_TerrainEditorFlags_3 and l_TerrainEditorFlags_3:FindFirstChild(l_v10_2) then
        return l_TerrainEditorFlags_3[l_v10_2].Value;
    else
        return l_v11_2;
    end;
end;
v10 = "LogAnalytics";
v11 = false;
local l_v10_3 = v10 --[[ copy: 8 -> 17 ]];
local l_v11_3 = v11 --[[ copy: 9 -> 18 ]];
v9.LogAnalytics = function()
    local l_TerrainEditorFlags_4 = l_Workspace_0:FindFirstChild("TerrainEditorFlags");
    if l_TerrainEditorFlags_4 and l_TerrainEditorFlags_4:FindFirstChild(l_v10_3) then
        return l_TerrainEditorFlags_4[l_v10_3].Value;
    else
        return l_v11_3;
    end;
end;
v10 = "ProfileTools";
v11 = true;
local l_v10_4 = v10 --[[ copy: 8 -> 19 ]];
local l_v11_4 = v11 --[[ copy: 9 -> 20 ]];
v9.ProfileTools = function()
    local l_TerrainEditorFlags_5 = l_Workspace_0:FindFirstChild("TerrainEditorFlags");
    if l_TerrainEditorFlags_5 and l_TerrainEditorFlags_5:FindFirstChild(l_v10_4) then
        return l_TerrainEditorFlags_5[l_v10_4].Value;
    else
        return l_v11_4;
    end;
end;
v10 = "RunDeveloperFrameworkTests";
v11 = false;
local l_v11_5 = v11 --[[ copy: 9 -> 21 ]];
v9.RunDeveloperFrameworkTests = function()
    local l_TerrainEditorFlags_6 = l_Workspace_0:FindFirstChild("TerrainEditorFlags");
    if l_TerrainEditorFlags_6 and l_TerrainEditorFlags_6:FindFirstChild(v10) then
        return l_TerrainEditorFlags_6[v10].Value;
    else
        return l_v11_5;
    end;
end;
v11 = (v3 or v2) or false;
local v29 = "EnableRoactConfigs";
v9.EnableRoactConfigs = function()
    local l_TerrainEditorFlags_7 = l_Workspace_0:FindFirstChild("TerrainEditorFlags");
    if l_TerrainEditorFlags_7 and l_TerrainEditorFlags_7:FindFirstChild(v29) then
        return l_TerrainEditorFlags_7[v29].Value;
    else
        return v11;
    end;
end;
return v9;


return function(v0, v1)
    local v2 = math.floor(v0 / 60);
    local v3 = math.floor(v2 / 60);
    if v3 > 0 then
        return v1:getText("Time", "HoursAndMinutes", {
            Hours = v3,
            Minutes = v2 % 60
        });
    elseif v2 > 10 then
        return v1:getText("Time", "Minutes", {
            Minutes = v2
        });
    elseif v2 >= 1 then
        return v1:getText("Time", "MinutesAndSeconds", {
            Minutes = v2,
            Seconds = (math.floor(v0 / 10) * 10) % 60
        });
    else
        return v1:getText("Time", "Seconds", {
            Seconds = v0
        });
    end;
end;


return function(v0)
    local v1 = 0;
    for v2 = 1, #v0 do
        local v3 = v0:sub(v2, v2);
        local v4 = tonumber(v3);
        v1 = if not v4 then (v1 + 7) * (v3:byte() + 3) else (v1 + 6) * (v4 + 5) % 61803;
    end;
    return v1;
end;


return {
    Threshold = function(v0, v1, v2)
        if v2 ~= 0 then
            return (math.clamp((v0 - v1) / v2, 0, 1));
        elseif v0 <= v1 then
            return 0;
        else
            return 1;
        end;
    end,
    Ridge = function(v3)
        if v3 < 0.5 then
            return v3 * 2;
        else
            return 2 - v3 * 2;
        end;
    end,
    RidgeFlipped = function(v4)
        if v4 < 0.5 then
            return 1 - v4 * 2;
        else
            return v4 * 2 - 1;
        end;
    end
};


local l_Biome_0 = require(script:FindFirstAncestor("TerrainEditor").Src.Types).Biome;
return function(v1, v2, v3, v4)
    if v1 == l_Biome_0.Arctic then
        return (v2 > 0.2 and 1 or 0) * v3;
    elseif v1 == l_Biome_0.Canyons then
        return (v2 > 0.7 and 1 or 0) * v3;
    elseif v1 == l_Biome_0.Mountains then
        local v5 = v2 ^ 3;
        return v4 * (1 - v5) + v3 * v5;
    else
        return v4 * (1 - v2) + v3 * v2;
    end;
end;


return function(v0, v1, v2)
    return function(v3, v4, v5, v6)
        local v7 = 0;
        local l_v3_0 = v3;
        local l_v4_0 = v4;
        local v10 = 1;
        for _ = 1, v0 do
            v7 = v7 + math.noise(l_v3_0 / v6, l_v4_0 / v6, v5) * v10;
            l_v4_0 = l_v4_0 * v1;
            l_v3_0 = l_v3_0 * v1;
            v10 = v10 * v2;
        end;
        return (math.clamp(v7, -1, 1));
    end;
end;


return function(v0, v1, v2)
    local v3 = v2.Samples or 3;
    local v4 = v2.Scale or 0.5;
    local v5 = v2.Offset or 0;
    local v6 = v2.Gain or 1;
    local v7 = 0;
    local v8 = 0;
    for v9 = 1, v3 do
        local v10 = v4 ^ (v9 - 1);
        v8 = v8 + v10;
        v7 = v7 + (v5 + v6 * v0(v1, v9)) * v10;
    end;
    return v7 / v8;
end;


local function _(v0, v1)
    assert(v1 > 0, "w should be greater than 0");
    return 1 - math.exp(-(v0 * v0) / ((2 * v1) * v1));
end;
return function(v3, v4)
    local l_CurveWidth_0 = v4.CurveWidth;
    local l_Distance_0 = v4.Distance;
    local l_PreserveDistance_0 = v4.PreserveDistance;
    local l_PreserveRatio_0 = v4.PreserveRatio;
    local l_RoundCorner_0 = v4.RoundCorner;
    local v10 = if v3.Y <= v3.X then v3.X else v3.Y;
    local v11 = if v3.Y <= v3.X then v3.Y else v3.X;
    local v12 = Vector2.new(v10 / 2, v11 / 2);
    local v13 = (v10 - v11) * l_PreserveRatio_0;
    local v14 = table.create(v3.X * v3.Y, 0);
    for v15 = 1, v10 do
        for v16 = 1, v11 do
            local v17 = 0;
            local v18 = v12 - Vector2.new(v13 / 2, 0);
            local v19 = v12 + Vector2.new(v13 / 2, 0);
            local v20 = v18.Magnitude * l_PreserveDistance_0;
            local v21 = (v18.Magnitude - v20) * l_Distance_0;
            local v22 = 0;
            if not (v15 >= v18.X) or v19.X < v15 then
                local v23 = Vector2.new(v15, v16);
                local v24 = if v15 < v18.X then v23 - v18 else v23 - v19;
                v22 = v24.Magnitude * l_RoundCorner_0 + math.max(math.abs(v24.X), (math.abs(v24.Y))) * (1 - l_RoundCorner_0);
            else
                v22 = if v12.Y < v16 then v16 - v12.Y else v12.Y - v16;
            end;
            if v20 < v22 then
                v17 = math.clamp((v22 - v20) / v21, 0, 1);
                if v17 > 0 and v17 < 1 then
                    local l_v17_0 = v17;
                    assert(l_CurveWidth_0 > 0, "w should be greater than 0");
                    v17 = 1 - math.exp(-(l_v17_0 * l_v17_0) / ((2 * l_CurveWidth_0) * l_CurveWidth_0));
                end;
                v14[if v3.Y <= v3.X then (v15 - 1) * v3.Y + v16 else (v16 - 1) * v3.Y + v15] = v17;
            end;
        end;
    end;
    return v14;
end;


local v0 = require(script:FindFirstAncestor("TerrainEditor").Src.Types);
return {
    FromPreset = function(v1, v2)
        local v3 = v1.Unit == v0.MaterialUnit.Percentage;
        local l_MaterialList_0 = v1.MaterialList;
        local l_FillMaterial_0 = v1.FillMaterial;
        if not l_MaterialList_0 or #l_MaterialList_0 == 0 then
            return nil;
        else
            local l_HeightInPercentage_0 = v2.HeightInPercentage;
            local l_HeightInStud_0 = v2.HeightInStud;
            local l_Position_0 = v2.Position;
            local l_Slope_0 = v2.Slope;
            if not (not v2.FillBottom or not l_FillMaterial_0) and l_Slope_0 < 10 then
                return l_FillMaterial_0;
            else
                local v10 = {};
                for _, v12 in l_MaterialList_0, nil, nil do
                    local l_MinHeight_0 = v12.MinHeight;
                    local l_MaxHeight_0 = v12.MaxHeight;
                    local v15 = if not v3 then l_HeightInStud_0 else l_HeightInPercentage_0;
                    if l_MinHeight_0 <= v15 and v15 <= l_MaxHeight_0 then
                        table.insert(v10, v12);
                    end;
                end;
                if #v10 <= 0 then
                    return nil;
                elseif #v10 == 1 then
                    return v10[1].Material;
                else
                    local v16 = {};
                    for _, v18 in v10, nil, nil do
                        local l_MinSlope_0 = v18.MinSlope;
                        local l_MaxSlope_0 = v18.MaxSlope;
                        if l_MinSlope_0 <= l_Slope_0 and l_Slope_0 <= l_MaxSlope_0 then
                            table.insert(v16, v18);
                        end;
                    end;
                    if #v16 == 1 then
                        return v16[1].Material;
                    else
                        local v21 = if #v16 > 1 then v16 else v10;
                        return v21[math.ceil((math.clamp(math.noise(l_Position_0.X, l_Position_0.Z, 0.12345), -1, 1) * 0.5 + 0.5) * #v21)].Material;
                    end;
                end;
            end;
        end;
    end,
    Blend = function(v22, v23, v24)
        local l_BlendingFactor_0 = v24.BlendingFactor;
        local l_EdgePosition_0 = v24.EdgePosition;
        local l_Width_0 = v24.Width;
        local v28 = l_EdgePosition_0 - l_Width_0 / 2;
        local v29 = l_EdgePosition_0 + l_Width_0 / 2;
        if l_BlendingFactor_0 < v28 then
            return v22;
        elseif v29 < l_BlendingFactor_0 then
            return v23;
        elseif (l_BlendingFactor_0 - v28) / (v29 - v28) < math.random() then
            return v22;
        else
            return v23;
        end;
    end
};


local v0 = {};
v0.__index = v0;
local l_script_FirstAncestor_0 = script:FindFirstAncestor("TerrainEditor");
local v2 = require(l_script_FirstAncestor_0.Src.Types);
local v3 = require(l_script_FirstAncestor_0.Src.Resources.Constants);
local function v15(v4, v5, v6, v7, v8, v9, v10)
    local v11 = {};
    local v12 = #v5;
    local v13 = v4 + (v4 * v7) * (math.random() * 2 - 1);
    for v14 = 1, v12 do
        if v5[v14][v6][1] <= v13 and v13 <= v5[v14][v6][2] then
            table.insert(v11, v5[v14]);
        end;
    end;
    if not (#v11 == 0) or not v8 then
        return v11;
    elseif v13 < v9[v6][1] then
        return {
            v9
        };
    elseif v10[v6][2] < v13 then
        return {
            v10
        };
    else
        return nil;
    end;
end;
local function v18(v16, v17)
    return v16.priority < v17.priority;
end;
v0.new = function(v19)
    local v20 = v19.Unit == v2.MaterialUnit.Percentage;
    local l_MaterialList_0 = v19.MaterialList;
    local l_FillMaterial_0 = v19.FillMaterial;
    local l_FallbackMaterial_0 = v19.FallbackMaterial;
    local v24 = table.create(1050624, l_FallbackMaterial_0);
    local l_Min_0 = v19.Min;
    local l_Max_0 = v19.Max;
    local v27 = {};
    for _, v29 in ipairs(l_MaterialList_0) do
        local v30 = {};
        if not v20 then
            local v31 = false;
            if v29.MinHeight <= v29.MaxHeight then
                v31 = v29.MinHeight >= 0;
            end;
            assert(v31, "invalid minimum height input");
            v30.heightRange = {
                v29.MinHeight,
                v29.MaxHeight
            };
            l_Min_0 = math.min(l_Min_0, v29.MinHeight);
            l_Max_0 = math.max(l_Max_0, v29.MaxHeight);
        else
            local v32 = false;
            if v29.MinHeight <= 1 then
                v32 = v29.MinHeight >= 0;
            end;
            assert(v32, "invalid minimum height input");
            v32 = false;
            if v29.MaxHeight <= 1 then
                v32 = v29.MaxHeight >= 0;
            end;
            assert(v32, "invalid maximum height input");
            v30.heightRange = {
                v29.MinHeight,
                v29.MaxHeight
            };
        end;
        assert(v29.MinSlope <= v29.MaxSlope, "invalid slope input");
        local v33 = false;
        if v29.MinSlope <= 90 then
            v33 = v29.MinSlope >= 0;
        end;
        assert(v33, "invalid minimum slope input");
        v33 = false;
        if v29.MaxSlope <= 90 then
            v33 = v29.MaxSlope >= 0;
        end;
        assert(v33, "invalid maximum slope input");
        v30.slopeRange = {
            (v29.MinSlope / 180) * 3.141592653589793,
            (v29.MaxSlope / 180) * 3.141592653589793
        };
        v30.value = v29.Material;
        v30.priority = v29.Priority;
        table.insert(v27, v30);
    end;
    table.sort(v27, v18);
    for v34 = 1, 1024 do
        local v35 = (v34 - 1) / 1023;
        local v36 = nil;
        v36 = if not v20 then v15(v35 * (l_Max_0 - l_Min_0) + l_Min_0, v27, "heightRange", 0, false) else v15(v35, v27, "heightRange", 0, false);
        for v37 = 1, 1024 do
            if not v36 or #v36 == 0 then
                v24[v34 * 1024 + v37] = l_FallbackMaterial_0;
            else
                local v38 = v15(((v37 - 1) / 1023) * 1.5707963267948966, v36, "slopeRange", 0, false);
                v24[v34 * 1024 + v37] = if not not v38 and #v38 > 0 then v38[1].value else l_FallbackMaterial_0;
            end;
        end;
    end;
    local v39 = setmetatable({}, v0);
    v39._lut = v24;
    v39._isPercentage = v20;
    v39._resolution = {
        1024,
        1024
    };
    if not v39._isPercentage then
        v39.GetValue = v39._getValueStud;
    else
        v39.GetValue = v39._getValuePercentage;
    end;
    if not v39._isPercentage then
        v39.GetValueByIndex = v39._getValueStudSlopeIndex;
    else
        v39.GetValueByIndex = v39._getValuePercentageSlopeIndex;
    end;
    v39._maxHeight = l_Max_0;
    v39._minHeight = l_Min_0;
    v39._heightRange = l_Max_0 - l_Min_0;
    v39.fallbackMaterial = l_FallbackMaterial_0;
    v39.fillMaterial = l_FillMaterial_0;
    v39.GetSlopeIndex = v39._getSlopeIndex;
    return v39;
end;
v0._getSlopeIndex = function(_, v41)
    return (math.clamp(math.floor((v41 / 1.5707963267948966) * 1023 + 1), 1, 1024));
end;
v0._getValuePercentage = function(v42, v43, v44, v45)
    return v42._lut[math.clamp(math.floor((v43 / v44) * 1023 + 1), 0, 1025) * 1024 + math.clamp(math.floor((v45 / 1.5707963267948966) * 1023 + 1), 1, 1024)];
end;
v0._getValueStud = function(v46, v47, _, v49)
    return v46._lut[math.clamp(math.floor(((v47 * v3.VoxelResolution - v46._minHeight) / v46._heightRange) * 1023 + 1), 0, 1025) * 1024 + math.clamp(math.floor((v49 / 1.5707963267948966) * 1023 + 1), 1, 1024)];
end;
v0._getValuePercentageSlopeIndex = function(v50, v51, v52, v53)
    return v50._lut[math.clamp(math.floor((v51 / v52) * 1023 + 1), 0, 1025) * 1024 + v53];
end;
v0._getValueStudSlopeIndex = function(v54, v55, _, v57)
    return v54._lut[math.clamp(math.floor(((v55 * v3.VoxelResolution - v54._minHeight) / v54._heightRange) * 1023 + 1), 0, 1025) * 1024 + v57];
end;
return v0;


local v0 = require(script:FindFirstAncestor("TerrainEditor").Src.Flags.getFFlagTerrainEditorIndexingBugFix);
return function(v1)
    local v2 = nil;
    math.randomseed(6180339);
    v2 = {};
    for _ = 1, 999 do
        table.insert(v2, math.random());
    end;
    local _ = nil;
    return not v0() and function(v5)
        local l_X_0 = v5.X;
        local l_Y_0 = v5.Y;
        local l_Z_0 = v5.Z;
        return v2[math.floor(((((((l_X_0 + l_Y_0) + l_Z_0) + 7) + v1) + (v1 - l_X_0) * (7 + l_Z_0)) + (7 - l_Y_0) * (v1 + l_Z_0)) % #v2) + 1];
    end or function(v9)
        local l_X_1 = v9.X;
        local l_Y_1 = v9.Y;
        local l_Z_1 = v9.Z;
        local v13 = (((((l_X_1 + l_Y_1) + l_Z_1) + 7) + v1) + (v1 - l_X_1) * (7 + l_Z_1)) + (7 - l_Y_1) * (v1 + l_Z_1);
        local v14 = math.floor((math.fmod(v13, #v2)));
        if v13 < 0 then
            v14 = (v14 + #v2) - 1;
        end;
        return v2[v14 + 1];
    end;
end;


return function(v0)
    return function(v1, v2, v3)
        local v4 = v3 or 1;
        return math.noise((v1.X / v4 + v2 * 17) + v0, v1.Y / v4 - v0, v1.Z / v4 - v2 * v2);
    end;
end;


local l_script_FirstAncestor_0 = script:FindFirstAncestor("TerrainEditor");
local v1 = require(l_script_FirstAncestor_0.Src.Util.BiomeGenerators);
local v2 = require(l_script_FirstAncestor_0.Src.Util.Generation.FindBiomeTransitionValue);
local l_Generation_0 = l_script_FirstAncestor_0.Src.Util.Generation;
local v4 = require(l_Generation_0.Filter);
local _ = require(l_Generation_0.NoisySeed);
local _ = require(l_Generation_0.Perlin);
local v7 = require(l_Generation_0.ProcessPerlin);
local _ = require(l_script_FirstAncestor_0.Src.Types);
return function(v9, v10, v11)
    local v12 = v1(v9, v10, v11);
    return function(v13, v14, v15)
        local l_Y_0 = v13.Y;
        local l_X_0 = v14.X;
        local l_Y_1 = v14.Y;
        local l_Z_0 = v14.Z;
        local l_Biomes_0 = v11.Biomes;
        local l_DefaultBiomeFill_0 = v11.DefaultBiomeFill;
        local l_DefaultBiomeSurface_0 = v11.DefaultBiomeSurface;
        local l_DefaultBiomeValue_0 = v11.DefaultBiomeValue;
        local l_HasCaves_0 = v11.HasCaves;
        local l_MapHeight_0 = v11.MapHeight;
        local l_SurfaceThickness_0 = v11.SurfaceThickness;
        local l_WaterLevel_0 = v11.WaterLevel;
        local v28 = Vector3.new(l_X_0, l_Y_0, l_Z_0);
        local v29 = 1 - (l_Y_0 - 1) / (l_Y_1 - 1);
        local v30 = v29 * 0.9 + 0.1 * v7(v9(v28, 107, 15));
        local v31 = 0;
        local l_CrackedLava_0 = Enum.Material.CrackedLava;
        local l_Rock_0 = Enum.Material.Rock;
        if not (v29 <= 0.65) or v29 < 0.1 then
            v31 = 0.5;
        elseif #l_Biomes_0 == 1 then
            local v34 = v12[l_Biomes_0[1]];
            if not v34 then
                v31 = l_DefaultBiomeValue_0;
                l_CrackedLava_0 = l_DefaultBiomeSurface_0;
                l_Rock_0 = l_DefaultBiomeFill_0;
            else
                local v35, v36, v37 = v34(v28, v30);
                v31 = v35;
                l_CrackedLava_0 = v36;
                l_Rock_0 = v37;
            end;
        else
            local v38 = 0;
            for v39, v40 in v15.WeightPoints, nil, nil do
                local v41 = v12[v39];
                if not v41 then
                    v40.BiomeValue = l_DefaultBiomeValue_0;
                    v40.BiomeSurface = l_DefaultBiomeSurface_0;
                    v40.BiomeFill = l_DefaultBiomeFill_0;
                else
                    local v42, v43, v44 = v41(v28, v30);
                    v40.BiomeValue = v42;
                    v40.BiomeSurface = v43;
                    v40.BiomeFill = v44;
                end;
                v38 = v38 + v40.BiomeValue * v40.Weight;
            end;
            for v45, v46 in v15.WeightPoints, nil, nil do
                local v47 = v2(v45, v46.Weight, v46.BiomeValue, v38);
                if v31 < v47 then
                    v31 = v47;
                    l_CrackedLava_0 = v46.BiomeSurface;
                    l_Rock_0 = v46.BiomeFill;
                end;
            end;
        end;
        local v48 = v29 * 0.5 + v31 * 0.5;
        local v49 = false;
        if 0.5 - l_SurfaceThickness_0 < v48 then
            v49 = v48 < 0.5 + l_SurfaceThickness_0;
        end;
        local v50 = 0;
        local v51 = v15.HasCaves or v29 > 0.65;
        local v52 = not (v49 and 1 - v29 < l_WaterLevel_0 + 0.005);
        local v53 = not (v49 and l_WaterLevel_0 + 0.58 < 1 - v29);
        if not (((not l_HasCaves_0 or not v51) or not v52) or not v53) then
            v50 = math.clamp((v4.Threshold(v4.Ridge(v7(v9(v28, 4, 30))), 0.84, 0.01) * v4.Threshold(v4.Ridge(v7(v9(v28, 5, 30))), 0.84, 0.01)) * v4.Threshold(v4.Ridge(v7(v9(v28, 6, 30))), 0.84, 0.01) - if v49 then v4.Threshold(v7(v9(v28 * Vector3.new(1, 0, 1), 143, 62)), 0.35, 0) else 0, 0, 1);
        end;
        local v54 = v4.Threshold(v48 - v50, 0.5, l_MapHeight_0);
        local v55 = 1 - v29 < l_WaterLevel_0;
        local v56 = v48 <= 0.5;
        local v57 = v54 <= 0;
        if not ((not v55 or not v56) or not v57) then
            v54 = 1;
            l_CrackedLava_0 = Enum.Material.Water;
            l_Rock_0 = Enum.Material.Water;
            v49 = true;
        end;
        local v58 = l_Y_0 == 1 and 1 or v54;
        local v59 = if l_Y_0 == 1 then Enum.Material.CrackedLava else if v54 <= 0 then Enum.Material.Air else if v49 then l_CrackedLava_0 else l_Rock_0;
        local l_v49_0 = v49;
        if l_v49_0 then
            l_v49_0 = true;
            if v58 > 0 then
                l_v49_0 = v59 == Enum.Material.Air;
            end;
        end;
        return v59, v58, l_v49_0;
    end;
end;


local function _(v0, v1, v2)
    local v3 = math.cos(v2);
    local v4 = math.sin(v2);
    return v0 * v3 - v1 * v4, v0 * v4 + v1 * v3;
end;
return function(v6, v7, v8)
    local v9 = v6 / 2;
    local v10 = v7 / 2;
    return function(v11, v12)
        local v13 = v11 - v9;
        local v14 = v12 - v10;
        local l_v8_0 = v8;
        local v16 = math.cos(l_v8_0);
        local v17 = math.sin(l_v8_0);
        return (v13 * v16 - v14 * v17) + v9, (v13 * v17 + v14 * v16) + v10;
    end;
end;