Home > How To

How To Build A PC: The Ultimate Step-By-Step Guide In 2023

This in-depth step-by-step has everything you need

Reviewed By: Kevin Pocock

Last Updated on July 24, 2023
How to build a PC - title hero
You can trust PC Guide: Our team of experts use a combination of independent consumer research, in-depth testing where appropriate - which will be flagged as such, and market analysis when recommending products, software and services. Find out how we test here.

If you’re a gamer, craving to build your own PC is something that has definitely crossed your mind at least once. But the thought of piecing together all the components yourself can be intimidating. Fortunately, that’s what this article is for; to provide you with step-by-step instructions on how to build a PC.

How to Build a PC

How to build a PC – what you need

To be able to build your own desktop PC, you need to have the right tools. In this article, we’ll be covering all the important tools you need – complete with recommendations and tips from our very own PCGuide experienced builders.

  • Screwdriver – You only need the #2 Phillips screwdriver to do all the work. And if you have an M.2 device, then tag along with you a #0 screwdriver – that’s it. We recommend using magnetic screwdrivers to easily get into tight places.
  • Bowl – Well, it doesn’t have to be a bowl, per se, but you will need somewhere to put all of the screws you are using during your build.
  • Workspace – Whether a table or floor, make sure it is large. To prevent unwanted damage from ESD (electrostatic discharge), use a surface that isn’t metal – preferably, a wood or a glass surface. Also, avoid carpets.
  • Anti-Static Equipment – Anti-static wrist straps and anti-static mats are used by a lot of technicians and builders to discharge static electricity. They aren’t necessary, but $5 for a flimsy cable is worth ensuring your several-hundred-dollar rig.
  • Zip Ties – Needless to say, tying up the cables so they’ll look clean can be a challenging task. This is why you need zip ties. Some cases (like the one in Our Favorite Gaming PC Components section) have Velcro straps.
  • Scissors/Cutter – Obviously, you’re going to have to cut a few things here and there as you learn how to build a PC. So, make sure you have a pair of scissors/cutters within your reach.

How to build a PC – A step-by-step guide

If you want to know how to build a PC from scratch, you’ll need at least weeks of preparation ahead. Planning is everything if you want to know how to assemble a computer right.

The first part to your plan will be picking parts. There are plenty of things you need to consider such as compatibility, what you plan on using it for, etc.

For the purpose of making the best PC building guide, we’ll be using our favorite gaming PC components as an example to teach you how to build your own computer kit from start to finish.

However, you might want to get different parts than what you choose. Maybe you want something cheaper, maybe you prefer AMD to Intel, or maybe you want a smaller form factor case. Whatever your reasoning, we recommend using PCPartPicker to check parts compatibility and keep track of your build.

Moreover, you should also be patient enough and wait to snag the best deals online for your parts. For instance, part prices fluctuate a lot. Using a website like CamelCamelCamel.com to see the price of a product on Amazon – as well as other 3rd party sites – over the course of its whole shelf life.

Our favorite gaming PC components

Knowing how to build a PC is one thing; knowing what to buy is another. The below build costs around $1600, but you can always make changes so it’ll fit your budget.

  • CPU: AMD Ryzen 7 7700X – Check price
  • Cooler: Noctua NH-D15 chromax.Black – Check price
  • GPU: ASUS Dual NVIDIA GeForce RTX 3070 V2 OC Edition – Check price
  • Motherboard: GIGABYTE B650 AORUS Elite AX – Check price
  • RAM: TEAMGROUP T-Force Vulcan DDR5 32GB (2x16GB) 6000MHz – Check price
  • SSD: Crucial T700 1TB Gen5 NVMe M.2 SSD – Check price
  • HDD: Seagate BarraCuda 2TB Internal Hard Drive HDD – Check price
  • PSU: Corsair RMX Series RM750X – Check price
  • Case: Corsair 4000D Airflow ATX Mid Tower – Check price

Putting it altogether

One last piece of advice before we get hands-on with how to build a PC: reference your manuals. Or put another way, don’t be afraid to search for more info while building your PC if you are uncomfortable.

Building computers – especially for beginners – can get overwhelming and fast. Thankfully, if you are uncertain about how to do a particular step, there are a lot of resources.

Of course, you can reference your manuals, go to the website for the part in question, search forums, etc. Moreover, you might find that the visual aspect of YouTube videos helps you better understand exactly what you are supposed to do.

1. Breaking the Case

