local l_script_FirstAncestor_0 = script:FindFirstAncestor("TerrainEditor");
local v1 = require(l_script_FirstAncestor_0.Packages.Framework);
local l_ContextServices_0 = v1.ContextServices;
local l_ContextItem_0 = l_ContextServices_0.ContextItem;
local l_PluginActions_0 = l_ContextServices_0.PluginActions;
local l_Signal_0 = v1.Util.Signal;
local v6 = require(l_script_FirstAncestor_0.Src.Resources.Constants);
local v7 = require(l_script_FirstAncestor_0.Src.Util.getMaterials);
local v8 = require(l_script_FirstAncestor_0.Src.Types);
local l_BrushMode_0 = v8.BrushMode;
local l_BrushSettings_0 = v8.BrushSettings;
local l_MaterialSettings_0 = v8.MaterialSettings;
local l_PluginAction_0 = v8.PluginAction;
local v13 = l_ContextItem_0:extend("ShortcutController");
v13.new = function(v14, v15)
    assert(v14, "ShortcutController.new() requires a plugin");
    local function _(v16)
        return v15:getText("PluginActions", v16 .. "StatusTip");
    end;
    local function _(v18)
        return v15:getText("PluginActions", v18 .. "Text");
    end;
    local v20 = setmetatable({
        _mouse = v14:GetMouse(),
        _pluginActions = l_PluginActions_0.new(v14, {
            EditPlane = {
                allowBinding = false,
                defaultShortcut = "ctrl+shift+space",
                id = l_PluginAction_0.EditPlane,
                statusTip = v15:getText("PluginActions", l_PluginAction_0.EditPlane .. "StatusTip"),
                text = v15:getText("PluginActions", l_PluginAction_0.EditPlane .. "Text")
            },
            CopySelected = {
                allowBinding = false,
                defaultShortcut = "ctrl+c",
                id = l_PluginAction_0.CopySelected,
                statusTip = v15:getText("PluginActions", l_PluginAction_0.CopySelected .. "StatusTip"),
                text = v15:getText("PluginActions", l_PluginAction_0.CopySelected .. "Text")
            },
            CutSelected = {
                allowBinding = false,
                defaultShortcut = "ctrl+x",
                id = l_PluginAction_0.CutSelected,
                statusTip = v15:getText("PluginActions", l_PluginAction_0.CutSelected .. "StatusTip"),
                text = v15:getText("PluginActions", l_PluginAction_0.CutSelected .. "Text")
            },
            DeleteSelected = {
                allowBinding = false,
                defaultShortcut = "delete",
                id = l_PluginAction_0.DeleteSelected,
                statusTip = v15:getText("PluginActions", l_PluginAction_0.DeleteSelected .. "StatusTip"),
                text = v15:getText("PluginActions", l_PluginAction_0.DeleteSelected .. "Text")
            },
            PasteSelected = {
                allowBinding = false,
                defaultShortcut = "ctrl+v",
                id = l_PluginAction_0.PasteSelected,
                statusTip = v15:getText("PluginActions", l_PluginAction_0.PasteSelected .. "StatusTip"),
                text = v15:getText("PluginActions", l_PluginAction_0.PasteSelected .. "Text")
            },
            DuplicateSelected = {
                allowBinding = false,
                defaultShortcut = "ctrl+d",
                id = l_PluginAction_0.DuplicateSelected,
                statusTip = v15:getText("PluginActions", l_PluginAction_0.DuplicateSelected .. "StatusTip"),
                text = v15:getText("PluginActions", l_PluginAction_0.DuplicateSelected .. "Text")
            },
            Apply = {
                allowBinding = false,
                defaultShortcut = "return",
                id = l_PluginAction_0.Apply,
                statusTip = v15:getText("PluginActions", l_PluginAction_0.Apply .. "StatusTip"),
                text = v15:getText("PluginActions", l_PluginAction_0.Apply .. "Text")
            },
            Cancel = {
                allowBinding = false,
                defaultShortcut = "escape",
                id = l_PluginAction_0.Quit,
                statusTip = v15:getText("PluginActions", l_PluginAction_0.Quit .. "StatusTip"),
                text = v15:getText("PluginActions", l_PluginAction_0.Quit .. "Text")
            }
        }),
        _cachedValues = {},
        _originalValues = {},
        _userInputService = game:GetService("UserInputService"),
        _workspace = game:GetService("Workspace"),
        _reservedMouseMove = {},
        _reservedMouseDown = {},
        _brushMouse = {},
        _brushScrollWheel = {},
        MouseDownAction = l_Signal_0.new(),
        MouseMoveAction = l_Signal_0.new()
    }, v13);
    v20._mouse.Button1Down:Connect(function()
        v20._mouseDown = true;
        if not v20:isMouseDownReserved() then
            v20.MouseDownAction:Fire();
        end;
    end);
    v20._mouse.Button1Up:Connect(function()
        v20._mouseDown = false;
    end);
    v20._mouse.Move:Connect(function()
        if not v20:isMouseMoveReserved() then
            v20.MouseMoveAction:Fire();
        end;
    end);
    return v20;
end;
v13.isMouseMoveReserved = function(v21)
    return #v21._reservedMouseMove ~= 0;
end;
v13.isMouseDownReserved = function(v22)
    return #v22._reservedMouseDown ~= 0;
end;
v13.isAltDown = function(v23)
    return v23._userInputService:IsKeyDown(Enum.KeyCode.LeftAlt) or v23._userInputService:IsKeyDown(Enum.KeyCode.RightAlt);
end;
v13.isShiftDown = function(v24)
    return v24._userInputService:IsKeyDown(Enum.KeyCode.LeftShift) or v24._userInputService:IsKeyDown(Enum.KeyCode.RightShift);
end;
v13.isControlDown = function(v25)
    return v25._userInputService:IsKeyDown(Enum.KeyCode.LeftControl) or v25._userInputService:IsKeyDown(Enum.KeyCode.RightControl);
end;
v13.isBDown = function(v26)
    return v26._userInputService:IsKeyDown(Enum.KeyCode.B);
end;
v13.onBrushChanged = function(v27, v28, v29, v30)
    local function _()
        return v30((math.clamp(math.floor((v27._originalValues[v28] + v27._cachedValues[v28]) * 100) / 100, 0, 1)));
    end;
    local function v33()
        local v32 = table.clone(v29);
        v32.Size = math.clamp(math.floor(v27._originalValues[v28].Size + v27._cachedValues[v28].Size), 1, 64);
        v32.Height = math.clamp(math.floor(v27._originalValues[v28].Height + v27._cachedValues[v28].Height), 1, 64);
        return v30(v32);
    end;
    local function v41(v34, v35)
        local function _()
            if v35 then
                v27._workspace.CurrentCamera:Zoom(-v34);
            end;
        end;
        if v27:isShiftDown() and v28 == l_BrushSettings_0.Strength then
            local l__cachedValues_0 = v27._cachedValues;
            local l_v28_0 = v28;
            l__cachedValues_0[l_v28_0] = l__cachedValues_0[l_v28_0] + v34 / 100;
            if v35 then
                v27._workspace.CurrentCamera:Zoom(-v34);
            end;
            l__cachedValues_0 = v30((math.clamp(math.floor((v27._originalValues[v28] + v27._cachedValues[v28]) * 100) / 100, 0, 1)));
            return ;
        elseif v27:isControlDown() and v28 == l_BrushSettings_0.BrushSize then
            local v39 = v27._cachedValues[v28];
            v39.Height = v39.Height + v34;
            if v29.Locked then
                v27._cachedValues[v28].Size = v27._cachedValues[v28].Height;
            end;
            v33();
            return ;
        else
            if not (v27:isShiftDown() or v27:isControlDown()) and v28 == l_BrushSettings_0.BrushSize then
                local v40 = v27._cachedValues[v28];
                v40.Size = v40.Size + v34;
                if v29.Locked then
                    v27._cachedValues[v28].Height = v27._cachedValues[v28].Size;
                end;
                if v35 then
                    v27._workspace.CurrentCamera:Zoom(-v34);
                end;
                v33();
            end;
            return ;
        end;
    end;
    local function v44(v42)
        if v27:isBDown() then
            local v43 = table.find(v27._reservedMouseMove, v28);
            if v43 then
                table.remove(v27._reservedMouseDown, v43);
            end;
            v27._brushScrollWheel[v28] = true;
            v41(v42, true);
            return ;
        else
            return ;
        end;
    end;
    local function v47()
        if v27:isBDown() and not v27._brushScrollWheel[v28] then
            local v45 = Vector2.new(v27._mouse.X, v27._mouse.Y);
            local v46 = v45 - v27._brushMouse[v28];
            v27._brushMouse[v28] = v45;
            v41(v46.X / 10, false);
            return ;
        else
            return ;
        end;
    end;
    return {
        v27._userInputService.InputChanged:Connect(function(v48)
            if v48.UserInputType == Enum.UserInputType.MouseMovement then
                v47();
                return ;
            else
                if v48.UserInputType == Enum.UserInputType.MouseWheel then
                    v44(v48.Position.Z);
                end;
                return ;
            end;
        end),
        v27._userInputService.InputBegan:Connect(function(v49)
            if v49.KeyCode == Enum.KeyCode.B then
                if not v27._cachedValues[v28] then
                    if v28 == l_BrushSettings_0.BrushSize then
                        v27._originalValues[v28] = {
                            Height = v29.Height,
                            Size = v29.Size
                        };
                        v27._cachedValues[v28] = {
                            Height = 0,
                            Size = 0
                        };
                    else
                        v27._originalValues[v28] = v29;
                        v27._cachedValues[v28] = 0;
                    end;
                end;
                v27._brushScrollWheel[v28] = false;
                v27._brushMouse[v28] = Vector2.new(v27._mouse.X, v27._mouse.Y);
                v27._cameraPosition = v27._workspace.CurrentCamera.CFrame;
                if not v27._mouseDown then
                    if not table.find(v27._reservedMouseMove, v28) then
                        table.insert(v27._reservedMouseMove, v28);
                    end;
                else
                    v27._brushScrollWheel[v28] = true;
                    return ;
                end;
            end;
        end),
        v27._userInputService.InputEnded:Connect(function(v50)
            if v50.KeyCode == Enum.KeyCode.B then
                local v51 = table.find(v27._reservedMouseMove, v28);
                if v51 then
                    table.remove(v27._reservedMouseMove, v51);
                end;
                v27._cachedValues[v28] = nil;
            end;
        end)
    };
end;
v13.onMaterialPicked = function(v52, v53, v54)
    local function _(v55)
        local v56 = true;
        if v55.KeyCode ~= Enum.KeyCode.LeftAlt then
            v56 = v55.KeyCode == Enum.KeyCode.RightAlt;
        end;
        return v56;
    end;
    return {
        v52._mouse.Button1Down:Connect(function()
            if v52:isAltDown() then
                local l_Position_0 = v52._mouse.Origin.Position;
                local l_Direction_0 = v52._mouse.UnitRay.Direction;
                local v60 = RaycastParams.new();
                v60.BruteForceAllSlow = true;
                local v61 = v52._workspace:Raycast(l_Position_0, l_Direction_0 * v6.RayLength, v60);
                if not (not v61 or not v61.Material) then
                    if table.find(v7(), v61.Material) then
                        if v52:isShiftDown() and v53 == l_MaterialSettings_0.TargetMaterial then
                            v54(v61.Material);
                            return ;
                        elseif v53 == l_MaterialSettings_0.SourceMaterial then
                            v54(v61.Material);
                        end;
                    else
                        return ;
                    end;
                end;
            end;
        end),
        v52._userInputService.InputBegan:Connect(function(v62)
            local v63 = true;
            if v62.KeyCode ~= Enum.KeyCode.LeftAlt then
                v63 = v62.KeyCode == Enum.KeyCode.RightAlt;
            end;
            if v63 then
                table.insert(v52._reservedMouseDown, v53);
            end;
        end),
        v52._userInputService.InputEnded:Connect(function(v64)
            local v65 = true;
            if v64.KeyCode ~= Enum.KeyCode.LeftAlt then
                v65 = v64.KeyCode == Enum.KeyCode.RightAlt;
            end;
            if v65 then
                v65 = table.find(v52._reservedMouseDown, v53);
                if v65 then
                    table.remove(v52._reservedMouseDown, v65);
                end;
            end;
        end)
    };
end;
v13.onBrushMode = function(v66, v67, v68)
    local function v70(v69)
        if not (v69.KeyCode ~= Enum.KeyCode.LeftControl) or v69.KeyCode == Enum.KeyCode.RightControl then
            if not v66:isControlDown() or v66._controlWasDown then
                if not (v66:isControlDown() or not v66._controlWasDown) then
                    v67(v68);
                    v66._controlWasDown = false;
                end;
            else
                v67(if v68 == l_BrushMode_0.Add then l_BrushMode_0.Subtract else l_BrushMode_0.Add);
                v66._controlWasDown = true;
                return ;
            end;
        end;
    end;
    return {
        v66._userInputService.InputBegan:Connect(v70),
        v66._userInputService.InputEnded:Connect(v70)
    };
