local l_CoreGui_0 = game:GetService("CoreGui");
local l_TweenService_0 = game:GetService("TweenService");
local l_CorePackages_0 = game:GetService("CorePackages");
local l_Modules_0 = l_CoreGui_0.RobloxGui.Modules;
local v4 = require(l_Modules_0.LuaApp.mutedError);
local l_DeviceOrientationMode_0 = require(l_CorePackages_0.Workspace.Packages.RobloxAppEnums).DeviceOrientationMode;
local v6 = require(l_Modules_0.AvatarExperience.Common.Utils);
local v7 = require(l_Modules_0.AvatarExperience.Common.Components.RoactNavigation.AvatarScreen);
local v8 = require(l_Modules_0.AvatarExperience.Common.Constants);
local l_PeekViewState_0 = require(l_CorePackages_0.Workspace.Packages.PeekView).PeekViewState;
local l_memoize_0 = require(l_CorePackages_0.Workspace.Packages.AppCommonLib).memoize;
local _ = require(l_Modules_0.AvatarExperience.Common.Types);
local v12 = require(l_Modules_0.AvatarExperience.Flags.GetAXCameraManagerErrorsEnabled);
local v13 = TweenInfo.new(0.5, Enum.EasingStyle.Quad, Enum.EasingDirection.InOut, 0, false, 0);
local v14 = Vector3.new(4, 6, 2);
local v15 = Vector3.new(-3, 2.5, 1.5);
local v16 = CFrame.new(v15, v15 + Vector3.new(1, 0, 0));
local v17 = {
    [l_DeviceOrientationMode_0.Portrait] = {
        cameraCenterScreenPosition = UDim2.new(0, 0, -0.5, 40),
        baseCameraOrigin = Vector3.new(19.24339867, 0, 0.594265997),
        landingPageCameraCenterScreenPosition = UDim2.new(0, 0, -0.4, 40),
        landingPageZoomToFocusHeightRatio = 6.188,
        zoomToFocusHeightRatio = 8.704,
        fullViewZoomToFocusHeightRatio = 4.5,
        defaultVerticalFocusScale = 0.4,
        minZoomRadius = 5,
        maxZoomRadius = 30
    },
    [l_DeviceOrientationMode_0.Landscape] = {
        cameraCenterScreenPosition = UDim2.new(v8.LandscapeNavWidth, 0, 0, 10),
        baseCameraOrigin = Vector3.new(9.24339867, 0, 0.594265997),
        zoomToFocusHeightRatio = 3.84,
        fullViewZoomToFocusHeightRatio = 3.6,
        defaultVerticalFocusScale = 0.5,
        minZoomRadius = 3,
        maxZoomRadius = 20
    }
};
local function _(v18, v19)
    return v18 - UDim2.new(0, 0, 0, 64 - v19);
end;
local function _(v21)
    local v22 = v21.AvatarExperience.AvatarScene.OutfitTryOn.LastToggledItem or {};
    if not v22.isUnequipped then
        return v22.itemSubType == v8.BundleTypeIdStrings.Animations;
    else
        return false;
    end;
end;
local function v31(v24, v25)
    local v26 = #v25;
    if v26 == 0 then
        return v8.DefaultRigPosition;
    else
        local v27 = Vector3.new();
        for _, v29 in v25, nil, nil do
            if not v29.Attachment then
                v27 = v27 + v6.getPartCFrame(v24, v29.Part).Position;
            else
                local v30 = v6.getAttachmentCFrame(v24, v29.Part, v29.Attachment);
                if v30 == nil then
                    v30 = v6.getPartCFrame(v24, v29.Part);
                end;
                v27 = v27 + v30.Position;
            end;
        end;
        return v27 / v26;
    end;
end;
local v39 = l_memoize_0(function(v32)
    local v33 = " equippedAssets=";
    local v34 = {};
    for _, v36 in v32, nil, nil do
        for v37, _ in v36, nil, nil do
            table.insert(v34, v37);
        end;
    end;
    return v33 .. table.concat(v34, ", ");
end);
local function v53(v40, v41, v42)
    local l_v40_BoundingBox_0, v44 = v40:GetBoundingBox();
    if not v6.isBoundingBoxVectorSane(v44) then
        if v12() then
            v4("(Avatar Experience) size = " .. v44.X .. ", " .. v44.Y .. ", " .. v44.Z .. v39(v42));
        end;
        v44 = v14;
    end;
    if not v6.isBoundingBoxCFrameSane(l_v40_BoundingBox_0) then
        if v12() then
            v4("(Avatar Experience) orientation = " .. l_v40_BoundingBox_0.X .. ", " .. l_v40_BoundingBox_0.Y .. ", " .. l_v40_BoundingBox_0.Z .. v39(v42));
        end;
        l_v40_BoundingBox_0 = v16;
    end;
    if not (not v12() or v6.isBoundingBoxCFrameSane(v41)) then
        v4("(Avatar Experience) cframe = " .. v41.X .. ", " .. v41.Y .. ", " .. v41.Z .. v39(v42));
    end;
    local v45 = v44 / 2;
    local v46 = {
        Vector3.new(-v45.X, -v45.Y, -v45.Z),
        Vector3.new(v45.X, -v45.Y, -v45.Z),
        Vector3.new(v45.X, v45.Y, -v45.Z),
        Vector3.new(-v45.X, v45.Y, -v45.Z),
        Vector3.new(-v45.X, -v45.Y, v45.Z),
        Vector3.new(v45.X, -v45.Y, v45.Z),
        Vector3.new(v45.X, v45.Y, v45.Z),
        (Vector3.new(-v45.X, v45.Y, v45.Z))
    };
    local l_huge_0 = math.huge;
    local l_huge_1 = math.huge;
    local v49 = -math.huge;
    local v50 = -math.huge;
    for v51 = 1, #v46 do
        local v52 = v41:PointToObjectSpace(l_v40_BoundingBox_0:PointToWorldSpace(v46[v51]));
        l_huge_0 = math.min(l_huge_0, v52.X);
        l_huge_1 = math.min(l_huge_1, v52.Y);
        v49 = math.max(v49, v52.X);
        v50 = math.max(v50, v52.Y);
        if v12() then
            if v49 < l_huge_0 then
                v4("(Avatar Experience) maxX = " .. v49 .. ", minX = " .. l_huge_0);
            end;
            if v50 < l_huge_1 then
                v4("(Avatar Experience) maxY = " .. v50 .. ", minY = " .. l_huge_1);
            end;
        end;
    end;
    return Vector2.new(v49 - l_huge_0, v50 - l_huge_1);
end;
local function _(v54)
    if v54 ~= v7.AvatarExperienceLandingPage and not v6.isAvatarBackground(v54) then
        return true;
    else
        return false;
    end;
end;
local v56 = {};
v56.__index = v56;
v56.calculateFocusPoint = function(v57)
    local v58 = v57.store:getState();
    local v59 = v57:useCenteredSceneView(v58, v57.avatarRoute);
    local v60 = v6.getCategoryInfoFromState(v58, v57.avatarRoute);
    local l_AvatarType_0 = v58.AvatarExperience.AvatarEditor.Character.AvatarType;
    local l_CurrentCharacter_0 = v58.AvatarExperience.AvatarScene.Character.CurrentCharacter;
    local l_DeviceOrientation_0 = v58.DeviceOrientation;
    local v64 = v8.AvatarTypeFocusGroups[l_AvatarType_0][v60.CameraFocus];
    local _ = nil;
    if not v64 or v59 then
        local v66 = v31(l_CurrentCharacter_0, {
            {
                Part = "HumanoidRootPart"
            }
        });
        local l_Y_0 = (l_CurrentCharacter_0:GetExtentsSize() * v17[l_DeviceOrientation_0].defaultVerticalFocusScale).Y;
        local l_Head_0 = l_CurrentCharacter_0:FindFirstChild("Head");
        if l_Head_0 then
            l_Y_0 = math.min(l_Head_0.Position.Y, l_Y_0);
        end;
        return (Vector3.new(v66.X, l_Y_0, v66.Z));
    else
        return (v31(l_CurrentCharacter_0, v64));
    end;
end;
v56.calculateBaseZoomRadius = function(v69, v70)
    local v71 = v69.store:getState();
    local v72 = v69:useCenteredSceneView(v71, v69.avatarRoute);
    local v73 = nil;
    local l_DeviceOrientation_1 = v71.DeviceOrientation;
    if not v72 then
        local l_name_0 = v69.avatarRoute.current.name;
        local v76 = v6.getCategoryInfoFromState(v71, v69.avatarRoute);
        local l_AvatarType_1 = v71.AvatarExperience.AvatarEditor.Character.AvatarType;
        local v78 = l_name_0 == v7.AvatarExperienceLandingPage;
        local v79 = v8.AvatarTypeFocusGroups[l_AvatarType_1][v76.CameraFocus] or nil;
        local v80 = v71.AvatarExperience.AvatarScene.OutfitTryOn.LastToggledItem or {};
        v73 = if not if not v80.isUnequipped then v80.itemSubType == v8.BundleTypeIdStrings.Animations else false then v76.CameraZoomRadius or 0 else v8.AnimationCategoryCameraZoomRadius;
        if not v79 then
            v73 = v73 + v70.Y * (not not v78 and v17[l_DeviceOrientation_1].landingPageZoomToFocusHeightRatio or v17[l_DeviceOrientation_1].zoomToFocusHeightRatio);
        end;
        return v73;
    else
        return (v71.AvatarExperience.AvatarScene.Character.CurrentCharacter:GetExtentsSize() * 0.5).Y * v17[l_DeviceOrientation_1].fullViewZoomToFocusHeightRatio;
    end;
end;
v56.calculateZoomRadius = function(v81)
    return v81.cachedBaseZoomRadius + v81.zoomOffset;
end;
v56.calculateCameraOrigin = function(v82, v83, v84)
    local v85 = v17[v82.store:getState().DeviceOrientation].baseCameraOrigin - v83;
    return v83 + Vector3.new(v85.x, 0, v85.z).Unit * v84;
end;
v56.calculateHalfFieldsOfView = function(v86)
    local l_ViewportSize_0 = v86.camera.ViewportSize;
    return math.atan((0.4663076581549986 * l_ViewportSize_0.X) / l_ViewportSize_0.Y), 0.4363323129985824;
end;
v56.useCenteredSceneView = function(_, v89, v90)
    return v90.opaque.name == v7.TryOnItem or v6.getIsSceneFullViewFromState(v89, v90);
end;
v56.getPeekViewHeight = function(v91)
    local l_ItemDetailsPeekView_0 = v91.store:getState().AvatarExperience.Common.ItemDetailsPeekView;
    if not (l_ItemDetailsPeekView_0.viewState == l_PeekViewState_0.Brief) or not l_ItemDetailsPeekView_0.briefViewHeight then
        return 0;
    else
        return l_ItemDetailsPeekView_0.briefViewHeight;
    end;
end;
v56.calculateCameraOffsetAngles = function(v93)
    local v94 = v93.store:getState();
    if not v93:useCenteredSceneView(v94, v93.avatarRoute) then
        local l_DeviceOrientation_2 = v94.DeviceOrientation;
        local v96 = (not not (v93.avatarRoute.current.name == v7.AvatarExperienceLandingPage) and v17[l_DeviceOrientation_2].landingPageCameraCenterScreenPosition or v17[l_DeviceOrientation_2].cameraCenterScreenPosition) - UDim2.new(0, 0, 0, 64 - v6.getTopBarHeightAvatarScene(v94));
        local v97, v98 = v93:calculateHalfFieldsOfView();
        local l_ViewportSize_1 = v93.camera.ViewportSize;
        return math.atan(math.tan(v97) * (v96.X.Scale + (2 * v96.X.Offset) / l_ViewportSize_1.X)), (math.atan(math.tan(v98) * (v96.Y.Scale + (2 * v96.Y.Offset) / l_ViewportSize_1.Y)));
    else
        return 0, 0;
    end;
end;
v56.pixelOffsetToPositionOffset = function(v100, v101)
    local v102, v103 = v100:calculateCameraOffsetAngles();
    local v104, v105 = v100:calculateHalfFieldsOfView();
    local l_cachedFocusPoint_0 = v100.cachedFocusPoint;
    local v107 = l_cachedFocusPoint_0 - v100:calculateCameraOrigin(l_cachedFocusPoint_0, (v100:calculateZoomRadius()));
    return (((v101 / v100.camera.ViewportSize) * Vector2.new(math.tan(v104), (math.tan(v105)))) * -(CFrame.new(Vector3.new(), v107) * CFrame.Angles(v103, v102, 0)):VectorToObjectSpace(v107).Z) * 2;
end;
v56.tweenCameraIntoPlace = function(v108, v109, v110, v111)
    local v112, v113 = v108:calculateCameraOffsetAngles();
    local v114 = CFrame.new(Vector3.new(), v110 - v109) * CFrame.Angles(v113, v112, 0);
    local l_panOffset_0 = v108.panOffset;
    local v116 = Vector3.new(0, 1, 0);
    local v117 = CFrame.new(v109 + (v114.LookVector:Cross(v116).Unit * l_panOffset_0.X + v116 * l_panOffset_0.Y)) * v114;
    v108:cancelTween();
    if not v111 then
        local v118 = {
            CFrame = v117
        };
        v108.isTweening = true;
        local v119 = l_TweenService_0:Create(v108.camera, v13, v118);
        v119.Completed:Connect(function()
            v108.isTweening = false;
            v108.tween = nil;
        end);
        v119:Play();
        v108.tween = v119;
        return ;
    else
        v108.camera.CFrame = v117;
        return ;
    end;