Well, not literally breaking it – more like stripping it down. Taking the Phanteks P400S ATX Mid Tower Case as an example…

Step 1: Unscrew the front panel and 2 side panels using the #2 Phillips screwdriver

Step 2: Place the screws in a bowl or a mini magnetic parts tray

Step 3: Remove the panels and place them on a safe surface or just put them back inside the case box

Step 4: Remove the top magnetic dust filters

Now at this point, you’ll want to familiarize the case’s layout (like I usually do), such as where the SSDs and HDDs go, the direction where the power supply’s exhaust should be facing, the mounts, and which standoffs to use to fit your motherboard.

This should give you a general idea where things should go and which holes the cables should be routed to.

Further Reading: Best PC Cases

2. Power Supply Unit (PSU) Installation

Get your power supply and check which cables you’ll be using for later (if you’re using a semi-modular or fully modular PSU). Unlike other parts, non-modular PSUs are pretty uniform, so if you’ve installed one PSU, you’ve installed them all… sorta.

Don’t worry though if you are first time builder, just:

Step 1: Open the bracket from the back of the case.

Step 2: Place the PSU so that its exhaust is blowing out of the case

Step 3: Secure the bracket back to its place.

Step 4: Screw it back in place.

If you’re using an old case, then you might need to push the case firmly against the inside wall of the case before you lock it in place with the four screws.

The power supply we’re using as an example (Corsair CXM 550W 80+ Bronze PSU) is semi-modular. This means that some of the cables can be removed to help keep things clean, but some of the other cables, like the one that leads to the motherboard and which will always be needed, can not be removed from the PSU.

Further Reading: Best Power Supply for Gaming

3. Processor (CPU) Installation

During the next 3 steps, we will be outfitting the motherboard prior to installing it.

Before you even unbox the CPU, be aware that you should never touch the bottom where the pins are; it’s always best to hold it by its sides. Intel and AMD processors largely install the same way, but there are slight differences as covered below.

For Intel:

Step 1: Slide the spring-loaded retention arm out and up.

Step 2: Lift the bracket up (don’t bother taking off the plastic cover).

Step 3: Gently place the processor on top of the socket by matching the golden triangle located on the bottom-left corner of the Intel processor chip with the triangle on the socket bracket.

You shouldn’t need to press down on it. If it doesn’t align properly, then pick it up and make sure it’s placed properly and that none of the pins are damaged.

Step 4: Slide the bracket back to its original position

Step 5: Slide the spring-loaded retention arm back down and lock it back in place

Note: It’s perfectly alright for the plastic cover to pop off when doing Step 5, so you shouldn’t worry about a thing if it flies off.

It’s also worth noting that the plastic cover at this point has served its purpose. Personally, I like to keep it somewhere safe so I can use it to protect the pins on the motherboard CPU socket in the future in case I want to remove the CPU for upgrade purposes.

For AMD:

Step 1: Lift the spring-loaded retention arm out and up.

Step 2: Gently place the processor on top of the socket by matching the golden triangle located on the bottom-left corner of the AMD processor with the triangle on the socket.

You shouldn’t need to press down on it. If it doesn’t align properly, then pick it up and make sure it’s placed properly and that none of the pins are damaged.

Step 3: Make sure it’s in place before lowering the retention arm back down and locking it in place.

Once everything is locked in place, it’s time to install the RAM or memory sticks.

Further Reading: Best CPU for Gaming

4. Memory (RAM) Installation

The RAM are probably the easiest to install.

Step 1: Push the latches on either end of the RAM slots on the motherboard.

Step 2: Line up the notch on the bottom of the memory with the notch in the RAM slot.

Step 3: Gently push both sides of the memory into the slot.

The motherboard we’re using in this example (MSI H310M Pro-VD Micro ATX Motherboard) only has 2 RAM slots. If the motherboard you have has 4 or 8 slots, refer to your motherboard’s manual to see which slots to fill first to ensure you are running it in Dual Channel. Placing the RAM in the wrong slots would mean you’re not using Dual Channel mode, and thus wasting its capacity.

Further Reading: Best RAM for Gaming

5. Mounting the CPU Cooler

While some components are highly standardized, CPU coolers come in a lot of different shapes and sizes; many third-party CPU coolers even require installing a backplate. As such, you should follow its installation guide.

The overall idea is to affix the backplate that comes with the CPU cooler (with the four pins) through the back of your motherboard first so you can mount the cooler in place later after installing the motherboard inside the case (5. Motherboard (MOBO) Installation).