end;
v13.onTemporarySmooth = function(v71, v72)
    local function v74(v73)
        if not (v73.KeyCode ~= Enum.KeyCode.LeftShift) or v73.KeyCode == Enum.KeyCode.RightShift then
            v72(v71:isShiftDown());
        end;
    end;
    return {
        v71._userInputService.InputBegan:Connect(v74),
        v71._userInputService.InputEnded:Connect(v74)
    };
end;
v13.onToggleEdit = function(v75, v76, v77)
    if not v75._toggleEditEnabled then
        v75:Enable(l_PluginAction_0.EditPlane);
        v75._toggleEditEnabled = true;
    end;
    v75._manualPlaneLock = v76;
    return {
        v75._pluginActions:get(l_PluginAction_0.EditPlane).Triggered:Connect(function()
            v75._manualPlaneLock = not v75._manualPlaneLock;
            v77(v75._manualPlaneLock);
        end),
        {
            Disconnect = function()
                v75:Disable(l_PluginAction_0.EditPlane);
                v75._toggleEditEnabled = false;
            end
        }
    };
end;
v13.registerShortcut = function(v78, v79, v80, v81)
    if not v78:supportsShortcut(v79) then
        error((("Cannot register unsupported shortcut for property %*."):format(v79)));
    end;
    if not (v79 ~= l_BrushSettings_0.BrushSize) or v79 == l_BrushSettings_0.Strength then
        return v78:onBrushChanged(v79, v80, v81);
    elseif not (v79 ~= l_MaterialSettings_0.SourceMaterial) or v79 == l_MaterialSettings_0.TargetMaterial then
        return v78:onMaterialPicked(v79, v81);
    elseif v79 == l_BrushSettings_0.BrushMode then
        return v78:onBrushMode(v81, v80);
    elseif v79 == l_BrushSettings_0.TemporarySmooth then
        return v78:onTemporarySmooth(v81);
    elseif v79 == l_BrushSettings_0.ManualPlaneLock then
        return v78:onToggleEdit(v80, v81);
    else
        return ;
    end;
end;
v13.supportsShortcut = function(_, v83)
    return ({
        [l_BrushSettings_0.BrushSize] = true,
        [l_BrushSettings_0.BrushMode] = true,
        [l_BrushSettings_0.ManualPlaneLock] = true,
        [l_BrushSettings_0.Strength] = true,
        [l_BrushSettings_0.TemporarySmooth] = true,
        [l_MaterialSettings_0.SourceMaterial] = true,
        [l_MaterialSettings_0.TargetMaterial] = true
    })[v83];
end;
v13.getMouse = function(v84)
    return v84._mouse;
end;
v13.IsMouseDown = function(v85)
    return v85._mouseDown;
end;
v13.Enable = function(v86, v87)
    v86:SetEnabled(v87, true);
end;
v13.Disable = function(v88, v89)
    v88:SetEnabled(v89, false);
end;
v13.SetEnabled = function(v90, v91, v92)
    v90._pluginActions:get(v91).Enabled = v92;
end;
v13.Connect = function(v93, v94, v95)
    return v93._pluginActions:get(v94).Triggered:Connect(v95);
end;
return v13;


local _ = game:GetService("ChangeHistoryService");
local l_script_FirstAncestor_0 = script:FindFirstAncestor("TerrainEditor");
local v2 = require(l_script_FirstAncestor_0.Packages.Dash);
local v3 = require(l_script_FirstAncestor_0.Packages.Framework);
local l_ContextServices_0 = v3.ContextServices;
local l_ContextItem_0 = l_ContextServices_0.ContextItem;
local v6 = require(l_script_FirstAncestor_0.Src.Tools.BaseTool);
local l_Signal_0 = v3.Util.Signal;
local l_findIndex_0 = v2.findIndex;
local v9 = require(l_script_FirstAncestor_0.Src.Tools);
local l_Tab_0 = require(l_script_FirstAncestor_0.Src.Types).Tab;
local v11 = require(l_script_FirstAncestor_0.Src.Controllers.PluginController);
local v12 = require(l_script_FirstAncestor_0.Src.Controllers.ShortcutController);
local v13 = l_ContextItem_0:extend("ToolController");
v13.new = function(v14, v15, v16, v17, v18, v19)
    local v20 = setmetatable({
        _mocking = v19,
        OnToolChanged = l_Signal_0.new(),
        OnToolIndexChanged = l_Signal_0.new(),
        OnTabIndexChanged = l_Signal_0.new()
    }, v13);
    local v21 = {};
    local v22 = {};
    for _, v24 in v9, nil, nil do
        local v25 = v24:new();
        v25:init({
            Analytics = v16,
            Localization = v17,
            PluginController = v14,
            ShortcutController = v15,
            Stylizer = v18,
            ToolController = {
                selectTool = function(v26)
                    v20:setToolIndex(l_findIndex_0(v20._tabs[v20._tabIndex].ToolRegistry, function(v27)
                        return v27._name == v26;
                    end));
                end,
                selectTab = function(v28)
                    v20:setTabIndex(v20._tabRegistry[v28]);
                end,
                selectTabAndTool = function(v29, v30)
                    local v31 = v20._tabRegistry[v29];
                    v20:setTabAndToolIndex(v31, (l_findIndex_0(v20._tabs[v31].ToolRegistry, function(v32)
                        return v32._name == v30;
                    end)));
                end
            }
        }, {
            ChangeHistoryService = game:GetService("ChangeHistoryService"),
            CoreGui = game:GetService("CoreGui"),
            Selection = game:GetService("Selection"),
            ShorelineUpgraderService = game:GetService("ShorelineUpgraderService"),
            Terrain = game:GetService("Workspace"):FindFirstChildOfClass("Terrain")
        });
        local v33 = v25:getCategory();
        if v33 == l_Tab_0.None then
            if v20._emptyTool then
                assert("Cannot have more than one empty tool.");
            end;
            v20._emptyTool = v25;
        else
            if not v21[v33] then
                local v34 = #v22 + 1;
                table.insert(v22, {
                    Key = v34,
                    Label = v17:getText("Tabs", v33),
                    ToolIndex = 1,
                    ToolRegistry = {},
                    Toolbar = {}
                });
                v21[v33] = v34;
            end;
            table.insert(v22[v21[v33]].ToolRegistry, v25);
            table.insert(v22[v21[v33]].Toolbar, v25:getTile());
        end;
    end;
    v20._tabRegistry = v21;
    v20._tabs = v22;
    v20._tabIndex = 1;
    v20._useEmptyTool = true;
    v20._focusedConnection = v14.Activation:Connect(function(v35)
        if not v35 then
            v20:getTool():reportAnalytics();
        end;
    end);
    return v20;
end;
v13.mock = function(v36, v37, v38, v39, v40)
    return v13.new(v36 or v11.mock(), v37 or v12.mock(), v38 or l_ContextServices_0.Analytics.mock(), v39 or l_ContextServices_0.Localization.mock(), v40, true);
end;
v13.destroy = function(v41)
    v41._focusedConnection:Disconnect();
end;
v13.getTabs = function(v42)
    return v42._tabs;
end;
v13.getTabIndex = function(v43)
    return v43._tabIndex;
end;
v13.getToolbar = function(v44)
    return v44._tabs[v44._tabIndex].Toolbar;
end;
v13.getToolIndex = function(v45)
    if not v45._useEmptyTool then
        return v45._tabs[v45._tabIndex].ToolIndex;
    else
        return -1;
    end;
end;
v13.getTool = function(v46)
    local v47 = v46._tabs[v46._tabIndex];
    if not v46._useEmptyTool then
        return v47.ToolRegistry[v47.ToolIndex] or v6.empty();
    else
        return v46._emptyTool;
    end;