end;
v56.boundPanOffset = function(v120)
    local v121 = v120.store:getState();
    local l_CurrentCharacter_1 = v121.AvatarExperience.AvatarScene.Character.CurrentCharacter;
    if l_CurrentCharacter_1 then
        local _, v124 = v120:calculateHalfFieldsOfView();
        local v125, v126 = v120:calculateCameraOffsetAngles();
        local l_cachedFocusPoint_1 = v120.cachedFocusPoint;
        local v128 = v120:calculateCameraOrigin(l_cachedFocusPoint_1, (v120:calculateZoomRadius()));
        local v129 = CFrame.new(v128) * (CFrame.new(Vector3.new(), l_cachedFocusPoint_1 - v128) * CFrame.Angles(v126, v125, 0));
        local v130 = -v120.camera.NearPlaneZ;
        local v131 = math.tan(v124) * v130;
        local v132 = (math.sin(v124 + v126) * math.sqrt(v131 * v131 + v130 * v130) - v128.Y) + 0.01;
        local v133 = v53(l_CurrentCharacter_1, v129, v121.AvatarExperience.AvatarEditor.Character.EquippedAssets) / 2;
        if v12() then
            if v133.X < 0 then
                v4("(Avatar Experience) characterHalf2DBoundingSize.X = " .. v133.X);
            end;
            if v133.Y < 0 then
                v4("(Avatar Experience) characterHalf2DBoundingSize.Y = " .. v133.Y);
            end;
        end;
        local l_panOffset_1 = v120.panOffset;
        v120.panOffset = Vector3.new(math.clamp(v120.panOffset.X, -v133.X, v133.X), math.clamp(v120.panOffset.Y, math.max(v132, -v133.Y), (math.max(v132, v133.Y))), v120.panOffset.Z);
        return l_panOffset_1 ~= v120.panOffset;
    else
        return ;
    end;
end;
v56.calculateZoomOffsetBounds = function(v135)
    local v136 = v17[v135.store:getState().DeviceOrientation];
    local l_cachedBaseZoomRadius_0 = v135.cachedBaseZoomRadius;
    return v136.minZoomRadius - l_cachedBaseZoomRadius_0, v136.maxZoomRadius - l_cachedBaseZoomRadius_0;
end;
v56.boundZoomOffset = function(v138, v139, v140)
    if not (v139 and v140) then
        local v141, v142 = v138:calculateZoomOffsetBounds();
        v139 = v141;
        v140 = v142;
    end;
    local l_zoomOffset_0 = v138.zoomOffset;
    v138.zoomOffset = math.clamp(v138.zoomOffset, v139, v140);
    return l_zoomOffset_0 ~= v138.zoomOffset;
end;
v56.handleCameraChange = function(v144, v145)
    if v144.store:getState().AvatarExperience.AvatarScene.Character.CurrentCharacter then
        local l_cachedFocusPoint_2 = v144.cachedFocusPoint;
        v144:tweenCameraIntoPlace(v144:calculateCameraOrigin(l_cachedFocusPoint_2, (v144:calculateZoomRadius())), l_cachedFocusPoint_2, v145);
        return ;
    else
        return ;
    end;
end;
v56.panByDistance = function(v147, v148)
    v147.panOffset = Vector3.new(v147.panOffset.X + v148.X, v147.panOffset.Y + v148.Y, 0);
    v147:boundPanOffset();
    v147:handleCameraChange(true);
end;
v56.panByPixels = function(v149, v150)
    v149:panByDistance((v149:pixelOffsetToPositionOffset(v150)));
end;
v56.zoomStraight = function(v151, v152)
    v151.zoomOffset = v151.zoomOffset + v152;
    v151:boundZoomOffset();
    v151:handleCameraChange(true);
end;
v56.zoomToPoint = function(v153, v154, v155)
    local v156, v157 = v153:calculateCameraOffsetAngles();
    local l_cachedFocusPoint_3 = v153.cachedFocusPoint;
    local v159 = l_cachedFocusPoint_3 - v153:calculateCameraOrigin(l_cachedFocusPoint_3, (v153:calculateZoomRadius()));
    local v160 = CFrame.new(Vector3.new(), v159) * CFrame.Angles(v157, v156, 0);
    local v161 = v160:VectorToObjectSpace(v159);
    local v162 = (v155 - v153.camera.ViewportSize / 2) * Vector2.new(1, -1);
    local v163 = v153:pixelOffsetToPositionOffset(v162);
    local v164 = Vector3.new(v163.X, v163.Y, v161.Z) - v161;
    local v165, v166 = v153:calculateZoomOffsetBounds();
    v153.zoomOffset = v153.zoomOffset + v154;
    v153:boundZoomOffset(v165, v166);
    local v167 = v160:VectorToObjectSpace(l_cachedFocusPoint_3 - v153:calculateCameraOrigin(l_cachedFocusPoint_3, (v153:calculateZoomRadius())));
    local v168 = v153:pixelOffsetToPositionOffset(v162);
    v153.panOffset = (v153.panOffset + v164) - (Vector3.new(v168.X, v168.Y, v161.Z) - v167);
    v153:boundPanOffset();
    v153:handleCameraChange(true);
end;
v56.update = function(v169, v170, v171, v172, v173)
    local l_name_1 = v172.current.name;
    local l_name_2 = v173.current.name;
    local v176 = l_name_1 ~= v7.AvatarExperienceLandingPage and (not v6.isAvatarBackground(l_name_1) or false);
    local v177 = l_name_2 ~= v7.AvatarExperienceLandingPage and (not v6.isAvatarBackground(l_name_2) or false);
    local v178 = not v176 and v177;
    local v179 = v176 and not v177;
    if not v178 then
        if v179 and #v169.interactionConnections == 0 then
            v169:connectInteractionEvents();
        end;
    elseif #v169.interactionConnections > 0 then
        v169:disconnectInteractionEvents();
    end;
    local l_CurrentCharacter_2 = v170.AvatarExperience.AvatarScene.Character.CurrentCharacter;
    local v181 = v6.getCategoryInfoFromState(v170, v172);
    if l_CurrentCharacter_2 and v181 then
        local v182 = v169:useCenteredSceneView(v170, v172);
        local v183 = v169:useCenteredSceneView(v171, v173);
        local v184 = v6.getCategoryInfoFromState(v171, v173);
        local l_CharacterModelVersion_0 = v170.AvatarExperience.AvatarScene.Character.CharacterModelVersion;
        local l_CharacterModelVersion_1 = v171.AvatarExperience.AvatarScene.Character.CharacterModelVersion;
        local l_TryOnCharacterModelVersion_0 = v170.AvatarExperience.AvatarScene.Character.TryOnCharacterModelVersion;
        local l_TryOnCharacterModelVersion_1 = v171.AvatarExperience.AvatarScene.Character.TryOnCharacterModelVersion;
        local v189 = true;
        if l_CharacterModelVersion_0 == l_CharacterModelVersion_1 then
            v189 = l_TryOnCharacterModelVersion_0 ~= l_TryOnCharacterModelVersion_1;
        end;
        local l_CurrentCharacter_3 = v171.AvatarExperience.AvatarScene.Character.CurrentCharacter;
        local v191 = v6.getTopBarHeightAvatarScene(v170);
        local v192 = v6.getTopBarHeightAvatarScene(v171);
        local v193 = v170.DeviceOrientation ~= v171.DeviceOrientation;
        local v194 = v170.ScreenSize ~= v171.ScreenSize;
        local v195 = not (v173.opaque.name == v7.TryOnItem) and v172.opaque.name == v7.TryOnItem;
        local v196 = v8.AvatarTypeFocusGroups[v170.AvatarExperience.AvatarEditor.Character.AvatarType][v181.CameraFocus];
        local v197 = v171.AvatarExperience.ProfilePictureEditor.ProfilePictureParams.lastSuccessfulPoseEmoteAssetId ~= v170.AvatarExperience.ProfilePictureEditor.ProfilePictureParams.lastSuccessfulPoseEmoteAssetId;
        local v198 = true;
        if v182 == v183 then
            v198 = v181 ~= v184;
        end;
        if v198 then
            v169.panOffset = Vector3.new();
            v169.zoomOffset = 0;
        end;
        local l_v197_0 = v197;
        if not l_v197_0 then
            l_v197_0 = v198;
            if not l_v197_0 then
                l_v197_0 = true;
                if l_CurrentCharacter_2 == l_CurrentCharacter_3 then
                    l_v197_0 = not v196 and v189;
                end;
            end;
        end;
        if l_v197_0 then
            local l_cachedFocusPoint_4 = v169.cachedFocusPoint;
            v169.cachedFocusPoint = v169:calculateFocusPoint();
            local l_cachedBaseZoomRadius_1 = v169.cachedBaseZoomRadius;
            v169.cachedBaseZoomRadius = v169:calculateBaseZoomRadius(v169.cachedFocusPoint);
            if not v198 then
                if v169.panOffset ~= Vector3.new() then
                    v169.panOffset = v169.panOffset - (v169.cachedFocusPoint - l_cachedFocusPoint_4);
                end;
                if v169.zoomOffset ~= 0 then
                    v169.zoomOffset = v169.zoomOffset - (v169.cachedBaseZoomRadius - l_cachedBaseZoomRadius_1);
                end;
            end;
        end;
        if ((l_v197_0 or v193) or v194) or v191 ~= v192 then
            v169:boundPanOffset();
            v169:boundZoomOffset();
            v169:handleCameraChange(v193 or v195);
        end;
        return ;
    else
        return ;
    end;
end;
v56.updateState = function(v202, v203, v204)
    local l_avatarRoute_0 = v202.avatarRoute;
    v202:update(v203, v204, l_avatarRoute_0, l_avatarRoute_0);
end;
v56.updateAvatarRoute = function(v206, v207, v208)
    v206.avatarRoute = v207;
    if v206.started then
        local v209 = v206.store:getState();
        v206:update(v209, v209, v207, v208);
    end;
end;
v56.connectInteractionEvents = function(v210)
    table.insert(v210.interactionConnections, v210.events.panByDistance:Connect(function(...)
        v210:panByDistance(...);
    end));
    table.insert(v210.interactionConnections, v210.events.panByPixels:Connect(function(...)
        v210:panByPixels(...);
    end));
    table.insert(v210.interactionConnections, v210.events.zoomStraight:Connect(function(...)
        v210:zoomStraight(...);
    end));
    table.insert(v210.interactionConnections, v210.events.zoomToPoint:Connect(function(...)
        v210:zoomToPoint(...);
    end));
end;
v56.disconnectInteractionEvents = function(v211)
    for _, v213 in v211.interactionConnections, nil, nil do
        v213:Disconnect();
    end;
    v211.interactionConnections = {};
end;
v56.new = function(v214, v215, v216)
    local v217 = {};
    setmetatable(v217, v56);
    v217.store = v214;
    v217.avatarRoute = v215;
    v217.events = v216;
    v217.updateConnection = nil;
    v217.interactionConnections = {};
    v217.camera = game.Workspace.CurrentCamera;
    v217.isTweening = false;
    v217.panOffset = Vector3.new();
    v217.zoomOffset = 0;
    v217.cachedFocusPoint = nil;
    v217.cachedBaseZoomRadius = nil;
    v217.started = false;
    return v217;
end;
v56.start = function(v218)
    if not v218.started then
        v218.started = true;
        v218.cachedFocusPoint = v218:calculateFocusPoint();
        v218.cachedBaseZoomRadius = v218:calculateBaseZoomRadius(v218.cachedFocusPoint);
        local v219 = v218.store:getState();
        local l_name_3 = v218.avatarRoute.current.name;
        if l_name_3 ~= v7.AvatarExperienceLandingPage and (not v6.isAvatarBackground(l_name_3) or false) then
            v218:connectInteractionEvents();
        end;
        v218.updateConnection = v218.store.changed:connect(function(...)
            v218:updateState(...);
        end);
        v218.camera.CameraType = Enum.CameraType.Scriptable;
        v218.camera.FieldOfView = 50;
        if v219.AvatarExperience.AvatarScene.Character.CurrentCharacter then
            v218.cachedBaseZoomRadius = v218:calculateBaseZoomRadius(v218.cachedFocusPoint);
            v218:handleCameraChange(true);
        end;
        return ;
    else
        return ;
    end;
end;
v56.cancelTween = function(v221)
    if v221.tween then
        v221.tween:Cancel();
        v221.tween = nil;
        v221.isTweening = false;
    end;
end;
v56.stop = function(v222)
    if v222.started then
        v222.started = false;
        v222:cancelTween();
        v222.updateConnection:disconnect();
        v222:disconnectInteractionEvents();
        return ;
    else
        return ;
    end;
end;
v56.onDestroy = function(_)
end;
return v56;