When you’re done installing the motherboard with the CPU mount backplate, it’s time to install the cooler on the CPU. Keep in mind that most CPU coolers have pre-applied thermal paste. If yours doesn’t, add a small blob of thermal paste, ideally, around the size of a pea, on the center of the CPU. This will then spread out evenly as you mount the cooler in place.

It’s also important to note that installing an air CPU cooler is different than installing a liquid CPU cooler.

Air CPU Cooler

Ideally, you want to install an air CPU cooler with the fans unattached, installing the heatsink onto the pins of the mounting plate first before installing the motherboard inside the case.

When done, all you need to do is to simply reattach the fans to the mount and plug in the 4-pin PWM fan header into the motherboard’s CPU fan slot, which is usually located at the top side of the motherboard. There’s more than one way to find the CPU fan slot:

  1. Read the label on the motherboard.
  2. Refer to your motherboard manual to see where the CPU fan slot is located.

Liquid CPU Cooler

Installing a liquid CPU cooler follows the general process of installing the mounting plate first before attaching the heatsink onto the CPU.

Taking the liquid cooler and the case we used as an example, put the 240mm liquid CPU cooler at the front of the case as an intake fan and screw it in place using the #2 Phillips screwdriver along with the included radiator.

This acts as two intake fans at the same time, so using the 2nd included fan as a second exhaust will balance the airflow (2 intake fans/2 exhaust). More of this in the 7. Fan Installation section.

Also, you may need to plug in a second 4-pin cable dedicated to the AIO cooler for the pump or even a Molex connector if you’re going to use the CPU cooler (Cooler Master MasterLiquid Lite 240 Liquid Cooler) on our example for the RGB lighting setup and whatnot.

If you’re unsure or confused, always refer to your CPU cooler manual. When done, it’s time to install the motherboard inside the case.

Further Reading: Best CPU Coolers

6. Motherboard (MOBO) Installation

Installing the motherboard is kind of tricky. In fact, you will need to have patience with this step of learning how to build a PC. The standoff screws and I/O shield can be notoriously annoying. Both tasks represent a balancing act between power and dexterity. Still, it’s nothing too complex, just annoying.

Step 1: Grab the I/O shield and install it by pushing it into the rectangular slot found in the back of the case. Push on the edges – not in the middle – otherwise, it could break. You need to do this first because you can’t put it in place once the motherboard is installed.

Step 2: Check for pre-installed motherboard standoffs and see if it’s in line with the holes found on your selected motherboard.

Note: Some motherboards, like the Phanteks Eclipse P400s, have pre-installed motherboard standoffs for ATX-sized boards while some don’t. Make sure you double-check.

Step 3: Lay the case down and carefully lay your motherboard on top of the standoff screws as you line it up with the ports and respective holes in the I/O shield.

Step 4: Use the #2 Phillips screwdriver to tighten the screws that came with the case to secure the motherboard in. Don’t tighten them too much at a time, though, as you can crack your motherboard.

It’s very important to refer to your case’s and your motherboard’s manual to identify which screw to use – or if you’re simply confused.

Further Reading: Best Motherboards for Gaming

7. Fan Installation

The Phanteks P400S ATX Mid Tower Case comes pre-installed with 2x 120mm case fans (1 intake and 1 exhaust). But since we included a Cooler Master MasterLiquid Lite 240mm Liquid Cooler in this example, we want to balance things out for maximum airflow.

Step 1: Unscrew the included 120mm intake fan from the front panel using the #2 Phillips screwdriver.

Step 2: Move it to the top (further to the rear side) as a second exhaust fan and screw it in place. As mentioned above, you want to equalize the number of intake/exhaust to achieve quality airflow inside the case.

You should remember that not all cases have included fans. So, if it only comes with 1 fan, then your best bet is to place it at the rear to act as an exhaust. Just make sure you get another 120mm fan as an intake later on.

Further Reading: Best Case Fans

8. Storage (SSD or HDD) Installation

Now, it’s time to install the hard disk drives (HDD) and the solid-state drives (SSD) – or even the M.2 SSD if you decided to use this instead. If we go back to 1. Breaking the Case, you should already have an idea where the drives should go in your case.

And if we use the case from our example (Phanteks P400S ATX Mid Tower Case), we can put the Hitachi Ultrastar 7K3000 2TB HDD inside the hard drive bay found at the back of the case (not the rear). We can also put the ADATA Ultimate SU800 512GB SSD on this side by screwing it in its respective place.

