Current section
Files
Jump to
Current section
Files
priv/static/client.js
(()=>{var H=`<div id="live-debugger-debug-button">
<svg
viewBox="0 0 24 24"
width="24"
height="24"
fill="none"
xmlns="http://www.w3.org/2000/svg"
class="live-debugger-bug-icon"
>
<path
fill-rule="evenodd"
clip-rule="evenodd"
d="M22.0941 20.624C22.5697 20.624 22.9553 20.2385 22.9554 19.7628L22.9556 16.6568C22.9556 16.4283 22.8649 16.2093 22.7034 16.0477C22.5418 15.8862 22.3228 15.7955 22.0944 15.7955L18.3034 15.7955L18.3034 17.5179L21.2331 17.5179L21.2329 19.7627C21.2329 20.2384 21.6185 20.624 22.0941 20.624Z"
fill="currentColor"
/>
<path
fill-rule="evenodd"
clip-rule="evenodd"
d="M22.9823 12.9677C22.9823 12.4921 22.5968 12.1065 22.1211 12.1065L18.3034 12.1065V13.8289H22.1211C22.5968 13.8289 22.9823 13.4433 22.9823 12.9677Z"
fill="currentColor"
/>
<path
fill-rule="evenodd"
clip-rule="evenodd"
d="M22.1385 5.31162C22.6142 5.31159 22.9998 5.69715 22.9998 6.17279L23 9.27886C23 9.50728 22.9093 9.72635 22.7478 9.88787C22.5863 10.0494 22.3672 10.1401 22.1388 10.1401L18.3034 10.1402L18.3164 8.41772L21.2775 8.4177L21.2774 6.1729C21.2773 5.69726 21.6629 5.31165 22.1385 5.31162Z"
fill="currentColor"
/>
<path
fill-rule="evenodd"
clip-rule="evenodd"
d="M1.86148 20.624C1.38585 20.624 1.00024 20.2385 1.00021 19.7628L1 16.6568C0.999985 16.4283 1.09071 16.2093 1.25222 16.0478C1.41373 15.8862 1.6328 15.7955 1.86122 15.7955L5.6836 15.7955L5.6836 17.5179L2.7225 17.5179L2.72265 19.7627C2.72268 20.2384 2.33712 20.624 1.86148 20.624Z"
fill="currentColor"
/>
<path
fill-rule="evenodd"
clip-rule="evenodd"
d="M1.00465 12.9677C1.00465 12.4921 1.39023 12.1065 1.86587 12.1065L5.6836 12.1065L5.68361 13.8289L1.86588 13.8289C1.39024 13.8289 1.00465 13.4434 1.00465 12.9677Z"
fill="currentColor"
/>
<path
fill-rule="evenodd"
clip-rule="evenodd"
d="M1.8619 5.31162C1.38626 5.31159 1.00066 5.69715 1.00062 6.17279L1.00042 9.27886C1.00041 9.50728 1.09113 9.72635 1.25265 9.88787C1.41416 10.0494 1.63322 10.1401 1.86164 10.1401L5.68402 10.1402L5.68403 8.41773L2.72292 8.4177L2.72307 6.1729C2.7231 5.69726 2.33754 5.31165 1.8619 5.31162Z"
fill="currentColor"
/>
<path
fill-rule="evenodd"
clip-rule="evenodd"
d="M16.5822 5.951C16.5563 5.55988 16.4815 5.18216 16.3637 4.82389C15.761 2.9901 14.0347 1.66608 11.9993 1.66608C9.46255 1.66608 7.40614 3.72245 7.40607 6.25914C7.40607 6.07964 7.41637 5.90255 7.4364 5.72842C6.37344 6.4641 5.5006 7.27955 4.95972 7.82907C4.57693 8.21798 4.3604 8.47369 4.3604 8.47369V15.576C4.3604 16.9134 4.75938 18.2352 5.70216 19.1839C6.91489 20.4041 8.85964 21.9501 11.1606 22.2731C11.4426 22.3127 11.7299 22.3339 12.0219 22.3339C12.3121 22.3339 12.5995 22.3101 12.8831 22.266C15.0234 21.9325 16.9448 20.4369 18.1856 19.2336C19.1941 18.2556 19.6354 16.8718 19.6354 15.4671V8.47369C19.6354 8.47369 19.4208 8.21698 19.0408 7.8268C18.5007 7.27223 17.6266 6.44804 16.5597 5.7081C16.5693 5.78844 16.5768 5.86943 16.5822 5.951ZM9.94789 6.25926C9.21504 6.59448 8.48065 7.06772 7.79147 7.60478C7.27937 8.00384 6.83377 8.40537 6.483 8.74437L12.0205 12.0717L17.5232 8.74442C17.1757 8.40464 16.7328 8.00128 16.2228 7.60045C15.5416 7.06516 14.8151 6.59357 14.0886 6.25926H9.94789ZM11.9993 3.38852C13.0618 3.38852 13.9896 3.96582 14.4859 4.82389L9.51244 4.82411C10.0088 3.96592 10.9366 3.38852 11.9993 3.38852ZM11.1606 13.5645L6.08284 10.5134V15.576C6.08284 16.5949 6.38663 17.4291 6.92389 17.9697C8.02405 19.0767 9.53264 20.2139 11.1606 20.5272V13.5645ZM12.8831 20.5143C14.3643 20.1903 15.8444 19.1047 16.9865 17.9971C17.5787 17.4228 17.913 16.5336 17.913 15.4671V10.5216L12.8831 13.5629V20.5143Z"
fill="currentColor"
/>
</svg>
<svg
xmlns="http://www.w3.org/2000/svg"
width="24"
height="24"
viewBox="0 0 24 24"
fill="none"
stroke="#001A72"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
class="lucide lucide-square-dashed-mouse-pointer-icon lucide-square-dashed-mouse-pointer live-debugger-inspect-icon"
>
<path
d="M12.034 12.681a.498.498 0 0 1 .647-.647l9 3.5a.5.5 0 0 1-.033.943l-3.444 1.068a1 1 0 0 0-.66.66l-1.067 3.443a.5.5 0 0 1-.943.033z"
/>
<path d="M5 3a2 2 0 0 0-2 2" />
<path d="M19 3a2 2 0 0 1 2 2" />
<path d="M5 21a2 2 0 0 1-2-2" />
<path d="M9 3h1" />
<path d="M9 21h2" />
<path d="M14 3h1" />
<path d="M3 9v1" />
<path d="M21 9v2" />
<path d="M3 14v1" />
</svg>
</div>
`;function b(e){let t=document.createElement("div");return t.innerHTML=e,t.firstElementChild}function c(e,t={}){let o=new CustomEvent(e,t);document.dispatchEvent(o)}function x(){let e=b(H),t=!1,o=()=>{t?i():c("lvdbg:debug-button-click",{detail:{buttonRect:e.getBoundingClientRect()}})},n=()=>{t=!0,e.style.cursor="grabbing",document.addEventListener("mousemove",l)},i=()=>{t=!1,e.style.cursor="pointer",document.removeEventListener("mousemove",l)},l=u=>{let m=e.offsetWidth,h=e.offsetHeight,p=window.innerWidth-m,g=window.innerHeight-h,v=Math.max(0,Math.min(u.clientX-m/2,p)),r=Math.max(0,Math.min(u.clientY-h/2,g));e.style.left=`${v}px`,e.style.top=`${r}px`,e.style.right="auto",e.style.bottom="auto"},d=()=>{let u=e.getBoundingClientRect();u.top>=0&&u.left>=0&&u.bottom<=window.innerHeight&&u.right<=window.innerWidth||(e.style.left="auto",e.style.top="auto",e.style.right="20px",e.style.bottom="20px")};return e.addEventListener("click",o),document.addEventListener("lvdbg:move-button-click",n),window.addEventListener("resize",()=>d()),e}var V=`<div id="live-debugger-debug-tooltip">
<div
class="live-debugger-tooltip-option"
id="live-debugger-debug-tooltip-open-in-new-tab"
>
<svg
xmlns="http://www.w3.org/2000/svg"
width="16"
height="16"
viewBox="0 0 24 24"
fill="none"
stroke="#001a72"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
class="lucide lucide-square-arrow-out-up-right-icon lucide-square-arrow-out-up-right"
>
<path d="M21 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h6" />
<path d="m21 3-9 9" />
<path d="M15 3h6v6" />
</svg>
<p>Open in new tab</p>
</div>
<div
class="live-debugger-tooltip-option"
id="live-debugger-debug-tooltip-inspect-elements"
>
<svg
xmlns="http://www.w3.org/2000/svg"
width="16"
height="16"
viewBox="0 0 24 24"
fill="none"
stroke="#001a72"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
class="lucide lucide-square-dashed-mouse-pointer-icon lucide-square-dashed-mouse-pointer"
>
<path
d="M12.034 12.681a.498.498 0 0 1 .647-.647l9 3.5a.5.5 0 0 1-.033.943l-3.444 1.068a1 1 0 0 0-.66.66l-1.067 3.443a.5.5 0 0 1-.943.033z"
/>
<path d="M5 3a2 2 0 0 0-2 2" />
<path d="M19 3a2 2 0 0 1 2 2" />
<path d="M5 21a2 2 0 0 1-2-2" />
<path d="M9 3h1" />
<path d="M9 21h2" />
<path d="M14 3h1" />
<path d="M3 9v1" />
<path d="M21 9v2" />
<path d="M3 14v1" />
</svg>
<p>Inspect in new tab</p>
</div>
<div
class="live-debugger-tooltip-option"
id="live-debugger-debug-tooltip-move-button"
>
<svg
xmlns="http://www.w3.org/2000/svg"
width="16"
height="16"
viewBox="0 0 24 24"
fill="none"
stroke="#001a72"
stroke-width="2"
stroke-linecap="round"
stroke-linejoin="round"
class="lucide lucide-move-icon lucide-move"
>
<path d="M12 2v20" />
<path d="m15 19-3 3-3-3" />
<path d="m19 9 3 3-3 3" />
<path d="M2 12h20" />
<path d="m5 9-3 3 3 3" />
<path d="m9 5 3-3 3 3" />
</svg>
<p>Move button</p>
</div>
</div>
`;function C({liveDebuggerURL:e,debugChannel:t}){let o=b(V),n=!1,i=p=>{o.style.display="block";let g=o.getBoundingClientRect(),v=g.width,r=g.height;p.right+v>window.innerWidth?o.style.left=`${p.left-v}px`:o.style.left=`${p.right}px`,p.top+r>window.innerHeight?o.style.top=`${p.bottom-r}px`:o.style.top=`${p.top}px`,n=!0},l=()=>{o.style.display="none",n=!1},d=p=>{let g=p.detail.buttonRect;n?l():i(g)},u=()=>{window.open(e,"_blank"),l()},m=()=>{c("lvdbg:inspect-button-click"),l()},h=()=>{c("lvdbg:move-button-click"),l()};return o.querySelector("#live-debugger-debug-tooltip-open-in-new-tab").addEventListener("click",u),o.querySelector("#live-debugger-debug-tooltip-inspect-elements").addEventListener("click",m),o.querySelector("#live-debugger-debug-tooltip-move-button").addEventListener("click",h),document.addEventListener("lvdbg:debug-button-click",d),document.addEventListener("lvdbg:click-outside-debug-menu",l),t.on("inspect-mode-changed",l),window.addEventListener("resize",()=>{n&&l()}),o}function _(){return new Promise(e=>{let t=document.querySelectorAll("[data-phx-session]"),o={},n=document.querySelector("[data-phx-main]")?.id,i=d=>{le(d)&&(re(o,d.target),de(o,t)&&(l.disconnect(),e({mainSocketID:n,rootSocketIDs:se(o,n)})))},l=new MutationObserver(d=>{d.forEach(i)});t.forEach(d=>{l.observe(d,{attributes:!0})})})}function le(e){return e.type==="attributes"&&e.attributeName==="data-phx-root-id"}function re(e,t){e[t.id]=t.getAttribute("data-phx-root-id")}function de(e,t){return Object.keys(e).length>=t.length}function se(e,t){let o=new Set(Object.values(e));return o.delete(t),[...o]}function U(){let e=document.querySelector('meta[name="live-debugger-config"]');if(e)return e;{let t=`
LiveDebugger meta tag not found!
If you have recently bumped LiveDebugger version, please update your layout according to the instructions in the GitHub README.
You can find it here: https://github.com/software-mansion/live-debugger#installation
`;throw new Error(t)}}function A(e){return e.getAttribute("url")}function O(e){return e.hasAttribute("debug-button")}function E(e,t,o){let n=x(),i=C({liveDebuggerURL:t,debugChannel:o});return O(e)&&(document.body.appendChild(n),document.body.appendChild(i)),o.on("toggle-debug-button",({enabled:l})=>{l?(document.body.appendChild(n),document.body.appendChild(i)):(n.remove(),i.remove())}),document.addEventListener("click",l=>{!n.contains(l.target)&&!i.contains(l.target)&&c("lvdbg:click-outside-debug-menu")}),{debugButton:n,debugMenu:i}}var y="live-debugger-highlight-element",ue="live-debugger-highlight-pulse-element",ce=["#ffe78080","#ffe78060","#ffe78030","#ffe78000"],ae=["#87CCE880","#87CCE860","#87CCE830","#87CCE800"],j=e=>{if(!e)return!1;if(e.checkVisibility)return e.checkVisibility();let t=window.getComputedStyle(e);return t.display!=="none"&&t.visibility!=="hidden"&&t.opacity!=="0"};function W(e){return e==="LiveComponent"?ae:ce}function Z(e,t,o){let n=e.getBoundingClientRect(),i=document.createElement("div");return i.id=o,i.dataset.attr=t.attr,i.dataset.val=t.val,i.style.position="absolute",i.style.top=`${n.top+window.scrollY}px`,i.style.left=`${n.left+window.scrollX}px`,i.style.width=`${e.offsetWidth}px`,i.style.height=`${e.offsetHeight}px`,i.style.backgroundColor=W(t.type)[0],i.style.zIndex="10000",i.style.pointerEvents="none",i}function pe(){let e=document.getElementById(y);e&&e.remove(),c("lvdbg:remove-tooltip")}function P({detail:e}){let t=document.getElementById(y);if(t){t.remove(),c("lvdbg:remove-tooltip");let n=e.attr===void 0||e.val===void 0,i=t.dataset.val===e.val;if(n||i)return}let o=document.querySelector(`[${e.attr}="${e.val}"]`);j(o)&&(t=Z(o,e,y),document.body.appendChild(t),me(e))}function ge(){let e=document.getElementById(y);if(e){let t=document.querySelector(`[${e.dataset.attr}="${e.dataset.val}"]`),o=t.getBoundingClientRect();e.style.top=`${o.top+window.scrollY}px`,e.style.left=`${o.left+window.scrollX}px`,e.style.width=`${t.offsetWidth}px`,e.style.height=`${t.offsetHeight}px`}}function z({detail:e}){let t=document.querySelector(`[${e.attr}="${e.val}"]`);if(j(t)){let o=Z(t,e,ue);document.body.appendChild(o);let n=o.offsetWidth,i=o.offsetHeight,l=W(e.type);o.animate([{width:`${n}px`,height:`${i}px`,transform:"translate(0, 0)",backgroundColor:l[1]},{width:`${n+20}px`,height:`${i+20}px`,transform:"translate(-10px, -10px)",backgroundColor:l[2]},{width:`${n+40}px`,height:`${i+40}px`,transform:"translate(-20px, -20px)",backgroundColor:l[3]}],{duration:500,iterations:1,delay:200}).onfinish=()=>{o.remove()}}}function me(e){if(!["module","type","id_key","id_value"].every(i=>e.hasOwnProperty(i)))return;let n={detail:{module:e.module,type:e.type,id_key:e.id_key,id_value:e.id_value}};c("lvdbg:show-tooltip",n)}function L(e){document.addEventListener("lvdbg:inspect-highlight",P),document.addEventListener("lvdbg:inspect-pulse",z),document.addEventListener("lvdbg:inspect-clear",pe),e.on("highlight",t=>P({detail:t})),e.on("pulse",t=>z({detail:t})),window.addEventListener("resize",ge)}var a=[];for(let e=0;e<256;++e)a.push((e+256).toString(16).slice(1));function N(e,t=0){return(a[e[t+0]]+a[e[t+1]]+a[e[t+2]]+a[e[t+3]]+"-"+a[e[t+4]]+a[e[t+5]]+"-"+a[e[t+6]]+a[e[t+7]]+"-"+a[e[t+8]]+a[e[t+9]]+"-"+a[e[t+10]]+a[e[t+11]]+a[e[t+12]]+a[e[t+13]]+a[e[t+14]]+a[e[t+15]]).toLowerCase()}var k,he=new Uint8Array(16);function I(){if(!k){if(typeof crypto>"u"||!crypto.getRandomValues)throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");k=crypto.getRandomValues.bind(crypto)}return k(he)}var ve=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),M={randomUUID:ve};function fe(e,t,o){if(M.randomUUID&&!t&&!e)return M.randomUUID();e=e||{};let n=e.random??e.rng?.()??I();if(n.length<16)throw new Error("Random bytes length must be >= 16");if(n[6]=n[6]&15|64,n[8]=n[8]&63|128,t){if(o=o||0,o<0||o+16>t.length)throw new RangeError(`UUID byte range ${o}:${o+15} is out of buffer bounds`);for(let i=0;i<16;++i)t[o+i]=n[i];return t}return N(n)}var D=fe;function S(e,t){let o=be();e.push("window-initialized",{window_id:o,socket_id:t})}function be(){let e=window.name;if(e)return e;let t=D();return window.name=t,t}function B(e,t,o){let n=e.replace(/^http/,"ws")+"/client",i=new window.Phoenix.Socket(n,{params:{socketID:t,rootSocketIDs:o}});i.connect();let l=i.channel(`client:${t}`);return l.join().receive("ok",()=>{S(l,t),console.log("LiveDebugger debug connection established!")}).receive("error",d=>{console.error(`LiveDebugger was unable to establish websocket debug connection! Browser features will not work:
`,d)}),{debugSocket:i,debugChannel:l}}function $({baseURL:e,debugChannel:t,socketID:o}){let n=!1,i=null,l=[];t.on("found-node-element",r=>{xe({module:r.module,type:r.type,id_key:r.id_key,id_value:r.id_value})}),t.on("inspect-mode-changed",r=>{r.inspect_mode?(v(),l.push(r.pid)):(l=l.filter(s=>s!==r.pid),l.length===0&&g())});let d=r=>{let s=Y(r.target);if(!s)return;let f=K(s);if(f.val===i)return;let w=s.type=="LiveComponent"?s.element.dataset.phxComponent:s.element.id;t.push("request-node-element",{root_socket_id:o,socket_id:s.phxId,type:s.type,id:w}),i=f.val,we({attr:f.attr,val:f.val,type:s.type})},u=r=>{r.preventDefault(),r.stopPropagation();let s=Y(r.target);if(!s)return;let f=K(s);ye({attr:f.attr,val:f.val,type:s.type});let w=Ee(e,s);l.length===0?window.open(w,"_blank"):l.forEach(oe=>{t.push("element-inspected",{pid:oe,url:w})}),l=[],g()},m=r=>{r.preventDefault(),l.forEach(s=>{t.push("inspect-mode-changed",{inspect_mode:!1,pid:s})}),l=[],g()},h=r=>{r.key==="Escape"&&(l.forEach(s=>{t.push("inspect-mode-changed",{inspect_mode:!1,pid:s})}),l=[],g())},p=()=>{X(),i=null},g=()=>{if(!n)return;n=!1,i=null;let r=document.getElementById("live-debugger-debug-button");r&&r.classList.remove("live-debugger-inspect-mode"),X(),Ce(),document.body.classList.remove("live-debugger-inspect-mode"),document.body.removeEventListener("click",u),document.body.removeEventListener("mouseover",d),document.removeEventListener("mouseleave",p),document.removeEventListener("contextmenu",m),document.removeEventListener("keydown",h)},v=()=>{if(n)return;n=!0;let r=document.getElementById("live-debugger-debug-button");r&&r.classList.add("live-debugger-inspect-mode"),document.body.classList.add("live-debugger-inspect-mode"),document.body.addEventListener("click",u),document.body.addEventListener("mouseover",d),document.body.addEventListener("mouseleave",p),document.addEventListener("contextmenu",m),document.addEventListener("keydown",h)};document.addEventListener("lvdbg:inspect-button-click",r=>{setTimeout(v)})}function we(e){c("lvdbg:inspect-highlight",{detail:e})}function ye(e){c("lvdbg:inspect-pulse",{detail:e})}function X(){c("lvdbg:inspect-clear")}function xe(e){c("lvdbg:show-tooltip",{detail:e})}function Ce(){c("lvdbg:remove-tooltip")}function Y(e){let t=e.closest("[data-phx-session]"),o=e.closest("[data-phx-component]");if(!t)return null;let n=t.getAttribute("data-phx-root-id");return o&&t.contains(o)?{element:o,type:"LiveComponent",phxRootId:n,phxId:t.id}:{element:t,type:"LiveView",phxRootId:n,phxId:t.id}}function Ee(e,{element:t,type:o,phxRootId:n,phxId:i}){let l=new URL(`${e}/redirect/${i}`);return n!==i&&l.searchParams.set("root_id",n),o==="LiveComponent"&&l.searchParams.set("node_id",t.dataset.phxComponent),l}function K({type:e,element:t,phxId:o}){return e==="LiveComponent"?{attr:"data-phx-id",val:`c${t.dataset.phxComponent}-${o}`}:{attr:"id",val:t.id}}var G=`<div id="live-debugger-tooltip" class="live-debugger-inspection-tooltip">
<div class="live-debugger-tooltip-content">
<div class="live-debugger-tooltip-type-wrapper">
<div class="live-debugger-tooltip-icon-component">
<svg
width="16"
height="16"
viewBox="0 0 24 24"
fill="none"
xmlns="http://www.w3.org/2000/svg"
stroke="#001a72"
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="2"
>
<path
d="M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z"
/>
<path d="m3.3 7 8.7 5 8.7-5" />
<path d="M12 22V12" />
</svg>
</div>
<div class="live-debugger-tooltip-icon-view">
<svg
xmlns="http://www.w3.org/2000/svg"
width="16"
height="16"
viewBox="0 0 24 24"
fill="none"
stroke="#001a72"
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="2"
>
<path d="m10 9-3 3 3 3" />
<path d="m14 15 3-3-3-3" />
<rect x="3" y="3" width="18" height="18" rx="2" />
</svg>
</div>
<div class="live-debugger-tooltip-module"></div>
</div>
<div class="live-debugger-tooltip-info">
<div class="live-debugger-tooltip-info-item type-info">
<span class="label">Type:</span>
<span class="value">
<span class="type-text"></span>
<span class="live-debugger-type-square"></span>
</span>
</div>
<div class="live-debugger-tooltip-info-item id-info">
<span class="label"></span>
<span class="value"></span>
</div>
</div>
</div>
</div>
`;function ke(e,t){let o=e.querySelector(".live-debugger-tooltip-icon-component");o.style.display=t.type==="LiveComponent"?"block":"none";let n=e.querySelector(".live-debugger-tooltip-icon-view");n.style.display=t.type==="LiveView"?"block":"none"}function Ie(e,t){let o=e.querySelector(".type-info"),n=o.querySelector(".type-text"),i=o.querySelector(".live-debugger-type-square");n.textContent=t.type,i.style.backgroundColor=t.type==="LiveComponent"?"#87CCE8":"#ffe780"}function Me(e,t){let o=e.querySelector(".id-info"),n=o.querySelector(".label"),i=o.querySelector(".value");n.textContent=`${t.id_key}:`,i.textContent=t.id_value}function De(e,t){Ie(e,t),Me(e,t)}function Se(e,t){let o=e.querySelector(".live-debugger-tooltip-module");o.textContent=t.module||"Element"}function F(e){let t=b(G);return Se(t,e),ke(t,e),De(t,e),document.body.appendChild(t),t}function Be(e,t){let o=e.top-t.height-10,n=e.left;return{top:o,left:n}}function $e(e,t,o,n){return e<10&&(e=t.bottom+10),e+o.height>n-10&&(e=t.top-o.height-10,e<10&&(e=10)),e<10&&(e=10),e+o.height>n-10&&(e=n-o.height-10),e}function Te(e,t,o){return e+t.width>o-10&&(e=o-t.width-10),e<10&&(e=10),e<10&&(e=10),e+t.width>o-10&&(e=o-t.width-10),e}function qe(e,t,o){e.style.top=`${t+window.scrollY}px`,e.style.left=`${o+window.scrollX}px`}function T(e,t){if(!t||!e)return;let o=t.getBoundingClientRect(),n=e.getBoundingClientRect(),i=window.innerWidth,l=window.innerHeight,{top:d,left:u}=Be(o,n);return d=$e(d,o,n,l),u=Te(u,n,i),qe(e,d,u),{top:d,left:u,tooltipRect:n}}function Re(e){let t=e.querySelector(".live-debugger-tooltip-arrow");t&&t.remove()}function He(){let e=document.createElement("div");return e.className="live-debugger-tooltip-arrow",e}function Ve(e,t,o){let n=e+t.height,i=o.top;return n<i?"down":"up"}function q(e,t,o,n){Re(e);let i=He();Ve(o,n,t)==="down"?i.classList.add("live-debugger-tooltip-arrow-down"):i.classList.add("live-debugger-tooltip-arrow-up"),e.appendChild(i)}var Q="live-debugger-tooltip",_e="live-debugger-highlight-element";function ee(){return document.getElementById(_e)}function te(){let e=document.getElementById(Q);e&&e.remove()}function Ue(e){let t=ee();if(!t)return;te();let o=F(e),n=T(o,t);n&&q(o,t.getBoundingClientRect(),n.top,n.tooltipRect)}function J(){let e=document.getElementById(Q),t=ee();if(e&&t){let o=T(e,t);o&&q(e,t.getBoundingClientRect(),o.top,o.tooltipRect)}}function Ae(e){Ue(e.detail)}function Oe(){te()}function Pe(){window.addEventListener("resize",J),window.addEventListener("scroll",J),document.addEventListener("lvdbg:show-tooltip",Ae),document.addEventListener("lvdbg:remove-tooltip",Oe)}function R(){Pe()}window.document.addEventListener("DOMContentLoaded",async()=>{let e=U(),t=A(e),{mainSocketID:o,rootSocketIDs:n}=await _();if(o?n=[]:[o,...n]=n,o){let i=`${t}/redirect/${o}`,{debugChannel:l}=B(t,o,n);l.on("ping",d=>{console.log("Received ping",d),l.push("pong",d)}),$({baseURL:t,debugChannel:l,socketID:o}),R(),E(e,i,l),L(l)}console.info(`LiveDebugger available at: ${t}`)});})();