local l_AvatarEditorService_0 = game:GetService("AvatarEditorService");
local l_CoreGui_0 = game:GetService("CoreGui");
local l_CorePackages_0 = game:GetService("CorePackages");
local l_RunService_0 = game:GetService("RunService");
local l_Modules_0 = l_CoreGui_0.RobloxGui.Modules;
local v5 = require(l_CorePackages_0.Cryo);
local v6 = require(l_CorePackages_0.Logging);
local l_ParticleUtility_0 = require(l_CorePackages_0.Thumbnailing).ParticleUtility;
local l_IsVRAppBuild_0 = require(l_CorePackages_0.Workspace.Packages.AppCommonLib).IsVRAppBuild;
local v9 = require(l_Modules_0.LuaApp.mutedError);
local v10 = require(l_CorePackages_0.Workspace.Packages.ArgCheck);
local v11 = require(l_Modules_0.AvatarExperience.Common.Actions.SetCurrentCharacter);
local v12 = require(l_Modules_0.AvatarExperience.Common.Actions.IncrementCharacterVersion);
local v13 = require(l_Modules_0.LuaApp.Actions.SetCurrentToastMessage);
local v14 = require(l_Modules_0.AvatarExperience.AvatarEditor.Actions.IncrementCharacterModelVersion);
local v15 = require(l_Modules_0.AvatarExperience.Catalog.Actions.IncrementTryOnCharacterModelVersion);
local v16 = require(l_Modules_0.AvatarExperience.Common.Actions.FinishedWaitingOnLCUpdate);
local v17 = require(l_Modules_0.AvatarExperience.Common.Managers.AnimationManager);
local v18 = require(l_Modules_0.AvatarExperience.Common.Managers.ToolManager);
local v19 = require(l_Modules_0.AvatarExperience.Common.Managers.CharacterModelPool);
local v20 = require(l_Modules_0.AvatarExperience.Common.Selectors.selectHasAvatarData);
local v21 = require(l_Modules_0.AvatarExperience.AvatarEditor.Constants);
local v22 = require(l_Modules_0.AvatarExperience.Common.Constants);
local v23 = require(l_Modules_0.AvatarExperience.Common.Util.CharacterManagerUtils);
local v24 = require(l_Modules_0.AvatarExperience.Common.Utils);
local v25 = require(l_Modules_0.AvatarExperience.LayeredClothingSort.LayeredClothingSortUtils);
local v26 = require(l_Modules_0.LuaApp.Enum.ToastType);
local v27 = require(l_Modules_0.AvatarExperience.AvatarEditor.Utils);
local _ = require(l_Modules_0.AvatarExperience.Common.Types);
local _ = require(l_Modules_0.AvatarExperience.Common.Reducers.OutfitTryOn);
local _ = require(l_Modules_0.AvatarExperience.Common.AvatarExperienceState);
local v31 = require(l_Modules_0.AvatarExperience.Common.Analytics.reportAvatarEventCounterNoAnalyticsArgument);
local v32 = require(l_Modules_0.AvatarExperience.Common.Constants);
local v33 = require(l_Modules_0.AvatarExperience.Flags.GetFFlagEnableAvatarEditorServiceAPIErrorLogging);
local v34 = require(l_Modules_0.AvatarExperience.Common.Util.IXPUtils);
local v35 = require(l_Modules_0.AvatarExperience.Flags.ColorPickerSliderIXPTest);
local v36 = require(l_Modules_0.AvatarExperience.Flags.GetFFlagFixCharacterManagerValueConversionWarning);
local v37 = require(l_Modules_0.AvatarExperience.Flags.GetFFlagUnequipAccessoriesBeforeLookTryOn);
local l_GetFFlagColorPickerSliderOptimization_0 = require(l_CorePackages_0.Workspace.Packages.SharedFlags).GetFFlagColorPickerSliderOptimization;
local v39 = game:DefineFastFlag("ColorPickerApplyDefaultClothing", false);
local v40 = game:DefineFastFlag("AXColorPickerErrorAnalytics", false);
local v41 = require(l_Modules_0.AvatarExperience.Flags.GetFFlagAXFixOrderFieldUnlayeredItems);
local v42 = settings():GetFVariable("LuaAppsDiagLoadTimeAvatarModel") .. "_" .. v24.getDeviceType();
local v43 = {};
v43.__index = v43;
local l_AssetTypeIdStringToHumanoidDescriptionProp_0 = v22.AssetTypeIdStringToHumanoidDescriptionProp;
local l_HumanoidDescriptionScaleToName_0 = v22.HumanoidDescriptionScaleToName;
local l_AssetTypeIdStrings_0 = v22.AssetTypeIdStrings;
local v47 = require(l_Modules_0.AvatarExperience.Common.Debug.LogTree).logger("ax.loadtime");
local v48 = {
    toastMessage = "Feature.Avatar.Message.FaceNotVisible",
    isLocalized = false,
    toastType = v26.InformationMessage
};
local function _(v49, v50)
    return v25.createAssetIdToOrderMapping(v49.AvatarExperience.LayeredClothingSort.CurrentSort.OrderedList)[v50], v49.AvatarExperience.LayeredClothingSort.CurrentSort.RemovedList[v50];
end;
local function _(v52)
    local v53 = true;
    if v52 ~= "" then
        v53 = v52 == 0;
    end;
    return v53;
end;
local function v60(v55)
    for _, v57 in l_AssetTypeIdStringToHumanoidDescriptionProp_0, nil, nil do
        local v58 = v55[v57];
        local v59 = true;
        if v58 ~= "" then
            v59 = v58 == 0;
        end;
        if not v59 then
            return false;
        end;
    end;
    if #v55:GetAccessories(true) > 0 then
        return false;
    else
        return true;
    end;
end;
v43.new = function(v61, v62, v63, v64, v65, v66)
    local v67 = {};
    setmetatable(v67, v43);
    v67.startAvatarModelLoadTime = tick();
    v67.connections = {};
    v67.store = v61;
    v67.networking = v62;
    v67.analytics = v63;
    if l_GetFFlagColorPickerSliderOptimization_0() then
        v67.bodyColorsChangedEvent = v66;
    end;
    v67.characterModelPool = v19.new(v61, v63, v65);
    v67._currentCharacter = v67.characterModelPool:getCurrentCharacter();
    v67.store:dispatch(v11(v67._currentCharacter));
    v67.store:dispatch(v12());
    v67.characterRoot = Instance.new("Folder");
    v67.characterRoot.Name = "CharacterRoot";
    v67.characterRoot.Parent = game.Workspace;
    v67.needsToEquipBundleTryOn = false;
    v67.initialHumanoidDescriptionApplied = false;
    v67.initialTryOnApplied = false;
    v67.destroyed = false;
    v67.checkBodyColors = true;
    v67.modelInitialized = false;
    v67.firstCallinPPE = true;
    if v37() then
        v67.shouldUnequipAccessoriesBeforeTryOn = false;
    end;
    v67.animationManager = v17.new(v61, v67, v64);
    v67.toolManager = v18.new(v61, v67.animationManager, v67);
    v67.humanoidDescriptionCurrentlyEquipped = Instance.new("HumanoidDescription");
    v67.humanoidDescriptionTryOn = Instance.new("HumanoidDescription");
    v67.lastHumanoidDescriptionApplied = Instance.new("HumanoidDescription");
    if not l_IsVRAppBuild_0() then
        v67:maybeInitializeModel(v67.store:getState());
    end;
    v67.cachedRoduxState = v67.store:getState();
    return v67;
end;
v43.maybeInitializeModel = function(v68, v69)
    if not (v68.modelInitialized or not v20(v69)) then
        v68.modelInitialized = true;
        v68:initializeModel(v69);
    end;
end;
v43.setupAnimations = function(v70, v71, v72)
    v70.characterModelPool:setupAnimations(v71, v72);
end;
v43.initializeModel = function(v73, v74)
    local l_AvatarType_0 = v74.AvatarExperience.AvatarEditor.Character.AvatarType;
    if l_AvatarType_0 == v21.AvatarType.R6 then
        v73:switchAvatarType(l_AvatarType_0);
    end;
    v73._currentCharacter.Parent = v73.characterRoot;
    v73:updateHumanoidDescriptionCurrentlyEquipped(v74);
    v73:applyHumanoidDescription(true);
    v73.toolManager:update(v74);
end;
v43.start = function(v76)
    v76:maybeInitializeModel(v76.store:getState());
    v76._currentCharacter.Parent = v76.characterRoot;
    table.insert(v76.connections, (v76.store.changed:connect(function(v77, v78)
        v76:update(v77, v78);
    end)));
    if l_GetFFlagColorPickerSliderOptimization_0() then
        table.insert(v76.connections, (v76.bodyColorsChangedEvent:Connect(function(v79)
            if v79 then
                local l_bodyPartForSkinColoringIds_0 = v21.BodyPartButtonData[v76.store:getState().AvatarExperience.AvatarEditor.BodyColorPickerSettings.selectedBodyPartIndex].bodyPartForSkinColoringIds;
                local v81 = {};
                for _, v83 in l_bodyPartForSkinColoringIds_0, nil, nil do
                    v81[v83] = v79;
                end;
                if not v39 then
                    v27.setHumanoidDescriptionColorsFromBodyColor3s(v76.humanoidDescriptionCurrentlyEquipped, v81);
                    v76.overrideBodyColor3s = v81;
                    v76.characterModelPool:maybeUpdateCharacter(v76.humanoidDescriptionCurrentlyEquipped);
                    return ;
                else
                    local v84 = v76.humanoidDescriptionCurrentlyEquipped:Clone();
                    v27.setHumanoidDescriptionColorsFromBodyColor3s(v84, v81);
                    local v85 = nil;
                    if not v40 or not v33() then
                        v85 = l_AvatarEditorService_0:CheckApplyDefaultClothing(v84);
                    else
                        local l_status_0, l_result_0 = pcall(function()
                            return l_AvatarEditorService_0:CheckApplyDefaultClothing(v84);
                        end);
                        if not l_status_0 then
                            v31(v32.Counter.AvatarEditorServiceErrors.CheckApplyDefaultClothing);
                            error(l_result_0);
                        else
                            v85 = l_result_0;
                        end;
                    end;
                    v76.overrideBodyColor3s = v81;
                    v76.characterModelPool:maybeUpdateCharacter(v85 or v84);
                    return ;
                end;
            else
                v76.overrideBodyColor3s = nil;
                return ;
            end;
        end)));
    end;
    v76.characterModelPool:start();
    v76.animationManager:start();
    v76.toolManager:start();
    v76:updateHumanoidDescriptionCurrentlyEquipped(v76.store:getState());
    v76:applyHumanoidDescription(true);
    v76.toolManager:update(v76.store:getState());
    v76:update(v76.store:getState(), v76.cachedRoduxState);
end;
v43.update = function(v88, v89, v90)
    local v91 = v88:shouldUpdateHumanoidDescriptionCurrentlyEquipped(v89, v90);
    if v91 then
        v88:updateHumanoidDescriptionCurrentlyEquipped(v89);
    end;
    local v92 = v88:shouldUpdateHumanoidDescriptionTryOnOutfit(v89, v90);
    if v92 then
        v23.updateHumanoidDescriptionUsingOutfitTryOn(v89, v88.humanoidDescriptionTryOn);
    end;
    local l_AvatarType_1 = v89.AvatarExperience.AvatarEditor.Character.AvatarType;
    local v94 = l_AvatarType_1 ~= v90.AvatarExperience.AvatarEditor.Character.AvatarType;
    if v94 then
        v88:switchAvatarType(l_AvatarType_1);
    end;
    if v37() then
        v88.shouldUnequipAccessoriesBeforeTryOn = v89.AvatarExperience.AvatarScene.OutfitTryOn.LookId ~= nil;
    end;
    local v95 = v90.AvatarExperience.ProfilePictureEditor.FinalPageViewMode.finalPageViewMode ~= v89.AvatarExperience.ProfilePictureEditor.FinalPageViewMode.finalPageViewMode;
    if not (not (v91 or v92) and not v94) then
        v88:applyHumanoidDescription(v91, v92);
    end;
    if not (not ((v95 or v91) or v92) and not v94) then
        v88.toolManager:update(v89);
    end;
end;
v43.updateNoFace = function(v96, v97)
    local l_Head_0 = v96._currentCharacter:FindFirstChild("Head");
    if l_Head_0 then
        local v99 = not l_Head_0:FindFirstChildWhichIsA("Decal");
        local v100 = l_AssetTypeIdStringToHumanoidDescriptionProp_0[l_AssetTypeIdStrings_0.Face];
        local v101 = v97[v100];
        local v102 = v96.lastHumanoidDescriptionApplied[v100];
        if (v99 and v101 ~= v102) and v102 ~= 0 then
            v96.store:dispatch(v13(v5.Dictionary.join(v48)));
        end;
        return ;
    else
        warn("No head was found on the character");
        return ;
    end;
end;
v43.shouldUpdateHumanoidDescriptionCurrentlyEquipped = function(_, v104, v105)
    local l_EquippedAssets_0 = v104.AvatarExperience.AvatarEditor.Character.EquippedAssets;
    local l_EquippedAssets_1 = v105.AvatarExperience.AvatarEditor.Character.EquippedAssets;
    local l_AvatarScales_0 = v104.AvatarExperience.AvatarEditor.Character.AvatarScales;
    local l_AvatarScales_1 = v105.AvatarExperience.AvatarEditor.Character.AvatarScales;
    local l_BodyColors_0 = v104.AvatarExperience.AvatarEditor.Character.BodyColors;
    local l_BodyColors_1 = v105.AvatarExperience.AvatarEditor.Character.BodyColors;
    local v112 = nil;
    local v113 = nil;
    if v34.readTestVariable(v35.EnabledForUser) then
        v112 = v104.AvatarExperience.AvatarEditor.Character.BodyColor3s;
        v113 = v105.AvatarExperience.AvatarEditor.Character.BodyColor3s;
    end;
    return ((l_EquippedAssets_0 ~= l_EquippedAssets_1 or l_AvatarScales_0 ~= l_AvatarScales_1) or l_BodyColors_0 ~= l_BodyColors_1) or v112 ~= v113;