If you have an M.2 SSD, refer to your motherboard manual to see where it should go. These things go directly into your motherboard and is not designed to be placed in any drive bays.

As always, refer to your case manual if you’re confused or unsure where to store your storage devices. And remember that there are computer cases that may restrict access to specific hard drive bays if you use a radiator-type cooling system as an intake. As such, make sure you do your research prior to making any selection.

Further Reading: Best Budget SSDs

9. Graphic Card (GPU) Installation

After installing the storage devices, it’s time to install the graphics card – the heart of every gaming PC. And often the most exciting bit for gamers when you learn how to build a PC. When you first take it out from the anti-static bag, place it on a safe, non-metal surface and make sure you do the following:

Step 1: Locate the PCIe slot on your motherboard that is closest to your CPU.

Step 2: Remove the 2x PCIe slot covers with the help of the #2 Phillips screwdriver.

Step 3: Take the graphics card and line it up with the PCIe slot closest to your CPU. The GPU I/O ports should face out the back of the computer case.

Step 4: Gently push the graphics card into the PCIe slot until you hear a click sound, indicating it’s locked in place.

Step 5: Screw the PCIe slot cover you just unscrewed to secure the rear end of the graphics card.

Don’t forget to always check the dimensions of the graphics card before purchasing so you can evaluate and see whether or not it’ll fit just right inside the case. In particular, some of the high-end GPUs have large, dedicated coolers that can make it hard to squeeze into cases, even the standard ATX Full-tower cases.

Further Reading: Best Graphics Card for Gaming

10. Hooking up the Buttons and I/O Ports

Along your motherboard, you will have a lot of different pins and ports and what have you. You will need to use these to hook up your power, reset, and other I/O buttons and ports.

Honestly, this can be one of the most challenging tasks when building a computer. You have a lot of small cords with sometimes very similar connectors all going to different places. In fact, I still have problems with this from time to time.

To make sure you’re plugging the right cables to the right ports, refer to your motherboard installation manual. Some cases come with LED lights (like the Phanteks P400S ATX Mid Tower Case), and they have to be oriented correctly with the + and – pins on the board.

11. Connecting The Cables

Now that everything’s in place, it’s time to hook the cables to the motherboard ports. You probably have a general idea which cables go to which ports by now if you followed the very first step. So do that if you haven’t already or proceed and check which holes the cables should be routed to.

Step 1: Connect the 8-pin EPS from the PSU through the cable routing hole to the EPS connector on the motherboard, usually located at the top portion of the motherboard

Step 2: Get the 24-pin cable from the PSU and slide it through the cable management hole to get to the 24-pin ATX port of the motherboard, usually located at the right side of the motherboard

Step 3: Take the SATA power cable and SATA data cables and connect it to the hard disk drives. If needed, route the cables through the cable management holes to get to the SSD storage device. The SATA data pins are located at the lower right portion of the motherboard just below the 24-pin port.

Step 4: Connect the PCIe 6-pin connector from the PSU to the graphics card through the cable management holes

For now, the cables don’t have to be orderly. First, we need to test that the machine is actually running as intended.

12. Testing it Out and Cleaning up the Mess

At this point, you will need to bring some of your peripherals into the picture, like a monitor, keyboard, and mouse. Connect the power supply to an electrical outlet or an automatic voltage regulator (AVR) and turn the computer on. (Don’t forget to turn the switch behind the power supply on! It’s very common for builders – including me! – to forget about this.)

If it turns on, hit the delete key until the BIOS screen pops up. Try to check the CPU temperatures and make sure it operates somewhere around 30-40 degrees Celsius (86 – 104 degrees Fahrenheit). Similarly, check if the drives are registered and whether or not your memory is operating at the right frequencies.

If you get to this part of the building process, you’re good to go. But if you didn’t get any of this, check everything from the start and make sure you didn’t miss a thing.

Now that you’re sure you have a working computer, you can now tidy up the cables at the back and use the Velcro straps and zip ties to secure everything in place.

13. OS Installation

Now that your computer is working, you can bring it to where it’ll spend the rest of its life and hook up all of your peripherals for good this time. Now, we’ll install the operating system.

Modern PC setups don’t have optical drives so you’ll need to download the OS onto a flash drive from another computer. To do this, download the Windows 10 installer from this link. Keep in mind you will need a product key if you wish to install a paid version of Windows.