end;
v13.setToolIndex = function(v48, v49)
    local v50 = v48._tabs[v48._tabIndex];
    assert(v49 <= #v50.ToolRegistry);
    if not (v49 == v50.ToolIndex) or v48._useEmptyTool then
        if not v48._useEmptyTool then
            v50.ToolRegistry[v50.ToolIndex]:deactivate();
        else
            v48._useEmptyTool = false;
            v48._emptyTool:deactivate();
        end;
        v50.ToolIndex = v49;
        v50.ToolRegistry[v50.ToolIndex]:activate();
        v48.OnToolIndexChanged:Fire(v49);
        v48.OnToolChanged:Fire(v50.ToolRegistry[v50.ToolIndex]);
        return ;
    else
        v50.ToolRegistry[v50.ToolIndex]:deactivate();
        v48._useEmptyTool = true;
        v48._emptyTool:activate();
        v48.OnToolIndexChanged:Fire(-1);
        v48.OnToolChanged:Fire(v48._emptyTool);
        return ;
    end;
end;
v13.setTabIndex = function(v51, v52)
    local v53 = v51._tabs[v51._tabIndex];
    if not v51._useEmptyTool then
        v53.ToolRegistry[v53.ToolIndex]:deactivate();
    end;
    v51._tabIndex = v52;
    v53 = v51._tabs[v51._tabIndex];
    if not v51._useEmptyTool then
        v53.ToolRegistry[v53.ToolIndex]:activate();
    end;
    v51.OnTabIndexChanged:Fire(v52);
    if not v51._useEmptyTool then
        v51.OnToolIndexChanged:Fire(v53.ToolIndex);
        v51.OnToolChanged:Fire(v53.ToolRegistry[v53.ToolIndex]);
        return ;
    else
        v51.OnToolIndexChanged:Fire(-1);
        v51.OnToolChanged:Fire(v51._emptyTool);
        return ;
    end;
end;
v13.setTabAndToolIndex = function(v54, v55, v56)
    local v57 = v54._tabs[v54._tabIndex];
    if not (v56 == v57.ToolIndex and v54._tabIndex == v55) or v54._useEmptyTool then
        if not v54._useEmptyTool then
            v57.ToolRegistry[v57.ToolIndex]:deactivate();
        else
            v54._useEmptyTool = false;
            v54._emptyTool:deactivate();
        end;
        if v56 == v57.ToolIndex then
            v54._useEmptyTool = true;
        end;
        v54._useEmptyTool = false;
        v54._tabIndex = v55;
        v57 = v54._tabs[v54._tabIndex];
        v57.ToolIndex = v56;
        v57.ToolRegistry[v57.ToolIndex]:activate();
        v54.OnTabIndexChanged:Fire(v55);
        v54.OnToolIndexChanged:Fire(v57.ToolIndex);
        v54.OnToolChanged:Fire(v57.ToolRegistry[v57.ToolIndex]);
        return ;
    else
        v57.ToolRegistry[v57.ToolIndex]:deactivate();
        v54._useEmptyTool = true;
        v54._emptyTool:activate();
        v54.OnToolIndexChanged:Fire(-1);
        v54.OnToolChanged:Fire(v54._emptyTool);
        return ;
    end;
end;
v13.selectTabAndTool = function(v58, v59, v60)
    local v61 = v58._tabRegistry[v59];
    v58:setTabAndToolIndex(v61, (l_findIndex_0(v58._tabs[v61].ToolRegistry, function(v62)
        return v62._name == v60;
    end)));
end;
return v13;


game:DefineFastFlag("AssetPreviewContentAttribution", false);
return function()
    return game:GetFastFlag("AssetPreviewContentAttribution");
end;


game:DefineFastFlag("FixTerrainEditorDETruncations", false);
return function()
    return game:GetFastFlag("FixTerrainEditorDETruncations");
end;


game:DefineFastFlag("TerrainEditorAirSourceMaterial", false);
return function()
    return game:GetFastFlag("TerrainEditorAirSourceMaterial");
end;


game:DefineFastFlag("TerrainEditorBrushPerformanceEnhancements3", false);
return function()
    return game:GetFastFlag("TerrainEditorBrushPerformanceEnhancements3");
end;


game:DefineFastFlag("TerrainEditorCompactMode", false);
return function()
    return game:GetFastFlag("TerrainEditorCompactMode");
end;


game:DefineFastFlag("TerrainEditorCopyPasteFix", false);
return function()
    return game:GetFastFlag("TerrainEditorCopyPasteFix");
end;


game:DefineFastFlag("TerrainEditorDebugMode", false);
return function()
    return game:GetFastFlag("TerrainEditorDebugMode");
end;


game:DefineFastFlag("TerrainEditorDisabledFixes", false);
return function()
    return game:GetFastFlag("TerrainEditorDisabledFixes");
end;


game:DefineFastFlag("TerrainEditorDoNotSetSetting", false);
return function()
    return game:GetFastFlag("TerrainEditorDoNotSetSetting");
end;


game:DefineFastFlag("TerrainEditorErrorHandling3", false);
return function()
    return game:GetFastFlag("TerrainEditorErrorHandling3");
end;


game:DefineFastFlag("TerrainEditorFixInitialization", false);
return function()
    return game:GetFastFlag("TerrainEditorFixInitialization");
end;


local _ = script:FindFirstAncestor("TerrainEditor");
game:DefineFastFlag("TerrainEditorGenerationFeature3", false);
return function()
    return game:GetFastFlag("TerrainEditorGenerationFeature3") and game:GetFastFlag("DevFrameworkFormSubsetting");
end;


game:DefineFastFlag("TerrainEditorHeightmapFixes", false);
return function()
    return game:GetFastFlag("TerrainEditorHeightmapFixes");
end;


game:DefineFastFlag("TerrainEditorIndexingBugFix", false);
return function()
    return game:GetFastFlag("TerrainEditorIndexingBugFix");
end;


game:DefineFastFlag("TerrainEditorManualPlaneLockRelative", false);
return function()
    return game:GetFastFlag("TerrainEditorManualPlaneLockRelative");
end;


game:DefineFastFlag("TerrainEditorTimeStatistic5", false);
return function()
    return game:GetFastFlag("TerrainEditorTimeStatistic5");
end;


game:DefineFastFlag("TerrainEditorWaterAutofill", false);
return function()
    return game:GetFastFlag("TerrainEditorWaterAutofill");
end;


game:DefineFastFlag("TerrainGenerationFixLakeNoiseRatio", false);
return function()
    return game:GetFastFlag("TerrainGenerationFixLakeNoiseRatio");
end;


local v0 = require(script:FindFirstAncestor("TerrainEditor").Packages.React);
return function(v1, v2, v3)
    local v4 = v0.useMemo(function()
        return v2;
    end, v3);
    v0.useEffect(function()
        local v5 = v1:Connect(v4);
        return function()
            v5:Disconnect();
        end;
    end, {
        v1,
        v4
    });
end;


local l_script_FirstAncestor_0 = script:FindFirstAncestor("TerrainEditor");
local v1 = require(l_script_FirstAncestor_0.Packages.React);
local l_useState_0 = v1.useState;
local l_useEffect_0 = v1.useEffect;
local v4 = require(l_script_FirstAncestor_0.Src.Flags.getFFlagTerrainEditorErrorHandling);
return function(v5)
    local v6 = v5:getTool();
    local v7, v8 = l_useState_0(v6:form());
    l_useEffect_0(function()
        local v10 = v5.OnToolChanged:Connect(function(v9)
            v8(v9:form());
        end);
        local v11 = v6.OnGizmoChanged:Connect(function()
            v8(v6:form());
        end);
        local v12 = nil;
        if v4() then
            v12 = v6.OnInternalsChanged:Connect(function()
                v8(v6:form());
            end);
        end;
        local v13 = v6.OnShortcutChanged:Connect(function()
            v8(v6:form());
        end);
        return function()
            v10:Disconnect();
            v11:Disconnect();
            if v4() then
                v12:Disconnect();
            end;
            v13:Disconnect();
        end;
    end, {
        v6
    });
    return v7, function(v14)
        v5:getTool():saveForm(v14);
        v8(v6:form());
    end;
end;


local l_script_FirstAncestor_0 = script:FindFirstAncestor("TerrainEditor");
local v1 = require(l_script_FirstAncestor_0.Packages.React);
local v2 = require(l_script_FirstAncestor_0.Src.Flags.getFFlagTerrainEditorErrorHandling);
local l_useMemo_0 = v1.useMemo;
local l_useRef_0 = v1.useRef;
local l_useState_0 = v1.useState;
local l_useEffect_0 = v1.useEffect;
local _ = require(l_script_FirstAncestor_0.Src.Types);
return function(v8, v9)
    local v10, v11 = l_useState_0({
        Gizmos = {},
        FromSelf = false
    });
    local v12 = l_useMemo_0(function()
        return v8:getTool();
    end, {
        v10
    });
    local v13, v14 = l_useState_0(false);
    local v15 = l_useRef_0(nil);
    if v15.current then
        v11(v15.current);
        v15.current = nil;
        if v13 then
            v14(false);
        end;
    end;
    l_useEffect_0(function()
        local v17 = v8.OnToolChanged:Connect(function(v16)
            v15.current = {
                Gizmos = v16:gizmos(),
                FromSelf = false
            };
            v11(v15.current);
            v14(true);
        end);
        if v9 then
            local v18 = nil;
            if v2() then
                v18 = v12.OnInternalsChanged:Connect(function()
                    v11({
                        Gizmos = v12:gizmos(),
                        FromSelf = false
                    });
                end);
            end;
            local v19 = v12.OnFormChanged:Connect(function()
                v15.current = {
                    Gizmos = v12:gizmos(),
                    FromSelf = false
                };
                v11(v15.current);
                v14(true);
            end);
            local v20 = v12.OnShortcutChanged:Connect(function()
                v15.current = {
                    Gizmos = v12:gizmos(),
                    FromSelf = false
                };
                v11(v15.current);
                v14(true);
            end);
            return function()
                v17:Disconnect();
                v19:Disconnect();
                if v2() then
                    v18:Disconnect();
                end;
                v20:Disconnect();
            end;
        else
            return function()
                v17:Disconnect();
            end;
        end;
    end, {
        v12,
        v9
    });
    l_useEffect_0(function()
        v11(if not v9 then {
            Gizmos = {},
            FromSelf = false
        } else {
            Gizmos = v12:gizmos(),
            FromSelf = false
        });
    end, {
        v9
    });
    return v10.Gizmos, function(_, v22)
        if not v15.current then
            v8:getTool():saveGizmos(v22);
            v11({
                Gizmos = v8:getTool():gizmos(),
                FromSelf = true
            });
            return ;
        else
            return ;
        end;
    end, v12, v10.FromSelf;
end;


local v0 = require(script:FindFirstAncestor("TerrainEditor").Packages.React);
local l_useCallback_0 = v0.useCallback;
local l_useEffect_0 = v0.useEffect;
local l_useRef_0 = v0.useRef;
local l_ChangeHistoryService_0 = game:GetService("ChangeHistoryService");
return function(v5, v6, v7)
    local v8 = l_useRef_0(v5);
    local v9 = l_useRef_0({});
    local v10 = l_useRef_0({});
    l_useEffect_0(function()
        local v16 = l_ChangeHistoryService_0.OnUndo:Connect(function(v11)
            local l_current_0 = v9.current;
            local l_current_1 = v10.current;
            if not l_current_0[v11] or #l_current_0[v11] == 0 then
                return ;
            else
                if not l_current_1[v11] then
                    l_current_1[v11] = {};
                end;
                local v14 = #l_current_0[v11];
                local v15 = l_current_0[v11][v14];
                table.insert(l_current_1[v11], v8.current);
                table.remove(l_current_0[v11], v14);
                v8.current = v15;
                v6(v15);
                v9.current = l_current_0;
                v10.current = l_current_1;
                return ;
            end;
        end);
        local v22 = l_ChangeHistoryService_0.OnRedo:Connect(function(v17)
            local l_current_2 = v9.current;
            local l_current_3 = v10.current;
            if not l_current_3[v17] or #l_current_3[v17] == 0 then
                return ;
            else
                local v20 = #l_current_3[v17];
                local v21 = l_current_3[v17][v20];
                table.insert(l_current_2[v17], v8.current);
                table.remove(l_current_3[v17], v20);
                v8.current = v21;
                v6(v21);
                v9.current = l_current_2;
                v10.current = l_current_3;
                return ;
            end;
        end);
        return function()
            v16:Disconnect();
            v22:Disconnect();
        end;
    end, v7);
    l_useEffect_0(function()
        v9.current = {};
        v10.current = {};
    end, v7);
    return (l_useCallback_0(function(v23, v24)
        local l_current_4 = v9.current;
        if not l_current_4[v23] then
            l_current_4[v23] = {};
        end;
        v10.current = {};
        l_ChangeHistoryService_0:SetWaypoint(v23);
        table.insert(l_current_4[v23], table.clone(v8.current));
        v8.current = v24;
        v9.current = l_current_4;
    end, v7));
end;


local l_script_FirstAncestor_0 = script:FindFirstAncestor("TerrainEditor");
local v1 = require(l_script_FirstAncestor_0.Packages.React);
local l_useEffect_0 = v1.useEffect;
local l_useState_0 = v1.useState;
local v4 = require(l_script_FirstAncestor_0.Src.Hooks.useTerrain);
local v5 = require(l_script_FirstAncestor_0.Src.Types);
local l_Category_0 = v5.Category;
local l_Tool_0 = v5.Tool;
local l_TransformMode_0 = v5.TransformMode;
local l_TransformSettings_0 = v5.TransformSettings;
local l_CoreGui_0 = game:GetService("CoreGui");
return function(v11, v12, v13, v14)
    local v15, v16 = l_useState_0({});
    local v17 = v4();
    l_useEffect_0(function()
        if not v14 then
            v16({});
            return ;
        elseif v11 == l_Tool_0.Transform then
            local v18 = v12[l_Category_0.TransformSettings][l_TransformSettings_0.TransformMode];
            local v19 = nil;
            if v18 == l_TransformMode_0.Paste then
                v19 = v12[l_Category_0.TransformSettings][l_TransformSettings_0.TerrainRegionBuffer];
            elseif not (v18 ~= l_TransformMode_0.Duplicate) or v18 == l_TransformMode_0.Import then
                v19 = v12[l_Category_0.TransformSettings][l_TransformSettings_0.TerrainRegion];
            end;
            if v19 then
                v19.Parent = l_CoreGui_0;
                v16(v19:GetRegionWireframe());
                return function()
                    v19.Parent = nil;
                end;
            else
                v16({});
                return ;
            end;
        else
            v16(v17:GetTerrainWireframe(v13.Transform, v13.Size));
            return ;
        end;
    end, {
        v11,
        v13,
        v14
    });
    return v15;
end;


local l_script_FirstAncestor_0 = script:FindFirstAncestor("TerrainEditor");
local v1 = require(l_script_FirstAncestor_0.Packages.React);
local _ = v1.useEffect;
local l_useState_0 = v1.useState;
local v4 = require(l_script_FirstAncestor_0.Src.Hooks.useEventConnection);
local v5 = require(l_script_FirstAncestor_0.Src.Controllers.ShortcutController);
return function()
    local v6 = v5:use();
    local v7 = v6:getMouse();
    local v8, v9 = l_useState_0(v6:IsMouseDown());
    v4(v7.Button1Down, function()
        v9(true);
    end, {});
    v4(v7.Button1Up, function()
        v9(false);
    end, {});
    return v8;
end;


local v0 = require(script:FindFirstAncestor("TerrainEditor").Packages.React);
local l_useState_0 = v0.useState;
local l_useEffect_0 = v0.useEffect;
return function(v3, v4)
    local v5 = v3:getTool();
    local v6, v7 = l_useState_0(v5:note());
    l_useEffect_0(function()
        local v9 = v3.OnToolChanged:Connect(function(v8)
            v7(v8:note());
        end);
        if v4 then
            local v10 = v5.OnNoteChanged:Connect(function()
                v7(v5:note());
            end);
            return function()
                v9:Disconnect();
                v10:Disconnect();
            end;
        else
            return function()
                v9:Disconnect();
            end;
        end;
    end, {
        v5,
        v4
    });
    l_useEffect_0(function()
        v7(if not v4 then nil else v5:note());
    end, {
        v4
    });
    return v6;
end;


local l_script_FirstAncestor_0 = script:FindFirstAncestor("TerrainEditor");
local v1 = require(l_script_FirstAncestor_0.Packages.Dash);
local v2 = require(l_script_FirstAncestor_0.Packages.React);
local l_useCallback_0 = v2.useCallback;
local l_useState_0 = v2.useState;
local l_useEffect_0 = v2.useEffect;
return function(v6)
    local v7 = v6:getTool();
    local v8, v9 = l_useState_0(false);
    local v10, v11 = l_useState_0({
        Operation = l_useState_0(v7:operation()),
        Paused = l_useState_0(false),
        Progress = l_useState_0(0)
    });
    l_useEffect_0(function()
        local v13 = v7.OnOperationChanged:Connect(function()
            local v12 = v7:operation();
            v11({
                Operation = v12,
                Paused = v12:isPaused(),
                Progress = v12:getProgress()
            });
            v9(v12:hasStarted());
        end);
        return function()
            v13:Disconnect();
        end;
    end, {
        v7
    });
    l_useEffect_0(function()
        if v10.Operation then
            local v14 = v10.Operation.Canceled:Connect(function()
                v9(false);
            end);
            local v15 = v10.Operation.Finished:Connect(function()
                v9(false);
            end);
            local v16 = v10.Operation.Paused:Connect(function()
                v11(v1.join(v10, {
                    Paused = true
                }));
            end);
            local v19 = v10.Operation.ProgressChanged:Connect(function(v17, v18)
                v11(v1.join(v10, {
                    Progress = v17,
                    TimeRemaining = v18
                }));
            end);
            local v20 = v10.Operation.Resumed:Connect(function()
                v11(v1.join(v10, {
                    Paused = false
                }));
            end);
            local v21 = v10.Operation.Started:Connect(function()
                v9(true);
            end);
            if v10.Operation:hasFinished() then
                v9(false);
            end;
            return function()
                v14:Disconnect();
                v15:Disconnect();
                v16:Disconnect();
                v19:Disconnect();
                v20:Disconnect();
                v21:Disconnect();
            end;
        else
            return ;
        end;
    end, {
        v7,
        v10.Operation,
        v10.Paused,
        v10.Progress,
        v10.TimeRemaining
    });
    local v22 = l_useCallback_0(function()
        if not (not v10.Operation or v10.Operation:isPaused()) then
            v10.Operation:pause();
        end;
    end, {
        v7,
        v10.Operation
    });
    local v23 = l_useCallback_0(function()
        if not (not v10.Operation or not v10.Operation:isPaused()) then
            v10.Operation:resume();
        end;
    end, {
        v7,
        v10.Operation
    });
    local v24 = l_useCallback_0(function()
        if v10.Operation then
            v10.Operation:cancel();
        end;
    end, {
        v7,
        v10.Operation
    });
    if not v10.Operation then
        return nil;
    else
        return {
            Description = v10.Operation:getDescription(),
            Enabled = v8,
            OnCancel = if not v10.Operation:canCancel() then nil else v24,
            OnClose = v24,
            OnPause = if not v10.Operation:canPause() then nil else v22,
            OnResume = if not v10.Operation:canResume() then nil else v23,
            Paused = v10.Paused,
            Progress = v10.Progress,
            TimeRemaining = v10.TimeRemaining,
            Title = v10.Operation:getName()
        };
    end;
end;


local l_script_FirstAncestor_0 = script:FindFirstAncestor("TerrainEditor");
local l_DraggerFramework_0 = l_script_FirstAncestor_0.Packages.DraggerFramework;
local v2 = require(l_script_FirstAncestor_0.Packages.React);
local l_useCallback_0 = v2.useCallback;
local l_useEffect_0 = v2.useEffect;
local l_useMemo_0 = v2.useMemo;
local l_useState_0 = v2.useState;
local v7 = require(l_script_FirstAncestor_0.Src.Controllers.PluginController);
local v8 = require(l_script_FirstAncestor_0.Src.Controllers.ShortcutController);
local v9 = require(l_script_FirstAncestor_0.Src.Schemas.Plane);
local v10 = require(l_DraggerFramework_0.Implementation.DraggerContext_PluginImpl);
local v11 = require(l_DraggerFramework_0.Handles.MoveHandles);
local v12 = require(l_DraggerFramework_0.Handles.RotateHandles);
local v13 = require(l_script_FirstAncestor_0.Src.Types);
local l_BrushSettings_0 = v13.BrushSettings;
local l_Category_0 = v13.Category;
return function(v16, v17, v18, v19)
    local v20 = v7:use();
    local v21 = v8:use();
    local v22 = l_useMemo_0(function()
        return v9.Selection.new(v17[l_Category_0.BrushSettings][l_BrushSettings_0.PlaneTransform]);
    end, {
        v16
    });
    local v23, v24 = l_useState_0(v17[l_Category_0.BrushSettings][l_BrushSettings_0.PlaneTransform]);
    local v26 = l_useCallback_0(function(v25)
        v18({
            [l_Category_0.BrushSettings] = {
                [l_BrushSettings_0.PlaneTransform] = v25
            }
        });
        v24(v25);
    end, {
        v17
    });
    local v28 = l_useCallback_0(function(v27)
        v22:SetTransform(v27);
        v26(v27);
    end, {
        v22,
        v26
    });
    local v30 = l_useMemo_0(function()
        if not v20:isMocking() then
            local v29 = v10.new(l_script_FirstAncestor_0.Parent, game, settings(), v22);
            v29.updatePlane = v28;
            v29.Mock = false;
            return {
                Mouse = v21:getMouse(),
                DraggerContext = v29,
                DraggerSchema = v9,
                DraggerSettings = {
                    AnalyticsName = "AdjustablePlaneLock",
                    AllowDragSelect = true,
                    AllowFreeformDrag = true,
                    ShowLocalSpaceIndicator = true,
                    ShowPivotIndicator = true,
                    HandlesList = {
                        v11.new(v29, {
                            ShowBoundingBox = false,
                            Summonable = false,
                            Outset = 1
                        }, v9.TransformHandlesImplementation.new(v29)),
                        v12.new(v29, {
                            ShowBoundingBox = false,
                            Summonable = false,
                            Outset = 1
                        }, v9.TransformHandlesImplementation.new(v29))
                    }
                }
            };
        else
            return {
                DraggerContext = {},
                Mock = true
            };
        end;
    end, {
        v16
    });
    l_useEffect_0(function()
        v30.DraggerContext.updatePlane = v28;
    end, {
        v28
    });
    l_useEffect_0(function()
        local v31 = v17[l_Category_0.BrushSettings][l_BrushSettings_0.PlaneTransform];
        if not v19 then
            v22:SetTransformSignal(v31);
            v24(v31);
        end;
    end, {
        v16,
        v17[l_Category_0.BrushSettings][l_BrushSettings_0.PlaneTransform]
    });
    return v30, v23;
end;


local l_script_FirstAncestor_0 = script:FindFirstAncestor("TerrainEditor");
local v1 = require(l_script_FirstAncestor_0.Packages.Dash);
local v2 = require(l_script_FirstAncestor_0.Packages.React);
local l_useCallback_0 = v2.useCallback;
local l_useEffect_0 = v2.useEffect;
local l_useState_0 = v2.useState;
local v6 = require(l_script_FirstAncestor_0.Src.Controllers.ShortcutController);
local v7 = require(l_script_FirstAncestor_0.Src.Hooks.useEventConnection);
local v8 = require(l_script_FirstAncestor_0.Src.Hooks.useTerrain);
local v9 = require(l_script_FirstAncestor_0.Src.Resources.Constants);
local v10 = require(l_script_FirstAncestor_0.Src.Util.ApplyPlaneLock);
local v11 = require(l_script_FirstAncestor_0.Src.Util.ConvertForPivot);
local v12 = require(l_script_FirstAncestor_0.Src.Util.getCameraLookPlane);
local v13 = require(l_script_FirstAncestor_0.Src.Util.getPlaneIntersection);
local v14 = require(l_script_FirstAncestor_0.Src.Util.getSnappedToVoxel);
local l_CoreGui_0 = game:GetService("CoreGui");
local l_Players_0 = game:GetService("Players");
local l_RunService_0 = game:GetService("RunService");
local l_Workspace_0 = game:GetService("Workspace");
local v19 = require(l_script_FirstAncestor_0.Src.Types);
local l_BrushSettings_0 = v19.BrushSettings;
local l_BrushShape_0 = v19.BrushShape;
local l_Category_0 = v19.Category;
local l_MaterialSettings_0 = v19.MaterialSettings;
local l_PlaneLock_0 = v19.PlaneLock;
local l_Snapping_0 = v19.Snapping;
local l_Tool_0 = v19.Tool;
local v27 = require(l_script_FirstAncestor_0.Src.Flags.getFFlagTerrainEditorBrushPerformanceEnhancements);
local v28 = require(l_script_FirstAncestor_0.Src.Flags.getFFlagTerrainEditorAirSourceMaterial);
return function(v29, v30, v31)
    local v32 = v6:use();
    local v33 = v32:getMouse();
    local v34, v35 = l_useState_0({
        Distance = v33.Origin.Position.Magnitude,
        Normal = Vector3.yAxis,
        Position = Vector3.zero
    });
    local v36, v37 = l_useState_0({
        Distance = v33.Origin.Position.Magnitude,
        Normal = Vector3.yAxis,
        Position = Vector3.zero
    });
    local v38, v39 = l_useState_0(CFrame.lookAt(v34.Position, v34.Position + Vector3.yAxis));
    l_useEffect_0(function()
        if not v32:IsMouseDown() then
            v39((CFrame.lookAt(v34.Position, v34.Position + v12())));
        end;
    end, {
        v29,
        v34
    });
    local v40, v41 = l_useState_0({
        CacheID = nil,
        CachePoint = Vector3.zero
    });
    local v42, v43 = l_useState_0(v32:isMouseMoveReserved());
    local v44 = v8();
    local v45 = v30[l_Category_0.MaterialSettings];
    local v46 = l_useCallback_0(function()
        return (math.min(((v30[l_Category_0.BrushSettings][l_BrushSettings_0.BrushSize].Size / 2) * v9.VoxelResolution) * v9.TerrainCacheMultiplier, v9.TerrainCacheMaxRadius));
    end, {
        v30[l_Category_0.BrushSettings][l_BrushSettings_0.BrushSize]
    });
    local v47 = l_useCallback_0(function()
        if v29 == l_Tool_0.Draw and not v30[l_Category_0.BrushSettings][l_BrushSettings_0.TemporarySmooth] or not (not (v29 == l_Tool_0.Paint) or not v45) and (not (v45[l_MaterialSettings_0.TargetMaterial] ~= Enum.Material.Air) or v28() and v45[l_MaterialSettings_0.SourceMaterial] == Enum.Material.Air) then
            return v30[l_Category_0.BrushSettings][l_BrushSettings_0.PlaneLock] == l_PlaneLock_0.Off;
        else
            return false;
        end;
    end, {
        v30[l_Category_0.BrushSettings][l_BrushSettings_0.TemporarySmooth],
        v30[l_Category_0.BrushSettings][l_BrushSettings_0.PlaneLock],
        not v45 and true or v45[l_MaterialSettings_0.TargetMaterial],
        v29
    });
    local v55 = l_useCallback_0(function(v48)
        local v49 = v30[l_Category_0.BrushSettings][l_BrushSettings_0.BrushShape];
        local v50 = v30[l_Category_0.BrushSettings][l_BrushSettings_0.BrushSize];
        local v51 = v11(v30[l_Category_0.BrushSettings][l_BrushSettings_0.PivotPosition], v48.Position, if v49 == l_BrushShape_0.Sphere then v50.Size * v9.VoxelResolution else v50.Height * v9.VoxelResolution);
        local l_BrushVisual_0 = l_CoreGui_0:FindFirstChild("BrushVisual");
        if l_BrushVisual_0 then
            local l_l_BrushVisual_0_FirstChild_0 = l_BrushVisual_0:FindFirstChild("Central", true);
            if l_l_BrushVisual_0_FirstChild_0 then
                local v54 = if v49 == l_BrushShape_0.Cylinder then CFrame.Angles(1.5707963267948966, 0, 0) + v51 else CFrame.new(v51);
                l_l_BrushVisual_0_FirstChild_0.CFrame = v54;
                l_BrushVisual_0:FindFirstChild("OnTop", true).CFrame = v54;
                l_BrushVisual_0:FindFirstChild("Outline", true).CFrame = v54;
            end;
            return ;
        else
            return ;
        end;
    end, {
        v30
    });
    local v58 = l_useCallback_0(function(v56)
        local v57 = {
            [l_Category_0.BrushSettings] = {
                [l_BrushSettings_0.State] = v56
            }
        };
        if v27() and v29 ~= l_Tool_0.Build then
            v55(v56);
        end;
        v35(v56);
        v31(v57);
    end, {
        v38,
        v31,
        v29,
        v55
    });
    local v79 = l_useCallback_0(function()
        local l_Position_0 = v33.Origin.Position;
        local l_Direction_0 = v33.UnitRay.Direction;
        local v61 = RaycastParams.new();
        if not v30[l_Category_0.BrushSettings][l_BrushSettings_0.IgnoreParts] then
            local v62 = {};
            if not (not l_Players_0.LocalPlayer or not l_Players_0.LocalPlayer.Character) then
                table.insert(v62, l_Players_0.LocalPlayer.Character);
            end;
            v61.FilterType = Enum.RaycastFilterType.Blacklist;
            v61.FilterDescendantsInstances = v62;
        else
            local v63 = {
                v44
            };
            local l_Baseplate_0 = l_Workspace_0:FindFirstChild("Baseplate");
            if l_Baseplate_0 then
                table.insert(v63, l_Baseplate_0);
            end;
            v61.FilterType = Enum.RaycastFilterType.Whitelist;
            v61.FilterDescendantsInstances = v63;
        end;
        v61.IgnoreWater = v30[l_Category_0.BrushSettings][l_BrushSettings_0.IgnoreWater];
        v61.BruteForceAllSlow = true;
        local v65 = l_Workspace_0:Raycast(l_Position_0, l_Direction_0 * v9.RayLength, v61);
        if not (not v32:IsMouseDown() or not v47()) then
            local v66 = if not v65 then v34.Position else v65.Position;
            local l_magnitude_0 = (v66 - v40.CachePoint).magnitude;
            local l_CacheID_0 = v40.CacheID;
            do
                local l_l_CacheID_0_0 = l_CacheID_0;
                if not (v46() * v9.TerrainCacheUpdateThreshold >= l_magnitude_0 and l_l_CacheID_0_0) then
                    l_l_CacheID_0_0 = l_Workspace_0:CacheCurrentTerrain(v40.CacheID or "", v66, v46());
                    local l_v66_0 = v66 --[[ copy: 4 -> 8 ]];
                    v41(function(v71)
                        return v1.join(v71, {
                            CacheID = l_l_CacheID_0_0,
                            CachePoint = l_v66_0
                        });
                    end);
                end;
                v65 = l_Workspace_0:RaycastCachedTerrain(l_l_CacheID_0_0, l_Position_0, l_Direction_0 * v9.RayLength, true, v61);
            end;
        end;
        if not v65 then
            local v72 = v12();
            local v73, v74 = v13(l_Position_0, l_Direction_0, Vector3.zero, Vector3.yAxis);
            if not (not v73 or not v74) and v74 >= 0 then
                v65 = {
                    Distance = (v73 - l_Position_0).Magnitude,
                    Normal = v72,
                    Position = v73
                };
            else
                local v75 = l_Position_0 + l_Direction_0 * v9.RayLength;
                v65 = {
                    Distance = (v75 - l_Position_0).Magnitude,
                    Normal = v72,
                    Position = v75
                };
            end;
        else
            v65 = {
                Distance = (v65.Position - l_Position_0).Magnitude,
                Instance = v65.Instance,
                Material = v65.Material,
                Normal = v65.Normal,
                Position = v65.Position
            };
        end;
        local v76 = v10(v30, if not v32:IsMouseDown() then CFrame.lookAt(v65.Position, v65.Position + v12()) else v38, v33);
        if v76 then
            v65 = v76;
        end;
        local v77 = v30[l_Category_0.BrushSettings][l_BrushSettings_0.Snapping];
        v37(table.clone(v65));
        if v77 ~= nil and v77 ~= l_Snapping_0.Off then
            local v78 = v14(v65.Position);
            if v30[l_Category_0.BrushSettings][l_BrushSettings_0.FixedYPlane] then
                v78 = Vector3.new(v78.X, v30[l_Category_0.BrushSettings][l_BrushSettings_0.FixedYPlanePosition], v78.Z);
            end;
            v65.Distance = (v78 - l_Position_0).Magnitude;
            v65.Position = v78;
        end;
        return v65;
    end, {
        not v32:IsMouseDown() and true or v38,
        v40,
        v46,
        v47,
        v30[l_Category_0.BrushSettings][l_BrushSettings_0.IgnoreParts],
        v30[l_Category_0.BrushSettings][l_BrushSettings_0.IgnoreWater],
        v30[l_Category_0.BrushSettings][l_BrushSettings_0.Snapping],
        v30[l_Category_0.BrushSettings][l_BrushSettings_0.FixedYPlane],
        v30[l_Category_0.BrushSettings][l_BrushSettings_0.FixedYPlanePosition],
        v30[l_Category_0.BrushSettings][l_BrushSettings_0.PlaneTransform],
        v30[l_Category_0.BrushSettings][l_BrushSettings_0.PlaneLock]
    });
    v7(v33.Button1Down, function()
        if v47() then
            v41(function(v80)
                if not v80.CacheID then
                    return {
                        CacheID = l_Workspace_0:CacheCurrentTerrain("", v34.Position, v46()),
                        CachePoint = v34.Position
                    };
                else
                    return v80;
                end;
            end);
        end;
    end, {
        v34
    });
    v7(v33.Button1Up, function()
        if v40.CacheID then
            l_Workspace_0:ClearCachedTerrain(v40.CacheID);
        end;
        v41({
            CachePoint = Vector3.zero
        });
    end, {
        v40
    });
    v7(v32.MouseMoveAction, function()
        if v42 then
            v43(false);
        end;
    end, {
        v42
    });
    l_useEffect_0(function()
        if not v27() then
            return function()
            end;
        else
            l_RunService_0:BindToRenderStep("TerrainRaycast", 1, function()
                if v32:isMouseMoveReserved() then
                    if not v42 then
                        v43(true);
                    end;
                    return ;
                else
                    v58(v79(v32:IsMouseDown()));
                    return ;
                end;
            end);
            return function()
                l_RunService_0:UnbindFromRenderStep("TerrainRaycast");
            end;
        end;
    end, {
        v58
    });
    l_useEffect_0(function()
        if not v27() then
            task.defer(function()
                if v32:isMouseMoveReserved() then
                    if not v42 then
                        v43(true);
                    end;
                    return ;
                else
                    v58(v79(v32:IsMouseDown()));
                    return ;
                end;
            end);
        end;
    end, {
        v29,
        v79,
        v58,
        v34,
        v42
    });
    return v34, v36;
end;


local l_script_FirstAncestor_0 = script:FindFirstAncestor("TerrainEditor");
local l_DraggerFramework_0 = l_script_FirstAncestor_0.Packages.DraggerFramework;
local v2 = require(l_script_FirstAncestor_0.Packages.React);
local l_useCallback_0 = v2.useCallback;
local l_useEffect_0 = v2.useEffect;
local l_useMemo_0 = v2.useMemo;
local l_useState_0 = v2.useState;
local v7 = require(l_script_FirstAncestor_0.Src.Schemas.Region);
local v8 = require(l_DraggerFramework_0.Implementation.DraggerContext_PluginImpl);
local v9 = require(l_DraggerFramework_0.Handles.MoveHandles);
local v10 = require(l_DraggerFramework_0.Handles.RotateHandles);
local v11 = require(l_DraggerFramework_0.Handles.ExtrudeHandles);
local v12 = require(l_script_FirstAncestor_0.Src.Util.getVoxelAlignedRegion);
local v13 = require(l_script_FirstAncestor_0.Src.Hooks.useHistory);
local v14 = require(l_script_FirstAncestor_0.Src.Resources.Constants);
local v15 = require(l_script_FirstAncestor_0.Src.Types);
local l_BuildSettings_0 = v15.BuildSettings;
local l_Category_0 = v15.Category;
local l_OperationSource_0 = v15.OperationSource;
local l_SeaLevelSettings_0 = v15.SeaLevelSettings;
local l_SelectionSettings_0 = v15.SelectionSettings;
local l_Tool_0 = v15.Tool;
local l_TransformMode_0 = v15.TransformMode;
local l_TransformSettings_0 = v15.TransformSettings;
local v24 = require(l_script_FirstAncestor_0.Src.Controllers.PluginController);
local v25 = require(l_script_FirstAncestor_0.Src.Flags.getFFlagTerrainEditorGenerationFeature);
local v26 = require(l_script_FirstAncestor_0.Src.Flags.getFFlagTerrainEditorErrorHandling);
local v27 = require(l_script_FirstAncestor_0.Src.Flags.getFFlagTerrainEditorCopyPasteFix);
local l_StudioService_0 = game:GetService("StudioService");
local v29 = {
    [l_Tool_0.Build] = if not v25() then nil else l_Category_0.BuildSettings,
    [l_Tool_0.Transform] = l_Category_0.TransformSettings,
    [l_Tool_0.Select] = l_Category_0.SelectionSettings,
    [l_Tool_0.Generate] = l_Category_0.SelectionSettings,
    [l_Tool_0.Fill] = l_Category_0.SelectionSettings,
    [l_Tool_0.Import] = l_Category_0.SelectionSettings,
    [l_Tool_0.SeaLevel] = l_Category_0.SeaLevelSettings,
    [l_Tool_0.Mock] = l_Category_0.SelectionSettings
};
local v30 = {
    [l_Tool_0.Build] = if not v25() then nil else l_BuildSettings_0,
    [l_Tool_0.Transform] = l_TransformSettings_0,
    [l_Tool_0.Select] = l_SelectionSettings_0,
    [l_Tool_0.Generate] = l_SelectionSettings_0,
    [l_Tool_0.Fill] = l_SelectionSettings_0,
    [l_Tool_0.Import] = l_SelectionSettings_0,
    [l_Tool_0.SeaLevel] = l_SeaLevelSettings_0,
    [l_Tool_0.Mock] = l_SelectionSettings_0
};
return function(v31, v32, v33, v34)
    local v35 = v24:use();
    local v36, v37 = l_useState_0({
        Size = v32[v29[v31]][v30[v31].Size],
        Transform = v32[v29[v31]][v30[v31].Transform]
    });
    local v38, v39 = l_useState_0((Vector3.new(1, 1, 1)));
    local v40 = l_useMemo_0(function()
        return v7.Selection.new(v36.Transform, v36.Size);
    end, {
        v31
    });
    local v41, v42 = l_useState_0(nil);
    local v47 = l_useCallback_0(function(v43, v44)
        v33({
            [v29[v31]] = {
                [v30[v31].OperationSource] = v44,
                [v30[v31].Size] = v43.Size,
                [v30[v31].Transform] = v43.Transform
            }
        });
        v37(v43);
        if v31 == l_Tool_0.Transform then
            local v45 = v32[l_Category_0.SelectionSettings][l_SelectionSettings_0.Size];
            local v46 = v32[l_Category_0.TransformSettings][l_TransformSettings_0.TransformMode];
            if v46 == l_TransformMode_0.Paste then
                v45 = v32[l_Category_0.TransformSettings][l_TransformSettings_0.TerrainRegionBufferSize];
            elseif not (v46 ~= l_TransformMode_0.Import) or v46 == l_TransformMode_0.Duplicate then
                v45 = v32[l_Category_0.TransformSettings][l_TransformSettings_0.TerrainRegionSize];
            elseif v46 == l_TransformMode_0.Move then
                v45 = v32[l_Category_0.SelectionSettings][l_SelectionSettings_0.Size];
            end;
            v39(v43.Size / v45);
            return ;
        else
            if v31 == l_Tool_0.Select then
                v39(Vector3.one);
            end;
            return ;
        end;
    end, {
        v33,
        v31,
        v32
    });
    local v49 = v13(v36, function(v48)
        v47(v48, l_OperationSource_0.History);
        v40:SetRegionSignal(v48);
    end, {
        v31
    });
    local v51 = l_useCallback_0(function(v50)
        v49(v50, v36);
    end, {
        v49,
        v36
    });
    local v55 = l_useCallback_0(function(_, v53)
        if not v32[v29[v31]][v30[v31].SnapToVoxels] then
            return v53;
        else
            local v54 = math.round(l_StudioService_0.GridSize / 4) * 4;
            if v54 <= 0 then
                v54 = 4;
            end;
            if math.abs(v54 - 0.01) < 0.001 then
                return v53;
            else
                return math.round(v53 / v54) * v54;
            end;
        end;
    end, {
        v32[v29[v31]][v30[v31].SnapToVoxels]
    });
    local v59 = l_useCallback_0(function(v56, v57)
        local v58 = {
            Size = v57,
            Transform = v56
        };
        v40:SetRegion(v58);
        v47(v58, l_OperationSource_0.Gizmo);
    end, {
        v47
    });
    local v61 = l_useCallback_0(function(v60)
        v40:SetRegion(v60);
        v47(v60, l_OperationSource_0.Gizmo);
    end, {
        v47
    });
    local v64 = l_useMemo_0(function()
        local v62 = if not v35:isMocking() then v8.new(l_script_FirstAncestor_0.Parent, game, settings(), v40) else {
            Mock = true
        };
        v62.snapToGridSize = v55;
        v62.endSelectionOnDrag = function()
            v62.selectionOnDragPoint = nil;
        end;
        v62.updateRegion = v59;
        v62.updateSelectionOnDrag = v61;
        v62.addWaypoint = if not v25() or v31 ~= l_Tool_0.Build then v51 else function()
        end;
        v62.shouldExtendSelection = function()
            return true;
        end;
        local v63 = {
            v11.new(v62, {
                ShowBoundingBox = false,
                Summonable = false
            }, if not not v25() and v31 == l_Tool_0.Build then v7.ExtrudeHandlesImplementation.new(v62, {
                Max = Vector3.one * v14.MaxBuildRegion,
                UseVolume = true
            }) else if not (v31 ~= l_Tool_0.Import) or v26() and v31 == l_Tool_0.Generate then v7.ExtrudeHandlesImplementation.new(v62, {
                Max = Vector3.new(256 * v14.VoxelResolution, 4096 * v14.VoxelResolution, 4096 * v14.VoxelResolution),
                UseVolume = true
            }) else v7.ExtrudeHandlesImplementation.new(v62)),
            v9.new(v62, {
                ShowBoundingBox = false,
                Summonable = false,
                Outset = 1
            }, v7.TransformHandlesImplementation.new(v62))
        };
        if v34 then
            table.insert(v63, v10.new(v62, {
                ShowBoundingBox = false,
                Summonable = false,
                Outset = 1
            }, v7.TransformHandlesImplementation.new(v62)));
        end;
        return {
            Mouse = l_script_FirstAncestor_0.Parent:GetMouse(),
            DraggerContext = v62,
            DraggerSchema = v7,
            DraggerSettings = {
                AnalyticsName = "TerrainEditorRegion",
                AllowDragSelect = true,
                AllowFreeformDrag = false,
                ShowDragSelect = false,
                ShowLocalSpaceIndicator = true,
                ShowPivotIndicator = true,
                HandlesList = v63
            }
        };
    end, {
        v31
    });
    l_useEffect_0(function()
        v64.DraggerContext.addWaypoint = if not v25() or v31 ~= l_Tool_0.Build then v51 else function()
        end;
        v64.DraggerContext.updateRegion = v59;
        v64.DraggerContext.updateSelectionOnDrag = v61;
    end, {
        v36,
        v47,
        v49
    });
    l_useEffect_0(function()
        v64.DraggerContext.snapToGridSize = v55;
    end, {
        v55
    });
    l_useEffect_0(function()
        local v65 = {
            Size = v32[v29[v31]][v30[v31].Size],
            Transform = v32[v29[v31]][v30[v31].Transform]
        };
        if not (v65.Size == v36.Size) or v65.Transform ~= v36.Transform then
            v40:SetRegionSignal(v65);
            v47(v65, l_OperationSource_0.Gizmo);
        end;
    end, {
        v31,
        v32[v29[v31]][v30[v31].Size],
        v32[v29[v31]][v30[v31].Transform]
    });
    l_useEffect_0(function()
        local v66 = {
            Size = v32[v29[v31]][v30[v31].Size],
            Transform = v32[v29[v31]][v30[v31].Transform]
        };
        if v32[v29[v31]][v30[v31].SnapToVoxels] and (not (v32[v29[v31]][v30[v31].SnapToVoxels] == v41 and v66.Size == v36.Size) or v66.Transform ~= v36.Transform) then
            local v67 = math.floor(l_StudioService_0.GridSize / 4 + 0.5) * 4;
            if v67 <= 0 then
                v67 = 4;
            end;
            local v68, v69 = v12(v32[v29[v31]][v30[v31].Transform], v32[v29[v31]][v30[v31].Size], v67);
            local v70 = {
                Size = v69,
                Transform = v68
            };
            if not (v70.Size == v66.Size) or v70.Transform ~= v66.Transform then
                v40:SetRegionSignal(v70);
                v47(v70, l_OperationSource_0.Gizmo);
            end;
        end;
        v42(v32[v29[v31]][v30[v31].SnapToVoxels]);
    end, {
        v32[v29[v31]][v30[v31].SnapToVoxels],
        v32[v29[v31]][v30[v31].Size],
        v32[v29[v31]][v30[v31].Transform]
    });
    l_useEffect_0(function()
        if v27() then
            if v31 == l_Tool_0.Transform then
                local v71 = v32[l_Category_0.SelectionSettings][l_SelectionSettings_0.Size];
                local v72 = v32[l_Category_0.TransformSettings][l_TransformSettings_0.TransformMode];
                if v72 == l_TransformMode_0.Paste then
                    v71 = v32[l_Category_0.TransformSettings][l_TransformSettings_0.TerrainRegionBufferSize];
                elseif not (v72 ~= l_TransformMode_0.Import) or v72 == l_TransformMode_0.Duplicate then
                    v71 = v32[l_Category_0.TransformSettings][l_TransformSettings_0.TerrainRegionSize];
                elseif v72 == l_TransformMode_0.Move then
                    v71 = v32[l_Category_0.SelectionSettings][l_SelectionSettings_0.Size];
                end;
                v39(v32[l_Category_0.TransformSettings][l_TransformSettings_0.Size] / v71);
                return ;
            else
                if v31 == l_Tool_0.Select then
                    v39(Vector3.one);
                end;
                return ;
            end;
        else
            return ;
        end;
    end, {
        v31
    });
    return v64, v36, v38;
end;


local l_useState_0 = require(script:FindFirstAncestor("TerrainEditor").Packages.React).useState;
return function()
    local v1, v2 = l_useState_0(Region3.new(Vector3.new(-64, -64, -64), (Vector3.new(64, 64, 64))));
    return v1, v2;
end;


local l_useState_0 = require(script:FindFirstAncestor("TerrainEditor").Packages.React).useState;
return function(v1, v2)
    local v3 = nil;
    if not v1 then
        v3 = game.Workspace.Terrain;
    elseif not v2 then
        v3 = {};
    else
        return ;
    end;
    return (l_useState_0(v3));
end;


local l_script_FirstAncestor_0 = script:FindFirstAncestor("TerrainEditor");
local v1 = require(l_script_FirstAncestor_0.Packages.React);
local _ = require(l_script_FirstAncestor_0.Src.Controllers.ToolController);
local _ = require(l_script_FirstAncestor_0.Src.Tools.BaseTool);
local l_useState_0 = v1.useState;
local l_useEffect_0 = v1.useEffect;
return function(v6)
    local v7, v8 = l_useState_0(v6:getToolIndex());
    local v9, v10 = l_useState_0(v6:getTabIndex());
    l_useEffect_0(function()
        local v11 = v6.OnToolIndexChanged:Connect(v8);
        return function()
            v11:Disconnect();
        end;
    end, {});
    l_useEffect_0(function()
        local v12 = v6.OnTabIndexChanged:Connect(v10);
        return function()
            v12:Disconnect();
        end;
    end, {});
    return {
        Tabs = v6:getTabs(),
        TabIndex = v9,
        Tools = v6:getToolbar(),
        ToolIndex = v7
    };
end;


local l_StudioFixPluginWidgetLocalizedIds_0 = game:GetFastFlag("StudioFixPluginWidgetLocalizedIds");
local l_Parent_0 = script.Parent.Parent;
local v2 = require(l_Parent_0.Packages.React);
local v3 = require(l_Parent_0.Packages.ReactRoblox);
local v4 = require(l_Parent_0.Packages.Framework);
local v5 = require(l_Parent_0.Packages.MaterialFramework);
local l_DockWidget_0 = v4.UI.DockWidget;
local l_ContextServices_0 = v4.ContextServices;
local l_Plugin_0 = l_ContextServices_0.Plugin;
local l_Mouse_0 = l_ContextServices_0.Mouse;
local l_StudioServices_0 = v5.Context.StudioServices;
local v11 = require(l_Parent_0.Src.Resources.MakeTheme);
local l_SourceStrings_0 = l_Parent_0.Src.Resources.Localization.SourceStrings;
local l_LocalizedStrings_0 = l_Parent_0.Src.Resources.Localization.LocalizedStrings;
local v14 = require(l_Parent_0.Src.Components.App);
local l_Controllers_0 = l_Parent_0.Src.Controllers;
local v16 = require(l_Controllers_0.ShortcutController);
local v17 = require(l_Controllers_0.PluginController);
local v18 = require(l_Controllers_0.ToolController);
local v19 = require(l_Parent_0.Src.Resources.AnalyticsHandlers);
local v20 = require(l_Parent_0.Src.Flags.getFFlagTerrainEditorFixInitialization);
local v21 = require(l_Parent_0.Src.Flags.getFFlagFixTerrainEditorDETruncations);
local l_Tool_0 = require(l_Parent_0.Src.Types).Tool;
local v23 = v2.PureComponent:extend("MainPlugin");
v23.init = function(v24, v25)
    local l_Plugin_1 = v25.Plugin;
    if not v20() then
        local v27 = false;
        if v25.PluginLoaderContext then
            local l_mainDockWidget_0 = v25.PluginLoaderContext.mainDockWidget;
            local v29 = false;
            if l_mainDockWidget_0 ~= nil then
                v29 = l_mainDockWidget_0.Enabled;
            end;
            v27 = v29;
        end;
        v24:setState({
            enabled = v27
        });
    end;
    v24.toggleEnabled = function()
        if not v24.state.enabled then
            v24.onRestore(true);
            return ;
        else
            v24.onClose();
            return ;
        end;
    end;
    v24.onClose = function()
        v24:setState({
            enabled = false
        });
        if v24.toolController and v24.toolController:getTool()._name ~= l_Tool_0.Empty then
            v24.toolIndex = v24.toolController:getToolIndex();
            v24.tabIndex = v24.toolController:getTabIndex();
            v24.toolController:setTabAndToolIndex(v24.tabIndex, v24.toolIndex);
        end;
    end;
    v24.onCreated = function()
        if v24.props.PluginLoaderContext then
            v24.props.PluginLoaderContext.mainButton:SetActive(v24.state.enabled);
            v24.props.PluginLoaderContext.mainButtonClickedSignal:Connect(v24.toggleEnabled);
        end;
    end;
    v24.onRestore = function(v30)
        v24:setState({
            enabled = v30
        });
        if not ((not v24.toolController or not v24.tabIndex) or not v24.toolIndex) then
            v24.toolController:setTabAndToolIndex(v24.tabIndex, v24.toolIndex);
            v24.toolIndex = nil;
            v24.tabIndex = nil;
        end;
    end;
    v24.onWidgetEnabledChanged = function(v31)
        if not v31.Enabled then
            v24.onClose();
            return ;
        else
            v24.onRestore(v31.Enabled);
            return ;
        end;
    end;
    if not v20() then
        v24.localization = l_ContextServices_0.Localization.new({
            libraries = {
                [v5.Resources.LOCALIZATION_PROJECT_NAME] = {
                    stringResourceTable = v5.Resources.SourceStrings,
                    translationResourceTable = v5.Resources.LocalizedStrings
                },
                [v4.Resources.LOCALIZATION_PROJECT_NAME] = {
                    stringResourceTable = v4.Resources.SourceStrings,
                    translationResourceTable = v4.Resources.LocalizedStrings
                }
            },
            stringResourceTable = l_SourceStrings_0,
            translationResourceTable = l_LocalizedStrings_0,
            pluginName = "TerrainEditor"
        });
        v24.analytics = l_ContextServices_0.Analytics.new(v19);
        v24.shortcutController = v16.new(l_Plugin_1, v24.localization);
        v24.pluginController = v17.new(l_Plugin_1);
        v24.studioServices = l_StudioServices_0.new();
        v24.stylizer = v11();
        v24.toolController = v18.new(v24.pluginController, v24.shortcutController, v24.analytics, v24.localization, v24.stylizer);
    end;
    v24.onFocused = function()
        v24.pluginController:resume();
    end;
    v24.onUnfocused = function()
        v24.pluginController:pause();
    end;
    v24.button = if not v24.props.PluginLoaderContext then nil else v24.props.PluginLoaderContext.mainButton;
    if v20() then
        v24.state = {
            enabled = false
        };
    end;
end;
if v20() then
    v23.didMount = function(v32)
        local l_Plugin_2 = v32.props.Plugin;
        if not v32.localization then
            v32.localization = l_ContextServices_0.Localization.new({
                libraries = {
                    [v5.Resources.LOCALIZATION_PROJECT_NAME] = {
                        stringResourceTable = v5.Resources.SourceStrings,
                        translationResourceTable = v5.Resources.LocalizedStrings
                    },
                    [v4.Resources.LOCALIZATION_PROJECT_NAME] = {
                        stringResourceTable = v4.Resources.SourceStrings,
                        translationResourceTable = v4.Resources.LocalizedStrings
                    }
                },
                stringResourceTable = l_SourceStrings_0,
                translationResourceTable = l_LocalizedStrings_0,
                pluginName = "TerrainEditor"
            });
        end;
        if not v32.analytics then
            v32.analytics = l_ContextServices_0.Analytics.new(v19);
        end;
        if not v32.shortcutController then
            v32.shortcutController = v16.new(l_Plugin_2, v32.localization);
        end;
        if not v32.pluginController then
            v32.pluginController = v17.new(l_Plugin_2);
        end;
        if not v32.studioServices then
            v32.studioServices = l_StudioServices_0.new();
        end;
        if not v32.stylizer then
            v32.stylizer = v11();
        end;
        if not v32.toolController then
            v32.toolController = v18.new(v32.pluginController, v32.shortcutController, v32.analytics, v32.localization, v32.stylizer);
        end;
        if not v32._initialized then
            local v34 = false;
            if v32.props.PluginLoaderContext then
                local l_mainDockWidget_1 = v32.props.PluginLoaderContext.mainDockWidget;
                local v36 = false;
                if l_mainDockWidget_1 ~= nil then
                    v36 = l_mainDockWidget_1.Enabled;
                end;
                v34 = v36;
            end;
            v32:setState({
                enabled = v34
            });
            v32._initialized = true;
        end;
    end;
end;
v23.didUpdate = function(v37)
    v37.button:SetActive(v37.state.enabled);
end;
v23.willUnmount = function(v38)
    v38.pluginController:destroy();
    v38.toolController:destroy();
end;
v23.render = function(v39)
    local l_props_0 = v39.props;
    local l_state_0 = v39.state;
    local l_Plugin_3 = l_props_0.Plugin;
    local l_enabled_0 = l_state_0.enabled;
    if not v20() or v39.localization then
        return l_ContextServices_0.provide({
            l_Plugin_0.new(l_Plugin_3),
            l_Mouse_0.new(l_Plugin_3:getMouse()),
            v39.stylizer,
            v39.localization,
            v39.analytics,
            v39.shortcutController,
            v39.pluginController,
            v39.studioServices,
            v39.toolController
        }, {
            MainWidget = v2.createElement(l_DockWidget_0, {
                Id = if not l_StudioFixPluginWidgetLocalizedIds_0 then nil else "TerrainEditor",
                Enabled = l_enabled_0,
                Title = v39.localization:getText("Plugin", "Name"),
                ZIndexBehavior = Enum.ZIndexBehavior.Sibling,
                InitialDockState = Enum.InitialDockState.Left,
                Size = Vector2.new(640, 480),
                MinSize = if not v21() then Vector2.new(320, 200) else Vector2.new(350, 200),
                OnClose = v39.onClose,
                ShouldRestore = true,
                OnWidgetCreated = v39.onCreated,
                OnWidgetFocused = v39.onFocused,
                OnWidgetFocusReleased = v39.onUnfocused,
                OnWidgetRestored = v39.onRestore,
                Widget = if not v39.props.PluginLoaderContext then nil else v39.props.PluginLoaderContext.mainDockWidget,
                [v3.Change.Enabled] = v39.onWidgetEnabledChanged
            }, {
                App = v2.createElement(v14)
            })
        }, true);
    else
        return ;
    end;
end;
return v23;


local l_script_FirstAncestor_0 = script:FindFirstAncestor("TerrainEditor");
local l_join_0 = require(l_script_FirstAncestor_0.Packages.Dash).join;
local l_Util_0 = l_script_FirstAncestor_0.Src.Util;
local v3 = require(l_Util_0.ConvertForAnalytics);
local v4 = require(l_Util_0.DebugFlags);
local _ = require(l_script_FirstAncestor_0.Src.Types);
local l_HttpService_0 = game:GetService("HttpService");
local l_StudioService_0 = game:GetService("StudioService");
local v8 = require(l_script_FirstAncestor_0.Src.Flags.getFFlagTerrainEditorTimeStatistic);
return function(v9)
    local function v12(v10, v11)
        v11 = v3(l_join_0({
            studioSid = v9:GetSessionId(),
            placeId = game.PlaceId,
            userId = l_StudioService_0:GetUserId()
        }, v11));
        if v4.LogAnalytics() then
            print((("(EVENT) TerrainEditor reported event %* with payload %*"):format(tostring(v10), (l_HttpService_0:JSONEncode(v11)))));
        end;
        v9:SendEventDeferred("studio", "TerrainEditor", v10, v11);
    end;
    local function _(v13, v14)
        v14 = v14 or 1;
        if v4.LogAnalytics() then
            print((("Terrain ReportCounter counterName=%* count=%*"):format(v13, v14)));
        end;
        v9:ReportCounter(v13, v14);
    end;
    local function _(v16, v17)
        if v4.LogAnalytics() then
            print((("Terrain ReportCounter counterName=%* count=%*"):format(v16, v17)));
        end;
        v9:ReportStats(v16, v17);
    end;
    return {
        Activated = function(_, v20, v21)
            local v22 = ("%*ToolActivated"):format(v20);
            local v23 = v21 or 1;
            if v4.LogAnalytics() then
                print((("Terrain ReportCounter counterName=%* count=%*"):format(v22, v23)));
            end;
            v9:ReportCounter(v22, v23);
        end,
        Usage = function(_, v25, v26)
            local v27 = ("%*ToolUsage"):format(v25);
            local v28 = v26 or 1;
            if v4.LogAnalytics() then
                print((("Terrain ReportCounter counterName=%* count=%*"):format(v27, v28)));
            end;
            v9:ReportCounter(v27, v28);
        end,
        Performance = if not v8() then nil else function(_, v30, v31)
            local v32 = ("%*ToolPerformance"):format(v30);
            if v4.LogAnalytics() then
                print((("Terrain ReportCounter counterName=%* count=%*"):format(v32, v31)));
            end;
            v9:ReportStats(v32, v31);
        end,
        BrushProperties = function(_, v34)
            v12("terrainEditorBrushProperties", v34);
        end,
        RegionProperties = function(_, v36)
            v12("terrainEditorRegionProperties", v36);
        end,
        MaterialProperties = function(_, v38)
            v12("terrainEditorMaterialProperties", v38);
        end
    };
end;


return {
    AspectRatioThreshold = 0.1,
    GridLineWidth = 20,
    IsDebuggingSavedSettings = false,
    MaxScaleFactor = 2,
    MaximumOccupancy = 1,
    MinimumOccupancy = 0.00390625,
    MinimumSmooth = 0.0625,
    RayLength = 10000,
    TerrainCacheMaxRadius = 500,
    TerrainCacheMultiplier = 5,
    TerrainCacheUpdateThreshold = 0.9,
    VoxelResolution = 4,
    MaxRegion = 16384,
    MaxBuildRegion = 512,
    MaxMaterialListSize = 5,
    MaxImportVolume = 274877906944,
    RegionNormalization = 256,
    RegionNormalizationMinVolume = 262144,
    BrushNormalization = 64,
    BrushNormalizationMinVolume = 216,
    PlacementSnap = 6,
    SpikeThreshold = 10000,
    MinWindowWidth = 330
};


local l_script_FirstAncestor_0 = script:FindFirstAncestor("TerrainEditor");
local v1 = require(l_script_FirstAncestor_0.Packages.Framework);
local l_Style_0 = v1.Style;
local l_StyleKey_0 = l_Style_0.StyleKey;
local l_StyleModifier_0 = v1.Util.StyleModifier;
local l_ComponentSymbols_0 = l_Style_0.ComponentSymbols;
local v6 = require(l_script_FirstAncestor_0.Src.Flags.getFFlagFixTerrainEditorDETruncations);
local v7 = {};
l_ComponentSymbols_0:add("Toolbar");
v7[l_ComponentSymbols_0.Toolbar] = {
    CellSize = if not v6() then UDim2.fromOffset(70, 70) else UDim2.fromOffset(84, 84),
    CellPadding = UDim2.fromOffset(2, 2),
    IconSize = if not v6() then UDim2.fromOffset(28, 28) else UDim2.fromOffset(30, 30),
    OverflowTextSize = if not v6() then nil else 15,
    OverflowThreshold = if not v6() then nil else 75,
    StudioTheme = l_StyleKey_0.StudioTheme,
    TabBackgroundColor = l_StyleKey_0.SubBackground,
    TextSize = if not v6() then nil else 18
};
l_ComponentSymbols_0:add("ToolSettings");
v7[l_ComponentSymbols_0.ToolSettings] = {
    BackgroundColor = l_StyleKey_0.MainBackground
};
l_ComponentSymbols_0:add("ImageRenderer");
v7[l_ComponentSymbols_0.ImageRenderer] = {
    ClearIcon = "rbxasset://textures/StudioSharedUI/preview_clear.png",
    ExpandIcon = "rbxasset://textures/StudioSharedUI/preview_expand.png",
    IconPadding = 3,
    ImportIcon = "rbxasset://textures/StudioSharedUI/import@2x.png",
    PreviewSize = UDim2.fromOffset(100, 100),
    ToolbarTransparency = 0.4,
    ToolbarBackgroundColor = l_StyleKey_0.ToolbarBackgroundColor,
    ToolbarButtonBackgroundColor = l_StyleKey_0.ToolbarButtonBackgroundColor,
    ToolbarHeight = 32
};
l_ComponentSymbols_0:add("MetadataDialog");
v7[l_ComponentSymbols_0.MetadataDialog] = {
    ImageBackgroundColor = Color3.new(0, 0, 0),
    MetadataLineHeight = 16,
    MinSize = Vector2.new(100, 100),
    Padding = 4,
    Size = Vector2.new(400, 400),
    Spacing = 4
};
l_ComponentSymbols_0:add("MaterialRenderer");
v7[l_ComponentSymbols_0.MaterialRenderer] = {
    CornerRadius = UDim.new(0, 4),
    DropdownItemHeight = 40,
    GridItemSize = 48,
    InitialDistance = 6.2,
    MaterialPreviewBackground = l_StyleKey_0.InputFieldBackground,
    PreviewSize = 24,
    Spacing = 6
};
l_ComponentSymbols_0:add("ProgressDialog");
v7[l_ComponentSymbols_0.ProgressDialog] = {
    DescriptionHeight = 20,
    MinContentSize = Vector2.new(320, 60),
    Padding = 5,
    ProgressHeight = 20,
    Spacing = 5
};
l_ComponentSymbols_0:add("PlaneLockRenderer");
v7[l_ComponentSymbols_0.PlaneLockRenderer] = {
    Height = 32,
    Icon = l_StyleKey_0.Reset,
    Spacing = 6
};
l_ComponentSymbols_0:add("UpgradeRenderer");
v7[l_ComponentSymbols_0.UpgradeRenderer] = {
    Font = Enum.Font.SourceSans,
    MaxWidth = 300,
    Spacing = 12,
    TextSize = 16
};
l_ComponentSymbols_0:add("Line");
v7[l_ComponentSymbols_0.Line] = {
    Color = BrickColor.White(),
    TransparencyActive = 0.8,
    Transparency = 0.3
};
l_ComponentSymbols_0:add("Brush");
v7[l_ComponentSymbols_0.Brush] = {
    CenterRadiusMultiplier = 0.015,
    CenterTransparency = 0.25,
    Color = BrickColor.White(),
    MainTransparency = 0.95
};
v7[l_ComponentSymbols_0.SimpleTab] = {
    BorderSize = 1,
    Spacing = 5,
    Padding = {
        Left = 20,
        Top = 4,
        Bottom = 0,
        Right = 20
    },
    TopLineHeight = 3,
    Color = l_StyleKey_0.ButtonText,
    BackgroundColor = l_StyleKey_0.SubBackground,
    BorderColor = l_StyleKey_0.SubBackground,
    TopLineColor = l_StyleKey_0.DialogMainButton,
    BottomLineColor = l_StyleKey_0.SubBackground,
    [l_StyleModifier_0.Hover] = {
        Color = l_StyleKey_0.DialogMainButton
    },
    [l_StyleModifier_0.Selected] = {
        BottomLineColor = l_StyleKey_0.MainBackground,
        BackgroundColor = l_StyleKey_0.MainBackground,
        BorderColor = l_StyleKey_0.Border
    },
    [l_StyleModifier_0.Disabled] = {
        Color = l_StyleKey_0.ButtonTextDisabled
    }
};
local v8 = UDim.new(0, 6);
l_ComponentSymbols_0:add("MaterialGrid");
v7[l_ComponentSymbols_0.MaterialGrid] = {
    BackgroundColor = l_StyleKey_0.MainBackground,
    GridItemBackgroundColor = l_StyleKey_0.Button,
    GridItemBackgroundColorHovered = l_StyleKey_0.ButtonHover,
    GridItemBorderColor = l_StyleKey_0.Border,
    GridItemBorderColorSelected = l_StyleKey_0.InputFieldBorderSelected,
    GridItemCornerRadius = UDim.new(0, 6),
    GridItemPadding = 2,
    GridItemSize = 128,
    GridItemLabelPadding = {
        PaddingBottom = v8,
        PaddingLeft = v8,
        PaddingRight = v8
    },
    ListItemHeight = 40,
    ListItemPadding = 0,
    ListItemSpacing = 4,
    MaterialPreviewStyle = "CornerBox",
    Padding = 0,
    ShimmerSizeOffset = 2,
    TextSize = 20
};
l_ComponentSymbols_0:add("Note");
v7[l_ComponentSymbols_0.Note] = {
    Background = l_StyleKey_0.MainBackground,
    KeyBackground = l_StyleKey_0.DimmedText,
    EdgePadding = 2,
    FramePadding = 3,
    TextMargin = 2
};
l_ComponentSymbols_0:add("BrushSizeRenderer");
v7[l_ComponentSymbols_0.BrushSizeRenderer] = {
    LabelWidth = 20,
    LockButtonWidth = 26,
    RowHeight = 24,
    Locked = l_StyleKey_0.Locked,
    Unlocked = l_StyleKey_0.Unlocked
};
l_ComponentSymbols_0:add("MultiSelectionRenderer");
v7[l_ComponentSymbols_0.MultiSelectionRenderer] = {
    Spacing = 4
};
l_ComponentSymbols_0:add("ElevationRenderer");
v7[l_ComponentSymbols_0.ElevationRenderer] = {
    AddStyle = {
        Color = l_StyleKey_0.TextPrimary,
        Image = "rbxasset://textures/TagEditor/Add.png"
    },
    ArrowSize = UDim2.fromOffset(10, 5),
    ArrowStyle = {
        Image = "rbxasset://textures/TerrainEditor/trianglesmallinverted.png"
    },
    ButtonSize = UDim2.fromOffset(16, 16),
    Corner = UDim.new(0, 4),
    ImageColor = l_StyleKey_0.TextPrimary,
    ImageColorSelected = l_StyleKey_0.DialogMainButton,
    MaterialPreviewSize = UDim2.fromOffset(20, 20),
    PreviewBorder = {
        Color = l_StyleKey_0.DialogMainButton,
        Image = "rbxasset://textures/StudioToolbox/RoundedBorder.png",
        SliceCenter = Rect.new(3, 3, 13, 13)
    },
    RemoveStyle = {
        Image = "rbxasset://textures/TagEditor/Close.png"
    },
    SliderSize = UDim2.fromOffset(20, 200),
    TextBoxSize = UDim2.fromOffset(50, 20),
    Spacing = 10
};
l_ComponentSymbols_0:add("SlopeRenderer");
v7[l_ComponentSymbols_0.SlopeRenderer] = {
    Height = 24,
    Spacing = 6,
    TextInputWidth = 50
};
l_ComponentSymbols_0:add("MaterialRangesRenderer");
v7[l_ComponentSymbols_0.MaterialRangesRenderer] = {
    BackgroundColor = BrickColor.new(0, 0, 0),
    CloseButton = {
        AnchorPoint = Vector2.new(1, 0),
        BackgroundTransparency = 1,
        BorderSizePixel = 0,
        Image = "rbxasset://textures/DeveloperFramework/AssetPreview/close_button.png",
        ImageColor3 = Color3.fromRGB(255, 255, 255),
        Position = UDim2.fromScale(1, 0),
        Size = UDim2.fromOffset(28, 28),
        ZIndex = 2
    },
    Dialog = {
        AnchorPoint = Vector2.new(0.5, 0.5),
        BackgroundColor = l_StyleKey_0.MainBackground,
        Position = UDim2.fromScale(0.5, 0.5),
        FillSize = UDim2.new(0, 250, 1, -60),
        Size = UDim2.fromOffset(250, 0)
    },
    MinHeight = 587,
    Padding = 6,
    Reset = {
        Icon = l_StyleKey_0.Reset,
        Size = UDim2.fromOffset(90, 32)
    }
};
l_ComponentSymbols_0:add("TerrainTypeRenderer");
v7[l_ComponentSymbols_0.TerrainTypeRenderer] = {
    BorderColor = l_StyleKey_0.DialogMainButton,
    Height = 32,
    IconSize = 24,
    ItemsPerRow = 3,
    Spacing = 6
};
return v7;


local l_script_FirstAncestor_0 = script:FindFirstAncestor("TerrainEditor");
local v1 = require(l_script_FirstAncestor_0.Packages.Framework);
local v2 = require(l_script_FirstAncestor_0.Packages.React);
local v3 = require(l_script_FirstAncestor_0.Packages.ReactRoblox);
local v4 = require(l_script_FirstAncestor_0.Packages.Dev.ReactTestingLibrary);
local v5 = require(l_script_FirstAncestor_0.Packages.Dev.Rhodium);
local l_render_0 = v4.render;
local l_screen_0 = v4.screen;
local l_Pane_0 = v1.UI.Pane;
local v9 = require(l_script_FirstAncestor_0.Src.Util.mockContext);
local v10 = require(l_script_FirstAncestor_0.Src.Components.App);
local _ = require(l_script_FirstAncestor_0.Src.Types);
local l_UserInputService_0 = game:GetService("UserInputService");
local l_VirtualInputManager_0 = game:GetService("VirtualInputManager");
local v23 = {
    MountApp = function(v14)
        l_render_0((v9({
            AppContainer = v2.createElement(l_Pane_0, {
                Size = UDim2.new(0, 300, 1, 0)
            }, {
                App = v2.createElement(v10)
            })
        }, v14)));
    end,
    SelectTab = function(v15)
        v4.fireEvent.click(l_screen_0.getByText((("Studio.Test.Tabs.%*:[]"):format(v15))).Parent.Parent);
    end,
    SelectTool = function(v16)
        v4.fireEvent.click(l_screen_0.getByText((("Studio.Test.BaseTool.%*:[]"):format(v16))).Parent.Parent);
    end,
    UseBrush = function(v17, v18)
        v18._options = {
            cycles = 1
        };
        v17.Move:Fire();
        v18:startOperation({
            cycles = 1
        });
    end,
    UseBrushWithMouse = function(v19, v20)
        v19.Move:Fire();
        v19.Button1Down:Fire();
        v3.act(function()
            v20._operation._budget = nil;
            wait(1);
        end);
        v19.Button1Up:Fire();
    end,
    GetSettingsContainer = function(v21, v22)
        return l_screen_0.getByText((("Studio.Test.%*.%*:[]"):format(v21, v22))).Parent.Parent.Parent.Property.Content;
    end
};
v23.SetNumber = function(v24, v25, v26)
    v4.fireEvent.change(v23.GetSettingsContainer(v24, v25):FindFirstChildWhichIsA("TextBox", true), {
        target = {
            Text = tostring(v26)
        }
    });
end;
v23.SetVector = function(v27, v28, v29)
    local l_Children_0 = v23.GetSettingsContainer(v27, v28):GetChildren();
    local v31 = {};
    for _, v33 in l_Children_0, nil, nil do
        if v33:IsA("Frame") then
            table.insert(v31, v33:FindFirstChildWhichIsA("TextBox", true));
        end;
    end;
    table.sort(v31, function(v34, v35)
        return v34.LayoutOrder < v35.LayoutOrder;
    end);
    v31[1]:CaptureFocus();
    v4.fireEvent.change(v31[1], {
        target = {
            Text = tostring(v29.X)
        }
    });
    v31[1]:ReleaseFocus();
    v31[2]:CaptureFocus();
    v4.fireEvent.change(v31[2], {
        target = {
            Text = tostring(v29.Y)
        }
    });
    v31[2]:ReleaseFocus();
    v31[3]:CaptureFocus();
    v4.fireEvent.change(v31[3], {
        target = {
            Text = tostring(v29.Z)
        }
    });
    v31[3]:ReleaseFocus();
end;
v23.SetTabbedEnum = function(v36, v37, v38)
    v4.fireEvent.click(v23.GetSettingsContainer(v36, v37):FindFirstChild(v38, true).Contents.TextButton);
end;
v23.ToggleCheckbox = function(v39, v40)
    v4.fireEvent.click((v23.GetSettingsContainer(v39, v40):FindFirstChildWhichIsA("TextButton", true)));
end;
v23.SetMaterial = function(v41, v42, v43)
    for _, v45 in (v23.GetSettingsContainer(v41, v42):FindFirstChildWhichIsA("ScrollingFrame", true)), nil, nil do
        if v45:FindFirstChildWhichIsA("MeshPart").Material == v43 then
            v4.fireEvent.click(v45);
        end;
    end;
end;
v23.ClickButton = function(v46, v47)
    v4.fireEvent.click((l_screen_0.getByText((("Studio.Test.%*.%*:[]"):format(v46, v47)))));
end;
v23.ScrollUp = function()
    v3.act(function()
        v5.VirtualInput.Mouse.SendMouseWheelEvent(350, 150, true);
        l_VirtualInputManager_0:WaitForInputEventsProcessed();
    end);
end;
v23.ScrollDown = function()
    v3.act(function()
        v5.VirtualInput.Mouse.SendMouseWheelEvent(350, 150, false);
        l_VirtualInputManager_0:WaitForInputEventsProcessed();
    end);
end;
v23.ToggleControl = function()
    v3.act(function()
        if not l_UserInputService_0:IsKeyDown(Enum.KeyCode.LeftControl) then
            v5.VirtualInput.Keyboard.pressKey(Enum.KeyCode.LeftControl);
        else
            v5.VirtualInput.Keyboard.releaseKey(Enum.KeyCode.LeftControl);
        end;
        l_VirtualInputManager_0:WaitForInputEventsProcessed();
    end);
end;
v23.ToggleShift = function()
    v3.act(function()
        if not l_UserInputService_0:IsKeyDown(Enum.KeyCode.LeftShift) then
            v5.VirtualInput.Keyboard.pressKey(Enum.KeyCode.LeftShift);
        else
            v5.VirtualInput.Keyboard.releaseKey(Enum.KeyCode.LeftShift);
        end;
        l_VirtualInputManager_0:WaitForInputEventsProcessed();
    end);
end;
v23.ToggleAlt = function()
    v3.act(function()
        if not l_UserInputService_0:IsKeyDown(Enum.KeyCode.LeftAlt) then
            v5.VirtualInput.Keyboard.pressKey(Enum.KeyCode.LeftAlt);
        else
            v5.VirtualInput.Keyboard.releaseKey(Enum.KeyCode.LeftAlt);
        end;
        l_VirtualInputManager_0:WaitForInputEventsProcessed();
    end);
end;
v23.ToggleB = function()
    v3.act(function()
        if not l_UserInputService_0:IsKeyDown(Enum.KeyCode.B) then
            v5.VirtualInput.Keyboard.pressKey(Enum.KeyCode.B);
        else
            v5.VirtualInput.Keyboard.releaseKey(Enum.KeyCode.B);
        end;
        l_VirtualInputManager_0:WaitForInputEventsProcessed();
    end);
end;
v23.HitKey = function(v48)
    v3.act(function()
        v5.VirtualInput.Keyboard.hitKey(v48);
    end);
end;
return v23;


local v0 = require(script:FindFirstAncestor("TerrainEditor").Packages.DraggerFramework.Utility.Signal);
local v1 = {};
v1.__index = v1;
v1.new = function(v2)
    local v3 = setmetatable({
        _transform = {
            Transform = v2
        }
    }, v1);
    v3.SelectionChanged = v0.new();
    return v3;
end;
v1.SetTransform = function(v4, v5)
    v4._transform.Transform = v5;
end;
v1.SetTransformSignal = function(v6, v7)
    v6:SetTransform(v7);
    v6.SelectionChanged:Fire();
end;
v1.Set = function(_)
end;
v1.Get = function(v9)
    return {
        v9._transform
    };
end;
return v1;


local v0 = {};
v0.__index = v0;
v0.new = function(v1, v2)
    assert(#v2 == 1, "Expected selection to have length 1.");
    return (setmetatable({
        _transform = v2[1],
        _draggerContext = v1
    }, v0));
end;
v0.isEmpty = function(_)
    return false;
end;
v0.getBoundingBox = function(v4)
    if not v4._draggerContext:shouldUseLocalSpace() then
        return CFrame.new(v4._transform.Transform.Position), Vector3.new(), (Vector3.new());
    else
        return v4:getLocalBoundingBox();
    end;
end;
v0.getLocalBoundingBox = function(v5)
    return v5._transform.Transform, Vector3.new(), (Vector3.new());
end;
v0.doesContainItem = function(_, _)
    return true;
end;
v0.isDynamic = function(_)
    return false;
end;
return v0;


local v0 = {};
v0.__index = v0;
v0.new = function(v1)
    return (setmetatable({
        _draggerContext = v1
    }, v0));
end;
v0.beginDrag = function(v2, v3, _)
    assert(#v3 == 1, "Expected selection to have length 1.");
    v2.source = v3[1].Transform;
end;
v0.updateDrag = function(v5, v6)
    v5._draggerContext.updatePlane(v6 * v5.source);
    return v6;
end;
v0.endDrag = function(_)
end;
v0.render = function(_, _)
    return nil;
end;
return v0;


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


local l_script_FirstAncestor_0 = script:FindFirstAncestor("TerrainEditor");
local v1 = require(l_script_FirstAncestor_0.Src.Util.getBinarySearchedSize);
local v2 = require(l_script_FirstAncestor_0.Src.Resources.Constants);
local _ = require(l_script_FirstAncestor_0.Src.Flags.getFFlagTerrainEditorGenerationFeature);
local v4 = {};
v4.__index = v4;
v4.new = function(v5, v6)
    return (setmetatable({
        _draggerContext = v5,
        _max = if not v6 then nil else v6.Max,
        _volume = if (not not v6 and v6.Max) and v6.UseVolume then (v6.Max.X * v6.Max.Y) * v6.Max.Z else nil
    }, v4));
end;
v4.getBoundingBox = function(_, _, v9)
    return v9:getBoundingBox();
end;
v4.shouldScaleFromCenter = function(v10, _, _, _)
    return v10._draggerContext:isCtrlKeyDown();
end;
v4.axesToScale = function(v14, _, v16)
    if not v14._draggerContext:isShiftKeyDown() then
        return ({
            {
                X = true
            },
            {
                Y = true
            },
            {
                Z = true
            }
        })[v16];
    else
        return {
            X = true,
            Y = true,
            Z = true
        };
    end;
end;
v4.getMinMaxSizes = function(v17, v18, v19, v20)
    local v21 = Vector3.one * 4;
    local v22 = v17._max or (Vector3.one * 4096) * 4;
    if v17._volume then
        if not (not v18 or not v19) and v20 then
            if (not v19.X or not v19.Y) or not v19.Z then
                if not v19.X then
                    if not v19.Y then
                        if v19.Z then
                            local l_X_0 = v20.X;
                            local l_Y_0 = v20.Y;
                            v22 = Vector3.new(l_X_0, l_Y_0, v17._volume / (l_X_0 * l_Y_0));
                        end;
                    else
                        local l_X_1 = v20.X;
                        local l_Z_0 = v20.Z;
                        v22 = Vector3.new(l_X_1, v17._volume / (l_X_1 * l_Z_0), l_Z_0);
                    end;
                else
                    local l_Y_1 = v20.Y;
                    local l_Z_1 = v20.Z;
                    v22 = Vector3.new(v17._volume / (l_Y_1 * l_Z_1), l_Y_1, l_Z_1);
                end;
            else
                v22 = v1(v20, v17._volume);
            end;
        else
            return v21, v17._calculatedMax;
        end;
    end;
    v22 = v22:Min(Vector3.one * v2.MaxRegion);
    v17._calculatedMin = v21;
    v17._calculatedMax = v22;
    return v21, v22;
end;
v4.beginScale = function(v29, v30, v31, _)
    local v33, _, v35 = v29:getBoundingBox(v30, v31);
    v29._originalBoundingBoxCFrame = v33;
    v29._originalBoundingBoxSize = v35;
end;
v4.updateScale = function(v36, v37, v38)
    local v39 = v36._originalBoundingBoxCFrame + v36._originalBoundingBoxCFrame.Rotation * v38;
    local v40 = v36._originalBoundingBoxSize + v37;
    local v41, v42 = v36:getMinMaxSizes();
    if ((((v40.X <= v42.X and v40.Y <= v42.Y) and v40.Z <= v42.Z) and v41.X <= v40.X) and v41.Y <= v40.Y) and v41.Z <= v40.Z then
        v36._draggerContext.updateRegion(v39, v40);
        return v37, v38;
    elseif not (v37.X >= 0 and v37.Y >= 0) or v37.Z < 0 then
        return v37, Vector3.zero;
    else
        return Vector3.zero, Vector3.zero;
    end;
end;
v4.getPriority = function(_)
    return 1;
end;
v4.endScale = function(_)
end;
v4.render = function(_, _, _)
end;
return v4;