end;
v43.updateHumanoidDescriptionCurrentlyEquipped = function(v114, v115)
    local l_EquippedAssets_2 = v115.AvatarExperience.AvatarEditor.Character.EquippedAssets;
    local l_AvatarScales_2 = v115.AvatarExperience.AvatarEditor.Character.AvatarScales;
    if l_EquippedAssets_2 then
        if not v36() then
            for _, v119 in l_AssetTypeIdStringToHumanoidDescriptionProp_0, nil, nil do
                v114.humanoidDescriptionCurrentlyEquipped[v119] = "";
            end;
        else
            v23.resetHumanoidDescriptionProperties(v114.humanoidDescriptionCurrentlyEquipped);
        end;
        v114.humanoidDescriptionCurrentlyEquipped:SetAccessories({}, true);
        local v120 = {};
        local v121 = false;
        local v122 = false;
        if not l_EquippedAssets_2 or l_EquippedAssets_2[l_AssetTypeIdStrings_0.Head] and not v5.isEmpty(l_EquippedAssets_2[l_AssetTypeIdStrings_0.Head]) then
            if not (not l_EquippedAssets_2 or l_EquippedAssets_2[l_AssetTypeIdStrings_0.DynamicHead] and not v5.isEmpty(l_EquippedAssets_2[l_AssetTypeIdStrings_0.DynamicHead])) then
                v122 = true;
            end;
        else
            v121 = true;
        end;
        for v123, v124 in l_EquippedAssets_2, nil, nil do
            local v125 = l_AssetTypeIdStringToHumanoidDescriptionProp_0[v123];
            if v123 ~= l_AssetTypeIdStrings_0.Gear then
                if not v22.AssetTypeIdToAccessoryTypeEnum[v123] then
                    if not (not v125 or v123 == l_AssetTypeIdStrings_0.Head and v121) and (not (v123 == l_AssetTypeIdStrings_0.DynamicHead) or not v122) then
                        v114.humanoidDescriptionCurrentlyEquipped[v125] = table.concat(v5.Dictionary.keys(v124), ",");
                    end;
                else
                    for v126, v127 in v124, nil, nil do
                        table.insert(v120, v24.createHumanoidDescriptionAccessoryInfo(v123, v126, v127));
                    end;
                end;
            end;
        end;
        v114.humanoidDescriptionCurrentlyEquipped:SetAccessories(v120, true);
        for v128, v129 in l_AvatarScales_2, nil, nil do
            v114.humanoidDescriptionCurrentlyEquipped[l_HumanoidDescriptionScaleToName_0[v128]] = v129;
        end;
        v114.checkBodyColors = true;
        if not l_GetFFlagColorPickerSliderOptimization_0() or not v114.overrideBodyColor3s then
            v27.setHumanoidDescriptionColorsFromCharacter(v114.humanoidDescriptionCurrentlyEquipped, v115.AvatarExperience);
            return ;
        else
            v27.setHumanoidDescriptionColorsFromBodyColor3s(v114.humanoidDescriptionCurrentlyEquipped, v114.overrideBodyColor3s);
            return ;
        end;
    else
        v6.warn("CharacterManager: Equipped assets has not been initialized");
        return ;
    end;
end;
v43.shouldUpdateHumanoidDescriptionTryOnOutfit = function(v130, v131, v132)
    if v130.latestAvatarRoute then
        if not v24.routeIsProfilePictureEditor(v130.latestAvatarRoute) then
            v130.firstCallinPPE = true;
        elseif v130.firstCallinPPE then
            v130.firstCallinPPE = false;
        else
            return false;
        end;
    end;
    local v133 = v131.AvatarExperience.AvatarScene.OutfitTryOn.TryOnItems ~= v132.AvatarExperience.AvatarScene.OutfitTryOn.TryOnItems;
    local v134 = v131.AvatarExperience.LayeredClothingSort.CurrentSort ~= v132.AvatarExperience.LayeredClothingSort.CurrentSort;
    if not v130.initialTryOnApplied then
        v133 = true;
        v130.initialTryOnApplied = true;
    end;
    if not v133 and not v134 then
        return false;
    else
        return true;
    end;
end;
v43.updateHumanoidDescriptionTryOnOutfitAsset = function(v135, v136, v137, v138)
    local l_itemSubType_0 = v136.itemSubType;
    if v137 and l_itemSubType_0 ~= l_AssetTypeIdStrings_0.Gear then
        local v140 = l_AssetTypeIdStringToHumanoidDescriptionProp_0[l_itemSubType_0];
        if not v22.AssetTypeIdToAccessoryTypeEnum[l_itemSubType_0] then
            if v140 then
                v135.humanoidDescriptionTryOn[v140] = v137;
            end;
        else
            local v141 = v24.createDefaultHumanoidDescriptionAccessoryInfo(l_itemSubType_0, v137);
            if not (not (v136.order ~= nil) or v41() and not v141.IsLayered) then
                v141.Order = v136.order;
            end;
            local v142 = v135.store:getState();
            local l_OrderedList_0 = v142.AvatarExperience.LayeredClothingSort.CurrentSort.OrderedList;
            local l_RemovedList_0 = v142.AvatarExperience.LayeredClothingSort.CurrentSort.RemovedList;
            local v145 = v25.createAssetIdToOrderMapping(l_OrderedList_0)[v137];
            local v146 = l_RemovedList_0[v137];
            local _ = v145;
            if not v146 then
                table.insert(v138, v141);
                return ;
            end;
        end;
    end;
end;
v43.updateHumanoidDescriptionTryOnOutfitBundle = function(v148, v149, v150, v151)
    for v152, v153 in v149.assets, nil, nil do
        local v154 = l_AssetTypeIdStringToHumanoidDescriptionProp_0[v152];
        local v155 = v154 and v152 ~= l_AssetTypeIdStrings_0.Gear;
        if not v22.AssetTypeIdToAccessoryTypeEnum[v152] then
            if v155 then
                v148.humanoidDescriptionTryOn[v154] = table.concat(v5.Dictionary.keys(v153), ",");
            end;
        else
            for v156, v157 in v153, nil, nil do
                local v158 = v24.createHumanoidDescriptionAccessoryInfo(v152, v156, v157);
                local l_bundleInfo_0 = v150.bundleInfo;
                if not (not (not (not l_bundleInfo_0 or not l_bundleInfo_0[v156]) and l_bundleInfo_0[v156].order ~= nil) or v41() and not v158.IsLayered) then
                    v158.Order = l_bundleInfo_0[v156].order;
                end;
                local v160 = v148.store:getState();
                local l_OrderedList_1 = v160.AvatarExperience.LayeredClothingSort.CurrentSort.OrderedList;
                local l_RemovedList_1 = v160.AvatarExperience.LayeredClothingSort.CurrentSort.RemovedList;
                local v163 = v25.createAssetIdToOrderMapping(l_OrderedList_1)[v156];
                local v164 = l_RemovedList_1[v156];
                local _ = v163;
                if not v164 then
                    table.insert(v151, v158);
                end;
            end;
        end;
    end;
end;
v43.updateHumanoidDescriptionTryOnOutfitBundleNoUserOutfit = function(_, v167, v168, v169, v170)
    local l_AssetInfos_0 = v167.AvatarExperience.Common.AssetInfos;
    local v172 = false;
    if v169.items == nil then
        return ;
    else
        assert(v169.items, "bundleInfo.items is non-nil. Silence type checker.");
        for _, v174 in v169.items, nil, nil do
            local v175 = l_AssetInfos_0[v174.id];
            if not (v175 and v175.assetType) then
                v172 = true;
            end;
        end;
        if not v172 then
            for _, v177 in v169.items, nil, nil do
                local v178 = v24.createDefaultHumanoidDescriptionAccessoryInfo(l_AssetInfos_0[v177.id].assetType, v177.id);
                local l_bundleInfo_1 = v168.bundleInfo;
                if not (not (not (not l_bundleInfo_1 or not l_bundleInfo_1[v177.id]) and l_bundleInfo_1[v177.id].order ~= nil) or v41() and not v178.IsLayered) then
                    v178.Order = l_bundleInfo_1[v177.id].order;
                end;
                local l_id_0 = v177.id;
                local l_OrderedList_2 = v167.AvatarExperience.LayeredClothingSort.CurrentSort.OrderedList;
                local l_RemovedList_2 = v167.AvatarExperience.LayeredClothingSort.CurrentSort.RemovedList;
                local v183 = v25.createAssetIdToOrderMapping(l_OrderedList_2)[l_id_0];
                local v184 = l_RemovedList_2[l_id_0];
                local _ = v183;
                if not v184 then
                    table.insert(v170, v178);
                end;
            end;
        end;
        return ;
    end;
end;
v43.updateHumanoidDescriptionUsingOutfitTryOn = function(v186, v187)
    if not v36() then
        for _, v189 in l_AssetTypeIdStringToHumanoidDescriptionProp_0, nil, nil do
            v186.humanoidDescriptionTryOn[v189] = "";
        end;
    else
        v23.resetHumanoidDescriptionProperties(v186.humanoidDescriptionTryOn);
    end;
    v186.humanoidDescriptionTryOn:SetAccessories({}, true);
    local l_TryOnItems_0 = v187.AvatarExperience.AvatarScene.OutfitTryOn.TryOnItems;
    local v191 = {};
    for _, v193 in (v24.sortOutfitTryOnItemsByRecency(l_TryOnItems_0, false)), nil, nil do
        if v193.selectedInTryOnManager then
            if v193.itemType == v22.ItemType.Asset then
                v186:updateHumanoidDescriptionTryOnOutfitAsset(v193, v193.itemId, v191);
            elseif v193.itemType == v22.ItemType.Bundle then
                local v194 = v24.getBundleInfoFromState(v187, v193.itemId);
                local v195 = v24.getOutfitInfoFromBundleId(v187, v193.itemId);
                if not v195 then
                    if v194 then
                        v186:updateHumanoidDescriptionTryOnOutfitBundleNoUserOutfit(v187, v193, v194, v191);
                    end;
                else
                    v186:updateHumanoidDescriptionTryOnOutfitBundle(v195, v193, v191);
                end;
            end;
        end;
    end;
    v186.humanoidDescriptionTryOn:SetAccessories(v191, true);
end;
v43.isDHBundleTryOn = function(v196)
    return v23.isDHBundleTryOn(v196.store:getState());
end;
v43.setAccessoriesForTryOn = function(v197, v198)
    local l_v198_Accessories_0 = v198:GetAccessories(true);
    local l_Accessories_0 = v197.humanoidDescriptionTryOn:GetAccessories(true);
    local l_RemovedList_3 = v197.store:getState().AvatarExperience.LayeredClothingSort.CurrentSort.RemovedList;
    local v202 = {};
    local v203 = {};
    for _, v205 in l_Accessories_0, nil, nil do
        local v206 = v22.AssetTypeToAssetCategory[v22.AccessoryTypeEnumToAssetTypeId[v205.AccessoryType]];
        v202[v205.AccessoryType] = true;
        if v206 then
            v203[v206] = true;
        end;
    end;
    for _, v208 in l_RemovedList_3, nil, nil do
        local v209 = v22.AssetTypeIdToAccessoryTypeEnum[v208];
        local v210 = v22.AssetTypeToAssetCategory[v208];
        v202[v209] = true;
        if v210 then
            v203[v210] = true;
        end;
    end;
    for _, v212 in l_v198_Accessories_0, nil, nil do
        local v213 = v22.AccessoryTypeEnumToAssetTypeId[v212.AccessoryType];
        local v214 = not v202[v212.AccessoryType];
        local v215 = v22.AssetTypeToAssetCategory[v213];
        if v215 then
            v214 = not v203[v215];
        end;
        if not (not v197:isDHBundleTryOn() or not v22.DynamicHeadAssetTypes[v213]) then
            v214 = false;
        end;
        if v214 then
            table.insert(l_Accessories_0, v212);
        end;
    end;
    v198:SetAccessories(l_Accessories_0, true);
end;
v43.getTryOnsBundleOutfitInfo = function(v216)
    local v217 = v216.store:getState();
    for v218, v219 in v217.AvatarExperience.AvatarScene.OutfitTryOn.TryOnItems, nil, nil do
        if v219.itemType == v22.ItemType.Bundle and v219.itemSubType == v22.BundleTypeIdStrings.BodyParts then
            local v220 = v24.getOutfitInfoFromBundleId(v217, v218);
            if v220 then
                return v220;
            end;
        end;
    end;
    return nil;
end;
v43.combineOutfitTryOnAndEquippedHumanoidDescriptions = function(v221)
    local v222 = nil;
    local v223 = v221:getTryOnsBundleOutfitInfo();
    v222 = v221.humanoidDescriptionCurrentlyEquipped:Clone();
    if not (not v37() or not v221.shouldUnequipAccessoriesBeforeTryOn) then
        v222:SetAccessories({}, true);
        v222.GraphicTShirt = 0;
        v222.Shirt = 0;
        v222.Pants = 0;
    end;
    for v224, v225 in l_AssetTypeIdStringToHumanoidDescriptionProp_0, nil, nil do
        if not v22.AssetTypeIdToAccessoryTypeEnum[v224] then
            local v226 = v221.humanoidDescriptionTryOn[v225];
            local v227 = true;
            if v226 ~= "" then
                v227 = v226 == 0;
            end;
            if not v227 then
                v222[v225] = v221.humanoidDescriptionTryOn[v225];
            end;
        end;
    end;
    v221:setAccessoriesForTryOn(v222);
    local v228 = nil;
    if not v33() then
        v228 = l_AvatarEditorService_0:CheckApplyDefaultClothing(v222);
    else
        local l_status_1, l_result_1 = pcall(function()
            return l_AvatarEditorService_0:CheckApplyDefaultClothing(v222);
        end);
        if not l_status_1 then
            v31(v32.Counter.AvatarEditorServiceErrors.CheckApplyDefaultClothing);
            error(l_result_1);
        else
            v228 = l_result_1;
        end;
    end;
    v222 = v228 or v222;
    if v223 then
        for v231, v232 in v223.scales, nil, nil do
            v222[l_HumanoidDescriptionScaleToName_0[v231]] = v232;
        end;
        if not v34.readTestVariable(v35.EnabledForUser) then
            v27.setHumanoidDescriptionColorsFromBodyColors(v222, v223.bodyColors);
        else
            v27.setHumanoidDescriptionColorsFromBodyColor3s(v222, v223.bodyColor3s);
        end;
    end;
    return v222;
