"use strict";var visualEditOverlay=(()=>{var V=Object.defineProperty;var fe=Object.getOwnPropertyDescriptor;var ge=Object.getOwnPropertyNames;var Te=Object.prototype.hasOwnProperty;var he=(t,e)=>{for(var o in e)V(t,o,{get:e[o],enumerable:!0})},Ae=(t,e,o,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of ge(e))!Te.call(t,a)&&a!==o&&V(t,a,{get:()=>e[a],enumerable:!(r=fe(e,a))||r.enumerable});return t};var be=t=>Ae(V({},"__esModule",{value:!0}),t);var De={};he(De,{CONFIG:()=>S,activateDebugMode:()=>H,badgeManager:()=>b,blockInteractiveEvent:()=>ee,deactivateDebugMode:()=>G,handleBadgeReposition:()=>R,init:()=>J,setInteractionMode:()=>X,state:()=>n});var T={MODE_ACTIVATED:"DEBUG_MODE_ACTIVATED",MODE_DEACTIVATED:"DEBUG_MODE_DEACTIVATED",ELEMENT_SELECTED:"ELEMENT_SELECTED",ELEMENT_DESELECTED:"ELEMENT_DESELECTED",CHANGES_ERROR:"CHANGES_ERROR",INTERACTION_MODE_CHANGED:"INTERACTION_MODE_CHANGED",INLINE_EDIT_START:"INLINE_EDIT_START",INLINE_EDIT_CHANGE:"INLINE_EDIT_CHANGE",INLINE_EDIT_END:"INLINE_EDIT_END",INLINE_EDIT_ERROR:"INLINE_EDIT_ERROR"},x={ACTIVATE:"ACTIVATE",DEACTIVATE:"DEACTIVATE",CLEAR_SELECTION:"CLEAR_SELECTION",APPLY_CHANGES:"APPLY_CHANGES",SET_INTERACTION_MODE:"SET_INTERACTION_MODE",ENABLE_INLINE_EDIT:"ENABLE_INLINE_EDIT",DISABLE_INLINE_EDIT:"DISABLE_INLINE_EDIT"},L={SITE_DEBUG:"SITE_DEBUG",DEBUG_COMMAND:"DEBUG_COMMAND"};var _=class{constructor(){this.GAP=8,this.VIEWPORT_PADDING=8,this.removalTimeouts=new Map}createBadge(e,o="hover"){let r=document.createElement("div");return r.className=`debug-badge ${o}`,r.textContent=e,r.style.opacity="0",r.setAttribute("role","tooltip"),r.setAttribute("aria-live","polite"),r.id=`debug-badge-${Date.now()}-${Math.random().toString(36).substring(2,11)}`,document.body.appendChild(r),r}calculatePosition(e,o){let r=e.getBoundingClientRect();if(r.top===0&&r.left===0&&r.bottom===0&&r.right===0){let s=e.parentElement;for(;s;){let d=s.getBoundingClientRect();if(d.top!==0||d.left!==0||d.bottom!==0||d.right!==0){r=d;break}s=s.parentElement}}let a=o.getBoundingClientRect(),E=[{side:"top",calc:()=>({top:r.top-a.height-this.GAP,left:r.left-4.5}),fits:s=>s.top>=this.VIEWPORT_PADDING},{side:"bottom",calc:()=>({top:r.bottom+this.GAP,left:r.left-4.5}),fits:s=>s.top+a.height<=window.innerHeight-this.VIEWPORT_PADDING},{side:"left",calc:()=>({top:r.top,left:r.left-a.width-this.GAP}),fits:s=>s.left>=this.VIEWPORT_PADDING},{side:"right",calc:()=>({top:r.top,left:r.right+this.GAP}),fits:s=>s.left+a.width<=window.innerWidth-this.VIEWPORT_PADDING}];for(let s of E){let d=s.calc();if((s.side==="top"||s.side==="bottom")&&(d.left+a.width>window.innerWidth-this.VIEWPORT_PADDING&&(d.left=window.innerWidth-a.width-this.VIEWPORT_PADDING),d.left<this.VIEWPORT_PADDING&&(d.left=this.VIEWPORT_PADDING)),(s.side==="left"||s.side==="right")&&(d.top+a.height>window.innerHeight-this.VIEWPORT_PADDING&&(d.top=window.innerHeight-a.height-this.VIEWPORT_PADDING),d.top<this.VIEWPORT_PADDING&&(d.top=this.VIEWPORT_PADDING)),s.fits(d))return{...d,side:s.side}}let p=E[0].calc();return{top:Math.max(this.VIEWPORT_PADDING,Math.min(p.top,window.innerHeight-a.height-this.VIEWPORT_PADDING)),left:Math.max(this.VIEWPORT_PADDING,Math.min(p.left,window.innerWidth-a.width-this.VIEWPORT_PADDING)),side:"constrained"}}positionBadge(e,o,r=!0){let a=this.calculatePosition(e,o);o.style.top=`${a.top}px`,o.style.left=`${a.left}px`,o.dataset.side=a.side,r&&requestAnimationFrame(()=>{o.style.opacity="1"})}showHoverBadge(e,o,r=!1){let a=r?"dynamic":"hover",E=this.createBadge(o,a);return this.positionBadge(e,E),E}showSelectedBadge(e,o,r=!1){let a=r?"selected-dynamic":"selected",E=this.createBadge(o,a);return this.positionBadge(e,E),E}removeBadge(e){if(e&&(this.removalTimeouts.has(e)&&(clearTimeout(this.removalTimeouts.get(e)),this.removalTimeouts.delete(e)),e.parentElement)){e.style.opacity="0";let o=setTimeout(()=>{e.parentElement&&e.parentElement.removeChild(e),this.removalTimeouts.delete(e)},150);this.removalTimeouts.set(e,o)}}cleanup(){this.removalTimeouts.forEach(e=>clearTimeout(e)),this.removalTimeouts.clear(),document.querySelectorAll(".debug-badge").forEach(e=>{e.parentElement&&e.parentElement.removeChild(e)})}updateBadgePosition(e,o){o&&e&&this.positionBadge(e,o,!1)}};function ne(t){if(document.getElementById("visual-edit-overlay-styles"))return;let e=document.createElement("style");e.id="visual-edit-overlay-styles",e.textContent=`
    /* Hover state - dotted lines (editable elements) */
    [data-debug-hover]:not([data-debug-selected]):not([data-debug-dynamic]) {
        outline: 2px dotted #5288CC !important;
        outline-offset: 2px !important;
    }

    /* Hover state for dynamic elements (not editable) - orange/warning color */
    [data-debug-hover][data-debug-dynamic]:not([data-debug-selected]) {
        outline: 2px dotted #FF8C42 !important;
        outline-offset: 2px !important;
    }

    /* Expression span hover \u2014 override display:contents so outline is visible */
    [data-debug-hover][data-ve-dynamic] {
        display: inline !important;
        outline: 2px dotted #5288CC !important;
        outline-offset: 1px !important;
    }

    /* Expression span selected \u2014 override display:contents so outline is visible */
    [data-debug-selected][data-ve-dynamic] {
        display: inline !important;
        outline: 1.5px solid #2764EB !important;
        outline-offset: 1px !important;
    }

    /* Selected state - solid lines */
    [data-debug-selected]:not([data-debug-dynamic]) {
        outline: 1.5px solid #2764EB !important;
        outline-offset: 3px !important;
        box-shadow: 0 0 0 1px rgba(39, 100, 235, 0.3), inset 0 0 0 999px rgba(39, 100, 235, 0.05) !important;
    }

    /* Selected state for dynamic elements - orange solid */
    [data-debug-selected][data-debug-dynamic] {
        outline: 1.5px solid #FF8C42 !important;
        outline-offset: 3px !important;
        box-shadow: 0 0 0 1px rgba(255, 140, 66, 0.3), inset 0 0 0 999px rgba(255, 140, 66, 0.05) !important;
    }

    /* Badge element styles (created dynamically in JS) */
    .debug-badge {
        position: fixed;
        z-index: ${t};
        pointer-events: none;
        padding: 4px 6px 4px 22px;
        border-radius: 6px;
        font-size: 11px;
        font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
        font-weight: bold;
        white-space: nowrap;
        background-repeat: no-repeat;
        background-position: 4px center;
        background-size: 14px 14px;
        transition: top 0.15s ease-out, left 0.15s ease-out, opacity 0.15s ease-out;
    }

    /* Badge variants */
    .debug-badge.hover {
        background-color: #DBEAFE;
        border: 1px solid #B5CBF6;
        color: #1E4ED8;
        background-image: url('data:image/svg+xml;utf8,<svg width="14" height="14" viewBox="0 0 14 14" fill="none" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" clip-rule="evenodd" d="M5.93934 1.06066L7 0L8.06066 1.06066L12.9393 5.93934L14 7L12.9393 8.06066L8.06066 12.9393L7 14L5.93934 12.9393L1.06066 8.06066L0 7L1.06066 5.93934L5.93934 1.06066ZM2.12132 7L7 11.8787L11.8787 7L7 2.12132L2.12132 7Z" fill="%231E4ED8"/></svg>');
    }

    .debug-badge.dynamic {
        background-color: #FFF5E6;
        border: 1px solid #FFCC99;
        color: #CC5500;
        background-image: url('data:image/svg+xml;utf8,<svg width="14" height="14" viewBox="0 0 14 14" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M7 0L8.5 5.5L14 7L8.5 8.5L7 14L5.5 8.5L0 7L5.5 5.5L7 0Z" fill="%23CC5500"/></svg>');
    }

    .debug-badge.selected {
        background-color: #1E4ED8;
        border: 1px solid #1E4ED8;
        color: white;
        background-image: url('data:image/svg+xml;utf8,<svg width="14" height="14" viewBox="0 0 14 14" fill="none" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" clip-rule="evenodd" d="M5.93934 1.06066L7 0L8.06066 1.06066L12.9393 5.93934L14 7L12.9393 8.06066L8.06066 12.9393L7 14L5.93934 12.9393L1.06066 8.06066L0 7L1.06066 5.93934L5.93934 1.06066ZM2.12132 7L7 11.8787L11.8787 7L7 2.12132L2.12132 7Z" fill="white"/></svg>');
    }

    .debug-badge.selected-dynamic {
        background-color: #FF8C42;
        border: 1px solid #FF8C42;
        color: white;
        background-image: url('data:image/svg+xml;utf8,<svg width="14" height="14" viewBox="0 0 14 14" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M7 0L8.5 5.5L14 7L8.5 8.5L7 14L5.5 8.5L0 7L5.5 5.5L7 0Z" fill="white"/></svg>');
    }

    /* Ensure debug badges are always visible */
    .debug-badge {
        pointer-events: none !important;
        display: block !important;
    }
  `,document.head.appendChild(e)}var i={FILE_NAME:"x-file-name",LINE_NUMBER:"x-line-number",COLUMN:"x-column",COMPONENT:"x-component",ID:"x-id",DYNAMIC:"x-dynamic",EXCLUDED:"x-excluded",SOURCE_TYPE:"x-source-type",SOURCE_VAR:"x-source-var",SOURCE_FILE:"x-source-file",SOURCE_FILE_ABS:"x-source-file-abs",SOURCE_LINE:"x-source-line",SOURCE_PATH:"x-source-path",SOURCE_EDITABLE:"x-source-editable",ARRAY_VAR:"x-array-var",ARRAY_FILE:"x-array-file",ARRAY_LINE:"x-array-line",ARRAY_ITEM_PARAM:"x-array-item-param",ARRAY_INLINE:"x-array-inline",VE_DYNAMIC:"data-ve-dynamic"},Ie=[i.FILE_NAME,i.LINE_NUMBER,i.COMPONENT];var N={STATIC_LOCAL:"static-local",STATIC_IMPORTED:"static-imported",PROP:"prop",STATE:"state",COMPUTED:"computed",TEMPLATE:"template",EXTERNAL:"external",UNKNOWN:"unknown"},re=new Set([N.STATIC_LOCAL,N.STATIC_IMPORTED]),O=new Set([N.PROP,N.STATE,N.COMPUTED,N.EXTERNAL]);function F(t,e){return O.has(t)?!1:re.has(t)?e==="true":!1}var C={TEXT_CONTENT:"textContent",VARIABLE_EDIT:"variableEdit",READONLY:"readonly",SHARED_SOURCE:"sharedSource",CLASS_NAME:"className",CONTENT:"content"};var k={[i.VE_DYNAMIC]:"true",[i.EXCLUDED]:"true"},$="display:contents";function P(t){let e="";for(let o of t.childNodes)o.nodeType===Node.TEXT_NODE&&(e+=o.textContent);return e.trim()}function W(t){let e=[];return!t||!t.childNodes||t.childNodes.forEach(o=>{if(o.nodeType===Node.TEXT_NODE){let r=o.textContent||"";r.trim()&&e.push({type:"text",text:r})}else if(o.nodeType===Node.ELEMENT_NODE){let r=o,a=r.tagName?r.tagName.toLowerCase():"";a==="br"?e.push({type:"dynamic",text:`
`}):r.hasAttribute&&r.hasAttribute("data-ve-dynamic")?e.push({type:"dynamic",text:r.textContent||""}):e.push({type:"element",text:r.textContent||"",tagName:a})}}),e}function oe(t,e){if(e.trim()===e){let o=t.match(/^(\s*)/)[1],r=t.match(/(\s*)$/)[1];return o+e+r}return e}function ie(t){let e=[],o=[];if(t.elementId)try{if(t.isMultiElement){let r=document.querySelectorAll(`[${i.ID}="${CSS.escape(t.elementId)}"]`),a=Array.from(r).filter(Boolean);if(o=a,t.arrayIndex!==void 0&&t.arrayIndex!==null){let E=a[t.arrayIndex];if(E)e=[E];else{h({action:T.CHANGES_ERROR,error:`Element at arrayIndex ${t.arrayIndex} not found`,elementId:t.elementId,arrayIndex:t.arrayIndex});return}}else e=a}else{let r=document.querySelector(`[${i.ID}="${CSS.escape(t.elementId)}"]`);if(!r){h({action:T.CHANGES_ERROR,error:`Element not found: ${i.ID}="${t.elementId}"`,elementId:t.elementId});return}e=[r],o=[r]}}catch(r){h({action:T.CHANGES_ERROR,error:`Invalid element selector: ${r.message}`,elementId:t.elementId});return}else{if(!n.selectedElement){h({action:T.CHANGES_ERROR,error:"No element selected and no elementId provided"});return}e=[n.selectedElement],o=[n.selectedElement]}if(e.length===0){h({action:T.CHANGES_ERROR,error:"No elements found",elementId:t.elementId});return}o.length>0&&o[0].hasAttribute(i.VE_DYNAMIC)&&o[0].getAttribute(i.SOURCE_EDITABLE)==="true"&&(o=o.map(r=>r.parentElement).filter(Boolean));try{e.forEach(r=>{let a=!t.isMultiElement||t.arrayIndex!==void 0&&t.arrayIndex!==null,E=Array.isArray(t.textParts);if((E||t.textContent!==void 0)&&a){let p=r.children&&r.children.length>0;if(E){let s=t.textParts,d=[];for(let l of r.childNodes)l.nodeType===Node.TEXT_NODE&&l.textContent&&l.textContent.trim()&&d.push(l.textContent);if(d.length===s.length){let l=!0;for(let m=0;m<s.length;m++)if(d[m].trim()!==(s[m]||"").trim()){l=!1;break}if(l)return}if(r.querySelector("[data-ve-dynamic]")!==null){let l=W(r),m=[];for(let u of r.childNodes)u.nodeType===Node.ELEMENT_NODE&&u.hasAttribute&&!u.hasAttribute("data-ve-dynamic")&&m.push(u.cloneNode(!0));for(;r.firstChild;)r.removeChild(r.firstChild);let f=0,I=0;for(let u of l)if(u.type==="text"){let g=s[f]??"";if(f++,g.trim()){let A=document.createTextNode(g);r.appendChild(A)}}else if(u.type==="dynamic"){let g=document.createElement("span");Object.entries(k).forEach(([A,v])=>{g.setAttribute(A,v)}),g.style.cssText=$,g.textContent=u.text,r.appendChild(g)}else u.type==="element"&&I<m.length&&(r.appendChild(m[I]),I++);if(f<s.length)for(let u=f;u<s.length;u++){let g=s[u]??"";if(g.trim()){let A=document.createTextNode(g);r.appendChild(A)}}}else{let l=[];for(let m of r.childNodes)m.nodeType===Node.TEXT_NODE&&m.textContent&&m.textContent.trim()&&l.push(m);for(let m=0;m<Math.min(l.length,s.length);m++)l[m].textContent=oe(l[m].textContent,s[m]??"");if(s.length>l.length)for(let m=l.length;m<s.length;m++){let f=s[m]??"";f.trim()&&r.appendChild(document.createTextNode(f))}if(s.length<l.length)for(let m=s.length;m<l.length;m++)l[m].textContent=""}}else if(!p)r.textContent=t.textContent;else{let s=Array.from(r.childNodes).filter(c=>c.nodeType===Node.TEXT_NODE),d=s.find(c=>c.textContent&&c.textContent.trim().length>0)||s[0];if(d)d.textContent=oe(d.textContent,t.textContent);else{let c=document.createTextNode(t.textContent);r.insertBefore(c,r.firstChild||null)}}}t.id!==void 0&&!t.isMultiElement&&(t.id?r.id=t.id:r.removeAttribute("id"))}),o.forEach(r=>{t.className!==void 0&&(r.className=t.className),t.attributes&&typeof t.attributes=="object"&&Object.entries(t.attributes).forEach(([a,E])=>{a.startsWith("x-")||(E?r.setAttribute(a,E):r.removeAttribute(a))})})}catch(r){h({action:T.CHANGES_ERROR,error:r.message,elementId:t.elementId})}}function w(t){if(t.getAttribute(i.DYNAMIC)==="true")return!0;let e=t.getAttribute(i.ID);return!!(e&&document.querySelectorAll(`[${i.ID}="${CSS.escape(e)}"]`).length>1)}function M(t){let e={isDynamic:!1,isEditable:!0,editType:C.TEXT_CONTENT,sourceInfo:null},o=t.getAttribute(i.DYNAMIC),r=t.getAttribute(i.ID),a=1;if(r&&(a=document.querySelectorAll(`[${i.ID}="${CSS.escape(r)}"]`).length),e.isDynamic=o==="true"||a>1,!e.isDynamic&&t.getAttribute(i.SOURCE_EDITABLE)!=="true")return e;let E=t.getAttribute(i.SOURCE_TYPE),p=t.getAttribute(i.SOURCE_EDITABLE);e.sourceInfo={type:E||null,varName:t.getAttribute(i.SOURCE_VAR)||null,file:t.getAttribute(i.SOURCE_FILE)||null,fileAbs:t.getAttribute(i.SOURCE_FILE_ABS)||null,line:t.getAttribute(i.SOURCE_LINE)||null,path:t.getAttribute(i.SOURCE_PATH)||null,editable:p==="true",arrayVar:t.getAttribute(i.ARRAY_VAR)||null,arrayFile:t.getAttribute(i.ARRAY_FILE)||null,arrayLine:t.getAttribute(i.ARRAY_LINE)||null,itemParam:t.getAttribute(i.ARRAY_ITEM_PARAM)||null,arrayInline:t.getAttribute(i.ARRAY_INLINE)||null};let s=Array.from(t.children||[]).some(l=>l.hasAttribute&&l.hasAttribute(i.VE_DYNAMIC)),d=Array.from(t.childNodes||[]).some(l=>l.nodeType===Node.TEXT_NODE&&l.textContent.trim());if(s&&d)return e.sourceInfo?.arrayVar?(e.isEditable=!1,e.editType=C.READONLY,e):(e.isEditable=!0,e.editType=C.TEXT_CONTENT,e);if(p==="true"?(e.isEditable=!0,e.editType=C.VARIABLE_EDIT):E&&F(E,p??void 0)?(e.isEditable=!0,e.editType=C.VARIABLE_EDIT):E&&O.has(E)?(e.isEditable=!1,e.editType=C.READONLY):E===N.STATIC_LOCAL||E===N.STATIC_IMPORTED?(e.isEditable=!1,e.editType=C.READONLY):(e.isEditable=!1,e.editType=C.READONLY),e.isEditable&&e.sourceInfo){let l=Ce(t);l.isShared&&(e.isEditable=!1,e.editType=C.SHARED_SOURCE,e.sourceInfo.isSharedSource=!0,e.sourceInfo.sharedCount=l.sharedCount)}return e}function Ce(t){let e=t.getAttribute(i.SOURCE_VAR),o=t.getAttribute(i.SOURCE_FILE_ABS),r=t.getAttribute(i.SOURCE_PATH),a=t.getAttribute(i.ARRAY_VAR),E=t.getAttribute(i.ARRAY_FILE),p=t.getAttribute(i.ID);if(!e)return{isShared:!1,sharedCount:0};let s=0,d=new Set,c=t.parentElement;for(;c;){let u=c.getAttribute(i.ID);u&&d.add(u),c=c.parentElement}let l=null,m=null,f=t.parentElement;for(;f;){let u=f.getAttribute(i.ID);if(u)if(document.querySelectorAll(`[${i.ID}="${CSS.escape(u)}"]`).length>1)l=f,m=u;else break;f=f.parentElement}function I(u,g){if(u===t||p&&g===p||t.contains(u)||u.contains(t)||g&&d.has(g)||l&&l.contains(u))return!0;if(m){let A=u.parentElement;for(;A;){if(A.getAttribute(i.ID)===m)return!0;A=A.parentElement}}return!1}if(o){let u=`[${i.SOURCE_VAR}="${e}"][${i.SOURCE_FILE_ABS}="${CSS.escape(o)}"]`;r&&(u+=`[${i.SOURCE_PATH}="${r}"]`),document.querySelectorAll(u).forEach(A=>{let v=A.getAttribute(i.ID);I(A,v)||s++})}if(a&&E&&r){let u=`[${i.ARRAY_VAR}="${a}"][${i.ARRAY_FILE}="${CSS.escape(E)}"][${i.SOURCE_PATH}="${r}"]`;document.querySelectorAll(u).forEach(A=>{let v=A.getAttribute(i.ID);I(A,v)||s++})}return{isShared:s>0,sharedCount:s}}function B(t){let e=t.getAttribute(i.ID);if(!e)return null;let o=document.querySelectorAll(`[${i.ID}="${CSS.escape(e)}"]`);if(o.length<=1)return null;let r=Array.from(o).indexOf(t);return r>=0?r:null}function ae(t){let e=t.target;h({action:T.INLINE_EDIT_CHANGE,elementId:e.getAttribute(i.ID),textContent:e.textContent})}function se(t){t.key==="Enter"&&!t.shiftKey?(t.preventDefault(),y(!0)):t.key==="Escape"&&(t.preventDefault(),y(!1))}function le(t){setTimeout(()=>{n.inlineEditElement&&document.activeElement!==n.inlineEditElement&&y(!0)},100)}function de(t){n.inlineEditElement&&y(!1);let e=t?.elementId,o=t?.arrayIndex,r=null;if(e){let c=document.querySelectorAll(`[${i.ID}="${CSS.escape(e)}"]`);c.length>1&&o!==void 0&&o!==null?r=c[o]:r=c[0]||null}else n.selectedElement&&(r=n.selectedElement);if(!r){h({action:T.INLINE_EDIT_ERROR,error:"No element found for inline editing",elementId:e});return}let a=M(r),E=P(r).length>0,p=Array.from(r.children||[]).some(c=>c.hasAttribute&&c.hasAttribute(i.VE_DYNAMIC));if(!E||a.isDynamic&&!a.isEditable||p){h({action:T.INLINE_EDIT_ERROR,error:p?"Mixed content (text + expressions) cannot be inline edited. Edit the source data instead.":a.isDynamic?"Dynamic element is not editable (source cannot be traced)":"Element has no direct text content",elementId:e,isDynamic:a.isDynamic,isEditable:a.isEditable});return}n.inlineEditMetadata={editType:a.editType,sourceInfo:a.sourceInfo,arrayIndex:t?.arrayIndex??B(r)},n.inlineEditOriginalText=r.textContent||"",n.inlineEditElement=r,r.contentEditable="true",r.style.outline="none",r.style.cursor="text",r.focus();let s=document.createRange();s.selectNodeContents(r),s.collapse(!1);let d=window.getSelection();d.removeAllRanges(),d.addRange(s),r.addEventListener("input",ae),r.addEventListener("keydown",se),r.addEventListener("blur",le),h({action:T.INLINE_EDIT_START,elementId:r.getAttribute(i.ID),textContent:r.textContent})}function y(t=!0){let e=n.inlineEditElement;if(!e)return;e.removeEventListener("input",ae),e.removeEventListener("keydown",se),e.removeEventListener("blur",le),e.contentEditable="false",e.style.cursor="";let o=e.textContent,r=e.getAttribute(i.ID);t||(e.textContent=n.inlineEditOriginalText),n.inlineEditElement=null;let a=n.inlineEditOriginalText;n.inlineEditOriginalText="",h({action:T.INLINE_EDIT_END,elementId:r,textContent:t?o:a,originalText:a,saved:t,editType:n.inlineEditMetadata?.editType,sourceInfo:n.inlineEditMetadata?.sourceInfo,arrayIndex:n.inlineEditMetadata?.arrayIndex}),n.inlineEditMetadata=null}function h(t){if(window.parent&&window.parent!==window)try{window.parent.postMessage({type:L.SITE_DEBUG,source:window.location.href,timestamp:Date.now(),...t},S.PARENT_ORIGIN)}catch{}}function ue(t){if(t.origin!==S.PARENT_ORIGIN&&S.PARENT_ORIGIN!=="*"||!t.data||typeof t.data!="object")return;let{type:e,action:o,data:r}=t.data;if(e===L.DEBUG_COMMAND)switch(o){case x.ACTIVATE:H();break;case x.DEACTIVATE:G();break;case x.CLEAR_SELECTION:D();break;case x.APPLY_CHANGES:ie(r);break;case x.SET_INTERACTION_MODE:X(r.mode);break;case x.ENABLE_INLINE_EDIT:de(r);break;case x.DISABLE_INLINE_EDIT:y(r?.save!==!1);break}}function Ne(t){let e=t.match(/rgba?\(([^)]+)\)/);if(!e)return null;let o=e[1].split(",").map(p=>parseFloat(p.trim()));if(o.length<3)return null;let r=Math.round(o[0]),a=Math.round(o[1]),E=Math.round(o[2]);return"#"+[r,a,E].map(p=>{let s=p.toString(16);return s.length===1?"0"+s:s}).join("").toUpperCase()}function xe(t){let e=t.match(/rgba?\(([^)]+)\)/);if(!e)return 1;let o=e[1].split(",").map(r=>parseFloat(r.trim()));return o.length===4?o[3]:1}function U(t){if(!t||t==="transparent"||t==="rgba(0, 0, 0, 0)")return{hex:null,opacity:0,hasColor:!1};let e=Ne(t),o=xe(t);return{hex:e,opacity:Math.round(o*100),hasColor:!!e}}function ce(t){let e=t.getBoundingClientRect(),o=window.getComputedStyle(t),r=U(o.color),a=U(o.backgroundColor),E=U(o.borderColor),p=P(t),s=p.length>0,d=W(t),c=d.filter(m=>m.type==="text").length,l=t.children?t.children.length:0;return{tagName:t.tagName.toLowerCase(),id:t.id||null,className:t.className||null,textContent:p||null,hasDirectTextContent:s,hasChildElements:l>0,childElementCount:l,textNodeCount:c,contentParts:d,attributes:Array.from(t.attributes).reduce((m,f)=>(m[f.name]=f.value,m),{}),rect:{x:e.x,y:e.y,width:e.width,height:e.height},computedStyles:{color:r,backgroundColor:a,borderColor:E,fontSize:o.fontSize,fontWeight:o.fontWeight,fontFamily:o.fontFamily,textAlign:o.textAlign,lineHeight:o.lineHeight,letterSpacing:o.letterSpacing,textDecoration:o.textDecoration,fontStyle:o.fontStyle,display:o.display,position:o.position,marginTop:o.marginTop,marginRight:o.marginRight,marginBottom:o.marginBottom,marginLeft:o.marginLeft,paddingTop:o.paddingTop,paddingRight:o.paddingRight,paddingBottom:o.paddingBottom,paddingLeft:o.paddingLeft}}}var ye=["Toast"],ve=new Set(["Toaster","Sonner"]);function Z(t){return t?ve.has(t)?!0:ye.some(e=>t.startsWith(e)):!1}function q(t){let e=t.getAttribute("data-ve-original-id");e&&(t.setAttribute(i.ID,e),t.removeAttribute("data-ve-original-id"))}function K(){n.selectedGroup.forEach(t=>{t.removeAttribute("data-debug-selected"),t.removeAttribute("data-debug-dynamic")}),n.selectedBadges.forEach(t=>{b.removeBadge(t)}),n.selectedGroup=[],n.selectedBadges=[],n.selectedExprParents.forEach(t=>t.removeAttribute("data-debug-selected")),n.selectedExprParents=[]}function Me(t){let e=t.getBoundingClientRect();if(e.top===0&&e.left===0&&e.bottom===0&&e.right===0){let o=t.parentElement;for(;o;){let r=o.getBoundingClientRect();if(r.top!==0||r.left!==0||r.bottom!==0||r.right!==0){e=r;break}o=o.parentElement}}return e}function Se(t,e){let o=t.parentElement;if(!o)return;let r=o.getAttribute(i.FILE_NAME),a=o.getAttribute(i.LINE_NUMBER),E=o.getAttribute(i.COLUMN),p=o.getAttribute(i.COMPONENT);r&&(e.attributes[i.FILE_NAME]=r),a&&(e.attributes[i.LINE_NUMBER]=a),E?e.attributes[i.COLUMN]=E:delete e.attributes[i.COLUMN],p&&(e.attributes[i.COMPONENT]=p),e.className=o.className||null}function z(t){if(!n.isActive||n.interactionMode==="preview")return;let e=t.target;if(e&&e.hasAttribute&&e.hasAttribute(i.VE_DYNAMIC)&&(e.hasAttribute(i.SOURCE_EDITABLE)||(e=e.parentElement)),n.inlineEditElement&&(e===n.inlineEditElement||n.inlineEditElement.contains(e))||(n.inlineEditElement&&y(!0),t.preventDefault(),t.stopPropagation(),e.tagName&&e.tagName.toLowerCase()==="svg")||e.id==="emergent-badge")return;let o=e.getAttribute(i.COMPONENT);if(Z(o)||e.closest(`[${i.COMPONENT}^="Toast"], [${i.COMPONENT}="Toaster"], [${i.COMPONENT}="Sonner"]`)||!e.hasAttribute(i.FILE_NAME)||!e.hasAttribute(i.LINE_NUMBER)||!e.hasAttribute(i.COMPONENT))return;let a=new Set(["strong","em","span","code","a","b","i","u","s","mark","small","sub","sup","abbr","cite","q","time","kbd","samp","var","del","ins","label"]),E=e.tagName?e.tagName.toLowerCase():"";if(a.has(E)&&e.hasAttribute(i.VE_DYNAMIC)&&e.getAttribute(i.SOURCE_EDITABLE)!=="true"){let f=e.parentElement;f&&f.hasAttribute(i.FILE_NAME)&&f.hasAttribute(i.LINE_NUMBER)&&f.hasAttribute(i.COMPONENT)&&(e=f)}let p=ce(e);if(!p.attributes[i.ID]){let f=`temp-${Date.now()}-${Math.random().toString(36).substring(2,11)}`;e.setAttribute(i.ID,f),p.attributes[i.ID]=f}let s=e.hasAttribute(i.VE_DYNAMIC)&&e.getAttribute(i.SOURCE_EDITABLE)==="true",d=null;if(s){Se(e,p);let f=p.attributes[i.ID];if(f){let I=document.querySelectorAll(`[${i.ID}="${CSS.escape(f)}"]`);if(I.length>1){d=Array.from(I).indexOf(e),d<0&&(d=null);let u=`expr-${Date.now()}-${Math.random().toString(36).substring(2,11)}`;e.setAttribute("data-ve-original-id",f),e.setAttribute(i.ID,u),p.attributes[i.ID]=u}}}let c=M(e),l=w(e),m=B(e);if(m===null&&d!==null&&(m=d),n.selectedElement&&n.selectedElement!==e&&(q(n.selectedElement),n.selectedElement.removeAttribute("data-debug-selected"),K()),n.selectedElement===e)q(e),n.selectedElement=null,e.removeAttribute("data-debug-selected"),K(),h({action:T.ELEMENT_DESELECTED});else{n.selectedElement=e;let f=p.hasChildElements&&(p.textNodeCount||0)>0,I=l&&!c.isEditable&&!f;if(s){e.setAttribute("data-debug-selected","true");let g=!c.isEditable;n.selectedBadges=[b.showSelectedBadge(e,"expr",g)],n.selectedExprParents=[]}else if(l&&p.attributes[i.ID]){let g=p.attributes[i.ID],A=document.querySelectorAll(`[${i.ID}="${CSS.escape(g)}"]`);n.selectedGroup=Array.from(A).filter(Boolean),n.selectedGroup.forEach(te=>{te.setAttribute("data-debug-selected","true"),I&&te.setAttribute("data-debug-dynamic","true")});let v=I?`${e.tagName.toLowerCase()} (Dynamic)`:e.tagName.toLowerCase(),pe=b.showSelectedBadge(e,v,I);n.selectedBadges=[pe],n.selectedExprParents=[]}else{e.setAttribute("data-debug-selected","true");let g=s?"expr":e.tagName.toLowerCase();n.selectedBadges=[b.showSelectedBadge(e,g,!1)],n.selectedExprParents=[]}let u=Me(e);h({action:T.ELEMENT_SELECTED,element:p,isDynamic:l,isEditable:c.isEditable,editType:c.editType,sourceInfo:c.sourceInfo,arrayIndex:m,elementCount:l?n.selectedGroup.length:1,isMultiElement:l&&n.selectedGroup.length>1,isExprSpan:s,position:{x:u.left,y:u.bottom,width:u.width,height:u.height,elementRect:{top:u.top,left:u.left,bottom:u.bottom,right:u.right}}})}}function D(){if(n.inlineEditElement&&y(!0),n.selectedElement&&(q(n.selectedElement),n.selectedElement.removeAttribute("data-debug-selected"),n.selectedElement=null),K(),n.hoverBadge&&(b.removeBadge(n.hoverBadge),n.hoverBadge=null),n.hoverTarget=null,n.hoverGroup=[],document.querySelectorAll("[data-debug-hover]").forEach(e=>{e.removeAttribute("data-debug-hover"),e.removeAttribute("data-debug-dynamic")}),h({action:T.ELEMENT_DESELECTED}),n.lastMouseX||n.lastMouseY){let e=document.elementFromPoint(n.lastMouseX,n.lastMouseY);e&&e.dispatchEvent(new MouseEvent("mouseover",{clientX:n.lastMouseX,clientY:n.lastMouseY,bubbles:!0}))}}function j(t){if(!n.isActive||n.interactionMode==="preview")return;let e=t.target,o=!!(e&&e.hasAttribute&&e.hasAttribute(i.VE_DYNAMIC)&&e.getAttribute(i.SOURCE_EDITABLE)==="true");if(e&&e.hasAttribute&&e.hasAttribute(i.VE_DYNAMIC)&&!o&&(e=e.parentElement),!e||e.nodeType!==Node.ELEMENT_NODE||e.hasAttribute("data-debug-selected")||o&&e.parentElement?.hasAttribute("data-debug-selected")||e.tagName&&e.tagName.toLowerCase()==="svg"||e.id==="emergent-badge")return;if(!o){let c=e.getAttribute(i.COMPONENT);if(Z(c)||!(e.hasAttribute(i.FILE_NAME)&&e.hasAttribute(i.LINE_NUMBER)&&e.hasAttribute(i.COMPONENT)))return}if(e===n.hoverTarget){o!==n.hoverIsExprSpan&&n.hoverBadge&&(n.hoverBadge.textContent=o?"expr":n.hoverNonExprLabel??"",n.hoverIsExprSpan=o);return}if(n.hoverGroup.length>0?(n.hoverGroup.forEach(c=>{c.removeAttribute("data-debug-hover"),c.hasAttribute("data-debug-selected")||c.removeAttribute("data-debug-dynamic")}),n.hoverGroup=[]):n.hoverTarget&&(n.hoverTarget.removeAttribute("data-debug-hover"),n.hoverTarget.hasAttribute("data-debug-selected")||n.hoverTarget.removeAttribute("data-debug-dynamic")),o){let l=!M(e).isEditable;e.setAttribute("data-debug-hover","true"),l&&e.setAttribute("data-debug-dynamic","true"),n.hoverBadge&&b.removeBadge(n.hoverBadge),n.hoverTarget=e,n.hoverIsExprSpan=!0,n.hoverNonExprLabel=null,n.hoverBadge=b.showHoverBadge(e,"expr",l);return}let r=w(e),a=M(e),E=e.children&&e.children.length>0&&Array.from(e.childNodes).some(c=>c.nodeType===Node.TEXT_NODE&&c.textContent&&c.textContent.trim()),p=r&&!a.isEditable&&!E;if(r){let c=e.getAttribute(i.ID)||e.closest(`[${i.ID}]`)?.getAttribute(i.ID);if(c){let l=document.querySelectorAll(`[${i.ID}="${CSS.escape(c)}"]`);if(n.hoverGroup=Array.from(l).filter(Boolean),n.hoverGroup.some(f=>f.hasAttribute("data-debug-selected"))){n.hoverGroup=[];return}n.hoverGroup.forEach(f=>{f.setAttribute("data-debug-hover","true"),p&&f.setAttribute("data-debug-dynamic","true")})}else e.setAttribute("data-debug-hover","true"),p&&e.setAttribute("data-debug-dynamic","true")}else e.setAttribute("data-debug-hover","true");let s=p?`${e.tagName.toLowerCase()} (Dynamic)`:e.tagName.toLowerCase(),d=o?"expr":s;n.hoverBadge&&b.removeBadge(n.hoverBadge),n.hoverTarget=e,n.hoverIsExprSpan=o??!1,n.hoverNonExprLabel=s,n.hoverBadge=b.showHoverBadge(e,d,p)}function Q(t){if(!n.isActive||n.interactionMode==="preview")return;let e=t.relatedTarget;e&&n.hoverTarget&&(n.hoverTarget===e||e.hasAttribute&&e.hasAttribute(i.VE_DYNAMIC)&&e.parentElement===n.hoverTarget&&e.getAttribute(i.SOURCE_EDITABLE)!=="true")||(n.hoverGroup.length>0?(n.hoverGroup.forEach(o=>{o.removeAttribute("data-debug-hover"),o.hasAttribute("data-debug-selected")||o.removeAttribute("data-debug-dynamic")}),n.hoverGroup=[]):n.hoverTarget&&(n.hoverTarget.removeAttribute("data-debug-hover"),n.hoverTarget.hasAttribute("data-debug-selected")||n.hoverTarget.removeAttribute("data-debug-dynamic")),n.hoverBadge&&(b.removeBadge(n.hoverBadge),n.hoverBadge=null,n.hoverTarget=null))}var S={VERSION:"0.1.9.1",PARENT_ORIGIN:"*",Z_INDEX:1e4},n={isActive:!1,interactionMode:"select",selectedElement:null,selectedGroup:[],selectedExprParents:[],hoverGroup:[],hoverBadge:null,selectedBadges:[],hoverTarget:null,hoverIsExprSpan:!1,hoverNonExprLabel:null,repositionRAF:null,inlineEditElement:null,inlineEditOriginalText:"",inlineEditMetadata:null,lastMouseX:0,lastMouseY:0},b=new _,Ee=["pointerdown","pointerup","touchstart","touchend","mousedown","mouseup","contextmenu"];function ee(t){if(n.isActive&&n.interactionMode==="select"&&!((t instanceof MouseEvent||t instanceof PointerEvent)&&(t.metaKey||t.ctrlKey||t.altKey))){if(n.inlineEditElement){let e=t.target;if(e===n.inlineEditElement||n.inlineEditElement.contains(e))return}t.preventDefault(),t.stopPropagation()}}function me(t){n.lastMouseX=t.clientX,n.lastMouseY=t.clientY}var Y;function R(){n.hoverBadge&&(n.hoverBadge.style.opacity="0",n.hoverBadge.style.transition="none"),n.selectedBadges.forEach(t=>{t.style.opacity="0",t.style.transition="none"}),clearTimeout(Y),Y=setTimeout(()=>{n.repositionRAF&&cancelAnimationFrame(n.repositionRAF),n.repositionRAF=requestAnimationFrame(()=>{if(n.hoverBadge&&n.hoverTarget&&(b.updateBadgePosition(n.hoverTarget,n.hoverBadge),n.hoverBadge.offsetHeight,n.hoverBadge.style.transition="",n.hoverBadge.style.opacity="1"),n.selectedBadges.length>0){let t=n.selectedGroup.length>0?n.selectedGroup[0]:n.selectedElement;t&&(b.updateBadgePosition(t,n.selectedBadges[0]),n.selectedBadges[0].offsetHeight,n.selectedBadges[0].style.transition="",n.selectedBadges[0].style.opacity="1")}n.repositionRAF=null})},50)}function H(){n.isActive=!0,document.body.style.cursor=n.interactionMode==="select"?"crosshair":"default",n.interactionMode==="select"&&document.body.classList.add("debug-select-mode"),document.addEventListener("click",z,!0),document.addEventListener("mouseover",j,!0),document.addEventListener("mouseout",Q,!0),document.addEventListener("mousemove",me,!0),Ee.forEach(t=>{document.addEventListener(t,ee,!0)}),window.addEventListener("scroll",R,{passive:!0}),window.addEventListener("resize",R,{passive:!0}),h({action:T.MODE_ACTIVATED,url:window.location.href})}function G(){n.isActive=!1,document.body.style.cursor="",document.body.classList.remove("debug-select-mode"),document.removeEventListener("click",z,!0),document.removeEventListener("mouseover",j,!0),document.removeEventListener("mouseout",Q,!0),document.removeEventListener("mousemove",me,!0),Ee.forEach(t=>{document.removeEventListener(t,ee,!0)}),window.removeEventListener("scroll",R),window.removeEventListener("resize",R),clearTimeout(Y),Y=void 0,n.repositionRAF&&(cancelAnimationFrame(n.repositionRAF),n.repositionRAF=null),D(),b.cleanup(),h({action:T.MODE_DEACTIVATED})}function X(t){n.interactionMode=t,n.isActive&&(document.body.style.cursor=t==="select"?"crosshair":"default",t==="select"?document.body.classList.add("debug-select-mode"):document.body.classList.remove("debug-select-mode")),h({action:T.INTERACTION_MODE_CHANGED,mode:t})}function J(){window.parent!==window&&(ne(S.Z_INDEX),window.addEventListener("message",ue))}document.readyState==="loading"?document.addEventListener("DOMContentLoaded",J):J();window.visualEditOverlay={activate:H,deactivate:G,clearSelection:D,getState:()=>({...n})};return be(De);})();
