import{withPathPrefix as v}from"@redocly/theme/core/utils";import{EJECT_COMPONENT_URL as y}from"../constants/common.js";(function(){let s=null,d;const g=function(){const t=document.createElement("style");t.innerHTML=`
      .eject-cover {
        position: absolute;
        pointer-events: none;
        height: 100%;
        width: 100%;
        display: block;
        z-index: 99;
        background: #fad7af;
        opacity: 0.7;
        top: 0;
        left: 0;
      }
      .toggle {
        cursor: pointer;
        display: inline-block;
      }
      .toggle-switch {
        display: inline-block;
        background: #ccc;
        border-radius: 16px;
        width: 58px;
        height: 32px;
        position: relative;
        vertical-align: middle;
        transition: background 0.25s;
        margin-right: 10px;
      }
      .toggle-switch:before, .toggle-switch:after {
        content: "";
      }
      .toggle-switch:before {
        display: block;
        background: linear-gradient(to bottom, #fff 0%, #eee 100%);
        border-radius: 50%;
        box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.25);
        width: 24px;
        height: 24px;
        position: absolute;
        top: 4px;
        left: 4px;
        transition: left 0.25s;
      }
      .toggle:hover .toggle-switch:before {
        background: linear-gradient(to bottom, #fff 0%, #fff 100%);
        box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.5);
      }
      .toggle-checkbox:checked + .toggle-switch {
        background: #56c080;
      }
      .toggle-checkbox:checked + .toggle-switch:before {
        left: 30px;
      }
      .toggle-checkbox {
        position: absolute;
        visibility: hidden;
      }
      .toggle-label {
        font-family: var(--font-family-primary);
        margin-left: 5px;
        position: relative;
        top: 2px;
      }
      .eject-toggle {
        position: absolute;
        top: 0;
        left: 35px;
        cursor:pointer;
        background: #e4e7eb;
        z-index: 999;
        height: fit-content;
        width: 280px;
        padding: 10px;
        line-height: 81px;
        opacity: 0.9;
      }
      .eject-button {
        width: fit-content;
        align-items: center;
        border-radius: 6px;
        border: none;
        background: #585759;
        box-shadow: 0px 0.5px 1px rgba(0, 0, 0, 0.1), inset 0px 0.5px 0.5px rgba(255, 255, 255, 0.5), 0px 0px 0px 0.5px rgba(0, 0, 0, 0.12);
        color: #DFDEDF;
        user-select: none;
        -webkit-user-select: none;
        touch-action: manipulation;
        position: absolute;
        top: 50%;
        left: 50%;
        z-index: 999;
        transform: translateX(-50%) translateY(-50%);
        line-height: auto;
        height: 100%;
        max-height: 40px;
        cursor: pointer;
      }
      .eject-button:hover {
        box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.5);
      }
      #slideout {
        position: fixed;
        z-index: 999;
        top: 50%;
        right: 0;
        width: 35px;
        -webkit-transition-duration: 0.3s;
        -moz-transition-duration: 0.3s;
        -o-transition-duration: 0.3s;
        transition-duration: 0.3s;
        transform: translateY(-40px);
      }
      #slideout_tab {
        position: relative;
        padding: 18px 9px;
        text-align: center;
        background: #f79548;
        color: #fff;
        cursor:pointer;
        -webkit-border-radius: 0 5px 5px 0;
        -moz-border-radius: 0 5px 5px 0;
        border-radius: 0 5px 5px 0;
        writing-mode: vertical-rl;
        transform: rotate(180deg);
      }
      #slideout_tab:hover {
        box-shadow: 0 0 0 1px #f79548;
      }
      #showblock:checked + #slideout{right: 190px;}
      #showblock{display:none;}
  `;const n=document.createElement("div");n.className="eject-toggle";const o=document.createElement("input");o.type="checkbox",o.checked=d,o.className="toggle-checkbox",o.addEventListener("change",w=>{w.target?.checked?h():x()});const e=document.createElement("div");e.className="toggle-switch";const i=document.createElement("span");i.className="toggle-label",i.innerText="Inspect mode";const c=document.createElement("label");c.className="toggle",n.appendChild(c),c.appendChild(o),c.appendChild(e),c.appendChild(i);const l=document.createElement("input");l.id="showblock",l.type="checkbox";const a=document.createElement("div");a.id="slideout";const r=document.createElement("label");r.id="slideout_tab",r.htmlFor="showblock",r.innerText="INSPECT",a.appendChild(r),a.appendChild(n),document.body.appendChild(l),document.body.appendChild(a),document.head.appendChild(t)},m=function(t,n,o=""){const e=document.createElement("button");if(e.innerText=`Eject ${o}`,e.className="eject-button",e.onclick=async i=>{i.preventDefault(),i.stopPropagation(),confirm(`Do you want to Eject ${o} component?`)&&await p(o)},t.offsetHeight>window.innerHeight&&(e.style.marginTop="60px",e.style.top="0",e.style.transform="translateX(-50%)"),o==="Navbar/Navbar"&&(e.style.left="20%"),o==="Footer/Footer"&&(e.style.left="10%"),["icons/MaximizeIcon/MaximizeIcon","Sidebar/LaunchIcon"].includes(o)&&(e.style.width="100px",e.style.height="auto",e.style.left="0",e.style.transform="none",e.style.maxHeight="none"),o==="Sidebar/MenuContainer"&&(e.style.marginTop="0",e.style.marginBottom="60px",e.style.top="auto",e.style.bottom="0"),t instanceof HTMLImageElement||t instanceof HTMLInputElement){if(!t.parentElement)return;t.parentElement.style.position="relative",t.parentElement.appendChild(e),t.parentElement.appendChild(n)}else t.appendChild(n),t.appendChild(e)},p=async(t,n=!1)=>{const o=`${y}/${encodeURIComponent(t)}?force=${n}`,e=await fetch(v(o)),i=await e.json();[200,404].includes(e.status)&&alert(i.message),e.status===409&&confirm(i.message)&&await p(t,!0)},u=function(){document.querySelector(".eject-button")?.remove(),document.querySelector(".eject-cover")?.remove()},b=function(t){const n=t.dataset.componentName,o=document.createElement("div");o.className="eject-cover",s&&(s.style.outline="none",u()),n==="Search/Popover"?t.style.cssText="outline: 2px solid #ffc9c9":t.style.cssText=`
        outline: 2px solid #ffc9c9;
        position: relative;
      `,s=t,m(s,o,n)},x=function(){s&&(s.style.outline="none",u()),document.removeEventListener("mouseover",f,!1)},h=function(){d=!0,document.addEventListener("mouseover",f,!1)},f=function(t){const n=t.target;n.matches("[data-component-name]")&&b(n)};window.onload=function(){h(),g()}})();