end;
v43.finishApplyDescription = function(v233, v234, v235, v236, v237)
    if not (not v233.initialHumanoidDescriptionApplied or v236) then
        v233:updateNoFace(v237);
    end;
    if not v233.initialHumanoidDescriptionApplied then
        local v238 = (tick() - v233.startAvatarModelLoadTime) * 1000;
        v47:info("Avatar model load time: {} ms", v238);
        v233.analytics.Diag:reportStats(v42, v238);
    end;
    if v233.characterModelPool:isR15() then
        v233:adjustHeightToStandOnPlatform(v233._currentCharacter);
    end;
    if not v234 then
        if v235 then
            v233.store:dispatch(v15());
        end;
    else
        v233.store:dispatch(v14());
    end;
    v233.initialHumanoidDescriptionApplied = true;
    if v233._currentCharacter then
        local l_BoundingBox_0, v240 = v233._currentCharacter:GetBoundingBox();
        if not (v24.isBoundingBoxVectorSane(v240) and v24.isBoundingBoxCFrameSane(l_BoundingBox_0)) then
            local v241 = v24.calculateNewAssetIdsWithGeometry(v237, v233.lastHumanoidDescriptionApplied);
            if #v241 > 0 then
                v9("(Avatar Experience) bad bounding box on adding assetIds: " .. table.concat(v241, ","));
            end;
        end;
    end;
end;
v43.getCurrentCharacter = function(v242)
    return v242._currentCharacter;
end;
v43.applyHumanoidDescription = function(v243, v244, v245)
    v10.assert(v243.modelInitialized, "applyHumanoidDescription called before initializeModel");
    task.spawn(function()
        if not v243.destroyed and v243._currentCharacter:IsDescendantOf(game) then
            local l_lastHumanoidDescriptionApplied_0 = v243.lastHumanoidDescriptionApplied;
            local v247 = v243:combineOutfitTryOnAndEquippedHumanoidDescriptions();
            v243.checkBodyColors = false;
            local v248 = v245 and v60(v243.humanoidDescriptionTryOn);
            v243.characterModelPool:maybeUpdateCharacter(v247):andThen(function(v249, v250)
                v243.store:dispatch(v12());
                if v249 ~= v243._currentCharacter then
                    v243.toolManager:unequipTool();
                    v243._currentCharacter = v249;
                    v243.store:dispatch(v11(v243._currentCharacter));
                    v243._currentCharacter.Parent = v243.characterRoot;
                    v243.toolManager:checkAndEquipTool();
                end;
                if not (v250 or not v243.store:getState().AvatarExperience.AvatarScene.Character.WaitingOnLayeredClothingUpdates) then
                    v243.store:dispatch(v16());
                end;
                v243.lastHumanoidDescriptionApplied = v247;
                v243:finishApplyDescription(v244, v245, v248, l_lastHumanoidDescriptionApplied_0);
            end);
            return ;
        else
            return ;
        end;
    end);
end;
v43.switchAvatarType = function(v251, v252)
    v251._currentCharacter = v251.characterModelPool:switchAvatarType(v252);
    v251.store:dispatch(v11(v251._currentCharacter));
    v251.store:dispatch(v12());
    v251._currentCharacter.Parent = v251.characterRoot;
    v251.toolManager:notifySwitchedAvatarType();
end;
v43.adjustHeightToStandOnPlatform = function(_, v254)
    local l_HumanoidRootPart_0 = v254.HumanoidRootPart;
    local v256 = l_HumanoidRootPart_0.Size.y * 0.5 + v254.Humanoid.HipHeight;
    local v257, _, v259, v260, v261, v262, v263, v264, v265, v266, v267, v268 = l_HumanoidRootPart_0.CFrame:components();
    l_HumanoidRootPart_0.CFrame = CFrame.new(v257, v256, v259, v260, v261, v262, v263, v264, v265, v266, v267, v268);
end;
v43.stop = function(v269)
    v23.updateHumanoidDescriptionUsingOutfitTryOn(v269.store:getState(), v269.humanoidDescriptionTryOn);
    v269:applyHumanoidDescription(true);
    for _, v271 in v269.connections, nil, nil do
        v271:disconnect();
    end;
    v269.connections = {};
    v269.characterModelPool:stop();
    v269.animationManager:stop();
    v269.toolManager:stop();
    v269.initialTryOnApplied = false;
    v269.cachedRoduxState = v269.store:getState();
end;
v43.onDestroy = function(v272)
    v272.humanoidDescriptionCurrentlyEquipped:Destroy();
    v272.humanoidDescriptionTryOn:Destroy();
    v272.lastHumanoidDescriptionApplied:Destroy();
    v272.characterRoot:Destroy();
    v272.destroyed = true;
    v272.animationManager:onDestroy();
    v272.toolManager:onDestroy();
    v272.characterModelPool:onDestroy();
    v272.store:dispatch(v11(nil));
    v272.store:dispatch(v12());
end;
v43.updateAvatarRoute = function(v273, v274, v275)
    v273.animationManager:updateAvatarRoute(v274, v275);
    v273.toolManager:updateAvatarRoute(v274, v275);
    v273.latestAvatarRoute = v274;
    local v276 = v24.routeIsPPEStaticImagePage(v274);
    local v277 = v24.routeIsPPEStaticImagePage(v275);
    if not v276 or v277 then
        if not (not v277 or v276) then
            v273:stopWatchingCharacter();
            v273:unfreezeParticles();
        end;
        return ;
    else
        v273:freezeParticles();
        v273:watchCharacterToFreezeNewParticles();
        return ;
    end;
end;
v43.watchCharacterToFreezeNewParticles = function(v278)
    local l_CurrentCharacter_0 = v278.store:getState().AvatarExperience.AvatarScene.Character.CurrentCharacter;
    if l_CurrentCharacter_0 then
        v278.freezeParticlesCharacterConnection = l_CurrentCharacter_0.DescendantAdded:Connect(function(v280)
            if v280:IsA("Tool") then
                l_RunService_0.Heartbeat:Wait();
                v278:recursiveFreezeParticles(v280);
                l_ParticleUtility_0.FastForwardParticles(v280);
            end;
        end);
    end;
end;
v43.stopWatchingCharacter = function(v281)
    if v281.freezeParticlesCharacterConnection then
        v281.freezeParticlesCharacterConnection:Disconnect();
        v281.freezeParticlesCharacterConnection = nil;
    end;
end;
v43.instanceIsAParticleEffect = function(_, v283)
    return ((v283:IsA("ParticleEmitter") or v283:IsA("Fire")) or v283:IsA("Smoke")) or v283:IsA("Sparkles");
end;
v43.recursiveFreezeParticles = function(v284, v285)
    if l_ParticleUtility_0.InstanceIsAParticleEffect(v285) then
        v284.frozenParticlesToTimeScale[v285] = v285.TimeScale;
        v285.TimeScale = 0;
    end;
    for _, v287 in (v285:GetChildren()), nil, nil do
        v284:recursiveFreezeParticles(v287);
    end;
end;
v43.freezeParticles = function(v288)
    v288.frozenParticlesToTimeScale = {};
    local l_CurrentCharacter_1 = v288.store:getState().AvatarExperience.AvatarScene.Character.CurrentCharacter;
    if l_CurrentCharacter_1 then
        v288:recursiveFreezeParticles(l_CurrentCharacter_1);
    end;
end;
v43.unfreezeParticles = function(v290)
    if v290.frozenParticlesToTimeScale then
        for v291, v292 in v290.frozenParticlesToTimeScale, nil, nil do
            v291.TimeScale = v292;
        end;
        v290.frozenParticlesToTimeScale = {};
    end;
end;
return v43;


local l_Players_0 = game:GetService("Players");
local l_ReplicatedStorage_0 = game:GetService("ReplicatedStorage");
local l_CoreGui_0 = game:GetService("CoreGui");
local l_CorePackages_0 = game:GetService("CorePackages");
local l_IsVRAppBuild_0 = require(l_CorePackages_0.Workspace.Packages.AppCommonLib).IsVRAppBuild;
local v5 = require(l_CorePackages_0.Packages.Promise);
local l_Modules_0 = l_CoreGui_0.RobloxGui.Modules;
local v7 = require(l_Modules_0.AvatarExperience.AvatarEditor.Constants);
local v8 = require(l_Modules_0.AvatarExperience.Common.Analytics.reportAvatarStat);
local v9 = require(l_Modules_0.AvatarExperience.Common.Actions.StartedApplyingLayeredClothing);
local v10 = require(l_Modules_0.AvatarExperience.Common.Actions.FinishedApplyingLayeredClothing);
local v11 = CFrame.new(-3.3, 3, 0.2, 0, 0, -1, 0, 1, 0, 1, 0, 0);
local v12 = CFrame.new(0, 150, 0, 0, 0, -1, 0, 1, 0, 1, 0, 0);
if l_IsVRAppBuild_0() then
    v11 = CFrame.lookAt(Vector3.new(0, 0, -6), (Vector3.new(0, 0, 0)));
    v12 = CFrame.lookAt(Vector3.new(6, 1, 100), (Vector3.new(0, 1, 100)));
end;
local v13 = game:DefineFastInt("AXClusterCompositionTimeoutMs", 3000);
local v14 = {};
v14.__index = v14;
local function v17()
    local l_l_Players_0_HumanoidModelFromDescription_0 = l_Players_0:CreateHumanoidModelFromDescription(Instance.new("HumanoidDescription"), Enum.HumanoidRigType.R6);
    local l_l_Players_0_HumanoidModelFromDescription_1 = l_Players_0:CreateHumanoidModelFromDescription(Instance.new("HumanoidDescription"), Enum.HumanoidRigType.R15);
    l_l_Players_0_HumanoidModelFromDescription_0.Humanoid.DisplayDistanceType = Enum.HumanoidDisplayDistanceType.None;
    l_l_Players_0_HumanoidModelFromDescription_1.Humanoid.DisplayDistanceType = Enum.HumanoidDisplayDistanceType.None;
    l_l_Players_0_HumanoidModelFromDescription_0.HumanoidRootPart.Anchored = true;
    l_l_Players_0_HumanoidModelFromDescription_1.HumanoidRootPart.Anchored = true;
    l_l_Players_0_HumanoidModelFromDescription_0.Parent = l_ReplicatedStorage_0;
    l_l_Players_0_HumanoidModelFromDescription_1.Parent = l_ReplicatedStorage_0;
    l_l_Players_0_HumanoidModelFromDescription_0.HumanoidRootPart.CFrame = v12;
    l_l_Players_0_HumanoidModelFromDescription_1:SetPrimaryPartCFrame(v12);
    return l_l_Players_0_HumanoidModelFromDescription_0, l_l_Players_0_HumanoidModelFromDescription_1;
end;
v14.new = function(v18, v19, v20, v21)
    local v22 = {};
    setmetatable(v22, v14);
    v22.store = v18;
    v22.analytics = v19;
    v22.characterMover = v20;
    v22.mockApplyDescription = v21;
    local v23, v24 = v17();
    v22.r6 = v23;
    v22.r6IsOffscreen = true;
    v22.r15current = v24;
    v22.r15offScreen = v24:Clone();
    v22.r15offScreen.Parent = l_ReplicatedStorage_0;
    v22.avatarType = v7.AvatarType.R15;
    v22.inProgressPromise = nil;
    v22.waitingPromise = nil;
    v22.r6Promise = nil;
    v22.destroyed = false;
    return v22;
end;
v14.setupAnimations = function(v25, v26, v27)
    v26.Parent = v25.r6;
    v27.Parent = v25.r15current;
    v27.Archivable = true;
    local v28 = v27:Clone();
    v28.Parent = v25.r15offScreen;
    v28.Archivable = false;
    v27.Archivable = false;
end;
v14.getCurrentCharacter = function(v29)
    if v29.avatarType == v7.AvatarType.R15 then
        return v29.r15current;
    else
        return v29.r6;
    end;
end;
v14.isR15 = function(v30)
    return v30.avatarType == v7.AvatarType.R15;
end;
v14.syncRotation = function(_, v32, v33)
    local _, _, _, v37, v38, v39, v40, v41, v42, v43, v44, v45 = v32.HumanoidRootPart.CFrame:components();
    local l_p_0 = v33.HumanoidRootPart.CFrame.p;
    v33.HumanoidRootPart.CFrame = CFrame.new(l_p_0.X, l_p_0.Y, l_p_0.Z, v37, v38, v39, v40, v41, v42, v43, v44, v45);
end;
local function v56(v47, v48)
    local l_v47_Accessories_0 = v47:GetAccessories(false);
    local l_v48_Accessories_0 = v48:GetAccessories(false);
    if #l_v48_Accessories_0 == 0 then
        return false;
    elseif #l_v47_Accessories_0 ~= #l_v48_Accessories_0 then
        return true;
    else
        local v51 = {};
        for _, v53 in l_v47_Accessories_0, nil, nil do
            v51[v53.AssetId] = true;
        end;
        for _, v55 in l_v48_Accessories_0, nil, nil do
            if not v51[v55.AssetId] then
                return true;
            end;
        end;
        return false;
    end;
end;
local function _(v57)
    return v57:FindFirstChildWhichIsA("WrapLayer", true) ~= nil;
end;
v14._doUpdateR6 = function(v59, v60)
    return v5.new(function(v61, _)
        if not v59.mockApplyDescription then
            v59.r6.Humanoid:ApplyDescription(v60);
        else
            v59.mockApplyDescription(v59.r6, v60);
        end;
        if v59.r6IsOffscreen then
            v59.r6.HumanoidRootPart.CFrame = v11;
            v59.r6IsOffscreen = false;
        end;
        v61(v59:getCurrentCharacter(), v59:_stillWaitingOnLCUpdates());
    end);