And in case you can’t afford Windows 10 right now, you can install a Linux distribution (Ubuntu or Mint). This obviously lacks many common Windows features and most software native to Windows, so most software, including games, so you will likely want to get Windows 10 eventually.

When you’re done, make sure the computer is turned off and follow the steps below:

Step 1: Plug the flash drive that has the OS installed in your computer.

Step 2: Turn the computer on and constantly hit the delete (Del) key to enter BIOS.

Step 3: Browse around and find the Boot page (sometimes called Boot Order or Boot Priority).

Step 4: Change the boot order by prioritizing the flash drive that contains the OS.

Step 5: Save the changes and restart your computer.

Step 6: Follow the instructions indicated to complete the OS installation. Remember, this will take a little while.

NOTE: It’ll take some time to complete the installation process but once installed, you’re one step closer to finally completing the build.

14. Installing the Drivers

After you’ve completed installing the OS, download the right chipset driver for your motherboard and graphics card. To do this…

Step 1.1: Head over to the motherboard manufacturer’s website and download the respective motherboard drivers. Here are some of the more popular motherboard manufacturer websites:

Step 1.2: As for GPUs, it is a little more straightforward since there are really only two viable competitors. Click this link to download NVIDIA graphics card drivers or this link to download AMD graphics card drivers.

Step 2: Open the setup file and follow the on-screen installation instructions.

NOTE: Your screen may flicker when installing the graphics card drivers so don’t panic when it does so.

Step 3: Restart your computer after installation (or it may automatically do it for you) and you’re done!

At this point, you’re basically done so CONGRATULATIONS! That wasn’t so hard after all, right?

From here, you’ll want to install the programs you need. For instance, if you’re a gamer, online gaming platforms such as Steam or EPIC Games are probably at the top of your list.

Final thoughts

So now you’ve found out how to build a PC and have been through the complete steps, you can enjoy the achievement of owning a PC you put together yourself. It’s not as hard as many would believe to put a computer together, but we hope keeping this article close by for reference was a good idea!

