iterate-ui-overlay 0.1.2 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -153,6 +153,14 @@ function isUserComponent(fiber) {
153
153
  return true;
154
154
  }
155
155
  function getComponentInfo(element) {
156
+ const directComponent = element.getAttribute("data-iterate-component");
157
+ if (directComponent) {
158
+ return {
159
+ component: directComponent,
160
+ source: element.getAttribute("data-iterate-source"),
161
+ isComponentRoot: true
162
+ };
163
+ }
156
164
  const fiber = getReactFiber(element);
157
165
  if (fiber) {
158
166
  let current = fiber;
@@ -169,13 +177,15 @@ function getComponentInfo(element) {
169
177
  }
170
178
  }
171
179
  let el = element;
180
+ let isComponentRoot = true;
172
181
  while (el && el !== document.documentElement) {
173
182
  const component = el.getAttribute("data-iterate-component");
174
183
  const source = el.getAttribute("data-iterate-source");
175
184
  if (component) {
176
- return { component, source, isComponentRoot: false };
185
+ return { component, source, isComponentRoot };
177
186
  }
178
187
  el = el.parentElement;
188
+ isComponentRoot = false;
179
189
  }
180
190
  return { component: null, source: null, isComponentRoot: false };
181
191
  }
@@ -2431,10 +2441,10 @@ function MovePopup({
2431
2441
  color: theme.textPrimary
2432
2442
  },
2433
2443
  children: (() => {
2434
- if (move.isComponentRoot && move.componentName) return `<${move.componentName}>`;
2444
+ if (move.componentName) return `<${move.componentName}>`;
2435
2445
  const lastPart = move.selector.split(" ").pop() || "";
2436
2446
  const tag = lastPart.replace(/[:.#\[].*$/, "").toLowerCase();
2437
- return tag ? `<${tag}>` : move.componentName || "Element";
2447
+ return tag ? `<${tag}>` : "Element";
2438
2448
  })()
2439
2449
  }
2440
2450
  ),
@@ -25,6 +25,8 @@ Error generating stack: `+l.message+`
25
25
  `;let c=o.textSelection.containingElement,r=c.componentName?`<${c.componentName}>`:c.elementName||c.selector;l+=` In: ${r} (\`${c.selector}\`)
26
26
  `}o.drawing&&(l+=`- **Drawing annotation** (marker tool)
27
27
  `,l+=` Region: ${o.drawing.bounds.width.toFixed(0)}\xD7${o.drawing.bounds.height.toFixed(0)} at (${o.drawing.bounds.x.toFixed(0)}, ${o.drawing.bounds.y.toFixed(0)})
28
+ `,l+=` SVG path: \`${o.drawing.path}\`
29
+ `,l+=` Stroke: ${o.drawing.strokeColor}, width ${o.drawing.strokeWidth}
28
30
  `),l+=`
29
31
  `}if(e.length>0){l+=`## DOM Changes (${e.length})
30
32
 
@@ -37,7 +39,7 @@ Error generating stack: `+l.message+`
37
39
  `);else{let g=u.before.rect,d=u.after.rect;l+=` Before: ${g.width.toFixed(0)}\xD7${g.height.toFixed(0)} at (${g.x.toFixed(0)}, ${g.y.toFixed(0)})
38
40
  `,l+=` After: ${d.width.toFixed(0)}\xD7${d.height.toFixed(0)} at (${d.x.toFixed(0)}, ${d.y.toFixed(0)})
39
41
  `}}l+=`
40
- `}return l+="Please process this feedback and make the requested changes.",l}var Ln=ot(be(),1);function Ol(t){if(t.id)return`#${CSS.escape(t.id)}`;let e=[],n=t;for(;n&&n!==document.documentElement;){let l=n.tagName.toLowerCase(),a=Array.from(n.classList).filter(i=>!i.startsWith("__")&&!i.includes("svelte-")&&!/^[a-z]{1,2}$/.test(i)&&!/[_][a-zA-Z0-9]{5,}/.test(i)).slice(0,2);if(a.length>0&&(l+=a.map(i=>`.${CSS.escape(i)}`).join("")),n.parentElement&&n.parentElement.querySelectorAll(`:scope > ${l}`).length>1){let u=Array.from(n.parentElement.children).indexOf(n)+1;l+=`:nth-child(${u})`}if(e.unshift(l),document.querySelectorAll(e.join(" > ")).length===1)break;n=n.parentElement}return e.join(" > ")}function rm(t,e=4){let n=[],l=t,a=0;for(;l&&l!==document.documentElement&&a<e;){let i=l.tagName.toLowerCase(),u=Array.from(l.classList).filter(o=>!/[_][a-zA-Z0-9]{5,}/.test(o)).slice(0,1);n.unshift(u.length>0?`${i}.${u[0]}`:i),l=l.parentElement,a++}return n.join(" > ")}function us(t){let e=t.tagName.toLowerCase(),n=t.getAttribute("data-element");if(n)return n;if(e==="button"||t.getAttribute("role")==="button"){let a=t.getAttribute("aria-label");if(a)return`button [${a}]`;let i=t.textContent?.trim().slice(0,30);return i?`button "${i}"`:"button"}if(e==="a"){let a=t.textContent?.trim().slice(0,30);return a?`link "${a}"`:"link"}if(e==="input"){let a=t.type||"text",i=t.name,u=t.placeholder;return i?`input[${a}] "${i}"`:u?`input[${a}] "${u}"`:`input[${a}]`}if(e==="img"){let a=t.alt;return a?`image "${a.slice(0,30)}"`:"image"}if(/^h[1-6]$/.test(e)){let a=t.textContent?.trim().slice(0,30);return a?`${e} "${a}"`:e}if(t.id)return`#${t.id}`;let l=Array.from(t.classList).filter(a=>!/[_][a-zA-Z0-9]{5,}/.test(a)&&a.length>2).at(0);return l?`${e}.${l}`:e}function sm(t){let e=[],n=t.previousElementSibling;n?.textContent?.trim()&&e.push(`[prev] ${n.textContent.trim().slice(0,50)}`);let l=t.textContent?.trim();l&&e.push(l.slice(0,80));let a=t.nextElementSibling;return a?.textContent?.trim()&&e.push(`[next] ${a.textContent.trim().slice(0,50)}`),e.join(" | ")}function Fg(t){for(let e of Object.keys(t))if(e.startsWith("__reactFiber$")||e.startsWith("__reactInternalInstance$"))return t[e];return null}var Ig=new Set(["AppRouter","Router","HotReload","InnerLayoutRouter","OuterLayoutRouter","RenderFromTemplateContext","ScrollAndFocusHandler","InnerScrollAndFocusHandler","ClientPageRoot","SegmentViewNode","SegmentStateProvider","RootErrorBoundary","AppDevOverlayErrorBoundary","DevRootHTTPAccessFallbackBoundary","Root","ServerRoot","ErrorBoundary","ErrorBoundaryHandler","Suspense","RedirectBoundary","RedirectErrorBoundary","HTTPAccessFallbackBoundary","HTTPAccessFallbackErrorBoundary","LoadingBoundary"]);function Pg(t){if(!t||!t.type||typeof t.type=="string")return!1;let e=t.type.displayName||t.type.name;return!(!e||!/^[A-Z]/.test(e)||Ig.has(e)||/Context$|Provider$/.test(e))}function Hi(t){let e=Fg(t);if(e){let l=e,a=!0;for(;l;){if(Pg(l)){let i=l.type.displayName||l.type.name,u=l._debugSource,o=u?`${u.fileName}:${u.lineNumber}`:null;return{component:i,source:o,isComponentRoot:a}}l===e.return&&(a=!1),l=l.return}}let n=t;for(;n&&n!==document.documentElement;){let l=n.getAttribute("data-iterate-component"),a=n.getAttribute("data-iterate-source");if(l)return{component:l,source:a,isComponentRoot:!1};n=n.parentElement}return{component:null,source:null,isComponentRoot:!1}}var tp=new Set(["p","span","h1","h2","h3","h4","h5","h6","label","a","li"]),ep=new Set(["div","section","main","article","aside","nav","header","footer"]),np=new Set(["button","input","select","textarea"]),om=["color","font-size","font-weight","font-family","line-height","text-align","text-decoration","letter-spacing"],cm=["display","flex-direction","justify-content","align-items","gap","grid-template-columns","grid-template-rows","padding","margin","background-color","border-radius","overflow"],lp=["background-color","color","padding","border-radius","font-size","font-weight","border","cursor","outline"],ap=["position","top","left","right","bottom","z-index","width","height"],ip=new Set(["none","normal","auto","0px","transparent","rgba(0, 0, 0, 0)"]);function za(t){let e=window.getComputedStyle(t),n=t.tagName.toLowerCase(),l={},a=[...ap];tp.has(n)?a=a.concat(om):np.has(n)?a=a.concat(lp):ep.has(n)?a=a.concat(cm):a=a.concat(cm,om);for(let i of a){let u=e.getPropertyValue(i);u&&!ip.has(u)&&(l[i]=u)}return l}var sl=ot(Qt(),1);function hm({active:t,iframeRef:e,selectedElements:n,onSelect:l,suppressHover:a,justFinishedDragRef:i}){let[u,o]=(0,Ln.useState)(null),[c,r]=(0,Ln.useState)(""),[y,g]=(0,Ln.useState)(null),d=(0,Ln.useCallback)(()=>{try{return e.current?.contentDocument??document}catch{return document}},[e]);return(0,Ln.useEffect)(()=>{a&&(o(null),g(null))},[a]),(0,Ln.useEffect)(()=>{if(!t){o(null),g(null);return}let m=d(),b=f=>!!f.closest("#__iterate-overlay-root__")||!!f.closest("#__iterate-markers-layer__")||!!f.closest("#__iterate-fixed-markers-layer__"),E=f=>{if(a)return;let s=f.target;if(!s||s===m.documentElement||b(s)){o(null),g(null);return}let h=s.getBoundingClientRect();o({x:h.x,y:h.y,width:h.width,height:h.height}),g({x:f.clientX,y:f.clientY});let{component:p,isComponentRoot:C}=Hi(s);r(p&&C?`<${p}>`:us(s))},O=f=>{if(i?.current){i.current=!1;return}let s=f.target;if(!s||b(s))return;f.preventDefault(),f.stopPropagation();let h=Hl(s),p={x:f.clientX,y:f.clientY};if(f.ctrlKey||f.metaKey){let L=n.findIndex(A=>A.selector===h.selector);if(L>=0){let A=[...n];A.splice(L,1),l(A,p)}else l([...n,h],p)}else l([h],p)};return m.addEventListener("mousemove",E),m.addEventListener("click",O,{capture:!0}),()=>{m.removeEventListener("mousemove",E),m.removeEventListener("click",O,{capture:!0})}},[t,d,l,n,a]),t?(0,sl.jsx)("div",{style:{position:"absolute",inset:0,pointerEvents:"none"},children:u&&(0,sl.jsxs)(sl.Fragment,{children:[(0,sl.jsx)("div",{style:{position:"absolute",left:u.x,top:u.y,width:u.width,height:u.height,border:"1.5px solid #6b9eff",backgroundColor:"rgba(107, 158, 255, 0.06)",borderRadius:4,pointerEvents:"none",boxSizing:"border-box",transition:"all 0.1s ease"}}),y&&(0,sl.jsx)("div",{style:{position:"absolute",left:y.x+12,top:y.y+16,background:"#6b9eff",color:"#fff",padding:"2px 8px",borderRadius:4,fontSize:11,fontFamily:"monospace",whiteSpace:"nowrap",pointerEvents:"none",maxWidth:400,overflow:"hidden",textOverflow:"ellipsis"},children:c})]})}):null}function Hl(t){let e=t.getBoundingClientRect(),{component:n,source:l,isComponentRoot:a}=Hi(t);return{domElement:t,selector:Ol(t),elementName:us(t),elementPath:rm(t),rect:{x:e.x,y:e.y,width:e.width,height:e.height},computedStyles:za(t),nearbyText:sm(t),componentName:a?n:null,sourceLocation:a?l:null}}var dn=ot(be(),1);var Li=ot(Qt(),1);function ym({active:t,iframeRef:e,onSelect:n,onDragStateChange:l,justFinishedDragRef:a}){let[i,u]=(0,dn.useState)(null),[o,c]=(0,dn.useState)(null),[r,y]=(0,dn.useState)([]),g=(0,dn.useRef)(0),d=(0,dn.useCallback)(()=>{try{return e.current?.contentDocument??document}catch{return document}},[e]);return(0,dn.useEffect)(()=>{if(!t){u(null),c(null);return}let m=d(),b=!1,E={x:0,y:0},O=h=>{if(h.button!==0||h.ctrlKey||h.metaKey)return;let p=h.target;p.closest("#__iterate-overlay-root__")||p.closest("#__iterate-markers-layer__")||(h.preventDefault(),b=!0,E={x:h.clientX,y:h.clientY},c(E),l?.(!0))},f=h=>{if(!b)return;let p=Math.min(E.x,h.clientX),C=Math.min(E.y,h.clientY),L=Math.abs(h.clientX-E.x),A=Math.abs(h.clientY-E.y);if(L>10||A>10){let q={x:p,y:C,width:L,height:A};u(q);let z=Date.now();if(z-g.current>80){g.current=z;let k=cp(m,q);y(k)}}},s=h=>{if(!b)return;b=!1,l?.(!1);let p={x:Math.min(E.x,h.clientX),y:Math.min(E.y,h.clientY),width:Math.abs(h.clientX-E.x),height:Math.abs(h.clientY-E.y)};if(u(null),c(null),y([]),p.width<20||p.height<20)return;let C=rp(m,p);C.length>0&&(a&&(a.current=!0),n(C))};return m.addEventListener("mousedown",O),m.addEventListener("mousemove",f),m.addEventListener("mouseup",s),()=>{m.removeEventListener("mousedown",O),m.removeEventListener("mousemove",f),m.removeEventListener("mouseup",s)}},[t,d,n,l]),!t||!i?null:(0,Li.jsxs)("div",{style:{position:"absolute",inset:0,pointerEvents:"none"},children:[(0,Li.jsx)("div",{style:{position:"absolute",left:i.x,top:i.y,width:i.width,height:i.height,border:"1.5px dashed #6b9eff",backgroundColor:"rgba(107, 158, 255, 0.06)",borderRadius:3,pointerEvents:"none"}}),r.map((m,b)=>(0,Li.jsx)("div",{style:{position:"absolute",left:m.x,top:m.y,width:m.width,height:m.height,border:"1.5px solid #6b9eff",borderRadius:4,pointerEvents:"none",boxSizing:"border-box"}},b))]})}function gm(t,e,n){return t.left>=e.x-n&&t.right<=e.x+e.width+n&&t.top>=e.y-n&&t.bottom<=e.y+e.height+n}var pm=new Set(["html","body","head","script","style","meta","link","noscript"]),vm=t=>!!t.closest("#__iterate-overlay-root__")||!!t.closest("#__iterate-markers-layer__"),bm=8;function cp(t,e){let n=new Set,l=t.querySelectorAll("*");for(let i of l){if(pm.has(i.tagName.toLowerCase())||vm(i))continue;let u=i.getBoundingClientRect();u.width===0||u.height===0||u.width>e.width*2&&u.height>e.height*2||gm(u,e,bm)&&n.add(i)}let a=[];for(let i of n){let u=i.parentElement,o=!1;for(;u;){if(n.has(u)){o=!0;break}u=u.parentElement}if(!o){let c=i.getBoundingClientRect();a.push({x:c.x,y:c.y,width:c.width,height:c.height})}}return a}function rp(t,e){let n=new Set,l=t.querySelectorAll("*");for(let i of l){if(pm.has(i.tagName.toLowerCase())||vm(i))continue;let u=i.getBoundingClientRect();u.width===0||u.height===0||u.width>e.width*2&&u.height>e.height*2||gm(u,e,bm)&&n.add(i)}let a=[];for(let i of n){let u=i.parentElement,o=!1;for(;u;){if(n.has(u)){o=!0;break}u=u.parentElement}o||a.push(Hl(i))}return a}var Ll=ot(be(),1);var yo=ot(Qt(),1);function Sm({active:t,iframeRef:e,onTextSelect:n}){let[l,a]=(0,Ll.useState)(null),[i,u]=(0,Ll.useState)(""),o=(0,Ll.useCallback)(()=>{try{return e.current?.contentDocument??document}catch{return document}},[e]);return(0,Ll.useEffect)(()=>{if(!t){a(null),u("");return}let c=o(),r=()=>{let m=c.getSelection();if(!m||m.isCollapsed||!m.rangeCount){a(null),u(""),n(null);return}let b=m.getRangeAt(0),E=m.toString().trim();if(!E||E.length<2){a(null),u("");return}let O=b.commonAncestorContainer,f=O.nodeType===Node.ELEMENT_NODE?O:O.parentElement;if(!f)return;let s=Hl(f),h=b.getBoundingClientRect();a({x:h.x+h.width/2,y:h.y-4}),u(E),n({text:E,containingElement:{selector:s.selector,elementName:s.elementName,elementPath:s.elementPath,rect:s.rect,computedStyles:s.computedStyles,nearbyText:s.nearbyText,componentName:s.componentName,sourceLocation:s.sourceLocation},startOffset:b.startOffset,endOffset:b.endOffset})},y,g=()=>{clearTimeout(y),y=setTimeout(r,150)};c.addEventListener("selectionchange",g);let d=()=>{setTimeout(r,50)};return c.addEventListener("mouseup",d),()=>{clearTimeout(y),c.removeEventListener("selectionchange",g),c.removeEventListener("mouseup",d)}},[t,o,n]),!t||!l||!i?null:(0,yo.jsx)("div",{style:{position:"absolute",inset:0,pointerEvents:"none"},children:(0,yo.jsxs)("div",{style:{position:"absolute",left:l.x,top:l.y,transform:"translate(-50%, -100%)",background:"#2563eb",color:"#fff",padding:"3px 8px",borderRadius:4,fontSize:10,fontFamily:"-apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif",whiteSpace:"nowrap",pointerEvents:"none",maxWidth:250,overflow:"hidden",textOverflow:"ellipsis"},children:['"',i.slice(0,50),i.length>50?"...":"",'"']})})}var tn=ot(be(),1);var Bl=ot(Qt(),1),Em="#2563eb",xm=3;function Mm({active:t,iframeRef:e,onDrawComplete:n}){let[l,a]=(0,tn.useState)(!1),[i,u]=(0,tn.useState)([]),[o,c]=(0,tn.useState)([]),r=(0,tn.useRef)([]),y=(0,tn.useCallback)(()=>{try{return e.current?.contentDocument??document}catch{return document}},[e]);if((0,tn.useEffect)(()=>{t||c([])},[t]),(0,tn.useEffect)(()=>{if(!t){a(!1),u([]),r.current=[];return}let d=y(),m=O=>{if(O.button!==0||O.target?.closest?.("#__iterate-markers-layer__, #__iterate-fixed-markers-layer__, [data-iterate-popup], [data-iterate-panel]"))return;O.preventDefault(),O.stopPropagation(),a(!0);let s={x:O.clientX,y:O.clientY};r.current=[s],u([s])},b=O=>{if(!l)return;let f={x:O.clientX,y:O.clientY};r.current.push(f),r.current.length%2===0&&u([...r.current])},E=O=>{if(!l)return;a(!1);let f=r.current;if(f.length<3){u([]),r.current=[];return}let s=Tm(f),h=sp(f),p={path:s,bounds:h,strokeColor:Em,strokeWidth:xm},C=fp(d,h);c(L=>[...L,p]),u([]),r.current=[],n(C,p)};return d.addEventListener("mousedown",m,{capture:!0}),d.addEventListener("mousemove",b),d.addEventListener("mouseup",E),()=>{d.removeEventListener("mousedown",m,{capture:!0}),d.removeEventListener("mousemove",b),d.removeEventListener("mouseup",E)}},[t,l,y,n]),!t)return null;let g=i.length>=2?Tm(i):null;return(0,Bl.jsxs)("div",{style:{position:"absolute",inset:0,pointerEvents:"none",cursor:"crosshair"},children:[(0,Bl.jsxs)("svg",{style:{position:"absolute",inset:0,width:"100%",height:"100%",pointerEvents:"none",overflow:"visible"},children:[o.map((d,m)=>(0,Bl.jsx)("path",{d:d.path,fill:"none",stroke:d.strokeColor,strokeWidth:d.strokeWidth,strokeLinecap:"round",strokeLinejoin:"round",opacity:.6},`completed-${m}`)),g&&(0,Bl.jsx)("path",{d:g,fill:"none",stroke:Em,strokeWidth:xm,strokeLinecap:"round",strokeLinejoin:"round"})]}),!l&&(0,Bl.jsx)("div",{style:{position:"absolute",inset:0,pointerEvents:"auto",cursor:"crosshair"}})]})}function Tm(t){if(t.length===0)return"";let e=[`M ${t[0].x} ${t[0].y}`];for(let n=1;n<t.length-1;n++){let l=t[n],a=t[n+1],i=(l.x+a.x)/2,u=(l.y+a.y)/2;e.push(`Q ${l.x} ${l.y} ${i} ${u}`)}if(t.length>1){let n=t[t.length-1];e.push(`L ${n.x} ${n.y}`)}return e.join(" ")}function sp(t){let e=1/0,n=1/0,l=-1/0,a=-1/0;for(let i of t)i.x<e&&(e=i.x),i.y<n&&(n=i.y),i.x>l&&(l=i.x),i.y>a&&(a=i.y);return{x:e,y:n,width:l-e,height:a-n}}function fp(t,e){let n=[],l=new Set,a=10,i={x:e.x-a,y:e.y-a,width:e.width+a*2,height:e.height+a*2},u=t.querySelectorAll("*");for(let o of u){let c=o.tagName.toLowerCase();if(["html","body","head","script","style","meta","link","noscript"].includes(c)||o.closest("#__iterate-overlay-root__")||o.closest("#__iterate-markers-layer__"))continue;let r=o.getBoundingClientRect();if(!(r.width===0||r.height===0)&&!(r.width>i.width*3&&r.height>i.height*3)&&r.left<i.x+i.width&&r.right>i.x&&r.top<i.y+i.height&&r.bottom>i.y){let y=!1,g=o.parentElement;for(;g;){if(l.has(g)){y=!0;break}g=g.parentElement}if(!y){for(let d=n.length-1;d>=0;d--)o.contains(n[d].domElement)&&n.splice(d,1);l.add(o),n.push(Hl(o))}}}return n}var Yt=ot(be(),1);var r2=ot(be(),1),gt=ot(Qt(),1);function Cm({size:t=24,color:e="currentColor"}){return(0,gt.jsx)("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",children:(0,gt.jsx)("path",{d:"M10 4H11C11 3.44772 10.5523 3 10 3V4ZM10 10V11C10.5523 11 11 10.5523 11 10H10ZM4 10H3C3 10.5523 3.44772 11 4 11V10ZM4.54601 4.10899L5 5L4.54601 4.10899ZM4.10899 4.54601L5 5L4.10899 4.54601ZM14 4V3C13.4477 3 13 3.44772 13 4H14ZM20 10V11C20.5523 11 21 10.5523 21 10H20ZM14 10H13C13 10.5523 13.4477 11 14 11V10ZM19.454 4.10899L19 5L19.454 4.10899ZM19.891 4.54601L19 5L19.891 4.54601ZM4 14V13C3.44772 13 3 13.4477 3 14H4ZM10 14H11C11 13.4477 10.5523 13 10 13V14ZM10 20V21C10.5523 21 11 20.5523 11 20H10ZM4.54601 19.891L5 19L4.54601 19.891ZM4.10899 19.454L5 19L4.10899 19.454ZM20.2929 21.7076C20.6834 22.0981 21.3166 22.0981 21.7071 21.7076C22.0976 21.317 22.0976 20.6839 21.7071 20.2934L21 21.0005L20.2929 21.7076ZM5.6 4V5H10V4V3H5.6V4ZM10 4H9V10H10H11V4H10ZM10 10V9H4V10V11H10V10ZM4 10H5V5.6H4H3V10H4ZM5.6 4V3C5.33647 3 5.07869 2.99922 4.86177 3.01695C4.63318 3.03562 4.36344 3.07969 4.09202 3.21799L4.54601 4.10899L5 5C4.94249 5.0293 4.91972 5.01887 5.02463 5.0103C5.14122 5.00078 5.30347 5 5.6 5V4ZM4 5.6H5C5 5.30347 5.00078 5.14122 5.0103 5.02463C5.01887 4.91972 5.0293 4.94249 5 5L4.10899 4.54601L3.21799 4.09202C3.07969 4.36344 3.03562 4.63318 3.01695 4.86177C2.99922 5.07869 3 5.33647 3 5.6H4ZM4.54601 4.10899L4.09202 3.21799C3.71569 3.40973 3.40973 3.71569 3.21799 4.09202L4.10899 4.54601L5 5V5L4.54601 4.10899ZM14 4V5H18.4V4V3H14V4ZM20 5.6H19V10H20H21V5.6H20ZM20 10V9H14V10V11H20V10ZM14 10H15V4H14H13V10H14ZM18.4 4V5C18.6965 5 18.8588 5.00078 18.9754 5.0103C19.0803 5.01887 19.0575 5.0293 19 5L19.454 4.10899L19.908 3.21799C19.6366 3.07969 19.3668 3.03562 19.1382 3.01695C18.9213 2.99922 18.6635 3 18.4 3V4ZM20 5.6H21C21 5.33647 21.0008 5.07869 20.9831 4.86177C20.9644 4.63318 20.9203 4.36344 20.782 4.09202L19.891 4.54601L19 5C18.9707 4.94249 18.9811 4.91972 18.9897 5.02463C18.9992 5.14122 19 5.30347 19 5.6H20ZM19.454 4.10899L19 5V5L19.891 4.54601L20.782 4.09202C20.5903 3.7157 20.2843 3.40973 19.908 3.21799L19.454 4.10899ZM4 14V15H10V14V13H4V14ZM10 14H9V20H10H11V14H10ZM10 20V19H5.6V20V21H10V20ZM4 18.4H5V14H4H3V18.4H4ZM5.6 20V19C5.30347 19 5.14122 18.9992 5.02463 18.9897C4.91972 18.9811 4.94249 18.9707 5 19L4.54601 19.891L4.09202 20.782C4.36344 20.9203 4.63318 20.9644 4.86177 20.9831C5.07869 21.0008 5.33647 21 5.6 21V20ZM4 18.4H3C3 18.6635 2.99922 18.9213 3.01695 19.1382C3.03562 19.3668 3.07969 19.6366 3.21799 19.908L4.10899 19.454L5 19C5.0293 19.0575 5.01887 19.0803 5.0103 18.9754C5.00078 18.8588 5 18.6965 5 18.4H4ZM4.54601 19.891L5 19V19L4.10899 19.454L3.21799 19.908C3.40973 20.2843 3.7157 20.5903 4.09202 20.782L4.54601 19.891ZM19.1213 19.1218L18.4142 18.4147C17.6332 19.1957 16.3668 19.1957 15.5858 18.4147L14.8787 19.1218L14.1716 19.8289C15.7337 21.391 18.2663 21.391 19.8284 19.8289L19.1213 19.1218ZM14.8787 19.1218L15.5858 18.4147C14.8047 17.6336 14.8047 16.3673 15.5858 15.5862L14.8787 14.8791L14.1716 14.172C12.6095 15.7341 12.6095 18.2668 14.1716 19.8289L14.8787 19.1218ZM14.8787 14.8791L15.5858 15.5862C16.3668 14.8052 17.6332 14.8052 18.4142 15.5862L19.1213 14.8791L19.8284 14.172C18.2663 12.6099 15.7337 12.6099 14.1716 14.172L14.8787 14.8791ZM19.1213 14.8791L18.4142 15.5862C19.1953 16.3673 19.1953 17.6336 18.4142 18.4147L19.1213 19.1218L19.8284 19.8289C21.3905 18.2668 21.3905 15.7341 19.8284 14.172L19.1213 14.8791ZM19.1213 19.1218L18.4142 19.8289L20.2929 21.7076L21 21.0005L21.7071 20.2934L19.8284 18.4147L19.1213 19.1218Z",fill:e})})}function wm({size:t=24,color:e="currentColor"}){return(0,gt.jsx)("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",children:(0,gt.jsx)("path",{d:"M15 9L9 15M15 15L9 9M21 12C21 16.9706 16.9706 21 12 21C7.02944 21 3 16.9706 3 12C3 7.02944 7.02944 3 12 3C16.9706 3 21 7.02944 21 12Z",stroke:e,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}function _m({size:t=24,color:e="currentColor"}){return(0,gt.jsx)("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",children:(0,gt.jsx)("path",{d:"M11 3V4.5M16.6569 5.34326L15.5962 6.40392M6.40381 15.5962L5.34315 16.6569M4.5 11H3M6.40381 6.40381L5.34315 5.34315M14.3136 20.7675L10.4536 10.7769C10.3754 10.5745 10.5745 10.3754 10.7769 10.4536L20.7675 14.3136C20.9626 14.3889 20.9844 14.6562 20.8042 14.7623L17.0559 16.9671C17.0192 16.9887 16.9887 17.0192 16.9671 17.0559L14.7623 20.8042C14.6562 20.9844 14.3889 20.9626 14.3136 20.7675Z",stroke:e,strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"})})}function Am({size:t=24,color:e="currentColor"}){return(0,gt.jsx)("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",children:(0,gt.jsx)("path",{d:"M8.99989 5.74989L11.4696 3.28022C11.7624 2.98732 12.2373 2.98732 12.5302 3.28022L14.9999 5.74989M5.74989 8.99989L3.28022 11.4696C2.98732 11.7624 2.98732 12.2373 3.28022 12.5302L5.74989 14.9999M18.2499 8.99989L20.7196 11.4696C21.0125 11.7624 21.0125 12.2373 20.7196 12.5302L18.2499 14.9999M14.9999 18.2499L12.5302 20.7196C12.2373 21.0125 11.7624 21.0125 11.4696 20.7196L8.99989 18.2499M11.9999 3.99989V11.9999M11.9999 11.9999V19.9999M11.9999 11.9999H3.99989M11.9999 11.9999H19.9999",stroke:e,strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"})})}function Da({size:t=24,color:e="currentColor"}){return(0,gt.jsx)("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",children:(0,gt.jsx)("path",{d:"M5.93777 20.0665L6.93555 20L5.93777 20.0665ZM18.0622 20.0665L17.0644 20L18.0622 20.0665ZM3 5C2.44772 5 2 5.44772 2 6C2 6.55228 2.44772 7 3 7V6V5ZM21 7C21.5523 7 22 6.55228 22 6C22 5.44772 21.5523 5 21 5V6V7ZM11 11C11 10.4477 10.5523 10 10 10C9.44772 10 9 10.4477 9 11H10H11ZM9 16C9 16.5523 9.44772 17 10 17C10.5523 17 11 16.5523 11 16H10H9ZM15 11C15 10.4477 14.5523 10 14 10C13.4477 10 13 10.4477 13 11H14H15ZM13 16C13 16.5523 13.4477 17 14 17C14.5523 17 15 16.5523 15 16H14H13ZM14.9056 6.24926C15.0432 6.78411 15.5884 7.1061 16.1233 6.96844C16.6581 6.83078 16.9801 6.28559 16.8424 5.75074L15.874 6L14.9056 6.24926ZM5 6L4.00221 6.06652L4.93998 20.133L5.93777 20.0665L6.93555 20L5.99779 5.93348L5 6ZM6.93555 21V22H17.0644V21V20H6.93555V21ZM18.0622 20.0665L19.06 20.133L19.9978 6.06652L19 6L18.0022 5.93348L17.0644 20L18.0622 20.0665ZM19 6V5H5V6V7H19V6ZM3 6V7H5V6V5H3V6ZM19 6V7H21V6V5H19V6ZM17.0644 21V22C18.1174 22 18.99 21.1836 19.06 20.133L18.0622 20.0665L17.0644 20H17.0644V21ZM5.93777 20.0665L4.93998 20.133C5.01002 21.1836 5.88262 22 6.93555 22V21V20V20L5.93777 20.0665ZM10 11H9V16H10H11V11H10ZM14 11H13V16H14H15V11H14ZM12 3V4C13.3965 4 14.5725 4.95512 14.9056 6.24926L15.874 6L16.8424 5.75074C16.2874 3.59442 14.3312 2 12 2V3ZM8.12604 6L9.09447 6.24926C9.42756 4.95512 10.6035 4 12 4V3V2C9.66885 2 7.7126 3.59442 7.1576 5.75074L8.12604 6Z",fill:e})})}function zm({size:t=24,color:e="currentColor"}){return(0,gt.jsx)("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",children:(0,gt.jsx)("path",{d:"M4.4834 14.6667C5.58163 17.7738 8.54493 20 12.0282 20C16.4465 20 20.0282 16.4183 20.0282 12C20.0282 7.58172 16.4465 4 12.0282 4C9.14453 4 7.27034 5.30135 5.41072 7.5M4.99986 4V7.5C4.99986 7.77614 5.22372 8 5.49986 8H8.99986",stroke:e,strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"})})}function Dm({size:t=24,color:e="currentColor"}){return(0,gt.jsx)("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",children:(0,gt.jsx)("path",{d:"M6.5 8C7.88071 8 9 6.88071 9 5.5C9 4.11929 7.88071 3 6.5 3C5.11929 3 4 4.11929 4 5.5C4 6.88071 5.11929 8 6.5 8ZM6.5 8V11C6.5 11.5523 6.94772 12 7.5 12H11C11.5523 12 12 12.4477 12 13M17.5 8C18.8807 8 20 6.88071 20 5.5C20 4.11929 18.8807 3 17.5 3C16.1193 3 15 4.11929 15 5.5C15 6.88071 16.1193 8 17.5 8ZM17.5 8V11C17.5 11.5523 17.0523 12 16.5 12H13C12.4477 12 12 12.4477 12 13M12 16C10.6193 16 9.5 17.1193 9.5 18.5C9.5 19.8807 10.6193 21 12 21C13.3807 21 14.5 19.8807 14.5 18.5C14.5 17.1193 13.3807 16 12 16ZM12 16V13",stroke:e,strokeWidth:2})})}function Rm({size:t=24,color:e="currentColor"}){return(0,gt.jsx)("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",children:(0,gt.jsx)("path",{d:"M6.5 8C7.88071 8 9 6.88071 9 5.5C9 4.11929 7.88071 3 6.5 3C5.11929 3 4 4.11929 4 5.5C4 6.88071 5.11929 8 6.5 8ZM6.5 8V16M6.5 16C5.11929 16 4 17.1193 4 18.5C4 19.8807 5.11929 21 6.5 21C7.88071 21 9 19.8807 9 18.5C9 17.1193 7.88071 16 6.5 16ZM17.5 16C16.1193 16 15 17.1193 15 18.5C15 19.8807 16.1193 21 17.5 21C18.8807 21 20 19.8807 20 18.5C20 17.1193 18.8807 16 17.5 16ZM17.5 16V6.5C17.5 5.94772 17.0523 5.5 16.5 5.5H12M12 5.5L14.5 3M12 5.5L14.5 8",stroke:e,strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"})})}function Om({size:t=24,color:e="currentColor"}){return(0,gt.jsx)("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",children:(0,gt.jsx)("path",{d:"M9 9V3.5C9 3.22386 9.22386 3 9.5 3H20.5C20.7761 3 21 3.22386 21 3.5V14.5C21 14.7761 20.7761 15 20.5 15H15M14.5 9H3.5C3.22386 9 3 9.22386 3 9.5V20.5C3 20.7761 3.22386 21 3.5 21H14.5C14.7761 21 15 20.7761 15 20.5V9.5C15 9.22386 14.7761 9 14.5 9Z",stroke:e,strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"})})}function Hm({size:t=24,color:e="currentColor"}){return(0,gt.jsx)("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",children:(0,gt.jsx)("path",{d:"M11.2479 10L15.2496 14.0017M15.2513 10L11.2496 14.0017M3.41478 11.4188L7.7005 5.41876C7.88821 5.15597 8.19128 5 8.51423 5H19.9996C20.5519 5 20.9996 5.44772 20.9996 6V18C20.9996 18.5523 20.5519 19 19.9996 19H8.51423C8.19128 19 7.88821 18.844 7.7005 18.5812L3.41478 12.5812C3.16643 12.2335 3.16643 11.7665 3.41478 11.4188Z",stroke:e,strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"})})}function Lm({size:t=24,color:e="currentColor"}){return(0,gt.jsx)("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",children:(0,gt.jsx)("path",{d:"M12.0003 21C11.5003 21 8.93732 20.1294 6.71782 17.9099C3.00784 14.1999 2.05809 9.13461 4.5965 6.5962C6.68218 4.51052 10.4738 4.77972 13.8179 7.00001M17.1066 10C19.9927 13.3312 21.2146 16.7286 19.0003 18.5C17.3415 19.8271 15.2424 18.2924 14.0176 17.1094M11.0003 13H13.6027C13.8683 13 14.1231 12.8943 14.3107 12.7062L20.2949 6.70711C20.6846 6.31644 20.6842 5.68395 20.294 5.29377L18.7074 3.70711C18.3168 3.31659 17.6837 3.31659 17.2931 3.70711L11.2932 9.70712C11.1057 9.89465 11.0003 10.149 11.0003 10.4142V13Z",stroke:e,strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"})})}function Bm({size:t=24,color:e="currentColor",animate:n=!1}){return(0,gt.jsxs)("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",children:[(0,gt.jsx)("path",{d:"M7 13L10 16L17 8",stroke:e,strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",...n?{strokeDasharray:20,strokeDashoffset:20,style:{animation:"iterate-check-draw 0.35s ease-out 0.1s forwards"}}:{}}),n&&(0,gt.jsx)("style",{children:"@keyframes iterate-check-draw { to { stroke-dashoffset: 0; } }"})]})}function go({size:t=24,color:e="currentColor"}){return(0,gt.jsxs)("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",style:{animation:"iterate-spin 0.8s linear infinite"},children:[(0,gt.jsx)("style",{children:"@keyframes iterate-spin { to { transform: rotate(360deg); } }"}),(0,gt.jsx)("circle",{cx:12,cy:12,r:9,stroke:e,strokeWidth:2,strokeLinecap:"round",strokeDasharray:"42 14"})]})}var en=ot(be(),1),Nm={panelBg:"#f7f7f7",cardBg:"#fff",toolbarBg:"#fff",drawerBg:"#efefef",hoverBg:"#f0f0f0",activeBg:"#e8e8e8",border:"#e0e0e0",textPrimary:"#333",textSecondary:"#666",textTertiary:"#999",textDisabled:"#888",iconDefault:"#666",iconHover:"#141414",suspenseOverlay:"rgba(255,255,255,0.75)",spinnerBg:"#e0e0e0",spinnerFg:"#666",tooltipBg:"#fff",tooltipText:"#333",tooltipKeyBg:"#f0f0f0",tooltipKeyText:"#888",buttonBg:"#333",buttonText:"#fff"},dp={panelBg:"#1e1e1e",cardBg:"#2a2a2a",toolbarBg:"#2a2a2a",drawerBg:"#252525",hoverBg:"#333",activeBg:"#3a3a3a",border:"#3a3a3a",textPrimary:"#e0e0e0",textSecondary:"#999",textTertiary:"#666",textDisabled:"#555",iconDefault:"#999",iconHover:"#e0e0e0",suspenseOverlay:"rgba(30,30,30,0.75)",spinnerBg:"#3a3a3a",spinnerFg:"#999",tooltipBg:"#2a2a2a",tooltipText:"#e0e0e0",tooltipKeyBg:"rgba(255,255,255,0.1)",tooltipKeyText:"#777",buttonBg:"#e0e0e0",buttonText:"#1e1e1e"};function mp(t){let e=t.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*(\d*\.?\d+))?\)/);if(!e||(e[4]!==void 0?Number(e[4]):1)<.1)return null;let[l,a,i]=[Number(e[1])/255,Number(e[2])/255,Number(e[3])/255],u=o=>o<=.03928?o/12.92:Math.pow((o+.055)/1.055,2.4);return .2126*u(l)+.7152*u(a)+.0722*u(i)}function os(t){let e=t??document,n=e.documentElement,l=n.getAttribute("data-theme")??n.getAttribute("data-color-mode")??"";if(l==="dark")return!0;if(l==="light")return!1;if(n.classList.contains("dark"))return!0;if(n.classList.contains("light"))return!1;let a=e.defaultView?.getComputedStyle(n).colorScheme??"";if(a==="dark")return!0;if(a==="light")return!1;let i=e.body;if(i){let u=e.defaultView?.getComputedStyle(i).colorScheme??"";if(u==="dark")return!0;if(u==="light")return!1}for(let u of[i,n]){if(!u)continue;let o=e.defaultView?.getComputedStyle(u).backgroundColor??"",c=mp(o);if(c!==null&&c<.2)return!0;if(c!==null&&c>.8)return!1}return window.matchMedia("(prefers-color-scheme: dark)").matches}var Um=(0,en.createContext)(Nm);function ve(){return(0,en.useContext)(Um)}function cs({children:t,targetDocument:e}){let[n,l]=(0,en.useState)(()=>os(e));return(0,en.useEffect)(()=>{l(os(e))},[e]),(0,en.useEffect)(()=>{let a=e??document,i=()=>l(os(a)),u=window.matchMedia("(prefers-color-scheme: dark)");u.addEventListener("change",i);let o=new MutationObserver(i);return o.observe(a.documentElement,{attributes:!0,attributeFilter:["class","data-theme","data-color-mode","style"]}),a.body&&o.observe(a.body,{attributes:!0,attributeFilter:["class","style"]}),()=>{u.removeEventListener("change",i),o.disconnect()}},[e]),en.default.createElement(Um.Provider,{value:n?dp:Nm},t)}var St=ot(Qt(),1),Bi="-apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif",hp="cubic-bezier(0.34, 1.56, 0.64, 1)";function yp(){let t=ve();return(0,St.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",children:(0,St.jsx)("path",{d:"M20 9L12.7071 16.2929C12.3166 16.6834 11.6834 16.6834 11.2929 16.2929L4 9",stroke:t.textTertiary,strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round"})})}function qm({selectedElements:t,textSelection:e,onAddToBatch:n,onClearSelection:l,clickPosition:a,isDrawing:i,initialComment:u,onDelete:o,iframeRef:c}){let r=ve(),[y,g]=(0,Yt.useState)(""),[d,m]=(0,Yt.useState)(new Set),b=(0,Yt.useRef)(null),E=(0,Yt.useRef)(null),[O,f]=(0,Yt.useState)(0),[s,h]=(0,Yt.useState)("hidden"),p=(0,Yt.useRef)(null),C=t.length>0||e!==null||i===!0,L=(0,Yt.useRef)(!1);(0,Yt.useEffect)(()=>{C&&!L.current&&(g(u??""),m(new Set)),L.current=C},[C,u]),(0,Yt.useEffect)(()=>{if(C){p.current&&(clearTimeout(p.current),p.current=null),h("entering");let w=0,X=requestAnimationFrame(()=>{w=requestAnimationFrame(()=>{h("visible")})});return()=>{cancelAnimationFrame(X),cancelAnimationFrame(w)}}else h(w=>w==="hidden"?"hidden":"exiting"),p.current=setTimeout(()=>{h("hidden"),p.current=null},200)},[C]),(0,Yt.useEffect)(()=>()=>{p.current&&clearTimeout(p.current)},[]),(0,Yt.useEffect)(()=>{C&&setTimeout(()=>b.current?.focus(),100)},[C]);let[A,q]=(0,Yt.useState)(!1),z=(0,Yt.useRef)(null);if((0,Yt.useEffect)(()=>{if(s!=="visible")return;let w=N=>{E.current?.contains(N.target)||(N.preventDefault(),N.stopPropagation(),q(!0),z.current&&clearTimeout(z.current),z.current=setTimeout(()=>{q(!1),z.current=null},400),b.current?.focus())};document.addEventListener("mousedown",w,{capture:!0});let X=null;try{X=c?.current?.contentDocument??null}catch{}return X?.addEventListener("mousedown",w,{capture:!0}),()=>{document.removeEventListener("mousedown",w,{capture:!0}),X?.removeEventListener("mousedown",w,{capture:!0})}},[s,c]),(0,Yt.useEffect)(()=>()=>{z.current&&clearTimeout(z.current)},[]),(0,Yt.useLayoutEffect)(()=>{if(s==="hidden"||!E.current)return;let w=new ResizeObserver(X=>{for(let N of X)f(N.borderBoxSize?.[0]?.blockSize??N.target.getBoundingClientRect().height)});return w.observe(E.current),()=>w.disconnect()},[s]),s==="hidden")return null;let k=s==="visible",wt=w=>{w.preventDefault(),y.trim()&&(n(y.trim()),g(""),m(new Set))},Vt=w=>{w.key==="Enter"&&(w.metaKey||w.ctrlKey)&&wt(w),w.key==="Escape"&&l()},_t=w=>{m(X=>{let N=new Set(X);return N.has(w)?N.delete(w):N.add(w),N})},ee=[];if(i)ee.push({name:"Path",styles:{},key:"drawing-path"});else if(t.forEach((w,X)=>{ee.push({name:w.componentName||w.elementName,styles:w.computedStyles||{},key:w.selector+X})}),e&&t.length===0){let w=e.containingElement;ee.push({name:w.componentName||w.elementName,styles:w.computedStyles||{},key:"text-selection"})}let zt=300,kt=16,ne=window.innerHeight*.8,Tt=O>0?Math.min(O,ne):ne,qt=a??{x:window.scrollX+window.innerWidth-kt-zt,y:window.scrollY+window.innerHeight/2},he=qt.x-window.scrollX,Bt=qt.x+kt;he+kt+zt+kt>window.innerWidth&&(Bt=qt.x-zt-kt),Bt=Math.max(window.scrollX+kt,Math.min(Bt,window.scrollX+window.innerWidth-zt-kt));let Z=qt.y-Tt/2;return Z=Math.max(window.scrollY+kt,Math.min(Z,window.scrollY+window.innerHeight-Tt-kt)),(0,St.jsxs)(St.Fragment,{children:[(0,St.jsx)("style",{children:`
42
+ `}return l+="Please process this feedback and make the requested changes.",l}var Ln=ot(be(),1);function Ol(t){if(t.id)return`#${CSS.escape(t.id)}`;let e=[],n=t;for(;n&&n!==document.documentElement;){let l=n.tagName.toLowerCase(),a=Array.from(n.classList).filter(i=>!i.startsWith("__")&&!i.includes("svelte-")&&!/^[a-z]{1,2}$/.test(i)&&!/[_][a-zA-Z0-9]{5,}/.test(i)).slice(0,2);if(a.length>0&&(l+=a.map(i=>`.${CSS.escape(i)}`).join("")),n.parentElement&&n.parentElement.querySelectorAll(`:scope > ${l}`).length>1){let u=Array.from(n.parentElement.children).indexOf(n)+1;l+=`:nth-child(${u})`}if(e.unshift(l),document.querySelectorAll(e.join(" > ")).length===1)break;n=n.parentElement}return e.join(" > ")}function rm(t,e=4){let n=[],l=t,a=0;for(;l&&l!==document.documentElement&&a<e;){let i=l.tagName.toLowerCase(),u=Array.from(l.classList).filter(o=>!/[_][a-zA-Z0-9]{5,}/.test(o)).slice(0,1);n.unshift(u.length>0?`${i}.${u[0]}`:i),l=l.parentElement,a++}return n.join(" > ")}function us(t){let e=t.tagName.toLowerCase(),n=t.getAttribute("data-element");if(n)return n;if(e==="button"||t.getAttribute("role")==="button"){let a=t.getAttribute("aria-label");if(a)return`button [${a}]`;let i=t.textContent?.trim().slice(0,30);return i?`button "${i}"`:"button"}if(e==="a"){let a=t.textContent?.trim().slice(0,30);return a?`link "${a}"`:"link"}if(e==="input"){let a=t.type||"text",i=t.name,u=t.placeholder;return i?`input[${a}] "${i}"`:u?`input[${a}] "${u}"`:`input[${a}]`}if(e==="img"){let a=t.alt;return a?`image "${a.slice(0,30)}"`:"image"}if(/^h[1-6]$/.test(e)){let a=t.textContent?.trim().slice(0,30);return a?`${e} "${a}"`:e}if(t.id)return`#${t.id}`;let l=Array.from(t.classList).filter(a=>!/[_][a-zA-Z0-9]{5,}/.test(a)&&a.length>2).at(0);return l?`${e}.${l}`:e}function sm(t){let e=[],n=t.previousElementSibling;n?.textContent?.trim()&&e.push(`[prev] ${n.textContent.trim().slice(0,50)}`);let l=t.textContent?.trim();l&&e.push(l.slice(0,80));let a=t.nextElementSibling;return a?.textContent?.trim()&&e.push(`[next] ${a.textContent.trim().slice(0,50)}`),e.join(" | ")}function Fg(t){for(let e of Object.keys(t))if(e.startsWith("__reactFiber$")||e.startsWith("__reactInternalInstance$"))return t[e];return null}var Ig=new Set(["AppRouter","Router","HotReload","InnerLayoutRouter","OuterLayoutRouter","RenderFromTemplateContext","ScrollAndFocusHandler","InnerScrollAndFocusHandler","ClientPageRoot","SegmentViewNode","SegmentStateProvider","RootErrorBoundary","AppDevOverlayErrorBoundary","DevRootHTTPAccessFallbackBoundary","Root","ServerRoot","ErrorBoundary","ErrorBoundaryHandler","Suspense","RedirectBoundary","RedirectErrorBoundary","HTTPAccessFallbackBoundary","HTTPAccessFallbackErrorBoundary","LoadingBoundary"]);function Pg(t){if(!t||!t.type||typeof t.type=="string")return!1;let e=t.type.displayName||t.type.name;return!(!e||!/^[A-Z]/.test(e)||Ig.has(e)||/Context$|Provider$/.test(e))}function Hi(t){let e=t.getAttribute("data-iterate-component");if(e)return{component:e,source:t.getAttribute("data-iterate-source"),isComponentRoot:!0};let n=Fg(t);if(n){let i=n,u=!0;for(;i;){if(Pg(i)){let o=i.type.displayName||i.type.name,c=i._debugSource,r=c?`${c.fileName}:${c.lineNumber}`:null;return{component:o,source:r,isComponentRoot:u}}i===n.return&&(u=!1),i=i.return}}let l=t,a=!0;for(;l&&l!==document.documentElement;){let i=l.getAttribute("data-iterate-component"),u=l.getAttribute("data-iterate-source");if(i)return{component:i,source:u,isComponentRoot:a};l=l.parentElement,a=!1}return{component:null,source:null,isComponentRoot:!1}}var tp=new Set(["p","span","h1","h2","h3","h4","h5","h6","label","a","li"]),ep=new Set(["div","section","main","article","aside","nav","header","footer"]),np=new Set(["button","input","select","textarea"]),om=["color","font-size","font-weight","font-family","line-height","text-align","text-decoration","letter-spacing"],cm=["display","flex-direction","justify-content","align-items","gap","grid-template-columns","grid-template-rows","padding","margin","background-color","border-radius","overflow"],lp=["background-color","color","padding","border-radius","font-size","font-weight","border","cursor","outline"],ap=["position","top","left","right","bottom","z-index","width","height"],ip=new Set(["none","normal","auto","0px","transparent","rgba(0, 0, 0, 0)"]);function za(t){let e=window.getComputedStyle(t),n=t.tagName.toLowerCase(),l={},a=[...ap];tp.has(n)?a=a.concat(om):np.has(n)?a=a.concat(lp):ep.has(n)?a=a.concat(cm):a=a.concat(cm,om);for(let i of a){let u=e.getPropertyValue(i);u&&!ip.has(u)&&(l[i]=u)}return l}var sl=ot(Qt(),1);function hm({active:t,iframeRef:e,selectedElements:n,onSelect:l,suppressHover:a,justFinishedDragRef:i}){let[u,o]=(0,Ln.useState)(null),[c,r]=(0,Ln.useState)(""),[y,g]=(0,Ln.useState)(null),d=(0,Ln.useCallback)(()=>{try{return e.current?.contentDocument??document}catch{return document}},[e]);return(0,Ln.useEffect)(()=>{a&&(o(null),g(null))},[a]),(0,Ln.useEffect)(()=>{if(!t){o(null),g(null);return}let m=d(),b=f=>!!f.closest("#__iterate-overlay-root__")||!!f.closest("#__iterate-markers-layer__")||!!f.closest("#__iterate-fixed-markers-layer__"),E=f=>{if(a)return;let s=f.target;if(!s||s===m.documentElement||b(s)){o(null),g(null);return}let h=s.getBoundingClientRect();o({x:h.x,y:h.y,width:h.width,height:h.height}),g({x:f.clientX,y:f.clientY});let{component:p,isComponentRoot:C}=Hi(s);r(p&&C?`<${p}>`:us(s))},O=f=>{if(i?.current){i.current=!1;return}let s=f.target;if(!s||b(s))return;f.preventDefault(),f.stopPropagation();let h=Hl(s),p={x:f.clientX,y:f.clientY};if(f.ctrlKey||f.metaKey){let L=n.findIndex(A=>A.selector===h.selector);if(L>=0){let A=[...n];A.splice(L,1),l(A,p)}else l([...n,h],p)}else l([h],p)};return m.addEventListener("mousemove",E),m.addEventListener("click",O,{capture:!0}),()=>{m.removeEventListener("mousemove",E),m.removeEventListener("click",O,{capture:!0})}},[t,d,l,n,a]),t?(0,sl.jsx)("div",{style:{position:"absolute",inset:0,pointerEvents:"none"},children:u&&(0,sl.jsxs)(sl.Fragment,{children:[(0,sl.jsx)("div",{style:{position:"absolute",left:u.x,top:u.y,width:u.width,height:u.height,border:"1.5px solid #6b9eff",backgroundColor:"rgba(107, 158, 255, 0.06)",borderRadius:4,pointerEvents:"none",boxSizing:"border-box",transition:"all 0.1s ease"}}),y&&(0,sl.jsx)("div",{style:{position:"absolute",left:y.x+12,top:y.y+16,background:"#6b9eff",color:"#fff",padding:"2px 8px",borderRadius:4,fontSize:11,fontFamily:"monospace",whiteSpace:"nowrap",pointerEvents:"none",maxWidth:400,overflow:"hidden",textOverflow:"ellipsis"},children:c})]})}):null}function Hl(t){let e=t.getBoundingClientRect(),{component:n,source:l,isComponentRoot:a}=Hi(t);return{domElement:t,selector:Ol(t),elementName:us(t),elementPath:rm(t),rect:{x:e.x,y:e.y,width:e.width,height:e.height},computedStyles:za(t),nearbyText:sm(t),componentName:a?n:null,sourceLocation:a?l:null}}var dn=ot(be(),1);var Li=ot(Qt(),1);function ym({active:t,iframeRef:e,onSelect:n,onDragStateChange:l,justFinishedDragRef:a}){let[i,u]=(0,dn.useState)(null),[o,c]=(0,dn.useState)(null),[r,y]=(0,dn.useState)([]),g=(0,dn.useRef)(0),d=(0,dn.useCallback)(()=>{try{return e.current?.contentDocument??document}catch{return document}},[e]);return(0,dn.useEffect)(()=>{if(!t){u(null),c(null);return}let m=d(),b=!1,E={x:0,y:0},O=h=>{if(h.button!==0||h.ctrlKey||h.metaKey)return;let p=h.target;p.closest("#__iterate-overlay-root__")||p.closest("#__iterate-markers-layer__")||(h.preventDefault(),b=!0,E={x:h.clientX,y:h.clientY},c(E),l?.(!0))},f=h=>{if(!b)return;let p=Math.min(E.x,h.clientX),C=Math.min(E.y,h.clientY),L=Math.abs(h.clientX-E.x),A=Math.abs(h.clientY-E.y);if(L>10||A>10){let q={x:p,y:C,width:L,height:A};u(q);let z=Date.now();if(z-g.current>80){g.current=z;let k=cp(m,q);y(k)}}},s=h=>{if(!b)return;b=!1,l?.(!1);let p={x:Math.min(E.x,h.clientX),y:Math.min(E.y,h.clientY),width:Math.abs(h.clientX-E.x),height:Math.abs(h.clientY-E.y)};if(u(null),c(null),y([]),p.width<20||p.height<20)return;let C=rp(m,p);C.length>0&&(a&&(a.current=!0),n(C))};return m.addEventListener("mousedown",O),m.addEventListener("mousemove",f),m.addEventListener("mouseup",s),()=>{m.removeEventListener("mousedown",O),m.removeEventListener("mousemove",f),m.removeEventListener("mouseup",s)}},[t,d,n,l]),!t||!i?null:(0,Li.jsxs)("div",{style:{position:"absolute",inset:0,pointerEvents:"none"},children:[(0,Li.jsx)("div",{style:{position:"absolute",left:i.x,top:i.y,width:i.width,height:i.height,border:"1.5px dashed #6b9eff",backgroundColor:"rgba(107, 158, 255, 0.06)",borderRadius:3,pointerEvents:"none"}}),r.map((m,b)=>(0,Li.jsx)("div",{style:{position:"absolute",left:m.x,top:m.y,width:m.width,height:m.height,border:"1.5px solid #6b9eff",borderRadius:4,pointerEvents:"none",boxSizing:"border-box"}},b))]})}function gm(t,e,n){return t.left>=e.x-n&&t.right<=e.x+e.width+n&&t.top>=e.y-n&&t.bottom<=e.y+e.height+n}var pm=new Set(["html","body","head","script","style","meta","link","noscript"]),vm=t=>!!t.closest("#__iterate-overlay-root__")||!!t.closest("#__iterate-markers-layer__"),bm=8;function cp(t,e){let n=new Set,l=t.querySelectorAll("*");for(let i of l){if(pm.has(i.tagName.toLowerCase())||vm(i))continue;let u=i.getBoundingClientRect();u.width===0||u.height===0||u.width>e.width*2&&u.height>e.height*2||gm(u,e,bm)&&n.add(i)}let a=[];for(let i of n){let u=i.parentElement,o=!1;for(;u;){if(n.has(u)){o=!0;break}u=u.parentElement}if(!o){let c=i.getBoundingClientRect();a.push({x:c.x,y:c.y,width:c.width,height:c.height})}}return a}function rp(t,e){let n=new Set,l=t.querySelectorAll("*");for(let i of l){if(pm.has(i.tagName.toLowerCase())||vm(i))continue;let u=i.getBoundingClientRect();u.width===0||u.height===0||u.width>e.width*2&&u.height>e.height*2||gm(u,e,bm)&&n.add(i)}let a=[];for(let i of n){let u=i.parentElement,o=!1;for(;u;){if(n.has(u)){o=!0;break}u=u.parentElement}o||a.push(Hl(i))}return a}var Ll=ot(be(),1);var yo=ot(Qt(),1);function Sm({active:t,iframeRef:e,onTextSelect:n}){let[l,a]=(0,Ll.useState)(null),[i,u]=(0,Ll.useState)(""),o=(0,Ll.useCallback)(()=>{try{return e.current?.contentDocument??document}catch{return document}},[e]);return(0,Ll.useEffect)(()=>{if(!t){a(null),u("");return}let c=o(),r=()=>{let m=c.getSelection();if(!m||m.isCollapsed||!m.rangeCount){a(null),u(""),n(null);return}let b=m.getRangeAt(0),E=m.toString().trim();if(!E||E.length<2){a(null),u("");return}let O=b.commonAncestorContainer,f=O.nodeType===Node.ELEMENT_NODE?O:O.parentElement;if(!f)return;let s=Hl(f),h=b.getBoundingClientRect();a({x:h.x+h.width/2,y:h.y-4}),u(E),n({text:E,containingElement:{selector:s.selector,elementName:s.elementName,elementPath:s.elementPath,rect:s.rect,computedStyles:s.computedStyles,nearbyText:s.nearbyText,componentName:s.componentName,sourceLocation:s.sourceLocation},startOffset:b.startOffset,endOffset:b.endOffset})},y,g=()=>{clearTimeout(y),y=setTimeout(r,150)};c.addEventListener("selectionchange",g);let d=()=>{setTimeout(r,50)};return c.addEventListener("mouseup",d),()=>{clearTimeout(y),c.removeEventListener("selectionchange",g),c.removeEventListener("mouseup",d)}},[t,o,n]),!t||!l||!i?null:(0,yo.jsx)("div",{style:{position:"absolute",inset:0,pointerEvents:"none"},children:(0,yo.jsxs)("div",{style:{position:"absolute",left:l.x,top:l.y,transform:"translate(-50%, -100%)",background:"#2563eb",color:"#fff",padding:"3px 8px",borderRadius:4,fontSize:10,fontFamily:"-apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif",whiteSpace:"nowrap",pointerEvents:"none",maxWidth:250,overflow:"hidden",textOverflow:"ellipsis"},children:['"',i.slice(0,50),i.length>50?"...":"",'"']})})}var tn=ot(be(),1);var Bl=ot(Qt(),1),Em="#2563eb",xm=3;function Mm({active:t,iframeRef:e,onDrawComplete:n}){let[l,a]=(0,tn.useState)(!1),[i,u]=(0,tn.useState)([]),[o,c]=(0,tn.useState)([]),r=(0,tn.useRef)([]),y=(0,tn.useCallback)(()=>{try{return e.current?.contentDocument??document}catch{return document}},[e]);if((0,tn.useEffect)(()=>{t||c([])},[t]),(0,tn.useEffect)(()=>{if(!t){a(!1),u([]),r.current=[];return}let d=y(),m=O=>{if(O.button!==0||O.target?.closest?.("#__iterate-markers-layer__, #__iterate-fixed-markers-layer__, [data-iterate-popup], [data-iterate-panel]"))return;O.preventDefault(),O.stopPropagation(),a(!0);let s={x:O.clientX,y:O.clientY};r.current=[s],u([s])},b=O=>{if(!l)return;let f={x:O.clientX,y:O.clientY};r.current.push(f),r.current.length%2===0&&u([...r.current])},E=O=>{if(!l)return;a(!1);let f=r.current;if(f.length<3){u([]),r.current=[];return}let s=Tm(f),h=sp(f),p={path:s,bounds:h,strokeColor:Em,strokeWidth:xm},C=fp(d,h);c(L=>[...L,p]),u([]),r.current=[],n(C,p)};return d.addEventListener("mousedown",m,{capture:!0}),d.addEventListener("mousemove",b),d.addEventListener("mouseup",E),()=>{d.removeEventListener("mousedown",m,{capture:!0}),d.removeEventListener("mousemove",b),d.removeEventListener("mouseup",E)}},[t,l,y,n]),!t)return null;let g=i.length>=2?Tm(i):null;return(0,Bl.jsxs)("div",{style:{position:"absolute",inset:0,pointerEvents:"none",cursor:"crosshair"},children:[(0,Bl.jsxs)("svg",{style:{position:"absolute",inset:0,width:"100%",height:"100%",pointerEvents:"none",overflow:"visible"},children:[o.map((d,m)=>(0,Bl.jsx)("path",{d:d.path,fill:"none",stroke:d.strokeColor,strokeWidth:d.strokeWidth,strokeLinecap:"round",strokeLinejoin:"round",opacity:.6},`completed-${m}`)),g&&(0,Bl.jsx)("path",{d:g,fill:"none",stroke:Em,strokeWidth:xm,strokeLinecap:"round",strokeLinejoin:"round"})]}),!l&&(0,Bl.jsx)("div",{style:{position:"absolute",inset:0,pointerEvents:"auto",cursor:"crosshair"}})]})}function Tm(t){if(t.length===0)return"";let e=[`M ${t[0].x} ${t[0].y}`];for(let n=1;n<t.length-1;n++){let l=t[n],a=t[n+1],i=(l.x+a.x)/2,u=(l.y+a.y)/2;e.push(`Q ${l.x} ${l.y} ${i} ${u}`)}if(t.length>1){let n=t[t.length-1];e.push(`L ${n.x} ${n.y}`)}return e.join(" ")}function sp(t){let e=1/0,n=1/0,l=-1/0,a=-1/0;for(let i of t)i.x<e&&(e=i.x),i.y<n&&(n=i.y),i.x>l&&(l=i.x),i.y>a&&(a=i.y);return{x:e,y:n,width:l-e,height:a-n}}function fp(t,e){let n=[],l=new Set,a=10,i={x:e.x-a,y:e.y-a,width:e.width+a*2,height:e.height+a*2},u=t.querySelectorAll("*");for(let o of u){let c=o.tagName.toLowerCase();if(["html","body","head","script","style","meta","link","noscript"].includes(c)||o.closest("#__iterate-overlay-root__")||o.closest("#__iterate-markers-layer__"))continue;let r=o.getBoundingClientRect();if(!(r.width===0||r.height===0)&&!(r.width>i.width*3&&r.height>i.height*3)&&r.left<i.x+i.width&&r.right>i.x&&r.top<i.y+i.height&&r.bottom>i.y){let y=!1,g=o.parentElement;for(;g;){if(l.has(g)){y=!0;break}g=g.parentElement}if(!y){for(let d=n.length-1;d>=0;d--)o.contains(n[d].domElement)&&n.splice(d,1);l.add(o),n.push(Hl(o))}}}return n}var Yt=ot(be(),1);var rv=ot(be(),1),gt=ot(Qt(),1);function Cm({size:t=24,color:e="currentColor"}){return(0,gt.jsx)("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",children:(0,gt.jsx)("path",{d:"M10 4H11C11 3.44772 10.5523 3 10 3V4ZM10 10V11C10.5523 11 11 10.5523 11 10H10ZM4 10H3C3 10.5523 3.44772 11 4 11V10ZM4.54601 4.10899L5 5L4.54601 4.10899ZM4.10899 4.54601L5 5L4.10899 4.54601ZM14 4V3C13.4477 3 13 3.44772 13 4H14ZM20 10V11C20.5523 11 21 10.5523 21 10H20ZM14 10H13C13 10.5523 13.4477 11 14 11V10ZM19.454 4.10899L19 5L19.454 4.10899ZM19.891 4.54601L19 5L19.891 4.54601ZM4 14V13C3.44772 13 3 13.4477 3 14H4ZM10 14H11C11 13.4477 10.5523 13 10 13V14ZM10 20V21C10.5523 21 11 20.5523 11 20H10ZM4.54601 19.891L5 19L4.54601 19.891ZM4.10899 19.454L5 19L4.10899 19.454ZM20.2929 21.7076C20.6834 22.0981 21.3166 22.0981 21.7071 21.7076C22.0976 21.317 22.0976 20.6839 21.7071 20.2934L21 21.0005L20.2929 21.7076ZM5.6 4V5H10V4V3H5.6V4ZM10 4H9V10H10H11V4H10ZM10 10V9H4V10V11H10V10ZM4 10H5V5.6H4H3V10H4ZM5.6 4V3C5.33647 3 5.07869 2.99922 4.86177 3.01695C4.63318 3.03562 4.36344 3.07969 4.09202 3.21799L4.54601 4.10899L5 5C4.94249 5.0293 4.91972 5.01887 5.02463 5.0103C5.14122 5.00078 5.30347 5 5.6 5V4ZM4 5.6H5C5 5.30347 5.00078 5.14122 5.0103 5.02463C5.01887 4.91972 5.0293 4.94249 5 5L4.10899 4.54601L3.21799 4.09202C3.07969 4.36344 3.03562 4.63318 3.01695 4.86177C2.99922 5.07869 3 5.33647 3 5.6H4ZM4.54601 4.10899L4.09202 3.21799C3.71569 3.40973 3.40973 3.71569 3.21799 4.09202L4.10899 4.54601L5 5V5L4.54601 4.10899ZM14 4V5H18.4V4V3H14V4ZM20 5.6H19V10H20H21V5.6H20ZM20 10V9H14V10V11H20V10ZM14 10H15V4H14H13V10H14ZM18.4 4V5C18.6965 5 18.8588 5.00078 18.9754 5.0103C19.0803 5.01887 19.0575 5.0293 19 5L19.454 4.10899L19.908 3.21799C19.6366 3.07969 19.3668 3.03562 19.1382 3.01695C18.9213 2.99922 18.6635 3 18.4 3V4ZM20 5.6H21C21 5.33647 21.0008 5.07869 20.9831 4.86177C20.9644 4.63318 20.9203 4.36344 20.782 4.09202L19.891 4.54601L19 5C18.9707 4.94249 18.9811 4.91972 18.9897 5.02463C18.9992 5.14122 19 5.30347 19 5.6H20ZM19.454 4.10899L19 5V5L19.891 4.54601L20.782 4.09202C20.5903 3.7157 20.2843 3.40973 19.908 3.21799L19.454 4.10899ZM4 14V15H10V14V13H4V14ZM10 14H9V20H10H11V14H10ZM10 20V19H5.6V20V21H10V20ZM4 18.4H5V14H4H3V18.4H4ZM5.6 20V19C5.30347 19 5.14122 18.9992 5.02463 18.9897C4.91972 18.9811 4.94249 18.9707 5 19L4.54601 19.891L4.09202 20.782C4.36344 20.9203 4.63318 20.9644 4.86177 20.9831C5.07869 21.0008 5.33647 21 5.6 21V20ZM4 18.4H3C3 18.6635 2.99922 18.9213 3.01695 19.1382C3.03562 19.3668 3.07969 19.6366 3.21799 19.908L4.10899 19.454L5 19C5.0293 19.0575 5.01887 19.0803 5.0103 18.9754C5.00078 18.8588 5 18.6965 5 18.4H4ZM4.54601 19.891L5 19V19L4.10899 19.454L3.21799 19.908C3.40973 20.2843 3.7157 20.5903 4.09202 20.782L4.54601 19.891ZM19.1213 19.1218L18.4142 18.4147C17.6332 19.1957 16.3668 19.1957 15.5858 18.4147L14.8787 19.1218L14.1716 19.8289C15.7337 21.391 18.2663 21.391 19.8284 19.8289L19.1213 19.1218ZM14.8787 19.1218L15.5858 18.4147C14.8047 17.6336 14.8047 16.3673 15.5858 15.5862L14.8787 14.8791L14.1716 14.172C12.6095 15.7341 12.6095 18.2668 14.1716 19.8289L14.8787 19.1218ZM14.8787 14.8791L15.5858 15.5862C16.3668 14.8052 17.6332 14.8052 18.4142 15.5862L19.1213 14.8791L19.8284 14.172C18.2663 12.6099 15.7337 12.6099 14.1716 14.172L14.8787 14.8791ZM19.1213 14.8791L18.4142 15.5862C19.1953 16.3673 19.1953 17.6336 18.4142 18.4147L19.1213 19.1218L19.8284 19.8289C21.3905 18.2668 21.3905 15.7341 19.8284 14.172L19.1213 14.8791ZM19.1213 19.1218L18.4142 19.8289L20.2929 21.7076L21 21.0005L21.7071 20.2934L19.8284 18.4147L19.1213 19.1218Z",fill:e})})}function wm({size:t=24,color:e="currentColor"}){return(0,gt.jsx)("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",children:(0,gt.jsx)("path",{d:"M15 9L9 15M15 15L9 9M21 12C21 16.9706 16.9706 21 12 21C7.02944 21 3 16.9706 3 12C3 7.02944 7.02944 3 12 3C16.9706 3 21 7.02944 21 12Z",stroke:e,strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})})}function _m({size:t=24,color:e="currentColor"}){return(0,gt.jsx)("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",children:(0,gt.jsx)("path",{d:"M11 3V4.5M16.6569 5.34326L15.5962 6.40392M6.40381 15.5962L5.34315 16.6569M4.5 11H3M6.40381 6.40381L5.34315 5.34315M14.3136 20.7675L10.4536 10.7769C10.3754 10.5745 10.5745 10.3754 10.7769 10.4536L20.7675 14.3136C20.9626 14.3889 20.9844 14.6562 20.8042 14.7623L17.0559 16.9671C17.0192 16.9887 16.9887 17.0192 16.9671 17.0559L14.7623 20.8042C14.6562 20.9844 14.3889 20.9626 14.3136 20.7675Z",stroke:e,strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"})})}function Am({size:t=24,color:e="currentColor"}){return(0,gt.jsx)("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",children:(0,gt.jsx)("path",{d:"M8.99989 5.74989L11.4696 3.28022C11.7624 2.98732 12.2373 2.98732 12.5302 3.28022L14.9999 5.74989M5.74989 8.99989L3.28022 11.4696C2.98732 11.7624 2.98732 12.2373 3.28022 12.5302L5.74989 14.9999M18.2499 8.99989L20.7196 11.4696C21.0125 11.7624 21.0125 12.2373 20.7196 12.5302L18.2499 14.9999M14.9999 18.2499L12.5302 20.7196C12.2373 21.0125 11.7624 21.0125 11.4696 20.7196L8.99989 18.2499M11.9999 3.99989V11.9999M11.9999 11.9999V19.9999M11.9999 11.9999H3.99989M11.9999 11.9999H19.9999",stroke:e,strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"})})}function Da({size:t=24,color:e="currentColor"}){return(0,gt.jsx)("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",children:(0,gt.jsx)("path",{d:"M5.93777 20.0665L6.93555 20L5.93777 20.0665ZM18.0622 20.0665L17.0644 20L18.0622 20.0665ZM3 5C2.44772 5 2 5.44772 2 6C2 6.55228 2.44772 7 3 7V6V5ZM21 7C21.5523 7 22 6.55228 22 6C22 5.44772 21.5523 5 21 5V6V7ZM11 11C11 10.4477 10.5523 10 10 10C9.44772 10 9 10.4477 9 11H10H11ZM9 16C9 16.5523 9.44772 17 10 17C10.5523 17 11 16.5523 11 16H10H9ZM15 11C15 10.4477 14.5523 10 14 10C13.4477 10 13 10.4477 13 11H14H15ZM13 16C13 16.5523 13.4477 17 14 17C14.5523 17 15 16.5523 15 16H14H13ZM14.9056 6.24926C15.0432 6.78411 15.5884 7.1061 16.1233 6.96844C16.6581 6.83078 16.9801 6.28559 16.8424 5.75074L15.874 6L14.9056 6.24926ZM5 6L4.00221 6.06652L4.93998 20.133L5.93777 20.0665L6.93555 20L5.99779 5.93348L5 6ZM6.93555 21V22H17.0644V21V20H6.93555V21ZM18.0622 20.0665L19.06 20.133L19.9978 6.06652L19 6L18.0022 5.93348L17.0644 20L18.0622 20.0665ZM19 6V5H5V6V7H19V6ZM3 6V7H5V6V5H3V6ZM19 6V7H21V6V5H19V6ZM17.0644 21V22C18.1174 22 18.99 21.1836 19.06 20.133L18.0622 20.0665L17.0644 20H17.0644V21ZM5.93777 20.0665L4.93998 20.133C5.01002 21.1836 5.88262 22 6.93555 22V21V20V20L5.93777 20.0665ZM10 11H9V16H10H11V11H10ZM14 11H13V16H14H15V11H14ZM12 3V4C13.3965 4 14.5725 4.95512 14.9056 6.24926L15.874 6L16.8424 5.75074C16.2874 3.59442 14.3312 2 12 2V3ZM8.12604 6L9.09447 6.24926C9.42756 4.95512 10.6035 4 12 4V3V2C9.66885 2 7.7126 3.59442 7.1576 5.75074L8.12604 6Z",fill:e})})}function zm({size:t=24,color:e="currentColor"}){return(0,gt.jsx)("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",children:(0,gt.jsx)("path",{d:"M4.4834 14.6667C5.58163 17.7738 8.54493 20 12.0282 20C16.4465 20 20.0282 16.4183 20.0282 12C20.0282 7.58172 16.4465 4 12.0282 4C9.14453 4 7.27034 5.30135 5.41072 7.5M4.99986 4V7.5C4.99986 7.77614 5.22372 8 5.49986 8H8.99986",stroke:e,strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"})})}function Dm({size:t=24,color:e="currentColor"}){return(0,gt.jsx)("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",children:(0,gt.jsx)("path",{d:"M6.5 8C7.88071 8 9 6.88071 9 5.5C9 4.11929 7.88071 3 6.5 3C5.11929 3 4 4.11929 4 5.5C4 6.88071 5.11929 8 6.5 8ZM6.5 8V11C6.5 11.5523 6.94772 12 7.5 12H11C11.5523 12 12 12.4477 12 13M17.5 8C18.8807 8 20 6.88071 20 5.5C20 4.11929 18.8807 3 17.5 3C16.1193 3 15 4.11929 15 5.5C15 6.88071 16.1193 8 17.5 8ZM17.5 8V11C17.5 11.5523 17.0523 12 16.5 12H13C12.4477 12 12 12.4477 12 13M12 16C10.6193 16 9.5 17.1193 9.5 18.5C9.5 19.8807 10.6193 21 12 21C13.3807 21 14.5 19.8807 14.5 18.5C14.5 17.1193 13.3807 16 12 16ZM12 16V13",stroke:e,strokeWidth:2})})}function Rm({size:t=24,color:e="currentColor"}){return(0,gt.jsx)("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",children:(0,gt.jsx)("path",{d:"M6.5 8C7.88071 8 9 6.88071 9 5.5C9 4.11929 7.88071 3 6.5 3C5.11929 3 4 4.11929 4 5.5C4 6.88071 5.11929 8 6.5 8ZM6.5 8V16M6.5 16C5.11929 16 4 17.1193 4 18.5C4 19.8807 5.11929 21 6.5 21C7.88071 21 9 19.8807 9 18.5C9 17.1193 7.88071 16 6.5 16ZM17.5 16C16.1193 16 15 17.1193 15 18.5C15 19.8807 16.1193 21 17.5 21C18.8807 21 20 19.8807 20 18.5C20 17.1193 18.8807 16 17.5 16ZM17.5 16V6.5C17.5 5.94772 17.0523 5.5 16.5 5.5H12M12 5.5L14.5 3M12 5.5L14.5 8",stroke:e,strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"})})}function Om({size:t=24,color:e="currentColor"}){return(0,gt.jsx)("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",children:(0,gt.jsx)("path",{d:"M9 9V3.5C9 3.22386 9.22386 3 9.5 3H20.5C20.7761 3 21 3.22386 21 3.5V14.5C21 14.7761 20.7761 15 20.5 15H15M14.5 9H3.5C3.22386 9 3 9.22386 3 9.5V20.5C3 20.7761 3.22386 21 3.5 21H14.5C14.7761 21 15 20.7761 15 20.5V9.5C15 9.22386 14.7761 9 14.5 9Z",stroke:e,strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"})})}function Hm({size:t=24,color:e="currentColor"}){return(0,gt.jsx)("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",children:(0,gt.jsx)("path",{d:"M11.2479 10L15.2496 14.0017M15.2513 10L11.2496 14.0017M3.41478 11.4188L7.7005 5.41876C7.88821 5.15597 8.19128 5 8.51423 5H19.9996C20.5519 5 20.9996 5.44772 20.9996 6V18C20.9996 18.5523 20.5519 19 19.9996 19H8.51423C8.19128 19 7.88821 18.844 7.7005 18.5812L3.41478 12.5812C3.16643 12.2335 3.16643 11.7665 3.41478 11.4188Z",stroke:e,strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"})})}function Lm({size:t=24,color:e="currentColor"}){return(0,gt.jsx)("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",children:(0,gt.jsx)("path",{d:"M12.0003 21C11.5003 21 8.93732 20.1294 6.71782 17.9099C3.00784 14.1999 2.05809 9.13461 4.5965 6.5962C6.68218 4.51052 10.4738 4.77972 13.8179 7.00001M17.1066 10C19.9927 13.3312 21.2146 16.7286 19.0003 18.5C17.3415 19.8271 15.2424 18.2924 14.0176 17.1094M11.0003 13H13.6027C13.8683 13 14.1231 12.8943 14.3107 12.7062L20.2949 6.70711C20.6846 6.31644 20.6842 5.68395 20.294 5.29377L18.7074 3.70711C18.3168 3.31659 17.6837 3.31659 17.2931 3.70711L11.2932 9.70712C11.1057 9.89465 11.0003 10.149 11.0003 10.4142V13Z",stroke:e,strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round"})})}function Bm({size:t=24,color:e="currentColor",animate:n=!1}){return(0,gt.jsxs)("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",children:[(0,gt.jsx)("path",{d:"M7 13L10 16L17 8",stroke:e,strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",...n?{strokeDasharray:20,strokeDashoffset:20,style:{animation:"iterate-check-draw 0.35s ease-out 0.1s forwards"}}:{}}),n&&(0,gt.jsx)("style",{children:"@keyframes iterate-check-draw { to { stroke-dashoffset: 0; } }"})]})}function go({size:t=24,color:e="currentColor"}){return(0,gt.jsxs)("svg",{width:t,height:t,viewBox:"0 0 24 24",fill:"none",style:{animation:"iterate-spin 0.8s linear infinite"},children:[(0,gt.jsx)("style",{children:"@keyframes iterate-spin { to { transform: rotate(360deg); } }"}),(0,gt.jsx)("circle",{cx:12,cy:12,r:9,stroke:e,strokeWidth:2,strokeLinecap:"round",strokeDasharray:"42 14"})]})}var en=ot(be(),1),Nm={panelBg:"#f7f7f7",cardBg:"#fff",toolbarBg:"#fff",drawerBg:"#efefef",hoverBg:"#f0f0f0",activeBg:"#e8e8e8",border:"#e0e0e0",textPrimary:"#333",textSecondary:"#666",textTertiary:"#999",textDisabled:"#888",iconDefault:"#666",iconHover:"#141414",suspenseOverlay:"rgba(255,255,255,0.75)",spinnerBg:"#e0e0e0",spinnerFg:"#666",tooltipBg:"#fff",tooltipText:"#333",tooltipKeyBg:"#f0f0f0",tooltipKeyText:"#888",buttonBg:"#333",buttonText:"#fff"},dp={panelBg:"#1e1e1e",cardBg:"#2a2a2a",toolbarBg:"#2a2a2a",drawerBg:"#252525",hoverBg:"#333",activeBg:"#3a3a3a",border:"#3a3a3a",textPrimary:"#e0e0e0",textSecondary:"#999",textTertiary:"#666",textDisabled:"#555",iconDefault:"#999",iconHover:"#e0e0e0",suspenseOverlay:"rgba(30,30,30,0.75)",spinnerBg:"#3a3a3a",spinnerFg:"#999",tooltipBg:"#2a2a2a",tooltipText:"#e0e0e0",tooltipKeyBg:"rgba(255,255,255,0.1)",tooltipKeyText:"#777",buttonBg:"#e0e0e0",buttonText:"#1e1e1e"};function mp(t){let e=t.match(/rgba?\((\d+),\s*(\d+),\s*(\d+)(?:,\s*(\d*\.?\d+))?\)/);if(!e||(e[4]!==void 0?Number(e[4]):1)<.1)return null;let[l,a,i]=[Number(e[1])/255,Number(e[2])/255,Number(e[3])/255],u=o=>o<=.03928?o/12.92:Math.pow((o+.055)/1.055,2.4);return .2126*u(l)+.7152*u(a)+.0722*u(i)}function os(t){let e=t??document,n=e.documentElement,l=n.getAttribute("data-theme")??n.getAttribute("data-color-mode")??"";if(l==="dark")return!0;if(l==="light")return!1;if(n.classList.contains("dark"))return!0;if(n.classList.contains("light"))return!1;let a=e.defaultView?.getComputedStyle(n).colorScheme??"";if(a==="dark")return!0;if(a==="light")return!1;let i=e.body;if(i){let u=e.defaultView?.getComputedStyle(i).colorScheme??"";if(u==="dark")return!0;if(u==="light")return!1}for(let u of[i,n]){if(!u)continue;let o=e.defaultView?.getComputedStyle(u).backgroundColor??"",c=mp(o);if(c!==null&&c<.2)return!0;if(c!==null&&c>.8)return!1}return window.matchMedia("(prefers-color-scheme: dark)").matches}var Um=(0,en.createContext)(Nm);function ve(){return(0,en.useContext)(Um)}function cs({children:t,targetDocument:e}){let[n,l]=(0,en.useState)(()=>os(e));return(0,en.useEffect)(()=>{l(os(e))},[e]),(0,en.useEffect)(()=>{let a=e??document,i=()=>l(os(a)),u=window.matchMedia("(prefers-color-scheme: dark)");u.addEventListener("change",i);let o=new MutationObserver(i);return o.observe(a.documentElement,{attributes:!0,attributeFilter:["class","data-theme","data-color-mode","style"]}),a.body&&o.observe(a.body,{attributes:!0,attributeFilter:["class","style"]}),()=>{u.removeEventListener("change",i),o.disconnect()}},[e]),en.default.createElement(Um.Provider,{value:n?dp:Nm},t)}var St=ot(Qt(),1),Bi="-apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif",hp="cubic-bezier(0.34, 1.56, 0.64, 1)";function yp(){let t=ve();return(0,St.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",children:(0,St.jsx)("path",{d:"M20 9L12.7071 16.2929C12.3166 16.6834 11.6834 16.6834 11.2929 16.2929L4 9",stroke:t.textTertiary,strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round"})})}function qm({selectedElements:t,textSelection:e,onAddToBatch:n,onClearSelection:l,clickPosition:a,isDrawing:i,initialComment:u,onDelete:o,iframeRef:c}){let r=ve(),[y,g]=(0,Yt.useState)(""),[d,m]=(0,Yt.useState)(new Set),b=(0,Yt.useRef)(null),E=(0,Yt.useRef)(null),[O,f]=(0,Yt.useState)(0),[s,h]=(0,Yt.useState)("hidden"),p=(0,Yt.useRef)(null),C=t.length>0||e!==null||i===!0,L=(0,Yt.useRef)(!1);(0,Yt.useEffect)(()=>{C&&!L.current&&(g(u??""),m(new Set)),L.current=C},[C,u]),(0,Yt.useEffect)(()=>{if(C){p.current&&(clearTimeout(p.current),p.current=null),h("entering");let w=0,X=requestAnimationFrame(()=>{w=requestAnimationFrame(()=>{h("visible")})});return()=>{cancelAnimationFrame(X),cancelAnimationFrame(w)}}else h(w=>w==="hidden"?"hidden":"exiting"),p.current=setTimeout(()=>{h("hidden"),p.current=null},200)},[C]),(0,Yt.useEffect)(()=>()=>{p.current&&clearTimeout(p.current)},[]),(0,Yt.useEffect)(()=>{C&&setTimeout(()=>b.current?.focus(),100)},[C]);let[A,q]=(0,Yt.useState)(!1),z=(0,Yt.useRef)(null);if((0,Yt.useEffect)(()=>{if(s!=="visible")return;let w=N=>{E.current?.contains(N.target)||(N.preventDefault(),N.stopPropagation(),q(!0),z.current&&clearTimeout(z.current),z.current=setTimeout(()=>{q(!1),z.current=null},400),b.current?.focus())};document.addEventListener("mousedown",w,{capture:!0});let X=null;try{X=c?.current?.contentDocument??null}catch{}return X?.addEventListener("mousedown",w,{capture:!0}),()=>{document.removeEventListener("mousedown",w,{capture:!0}),X?.removeEventListener("mousedown",w,{capture:!0})}},[s,c]),(0,Yt.useEffect)(()=>()=>{z.current&&clearTimeout(z.current)},[]),(0,Yt.useLayoutEffect)(()=>{if(s==="hidden"||!E.current)return;let w=new ResizeObserver(X=>{for(let N of X)f(N.borderBoxSize?.[0]?.blockSize??N.target.getBoundingClientRect().height)});return w.observe(E.current),()=>w.disconnect()},[s]),s==="hidden")return null;let k=s==="visible",wt=w=>{w.preventDefault(),y.trim()&&(n(y.trim()),g(""),m(new Set))},Vt=w=>{w.key==="Enter"&&(w.metaKey||w.ctrlKey)&&wt(w),w.key==="Escape"&&l()},_t=w=>{m(X=>{let N=new Set(X);return N.has(w)?N.delete(w):N.add(w),N})},ee=[];if(i)ee.push({name:"Path",styles:{},key:"drawing-path"});else if(t.forEach((w,X)=>{ee.push({name:w.componentName||w.elementName,styles:w.computedStyles||{},key:w.selector+X})}),e&&t.length===0){let w=e.containingElement;ee.push({name:w.componentName||w.elementName,styles:w.computedStyles||{},key:"text-selection"})}let zt=300,kt=16,ne=window.innerHeight*.8,Tt=O>0?Math.min(O,ne):ne,qt=a??{x:window.scrollX+window.innerWidth-kt-zt,y:window.scrollY+window.innerHeight/2},he=qt.x-window.scrollX,Bt=qt.x+kt;he+kt+zt+kt>window.innerWidth&&(Bt=qt.x-zt-kt),Bt=Math.max(window.scrollX+kt,Math.min(Bt,window.scrollX+window.innerWidth-zt-kt));let Z=qt.y-Tt/2;return Z=Math.max(window.scrollY+kt,Math.min(Z,window.scrollY+window.innerHeight-Tt-kt)),(0,St.jsxs)(St.Fragment,{children:[(0,St.jsx)("style",{children:`
41
43
  @keyframes iterate-panel-shake {
42
44
  0% { transform: translateX(0); }
43
45
  15% { transform: translateX(-6px); }
@@ -47,7 +49,7 @@ Error generating stack: `+l.message+`
47
49
  75% { transform: translateX(-1px); }
48
50
  100% { transform: translateX(0); }
49
51
  }
50
- `}),(0,St.jsx)("div",{ref:E,style:{position:"absolute",left:Bt,top:Z,zIndex:10002,pointerEvents:k?"auto":"none",width:zt,maxHeight:"80vh",opacity:k?1:0,transform:k?"scale(1)":"scale(0.92)",transition:`opacity 0.2s ease, transform 0.25s ${hp}`,animation:A?"iterate-panel-shake 0.4s ease":void 0},children:(0,St.jsxs)("form",{onSubmit:wt,style:{borderRadius:12,overflow:"hidden",border:"none",boxShadow:"0 4px 16px rgba(0,0,0,0.12)",fontFamily:Bi,background:r.panelBg,padding:4},children:[(0,St.jsx)("div",{style:{background:r.panelBg,padding:"4px 8px",maxHeight:400,overflowY:"auto"},children:ee.map((w,X)=>{let N=d.has(X),Mt=Object.entries(w.styles),ft=Mt.length>0,B=i;return(0,St.jsxs)("div",{children:[(0,St.jsxs)("button",{type:"button",onClick:()=>!B&&ft&&_t(X),style:{display:"flex",alignItems:"center",width:"100%",padding:"4px 0",background:"transparent",border:"none",cursor:B||!ft?"default":"pointer",fontSize:12,fontWeight:500,color:r.textPrimary,fontFamily:Bi,textAlign:"left"},children:[w.name,!B&&ft&&(0,St.jsx)("span",{style:{display:"inline-flex",color:r.textTertiary,transition:"transform 0.15s ease",transform:N?"rotate(180deg)":"rotate(0deg)",flexShrink:0,marginLeft:6},children:(0,St.jsx)(yp,{})})]}),!B&&ft&&(0,St.jsx)("div",{style:{maxHeight:N?200:0,overflow:"hidden",transition:"max-height 0.2s ease"},children:(0,St.jsx)("div",{style:{padding:"6px 8px",marginTop:4,marginBottom:4,background:r.drawerBg,borderRadius:4,fontSize:10,fontFamily:"monospace",color:r.textSecondary,lineHeight:1.7,maxHeight:180,overflow:"auto"},children:Mt.map(([et,dt])=>(0,St.jsxs)("div",{children:[(0,St.jsxs)("span",{style:{color:r.textTertiary},children:[et,":"]})," ",dt]},et))})})]},w.key)})}),(0,St.jsxs)("div",{style:{position:"relative",background:r.cardBg,border:`1px solid ${r.border}`,borderRadius:10,padding:8,display:"flex",flexDirection:"column",gap:8},children:[(0,St.jsx)("textarea",{ref:b,value:y,onChange:w=>{g(w.target.value),w.target.style.height="auto",w.target.style.height=w.target.scrollHeight+"px"},onKeyDown:Vt,placeholder:"Change this...",rows:3,style:{width:"100%",background:r.cardBg,border:`1px solid ${r.border}`,borderRadius:6,color:r.textPrimary,padding:8,fontSize:13,fontFamily:Bi,resize:"none",outline:"none",boxSizing:"border-box",overflow:"hidden"}}),(0,St.jsxs)("div",{style:{display:"flex",gap:8,justifyContent:"space-between",alignItems:"center"},children:[o?(0,St.jsx)(gp,{onClick:o}):(0,St.jsx)("div",{}),(0,St.jsxs)("div",{style:{display:"flex",gap:8},children:[(0,St.jsx)("button",{type:"button",onClick:l,style:{padding:"6px 14px",background:"transparent",border:`1px solid ${r.border}`,borderRadius:6,color:r.textSecondary,cursor:"pointer",fontSize:12,fontFamily:Bi},children:"Discard"}),(0,St.jsx)("button",{type:"submit",disabled:!y.trim(),style:{padding:"6px 14px",background:y.trim()?r.buttonBg:r.hoverBg,border:`1px solid ${y.trim()?r.buttonBg:r.border}`,borderRadius:6,color:y.trim()?r.buttonText:r.textTertiary,cursor:y.trim()?"pointer":"default",fontSize:12,fontWeight:600,fontFamily:Bi},children:o?"Update":"Add"})]})]})]})]})})]})}function gp({onClick:t}){let e=ve(),[n,l]=Yt.default.useState(!1);return(0,St.jsx)("button",{type:"button",onClick:t,onMouseEnter:()=>l(!0),onMouseLeave:()=>l(!1),style:{display:"flex",alignItems:"center",justifyContent:"center",width:32,height:32,borderRadius:8,border:"none",background:n?"rgba(229, 57, 53, 0.12)":"transparent",color:"#e53935",cursor:"pointer",padding:0,flexShrink:0,transition:"background 0.1s ease"},children:(0,St.jsx)(Da,{size:16})})}var rt=ot(be(),1);var Y=ot(Qt(),1);function Ym({active:t,iframeRef:e,onMove:n,pendingMoves:l,previewMode:a,onDeleteMove:i,moveDeltas:u={}}){let[o,c]=(0,rt.useState)(-1),[r,y]=(0,rt.useState)(!1),[g,d]=(0,rt.useState)(null),[m,b]=(0,rt.useState)(null),[E,O]=(0,rt.useState)(null),[f,s]=(0,rt.useState)(null),[h,p]=(0,rt.useState)(null),[C,L]=(0,rt.useState)(!1),[A,q]=(0,rt.useState)(null),z=(0,rt.useRef)(null),k=(0,rt.useRef)(null),wt=(0,rt.useRef)(null),Vt=(0,rt.useRef)({component:null,source:null,isComponentRoot:!1}),_t=(0,rt.useRef)(""),ee=(0,rt.useRef)({x:0,y:0}),zt=(0,rt.useRef)(null),kt=(0,rt.useRef)({x:0,y:0}),ne=(0,rt.useRef)(0),Tt=(0,rt.useCallback)(()=>{try{return e.current?.contentDocument??document}catch{return document}},[e]),qt=(0,rt.useCallback)((Z,w,X,N)=>{let Mt=window.getComputedStyle(Z),ft=Mt.display,B=ft.includes("flex")||ft.includes("grid");if(!B&&!(ft==="block"||ft==="flow-root"||ft==="list-item"))return null;let dt=B&&(ft.includes("grid")||Mt.flexDirection==="row"||Mt.flexDirection==="row-reverse"||Mt.flexDirection===""),mt=Array.from(Z.children).filter(nt=>nt!==w&&nt.getBoundingClientRect().width>0&&nt.getBoundingClientRect().height>0);if(mt.length===0)return{index:0,indicator:{x:0,y:0,width:0,height:0,isVertical:dt}};for(let nt=0;nt<=mt.length;nt++){let I=nt>0?mt[nt-1].getBoundingClientRect():null,it=nt<mt.length?mt[nt].getBoundingClientRect():null;if(dt){let le=I?it?(I.right+it.left)/2:I.right+4:it?it.left-4:0;if(nt===0&&X<(it?it.left+it.width/2:1/0)||nt===mt.length&&X>=(I?I.left+I.width/2:0)||I&&it&&X>=I.left+I.width/2&&X<it.left+it.width/2){let Ft=Z.getBoundingClientRect();return{index:nt,indicator:{x:le,y:Ft.top+4,width:2,height:Ft.height-8,isVertical:!0}}}}else{let le=I?it?(I.bottom+it.top)/2:I.bottom+4:it?it.top-4:0;if(nt===0&&N<(it?it.top+it.height/2:1/0)||nt===mt.length&&N>=(I?I.top+I.height/2:0)||I&&it&&N>=I.top+I.height/2&&N<it.top+it.height/2){let Ft=Z.getBoundingClientRect();return{index:nt,indicator:{x:Ft.left+4,y:le,width:Ft.width-8,height:2,isVertical:!1}}}}}return null},[]),he=(0,rt.useCallback)((Z,w,X,N)=>{let ft=Tt().elementsFromPoint(Z,w);for(let B of ft){if(B===X||X.contains(B))continue;let et=B.tagName?.toLowerCase();if(et==="body"||et==="html"||N&&B===N||B.closest?.("#__iterate-markers-layer__, #__iterate-fixed-markers-layer__, [data-iterate-popup], [data-iterate-panel]"))continue;let dt=window.getComputedStyle(B).display;if(dt.includes("flex")||dt.includes("grid")||dt==="block"||dt==="flow-root"||dt==="list-item"){let mt=B.getBoundingClientRect();if(Z>=mt.left&&Z<=mt.right&&w>=mt.top&&w<=mt.bottom)return B}}return null},[Tt]),Bt=(0,rt.useCallback)((Z,w)=>{let X=Z.parentElement;if(!X)return;let Mt=Array.from(X.children).filter(ft=>ft!==Z)[w]??null;X.insertBefore(Z,Mt),Z.style.opacity="",Z.style.transition=""},[]);return(0,rt.useEffect)(()=>{if(!t)return;let Z=Tt(),w=Z.createElement("style");return w.textContent="* { cursor: move !important; }",Z.head.appendChild(w),()=>{w.remove()}},[t,Tt]),(0,rt.useEffect)(()=>{if(!t){y(!1),d(null),p(null);return}let Z=Tt(),w=B=>{let et=B.target;if(!et)return;let dt=et.tagName.toLowerCase();if(["html","body","head","script","style"].includes(dt)||et.closest?.("#__iterate-markers-layer__, #__iterate-fixed-markers-layer__, [data-iterate-popup], [data-iterate-panel]"))return;B.preventDefault(),B.stopPropagation();let mt=et.getBoundingClientRect(),nt=et.parentElement,I=nt?window.getComputedStyle(nt).display:"",it=window.getComputedStyle(et).position,le=it==="absolute"||it==="fixed"||it==="sticky",Ft=I.includes("flex")||I.includes("grid"),x=!le&&(Ft||(I==="block"||I==="flow-root"||I==="list-item"));if(x&&nt){let G=Array.from(nt.children).indexOf(et);k.current=G,wt.current=G}else k.current=null,wt.current=null;Vt.current=Hi(et),_t.current=Ol(et),x?(ee.current={x:B.clientX-mt.x,y:B.clientY-mt.y},zt.current=et,z.current=nt,et.style.opacity="0.3"):(ee.current={x:0,y:0},zt.current=null,z.current=null),d(et),b({x:B.clientX,y:B.clientY}),O({x:B.clientX,y:B.clientY}),s({x:mt.x,y:mt.y,width:mt.width,height:mt.height}),L(x),y(!0)},X=B=>{if(!(!r||!m||!g)&&(kt.current={x:B.clientX,y:B.clientY},O({x:B.clientX,y:B.clientY}),C&&g.parentElement)){let et=z.current,dt=null;if(et){let I=et.getBoundingClientRect();(B.clientX<I.left||B.clientX>I.right||B.clientY<I.top||B.clientY>I.bottom)&&(dt=he(B.clientX,B.clientY,g,et))}let mt=dt??g.parentElement;if(dt){let I=dt.getBoundingClientRect();q({element:dt,rect:{x:I.x,y:I.y,width:I.width,height:I.height}})}else q(null);let nt=qt(mt,g,B.clientX,B.clientY);if(nt){let I=!dt&&nt.index===k.current;p(I?null:nt.indicator),wt.current=nt.index}else p(null)}},N=()=>{zt.current&&(zt.current.style.opacity="",zt.current=null),y(!1),d(null),b(null),O(null),s(null),p(null),q(null)},Mt=B=>{if(!r||!g||!f||!m){N();return}let et=B.clientX-m.x,dt=B.clientY-m.y;if(C){let Ft=z.current,S=null;if(Ft){let G=Ft.getBoundingClientRect();(B.clientX<G.left||B.clientX>G.right||B.clientY<G.top||B.clientY>G.bottom)&&(S=he(B.clientX,B.clientY,g,Ft))}let x=!!S;if(!x&&(wt.current===null||wt.current===k.current)){N();return}let H=z.current?Ol(z.current):void 0;if(x&&S){let Q=qt(S,g,B.clientX,B.clientY)?.index??S.children.length,$=Array.from(S.children)[Q]??null;S.insertBefore(g,$);let pt=g.getBoundingClientRect(),{component:v,source:_,isComponentRoot:M}=Vt.current,D={selector:_t.current,from:{x:pt.x,y:pt.y,width:pt.width,height:pt.height},to:{x:pt.x,y:pt.y,width:pt.width,height:pt.height},computedStyles:za(g),componentName:v,sourceLocation:_,isComponentRoot:M,reorderIndex:Q,originalSiblingIndex:k.current,parentSelector:H,targetParentSelector:Ol(S),scrollOffset:{x:0,y:0}};n(D)}else{let G=g.parentElement;if(G){let M=Array.from(G.children).filter(D=>D!==g)[wt.current]??null;G.insertBefore(g,M)}let Q=g.getBoundingClientRect(),{component:j,source:$,isComponentRoot:pt}=Vt.current,v={selector:_t.current,from:{x:Q.x,y:Q.y,width:Q.width,height:Q.height},to:{x:Q.x,y:Q.y,width:Q.width,height:Q.height},computedStyles:za(g),componentName:j,sourceLocation:$,isComponentRoot:pt,reorderIndex:wt.current,originalSiblingIndex:k.current,parentSelector:H,scrollOffset:{x:0,y:0}};n(v)}N();return}if(Math.abs(et)<3&&Math.abs(dt)<3){N();return}let mt={x:f.x+et,y:f.y+dt,width:f.width,height:f.height},{component:nt,source:I,isComponentRoot:it}=Vt.current,le={selector:Ol(g),from:f,to:mt,computedStyles:za(g),componentName:nt,sourceLocation:I,isComponentRoot:it,scrollOffset:{x:0,y:0}};n(le),N()},ft=B=>{B.key==="Escape"&&r&&N()};return Z.addEventListener("mousedown",w,{capture:!0}),Z.addEventListener("mousemove",X),Z.addEventListener("mouseup",Mt),Z.addEventListener("keydown",ft),()=>{Z.removeEventListener("mousedown",w,{capture:!0}),Z.removeEventListener("mousemove",X),Z.removeEventListener("mouseup",Mt),Z.removeEventListener("keydown",ft)}},[t,r,m,g,f,C,Tt,n,qt,he,Bt]),(0,rt.useEffect)(()=>{if(!r)return;let Z=60,w=15,X=()=>{let N=kt.current,Mt=null;try{let et=e.current?.contentDocument;Mt=et?.scrollingElement??et?.documentElement??null}catch{}Mt||(Mt=document.scrollingElement??document.documentElement);let ft=0,B=0;N.y<Z?B=-w*(1-N.y/Z):N.y>window.innerHeight-Z&&(B=w*(1-(window.innerHeight-N.y)/Z)),N.x<Z?ft=-w*(1-N.x/Z):N.x>window.innerWidth-Z&&(ft=w*(1-(window.innerWidth-N.x)/Z)),(ft||B)&&Mt.scrollBy(ft,B),ne.current=requestAnimationFrame(X)};return ne.current=requestAnimationFrame(X),()=>cancelAnimationFrame(ne.current)},[r,e]),(0,Y.jsxs)("div",{style:{position:"absolute",inset:0,pointerEvents:"none"},children:[r&&f&&E&&m&&(0,Y.jsxs)(Y.Fragment,{children:[!C&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)("div",{style:{position:"absolute",left:f.x,top:f.y,width:f.width,height:f.height,border:"2px dashed #2563eb",borderRadius:4,pointerEvents:"none"}}),(Math.abs(E.x-m.x)>10||Math.abs(E.y-m.y)>10)&&(0,Y.jsxs)("svg",{style:{position:"absolute",left:0,top:0,width:"100%",height:"100%",pointerEvents:"none",overflow:"visible"},children:[(0,Y.jsx)("defs",{children:(0,Y.jsx)("marker",{id:"drag-arrowhead",markerWidth:"8",markerHeight:"6",refX:"8",refY:"3",orient:"auto",children:(0,Y.jsx)("polygon",{points:"0 0, 8 3, 0 6",fill:"rgba(37, 99, 235, 0.7)"})})}),(0,Y.jsx)("line",{x1:f.x+f.width/2,y1:f.y+f.height/2,x2:E.x,y2:E.y,stroke:"rgba(37, 99, 235, 0.5)",strokeWidth:"2",strokeDasharray:"6 4",markerEnd:"url(#drag-arrowhead)"})]}),(0,Y.jsx)("div",{style:{position:"absolute",left:f.x+(E.x-m.x),top:f.y+(E.y-m.y),width:f.width,height:f.height,border:"2px dashed rgba(37, 99, 235, 0.4)",backgroundColor:"rgba(37, 99, 235, 0.06)",borderRadius:4,pointerEvents:"none"}})]}),C&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)("div",{style:{position:"fixed",left:f.x-1,top:f.y-1,width:f.width+2,height:f.height+2,border:"2px dashed rgba(37, 99, 235, 0.35)",borderRadius:4,background:"rgba(37, 99, 235, 0.03)",pointerEvents:"none"}}),(0,Y.jsx)("div",{style:{position:"fixed",left:E.x-ee.current.x,top:E.y-ee.current.y,width:f.width,height:f.height,opacity:.7,borderRadius:4,border:"1.5px solid #2563eb",background:"rgba(37, 99, 235, 0.06)",boxShadow:"0 4px 12px rgba(0, 0, 0, 0.15)",pointerEvents:"none",zIndex:99999}})]}),h&&(0,Y.jsx)("div",{style:{position:"absolute",left:h.x-(h.isVertical?1:0),top:h.y-(h.isVertical?0:1),width:h.isVertical?2:h.width,height:h.isVertical?h.height:2,background:"#2563eb",borderRadius:2,pointerEvents:"none",boxShadow:"0 0 6px rgba(37, 99, 235, 0.4)"}}),A&&(0,Y.jsx)("div",{style:{position:"fixed",left:A.rect.x-2,top:A.rect.y-2,width:A.rect.width+4,height:A.rect.height+4,border:"2px dashed #2563eb",borderRadius:6,background:"rgba(37, 99, 235, 0.04)",pointerEvents:"none",transition:"all 0.15s ease"}})]}),l.map((Z,w)=>{let X=Z.reorderIndex!==void 0;return(0,Y.jsx)(vp,{move:Z,idx:w,isReorder:X,editing:o===w,onToggleEdit:()=>c(o===w?-1:w),onDelete:()=>{i?.(w),c(-1)},onClose:()=>c(-1),iframeRef:e},`move-${w}`)})]})}var rs="-apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif",pp="cubic-bezier(0.34, 1.56, 0.64, 1)";function vp({move:t,idx:e,isReorder:n,editing:l,onToggleEdit:a,onDelete:i,onClose:u,iframeRef:o}){let[c,r]=(0,rt.useState)(null);return(0,rt.useEffect)(()=>{let y=(()=>{try{return o.current?.contentDocument??document}catch{return document}})(),g=(()=>{try{return o.current?.contentWindow??window}catch{return window}})(),d=()=>{let m=null;if(n&&t.parentSelector&&t.reorderIndex!==void 0){let b=t.targetParentSelector??t.parentSelector,E=y.querySelector(b);E&&(m=E.children[t.reorderIndex]??null)}if(m||(m=y.querySelector(t.selector)),m){let b=m.getBoundingClientRect();r({x:b.x,y:b.y,width:b.width,height:b.height})}};return d(),g.addEventListener("scroll",d,{passive:!0}),g.addEventListener("resize",d,{passive:!0}),()=>{g.removeEventListener("scroll",d),g.removeEventListener("resize",d)}},[o,t.selector,t.parentSelector,t.targetParentSelector,t.reorderIndex,n]),c?(0,Y.jsxs)(Y.Fragment,{children:[!n&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)("div",{style:{position:"fixed",left:c.x,top:c.y,width:c.width,height:c.height,border:"2px dashed rgba(37, 99, 235, 0.5)",borderRadius:4,pointerEvents:"none"}}),(0,Y.jsxs)("svg",{style:{position:"fixed",left:0,top:0,width:"100vw",height:"100vh",pointerEvents:"none",overflow:"visible"},children:[(0,Y.jsx)("defs",{children:(0,Y.jsx)("marker",{id:`arrowhead-${e}`,markerWidth:"8",markerHeight:"6",refX:"8",refY:"3",orient:"auto",children:(0,Y.jsx)("polygon",{points:"0 0, 8 3, 0 6",fill:"rgba(37, 99, 235, 0.6)"})})}),(0,Y.jsx)("line",{x1:c.x+c.width/2,y1:c.y+c.height/2,x2:t.to.x+t.to.width/2,y2:t.to.y+t.to.height/2,stroke:"rgba(37, 99, 235, 0.4)",strokeWidth:"1.5",strokeDasharray:"4 3",markerEnd:`url(#arrowhead-${e})`})]})]}),(0,Y.jsx)("div",{onClick:y=>{y.stopPropagation(),a()},style:{position:"fixed",left:c.x+c.width-8,top:c.y-8,width:18,height:18,borderRadius:"50% 50% 50% 2px",background:"#2563eb",color:"#fff",fontSize:10,fontWeight:700,display:"flex",alignItems:"center",justifyContent:"center",pointerEvents:"auto",cursor:"pointer",fontFamily:rs,boxShadow:l?"0 0 0 3px #2563eb44":"none",zIndex:10001},children:e+1}),l&&(0,Y.jsx)(bp,{x:c.x+c.width+12,y:c.y-8,move:t,onDelete:i,onClose:u})]}):null}function bp({x:t,y:e,move:n,onDelete:l,onClose:a}){let i=ve(),[u,o]=(0,rt.useState)(!1);(0,rt.useEffect)(()=>{let b=0,E=requestAnimationFrame(()=>{b=requestAnimationFrame(()=>o(!0))});return()=>{cancelAnimationFrame(E),cancelAnimationFrame(b)}},[]);let c=n.reorderIndex!==void 0,r=!!(n.targetParentSelector&&n.targetParentSelector!==n.parentSelector),y=240,g=16,d=t;d+y+g>window.innerWidth&&(d=t-y-30),d=Math.max(g,d);let m=Math.max(g,Math.min(e,window.innerHeight-200));return(0,Y.jsx)("div",{"data-iterate-popup":!0,style:{position:"fixed",left:d,top:m,zIndex:10002,pointerEvents:"auto",width:y,opacity:u?1:0,transform:u?"scale(1)":"scale(0.92)",transition:`opacity 0.2s ease, transform 0.25s ${pp}`},children:(0,Y.jsxs)("div",{style:{borderRadius:12,overflow:"hidden",boxShadow:"0 4px 16px rgba(0,0,0,0.12)",fontFamily:rs,background:i.panelBg,padding:4},children:[(0,Y.jsx)("div",{style:{padding:"4px 8px",fontSize:12,fontWeight:500,color:i.textPrimary},children:(()=>{if(n.isComponentRoot&&n.componentName)return`<${n.componentName}>`;let E=(n.selector.split(" ").pop()||"").replace(/[:.#\[].*$/,"").toLowerCase();return E?`<${E}>`:n.componentName||"Element"})()}),(0,Y.jsxs)("div",{style:{background:i.cardBg,border:`1px solid ${i.border}`,borderRadius:10,padding:8,display:"flex",flexDirection:"column",gap:8},children:[(0,Y.jsx)("div",{style:{fontSize:10,fontFamily:"monospace",color:i.textSecondary,lineHeight:1.7,background:i.drawerBg,borderRadius:6,padding:"6px 8px"},children:c?r?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)("div",{children:[(0,Y.jsx)("span",{style:{color:i.textTertiary},children:"from:"})," ",n.parentSelector?.split(" ").pop()??"parent"]}),(0,Y.jsxs)("div",{children:[(0,Y.jsx)("span",{style:{color:i.textTertiary},children:"to:"})," ",n.targetParentSelector?.split(" ").pop()??"parent"]})]}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)("div",{children:[(0,Y.jsx)("span",{style:{color:i.textTertiary},children:"from:"})," index ",n.originalSiblingIndex??"?"]}),(0,Y.jsxs)("div",{children:[(0,Y.jsx)("span",{style:{color:i.textTertiary},children:"to:"})," index ",n.reorderIndex]})]}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)("div",{children:[(0,Y.jsx)("span",{style:{color:i.textTertiary},children:"from:"})," ",Math.round(n.from.x),", ",Math.round(n.from.y)]}),(0,Y.jsxs)("div",{children:[(0,Y.jsx)("span",{style:{color:i.textTertiary},children:"to:"})," ",Math.round(n.to.x),", ",Math.round(n.to.y)]})]})}),(0,Y.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[(0,Y.jsx)(Sp,{onClick:b=>{b.stopPropagation(),l()}}),(0,Y.jsx)("button",{type:"button",onClick:b=>{b.stopPropagation(),a()},style:{padding:"6px 14px",background:"transparent",border:`1px solid ${i.border}`,borderRadius:6,color:i.textSecondary,cursor:"pointer",fontSize:12,fontFamily:rs},children:"Cancel"})]})]})]})})}function Sp({onClick:t}){let[e,n]=rt.default.useState(!1),l=ve();return(0,Y.jsx)("button",{type:"button",onClick:t,onMouseEnter:()=>n(!0),onMouseLeave:()=>n(!1),style:{display:"flex",alignItems:"center",justifyContent:"center",width:32,height:32,borderRadius:8,border:"none",background:e?l.hoverBg:"transparent",color:"#dc2626",cursor:"pointer",padding:0,flexShrink:0,transition:"background 0.1s ease"},children:(0,Y.jsx)(Da,{size:16})})}var Nl=class{ws=null;handlers=new Set;iterationsHandlers=new Set;toolModeHandlers=new Set;url;reconnectTimer=null;_iterations={};constructor(e){this.url=e??`ws://${window.location.host}/ws`}connect(){this.ws=new WebSocket(this.url),this.ws.onmessage=e=>{try{let n=JSON.parse(e.data);this.trackIterations(n),this.trackToolMode(n);for(let l of this.handlers)l(n)}catch{}},this.ws.onclose=()=>{this.reconnectTimer=setTimeout(()=>this.connect(),2e3)},this.ws.onerror=()=>{this.ws?.close()}}disconnect(){this.reconnectTimer&&clearTimeout(this.reconnectTimer),this.ws?.close(),this.ws=null}send(e){this.ws?.readyState===WebSocket.OPEN&&this.ws.send(JSON.stringify(e))}onMessage(e){return this.handlers.add(e),()=>this.handlers.delete(e)}onIterationsChange(e){return this.iterationsHandlers.add(e),()=>this.iterationsHandlers.delete(e)}get iterations(){return this._iterations}get connected(){return this.ws?.readyState===WebSocket.OPEN}sendToolMode(e){this.send({type:"tool:set-mode",payload:{mode:e}})}onToolModeChange(e){return this.toolModeHandlers.add(e),()=>this.toolModeHandlers.delete(e)}trackToolMode(e){if(e.type==="tool:mode-changed")for(let n of this.toolModeHandlers)n(e.payload.mode)}trackIterations(e){let n=!1;switch(e.type){case"state:sync":this._iterations={...e.payload.iterations},n=!0;break;case"iteration:created":this._iterations={...this._iterations,[e.payload.name]:e.payload},n=!0;break;case"iteration:status":this._iterations[e.payload.name]&&(this._iterations={...this._iterations,[e.payload.name]:{...this._iterations[e.payload.name],status:e.payload.status,...e.payload.error?{error:e.payload.error}:{}}},n=!0);break;case"iteration:removed":if(this._iterations[e.payload.name]){let{[e.payload.name]:l,...a}=this._iterations;this._iterations=a,n=!0}break}if(n)for(let l of this.iterationsHandlers)l(this._iterations)}};function Vm(t){return`iterate:state:${t}`}function km(t,e,n){try{let l={changes:e,domChanges:n};localStorage.setItem(Vm(t),JSON.stringify(l))}catch{}}function Zm(t){try{let e=localStorage.getItem(Vm(t));return e?JSON.parse(e):null}catch{return null}}var st=ot(Qt(),1);function Ep(t){try{return t.current?.contentWindow?.location.href}catch{return t.current?.src||void 0}}function po(t){return Ep(t)??window.location.href}function xp(t,e){try{return new URL(t).pathname===new URL(e).pathname}catch{return t===e}}function Ni(){return{x:window.scrollX||document.documentElement.scrollLeft||document.body.scrollLeft||0,y:window.scrollY||document.documentElement.scrollTop||document.body.scrollTop||0}}function Tp(t){let e=t;for(;e&&e!==document.documentElement;){let n=window.getComputedStyle(e).position;if(n==="fixed"||n==="sticky")return!0;e=e.parentElement}return!1}function Xm(t,e){let n=document.getElementById(t);return n||(n=document.createElement("div"),n.id=t,n.style.cssText=e,document.body.appendChild(n)),n}function Mp(){return Xm("__iterate-markers-layer__","position:absolute;top:0;left:0;width:0;height:0;overflow:visible;pointer-events:none;z-index:10001;")}function Cp(){return Xm("__iterate-fixed-markers-layer__","position:fixed;top:0;left:0;width:0;height:0;overflow:visible;pointer-events:none;z-index:9998;")}function fs({mode:t,iteration:e,wsUrl:n,iframeRef:l,onBatchCountChange:a,onMoveCountChange:i,onProcessingChange:u,previewMode:o=!0,visible:c=!0}){let r=(0,V.useRef)(null),[y,g]=(0,V.useState)([]),[d,m]=(0,V.useState)(null),[b,E]=(0,V.useState)(null),[O,f]=(0,V.useState)(null),[s,h]=(0,V.useState)({x:0,y:0}),[p,C]=(0,V.useState)([]),[L,A]=(0,V.useState)([]),q=(0,V.useRef)([]),z=(0,V.useRef)(new Set),[k,wt]=(0,V.useState)(!1),Vt=(0,V.useRef)(!1),_t=(0,V.useRef)(null),[ee]=(0,V.useState)(()=>typeof document<"u"?Mp():null),[zt]=(0,V.useState)(()=>typeof document<"u"?Cp():null),[kt,ne]=(0,V.useState)(()=>po(l));(0,V.useEffect)(()=>{let v=()=>ne(po(l));v();let _=history.pushState.bind(history),M=history.replaceState.bind(history);history.pushState=(...U)=>{_(...U),v()},history.replaceState=(...U)=>{M(...U),v()},window.addEventListener("popstate",v);let D=setInterval(v,500);return()=>{history.pushState=_,history.replaceState=M,window.removeEventListener("popstate",v),clearInterval(D)}},[l]);let[Tt,qt]=(0,V.useState)(null),[he,Bt]=(0,V.useState)(void 0),[Z,w]=(0,V.useState)(!1),X=c?t:"browse",N=y.length>0||d!==null||b!==null;(0,V.useEffect)(()=>{let v=new Nl(n);r.current=v,v.connect();let _=v.onMessage(M=>{switch(M.type){case"state:sync":{let D=M.payload.changes.filter(K=>K.iteration===e),U=M.payload.domChanges.filter(K=>K.iteration===e);if(D.length===0&&U.length===0){let K=Zm(e);if(K&&(K.changes.length>0||K.domChanges.length>0)){for(let nn of K.changes){let{id:oe,timestamp:mn,status:Bn,...vo}=nn;v.send({type:"change:create",payload:vo})}for(let nn of K.domChanges){let{id:oe,timestamp:mn,...Bn}=nn;v.send({type:"dom-change:create",payload:Bn})}break}}C(D),A(U);break}case"change:created":M.payload.iteration===e&&C(D=>[...D,M.payload]);break;case"change:updated":C(D=>D.map(U=>U.id===M.payload.id?M.payload:U));break;case"change:deleted":C(D=>D.filter(U=>U.id!==M.payload.id));break;case"dom:changed":M.payload.iteration===e&&(z.current.add(M.payload.id),A(D=>D.some(K=>K.id===M.payload.id)?D:[...M.payload.type==="reorder"?D.filter(K=>!(K.type==="reorder"&&K.selector===M.payload.selector)):D,M.payload]));break;case"dom:deleted":z.current.delete(M.payload.id),A(D=>D.filter(U=>U.id!==M.payload.id));break}});return()=>{_(),v.disconnect()}},[n,e]),(0,V.useEffect)(()=>{km(e,p,L)},[e,p,L]);let Mt=p.filter(v=>!(v.status==="implemented"||v.url&&kt&&!xp(v.url,kt))),ft=p.filter(v=>v.status==="queued"||v.status==="in-progress").length,B=L.length,et=p.some(v=>v.status==="in-progress");(0,V.useEffect)(()=>{a?.(ft)},[ft,a]),(0,V.useEffect)(()=>{i?.(B)},[B,i]),(0,V.useEffect)(()=>{u?.(et)},[et,u]);let dt=(0,V.useCallback)((v,_)=>{let M=Ni();g(v.map(D=>({...D,rect:{...D.rect,x:D.rect.x+M.x,y:D.rect.y+M.y}}))),_&&f({x:_.x+M.x,y:_.y+M.y})},[]),mt=(0,V.useCallback)(v=>{let _=Ni();if(g(v.map(M=>({...M,rect:{...M.rect,x:M.rect.x+_.x,y:M.rect.y+_.y}}))),v.length>0){let M=-1/0,D=0;for(let U of v){let K=U.rect;K.x+K.width>M&&(M=K.x+K.width),D+=K.y+K.height/2}f({x:M+_.x,y:D/v.length+_.y})}},[]),nt=(0,V.useCallback)(v=>{m(v)},[]),I=(0,V.useCallback)((v,_)=>{let M=Ni();g(v.map(U=>({...U,rect:{...U.rect,x:U.rect.x+M.x,y:U.rect.y+M.y}}))),E(_),h(M);let D=_.path.match(/^M\s+([\d.]+)\s+([\d.]+)/);f(D?{x:parseFloat(D[1])+M.x,y:parseFloat(D[2])+M.y}:{x:_.bounds.x+_.bounds.width+M.x,y:_.bounds.y+_.bounds.height/2+M.y})},[]),it=(0,V.useCallback)(v=>{g(_=>{let M=[..._];return M.splice(v,1),M})},[]),le=(0,V.useCallback)(v=>{if(y.length===0&&!d&&!b)return;let _=r.current;if(!_)return;let M=Tt!==null?Z:y.length>0&&Tp(y[0].domElement),D=Ni(),U;if(O)U=M?{x:O.x-D.x,y:O.y-D.y}:{x:O.x,y:O.y};else if(y.length>0){let K=y[0];U=M?{x:K.rect.x-D.x+K.rect.width/2,y:K.rect.y-D.y+K.rect.height/2}:{x:K.rect.x+K.rect.width/2,y:K.rect.y+K.rect.height/2}}else b&&(U={x:b.bounds.x+b.bounds.width/2+D.x,y:b.bounds.y+b.bounds.height/2+D.y});Tt!==null&&(_.send({type:"change:delete",payload:{id:Tt}}),qt(null),Bt(void 0)),_.send({type:"change:create",payload:{iteration:e,url:po(l),elements:y.map(K=>({selector:K.selector,elementName:K.elementName,elementPath:K.elementPath,rect:K.rect,computedStyles:K.computedStyles,nearbyText:K.nearbyText,componentName:K.componentName,sourceLocation:K.sourceLocation})),textSelection:d??void 0,drawing:b??void 0,comment:v,pagePosition:U,isFixedPosition:M||void 0,drawingScrollOffset:b?{x:D.x,y:D.y}:void 0}}),g([]),m(null),E(null)},[y,d,b,e,l,O,Tt,Z]),Ft=(0,V.useCallback)(v=>{r.current?.send({type:"change:delete",payload:{id:v}})},[]),S=(0,V.useCallback)(v=>{let _=p.find(M=>M.id===v);if(_){if(g(_.elements.map(M=>({...M,domElement:null}))),m(_.textSelection??null),E(_.drawing??null),_.pagePosition){let M=Ni();f(_.isFixedPosition?{x:_.pagePosition.x+M.x,y:_.pagePosition.y+M.y}:_.pagePosition)}else f(null);qt(v),w(!!_.isFixedPosition),Bt(_.comment)}},[p]),x=(0,V.useCallback)(()=>{Tt!==null&&Ft(Tt),qt(null),w(!1),Bt(void 0),g([]),m(null),E(null)},[Tt,Ft]),H=(0,V.useCallback)(()=>{g([]),m(null),E(null),qt(null),w(!1),Bt(void 0)},[]);(0,V.useEffect)(()=>{q.current=L},[L]);let G=(0,V.useCallback)(v=>{let _=r.current;if(!_)return;let M=v.reorderIndex!==void 0,D=v.originalSiblingIndex,U=v.parentSelector;if(M){let K=q.current.find(oe=>oe.type==="reorder"&&oe.selector===v.selector);if(K&&(D=K.before.siblingIndex,U=K.parentSelector,_.send({type:"dom-change:delete",payload:{id:K.id}})),(!v.targetParentSelector||v.targetParentSelector===U)&&v.reorderIndex===D)return}_.send({type:"dom-change:create",payload:{iteration:e,url:po(l),selector:v.selector,parentSelector:U,targetParentSelector:v.targetParentSelector,type:M?"reorder":"move",componentName:v.componentName,sourceLocation:v.sourceLocation,before:{rect:v.from,computedStyles:v.computedStyles,siblingIndex:D},after:{rect:v.to,computedStyles:v.computedStyles,siblingIndex:v.reorderIndex}}})},[e,l]),Q=(0,V.useCallback)(v=>{if(v.type!=="reorder"||v.after.siblingIndex===void 0)return;let _=(()=>{try{return l.current?.contentDocument??document}catch{return document}})();try{if(v.targetParentSelector&&v.targetParentSelector!==v.parentSelector){let oe=v.parentSelector?_.querySelector(v.parentSelector):null,mn=_.querySelector(v.targetParentSelector);if(!oe||!mn)return;let Bn=v.before.siblingIndex!==void 0?oe.children[v.before.siblingIndex]??null:null;if(!Bn)return;let bo=Array.from(mn.children)[v.after.siblingIndex]??null;mn.insertBefore(Bn,bo);return}let D=v.parentSelector?_.querySelector(v.parentSelector):null;if(!D)return;let U=v.before.siblingIndex!==void 0?D.children[v.before.siblingIndex]??null:null;if(!U)return;let nn=Array.from(D.children).filter(oe=>oe!==U)[v.after.siblingIndex]??null;D.insertBefore(U,nn)}catch{}},[l]);(0,V.useEffect)(()=>{if(L.length===0)return;let v=L.filter(_=>_.type==="reorder"&&!z.current.has(_.id)).sort((_,M)=>_.timestamp-M.timestamp);for(let _ of v)Q(_),z.current.add(_.id)},[L,Q]);let j=(0,V.useCallback)(v=>{if(v.type!=="reorder"||v.before.siblingIndex===void 0)return;let _=(()=>{try{return l.current?.contentDocument??document}catch{return document}})();try{if(v.targetParentSelector&&v.targetParentSelector!==v.parentSelector){let oe=_.querySelector(v.targetParentSelector),mn=v.parentSelector?_.querySelector(v.parentSelector):null;if(!oe||!mn)return;let Bn=v.after.siblingIndex!==void 0?oe.children[v.after.siblingIndex]??null:null;if(!Bn)return;let bo=Array.from(mn.children)[v.before.siblingIndex]??null;mn.insertBefore(Bn,bo);return}let D=null;if(v.parentSelector&&v.after.siblingIndex!==void 0){let oe=_.querySelector(v.parentSelector);oe&&(D=oe.children[v.after.siblingIndex]??null)}if(D||(D=_.querySelector(v.selector)),!D||!D.parentElement)return;let U=D.parentElement,nn=Array.from(U.children).filter(oe=>oe!==D)[v.before.siblingIndex]??null;U.insertBefore(D,nn)}catch{}},[l]),$=(0,V.useCallback)(v=>{let _=L.find(M=>M.id===v);_&&j(_),r.current?.send({type:"dom-change:delete",payload:{id:v}})},[L,j]),pt=L.map(v=>({iteration:v.iteration,url:v.url,selector:v.selector,from:v.before.rect,to:v.after.rect,computedStyles:v.before.computedStyles,componentName:v.componentName,sourceLocation:v.sourceLocation,reorderIndex:v.after.siblingIndex,originalSiblingIndex:v.before.siblingIndex,parentSelector:v.parentSelector,targetParentSelector:v.targetParentSelector}));return(0,V.useEffect)(()=>{let v=()=>{let _=r.current;if(_){for(let M of p)M.status==="queued"&&_.send({type:"change:delete",payload:{id:M.id}});for(let M=L.length-1;M>=0;M--)j(L[M]),_.send({type:"dom-change:delete",payload:{id:L[M].id}});g([]),m(null),E(null)}};return window.addEventListener("iterate:clear-batch",v),()=>window.removeEventListener("iterate:clear-batch",v)},[p,L,j]),(0,V.useEffect)(()=>{let v=()=>{let _=r.current;if(!_)return;let M=p.filter(nn=>nn.status==="queued").at(-1),D=L.at(-1);if(!M&&!D)return;let U=M?.timestamp??0,K=D?.timestamp??0;U>=K&&M?_.send({type:"change:delete",payload:{id:M.id}}):D&&(j(D),_.send({type:"dom-change:delete",payload:{id:D.id}}))};return window.addEventListener("iterate:undo",v),()=>window.removeEventListener("iterate:undo",v)},[p,L,j]),(0,V.useEffect)(()=>{let v=()=>{let _=p.filter(U=>U.status==="queued"||U.status==="in-progress");if(_.length===0&&L.length===0){window.dispatchEvent(new CustomEvent("iterate:batch-text-response",{detail:{text:""}}));return}let M=L.map(U=>({type:U.type,selector:U.selector,componentName:U.componentName,sourceLocation:U.sourceLocation,before:{rect:U.before.rect},after:{rect:U.after.rect},url:U.url})),D=is(_,M,e);window.dispatchEvent(new CustomEvent("iterate:batch-text-response",{detail:{text:D}}))};return window.addEventListener("iterate:request-batch-text",v),()=>window.removeEventListener("iterate:request-batch-text",v)},[p,L,e]),(0,V.useEffect)(()=>{let v=()=>{let _=p.filter(U=>U.status==="queued"||U.status==="in-progress");if(_.length===0&&L.length===0)return;let M=L.map(U=>({type:U.type,selector:U.selector,componentName:U.componentName,sourceLocation:U.sourceLocation,before:{rect:U.before.rect},after:{rect:U.after.rect},url:U.url})),D=is(_,M,e);navigator.clipboard.writeText(D)};return window.addEventListener("iterate:copy-batch",v),()=>window.removeEventListener("iterate:copy-batch",v)},[p,L,e]),(0,st.jsxs)(st.Fragment,{children:[(0,st.jsxs)("div",{ref:_t,style:{position:"absolute",inset:0,pointerEvents:"none",zIndex:9999},children:[(0,st.jsx)(hm,{active:X==="select"&&!N,iframeRef:l,selectedElements:y,onSelect:dt,suppressHover:k,justFinishedDragRef:Vt}),(0,st.jsx)(ym,{active:X==="select"&&!N,iframeRef:l,onSelect:mt,onDragStateChange:wt,justFinishedDragRef:Vt}),(0,st.jsx)(Sm,{active:X==="select"&&!N,iframeRef:l,onTextSelect:nt}),(0,st.jsx)(Mm,{active:X==="draw"&&!N,iframeRef:l,onDrawComplete:I}),(0,st.jsx)(Ym,{active:X==="move",iframeRef:l,onMove:G,pendingMoves:pt,previewMode:o,onDeleteMove:v=>{let _=L[v];_&&$(_.id)}})]}),c&&ee&&(0,ss.createPortal)((0,st.jsxs)(st.Fragment,{children:[N&&b&&(0,st.jsx)("svg",{style:{position:"absolute",left:s.x,top:s.y,width:"100vw",height:"100vh",pointerEvents:"none",overflow:"visible"},children:(0,st.jsx)("path",{d:b.path,fill:"none",stroke:b.strokeColor,strokeWidth:b.strokeWidth,strokeLinecap:"round",strokeLinejoin:"round",opacity:.7})}),!b&&y.map((v,_)=>{let M=v.rect.x,D=v.rect.y;return(0,st.jsxs)(V.default.Fragment,{children:[(0,st.jsx)("div",{style:{position:"absolute",left:M,top:D,width:v.rect.width,height:v.rect.height,border:"1.5px solid #6b9eff",backgroundColor:"rgba(107, 158, 255, 0.06)",borderRadius:4,pointerEvents:"none",boxSizing:"border-box"}}),!N&&(0,st.jsxs)("div",{style:{position:"absolute",left:M,top:D-26,background:"#6b9eff",color:"#fff",padding:"2px 8px",borderRadius:4,fontSize:10,fontFamily:"monospace",whiteSpace:"nowrap",pointerEvents:"none",display:"flex",gap:6,alignItems:"center",maxWidth:400,overflow:"hidden"},children:[(0,st.jsx)("span",{style:{fontWeight:700},children:v.elementName}),v.sourceLocation&&(0,st.jsx)("span",{style:{opacity:.7,fontSize:9},children:v.sourceLocation})]})]},v.selector+_)}),(0,st.jsx)(qm,{selectedElements:y,textSelection:d,onRemoveElement:it,onAddToBatch:le,onClearSelection:H,clickPosition:O,isDrawing:b!=null,initialComment:he,onDelete:Tt!==null?x:void 0}),N&&O&&Tt===null&&(0,st.jsx)(wp,{number:Mt.length+1,x:O.x,y:O.y,color:"#2563eb",elementRect:b?{...b.bounds,x:b.bounds.x+s.x,y:b.bounds.y+s.y}:y[0]?.rect},`preview-${Mt.length}-${O.x}-${O.y}`),Mt.map((v,_)=>{if(v.isFixedPosition)return null;let M=v.pagePosition;if(!M)return null;let D=v.drawingScrollOffset??{x:0,y:0},U=v.drawing?{x:v.drawing.bounds.x+D.x,y:v.drawing.bounds.y+D.y,width:v.drawing.bounds.width,height:v.drawing.bounds.height}:v.elements[0]?.rect;return(0,st.jsxs)(V.default.Fragment,{children:[v.drawing&&(0,st.jsx)("svg",{style:{position:"absolute",left:D.x,top:D.y,width:"100vw",height:"100vh",pointerEvents:"none",overflow:"visible"},children:(0,st.jsx)("path",{d:v.drawing.path,fill:"none",stroke:v.drawing.strokeColor,strokeWidth:v.drawing.strokeWidth,strokeLinecap:"round",strokeLinejoin:"round",opacity:.5})}),(0,st.jsx)(jm,{number:_+1,x:M.x,y:M.y,color:v.status==="in-progress"?"#16a34a":"#2563eb",onEdit:()=>S(v.id),isEditing:Tt===v.id,elementRect:U})]},v.id)})]}),ee),c&&zt&&(0,ss.createPortal)((0,st.jsx)(st.Fragment,{children:Mt.map((v,_)=>{if(!v.isFixedPosition)return null;let M=v.pagePosition;if(!M)return null;let D=v.drawing?v.drawing.bounds:v.elements[0]?.rect;return(0,st.jsxs)(V.default.Fragment,{children:[v.drawing&&(0,st.jsx)("svg",{style:{position:"absolute",left:0,top:0,width:"100vw",height:"100vh",pointerEvents:"none",overflow:"visible"},children:(0,st.jsx)("path",{d:v.drawing.path,fill:"none",stroke:v.drawing.strokeColor,strokeWidth:v.drawing.strokeWidth,strokeLinecap:"round",strokeLinejoin:"round",opacity:.5})}),(0,st.jsx)(jm,{number:_+1,x:M.x,y:M.y,color:v.status==="in-progress"?"#16a34a":"#2563eb",onEdit:()=>S(v.id),isEditing:Tt===v.id,elementRect:D})]},v.id)})}),zt)]})}var Gm="cubic-bezier(0.34, 1.56, 0.64, 1)";function Qm(t,e,n){if(!n)return"50% 50% 2px 50%";let l=n.x+n.width/2,a=n.y+n.height/2,i=t<=l,u=e<=a;return i&&u?"50% 50% 2px 50%":!i&&u?"50% 50% 50% 2px":!i&&!u?"2px 50% 50% 50%":"50% 2px 50% 50%"}function wp({number:t,x:e,y:n,color:l,elementRect:a}){let[i,u]=(0,V.useState)(!1);return(0,V.useEffect)(()=>{let o=0,c=requestAnimationFrame(()=>{o=requestAnimationFrame(()=>{u(!0)})});return()=>{cancelAnimationFrame(c),cancelAnimationFrame(o)}},[]),(0,st.jsx)("div",{style:{position:"absolute",left:e-9,top:n-9,width:18,height:18,borderRadius:Qm(e,n,a),background:l,color:"#fff",fontSize:10,fontWeight:700,display:"flex",alignItems:"center",justifyContent:"center",pointerEvents:"none",fontFamily:"-apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif",transform:i?"scale(1)":"scale(0.75)",opacity:i?1:0,transition:`transform 0.35s ${Gm}, opacity 0.2s ease`},children:t})}function jm({number:t,x:e,y:n,color:l,onEdit:a,isEditing:i,elementRect:u}){let[o,c]=(0,V.useState)(!1);return(0,V.useEffect)(()=>{let r=0,y=requestAnimationFrame(()=>{r=requestAnimationFrame(()=>{c(!0)})});return()=>{cancelAnimationFrame(y),cancelAnimationFrame(r)}},[]),(0,st.jsx)("div",{onClick:r=>{r.stopPropagation(),a()},style:{position:"absolute",left:e-9,top:n-9,width:18,height:18,borderRadius:Qm(e,n,u),background:l,color:"#fff",fontSize:10,fontWeight:700,display:"flex",alignItems:"center",justifyContent:"center",pointerEvents:"auto",cursor:"pointer",fontFamily:"-apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif",transform:o?"scale(1)":"scale(0.75)",opacity:o?1:0,transition:`transform 0.35s ${Gm}, opacity 0.2s ease`,boxShadow:i?`0 0 0 3px ${l}44`:"none"},children:t})}var W=ot(be(),1),ms=ot(Ba(),1);var R=ot(Qt(),1),Lt="__original__",fl=16,te=24,We="cubic-bezier(0.34, 1.56, 0.64, 1)",hs=W.default.createContext(!1),_p="0.8s",Km={ready:"#22c55e",creating:"#eab308",installing:"#eab308",starting:"#eab308",error:"#ef4444",stopped:"#888"};function Wm({mode:t,onModeChange:e,visible:n,onVisibilityChange:l,batchCount:a=0,moveCount:i=0,onClearBatch:u,onCopyBatch:o,onUndoMove:c,iterations:r,activeIteration:y,onIterationChange:g,onFork:d,onPick:m,onDiscard:b,isViewingIteration:E=!1,tabBadgeCounts:O={},readyIframes:f,processing:s=!1}){let h=ve(),p=(0,W.useRef)(null),[C,L]=(0,W.useState)("bottom-right"),[A,q]=(0,W.useState)(!1),[z,k]=(0,W.useState)({x:0,y:0}),[wt,Vt]=(0,W.useState)(null),[_t,ee]=(0,W.useState)(!1),[zt,kt]=(0,W.useState)(!1),[ne,Tt]=(0,W.useState)(!1),[qt,he]=(0,W.useState)(!1),Bt=(0,W.useRef)(null),Z=r?Object.keys(r).sort((j,$)=>j.localeCompare($,void 0,{numeric:!0})):[],w=Z.length>0,X=w?Z.map(j=>r[j]?.status):[],N=X.some(j=>j==="creating"||j==="installing"||j==="starting"),Mt=["creating","installing","starting"],ft=X.includes("starting")?2:X.includes("installing")?1:X.includes("ready")?2:0,B=(0,W.useRef)(-1);!N&&!_t?B.current=-1:ft>B.current&&(B.current=ft);let et=B.current>=0?Mt[B.current]:null,dt=a+i,mt=C==="top-left"||C==="bottom-left",nt=C==="top-left"||C==="top-right",I=!w&&!_t&&!N||_t||N||w&&E&&!zt&&!N||zt||w&&!E&&!ne&&!N||ne;(0,W.useEffect)(()=>()=>{Bt.current&&clearTimeout(Bt.current)},[]),(0,W.useEffect)(()=>{w&&ee(!1)},[w]),(0,W.useEffect)(()=>{w||(kt(!1),Tt(!1))},[w]);let it=(0,W.useRef)(!1);(N||_t)&&(it.current=!0);let le=f!=null&&w&&Z.every(j=>r[j]?.status!=="ready"||f.has(j));le&&it.current&&(it.current=!1);let Ft=it.current&&w&&!le&&!zt&&!ne,S=_t||N||zt||ne||Ft,x=zt?"Merging preferred changes\u2026":ne?"Removing iteration worktrees\u2026":Ft&&!N&&!_t?"Loading page\u2026":et==="installing"?"Installing dependencies\u2026":et==="starting"?"Starting dev server\u2026":"Creating iteration branches\u2026";(0,W.useEffect)(()=>{let j=$=>{if(($.metaKey||$.ctrlKey)&&$.key==="i"){$.preventDefault(),l(!n);return}if(!n)return;let pt=$.target?.tagName;if(!(pt==="INPUT"||pt==="TEXTAREA"||$.target?.isContentEditable)&&!($.metaKey||$.ctrlKey||$.altKey))switch($.key){case"Escape":$.preventDefault(),l(!1);break;case"s":$.preventDefault(),document.activeElement?.blur?.(),e(t==="select"?"browse":"select");break;case"d":$.preventDefault(),document.activeElement?.blur?.(),e(t==="draw"?"browse":"draw");break;case"m":$.preventDefault(),document.activeElement?.blur?.(),e(t==="move"?"browse":"move");break;case"u":$.preventDefault(),c?.();break;case"x":$.preventDefault(),u?.();break;case"c":$.preventDefault(),o?.(),he(!0),Bt.current&&clearTimeout(Bt.current),Bt.current=setTimeout(()=>he(!1),3e3);break}};return window.addEventListener("keydown",j),()=>window.removeEventListener("keydown",j)},[n,l,t,e,c,u,o]);let H=(0,W.useCallback)(j=>{if(j.target.closest("button"))return;let $=p.current;if(!$)return;let pt=$.getBoundingClientRect();q(!0),k({x:j.clientX-pt.left,y:j.clientY-pt.top}),Vt({x:pt.left,y:pt.top}),j.preventDefault()},[]);(0,W.useEffect)(()=>{if(!A)return;let j=pt=>{Vt({x:pt.clientX-z.x,y:pt.clientY-z.y})},$=pt=>{q(!1);let v=pt.clientX,_=pt.clientY,M=window.innerWidth/2,D=window.innerHeight/2,U=v<M?_<D?"top-left":"bottom-left":_<D?"top-right":"bottom-right";L(U),Vt(null)};return window.addEventListener("mousemove",j),window.addEventListener("mouseup",$),()=>{window.removeEventListener("mousemove",j),window.removeEventListener("mouseup",$)}},[A,z]);let G=wt?{left:wt.x,top:wt.y}:Np(C),Q=A?"none":"left 0.3s ease, top 0.3s ease, right 0.3s ease, bottom 0.3s ease";return(0,R.jsxs)(hs.Provider,{value:nt,children:[(0,R.jsx)(Ap,{active:S,message:x}),(0,R.jsxs)("div",{ref:p,"data-iterate-panel":"",onMouseDown:H,style:{position:"fixed",...G,zIndex:10001,pointerEvents:"auto",background:h.panelBg,border:"none",borderRadius:12,boxShadow:"0 4px 16px rgba(0,0,0,0.12)",display:"flex",flexDirection:nt?"column-reverse":"column",gap:0,cursor:A?"grabbing":"grab",userSelect:"none",overflow:"visible",padding:4,transition:Q},children:[dt>0&&(0,R.jsx)(Lp,{count:dt,isLeftSide:mt,processing:s}),w&&(0,R.jsx)("div",{style:{background:h.panelBg,maxHeight:n?56:0,maxWidth:n?999:0,opacity:n?1:0,overflow:"hidden",...nt?{marginBottom:n?2:0}:{marginTop:n?2:0},transition:n?"max-height 0.2s ease 0.2s, max-width 0.2s ease 0.2s, opacity 0.15s ease 0.2s, margin 0.2s ease 0.2s":"max-height 0.12s ease 0s, max-width 0.12s ease 0s, opacity 0.1s ease 0s, margin 0.12s ease 0s"},children:(0,R.jsx)("div",{style:{padding:"4px 4px 4px 4px"},children:(0,R.jsxs)("div",{ref:j=>{if(j&&!j.dataset.scrollbarHidden){let $=document.createElement("style");$.textContent="[data-iterate-tabs]::-webkit-scrollbar { display: none; }",j.appendChild($),j.dataset.scrollbarHidden="1"}},"data-iterate-tabs":"",style:{display:"flex",alignItems:"center",gap:2,overflowX:"auto",scrollbarWidth:"none",paddingTop:6,paddingRight:6,marginTop:-6,marginRight:-6},children:[(0,R.jsxs)($m,{active:y===Lt,badgeCount:O[Lt]??0,title:"Root directory",onClick:()=>g?.(Lt),children:[(0,R.jsx)("span",{style:{width:6,height:6,borderRadius:"50%",background:Km.ready,flexShrink:0}}),"Original"]}),Z.map(j=>{let $=r[j],pt=j===y,v=O[j]??0;return(0,R.jsxs)($m,{active:pt,badgeCount:v,title:$?.error?`${j}: ${$.error}`:`${j} worktree`,onClick:()=>g?.(j),children:[(0,R.jsx)("span",{style:{width:6,height:6,borderRadius:"50%",background:Km[$?.status??"stopped"],flexShrink:0}}),j]},j)})]})})}),(0,R.jsxs)("div",{style:{position:"relative",display:"flex",flexDirection:mt?"row-reverse":"row",justifyContent:"flex-end",alignItems:"center",background:h.toolbarBg,border:`1px solid ${h.border}`,borderRadius:10,padding:4},children:[(0,R.jsxs)(Dp,{reversed:mt,visible:n,children:[(0,R.jsx)($e,{icon:(0,R.jsx)(_m,{size:te}),label:"Select (S)",active:t==="select",onClick:()=>e(t==="select"?"browse":"select")}),(0,R.jsx)($e,{icon:(0,R.jsx)(Lm,{size:te}),label:"Draw (D)",active:t==="draw",onClick:()=>e(t==="draw"?"browse":"draw")}),(0,R.jsx)($e,{icon:(0,R.jsx)(Am,{size:te}),label:"Move (M)",active:t==="move",onClick:()=>e(t==="move"?"browse":"move")}),(0,R.jsx)(ds,{}),(0,R.jsx)($e,{icon:(0,R.jsx)(zm,{size:te}),label:"Undo last change (U)",disabled:dt===0,onClick:()=>c?.()}),(0,R.jsx)($e,{icon:(0,R.jsx)(Da,{size:te}),label:"Clear all changes (X)",disabled:dt===0,onClick:()=>u?.()}),(0,R.jsx)($e,{icon:(0,R.jsxs)("div",{style:{position:"relative",width:te,height:te},children:[(0,R.jsx)("div",{style:{position:"absolute",inset:0,display:"flex",alignItems:"center",justifyContent:"center",opacity:qt?0:1,transform:qt?"scale(0.6)":"scale(1)",filter:qt?"blur(4px)":"blur(0px)",transition:`opacity 0.25s ${We}, transform 0.3s ${We}, filter 0.25s ease`},children:(0,R.jsx)(Om,{size:te})}),(0,R.jsx)("div",{style:{position:"absolute",inset:0,display:"flex",alignItems:"center",justifyContent:"center",opacity:qt?1:0,transform:qt?"scale(1)":"scale(0.6)",filter:qt?"blur(0px)":"blur(4px)",transition:`opacity 0.25s ${We}, transform 0.3s ${We}, filter 0.25s ease`},children:(0,R.jsx)(Bm,{size:te,color:"#22c55e",animate:!0})})]}),label:qt?"Copied!":"Copy changes to clipboard (C)",disabled:dt===0,onClick:()=>{o?.(),he(!0),Bt.current&&clearTimeout(Bt.current),Bt.current=setTimeout(()=>he(!1),3e3)}}),I&&(0,R.jsx)(ds,{}),!w&&!_t&&!N&&(0,R.jsx)($e,{icon:(0,R.jsx)(Dm,{size:te}),label:"Create iterations",onClick:()=>{ee(!0),d?.()}}),(_t||N)&&(0,R.jsx)($e,{icon:(0,R.jsx)(go,{size:te}),label:"Creating iterations",onClick:()=>{}}),w&&E&&!zt&&!N&&(0,R.jsx)($e,{icon:(0,R.jsx)(Rm,{size:te}),label:`Merge "${y}"`,onClick:async()=>{if(!(!y||y===Lt)){kt(!0);try{await m?.(y)}finally{kt(!1)}}}}),zt&&(0,R.jsx)($e,{icon:(0,R.jsx)(go,{size:te}),label:"Merging\\u2026",onClick:()=>{}}),w&&!E&&!ne&&!N&&(0,R.jsx)($e,{icon:(0,R.jsx)(Hm,{size:te}),label:"Discard all iterations",onClick:async()=>{Tt(!0);try{await b?.()}finally{Tt(!1)}}}),ne&&(0,R.jsx)($e,{icon:(0,R.jsx)(go,{size:te}),label:"Removing iteration worktrees\\u2026",onClick:()=>{}}),(0,R.jsx)(ds,{})]}),(0,R.jsx)(Rp,{visible:n,onVisibilityChange:l})]})]})]})}function Ap({active:t,message:e}){let n=ve();return(0,R.jsxs)("div",{style:{position:"fixed",inset:0,zIndex:1e4,background:n.suspenseOverlay,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:20,backdropFilter:"blur(8px)",WebkitBackdropFilter:"blur(8px)",opacity:t?1:0,pointerEvents:t?"auto":"none",transition:"opacity 0.3s ease"},children:[(0,R.jsx)("style",{children:`
52
+ `}),(0,St.jsx)("div",{ref:E,style:{position:"absolute",left:Bt,top:Z,zIndex:10002,pointerEvents:k?"auto":"none",width:zt,maxHeight:"80vh",opacity:k?1:0,transform:k?"scale(1)":"scale(0.92)",transition:`opacity 0.2s ease, transform 0.25s ${hp}`,animation:A?"iterate-panel-shake 0.4s ease":void 0},children:(0,St.jsxs)("form",{onSubmit:wt,style:{borderRadius:12,overflow:"hidden",border:"none",boxShadow:"0 4px 16px rgba(0,0,0,0.12)",fontFamily:Bi,background:r.panelBg,padding:4},children:[(0,St.jsx)("div",{style:{background:r.panelBg,padding:"4px 8px",maxHeight:400,overflowY:"auto"},children:ee.map((w,X)=>{let N=d.has(X),Mt=Object.entries(w.styles),ft=Mt.length>0,B=i;return(0,St.jsxs)("div",{children:[(0,St.jsxs)("button",{type:"button",onClick:()=>!B&&ft&&_t(X),style:{display:"flex",alignItems:"center",width:"100%",padding:"4px 0",background:"transparent",border:"none",cursor:B||!ft?"default":"pointer",fontSize:12,fontWeight:500,color:r.textPrimary,fontFamily:Bi,textAlign:"left"},children:[w.name,!B&&ft&&(0,St.jsx)("span",{style:{display:"inline-flex",color:r.textTertiary,transition:"transform 0.15s ease",transform:N?"rotate(180deg)":"rotate(0deg)",flexShrink:0,marginLeft:6},children:(0,St.jsx)(yp,{})})]}),!B&&ft&&(0,St.jsx)("div",{style:{maxHeight:N?200:0,overflow:"hidden",transition:"max-height 0.2s ease"},children:(0,St.jsx)("div",{style:{padding:"6px 8px",marginTop:4,marginBottom:4,background:r.drawerBg,borderRadius:4,fontSize:10,fontFamily:"monospace",color:r.textSecondary,lineHeight:1.7,maxHeight:180,overflow:"auto"},children:Mt.map(([et,dt])=>(0,St.jsxs)("div",{children:[(0,St.jsxs)("span",{style:{color:r.textTertiary},children:[et,":"]})," ",dt]},et))})})]},w.key)})}),(0,St.jsxs)("div",{style:{position:"relative",background:r.cardBg,border:`1px solid ${r.border}`,borderRadius:10,padding:8,display:"flex",flexDirection:"column",gap:8},children:[(0,St.jsx)("textarea",{ref:b,value:y,onChange:w=>{g(w.target.value),w.target.style.height="auto",w.target.style.height=w.target.scrollHeight+"px"},onKeyDown:Vt,placeholder:"Change this...",rows:3,style:{width:"100%",background:r.cardBg,border:`1px solid ${r.border}`,borderRadius:6,color:r.textPrimary,padding:8,fontSize:13,fontFamily:Bi,resize:"none",outline:"none",boxSizing:"border-box",overflow:"hidden"}}),(0,St.jsxs)("div",{style:{display:"flex",gap:8,justifyContent:"space-between",alignItems:"center"},children:[o?(0,St.jsx)(gp,{onClick:o}):(0,St.jsx)("div",{}),(0,St.jsxs)("div",{style:{display:"flex",gap:8},children:[(0,St.jsx)("button",{type:"button",onClick:l,style:{padding:"6px 14px",background:"transparent",border:`1px solid ${r.border}`,borderRadius:6,color:r.textSecondary,cursor:"pointer",fontSize:12,fontFamily:Bi},children:"Discard"}),(0,St.jsx)("button",{type:"submit",disabled:!y.trim(),style:{padding:"6px 14px",background:y.trim()?r.buttonBg:r.hoverBg,border:`1px solid ${y.trim()?r.buttonBg:r.border}`,borderRadius:6,color:y.trim()?r.buttonText:r.textTertiary,cursor:y.trim()?"pointer":"default",fontSize:12,fontWeight:600,fontFamily:Bi},children:o?"Update":"Add"})]})]})]})]})})]})}function gp({onClick:t}){let e=ve(),[n,l]=Yt.default.useState(!1);return(0,St.jsx)("button",{type:"button",onClick:t,onMouseEnter:()=>l(!0),onMouseLeave:()=>l(!1),style:{display:"flex",alignItems:"center",justifyContent:"center",width:32,height:32,borderRadius:8,border:"none",background:n?"rgba(229, 57, 53, 0.12)":"transparent",color:"#e53935",cursor:"pointer",padding:0,flexShrink:0,transition:"background 0.1s ease"},children:(0,St.jsx)(Da,{size:16})})}var rt=ot(be(),1);var Y=ot(Qt(),1);function Ym({active:t,iframeRef:e,onMove:n,pendingMoves:l,previewMode:a,onDeleteMove:i,moveDeltas:u={}}){let[o,c]=(0,rt.useState)(-1),[r,y]=(0,rt.useState)(!1),[g,d]=(0,rt.useState)(null),[m,b]=(0,rt.useState)(null),[E,O]=(0,rt.useState)(null),[f,s]=(0,rt.useState)(null),[h,p]=(0,rt.useState)(null),[C,L]=(0,rt.useState)(!1),[A,q]=(0,rt.useState)(null),z=(0,rt.useRef)(null),k=(0,rt.useRef)(null),wt=(0,rt.useRef)(null),Vt=(0,rt.useRef)({component:null,source:null,isComponentRoot:!1}),_t=(0,rt.useRef)(""),ee=(0,rt.useRef)({x:0,y:0}),zt=(0,rt.useRef)(null),kt=(0,rt.useRef)({x:0,y:0}),ne=(0,rt.useRef)(0),Tt=(0,rt.useCallback)(()=>{try{return e.current?.contentDocument??document}catch{return document}},[e]),qt=(0,rt.useCallback)((Z,w,X,N)=>{let Mt=window.getComputedStyle(Z),ft=Mt.display,B=ft.includes("flex")||ft.includes("grid");if(!B&&!(ft==="block"||ft==="flow-root"||ft==="list-item"))return null;let dt=B&&(ft.includes("grid")||Mt.flexDirection==="row"||Mt.flexDirection==="row-reverse"||Mt.flexDirection===""),mt=Array.from(Z.children).filter(nt=>nt!==w&&nt.getBoundingClientRect().width>0&&nt.getBoundingClientRect().height>0);if(mt.length===0)return{index:0,indicator:{x:0,y:0,width:0,height:0,isVertical:dt}};for(let nt=0;nt<=mt.length;nt++){let I=nt>0?mt[nt-1].getBoundingClientRect():null,it=nt<mt.length?mt[nt].getBoundingClientRect():null;if(dt){let le=I?it?(I.right+it.left)/2:I.right+4:it?it.left-4:0;if(nt===0&&X<(it?it.left+it.width/2:1/0)||nt===mt.length&&X>=(I?I.left+I.width/2:0)||I&&it&&X>=I.left+I.width/2&&X<it.left+it.width/2){let Ft=Z.getBoundingClientRect();return{index:nt,indicator:{x:le,y:Ft.top+4,width:2,height:Ft.height-8,isVertical:!0}}}}else{let le=I?it?(I.bottom+it.top)/2:I.bottom+4:it?it.top-4:0;if(nt===0&&N<(it?it.top+it.height/2:1/0)||nt===mt.length&&N>=(I?I.top+I.height/2:0)||I&&it&&N>=I.top+I.height/2&&N<it.top+it.height/2){let Ft=Z.getBoundingClientRect();return{index:nt,indicator:{x:Ft.left+4,y:le,width:Ft.width-8,height:2,isVertical:!1}}}}}return null},[]),he=(0,rt.useCallback)((Z,w,X,N)=>{let ft=Tt().elementsFromPoint(Z,w);for(let B of ft){if(B===X||X.contains(B))continue;let et=B.tagName?.toLowerCase();if(et==="body"||et==="html"||N&&B===N||B.closest?.("#__iterate-markers-layer__, #__iterate-fixed-markers-layer__, [data-iterate-popup], [data-iterate-panel]"))continue;let dt=window.getComputedStyle(B).display;if(dt.includes("flex")||dt.includes("grid")||dt==="block"||dt==="flow-root"||dt==="list-item"){let mt=B.getBoundingClientRect();if(Z>=mt.left&&Z<=mt.right&&w>=mt.top&&w<=mt.bottom)return B}}return null},[Tt]),Bt=(0,rt.useCallback)((Z,w)=>{let X=Z.parentElement;if(!X)return;let Mt=Array.from(X.children).filter(ft=>ft!==Z)[w]??null;X.insertBefore(Z,Mt),Z.style.opacity="",Z.style.transition=""},[]);return(0,rt.useEffect)(()=>{if(!t)return;let Z=Tt(),w=Z.createElement("style");return w.textContent="* { cursor: move !important; }",Z.head.appendChild(w),()=>{w.remove()}},[t,Tt]),(0,rt.useEffect)(()=>{if(!t){y(!1),d(null),p(null);return}let Z=Tt(),w=B=>{let et=B.target;if(!et)return;let dt=et.tagName.toLowerCase();if(["html","body","head","script","style"].includes(dt)||et.closest?.("#__iterate-markers-layer__, #__iterate-fixed-markers-layer__, [data-iterate-popup], [data-iterate-panel]"))return;B.preventDefault(),B.stopPropagation();let mt=et.getBoundingClientRect(),nt=et.parentElement,I=nt?window.getComputedStyle(nt).display:"",it=window.getComputedStyle(et).position,le=it==="absolute"||it==="fixed"||it==="sticky",Ft=I.includes("flex")||I.includes("grid"),x=!le&&(Ft||(I==="block"||I==="flow-root"||I==="list-item"));if(x&&nt){let G=Array.from(nt.children).indexOf(et);k.current=G,wt.current=G}else k.current=null,wt.current=null;Vt.current=Hi(et),_t.current=Ol(et),x?(ee.current={x:B.clientX-mt.x,y:B.clientY-mt.y},zt.current=et,z.current=nt,et.style.opacity="0.3"):(ee.current={x:0,y:0},zt.current=null,z.current=null),d(et),b({x:B.clientX,y:B.clientY}),O({x:B.clientX,y:B.clientY}),s({x:mt.x,y:mt.y,width:mt.width,height:mt.height}),L(x),y(!0)},X=B=>{if(!(!r||!m||!g)&&(kt.current={x:B.clientX,y:B.clientY},O({x:B.clientX,y:B.clientY}),C&&g.parentElement)){let et=z.current,dt=null;if(et){let I=et.getBoundingClientRect();(B.clientX<I.left||B.clientX>I.right||B.clientY<I.top||B.clientY>I.bottom)&&(dt=he(B.clientX,B.clientY,g,et))}let mt=dt??g.parentElement;if(dt){let I=dt.getBoundingClientRect();q({element:dt,rect:{x:I.x,y:I.y,width:I.width,height:I.height}})}else q(null);let nt=qt(mt,g,B.clientX,B.clientY);if(nt){let I=!dt&&nt.index===k.current;p(I?null:nt.indicator),wt.current=nt.index}else p(null)}},N=()=>{zt.current&&(zt.current.style.opacity="",zt.current=null),y(!1),d(null),b(null),O(null),s(null),p(null),q(null)},Mt=B=>{if(!r||!g||!f||!m){N();return}let et=B.clientX-m.x,dt=B.clientY-m.y;if(C){let Ft=z.current,S=null;if(Ft){let G=Ft.getBoundingClientRect();(B.clientX<G.left||B.clientX>G.right||B.clientY<G.top||B.clientY>G.bottom)&&(S=he(B.clientX,B.clientY,g,Ft))}let x=!!S;if(!x&&(wt.current===null||wt.current===k.current)){N();return}let H=z.current?Ol(z.current):void 0;if(x&&S){let Q=qt(S,g,B.clientX,B.clientY)?.index??S.children.length,$=Array.from(S.children)[Q]??null;S.insertBefore(g,$);let pt=g.getBoundingClientRect(),{component:v,source:_,isComponentRoot:M}=Vt.current,D={selector:_t.current,from:{x:pt.x,y:pt.y,width:pt.width,height:pt.height},to:{x:pt.x,y:pt.y,width:pt.width,height:pt.height},computedStyles:za(g),componentName:v,sourceLocation:_,isComponentRoot:M,reorderIndex:Q,originalSiblingIndex:k.current,parentSelector:H,targetParentSelector:Ol(S),scrollOffset:{x:0,y:0}};n(D)}else{let G=g.parentElement;if(G){let M=Array.from(G.children).filter(D=>D!==g)[wt.current]??null;G.insertBefore(g,M)}let Q=g.getBoundingClientRect(),{component:j,source:$,isComponentRoot:pt}=Vt.current,v={selector:_t.current,from:{x:Q.x,y:Q.y,width:Q.width,height:Q.height},to:{x:Q.x,y:Q.y,width:Q.width,height:Q.height},computedStyles:za(g),componentName:j,sourceLocation:$,isComponentRoot:pt,reorderIndex:wt.current,originalSiblingIndex:k.current,parentSelector:H,scrollOffset:{x:0,y:0}};n(v)}N();return}if(Math.abs(et)<3&&Math.abs(dt)<3){N();return}let mt={x:f.x+et,y:f.y+dt,width:f.width,height:f.height},{component:nt,source:I,isComponentRoot:it}=Vt.current,le={selector:Ol(g),from:f,to:mt,computedStyles:za(g),componentName:nt,sourceLocation:I,isComponentRoot:it,scrollOffset:{x:0,y:0}};n(le),N()},ft=B=>{B.key==="Escape"&&r&&N()};return Z.addEventListener("mousedown",w,{capture:!0}),Z.addEventListener("mousemove",X),Z.addEventListener("mouseup",Mt),Z.addEventListener("keydown",ft),()=>{Z.removeEventListener("mousedown",w,{capture:!0}),Z.removeEventListener("mousemove",X),Z.removeEventListener("mouseup",Mt),Z.removeEventListener("keydown",ft)}},[t,r,m,g,f,C,Tt,n,qt,he,Bt]),(0,rt.useEffect)(()=>{if(!r)return;let Z=60,w=15,X=()=>{let N=kt.current,Mt=null;try{let et=e.current?.contentDocument;Mt=et?.scrollingElement??et?.documentElement??null}catch{}Mt||(Mt=document.scrollingElement??document.documentElement);let ft=0,B=0;N.y<Z?B=-w*(1-N.y/Z):N.y>window.innerHeight-Z&&(B=w*(1-(window.innerHeight-N.y)/Z)),N.x<Z?ft=-w*(1-N.x/Z):N.x>window.innerWidth-Z&&(ft=w*(1-(window.innerWidth-N.x)/Z)),(ft||B)&&Mt.scrollBy(ft,B),ne.current=requestAnimationFrame(X)};return ne.current=requestAnimationFrame(X),()=>cancelAnimationFrame(ne.current)},[r,e]),(0,Y.jsxs)("div",{style:{position:"absolute",inset:0,pointerEvents:"none"},children:[r&&f&&E&&m&&(0,Y.jsxs)(Y.Fragment,{children:[!C&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)("div",{style:{position:"absolute",left:f.x,top:f.y,width:f.width,height:f.height,border:"2px dashed #2563eb",borderRadius:4,pointerEvents:"none"}}),(Math.abs(E.x-m.x)>10||Math.abs(E.y-m.y)>10)&&(0,Y.jsxs)("svg",{style:{position:"absolute",left:0,top:0,width:"100%",height:"100%",pointerEvents:"none",overflow:"visible"},children:[(0,Y.jsx)("defs",{children:(0,Y.jsx)("marker",{id:"drag-arrowhead",markerWidth:"8",markerHeight:"6",refX:"8",refY:"3",orient:"auto",children:(0,Y.jsx)("polygon",{points:"0 0, 8 3, 0 6",fill:"rgba(37, 99, 235, 0.7)"})})}),(0,Y.jsx)("line",{x1:f.x+f.width/2,y1:f.y+f.height/2,x2:E.x,y2:E.y,stroke:"rgba(37, 99, 235, 0.5)",strokeWidth:"2",strokeDasharray:"6 4",markerEnd:"url(#drag-arrowhead)"})]}),(0,Y.jsx)("div",{style:{position:"absolute",left:f.x+(E.x-m.x),top:f.y+(E.y-m.y),width:f.width,height:f.height,border:"2px dashed rgba(37, 99, 235, 0.4)",backgroundColor:"rgba(37, 99, 235, 0.06)",borderRadius:4,pointerEvents:"none"}})]}),C&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)("div",{style:{position:"fixed",left:f.x-1,top:f.y-1,width:f.width+2,height:f.height+2,border:"2px dashed rgba(37, 99, 235, 0.35)",borderRadius:4,background:"rgba(37, 99, 235, 0.03)",pointerEvents:"none"}}),(0,Y.jsx)("div",{style:{position:"fixed",left:E.x-ee.current.x,top:E.y-ee.current.y,width:f.width,height:f.height,opacity:.7,borderRadius:4,border:"1.5px solid #2563eb",background:"rgba(37, 99, 235, 0.06)",boxShadow:"0 4px 12px rgba(0, 0, 0, 0.15)",pointerEvents:"none",zIndex:99999}})]}),h&&(0,Y.jsx)("div",{style:{position:"absolute",left:h.x-(h.isVertical?1:0),top:h.y-(h.isVertical?0:1),width:h.isVertical?2:h.width,height:h.isVertical?h.height:2,background:"#2563eb",borderRadius:2,pointerEvents:"none",boxShadow:"0 0 6px rgba(37, 99, 235, 0.4)"}}),A&&(0,Y.jsx)("div",{style:{position:"fixed",left:A.rect.x-2,top:A.rect.y-2,width:A.rect.width+4,height:A.rect.height+4,border:"2px dashed #2563eb",borderRadius:6,background:"rgba(37, 99, 235, 0.04)",pointerEvents:"none",transition:"all 0.15s ease"}})]}),l.map((Z,w)=>{let X=Z.reorderIndex!==void 0;return(0,Y.jsx)(vp,{move:Z,idx:w,isReorder:X,editing:o===w,onToggleEdit:()=>c(o===w?-1:w),onDelete:()=>{i?.(w),c(-1)},onClose:()=>c(-1),iframeRef:e},`move-${w}`)})]})}var rs="-apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif",pp="cubic-bezier(0.34, 1.56, 0.64, 1)";function vp({move:t,idx:e,isReorder:n,editing:l,onToggleEdit:a,onDelete:i,onClose:u,iframeRef:o}){let[c,r]=(0,rt.useState)(null);return(0,rt.useEffect)(()=>{let y=(()=>{try{return o.current?.contentDocument??document}catch{return document}})(),g=(()=>{try{return o.current?.contentWindow??window}catch{return window}})(),d=()=>{let m=null;if(n&&t.parentSelector&&t.reorderIndex!==void 0){let b=t.targetParentSelector??t.parentSelector,E=y.querySelector(b);E&&(m=E.children[t.reorderIndex]??null)}if(m||(m=y.querySelector(t.selector)),m){let b=m.getBoundingClientRect();r({x:b.x,y:b.y,width:b.width,height:b.height})}};return d(),g.addEventListener("scroll",d,{passive:!0}),g.addEventListener("resize",d,{passive:!0}),()=>{g.removeEventListener("scroll",d),g.removeEventListener("resize",d)}},[o,t.selector,t.parentSelector,t.targetParentSelector,t.reorderIndex,n]),c?(0,Y.jsxs)(Y.Fragment,{children:[!n&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)("div",{style:{position:"fixed",left:c.x,top:c.y,width:c.width,height:c.height,border:"2px dashed rgba(37, 99, 235, 0.5)",borderRadius:4,pointerEvents:"none"}}),(0,Y.jsxs)("svg",{style:{position:"fixed",left:0,top:0,width:"100vw",height:"100vh",pointerEvents:"none",overflow:"visible"},children:[(0,Y.jsx)("defs",{children:(0,Y.jsx)("marker",{id:`arrowhead-${e}`,markerWidth:"8",markerHeight:"6",refX:"8",refY:"3",orient:"auto",children:(0,Y.jsx)("polygon",{points:"0 0, 8 3, 0 6",fill:"rgba(37, 99, 235, 0.6)"})})}),(0,Y.jsx)("line",{x1:c.x+c.width/2,y1:c.y+c.height/2,x2:t.to.x+t.to.width/2,y2:t.to.y+t.to.height/2,stroke:"rgba(37, 99, 235, 0.4)",strokeWidth:"1.5",strokeDasharray:"4 3",markerEnd:`url(#arrowhead-${e})`})]})]}),(0,Y.jsx)("div",{onClick:y=>{y.stopPropagation(),a()},style:{position:"fixed",left:c.x+c.width-8,top:c.y-8,width:18,height:18,borderRadius:"50% 50% 50% 2px",background:"#2563eb",color:"#fff",fontSize:10,fontWeight:700,display:"flex",alignItems:"center",justifyContent:"center",pointerEvents:"auto",cursor:"pointer",fontFamily:rs,boxShadow:l?"0 0 0 3px #2563eb44":"none",zIndex:10001},children:e+1}),l&&(0,Y.jsx)(bp,{x:c.x+c.width+12,y:c.y-8,move:t,onDelete:i,onClose:u})]}):null}function bp({x:t,y:e,move:n,onDelete:l,onClose:a}){let i=ve(),[u,o]=(0,rt.useState)(!1);(0,rt.useEffect)(()=>{let b=0,E=requestAnimationFrame(()=>{b=requestAnimationFrame(()=>o(!0))});return()=>{cancelAnimationFrame(E),cancelAnimationFrame(b)}},[]);let c=n.reorderIndex!==void 0,r=!!(n.targetParentSelector&&n.targetParentSelector!==n.parentSelector),y=240,g=16,d=t;d+y+g>window.innerWidth&&(d=t-y-30),d=Math.max(g,d);let m=Math.max(g,Math.min(e,window.innerHeight-200));return(0,Y.jsx)("div",{"data-iterate-popup":!0,style:{position:"fixed",left:d,top:m,zIndex:10002,pointerEvents:"auto",width:y,opacity:u?1:0,transform:u?"scale(1)":"scale(0.92)",transition:`opacity 0.2s ease, transform 0.25s ${pp}`},children:(0,Y.jsxs)("div",{style:{borderRadius:12,overflow:"hidden",boxShadow:"0 4px 16px rgba(0,0,0,0.12)",fontFamily:rs,background:i.panelBg,padding:4},children:[(0,Y.jsx)("div",{style:{padding:"4px 8px",fontSize:12,fontWeight:500,color:i.textPrimary},children:(()=>{if(n.componentName)return`<${n.componentName}>`;let E=(n.selector.split(" ").pop()||"").replace(/[:.#\[].*$/,"").toLowerCase();return E?`<${E}>`:"Element"})()}),(0,Y.jsxs)("div",{style:{background:i.cardBg,border:`1px solid ${i.border}`,borderRadius:10,padding:8,display:"flex",flexDirection:"column",gap:8},children:[(0,Y.jsx)("div",{style:{fontSize:10,fontFamily:"monospace",color:i.textSecondary,lineHeight:1.7,background:i.drawerBg,borderRadius:6,padding:"6px 8px"},children:c?r?(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)("div",{children:[(0,Y.jsx)("span",{style:{color:i.textTertiary},children:"from:"})," ",n.parentSelector?.split(" ").pop()??"parent"]}),(0,Y.jsxs)("div",{children:[(0,Y.jsx)("span",{style:{color:i.textTertiary},children:"to:"})," ",n.targetParentSelector?.split(" ").pop()??"parent"]})]}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)("div",{children:[(0,Y.jsx)("span",{style:{color:i.textTertiary},children:"from:"})," index ",n.originalSiblingIndex??"?"]}),(0,Y.jsxs)("div",{children:[(0,Y.jsx)("span",{style:{color:i.textTertiary},children:"to:"})," index ",n.reorderIndex]})]}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)("div",{children:[(0,Y.jsx)("span",{style:{color:i.textTertiary},children:"from:"})," ",Math.round(n.from.x),", ",Math.round(n.from.y)]}),(0,Y.jsxs)("div",{children:[(0,Y.jsx)("span",{style:{color:i.textTertiary},children:"to:"})," ",Math.round(n.to.x),", ",Math.round(n.to.y)]})]})}),(0,Y.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center"},children:[(0,Y.jsx)(Sp,{onClick:b=>{b.stopPropagation(),l()}}),(0,Y.jsx)("button",{type:"button",onClick:b=>{b.stopPropagation(),a()},style:{padding:"6px 14px",background:"transparent",border:`1px solid ${i.border}`,borderRadius:6,color:i.textSecondary,cursor:"pointer",fontSize:12,fontFamily:rs},children:"Cancel"})]})]})]})})}function Sp({onClick:t}){let[e,n]=rt.default.useState(!1),l=ve();return(0,Y.jsx)("button",{type:"button",onClick:t,onMouseEnter:()=>n(!0),onMouseLeave:()=>n(!1),style:{display:"flex",alignItems:"center",justifyContent:"center",width:32,height:32,borderRadius:8,border:"none",background:e?l.hoverBg:"transparent",color:"#dc2626",cursor:"pointer",padding:0,flexShrink:0,transition:"background 0.1s ease"},children:(0,Y.jsx)(Da,{size:16})})}var Nl=class{ws=null;handlers=new Set;iterationsHandlers=new Set;toolModeHandlers=new Set;url;reconnectTimer=null;_iterations={};constructor(e){this.url=e??`ws://${window.location.host}/ws`}connect(){this.ws=new WebSocket(this.url),this.ws.onmessage=e=>{try{let n=JSON.parse(e.data);this.trackIterations(n),this.trackToolMode(n);for(let l of this.handlers)l(n)}catch{}},this.ws.onclose=()=>{this.reconnectTimer=setTimeout(()=>this.connect(),2e3)},this.ws.onerror=()=>{this.ws?.close()}}disconnect(){this.reconnectTimer&&clearTimeout(this.reconnectTimer),this.ws?.close(),this.ws=null}send(e){this.ws?.readyState===WebSocket.OPEN&&this.ws.send(JSON.stringify(e))}onMessage(e){return this.handlers.add(e),()=>this.handlers.delete(e)}onIterationsChange(e){return this.iterationsHandlers.add(e),()=>this.iterationsHandlers.delete(e)}get iterations(){return this._iterations}get connected(){return this.ws?.readyState===WebSocket.OPEN}sendToolMode(e){this.send({type:"tool:set-mode",payload:{mode:e}})}onToolModeChange(e){return this.toolModeHandlers.add(e),()=>this.toolModeHandlers.delete(e)}trackToolMode(e){if(e.type==="tool:mode-changed")for(let n of this.toolModeHandlers)n(e.payload.mode)}trackIterations(e){let n=!1;switch(e.type){case"state:sync":this._iterations={...e.payload.iterations},n=!0;break;case"iteration:created":this._iterations={...this._iterations,[e.payload.name]:e.payload},n=!0;break;case"iteration:status":this._iterations[e.payload.name]&&(this._iterations={...this._iterations,[e.payload.name]:{...this._iterations[e.payload.name],status:e.payload.status,...e.payload.error?{error:e.payload.error}:{}}},n=!0);break;case"iteration:removed":if(this._iterations[e.payload.name]){let{[e.payload.name]:l,...a}=this._iterations;this._iterations=a,n=!0}break}if(n)for(let l of this.iterationsHandlers)l(this._iterations)}};function Vm(t){return`iterate:state:${t}`}function km(t,e,n){try{let l={changes:e,domChanges:n};localStorage.setItem(Vm(t),JSON.stringify(l))}catch{}}function Zm(t){try{let e=localStorage.getItem(Vm(t));return e?JSON.parse(e):null}catch{return null}}var st=ot(Qt(),1);function Ep(t){try{return t.current?.contentWindow?.location.href}catch{return t.current?.src||void 0}}function po(t){return Ep(t)??window.location.href}function xp(t,e){try{return new URL(t).pathname===new URL(e).pathname}catch{return t===e}}function Ni(){return{x:window.scrollX||document.documentElement.scrollLeft||document.body.scrollLeft||0,y:window.scrollY||document.documentElement.scrollTop||document.body.scrollTop||0}}function Tp(t){let e=t;for(;e&&e!==document.documentElement;){let n=window.getComputedStyle(e).position;if(n==="fixed"||n==="sticky")return!0;e=e.parentElement}return!1}function Xm(t,e){let n=document.getElementById(t);return n||(n=document.createElement("div"),n.id=t,n.style.cssText=e,document.body.appendChild(n)),n}function Mp(){return Xm("__iterate-markers-layer__","position:absolute;top:0;left:0;width:0;height:0;overflow:visible;pointer-events:none;z-index:10001;")}function Cp(){return Xm("__iterate-fixed-markers-layer__","position:fixed;top:0;left:0;width:0;height:0;overflow:visible;pointer-events:none;z-index:9998;")}function fs({mode:t,iteration:e,wsUrl:n,iframeRef:l,onBatchCountChange:a,onMoveCountChange:i,onProcessingChange:u,previewMode:o=!0,visible:c=!0}){let r=(0,V.useRef)(null),[y,g]=(0,V.useState)([]),[d,m]=(0,V.useState)(null),[b,E]=(0,V.useState)(null),[O,f]=(0,V.useState)(null),[s,h]=(0,V.useState)({x:0,y:0}),[p,C]=(0,V.useState)([]),[L,A]=(0,V.useState)([]),q=(0,V.useRef)([]),z=(0,V.useRef)(new Set),[k,wt]=(0,V.useState)(!1),Vt=(0,V.useRef)(!1),_t=(0,V.useRef)(null),[ee]=(0,V.useState)(()=>typeof document<"u"?Mp():null),[zt]=(0,V.useState)(()=>typeof document<"u"?Cp():null),[kt,ne]=(0,V.useState)(()=>po(l));(0,V.useEffect)(()=>{let v=()=>ne(po(l));v();let _=history.pushState.bind(history),M=history.replaceState.bind(history);history.pushState=(...U)=>{_(...U),v()},history.replaceState=(...U)=>{M(...U),v()},window.addEventListener("popstate",v);let D=setInterval(v,500);return()=>{history.pushState=_,history.replaceState=M,window.removeEventListener("popstate",v),clearInterval(D)}},[l]);let[Tt,qt]=(0,V.useState)(null),[he,Bt]=(0,V.useState)(void 0),[Z,w]=(0,V.useState)(!1),X=c?t:"browse",N=y.length>0||d!==null||b!==null;(0,V.useEffect)(()=>{let v=new Nl(n);r.current=v,v.connect();let _=v.onMessage(M=>{switch(M.type){case"state:sync":{let D=M.payload.changes.filter(K=>K.iteration===e),U=M.payload.domChanges.filter(K=>K.iteration===e);if(D.length===0&&U.length===0){let K=Zm(e);if(K&&(K.changes.length>0||K.domChanges.length>0)){for(let nn of K.changes){let{id:oe,timestamp:mn,status:Bn,...vo}=nn;v.send({type:"change:create",payload:vo})}for(let nn of K.domChanges){let{id:oe,timestamp:mn,...Bn}=nn;v.send({type:"dom-change:create",payload:Bn})}break}}C(D),A(U);break}case"change:created":M.payload.iteration===e&&C(D=>[...D,M.payload]);break;case"change:updated":C(D=>D.map(U=>U.id===M.payload.id?M.payload:U));break;case"change:deleted":C(D=>D.filter(U=>U.id!==M.payload.id));break;case"dom:changed":M.payload.iteration===e&&(z.current.add(M.payload.id),A(D=>D.some(K=>K.id===M.payload.id)?D:[...M.payload.type==="reorder"?D.filter(K=>!(K.type==="reorder"&&K.selector===M.payload.selector)):D,M.payload]));break;case"dom:deleted":z.current.delete(M.payload.id),A(D=>D.filter(U=>U.id!==M.payload.id));break}});return()=>{_(),v.disconnect()}},[n,e]),(0,V.useEffect)(()=>{km(e,p,L)},[e,p,L]);let Mt=p.filter(v=>!(v.status==="implemented"||v.url&&kt&&!xp(v.url,kt))),ft=p.filter(v=>v.status==="queued"||v.status==="in-progress").length,B=L.length,et=p.some(v=>v.status==="in-progress");(0,V.useEffect)(()=>{a?.(ft)},[ft,a]),(0,V.useEffect)(()=>{i?.(B)},[B,i]),(0,V.useEffect)(()=>{u?.(et)},[et,u]);let dt=(0,V.useCallback)((v,_)=>{let M=Ni();g(v.map(D=>({...D,rect:{...D.rect,x:D.rect.x+M.x,y:D.rect.y+M.y}}))),_&&f({x:_.x+M.x,y:_.y+M.y})},[]),mt=(0,V.useCallback)(v=>{let _=Ni();if(g(v.map(M=>({...M,rect:{...M.rect,x:M.rect.x+_.x,y:M.rect.y+_.y}}))),v.length>0){let M=-1/0,D=0;for(let U of v){let K=U.rect;K.x+K.width>M&&(M=K.x+K.width),D+=K.y+K.height/2}f({x:M+_.x,y:D/v.length+_.y})}},[]),nt=(0,V.useCallback)(v=>{m(v)},[]),I=(0,V.useCallback)((v,_)=>{let M=Ni();g(v.map(U=>({...U,rect:{...U.rect,x:U.rect.x+M.x,y:U.rect.y+M.y}}))),E(_),h(M);let D=_.path.match(/^M\s+([\d.]+)\s+([\d.]+)/);f(D?{x:parseFloat(D[1])+M.x,y:parseFloat(D[2])+M.y}:{x:_.bounds.x+_.bounds.width+M.x,y:_.bounds.y+_.bounds.height/2+M.y})},[]),it=(0,V.useCallback)(v=>{g(_=>{let M=[..._];return M.splice(v,1),M})},[]),le=(0,V.useCallback)(v=>{if(y.length===0&&!d&&!b)return;let _=r.current;if(!_)return;let M=Tt!==null?Z:y.length>0&&Tp(y[0].domElement),D=Ni(),U;if(O)U=M?{x:O.x-D.x,y:O.y-D.y}:{x:O.x,y:O.y};else if(y.length>0){let K=y[0];U=M?{x:K.rect.x-D.x+K.rect.width/2,y:K.rect.y-D.y+K.rect.height/2}:{x:K.rect.x+K.rect.width/2,y:K.rect.y+K.rect.height/2}}else b&&(U={x:b.bounds.x+b.bounds.width/2+D.x,y:b.bounds.y+b.bounds.height/2+D.y});Tt!==null&&(_.send({type:"change:delete",payload:{id:Tt}}),qt(null),Bt(void 0)),_.send({type:"change:create",payload:{iteration:e,url:po(l),elements:y.map(K=>({selector:K.selector,elementName:K.elementName,elementPath:K.elementPath,rect:K.rect,computedStyles:K.computedStyles,nearbyText:K.nearbyText,componentName:K.componentName,sourceLocation:K.sourceLocation})),textSelection:d??void 0,drawing:b??void 0,comment:v,pagePosition:U,isFixedPosition:M||void 0,drawingScrollOffset:b?{x:D.x,y:D.y}:void 0}}),g([]),m(null),E(null)},[y,d,b,e,l,O,Tt,Z]),Ft=(0,V.useCallback)(v=>{r.current?.send({type:"change:delete",payload:{id:v}})},[]),S=(0,V.useCallback)(v=>{let _=p.find(M=>M.id===v);if(_){if(g(_.elements.map(M=>({...M,domElement:null}))),m(_.textSelection??null),E(_.drawing??null),_.pagePosition){let M=Ni();f(_.isFixedPosition?{x:_.pagePosition.x+M.x,y:_.pagePosition.y+M.y}:_.pagePosition)}else f(null);qt(v),w(!!_.isFixedPosition),Bt(_.comment)}},[p]),x=(0,V.useCallback)(()=>{Tt!==null&&Ft(Tt),qt(null),w(!1),Bt(void 0),g([]),m(null),E(null)},[Tt,Ft]),H=(0,V.useCallback)(()=>{g([]),m(null),E(null),qt(null),w(!1),Bt(void 0)},[]);(0,V.useEffect)(()=>{q.current=L},[L]);let G=(0,V.useCallback)(v=>{let _=r.current;if(!_)return;let M=v.reorderIndex!==void 0,D=v.originalSiblingIndex,U=v.parentSelector;if(M){let K=q.current.find(oe=>oe.type==="reorder"&&oe.selector===v.selector);if(K&&(D=K.before.siblingIndex,U=K.parentSelector,_.send({type:"dom-change:delete",payload:{id:K.id}})),(!v.targetParentSelector||v.targetParentSelector===U)&&v.reorderIndex===D)return}_.send({type:"dom-change:create",payload:{iteration:e,url:po(l),selector:v.selector,parentSelector:U,targetParentSelector:v.targetParentSelector,type:M?"reorder":"move",componentName:v.componentName,sourceLocation:v.sourceLocation,before:{rect:v.from,computedStyles:v.computedStyles,siblingIndex:D},after:{rect:v.to,computedStyles:v.computedStyles,siblingIndex:v.reorderIndex}}})},[e,l]),Q=(0,V.useCallback)(v=>{if(v.type!=="reorder"||v.after.siblingIndex===void 0)return;let _=(()=>{try{return l.current?.contentDocument??document}catch{return document}})();try{if(v.targetParentSelector&&v.targetParentSelector!==v.parentSelector){let oe=v.parentSelector?_.querySelector(v.parentSelector):null,mn=_.querySelector(v.targetParentSelector);if(!oe||!mn)return;let Bn=v.before.siblingIndex!==void 0?oe.children[v.before.siblingIndex]??null:null;if(!Bn)return;let bo=Array.from(mn.children)[v.after.siblingIndex]??null;mn.insertBefore(Bn,bo);return}let D=v.parentSelector?_.querySelector(v.parentSelector):null;if(!D)return;let U=v.before.siblingIndex!==void 0?D.children[v.before.siblingIndex]??null:null;if(!U)return;let nn=Array.from(D.children).filter(oe=>oe!==U)[v.after.siblingIndex]??null;D.insertBefore(U,nn)}catch{}},[l]);(0,V.useEffect)(()=>{if(L.length===0)return;let v=L.filter(_=>_.type==="reorder"&&!z.current.has(_.id)).sort((_,M)=>_.timestamp-M.timestamp);for(let _ of v)Q(_),z.current.add(_.id)},[L,Q]);let j=(0,V.useCallback)(v=>{if(v.type!=="reorder"||v.before.siblingIndex===void 0)return;let _=(()=>{try{return l.current?.contentDocument??document}catch{return document}})();try{if(v.targetParentSelector&&v.targetParentSelector!==v.parentSelector){let oe=_.querySelector(v.targetParentSelector),mn=v.parentSelector?_.querySelector(v.parentSelector):null;if(!oe||!mn)return;let Bn=v.after.siblingIndex!==void 0?oe.children[v.after.siblingIndex]??null:null;if(!Bn)return;let bo=Array.from(mn.children)[v.before.siblingIndex]??null;mn.insertBefore(Bn,bo);return}let D=null;if(v.parentSelector&&v.after.siblingIndex!==void 0){let oe=_.querySelector(v.parentSelector);oe&&(D=oe.children[v.after.siblingIndex]??null)}if(D||(D=_.querySelector(v.selector)),!D||!D.parentElement)return;let U=D.parentElement,nn=Array.from(U.children).filter(oe=>oe!==D)[v.before.siblingIndex]??null;U.insertBefore(D,nn)}catch{}},[l]),$=(0,V.useCallback)(v=>{let _=L.find(M=>M.id===v);_&&j(_),r.current?.send({type:"dom-change:delete",payload:{id:v}})},[L,j]),pt=L.map(v=>({iteration:v.iteration,url:v.url,selector:v.selector,from:v.before.rect,to:v.after.rect,computedStyles:v.before.computedStyles,componentName:v.componentName,sourceLocation:v.sourceLocation,reorderIndex:v.after.siblingIndex,originalSiblingIndex:v.before.siblingIndex,parentSelector:v.parentSelector,targetParentSelector:v.targetParentSelector}));return(0,V.useEffect)(()=>{let v=()=>{let _=r.current;if(_){for(let M of p)M.status==="queued"&&_.send({type:"change:delete",payload:{id:M.id}});for(let M=L.length-1;M>=0;M--)j(L[M]),_.send({type:"dom-change:delete",payload:{id:L[M].id}});g([]),m(null),E(null)}};return window.addEventListener("iterate:clear-batch",v),()=>window.removeEventListener("iterate:clear-batch",v)},[p,L,j]),(0,V.useEffect)(()=>{let v=()=>{let _=r.current;if(!_)return;let M=p.filter(nn=>nn.status==="queued").at(-1),D=L.at(-1);if(!M&&!D)return;let U=M?.timestamp??0,K=D?.timestamp??0;U>=K&&M?_.send({type:"change:delete",payload:{id:M.id}}):D&&(j(D),_.send({type:"dom-change:delete",payload:{id:D.id}}))};return window.addEventListener("iterate:undo",v),()=>window.removeEventListener("iterate:undo",v)},[p,L,j]),(0,V.useEffect)(()=>{let v=()=>{let _=p.filter(U=>U.status==="queued"||U.status==="in-progress");if(_.length===0&&L.length===0){window.dispatchEvent(new CustomEvent("iterate:batch-text-response",{detail:{text:""}}));return}let M=L.map(U=>({type:U.type,selector:U.selector,componentName:U.componentName,sourceLocation:U.sourceLocation,before:{rect:U.before.rect},after:{rect:U.after.rect},url:U.url})),D=is(_,M,e);window.dispatchEvent(new CustomEvent("iterate:batch-text-response",{detail:{text:D}}))};return window.addEventListener("iterate:request-batch-text",v),()=>window.removeEventListener("iterate:request-batch-text",v)},[p,L,e]),(0,V.useEffect)(()=>{let v=()=>{let _=p.filter(U=>U.status==="queued"||U.status==="in-progress");if(_.length===0&&L.length===0)return;let M=L.map(U=>({type:U.type,selector:U.selector,componentName:U.componentName,sourceLocation:U.sourceLocation,before:{rect:U.before.rect},after:{rect:U.after.rect},url:U.url})),D=is(_,M,e);navigator.clipboard.writeText(D)};return window.addEventListener("iterate:copy-batch",v),()=>window.removeEventListener("iterate:copy-batch",v)},[p,L,e]),(0,st.jsxs)(st.Fragment,{children:[(0,st.jsxs)("div",{ref:_t,style:{position:"absolute",inset:0,pointerEvents:"none",zIndex:9999},children:[(0,st.jsx)(hm,{active:X==="select"&&!N,iframeRef:l,selectedElements:y,onSelect:dt,suppressHover:k,justFinishedDragRef:Vt}),(0,st.jsx)(ym,{active:X==="select"&&!N,iframeRef:l,onSelect:mt,onDragStateChange:wt,justFinishedDragRef:Vt}),(0,st.jsx)(Sm,{active:X==="select"&&!N,iframeRef:l,onTextSelect:nt}),(0,st.jsx)(Mm,{active:X==="draw"&&!N,iframeRef:l,onDrawComplete:I}),(0,st.jsx)(Ym,{active:X==="move",iframeRef:l,onMove:G,pendingMoves:pt,previewMode:o,onDeleteMove:v=>{let _=L[v];_&&$(_.id)}})]}),c&&ee&&(0,ss.createPortal)((0,st.jsxs)(st.Fragment,{children:[N&&b&&(0,st.jsx)("svg",{style:{position:"absolute",left:s.x,top:s.y,width:"100vw",height:"100vh",pointerEvents:"none",overflow:"visible"},children:(0,st.jsx)("path",{d:b.path,fill:"none",stroke:b.strokeColor,strokeWidth:b.strokeWidth,strokeLinecap:"round",strokeLinejoin:"round",opacity:.7})}),!b&&y.map((v,_)=>{let M=v.rect.x,D=v.rect.y;return(0,st.jsxs)(V.default.Fragment,{children:[(0,st.jsx)("div",{style:{position:"absolute",left:M,top:D,width:v.rect.width,height:v.rect.height,border:"1.5px solid #6b9eff",backgroundColor:"rgba(107, 158, 255, 0.06)",borderRadius:4,pointerEvents:"none",boxSizing:"border-box"}}),!N&&(0,st.jsxs)("div",{style:{position:"absolute",left:M,top:D-26,background:"#6b9eff",color:"#fff",padding:"2px 8px",borderRadius:4,fontSize:10,fontFamily:"monospace",whiteSpace:"nowrap",pointerEvents:"none",display:"flex",gap:6,alignItems:"center",maxWidth:400,overflow:"hidden"},children:[(0,st.jsx)("span",{style:{fontWeight:700},children:v.elementName}),v.sourceLocation&&(0,st.jsx)("span",{style:{opacity:.7,fontSize:9},children:v.sourceLocation})]})]},v.selector+_)}),(0,st.jsx)(qm,{selectedElements:y,textSelection:d,onRemoveElement:it,onAddToBatch:le,onClearSelection:H,clickPosition:O,isDrawing:b!=null,initialComment:he,onDelete:Tt!==null?x:void 0}),N&&O&&Tt===null&&(0,st.jsx)(wp,{number:Mt.length+1,x:O.x,y:O.y,color:"#2563eb",elementRect:b?{...b.bounds,x:b.bounds.x+s.x,y:b.bounds.y+s.y}:y[0]?.rect},`preview-${Mt.length}-${O.x}-${O.y}`),Mt.map((v,_)=>{if(v.isFixedPosition)return null;let M=v.pagePosition;if(!M)return null;let D=v.drawingScrollOffset??{x:0,y:0},U=v.drawing?{x:v.drawing.bounds.x+D.x,y:v.drawing.bounds.y+D.y,width:v.drawing.bounds.width,height:v.drawing.bounds.height}:v.elements[0]?.rect;return(0,st.jsxs)(V.default.Fragment,{children:[v.drawing&&(0,st.jsx)("svg",{style:{position:"absolute",left:D.x,top:D.y,width:"100vw",height:"100vh",pointerEvents:"none",overflow:"visible"},children:(0,st.jsx)("path",{d:v.drawing.path,fill:"none",stroke:v.drawing.strokeColor,strokeWidth:v.drawing.strokeWidth,strokeLinecap:"round",strokeLinejoin:"round",opacity:.5})}),(0,st.jsx)(jm,{number:_+1,x:M.x,y:M.y,color:v.status==="in-progress"?"#16a34a":"#2563eb",onEdit:()=>S(v.id),isEditing:Tt===v.id,elementRect:U})]},v.id)})]}),ee),c&&zt&&(0,ss.createPortal)((0,st.jsx)(st.Fragment,{children:Mt.map((v,_)=>{if(!v.isFixedPosition)return null;let M=v.pagePosition;if(!M)return null;let D=v.drawing?v.drawing.bounds:v.elements[0]?.rect;return(0,st.jsxs)(V.default.Fragment,{children:[v.drawing&&(0,st.jsx)("svg",{style:{position:"absolute",left:0,top:0,width:"100vw",height:"100vh",pointerEvents:"none",overflow:"visible"},children:(0,st.jsx)("path",{d:v.drawing.path,fill:"none",stroke:v.drawing.strokeColor,strokeWidth:v.drawing.strokeWidth,strokeLinecap:"round",strokeLinejoin:"round",opacity:.5})}),(0,st.jsx)(jm,{number:_+1,x:M.x,y:M.y,color:v.status==="in-progress"?"#16a34a":"#2563eb",onEdit:()=>S(v.id),isEditing:Tt===v.id,elementRect:D})]},v.id)})}),zt)]})}var Gm="cubic-bezier(0.34, 1.56, 0.64, 1)";function Qm(t,e,n){if(!n)return"50% 50% 2px 50%";let l=n.x+n.width/2,a=n.y+n.height/2,i=t<=l,u=e<=a;return i&&u?"50% 50% 2px 50%":!i&&u?"50% 50% 50% 2px":!i&&!u?"2px 50% 50% 50%":"50% 2px 50% 50%"}function wp({number:t,x:e,y:n,color:l,elementRect:a}){let[i,u]=(0,V.useState)(!1);return(0,V.useEffect)(()=>{let o=0,c=requestAnimationFrame(()=>{o=requestAnimationFrame(()=>{u(!0)})});return()=>{cancelAnimationFrame(c),cancelAnimationFrame(o)}},[]),(0,st.jsx)("div",{style:{position:"absolute",left:e-9,top:n-9,width:18,height:18,borderRadius:Qm(e,n,a),background:l,color:"#fff",fontSize:10,fontWeight:700,display:"flex",alignItems:"center",justifyContent:"center",pointerEvents:"none",fontFamily:"-apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif",transform:i?"scale(1)":"scale(0.75)",opacity:i?1:0,transition:`transform 0.35s ${Gm}, opacity 0.2s ease`},children:t})}function jm({number:t,x:e,y:n,color:l,onEdit:a,isEditing:i,elementRect:u}){let[o,c]=(0,V.useState)(!1);return(0,V.useEffect)(()=>{let r=0,y=requestAnimationFrame(()=>{r=requestAnimationFrame(()=>{c(!0)})});return()=>{cancelAnimationFrame(y),cancelAnimationFrame(r)}},[]),(0,st.jsx)("div",{onClick:r=>{r.stopPropagation(),a()},style:{position:"absolute",left:e-9,top:n-9,width:18,height:18,borderRadius:Qm(e,n,u),background:l,color:"#fff",fontSize:10,fontWeight:700,display:"flex",alignItems:"center",justifyContent:"center",pointerEvents:"auto",cursor:"pointer",fontFamily:"-apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif",transform:o?"scale(1)":"scale(0.75)",opacity:o?1:0,transition:`transform 0.35s ${Gm}, opacity 0.2s ease`,boxShadow:i?`0 0 0 3px ${l}44`:"none"},children:t})}var W=ot(be(),1),ms=ot(Ba(),1);var R=ot(Qt(),1),Lt="__original__",fl=16,te=24,We="cubic-bezier(0.34, 1.56, 0.64, 1)",hs=W.default.createContext(!1),_p="0.8s",Km={ready:"#22c55e",creating:"#eab308",installing:"#eab308",starting:"#eab308",error:"#ef4444",stopped:"#888"};function Wm({mode:t,onModeChange:e,visible:n,onVisibilityChange:l,batchCount:a=0,moveCount:i=0,onClearBatch:u,onCopyBatch:o,onUndoMove:c,iterations:r,activeIteration:y,onIterationChange:g,onFork:d,onPick:m,onDiscard:b,isViewingIteration:E=!1,tabBadgeCounts:O={},readyIframes:f,processing:s=!1}){let h=ve(),p=(0,W.useRef)(null),[C,L]=(0,W.useState)("bottom-right"),[A,q]=(0,W.useState)(!1),[z,k]=(0,W.useState)({x:0,y:0}),[wt,Vt]=(0,W.useState)(null),[_t,ee]=(0,W.useState)(!1),[zt,kt]=(0,W.useState)(!1),[ne,Tt]=(0,W.useState)(!1),[qt,he]=(0,W.useState)(!1),Bt=(0,W.useRef)(null),Z=r?Object.keys(r).sort((j,$)=>j.localeCompare($,void 0,{numeric:!0})):[],w=Z.length>0,X=w?Z.map(j=>r[j]?.status):[],N=X.some(j=>j==="creating"||j==="installing"||j==="starting"),Mt=["creating","installing","starting"],ft=X.includes("starting")?2:X.includes("installing")?1:X.includes("ready")?2:0,B=(0,W.useRef)(-1);!N&&!_t?B.current=-1:ft>B.current&&(B.current=ft);let et=B.current>=0?Mt[B.current]:null,dt=a+i,mt=C==="top-left"||C==="bottom-left",nt=C==="top-left"||C==="top-right",I=!w&&!_t&&!N||_t||N||w&&E&&!zt&&!N||zt||w&&!E&&!ne&&!N||ne;(0,W.useEffect)(()=>()=>{Bt.current&&clearTimeout(Bt.current)},[]),(0,W.useEffect)(()=>{w&&ee(!1)},[w]),(0,W.useEffect)(()=>{w||(kt(!1),Tt(!1))},[w]);let it=(0,W.useRef)(!1);(N||_t)&&(it.current=!0);let le=f!=null&&w&&Z.every(j=>r[j]?.status!=="ready"||f.has(j));le&&it.current&&(it.current=!1);let Ft=it.current&&w&&!le&&!zt&&!ne,S=_t||N||zt||ne||Ft,x=zt?"Merging preferred changes\u2026":ne?"Removing iteration worktrees\u2026":Ft&&!N&&!_t?"Loading page\u2026":et==="installing"?"Installing dependencies\u2026":et==="starting"?"Starting dev server\u2026":"Creating iteration branches\u2026";(0,W.useEffect)(()=>{let j=$=>{if(($.metaKey||$.ctrlKey)&&$.key==="i"){$.preventDefault(),l(!n);return}if(!n)return;let pt=$.target?.tagName;if(!(pt==="INPUT"||pt==="TEXTAREA"||$.target?.isContentEditable)&&!($.metaKey||$.ctrlKey||$.altKey))switch($.key){case"Escape":$.preventDefault(),l(!1);break;case"s":$.preventDefault(),document.activeElement?.blur?.(),e(t==="select"?"browse":"select");break;case"d":$.preventDefault(),document.activeElement?.blur?.(),e(t==="draw"?"browse":"draw");break;case"m":$.preventDefault(),document.activeElement?.blur?.(),e(t==="move"?"browse":"move");break;case"u":$.preventDefault(),c?.();break;case"x":$.preventDefault(),u?.();break;case"c":$.preventDefault(),o?.(),he(!0),Bt.current&&clearTimeout(Bt.current),Bt.current=setTimeout(()=>he(!1),3e3);break}};return window.addEventListener("keydown",j),()=>window.removeEventListener("keydown",j)},[n,l,t,e,c,u,o]);let H=(0,W.useCallback)(j=>{if(j.target.closest("button"))return;let $=p.current;if(!$)return;let pt=$.getBoundingClientRect();q(!0),k({x:j.clientX-pt.left,y:j.clientY-pt.top}),Vt({x:pt.left,y:pt.top}),j.preventDefault()},[]);(0,W.useEffect)(()=>{if(!A)return;let j=pt=>{Vt({x:pt.clientX-z.x,y:pt.clientY-z.y})},$=pt=>{q(!1);let v=pt.clientX,_=pt.clientY,M=window.innerWidth/2,D=window.innerHeight/2,U=v<M?_<D?"top-left":"bottom-left":_<D?"top-right":"bottom-right";L(U),Vt(null)};return window.addEventListener("mousemove",j),window.addEventListener("mouseup",$),()=>{window.removeEventListener("mousemove",j),window.removeEventListener("mouseup",$)}},[A,z]);let G=wt?{left:wt.x,top:wt.y}:Np(C),Q=A?"none":"left 0.3s ease, top 0.3s ease, right 0.3s ease, bottom 0.3s ease";return(0,R.jsxs)(hs.Provider,{value:nt,children:[(0,R.jsx)(Ap,{active:S,message:x}),(0,R.jsxs)("div",{ref:p,"data-iterate-panel":"",onMouseDown:H,style:{position:"fixed",...G,zIndex:10001,pointerEvents:"auto",background:h.panelBg,border:"none",borderRadius:12,boxShadow:"0 4px 16px rgba(0,0,0,0.12)",display:"flex",flexDirection:nt?"column-reverse":"column",gap:0,cursor:A?"grabbing":"grab",userSelect:"none",overflow:"visible",padding:4,transition:Q},children:[dt>0&&(0,R.jsx)(Lp,{count:dt,isLeftSide:mt,processing:s}),w&&(0,R.jsx)("div",{style:{background:h.panelBg,maxHeight:n?56:0,maxWidth:n?999:0,opacity:n?1:0,overflow:"hidden",...nt?{marginBottom:n?2:0}:{marginTop:n?2:0},transition:n?"max-height 0.2s ease 0.2s, max-width 0.2s ease 0.2s, opacity 0.15s ease 0.2s, margin 0.2s ease 0.2s":"max-height 0.12s ease 0s, max-width 0.12s ease 0s, opacity 0.1s ease 0s, margin 0.12s ease 0s"},children:(0,R.jsx)("div",{style:{padding:"4px 4px 4px 4px"},children:(0,R.jsxs)("div",{ref:j=>{if(j&&!j.dataset.scrollbarHidden){let $=document.createElement("style");$.textContent="[data-iterate-tabs]::-webkit-scrollbar { display: none; }",j.appendChild($),j.dataset.scrollbarHidden="1"}},"data-iterate-tabs":"",style:{display:"flex",alignItems:"center",gap:2,overflowX:"auto",scrollbarWidth:"none",paddingTop:6,paddingRight:6,marginTop:-6,marginRight:-6},children:[(0,R.jsxs)($m,{active:y===Lt,badgeCount:O[Lt]??0,title:"Root directory",onClick:()=>g?.(Lt),children:[(0,R.jsx)("span",{style:{width:6,height:6,borderRadius:"50%",background:Km.ready,flexShrink:0}}),"Original"]}),Z.map(j=>{let $=r[j],pt=j===y,v=O[j]??0;return(0,R.jsxs)($m,{active:pt,badgeCount:v,title:$?.error?`${j}: ${$.error}`:`${j} worktree`,onClick:()=>g?.(j),children:[(0,R.jsx)("span",{style:{width:6,height:6,borderRadius:"50%",background:Km[$?.status??"stopped"],flexShrink:0}}),j]},j)})]})})}),(0,R.jsxs)("div",{style:{position:"relative",display:"flex",flexDirection:mt?"row-reverse":"row",justifyContent:"flex-end",alignItems:"center",background:h.toolbarBg,border:`1px solid ${h.border}`,borderRadius:10,padding:4},children:[(0,R.jsxs)(Dp,{reversed:mt,visible:n,children:[(0,R.jsx)($e,{icon:(0,R.jsx)(_m,{size:te}),label:"Select (S)",active:t==="select",onClick:()=>e(t==="select"?"browse":"select")}),(0,R.jsx)($e,{icon:(0,R.jsx)(Lm,{size:te}),label:"Draw (D)",active:t==="draw",onClick:()=>e(t==="draw"?"browse":"draw")}),(0,R.jsx)($e,{icon:(0,R.jsx)(Am,{size:te}),label:"Move (M)",active:t==="move",onClick:()=>e(t==="move"?"browse":"move")}),(0,R.jsx)(ds,{}),(0,R.jsx)($e,{icon:(0,R.jsx)(zm,{size:te}),label:"Undo last change (U)",disabled:dt===0,onClick:()=>c?.()}),(0,R.jsx)($e,{icon:(0,R.jsx)(Da,{size:te}),label:"Clear all changes (X)",disabled:dt===0,onClick:()=>u?.()}),(0,R.jsx)($e,{icon:(0,R.jsxs)("div",{style:{position:"relative",width:te,height:te},children:[(0,R.jsx)("div",{style:{position:"absolute",inset:0,display:"flex",alignItems:"center",justifyContent:"center",opacity:qt?0:1,transform:qt?"scale(0.6)":"scale(1)",filter:qt?"blur(4px)":"blur(0px)",transition:`opacity 0.25s ${We}, transform 0.3s ${We}, filter 0.25s ease`},children:(0,R.jsx)(Om,{size:te})}),(0,R.jsx)("div",{style:{position:"absolute",inset:0,display:"flex",alignItems:"center",justifyContent:"center",opacity:qt?1:0,transform:qt?"scale(1)":"scale(0.6)",filter:qt?"blur(0px)":"blur(4px)",transition:`opacity 0.25s ${We}, transform 0.3s ${We}, filter 0.25s ease`},children:(0,R.jsx)(Bm,{size:te,color:"#22c55e",animate:!0})})]}),label:qt?"Copied!":"Copy changes to clipboard (C)",disabled:dt===0,onClick:()=>{o?.(),he(!0),Bt.current&&clearTimeout(Bt.current),Bt.current=setTimeout(()=>he(!1),3e3)}}),I&&(0,R.jsx)(ds,{}),!w&&!_t&&!N&&(0,R.jsx)($e,{icon:(0,R.jsx)(Dm,{size:te}),label:"Create iterations",onClick:()=>{ee(!0),d?.()}}),(_t||N)&&(0,R.jsx)($e,{icon:(0,R.jsx)(go,{size:te}),label:"Creating iterations",onClick:()=>{}}),w&&E&&!zt&&!N&&(0,R.jsx)($e,{icon:(0,R.jsx)(Rm,{size:te}),label:`Merge "${y}"`,onClick:async()=>{if(!(!y||y===Lt)){kt(!0);try{await m?.(y)}finally{kt(!1)}}}}),zt&&(0,R.jsx)($e,{icon:(0,R.jsx)(go,{size:te}),label:"Merging\\u2026",onClick:()=>{}}),w&&!E&&!ne&&!N&&(0,R.jsx)($e,{icon:(0,R.jsx)(Hm,{size:te}),label:"Discard all iterations",onClick:async()=>{Tt(!0);try{await b?.()}finally{Tt(!1)}}}),ne&&(0,R.jsx)($e,{icon:(0,R.jsx)(go,{size:te}),label:"Removing iteration worktrees\\u2026",onClick:()=>{}}),(0,R.jsx)(ds,{})]}),(0,R.jsx)(Rp,{visible:n,onVisibilityChange:l})]})]})]})}function Ap({active:t,message:e}){let n=ve();return(0,R.jsxs)("div",{style:{position:"fixed",inset:0,zIndex:1e4,background:n.suspenseOverlay,display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:20,backdropFilter:"blur(8px)",WebkitBackdropFilter:"blur(8px)",opacity:t?1:0,pointerEvents:t?"auto":"none",transition:"opacity 0.3s ease"},children:[(0,R.jsx)("style",{children:`
51
53
  @keyframes iterate-suspense-spin {
52
54
  to { transform: rotate(360deg); }
53
55
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "iterate-ui-overlay",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "description": "iterate browser overlay — annotation canvas, element inspector, DOM manipulation",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -32,7 +32,7 @@
32
32
  "./package.json": "./package.json"
33
33
  },
34
34
  "dependencies": {
35
- "iterate-ui-core": "0.1.1"
35
+ "iterate-ui-core": "0.1.2"
36
36
  },
37
37
  "peerDependencies": {
38
38
  "react": "^18.0.0 || ^19.0.0",