end;
v14._doSimpleUpdateR15 = function(v63, v64)
    return v5.new(function(v65, _)
        local v67 = tick();
        if not v63.mockApplyDescription then
            v63.r15current.Humanoid:ApplyDescription(v64);
        else
            v63.mockApplyDescription(v63.r15current, v64);
        end;
        v8(v63.analytics, "AXCharacterStandardUpdateTimer", (tick() - v67) * 1000);
        v65(v63.r15current, v63:_stillWaitingOnLCUpdates());
    end);
end;
v14._updateOffscreenR15 = function(v68, v69)
    v68.store:dispatch(v9());
    return v5.new(function(v70, _)
        v68.r15offScreen.HumanoidRootPart.CFrame = v12;
        v68.r15offScreen.Parent = workspace;
        if not v68.mockApplyDescription then
            v68.r15offScreen.Humanoid:ApplyDescription(v69);
        else
            v68.mockApplyDescription(v68.r15offScreen, v69);
        end;
        v70(v68.r15offScreen);
    end);
end;
local function v73(v72)
    if not (v72:FindFirstChildWhichIsA("WrapLayer", true) ~= nil) then
        return v5.resolve(false);
    else
        return v5.race({
            v5.fromEvent(v72.Humanoid.ClusterCompositionFinished),
            v5.delay(v13 * 0.001)
        }):andThen(function()
            return true;
        end);
    end;
end;
v14._stillWaitingOnLCUpdates = function(v74)
    if v74.avatarType == v7.AvatarType.R6 then
        return false;
    elseif (not (v74.avatarType == v7.AvatarType.R15) or not v74.queuedHumanoidDescription) or not v56(v74.r15current.Humanoid.HumanoidDescription, v74.queuedHumanoidDescription) then
        return false;
    else
        return true;
    end;
end;
v14._completeUpdate = function(v75, v76, v77)
    v75.r15offScreen.HumanoidRootPart.CFrame = v75.r15current.HumanoidRootPart.CFrame;
    v75.characterMover:cancelCurrentTween();
    v75.r15current.HumanoidRootPart.CFrame = v12;
    v75.r15current.Parent = l_ReplicatedStorage_0;
    local l_r15current_0 = v75.r15current;
    local l_r15offScreen_0 = v75.r15offScreen;
    v75.r15offScreen = l_r15current_0;
    v75.r15current = l_r15offScreen_0;
    v75.store:dispatch(v10());
    l_r15current_0 = (tick() - v76) * 1000;
    if not v77 then
        v8(v75.analytics, "AXCharacterStandardUpdateTimer", l_r15current_0);
    else
        v8(v75.analytics, "AXCharacterLayeredUpdateTimer", l_r15current_0);
    end;
    return v75.r15current, v75:_stillWaitingOnLCUpdates();
end;
v14._doUpdateR15 = function(v80, v81)
    if v56(v80.r15current.Humanoid:GetAppliedDescription(), v81) then
        local v82 = tick();
        v80.inProgressPromise = v80:_updateOffscreenR15(v81):andThen(v73):andThen(function(v83)
            return v80:_completeUpdate(v82, v83);
        end);
        return v80.inProgressPromise;
    else
        return v80:_doSimpleUpdateR15(v81);
    end;
end;
v14.maybeUpdateCharacter = function(v84, v85)
    if v84.avatarType == v7.AvatarType.R6 then
        v84.r6Promise = v84:_doUpdateR6(v85);
        return v84.r6Promise;
    elseif v84.inProgressPromise and v84.inProgressPromise:getStatus() == v5.Status.Started then
        if v84.waitingPromise then
            v84.waitingPromise:cancel();
        end;
        v84.queuedHumanoidDescription = v85;
        v84.waitingPromise = v84.inProgressPromise:andThen(function()
            v84.inProgressPromise = v84.waitingPromise;
            v84.waitingPromise = nil;
            v84.queuedHumanoidDescription = nil;
            return v84:_doUpdateR15(v85);
        end);
        return v84.waitingPromise;
    else
        return v84:_doUpdateR15(v85);
    end;
end;
v14.switchAvatarType = function(v86, v87)
    if v87 == v86.avatarType then
        return v86:getCurrentCharacter();
    else
        v86:_cancelPromises();
        v86.avatarType = v87;
        local v88 = nil;
        local v89 = nil;
        if v87 == v7.AvatarType.R6 then
            v88 = v86.r6;
            v89 = v86.r15current;
        else
            v88 = v86.r15current;
            v89 = v86.r6;
        end;
        v89.Parent = l_ReplicatedStorage_0;
        v89.Humanoid:UnequipTools();
        v86:syncRotation(v89, v88);
        return v88;
    end;
end;
v14.start = function(v90)
    if l_IsVRAppBuild_0() then
        v90.r15current.HumanoidRootPart.CFrame = v11;
    end;
end;
local function _(v91)
    if v91 then
        v91:cancel();
    end;
end;
v14._cancelPromises = function(v93)
    local l_inProgressPromise_0 = v93.inProgressPromise;
    if l_inProgressPromise_0 then
        l_inProgressPromise_0:cancel();
    end;
    l_inProgressPromise_0 = v93.waitingPromise;
    if l_inProgressPromise_0 then
        l_inProgressPromise_0:cancel();
    end;
    l_inProgressPromise_0 = v93.r6Promise;
    if l_inProgressPromise_0 then
        l_inProgressPromise_0:cancel();
    end;
    v93.inProgressPromise = nil;
    v93.waitingPromise = nil;
    v93.r6Promise = nil;
end;
v14.stop = function(v95)
    v95.r6.Parent = l_ReplicatedStorage_0;
    v95.r15current.Parent = l_ReplicatedStorage_0;
    v95.r15offScreen.Parent = l_ReplicatedStorage_0;
    v95:_cancelPromises();
end;
v14.onDestroy = function(v96)
    v96:_cancelPromises();
    v96.r6:Destroy();
    v96.r15current:Destroy();
    v96.r15offScreen:Destroy();
end;
return v14;


local l_CoreGui_0 = game:GetService("CoreGui");
local l_RunService_0 = game:GetService("RunService");
local l_TweenService_0 = game:GetService("TweenService");
local l_Modules_0 = l_CoreGui_0.RobloxGui.Modules;
local v4 = require(l_Modules_0.AvatarExperience.Common.Utils);
local v5 = require(l_Modules_0.AvatarExperience.ProfilePictureEditor.Managers.PPECameraManager);
local v6 = require(l_Modules_0.AvatarExperience.ProfilePictureEditor.Utils);
local v7 = require(l_Modules_0.AvatarExperience.Common.Managers.CameraManager);
local _ = require(l_Modules_0.AvatarExperience.Common.Types);
local v9 = TweenInfo.new(0.5, Enum.EasingStyle.Cubic, Enum.EasingDirection.Out, 0, false, 0);
local function _(v10, v11)
    if math.abs(v10) < math.abs(v11) then
        return v10;
    else
        return v11;
    end;
end;
local function _(v13)
    return (v13 + 3.141592653589793) % 6.283185307179586 - 3.141592653589793;
end;
local v15 = {};
v15.__index = v15;
v15.resetRotation = function(v16, v17)
    if v16.store:getState().AvatarExperience.AvatarScene.Character.CurrentCharacter then
        local v18 = true;
        if v17 then
            v18 = false;
        end;
        v16:rotateByRadians(-v16.angleOffset.Y, 0, v18);
        return ;
    else
        return ;
    end;
end;
v15.cancelCurrentTween = function(v19)
    if v19.currentTween then
        v19.currentTween:Cancel();
        v19.currentTween = nil;
    end;
end;
v15.rotateByRadians = function(v20, v21, v22, v23)
    v21 = v21 or 0;
    v22 = v22 or 0;
    local l_CurrentCharacter_0 = v20.store:getState().AvatarExperience.AvatarScene.Character.CurrentCharacter;
    if l_CurrentCharacter_0 then
        local l_HumanoidRootPart_0 = l_CurrentCharacter_0.HumanoidRootPart;
        if not v20.initialAngles then
            local v26, v27, _ = l_HumanoidRootPart_0.CFrame:ToEulerAnglesYXZ();
            v20.initialAngles = Vector2.new(v26, v27);
        end;
        v20.angleOffset = Vector2.new((v20.angleOffset.X + v22) % 6.283185307179586, (v20.angleOffset.Y + v21) % 6.283185307179586);
        local v29 = CFrame.new(l_HumanoidRootPart_0.CFrame.p) * CFrame.fromEulerAnglesYXZ(v20.initialAngles.X + v20.angleOffset.X, v20.initialAngles.Y + v20.angleOffset.Y, 0);
        if not v23 then
            l_HumanoidRootPart_0.CFrame = v29;
        else
            v20.yAngularVelocity = 0;
            v20:cancelCurrentTween();
            v20.currentTween = l_TweenService_0:Create(l_HumanoidRootPart_0, v9, {
                CFrame = v29
            });
            v20.currentTween:Play();
        end;
        if not ((not v20.cameraManager or not v20.cameraManager:boundPanOffset()) or v20.cameraManager.isTweening) then
            v20.cameraManager:handleCameraChange(true);
        end;
        return ;
    else
        return ;
    end;
end;
v15.rotateByPixels = function(v30, v31)
    if v30.cameraManager then
        v30:rotateByRadians(v30.cameraManager:pixelOffsetToPositionOffset(Vector2.new(v31, 0)).X * 0.436);
    end;
end;
v15.setAngularVelocityByPixels = function(v32, v33)
    if v32.cameraManager then
        v32.yAngularVelocity = math.clamp(v32.cameraManager:pixelOffsetToPositionOffset(Vector2.new(v33, 0)).X * 0.436, -14.835298641951802, 14.835298641951802);
        if not (not (v32.yAngularVelocity ~= 0) or v32.renderSteppedConnection) then
            v32.renderSteppedConnection = l_RunService_0.RenderStepped:Connect(function(...)
                v32:onRenderStepped(...);
            end);
        end;
    end;
end;
v15.onRenderStepped = function(v34, v35)
    local v36 = v35 * v34.yAngularVelocity;
    v34.yAngularVelocity = v34.yAngularVelocity * math.pow(0.010000000000000009, v35);
    if math.abs(v34.yAngularVelocity) < 1.0E-4 then
        v34.yAngularVelocity = 0;
    end;
    local v37 = (((not v34.store:getState().AvatarExperience.AvatarScene.Character.PlayingSwimAnimation and 0 or -1.0471975511965976) - v34.angleOffset.X) + 3.141592653589793) % 6.283185307179586 - 3.141592653589793;
    local v38 = (2.0943951023931953 * v35) * math.sign(v37);
    local v39 = if math.abs(v37) < math.abs(v38) then v37 else v38;
    if not (v39 == 0) or v36 ~= 0 then
        v34:rotateByRadians(v36, v39);
    end;
    if v34.yAngularVelocity == 0 and math.abs(v37) < 1.0E-4 then
        v34.renderSteppedConnection:Disconnect();
        v34.renderSteppedConnection = nil;
    end;
end;
v15.update = function(v40, v41, v42, v43, v44)
    if not (not (v41.AvatarExperience.AvatarScene.Character.PlayingSwimAnimation ~= v42.AvatarExperience.AvatarScene.Character.PlayingSwimAnimation) or v40.renderSteppedConnection) then
        v40.renderSteppedConnection = l_RunService_0.RenderStepped:Connect(function(...)
            v40:onRenderStepped(...);
        end);
    end;
    if v4.getCategoryInfoFromState(v41, v43) ~= v4.getCategoryInfoFromState(v42, v44) then
        v40:resetRotation();
    end;
end;
v15.updateState = function(v45, v46, v47)
    local l_avatarRoute_0 = v45.avatarRoute;
    v45:update(v46, v47, l_avatarRoute_0, l_avatarRoute_0);
end;
v15.updateAvatarRoute = function(v49, v50, v51)
    if not (not v49.ppeCameraManager and not v49.cameraManager) then
        v49.ppeCameraManager:updateAvatarRoute(v50, v51);
        v49.cameraManager:updateAvatarRoute(v50, v51);
        local v52 = v6.isPPEScreenUsingPeekabooWidget(v50.opaque.name);
        local v53 = v6.isPPEScreenUsingPeekabooWidget(v51.opaque.name);
        if not v52 or v53 then
            if not (v52 or not v53) then
                v49.cameraManager:start();
                v49.ppeCameraManager:stop();
            end;
        else
            v49:resetRotation(true);
            v49.cameraManager:stop();
            v49.ppeCameraManager:start();
        end;
    end;
    v49.avatarRoute = v50;
    local v54 = v49.store:getState();
    v49:update(v54, v54, v50, v51);
end;
v15.onPPEPoseChanged = function(v55)
    if v55.ppeCameraManager then
        v55.ppeCameraManager:onPPEPoseChanged();
    end;
end;
v15.new = function(v56, v57, v58, v59, v60)
    local v61 = {};
    setmetatable(v61, v15);
    v61.cameraManager = nil;
    v61.ppeCameraManager = nil;
    if v60 then
        v61.cameraManager = v7.new(v56, v58, v59);
        v61.ppeCameraManager = v5.new(v56, v58);
    end;
    v61.store = v56;
    v61.avatarExperienceAnalytics = v57;
    v61.avatarRoute = v58;
    v61.events = v59;
    v61.bulkConnections = {};
    v61.camera = game.Workspace.CurrentCamera;
    v61.initialAngles = nil;
    v61.angleOffset = Vector2.new();
    v61.yAngularVelocity = 0;
    v61.currentTween = nil;
    return v61;
end;
v15.shouldUsePPECameraManager = function(v62)
    return v4.routeIsPPEStaticImagePage(v62.avatarRoute);