'),b.insertAdjacentHTML(d,e));return document.getElementById(a)};c.prototype._repeatDynamicAds=function(b){var a= [],d=this._removeRecipeCapExperiment.result&&"Recipe"===b.location?99:this.locationMaxLazySequence.get(b.location),e=b.lazy?u(d,0):0;d=b.max;var f=b.lazyMax;e=Math.max(d,0===e&&b.lazy?d+f:Math.min(Math.max(e-b.sequence+1,0),d+f));for(f=0;f=d;a.push(y(y({},b),{sequence:g,lazy:h}))}return a};c.prototype._locationEnabled=function(b){b=this._clsOptions.enabledLocations.includes(b.location);var a=this._clsOptions.disableAds&&this._clsOptions.disableAds.all|| document.body.classList.contains("adthrive-disable-all"),d=!document.body.classList.contains("adthrive-disable-content")&&!this._clsOptions.disableAds.reasons.has("content_plugin");return b&&!a&&d};return c}(),Za=function(c){function b(a,d){var e=c.call(this,a,"ClsVideoInsertion")||this;e._videoConfig=a;e._clsOptions=d;e._IN_POST_SELECTOR=".adthrive-video-player";e._WRAPPER_BAR_HEIGHT=36;e._playersAddedFromPlugin=[];d.removeVideoTitleWrapper&&(e._WRAPPER_BAR_HEIGHT=0);return e}v(b,c);b.prototype.init= function(){this._initializePlayers()};b.prototype._wrapJWPlayerWithCLS=function(a,d,e){void 0===e&&(e=0);return a.parentNode?(d=this._createGenericCLSWrapper(.5625*a.offsetWidth,d,e),a.parentNode.insertBefore(d,a),d.appendChild(a),d):null};b.prototype._createGenericCLSWrapper=function(a,d,e){var f=document.createElement("div");f.id="cls-video-container-".concat(d);f.className="adthrive";f.style.minHeight="".concat(a+e,"px");return f};b.prototype._getTitleHeight=function(a){a.innerText="Title";a.style.visibility= "hidden";document.body.appendChild(a);var d=window.getComputedStyle(a),e=parseInt(d.height,10),f=parseInt(d.marginTop,10);d=parseInt(d.marginBottom,10);document.body.removeChild(a);return Math.min(e+d+f,50)};b.prototype._initializePlayers=function(){var a=document.querySelectorAll(this._IN_POST_SELECTOR);a.length&&this._initializeRelatedPlayers(a);this._shouldRunAutoplayPlayers()&&this._determineAutoplayPlayers()};b.prototype._createStationaryRelatedPlayer=function(a,d,e){var f="mobile"===this._device? [400,225]:[640,360],g=G.Video_In_Post_ClicktoPlay_SoundOn;d&&a.mediaOrPlaylistId&&(e="".concat(a.mediaOrPlaylistId,"_").concat(e),d=this._wrapJWPlayerWithCLS(d,e),this._playersAddedFromPlugin.push(a.mediaOrPlaylistId),d&&this._clsOptions.setInjectedVideoSlots({playerId:a.playerId,playerName:g,playerSize:f,element:d,type:"stationaryRelated"}))};b.prototype._createStickyRelatedPlayer=function(a,d){var e="mobile"===this._device?[400,225]:[640,360],f=G.Video_Individual_Autoplay_SOff;this._stickyRelatedOnPage= !0;this._videoConfig.mobileStickyPlayerOnPage="mobile"===this._device;if(d&&a.position&&a.mediaId){var g=document.createElement("div");d.insertAdjacentElement(a.position,g);d=document.createElement("h3");d.style.margin="10px 0";d=this._getTitleHeight(d);d=this._wrapJWPlayerWithCLS(g,a.mediaId,this._WRAPPER_BAR_HEIGHT+d);this._playersAddedFromPlugin.push(a.mediaId);d&&this._clsOptions.setInjectedVideoSlots({playlistId:a.playlistId,playerId:a.playerId,playerSize:e,playerName:f,element:g,type:"stickyRelated"})}}; b.prototype._createPlaylistPlayer=function(a,d){var e=a.playlistId,f="mobile"===this._device?G.Video_Coll_SOff_Smartphone:G.Video_Collapse_Autoplay_SoundOff,g="mobile"===this._device?[400,225]:[640,360];this._videoConfig.mobileStickyPlayerOnPage=!0;var h=document.createElement("div");d.insertAdjacentElement(a.position,h);d=this._wrapJWPlayerWithCLS(h,e,this._WRAPPER_BAR_HEIGHT);this._playersAddedFromPlugin.push("playlist-".concat(e));d&&this._clsOptions.setInjectedVideoSlots({playlistId:a.playlistId, playerId:a.playerId,playerSize:g,playerName:f,element:h,type:"stickyPlaylist"})};b.prototype._isVideoAllowedOnPage=function(){var a=this._clsOptions.disableAds;if(a&&a.video){var d="";a.reasons.has("video_tag")?d="video tag":a.reasons.has("video_plugin")?d="video plugin":a.reasons.has("video_page")&&(d="command queue");q.error(d?"ClsVideoInsertionMigrated":"ClsVideoInsertion","isVideoAllowedOnPage",Error("DBP: Disabled by publisher via ".concat(d||"other")));return!1}return this._clsOptions.videoDisabledFromPlugin? !1:!0};return b}(function(c){function b(a,d){var e=c.call(this)||this;e._videoConfig=a;e._component=d;e._stickyRelatedOnPage=!1;e._relatedMediaIds=[];a=void 0;void 0===a&&(a=navigator.userAgent);a=/Windows NT|Macintosh/i.test(a);e._device=a?"desktop":"mobile";e._potentialPlayerMap=e.setPotentialPlayersMap();return e}v(b,c);b.prototype.setPotentialPlayersMap=function(){var a=this._videoConfig.players||[],d=this._filterPlayerMap();a=a.filter(function(e){return"stationaryRelated"===e.type&&e.enabled}); d.stationaryRelated=a;return this._potentialPlayerMap=d};b.prototype._filterPlayerMap=function(){var a=this,d=this._videoConfig.players,e={stickyRelated:[],stickyPlaylist:[],stationaryRelated:[]};return d&&d.length?d.filter(function(f){var g;return null===(g=f.devices)||void 0===g?void 0:g.includes(a._device)}).reduce(function(f,g){f[g.type]||(q.event(a._component,"constructor","Unknown Video Player Type detected",g.type),f[g.type]=[]);g.enabled&&f[g.type].push(g);return f},e):e};b.prototype._checkPlayerSelectorOnPage= function(a){var d=this;a=this._potentialPlayerMap[a].map(function(e){return{player:e,playerElement:d._getPlacementElement(e)}});return a.length?a[0]:{player:null,playerElement:null}};b.prototype._getOverrideElement=function(a,d,e){a&&d?(e=document.createElement("div"),d.insertAdjacentElement(a.position,e)):(d=this._checkPlayerSelectorOnPage("stickyPlaylist"),a=d.player,d=d.playerElement,a&&d&&(e=document.createElement("div"),d.insertAdjacentElement(a.position,e)));return e};b.prototype._shouldOverrideElement= function(a){a=a.getAttribute("override-embed");return"true"===a||"false"===a?"true"===a:this._videoConfig.relatedSettings?this._videoConfig.relatedSettings.overrideEmbedLocation:!1};b.prototype._checkPageSelector=function(a,d,e){void 0===e&&(e=[]);return a&&d&&0===e.length?("/"!==window.location.pathname&&q.event("VideoUtils","getPlacementElement",Error("PSNF: ".concat(a," does not exist on the page"))),!1):!0};b.prototype._getElementSelector=function(a,d,e){if(d&&d.length>e)return d[e];q.event("VideoUtils", "getPlacementElement",Error("ESNF: ".concat(a," does not exist on the page")));return null};b.prototype._getPlacementElement=function(a){var d=a.pageSelector,e=a.elementSelector;a=a.skip;var f=da(d),g=f.valid,h=f.elements;f=S(f,["valid","elements"]);var k=ca(e),l=k.valid,p=k.elements;k=S(k,["valid","elements"]);return""===d||g?l?this._checkPageSelector(d,g,h)?this._getElementSelector(e,p,a)||null:null:(q.error("VideoUtils","getPlacementElement",Error("".concat(e," is not a valid selector")),k),null): (q.error("VideoUtils","getPlacementElement",Error("".concat(d," is not a valid selector")),f),null)};b.prototype._getEmbeddedPlayerType=function(a){(a=a.getAttribute("data-player-type"))&&"default"!==a||(a=this._videoConfig.relatedSettings?this._videoConfig.relatedSettings.defaultPlayerType:"static");this._stickyRelatedOnPage&&(a="static");return a};b.prototype._getMediaId=function(a){return(a=a.getAttribute("data-video-id"))?(this._relatedMediaIds.push(a),a):!1};b.prototype._createRelatedPlayer= function(a,d,e,f){"collapse"===d?this._createCollapsePlayer(a,e):"static"===d&&this._createStaticPlayer(a,e,f)};b.prototype._createCollapsePlayer=function(a,d){var e=this._checkPlayerSelectorOnPage("stickyRelated"),f=e.player;e=e.playerElement;var g=f?f:this._potentialPlayerMap.stationaryRelated[0];g&&g.playerId?(this._shouldOverrideElement(d)&&(d=this._getOverrideElement(f,e,d)),d=document.querySelector("#cls-video-container-".concat(a," > div"))||d,this._createStickyRelatedPlayer(y(y({},g),{mediaId:a}), d)):q.error(this._component,"_createCollapsePlayer","No video player found")};b.prototype._createStaticPlayer=function(a,d,e){this._potentialPlayerMap.stationaryRelated.length&&this._potentialPlayerMap.stationaryRelated[0].playerId?this._createStationaryRelatedPlayer(y(y({},this._potentialPlayerMap.stationaryRelated[0]),{mediaOrPlaylistId:a}),d,e):q.error(this._component,"_createStaticPlayer","No video player found")};b.prototype._shouldRunAutoplayPlayers=function(){return this._isVideoAllowedOnPage()&& (this._potentialPlayerMap.stickyRelated.length||this._potentialPlayerMap.stickyPlaylist.length)?!0:!1};b.prototype._determineAutoplayPlayers=function(){var a=this._component,d="VideoManagerComponent"===a,e=this._config;if(this._stickyRelatedOnPage)q.event(a,"stickyRelatedOnPage",d&&{device:e&&e.context.device,isDesktop:this._device}||{});else{var f=this._checkPlayerSelectorOnPage("stickyPlaylist"),g=f.player;f=f.playerElement;g&&g.playerId&&g.playlistId&&f?this._createPlaylistPlayer(g,f):q.event(a, "noStickyPlaylist",d&&{vendor:"none",device:e&&e.context.device,isDesktop:this._device}||{})}};b.prototype._initializeRelatedPlayers=function(a){for(var d=new Map,e=0;e