end;
v15.start = function(v63)
    if not v63:shouldUsePPECameraManager() then
        if v63.cameraManager then
            v63.cameraManager:start();
        end;
    elseif v63.ppeCameraManager then
        v63.ppeCameraManager:start();
    end;
    table.insert(v63.bulkConnections, v63.store.changed:connect(function(...)
        v63:updateState(...);
    end));
    table.insert(v63.bulkConnections, v63.events.rotateByRadians:Connect(function(...)
        v63:rotateByRadians(...);
    end));
    table.insert(v63.bulkConnections, v63.events.rotateByPixels:Connect(function(...)
        v63:rotateByPixels(...);
    end));
    table.insert(v63.bulkConnections, v63.events.setAngularVelocityByPixels:Connect(function(...)
        v63:setAngularVelocityByPixels(...);
    end));
    v63:resetRotation();
end;
v15.stop = function(v64)
    for _, v66 in v64.bulkConnections, nil, nil do
        v66:disconnect();
    end;
    v64.bulkConnections = {};
    if v64.renderSteppedConnection then
        v64.renderSteppedConnection:Disconnect();
        v64.renderSteppedConnection = nil;
    end;
    if v64.cameraManager then
        v64.cameraManager:stop();
    end;
    if v64.ppeCameraManager then
        v64.ppeCameraManager:stop();
    end;
    v64:cancelCurrentTween();
end;
v15.onDestroy = function(v67)
    if v67.cameraManager then
        v67.cameraManager:onDestroy();
    end;
end;
return v15;


local l_CoreGui_0 = game:GetService("CoreGui");
local l_CorePackages_0 = game:GetService("CorePackages");
local l_Modules_0 = l_CoreGui_0.RobloxGui.Modules;
local l_EmoteUtility_0 = require(l_CorePackages_0.Thumbnailing).EmoteUtility;
local v4 = require(l_Modules_0.AvatarExperience.ProfilePictureEditor.PPEThumbnailType);
local v5 = require(l_Modules_0.AvatarExperience.Common.Selectors.SelectIsToolEquipped);
local v6 = require(l_Modules_0.AvatarExperience.Common.Utils);
local _ = require(l_Modules_0.AvatarExperience.Common.Managers.AnimationManagerTypes);
local v8 = require(l_Modules_0.AvatarExperience.ProfilePictureEditor.Actions.CompletePPEEmoteLoading);
local v9 = require(l_Modules_0.AvatarExperience.ProfilePictureEditor.Actions.StartPPEEmoteLoading);
local v10 = require(l_Modules_0.AvatarExperience.ProfilePictureEditor.Actions.SetLastSuccessfulPoseEmoteAssetId);
local v11 = require(l_Modules_0.AvatarExperience.Common.Managers.AnimationUtils);
local _ = require(l_Modules_0.AvatarExperience.Common.AvatarExperienceState);
local v13 = {};
local function _(v14)
    if not v14 then
        return false;
    else
        return v14:getEquippedToolModel() ~= nil;
    end;
end;
v13.getDidSomethingRequiringPPEPoseAdjustment = function(v16, v17, v18)
    if v16.AvatarExperience.AvatarScene.Character.CharacterModelVersion ~= v17.AvatarExperience.AvatarScene.Character.CharacterModelVersion then
        return true;
    else
        local l_finalPageViewMode_0 = v16.AvatarExperience.ProfilePictureEditor.FinalPageViewMode.finalPageViewMode;
        local l_finalPageViewMode_1 = v17.AvatarExperience.ProfilePictureEditor.FinalPageViewMode.finalPageViewMode;
        if l_finalPageViewMode_0 ~= l_finalPageViewMode_1 then
            if l_finalPageViewMode_0 == v4.Closeup and l_finalPageViewMode_1 == v4.FullBody then
                if not v5(v17) or not not v18 and v18:getEquippedToolModel() ~= nil then
                    return true;
                else
                    return false;
                end;
            elseif l_finalPageViewMode_0 == v4.FullBody and l_finalPageViewMode_1 == v4.Closeup then
                if not v5(v17) or not (not not v18 and v18:getEquippedToolModel() ~= nil) then
                    return true;
                else
                    return false;
                end;
            end;
        end;
        return false;
    end;
end;
v13.getAssetIdsToLoad = function(v21, v22)
    local v23 = {
        ppeEmoteAssetId = v6.getAssetIdForPPEPose(v21)
    };
    if v22 then
        v23.moodAssetId = v6.getEquippedMoodAssetId(v21);
    end;
    return v23;
end;
local v24 = false;
v13.makeLoadedAssets = function(v25, v26, v27)
    local v28 = {};
    local l_CurrentCharacter_0 = v25:getState().AvatarExperience.AvatarScene.Character.CurrentCharacter;
    if l_CurrentCharacter_0 then
        if l_CurrentCharacter_0:FindFirstChildOfClass("Humanoid") then
            assert(v24 == false, "promiseHasOutstandingPPELoading should be false");
            v25:dispatch(v9());
            v24 = true;
            local v30 = nil;
            local v31 = nil;
            if v27.ppeEmoteAssetId then
                v30 = tonumber(v27.ppeEmoteAssetId);
            end;
            if v27.moodAssetId then
                v31 = tonumber(v27.moodAssetId);
            end;
            v28.keyframesForPose = l_EmoteUtility_0.LoadKeyframesForPose(l_CurrentCharacter_0, v30, v31, true, not v26.ppeFinalPageFullView);
            v25:dispatch(v8());
            v24 = false;
            return v28;
        else
            return v28;
        end;
    else
        return v28;
    end;
end;
v13.maybeNoteLoadingFinished = function(v32)
    if v24 then
        v32:dispatch(v8());
    end;
    v24 = false;
end;
v13.applyNewProfilePictureEditorPose = function(v33, v34, v35, v36)
    assert(v34, "currentCharacter is non-nil.");
    assert(v35, "humanoid is non-nil..");
    if v36 then
        l_EmoteUtility_0.ApplyKeyframesForPose(v34, v36);
    else
        l_EmoteUtility_0.SetPlayerCharacterNeutralPose(v34);
        if Enum.HumanoidRigType.R6 == v35.RigType then
            l_EmoteUtility_0.AdjustArmOnR6ForTool(v34);
        end;
    end;
    local v37 = nil;
    if v36 then
        v37 = v36.finalAnimationAssetIdOrUrl and tostring(v37);
    end;
    v11.waitForAnimationAndPosingToResolve(function()
        v33:dispatch(v10(v37));
    end);
end;
v13.undoOldProfilePictureEditorPose = function(v38, v39, v40)
    if not (not v40 or not v39) then
        l_EmoteUtility_0.SetPlayerCharacterNeutralPose(v39);
        v38:dispatch(v10(nil));
    end;
end;
return v13;


local v0 = {};
v0.__index = v0;
v0.new = function()
    local v1 = {
        pageObjectMap = {}
    };
    setmetatable(v1, v0);
    return v1;
end;
v0.storePageObject = function(v2, v3, v4)
    v2.pageObjectMap[v3] = v4;
end;
v0.getPageObject = function(v5, v6)
    return v5.pageObjectMap[v6];
end;
return v0;


local l_Workspace_0 = game:GetService("Workspace");
local l_ReplicatedStorage_0 = game:GetService("ReplicatedStorage");
local l_CoreGui_0 = game:GetService("CoreGui");
local v3 = require(game:GetService("CorePackages").Cryo);
local l_Modules_0 = l_CoreGui_0.RobloxGui.Modules;
local v5 = require(l_Modules_0.AvatarExperience.Common.Utils);
local v6 = require(l_Modules_0.AvatarExperience.AvatarEditor.Utils);
local v7 = require(l_Modules_0.AvatarExperience.Common.Constants);
local v8 = {};
v8.__index = v8;
v8.new = function(v9, v10)
    local v11 = {};
    setmetatable(v11, v8);
    v11.connections = {};
    v11.store = v9;
    v11.avatarRoute = v10;
    v11.avatarSwapPFX = {};
    for _ = 1, 4 do
        table.insert(v11.avatarSwapPFX, l_ReplicatedStorage_0:WaitForChild("AvatarSwap-PFX"):Clone());
    end;
    v11.emissionId = 0;
    v11.destroyed = false;
    return v11;
end;
v8.setAvatarRoute = function(v13, v14)
    v13.avatarRoute = v14;
end;
v8.start = function(v15)
    for _, v17 in v15.avatarSwapPFX, nil, nil do
        v17.Parent = l_Workspace_0;
        v17.MainEmitter.Rate = 10;
        v17.MediumEmitter.MediumEmissions.Rate = 20;
        v17.SmallerEmitter.SmallerEmissions.Rate = 20;
    end;
    table.insert(v15.connections, (v15.store.changed:connect(function(v18, v19)
        v15:update(v18, v19);
    end)));
    v15.oldAccessories = {};
    v15.changedAccessories = {};
    v15.curCharacter = nil;
    v15.accessoryPositions = {};
end;
v8.stop = function(v20)
    for _, v22 in v20.avatarSwapPFX, nil, nil do
        v22.Parent = l_ReplicatedStorage_0;
    end;
    for _, v24 in v20.connections, nil, nil do
        v24:disconnect();
    end;
    v20.connections = {};
end;
local l_next_0 = next;
v8.getAttachmentOrPartPosition = function(v26, v27)
    local v28 = v7.AssetTypeIdToPartsAndAttachments[v26.store:getState().AvatarExperience.AvatarEditor.Character.AvatarType][v27];
    if v28 == nil then
        return nil;
    else
        local v29 = {};
        for _, v31 in v28, nil, nil do
            local v32 = not not v31 and (v31.Attachment and v5.getAttachmentCFrame(v26.curCharacter, v31.Part, v31.Attachment) or v5.getPartCFrame(v26.curCharacter, v31.Part)) or nil;
            if v32 ~= nil and v32.Position ~= nil then
                table.insert(v29, v32.Position);
            end;
        end;
        return v29;
    end;
end;
v8.getChangedTryOnPart = function(v33, v34, v35)
    local v36 = v35.AvatarExperience.AvatarScene.OutfitTryOn.LastToggledItem or {};
    local v37 = v34.AvatarExperience.AvatarScene.OutfitTryOn.LastToggledItem or {};
    if v37 == v36 then
        return nil, nil;
    else
        return v37.itemId or v36.itemId, v33:getAttachmentOrPartPosition(v37.itemSubType or v36.itemSubType);
    end;
end;
v8.getChangedEquippedPart = function(v38, v39, v40)
    local v41, v42 = l_next_0((v6.getEquippedDiffs(v39.AvatarExperience.AvatarEditor.Character.EquippedAssets or {}, v40.AvatarExperience.AvatarEditor.Character.EquippedAssets or {})));
    if not v41 then
        return nil, nil;
    else
        return v42[1], v38:getAttachmentOrPartPosition(v41);
    end;
end;
v8.setPositions = function(v43, v44)
    for v45, v46 in v44, nil, nil do
        if v45 <= 4 then
            v43.avatarSwapPFX[v45].Position = v46;
            v43.avatarSwapPFX[v45].MediumEmitter.Position = v46;
            v43.avatarSwapPFX[v45].SmallerEmitter.Position = v46;
        else
            break;
        end;
    end;
end;
v8.getChangedAttachmentPosition = function(v47, v48, v49)
    if not l_next_0(v47.changedAccessories) then
        local v50, v51 = v47:getChangedEquippedPart(v48, v49);
        if not v51 then
            local v52, v53 = v47:getChangedTryOnPart(v48, v49);
            v50 = v52;
            v51 = v53;
        end;
        return v51;
    else
        local v54 = {};
        local v55 = {};
        for _, v57 in v47.changedAccessories, nil, nil do
            local v58 = v47.accessoryPositions[v57.accessory.Name];
            if not v58 then
                if not v57.removed then
                    table.insert(v55, v57);
                end;
            else
                table.insert(v54, v58);
                if v57.removed then
                    v47.accessoryPositions[v57.accessory.Name] = nil;
                end;
            end;
        end;
        v47.changedAccessories = v55;
        return v54;
    end;
end;
v8.getAccessories = function(v59, _)
    return (v59.curCharacter:FindFirstChildOfClass("Humanoid"):GetAccessories());
end;
v8.cachePosition = function(v61, v62)
    local l_BasePart_0 = v62:FindFirstChildWhichIsA("BasePart");
    if l_BasePart_0 then
        v61.accessoryPositions[v62.Name] = l_BasePart_0.Position;
    end;
    return l_BasePart_0;
end;
v8.updateChangedAccessory = function(v64, v65)
    local v66 = v64:getAccessories(v65);
    local v67 = v6.diffList(v66, v64.oldAccessories);
    local l_oldAccessories_0 = v64.oldAccessories;
    v64.changedAccessories = v3.List.join(v64.changedAccessories, (v3.List.map(v67, function(v69)
        if not v3.List.find(l_oldAccessories_0, v69) then
            return {
                accessory = v69,
                removed = false
            };
        else
            return {
                accessory = v69,
                removed = true
            };
        end;
    end)));
    for _, v71 in v64.changedAccessories, nil, nil do
        if not v64.accessoryPositions[v71.accessory.Name] then
            v64:cachePosition(v71.accessory);
        end;
    end;
    v64.oldAccessories = v66;
end;
v8.update = function(v72, v73, v74)
    if v73.AvatarExperience.AvatarScene.Character.CurrentCharacter then
        v72.curCharacter = v73.AvatarExperience.AvatarScene.Character.CurrentCharacter;
        v72:updateChangedAccessory(v73);
        local v75 = v73.AvatarExperience.AvatarEditor.Character.EquippedAssets ~= v74.AvatarExperience.AvatarEditor.Character.EquippedAssets;
        local v76 = v73.AvatarExperience.AvatarEditor.Character.AvatarType ~= v74.AvatarExperience.AvatarEditor.Character.AvatarType;
        local v77 = v73.AvatarExperience.AvatarEditor.Character.BodyColors ~= v74.AvatarExperience.AvatarEditor.Character.BodyColors;
        local v78 = v73.AvatarExperience.AvatarScene.OutfitTryOn.TryOnItems ~= v74.AvatarExperience.AvatarScene.OutfitTryOn.TryOnItems;
        local l_name_0 = v72.avatarRoute.opaque.name;
        if not (l_name_0 ~= "ProfilePictureEditorEmotes" and l_name_0 ~= "ProfilePictureEditorCamera") or l_name_0 == "ProfilePictureEditorFinal" then
            for v80 = 1, #v72.avatarSwapPFX do
                v72.avatarSwapPFX[v80].MainEmitter.Enabled = false;
                v72.avatarSwapPFX[v80].MediumEmitter.MediumEmissions.Enabled = false;
                v72.avatarSwapPFX[v80].SmallerEmitter.SmallerEmissions.Enabled = false;
            end;
            return ;
        else
            if not (not (((v75 or v76) or v77) or v78) and not l_next_0(v72.changedAccessories)) then
                local v81 = v72:getChangedAttachmentPosition(v73, v74);
                if not (not v81 or not l_next_0(v81)) then
                    v72:setPositions(v81);
                    v72:runParticleEmitter(#v81);
                end;
            end;
            return ;
        end;
    else
        return ;
    end;
end;
v8.runParticleEmitter = function(v82, v83)
    task.spawn(function()
        local v84 = math.min(v83, 4);
        for v85, v86 in v82.avatarSwapPFX, nil, nil do
            if v84 < v85 then
                v86.MainEmitter.Enabled = false;
                v86.MediumEmitter.MediumEmissions.Enabled = false;
                v86.SmallerEmitter.SmallerEmissions.Enabled = false;
            else
                v86.MainEmitter.Enabled = true;
                v86.MediumEmitter.MediumEmissions.Enabled = true;
                v86.SmallerEmitter.SmallerEmissions.Enabled = true;
            end;
        end;
        v82.emissionId = v82.emissionId + 1;
        local l_emissionId_0 = v82.emissionId;
        task.wait(0.3);
        if not v82.destroyed then
            if v82.emissionId == l_emissionId_0 then
                for v88 = 1, v84 do
                    v82.avatarSwapPFX[v88].MainEmitter.Enabled = false;
                    v82.avatarSwapPFX[v88].MediumEmitter.MediumEmissions.Enabled = false;
                    v82.avatarSwapPFX[v88].SmallerEmitter.SmallerEmissions.Enabled = false;
                end;
            end;
            return ;
        else
            return ;
        end;
    end);
end;
v8.onDestroy = function(v89)
    v89.avatarSwapPFX[1]:Destroy();
    v89.avatarSwapPFX[2]:Destroy();
    v89.avatarSwapPFX[3]:Destroy();
    v89.avatarSwapPFX[4]:Destroy();
    v89.destroyed = true;
end;
return v8;


local l_InsertService_0 = game:GetService("InsertService");
local l_Modules_0 = game:GetService("CoreGui").RobloxGui.Modules;
local v2 = require(l_Modules_0.AvatarExperience.AvatarEditor.Actions.IncrementCharacterModelVersion);
local v3 = require(l_Modules_0.AvatarExperience.Catalog.Actions.IncrementTryOnCharacterModelVersion);
local v4 = require(l_Modules_0.LuaApp.mutedError);
local v5 = require(l_Modules_0.AvatarExperience.Common.Constants);
local v6 = require(l_Modules_0.AvatarExperience.Common.Utils);
local v7 = require(l_Modules_0.AvatarExperience.Common.Components.RoactNavigation.AvatarScreen);
local v8 = require(l_Modules_0.AvatarExperience.ProfilePictureEditor.PPEThumbnailType);
local v9 = require(l_Modules_0.AvatarExperience.Common.Utils);
local _ = require(l_Modules_0.AvatarExperience.Common.Types);
local v11 = require(l_Modules_0.AvatarExperience.Flags.FFlagAXAvatarWidgetTryOn);
local v12 = {};
v12.__index = v12;
local function _(v13)
    return v13:IsA("Tool");
end;
local function _(v15)
    return v15:IsA("Script");
end;
local function v17(v18)
    for _, v20 in v18:GetChildren() do
        if v20:IsA("Script") then
            v20.Disabled = true;
        end;
        v17(v20);
    end;
end;
local function _(v21)
    local l_assets_0 = v21.assets;
    if l_assets_0 then
        local v23 = l_assets_0[v5.AssetTypeIdStrings.Gear];
        if v23 then
            return v23[1];
        else
            return ;
        end;
    else
        return ;
    end;
end;
v12.new = function(v25, v26, v27)
    local v28 = {};
    setmetatable(v28, v12);
    v28.store = v25;
    v28.characterManager = v27;
    v28.animationManager = v26;
    v28.animationManager:setToolManager(v28);
    v28.equippedToolModel = nil;
    v28.isCurToolTryOn = false;
    v28.destroyed = false;
    v28.curToolId = nil;
    return v28;
end;
v12.getEquippedToolModel = function(v29)
    return v29.equippedToolModel;
end;
v12.checkAndEquipTool = function(v30)
    local l_EquippedAssets_0 = v30.store:getState().AvatarExperience.AvatarEditor.Character.EquippedAssets;
    local v32 = l_EquippedAssets_0 and l_EquippedAssets_0[v5.AssetTypeIdStrings.Gear];
    if not (not v32 or not next(v32)) then
        v30:loadAndEquipTool(next(v32), false);
    end;
end;
v12.checkOutfitAndEquipTool = function(v33, v34)
    if v33.equippedToolModel then
        v33:unequipTool();
    end;
    local l_assets_1 = v34.assets;
    local v36;
    if l_assets_1 then
        local v37 = l_assets_1[v5.AssetTypeIdStrings.Gear];
        v36 = if v37 then v37[1] else nil;
    else
        v36 = nil;
    end;
    if v36 then
        v33:loadAndEquipTool(v36, true);
    end;
end;
local function _(v38, v39)
    if v38 and v39 then
        if v6.routeIsProfilePictureEditor(v38) then
            if v38.opaque.name == v7.ProfilePictureEditorFinal and v39.AvatarExperience.ProfilePictureEditor.FinalPageViewMode.finalPageViewMode == v8.FullBody then
                return false;
            else
                return true;
            end;
        else
            return false;
        end;
    else
        return false;
    end;
end;
v12.updateAvatarRoute = function(v41, v42, v43)
    v41.currentAvatarRoute = v42;
    local v44 = v42.opaque.name == v7.ProfilePictureEditorFinal;
    local v45 = v43.opaque.name == v7.ProfilePictureEditorFinal;
    local v46 = v6.routeIsProfilePictureEditor(v42);
    local v47 = v6.routeIsProfilePictureEditor(v43);
    if not (v44 == v45) or v46 ~= v47 then
        v41:update(v41.store:getState());
    end;
end;
v12.update = function(v48, v49)
    local l_curToolId_0 = v48.curToolId;
    local v51 = nil;
    for v52, v53 in v49.AvatarExperience.AvatarScene.OutfitTryOn.TryOnItems, nil, nil do
        if (not (v11() and not v53.selectedInTryOnManager) and v53.itemType == v5.ItemType.Asset) and v53.itemSubType == v5.AssetTypeIdStrings.Gear then
            if not v11() then
                v51 = v52;
            else
                v51 = v53.itemId;
            end;
        end;
    end;
    local v54 = v9.getEquippedToolId(v49);
    local l_currentAvatarRoute_0 = v48.currentAvatarRoute;
    if not (not not l_currentAvatarRoute_0 and if v49 then if v6.routeIsProfilePictureEditor(l_currentAvatarRoute_0) then l_currentAvatarRoute_0.opaque.name ~= v7.ProfilePictureEditorFinal or v49.AvatarExperience.ProfilePictureEditor.FinalPageViewMode.finalPageViewMode ~= v8.FullBody else false else false) then
        if not v51 then
            if not v54 then
                if not v48.equippedToolModel then
                    v48.curToolId = nil;
                else
                    v48:unequipTool(true);
                end;
            else
                v48:unequipTool(v48.curToolIsTryOn);
                v48:loadAndEquipTool(v54, false);
            end;
        else
            v48:unequipTool();
            v48:loadAndEquipTool(v51, true);
        end;
    else
        v48:unequipTool(true);
    end;
    local v56 = false;
    if v48.curToolId ~= nil then
        v56 = v48.curToolId ~= l_curToolId_0;
    end;
    v48.checkForChangedTool = v56;
end;
v12.loadAndEquipTool = function(v57, v58, v59)
    v57.curToolId = v58;
    task.spawn(function()
        local v60 = nil;
        local _, l_result_0 = pcall(function()
            v60 = l_InsertService_0:LoadAsset(v58);
        end);
        if not v57.destroyed then
            if not l_result_0 and v60 then
                if v58 ~= v57.curToolId then
                    warn("Tool unequipped without getting a chance to get equipped.");
                    v60:Destroy();
                    return ;
                else
                    local _, v64 = next(v60:GetChildren());
                    if not (not v64 or not v64:IsA("Tool")) then
                        v17(v64);
                        v57:equipTool(v64);
                        if v57.checkForChangedTool then
                            v57.checkForChangedTool = false;
                            local l_BoundingBox_0, v66 = v57.characterManager:getCurrentCharacter():GetBoundingBox();
                            if not (v6.isBoundingBoxVectorSane(v66) and v6.isBoundingBoxCFrameSane(l_BoundingBox_0)) then
                                v4("(Avatar Experience) bad bounding box on adding tool: " .. v58);
                            end;
                        end;
                    end;
                    if v59 then
                        v57.curToolIsTryOn = true;
                        v57.store:dispatch(v3());
                    else
                        v57.curToolIsTryOn = false;
                        v57.store:dispatch(v2());
                    end;
                    return ;
                end;
            else
                warn("Error loading tool in CharacterManager: " .. l_result_0);
                return ;
            end;
        else
            if v60 then
                v60:Destroy();
            end;
            return ;
        end;
    end);
end;
v12.equipTool = function(v67, v68)
    v67.equippedToolModel = v68;
    v67.characterManager:getCurrentCharacter().Humanoid:EquipTool(v68);
end;
v12.unequipTool = function(v69, v70)
    v69.curToolId = nil;
    local l_equippedToolModel_0 = v69.equippedToolModel;
    if l_equippedToolModel_0 then
        if v70 then
            if not v69.curToolIsTryOn then
                v69.store:dispatch(v2());
            else
                v69.store:dispatch(v3());
            end;
        end;
        v69.equippedToolModel = nil;
        v69.characterManager:getCurrentCharacter().Humanoid:UnequipTools();
        l_equippedToolModel_0:Destroy();
    end;
end;
v12.notifySwitchedAvatarType = function(v72)
    if v72.equippedToolModel then
        v72:equipTool(v72.equippedToolModel);
    end;
end;
v12.start = function(_)
end;
v12.stop = function(v74)
    local l_EquippedAssets_1 = v74.store:getState().AvatarExperience.AvatarEditor.Character.EquippedAssets;
    local v76 = l_EquippedAssets_1 and l_EquippedAssets_1[v5.AssetTypeIdStrings.Gear];
    if not (v76 and next(v76) or not v74.equippedToolModel) then
        v74:unequipTool();
    end;
    v74:checkAndEquipTool();
end;
v12.onDestroy = function(v77)
    v77.destroyed = true;
end;
return v12;


local v0 = {};
v0.__index = v0;
v0.new = function()
    local v1 = {};
    setmetatable(v1, v0);
    v1.StoppedBindableEvent = Instance.new("BindableEvent");
    v1.Stopped = v1.StoppedBindableEvent.Event;
    v1.WeightCurrent = 1;
    v1.IsPlaying = false;
    return v1;
end;
v0.Play = function(v2, _)
    v2.IsPlaying = true;
end;
v0.Stop = function(v4, _)
    if v4.IsPlaying then
        v4.IsPlaying = false;
        v4.StoppedBindableEvent:Fire();
    end;
end;
v0.AdjustWeight = function(v6, v7)
    v6.WeightCurrent = v7;
end;
v0.Destroy = function(_)
end;
return v0;


local v0 = {};
v0.__index = v0;
v0.new = function()
    local v1 = {};
    setmetatable(v1, v0);
    v1.StoppedBindableEvent = Instance.new("BindableEvent");
    v1.EndedBindableEvent = Instance.new("BindableEvent");
    v1.DidLoopBindableEvent = Instance.new("BindableEvent");
    v1.Stopped = v1.StoppedBindableEvent.Event;
    v1.Ended = v1.EndedBindableEvent.Event;
    v1.DidLoop = v1.DidLoopBindableEvent.Event;
    v1.IsPlaying = false;
    return v1;
end;
v0.Play = function(v2, _)
    v2.IsPlaying = true;
    task.spawn(function()
        task.wait(1);
        if v2.IsPlaying then
            v2.IsPlaying = false;
            v2.StoppedBindableEvent:Fire();
            task.wait(0.2);
            v2.EndedBindableEvent:Fire();
        end;
    end);
end;
v0.Stop = function(v4, _)
    if v4.IsPlaying then
        task.spawn(function()
            v4.IsPlaying = false;
            v4.StoppedBindableEvent:Fire();
            task.wait(0.2);
            v4.EndedBindableEvent:Fire();
        end);
    end;
end;
v0.Destroy = function(_)
end;
return v0;