@firebuzz/design-mode 0.1.4 → 0.1.5

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/LICENSE ADDED
@@ -0,0 +1,77 @@
1
+ # Functional Source License, Version 1.1, Apache 2.0 Future License
2
+ **Abbreviation**: FSL-1.1-Apache-2.0
3
+
4
+ ---
5
+
6
+ ## Notice
7
+ Copyright 2023-2024 Firebuzz Inc., the creators of **Firebuzz**.
8
+
9
+ ---
10
+
11
+ ## Terms and Conditions
12
+
13
+ ### Licensor ("We")
14
+ The party offering **Firebuzz** under these Terms and Conditions.
15
+
16
+ ### The Software
17
+ The "Software" is each version of **Firebuzz** that we make available under these Terms and Conditions, as indicated by our inclusion of these Terms and Conditions with the Software.
18
+
19
+ ---
20
+
21
+ ## License Grant
22
+ Subject to your compliance with this License Grant and the Patents, Redistribution, and Trademark clauses below, we hereby grant you the right to use, copy, modify, create derivative works, publicly perform, publicly display, and redistribute **Firebuzz** for any Permitted Purpose identified below.
23
+
24
+ ---
25
+
26
+ ## Permitted Purpose
27
+ A Permitted Purpose is any purpose other than a Competing Use. A Competing Use means making **Firebuzz** available to others in a commercial product or service that:
28
+
29
+ 1. Substitutes for **Firebuzz**;
30
+ 2. Substitutes for any other product or service we offer using **Firebuzz** that exists as of the date we make **Firebuzz** available; or
31
+ 3. Offers the same or substantially similar functionality as **Firebuzz**.
32
+
33
+ Permitted Purposes specifically include using **Firebuzz**:
34
+
35
+ 1. For your internal use and access;
36
+ 2. For non-commercial education;
37
+ 3. For non-commercial research; and
38
+ 4. In connection with professional services that you provide to a licensee using **Firebuzz** in accordance with these Terms and Conditions.
39
+
40
+ ---
41
+
42
+ ## Patents
43
+ To the extent your use for a Permitted Purpose would necessarily infringe our patents, the license grant above includes a license under our patents. If you make a claim against any party that **Firebuzz** infringes or contributes to the infringement of any patent, then your patent license to **Firebuzz** ends immediately.
44
+
45
+ ---
46
+
47
+ ## Redistribution
48
+ The Terms and Conditions apply to all copies, modifications, and derivatives of **Firebuzz**.
49
+
50
+ If you redistribute any copies, modifications, or derivatives of **Firebuzz**, you must:
51
+
52
+ 1. Include a copy of or a link to these Terms and Conditions; and
53
+ 2. Not remove any copyright notices provided in or with **Firebuzz**.
54
+
55
+ ---
56
+
57
+ ## Disclaimer
58
+ THE SOFTWARE IS PROVIDED "AS IS" AND WITHOUT WARRANTIES OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABILITY, TITLE, OR NON-INFRINGEMENT.
59
+
60
+ IN NO EVENT WILL WE HAVE ANY LIABILITY TO YOU ARISING OUT OF OR RELATED TO **Firebuzz**, INCLUDING INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, EVEN IF WE HAVE BEEN INFORMED OF THEIR POSSIBILITY IN ADVANCE.
61
+
62
+ ---
63
+
64
+ ## Trademarks
65
+ Except for displaying the License Details and identifying us as the origin of **Firebuzz**, you have no right under these Terms and Conditions to use our trademarks, trade names, service marks, or product names.
66
+
67
+ ---
68
+
69
+ ## Grant of Future License
70
+ We hereby irrevocably grant you an additional license to use **Firebuzz** under the Apache License, Version 2.0, effective on the third anniversary of the date we make **Firebuzz** available. On or after that date, you may use **Firebuzz** under the Apache License, Version 2.0, in which case the following will apply:
71
+
72
+ Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License.
73
+
74
+ You may obtain a copy of the License at:
75
+ [http://www.apache.org/licenses/LICENSE-2.0](http://www.apache.org/licenses/LICENSE-2.0)
76
+
77
+ Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
package/dist/overlay.js CHANGED
@@ -1,10 +1,10 @@
1
- 'use strict';var c=class{config;generatedStyles=new Set;styleElement=null;constructor(e){e?this.config=e:this.config=window.__FIREBUZZ_TAILWIND_CONFIG__||{},this.initStyleElement(),console.log("[Tailwind Generator] Initialized with config:",{colors:Object.keys(this.config.theme?.colors||{}).length,spacing:Object.keys(this.config.theme?.spacing||{}).length});}initStyleElement(){let e=document.getElementById("fb-runtime-tailwind");if(e){console.warn("[Tailwind Generator] Style element already exists, reusing it"),this.styleElement=e;return}this.styleElement=document.createElement("style"),this.styleElement.id="fb-runtime-tailwind",this.styleElement.setAttribute("data-source","firebuzz-design-mode"),document.head.appendChild(this.styleElement),console.log("[Tailwind Generator] Created <style> element in <head>");}classExistsInStylesheet(e){try{let n=document.createElement("div");n.className=e,n.style.cssText="position:absolute;top:-9999px;left:-9999px;visibility:hidden;",document.body.appendChild(n);let t=window.getComputedStyle(n),i=!1;if(e.startsWith("bg-")&&t.backgroundColor!=="rgba(0, 0, 0, 0)")i=!0;else if(e.startsWith("text-")&&!e.match(/^text-(xs|sm|base|lg|xl|2xl|3xl|4xl|5xl|6xl|7xl|8xl|9xl)$/)){let r=window.getComputedStyle(document.body).color;t.color!==r&&t.color!=="rgb(0, 0, 0)"&&(i=!0);}else if(e.match(/^text-(xs|sm|base|lg|xl|2xl|3xl|4xl|5xl|6xl|7xl|8xl|9xl)$/)){let r=window.getComputedStyle(document.body).fontSize;t.fontSize!==r&&(i=!0);}else if(e.match(/^[pm][trblxy]?-/)){let r=e[0]==="p"?"padding":"margin",s=e[1]==="-"?"Top":e[1].toUpperCase(),o=`${r}${s==="-"?"Top":s}`;t[o]&&t[o]!=="0px"&&(i=!0);}else if(e.startsWith("gap-"))(t.gap!=="normal"&&t.gap!=="0px"||t.columnGap!=="normal"&&t.columnGap!=="0px"||t.rowGap!=="normal"&&t.rowGap!=="0px")&&(i=!0);else if(e.startsWith("space-"))i=!1;else if(e.match(/^[wh]-/)){let r=e[0]==="w"?"width":"height";t[r]!=="auto"&&t[r]!=="0px"&&(i=!0);}else if(["flex","inline-flex","grid","inline-grid","block","inline-block","hidden"].includes(e)){let r=e==="hidden"?"none":e.replace("inline-","inline-").replace("-","");(t.display===r||e==="flex"&&t.display==="flex"||e==="grid"&&t.display==="grid"||e==="block"&&t.display==="block")&&(i=!0);}else ["items-center","items-start","items-end","justify-center","justify-between","justify-around","flex-col","flex-row"].includes(e)&&(e.startsWith("items-")&&t.alignItems!=="normal"||e.startsWith("justify-")&&t.justifyContent!=="normal"||e.startsWith("flex-")&&t.flexDirection!=="row")&&(i=!0);return document.body.removeChild(n),i}catch{return false}}generateClasses(e){let n=e.split(/\s+/).filter(Boolean);for(let t of n){if(this.generatedStyles.has(t))continue;if(this.classExistsInStylesheet(t)){console.log(`[Tailwind Generator] Skipping ${t} - already in stylesheet`);continue}let i=this.generateCSSForClass(t);i&&(this.appendCSS(i),this.generatedStyles.add(t),console.log(`[Tailwind Generator] Generated CSS for new class: ${t}`));}}generateCSSForClass(e){let n=e.match(/^(sm|md|lg|xl|2xl):(.+)$/);if(n){let[,r,s]=n,o=this.generateBaseCSS(s);if(!o)return null;let l=(this.config.theme?.screens||{})[r];return l?`@media (min-width: ${l}) { ${o} }`:null}let t=e.match(/^(hover|focus|active|disabled|focus-visible|focus-within|visited):(.+)$/);if(t){let[,r,s]=t,o=this.generateBaseCSS(s);return o?o.replace(/\.([^\s{]+)/,`.${e.replace(/:/g,"\\:")}:${r}`):null}let i=e.match(/^dark:(.+)$/);if(i){let[,r]=i,s=this.generateBaseCSS(r);return s?`.dark ${s}`:null}return this.generateBaseCSS(e)}generateBaseCSS(e){if(e.startsWith("bg-"))return this.generateColorCSS(e,"background-color");if(e.startsWith("text-"))return e.match(/^text-(xs|sm|base|lg|xl|2xl|3xl|4xl|5xl|6xl|7xl|8xl|9xl)$/)?this.generateFontSizeCSS(e):this.generateColorCSS(e,"color");if(e.startsWith("border-")){if(e.match(/^border-(\d+|t|r|b|l|x|y)$/))return this.generateBorderWidthCSS(e);if(["border-solid","border-dashed","border-dotted","border-double","border-none"].includes(e)){let n=e.replace("border-","");return `.${e} { border-style: ${n} }`}return this.generateColorCSS(e,"border-color")}return e.match(/^p[trblxy]?-/)?this.generateSpacingCSS(e,"padding"):e.match(/^m[trblxy]?-/)?this.generateSpacingCSS(e,"margin"):e.startsWith("w-")?this.generateSizeCSS(e,"width"):e.startsWith("h-")?this.generateSizeCSS(e,"height"):e.startsWith("font-")?this.generateFontWeightCSS(e):e.startsWith("rounded")?this.generateBorderRadiusCSS(e):["flex","inline-flex","grid","inline-grid","block","inline-block","hidden"].includes(e)?`.${e} { display: ${e.replace("inline-","inline ").replace("-"," ")} }`:e.startsWith("gap-")?this.generateGapCSS(e):e.startsWith("space-")?this.generateSpaceBetweenCSS(e):e==="flex-row"?".flex-row { flex-direction: row }":e==="flex-row-reverse"?".flex-row-reverse { flex-direction: row-reverse }":e==="flex-col"?".flex-col { flex-direction: column }":e==="flex-col-reverse"?".flex-col-reverse { flex-direction: column-reverse }":e==="justify-start"?".justify-start { justify-content: flex-start }":e==="justify-center"?".justify-center { justify-content: center }":e==="justify-end"?".justify-end { justify-content: flex-end }":e==="justify-between"?".justify-between { justify-content: space-between }":e==="justify-around"?".justify-around { justify-content: space-around }":e==="justify-evenly"?".justify-evenly { justify-content: space-evenly }":e==="items-start"?".items-start { align-items: flex-start }":e==="items-center"?".items-center { align-items: center }":e==="items-end"?".items-end { align-items: flex-end }":e==="items-baseline"?".items-baseline { align-items: baseline }":e==="items-stretch"?".items-stretch { align-items: stretch }":e==="text-left"?".text-left { text-align: left }":e==="text-center"?".text-center { text-align: center }":e==="text-right"?".text-right { text-align: right }":e==="text-justify"?".text-justify { text-align: justify }":e==="underline"?".underline { text-decoration-line: underline }":e==="overline"?".overline { text-decoration-line: overline }":e==="line-through"?".line-through { text-decoration-line: line-through }":e==="no-underline"?".no-underline { text-decoration-line: none }":e==="italic"?".italic { font-style: italic }":e==="not-italic"?".not-italic { font-style: normal }":e.startsWith("leading-")?this.generateLineHeightCSS(e):e.startsWith("tracking-")?this.generateLetterSpacingCSS(e):e.startsWith("grid-cols-")?this.generateGridColumnsCSS(e):e.startsWith("grid-rows-")?this.generateGridRowsCSS(e):e.startsWith("opacity-")?this.generateOpacityCSS(e):e.startsWith("shadow")?this.generateShadowCSS(e):(console.warn(`[Tailwind Generator] Cannot generate CSS for class: ${e}`),null)}generateColorCSS(e,n){let t=this.config.theme?.colors||{},i=n==="background-color"?"bg-":n==="color"?"text-":"border-",s=e.slice(i.length).split("-");if(s.length===1){let o=t[s[0]];if(typeof o=="string")return `.${e} { ${n}: ${o} }`}else if(s.length===2){let[o,a]=s,l=t[o]?.[a];if(l)return `.${e} { ${n}: ${l} }`}return null}generateSpacingCSS(e,n){let t=this.config.theme?.spacing||{},i=n==="padding"?"p":"m",r=e.match(new RegExp(`^${i}([trblxy])?-(.+)$`));if(!r)return null;let[,s,o]=r,a=t[o];if(!a)return null;let l=[];if(!s)l.push(`${n}: ${a}`);else if(s==="x")l.push(`${n}-left: ${a}`,`${n}-right: ${a}`);else if(s==="y")l.push(`${n}-top: ${a}`,`${n}-bottom: ${a}`);else {let d={t:"top",r:"right",b:"bottom",l:"left"};l.push(`${n}-${d[s]}: ${a}`);}return `.${e} { ${l.join("; ")} }`}generateSizeCSS(e,n){let t=this.config.theme?.spacing||{},i=n==="width"?"w-":"h-",r=e.slice(i.length);if(r==="full")return `.${e} { ${n}: 100% }`;if(r==="screen")return `.${e} { ${n}: 100v${n[0]} }`;if(r==="auto")return `.${e} { ${n}: auto }`;if(r==="min")return `.${e} { ${n}: min-content }`;if(r==="max")return `.${e} { ${n}: max-content }`;if(r==="fit")return `.${e} { ${n}: fit-content }`;let s=t[r];return s?`.${e} { ${n}: ${s} }`:null}generateFontSizeCSS(e){let n=this.config.theme?.fontSize||{},t=e.slice(5),i=n[t];if(Array.isArray(i)){let[r,{lineHeight:s}]=i;return `.${e} { font-size: ${r}; line-height: ${s} }`}return typeof i=="string"?`.${e} { font-size: ${i} }`:null}generateFontWeightCSS(e){let n=this.config.theme?.fontWeight||{},t=e.slice(5),i=n[t];return i?`.${e} { font-weight: ${i} }`:null}generateBorderRadiusCSS(e){let n=this.config.theme?.borderRadius||{};if(e==="rounded"){let r=n.DEFAULT||n[""];if(r)return `.rounded { border-radius: ${r} }`}let t=e.slice(8),i=n[t];return i?`.${e} { border-radius: ${i} }`:null}generateBorderWidthCSS(e){let n=this.config.theme?.borderWidth||{};if(e==="border")return `.border { border-width: ${n.DEFAULT||"1px"} }`;let t=e.match(/^border-([trbl])$/);if(t){let r={t:"top",r:"right",b:"bottom",l:"left"},s=n.DEFAULT||"1px";return `.${e} { border-${r[t[1]]}-width: ${s} }`}let i=e.match(/^border-(\d+)$/);if(i){let r=n[i[1]];if(r)return `.${e} { border-width: ${r} }`}return null}generateGapCSS(e){let n=this.config.theme?.spacing||{};if(e.startsWith("gap-x-")){let r=e.slice(6),s=n[r];if(s)return `.${e} { column-gap: ${s} }`}if(e.startsWith("gap-y-")){let r=e.slice(6),s=n[r];if(s)return `.${e} { row-gap: ${s} }`}let t=e.slice(4),i=n[t];return i?`.${e} { gap: ${i} }`:null}generateSpaceBetweenCSS(e){let n=this.config.theme?.spacing||{};if(e.startsWith("space-x-")){let t=e.slice(8),i=n[t];if(i)return `.${e} > :not([hidden]) ~ :not([hidden]) { --tw-space-x-reverse: 0; margin-right: calc(${i} * var(--tw-space-x-reverse)); margin-left: calc(${i} * calc(1 - var(--tw-space-x-reverse))) }`}if(e.startsWith("space-y-")){let t=e.slice(8),i=n[t];if(i)return `.${e} > :not([hidden]) ~ :not([hidden]) { --tw-space-y-reverse: 0; margin-top: calc(${i} * calc(1 - var(--tw-space-y-reverse))); margin-bottom: calc(${i} * var(--tw-space-y-reverse)) }`}return e==="space-x-reverse"?`.${e} > :not([hidden]) ~ :not([hidden]) { --tw-space-x-reverse: 1 }`:e==="space-y-reverse"?`.${e} > :not([hidden]) ~ :not([hidden]) { --tw-space-y-reverse: 1 }`:null}generateLineHeightCSS(e){let n=this.config.theme?.lineHeight||{},t=e.slice(8),i=n[t];return i?`.${e} { line-height: ${i} }`:null}generateLetterSpacingCSS(e){let n=this.config.theme?.letterSpacing||{},t=e.slice(9),i=n[t];return i?`.${e} { letter-spacing: ${i} }`:null}generateGridColumnsCSS(e){let n=e.slice(10);if(n==="none")return `.${e} { grid-template-columns: none }`;if(n==="subgrid")return `.${e} { grid-template-columns: subgrid }`;let t=Number.parseInt(n,10);return !Number.isNaN(t)&&t>=1&&t<=12?`.${e} { grid-template-columns: repeat(${t}, minmax(0, 1fr)) }`:null}generateGridRowsCSS(e){let n=e.slice(10);if(n==="none")return `.${e} { grid-template-rows: none }`;if(n==="subgrid")return `.${e} { grid-template-rows: subgrid }`;let t=Number.parseInt(n,10);return !Number.isNaN(t)&&t>=1&&t<=6?`.${e} { grid-template-rows: repeat(${t}, minmax(0, 1fr)) }`:null}generateOpacityCSS(e){let n=e.slice(8),t=Number.parseInt(n,10);return !Number.isNaN(t)&&t>=0&&t<=100?`.${e} { opacity: ${t/100} }`:null}generateShadowCSS(e){let n=this.config.theme?.boxShadow||{};if(e==="shadow"){let r=n.DEFAULT||n[""];if(r)return `.shadow { box-shadow: ${r} }`}let t=e.slice(7),i=n[t];return i?`.${e} { box-shadow: ${i} }`:null}appendCSS(e){this.styleElement&&(this.styleElement.textContent+=`
2
- ${e}`);}clear(){this.generatedStyles.clear(),this.styleElement&&(this.styleElement.textContent="");}},u=null;function g(){return u||(u=new c),u}var h=class{isEnabled=false;selectedElement=null;hoveredElement=null;hoverOverlay;selectionOverlay;selectionTagLabel;childrenOverlays=[];resizeObserver=null;constructor(){this.hoverOverlay=this.createOverlay("2px solid #3b82f6",999991),this.selectionOverlay=this.createOverlay("1px solid #3b82f6",999990),this.selectionTagLabel=this.createTagLabel(),this.listen(),this.setupResizeObserver();}createOverlay(e,n){let t=document.createElement("div");return t.className="fb-design-mode-overlay",Object.assign(t.style,{position:"absolute",border:e,pointerEvents:"none",zIndex:String(n),display:"none",boxShadow:"0 0 0 1px rgba(59, 130, 246, 0.2)",transition:"all 0.1s ease-out"}),document.body.appendChild(t),t}createChildOverlay(){let e=document.createElement("div");return e.className="fb-design-mode-overlay fb-child-overlay",Object.assign(e.style,{position:"absolute",border:"1px dashed rgba(59, 130, 246, 0.4)",pointerEvents:"none",zIndex:"999989",display:"none",boxShadow:"0 0 0 1px rgba(59, 130, 246, 0.1)",transition:"all 0.1s ease-out"}),document.body.appendChild(e),e}createTagLabel(){let e=document.createElement("div");return e.className="fb-design-mode-tag",Object.assign(e.style,{position:"absolute",background:"#3b82f6",color:"white",padding:"2px 6px",fontSize:"11px",fontFamily:"monospace",fontWeight:"500",borderRadius:"0 0 4px 0",pointerEvents:"none",zIndex:"999999",display:"none"}),document.body.appendChild(e),e}listen(){window.addEventListener("message",e=>{e.data.type==="ENABLE_DESIGN_MODE"?this.enable():e.data.type==="DISABLE_DESIGN_MODE"?this.disable():e.data.type==="FB_UPDATE_ELEMENT"?this.handleUpdateElement(e.data):e.data.type==="FB_GET_ALL_ELEMENTS_STATE"?this.handleGetAllElementsState():e.data.type==="FB_UPDATE_THEME"?this.handleUpdateTheme(e.data.theme):e.data.type==="FB_DESELECT_ELEMENT"?this.deselectElement():e.data.type==="FB_SELECT_ELEMENT"&&this.handleSelectElement(e.data);});}setupResizeObserver(){window.addEventListener("resize",this.updateOverlayPositions),window.addEventListener("scroll",this.updateOverlayPositions,true),this.resizeObserver=new ResizeObserver(()=>{this.updateOverlayPositions();}),this.resizeObserver.observe(document.body);}updateOverlayPositions=()=>{this.selectedElement&&this.selectionOverlay.style.display!=="none"&&(this.updateOverlayPosition(this.selectionOverlay,this.selectedElement),this.updateTagLabel(this.selectedElement)),this.hoveredElement&&this.hoverOverlay.style.display!=="none"&&this.updateOverlayPosition(this.hoverOverlay,this.hoveredElement);for(let e of this.childrenOverlays)if(e.style.display!=="none"&&this.hoveredElement){let n=Array.from(this.hoveredElement.children).filter(r=>this.getReactFiberSource(r)!==null),t=this.childrenOverlays.indexOf(e),i=n[t];i&&this.updateOverlayPosition(e,i);}};enable(){this.isEnabled||(this.isEnabled=true,document.addEventListener("mousemove",this.handleMouseMove),document.addEventListener("click",this.handleClick,true),document.addEventListener("mouseleave",this.handleMouseLeave),document.body.style.cursor="crosshair");}disable(){this.isEnabled&&(this.isEnabled=false,document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("click",this.handleClick,true),document.removeEventListener("mouseleave",this.handleMouseLeave),this.hoverOverlay.style.display="none",this.selectionOverlay.style.display="none",this.selectionTagLabel.style.display="none",this.hideChildrenOverlays(),this.selectedElement&&this.selectedElement.removeAttribute("data-fb-selected"),this.hoveredElement&&this.hoveredElement.removeAttribute("data-fb-hovered"),document.body.style.cursor="",this.selectedElement=null,this.hoveredElement=null);}deselectElement(){this.selectedElement&&(this.selectedElement.removeAttribute("data-fb-selected"),this.selectedElement=null,this.selectionOverlay.style.display="none",this.selectionTagLabel.style.display="none");}handleSelectElement(e){if(!e.sourceFile||!e.sourceLine||e.sourceColumn===void 0)return;let n=document.querySelectorAll("*");for(let t of n){if(t.classList?.contains("fb-design-mode-overlay")||t.classList?.contains("fb-design-mode-tag"))continue;let i=this.getReactFiberSource(t);if(i&&i.fileName===e.sourceFile&&i.lineNumber===e.sourceLine&&i.columnNumber===e.sourceColumn){let r=t;this.selectedElement&&this.selectedElement.removeAttribute("data-fb-selected"),this.selectedElement=r,this.selectedElement.setAttribute("data-fb-selected","true"),this.updateOverlayPosition(this.selectionOverlay,r),this.selectionOverlay.style.display="block",this.updateTagLabel(r),this.selectionTagLabel.style.display="block",this.sendElementData(r,i);return}}}getReactFiberSource(e){let n=e,t=Object.keys(n).find(s=>s.startsWith("__reactFiber$")||s.startsWith("__reactInternalInstance$"));if(!t)return null;let i=n[t],r=null;for(;i;){if(i._debugSource){let s={fileName:i._debugSource.fileName,lineNumber:i._debugSource.lineNumber,columnNumber:i._debugSource.columnNumber??0};if(r||(r=s),s.fileName.includes("/components/ui/")||s.fileName.includes("/components/common/")){i=i.return;continue}return s}i=i.return;}return r}isContainer(e){return ["div","section","header","footer","main","aside","nav","article","ul","ol","li"].includes(e.tagName.toLowerCase())}hasDirectTextContent(e){return Array.from(e.childNodes).some(n=>n.nodeType===Node.TEXT_NODE&&n.textContent?.trim())}handleMouseLeave=()=>{this.isEnabled&&(this.hoveredElement&&this.hoveredElement.removeAttribute("data-fb-hovered"),this.hoveredElement=null,this.hoverOverlay.style.display="none",this.hideChildrenOverlays());};handleMouseMove=e=>{if(!this.isEnabled)return;let t=document.elementsFromPoint(e.clientX,e.clientY).filter(r=>r.classList.contains("fb-design-mode-overlay")||r.classList.contains("fb-design-mode-tag")?false:this.getReactFiberSource(r)!==null);if(t.length===0){this.hoveredElement&&this.hoveredElement.removeAttribute("data-fb-hovered"),this.hoveredElement=null,this.hoverOverlay.style.display="none",this.hideChildrenOverlays();return}let i=t[0];if(i){if(i===this.selectedElement){this.hoverOverlay.style.display="none",this.hideChildrenOverlays();return}this.hoveredElement&&this.hoveredElement!==i&&this.hoveredElement.removeAttribute("data-fb-hovered"),this.hoveredElement=i,this.hoveredElement.setAttribute("data-fb-hovered","true"),this.updateOverlayPosition(this.hoverOverlay,i),this.hoverOverlay.style.display="block",this.isContainer(i)&&!this.hasDirectTextContent(i)?this.showChildrenOverlays(i):this.hideChildrenOverlays();}};showChildrenOverlays(e){let n=Array.from(e.children).filter(t=>this.getReactFiberSource(t)!==null);for(;this.childrenOverlays.length<n.length;)this.childrenOverlays.push(this.createChildOverlay());n.forEach((t,i)=>{let r=this.childrenOverlays[i];r&&(this.updateOverlayPosition(r,t),r.style.display="block");});for(let t=n.length;t<this.childrenOverlays.length;t++){let i=this.childrenOverlays[t];i&&(i.style.display="none");}}hideChildrenOverlays(){for(let e of this.childrenOverlays)e.style.display="none";}currentSelectionIndex=0;lastClickTime=0;lastClickPosition={x:0,y:0};handleClick=e=>{if(!this.isEnabled||(e.preventDefault(),e.stopPropagation(),!this.hoveredElement))return;let n=Date.now(),t=n-this.lastClickTime,i=Math.hypot(e.clientX-this.lastClickPosition.x,e.clientY-this.lastClickPosition.y),s=document.elementsFromPoint(e.clientX,e.clientY).filter(l=>l.classList.contains("fb-design-mode-overlay")||l.classList.contains("fb-design-mode-tag")?false:this.getReactFiberSource(l)!==null);t<1e3&&i<10&&s.length>1?this.currentSelectionIndex=(this.currentSelectionIndex+1)%s.length:this.currentSelectionIndex=0;let o=s[this.currentSelectionIndex];if(!o)return;let a=this.getReactFiberSource(o);a&&(this.selectedElement&&this.selectedElement.removeAttribute("data-fb-selected"),this.selectedElement=o,this.selectedElement.setAttribute("data-fb-selected","true"),this.updateOverlayPosition(this.selectionOverlay,o),this.selectionOverlay.style.display="block",this.updateTagLabel(o),this.selectionTagLabel.style.display="block",this.sendElementData(o,a),this.lastClickTime=n,this.lastClickPosition={x:e.clientX,y:e.clientY});};updateOverlayPosition(e,n){let t=n.getBoundingClientRect();Object.assign(e.style,{top:`${t.top+window.scrollY}px`,left:`${t.left+window.scrollX}px`,width:`${t.width}px`,height:`${t.height}px`});}updateTagLabel(e){let n=e.getBoundingClientRect(),t=e.tagName.toLowerCase();this.selectionTagLabel.textContent=t,Object.assign(this.selectionTagLabel.style,{top:`${n.top+window.scrollY}px`,left:`${n.left+window.scrollX}px`});}getRelevantStyles(e){let n=window.getComputedStyle(e),t=["display","position","width","height","padding","margin","backgroundColor","color","fontSize","fontFamily"],i={};for(let r of t)i[r]=n.getPropertyValue(r);return i}getDirectTextContent(e){let n=Array.from(e.childNodes).filter(t=>t.nodeType===Node.TEXT_NODE).map(t=>t.textContent?.trim()).filter(Boolean);return n.length>0?n.join(" "):null}sendElementData(e,n){let t=this.getDirectTextContent(e),i={type:"FB_ELEMENT_SELECTED",data:{sourceFile:n.fileName,sourceLine:n.lineNumber,sourceColumn:n.columnNumber,tagName:e.tagName,className:e.className,textContent:t,src:e.getAttribute("src")||void 0,alt:e.getAttribute("alt")||void 0,href:e.getAttribute("href")||void 0,target:e.getAttribute("target")||void 0,rel:e.getAttribute("rel")||void 0,computedStyles:this.getRelevantStyles(e)}};window.parent.postMessage(i,"*");}handleGetAllElementsState(){let e=document.querySelectorAll("*"),n=[];for(let t of e){if(t.classList?.contains("fb-design-mode-overlay")||t.classList?.contains("fb-design-mode-tag"))continue;let i=this.getReactFiberSource(t);if(!i)continue;let r=t,s=r;if(r.tagName!=="IMG"){let l=r.querySelector("img");l&&(s=l);}let o=this.getDirectTextContent(r),a="";r.className&&(typeof r.className=="string"?a=r.className:"baseVal"in r.className&&(a=r.className.baseVal)),n.push({sourceFile:i.fileName,sourceLine:i.lineNumber,sourceColumn:i.columnNumber,className:a,textContent:o,src:s.getAttribute("src")||void 0,alt:s.getAttribute("alt")||void 0,href:r.getAttribute("href")||void 0,target:r.getAttribute("target")||void 0,rel:r.getAttribute("rel")||void 0});}window.parent.postMessage({type:"FB_ALL_ELEMENTS_STATE",data:n},"*");}handleUpdateElement(e){let{sourceFile:n,sourceLine:t,sourceColumn:i,updates:r}=e;if(!n||!t||!r)return;let s=document.querySelectorAll("*");for(let o of s){let a=this.getReactFiberSource(o);if(a?.fileName===n&&a?.lineNumber===t&&a?.columnNumber===i){let l=o;if((r.src!==void 0||r.alt!==void 0)&&l.tagName!=="IMG"){let d=l.querySelector("img");d&&(l=d);}if(r.className!==void 0&&(g().generateClasses(r.className),l.className=r.className),r.textContent!==void 0){let d=Array.from(l.childNodes).find(p=>p.nodeType===Node.TEXT_NODE);d?d.textContent=r.textContent:l.textContent=r.textContent;}r.src!==void 0&&"src"in l&&(l.setAttribute("src",r.src),l.hasAttribute("srcset")&&l.removeAttribute("srcset")),r.alt!==void 0&&"alt"in l&&(l.alt=r.alt),r.href!==void 0&&"href"in l&&l.setAttribute("href",r.href),r.target!==void 0&&"target"in l&&l.setAttribute("target",r.target),r.rel!==void 0&&"rel"in l&&l.setAttribute("rel",r.rel),l===this.hoveredElement&&this.updateOverlayPosition(this.hoverOverlay,l),l===this.selectedElement&&(this.updateOverlayPosition(this.selectionOverlay,l),this.updateTagLabel(l));return}}}handleUpdateTheme(e){if(!e)return;let n=document.getElementById("fb-design-mode-theme");n||(n=document.createElement("style"),n.id="fb-design-mode-theme",document.head.appendChild(n));let t="";if(e.lightVariables&&Object.keys(e.lightVariables).length>0){t+=`:root {
1
+ 'use strict';var h=class{config;generatedStyles=new Set;styleElement=null;constructor(e){e?this.config=e:this.config=window.__FIREBUZZ_TAILWIND_CONFIG__||{},this.initStyleElement(),console.log("[Tailwind Generator] Initialized with config:",{colors:Object.keys(this.config.theme?.colors||{}).length,spacing:Object.keys(this.config.theme?.spacing||{}).length});}initStyleElement(){let e=document.getElementById("fb-runtime-tailwind");if(e){console.warn("[Tailwind Generator] Style element already exists, reusing it"),this.styleElement=e;return}this.styleElement=document.createElement("style"),this.styleElement.id="fb-runtime-tailwind",this.styleElement.setAttribute("data-source","firebuzz-design-mode"),document.head.appendChild(this.styleElement),console.log("[Tailwind Generator] Created <style> element in <head>");}classExistsInStylesheet(e){try{let n=document.createElement("div");n.className=e,n.style.cssText="position:absolute;top:-9999px;left:-9999px;visibility:hidden;",document.body.appendChild(n);let t=window.getComputedStyle(n),i=!1;if(e.startsWith("bg-")&&t.backgroundColor!=="rgba(0, 0, 0, 0)")i=!0;else if(e.startsWith("text-")&&!e.match(/^text-(xs|sm|base|lg|xl|2xl|3xl|4xl|5xl|6xl|7xl|8xl|9xl)$/)){let r=window.getComputedStyle(document.body).color;t.color!==r&&t.color!=="rgb(0, 0, 0)"&&(i=!0);}else if(e.match(/^text-(xs|sm|base|lg|xl|2xl|3xl|4xl|5xl|6xl|7xl|8xl|9xl)$/)){let r=window.getComputedStyle(document.body).fontSize;t.fontSize!==r&&(i=!0);}else if(e.match(/^[pm][trblxy]?-/)){let r=e[0]==="p"?"padding":"margin",s=e[1]==="-"?"Top":e[1].toUpperCase(),o=`${r}${s==="-"?"Top":s}`;t[o]&&t[o]!=="0px"&&(i=!0);}else if(e.startsWith("gap-"))(t.gap!=="normal"&&t.gap!=="0px"||t.columnGap!=="normal"&&t.columnGap!=="0px"||t.rowGap!=="normal"&&t.rowGap!=="0px")&&(i=!0);else if(e.startsWith("space-"))i=!1;else if(e.match(/^[wh]-/)){let r=e[0]==="w"?"width":"height";t[r]!=="auto"&&t[r]!=="0px"&&(i=!0);}else if(["flex","inline-flex","grid","inline-grid","block","inline-block","hidden"].includes(e)){let r=e==="hidden"?"none":e.replace("inline-","inline-").replace("-","");(t.display===r||e==="flex"&&t.display==="flex"||e==="grid"&&t.display==="grid"||e==="block"&&t.display==="block")&&(i=!0);}else ["items-center","items-start","items-end","justify-center","justify-between","justify-around","flex-col","flex-row"].includes(e)&&(e.startsWith("items-")&&t.alignItems!=="normal"||e.startsWith("justify-")&&t.justifyContent!=="normal"||e.startsWith("flex-")&&t.flexDirection!=="row")&&(i=!0);return document.body.removeChild(n),i}catch{return false}}generateClasses(e){let n=e.split(/\s+/).filter(Boolean);for(let t of n){if(this.generatedStyles.has(t))continue;if(this.classExistsInStylesheet(t)){console.log(`[Tailwind Generator] Skipping ${t} - already in stylesheet`);continue}let i=this.generateCSSForClass(t);i&&(this.appendCSS(i),this.generatedStyles.add(t),console.log(`[Tailwind Generator] Generated CSS for new class: ${t}`));}}generateCSSForClass(e){let n=e.match(/^(sm|md|lg|xl|2xl):(.+)$/);if(n){let[,r,s]=n,o=this.generateBaseCSS(s);if(!o)return null;let l=(this.config.theme?.screens||{})[r];return l?`@media (min-width: ${l}) { ${o} }`:null}let t=e.match(/^(hover|focus|active|disabled|focus-visible|focus-within|visited):(.+)$/);if(t){let[,r,s]=t,o=this.generateBaseCSS(s);return o?o.replace(/\.([^\s{]+)/,`.${e.replace(/:/g,"\\:")}:${r}`):null}let i=e.match(/^dark:(.+)$/);if(i){let[,r]=i,s=this.generateBaseCSS(r);return s?`.dark ${s}`:null}return this.generateBaseCSS(e)}generateBaseCSS(e){if(e.startsWith("bg-"))return this.generateColorCSS(e,"background-color");if(e.startsWith("text-"))return e.match(/^text-(xs|sm|base|lg|xl|2xl|3xl|4xl|5xl|6xl|7xl|8xl|9xl)$/)?this.generateFontSizeCSS(e):this.generateColorCSS(e,"color");if(e.startsWith("border-")){if(e.match(/^border-(\d+|t|r|b|l|x|y)$/))return this.generateBorderWidthCSS(e);if(["border-solid","border-dashed","border-dotted","border-double","border-none"].includes(e)){let n=e.replace("border-","");return `.${e} { border-style: ${n} }`}return this.generateColorCSS(e,"border-color")}return e.match(/^p[trblxy]?-/)?this.generateSpacingCSS(e,"padding"):e.match(/^m[trblxy]?-/)?this.generateSpacingCSS(e,"margin"):e.startsWith("w-")?this.generateSizeCSS(e,"width"):e.startsWith("h-")?this.generateSizeCSS(e,"height"):e.startsWith("font-")?this.generateFontWeightCSS(e):e.startsWith("rounded")?this.generateBorderRadiusCSS(e):["flex","inline-flex","grid","inline-grid","block","inline-block","hidden"].includes(e)?`.${e} { display: ${e.replace("inline-","inline ").replace("-"," ")} }`:e.startsWith("gap-")?this.generateGapCSS(e):e.startsWith("space-")?this.generateSpaceBetweenCSS(e):e==="flex-row"?".flex-row { flex-direction: row }":e==="flex-row-reverse"?".flex-row-reverse { flex-direction: row-reverse }":e==="flex-col"?".flex-col { flex-direction: column }":e==="flex-col-reverse"?".flex-col-reverse { flex-direction: column-reverse }":e==="justify-start"?".justify-start { justify-content: flex-start }":e==="justify-center"?".justify-center { justify-content: center }":e==="justify-end"?".justify-end { justify-content: flex-end }":e==="justify-between"?".justify-between { justify-content: space-between }":e==="justify-around"?".justify-around { justify-content: space-around }":e==="justify-evenly"?".justify-evenly { justify-content: space-evenly }":e==="items-start"?".items-start { align-items: flex-start }":e==="items-center"?".items-center { align-items: center }":e==="items-end"?".items-end { align-items: flex-end }":e==="items-baseline"?".items-baseline { align-items: baseline }":e==="items-stretch"?".items-stretch { align-items: stretch }":e==="text-left"?".text-left { text-align: left }":e==="text-center"?".text-center { text-align: center }":e==="text-right"?".text-right { text-align: right }":e==="text-justify"?".text-justify { text-align: justify }":e==="underline"?".underline { text-decoration-line: underline }":e==="overline"?".overline { text-decoration-line: overline }":e==="line-through"?".line-through { text-decoration-line: line-through }":e==="no-underline"?".no-underline { text-decoration-line: none }":e==="italic"?".italic { font-style: italic }":e==="not-italic"?".not-italic { font-style: normal }":e.startsWith("leading-")?this.generateLineHeightCSS(e):e.startsWith("tracking-")?this.generateLetterSpacingCSS(e):e.startsWith("grid-cols-")?this.generateGridColumnsCSS(e):e.startsWith("grid-rows-")?this.generateGridRowsCSS(e):e.startsWith("opacity-")?this.generateOpacityCSS(e):e.startsWith("shadow")?this.generateShadowCSS(e):(console.warn(`[Tailwind Generator] Cannot generate CSS for class: ${e}`),null)}generateColorCSS(e,n){let t=this.config.theme?.colors||{},i=n==="background-color"?"bg-":n==="color"?"text-":"border-",s=e.slice(i.length).split("-");if(s.length===1){let o=t[s[0]];if(typeof o=="string")return `.${e} { ${n}: ${o} }`}else if(s.length===2){let[o,a]=s,l=t[o]?.[a];if(l)return `.${e} { ${n}: ${l} }`}return null}generateSpacingCSS(e,n){let t=this.config.theme?.spacing||{},i=n==="padding"?"p":"m",r=e.match(new RegExp(`^${i}([trblxy])?-(.+)$`));if(!r)return null;let[,s,o]=r,a=t[o];if(!a)return null;let l=[];if(!s)l.push(`${n}: ${a}`);else if(s==="x")l.push(`${n}-left: ${a}`,`${n}-right: ${a}`);else if(s==="y")l.push(`${n}-top: ${a}`,`${n}-bottom: ${a}`);else {let d={t:"top",r:"right",b:"bottom",l:"left"};l.push(`${n}-${d[s]}: ${a}`);}return `.${e} { ${l.join("; ")} }`}generateSizeCSS(e,n){let t=this.config.theme?.spacing||{},i=n==="width"?"w-":"h-",r=e.slice(i.length);if(r==="full")return `.${e} { ${n}: 100% }`;if(r==="screen")return `.${e} { ${n}: 100v${n[0]} }`;if(r==="auto")return `.${e} { ${n}: auto }`;if(r==="min")return `.${e} { ${n}: min-content }`;if(r==="max")return `.${e} { ${n}: max-content }`;if(r==="fit")return `.${e} { ${n}: fit-content }`;let s=t[r];return s?`.${e} { ${n}: ${s} }`:null}generateFontSizeCSS(e){let n=this.config.theme?.fontSize||{},t=e.slice(5),i=n[t];if(Array.isArray(i)){let[r,{lineHeight:s}]=i;return `.${e} { font-size: ${r}; line-height: ${s} }`}return typeof i=="string"?`.${e} { font-size: ${i} }`:null}generateFontWeightCSS(e){let n=this.config.theme?.fontWeight||{},t=e.slice(5),i=n[t];return i?`.${e} { font-weight: ${i} }`:null}generateBorderRadiusCSS(e){let n=this.config.theme?.borderRadius||{};if(e==="rounded"){let r=n.DEFAULT||n[""];if(r)return `.rounded { border-radius: ${r} }`}let t=e.slice(8),i=n[t];return i?`.${e} { border-radius: ${i} }`:null}generateBorderWidthCSS(e){let n=this.config.theme?.borderWidth||{};if(e==="border")return `.border { border-width: ${n.DEFAULT||"1px"} }`;let t=e.match(/^border-([trbl])$/);if(t){let r={t:"top",r:"right",b:"bottom",l:"left"},s=n.DEFAULT||"1px";return `.${e} { border-${r[t[1]]}-width: ${s} }`}let i=e.match(/^border-(\d+)$/);if(i){let r=n[i[1]];if(r)return `.${e} { border-width: ${r} }`}return null}generateGapCSS(e){let n=this.config.theme?.spacing||{};if(e.startsWith("gap-x-")){let r=e.slice(6),s=n[r];if(s)return `.${e} { column-gap: ${s} }`}if(e.startsWith("gap-y-")){let r=e.slice(6),s=n[r];if(s)return `.${e} { row-gap: ${s} }`}let t=e.slice(4),i=n[t];return i?`.${e} { gap: ${i} }`:null}generateSpaceBetweenCSS(e){let n=this.config.theme?.spacing||{};if(e.startsWith("space-x-")){let t=e.slice(8),i=n[t];if(i)return `.${e} > :not([hidden]) ~ :not([hidden]) { --tw-space-x-reverse: 0; margin-right: calc(${i} * var(--tw-space-x-reverse)); margin-left: calc(${i} * calc(1 - var(--tw-space-x-reverse))) }`}if(e.startsWith("space-y-")){let t=e.slice(8),i=n[t];if(i)return `.${e} > :not([hidden]) ~ :not([hidden]) { --tw-space-y-reverse: 0; margin-top: calc(${i} * calc(1 - var(--tw-space-y-reverse))); margin-bottom: calc(${i} * var(--tw-space-y-reverse)) }`}return e==="space-x-reverse"?`.${e} > :not([hidden]) ~ :not([hidden]) { --tw-space-x-reverse: 1 }`:e==="space-y-reverse"?`.${e} > :not([hidden]) ~ :not([hidden]) { --tw-space-y-reverse: 1 }`:null}generateLineHeightCSS(e){let n=this.config.theme?.lineHeight||{},t=e.slice(8),i=n[t];return i?`.${e} { line-height: ${i} }`:null}generateLetterSpacingCSS(e){let n=this.config.theme?.letterSpacing||{},t=e.slice(9),i=n[t];return i?`.${e} { letter-spacing: ${i} }`:null}generateGridColumnsCSS(e){let n=e.slice(10);if(n==="none")return `.${e} { grid-template-columns: none }`;if(n==="subgrid")return `.${e} { grid-template-columns: subgrid }`;let t=Number.parseInt(n,10);return !Number.isNaN(t)&&t>=1&&t<=12?`.${e} { grid-template-columns: repeat(${t}, minmax(0, 1fr)) }`:null}generateGridRowsCSS(e){let n=e.slice(10);if(n==="none")return `.${e} { grid-template-rows: none }`;if(n==="subgrid")return `.${e} { grid-template-rows: subgrid }`;let t=Number.parseInt(n,10);return !Number.isNaN(t)&&t>=1&&t<=6?`.${e} { grid-template-rows: repeat(${t}, minmax(0, 1fr)) }`:null}generateOpacityCSS(e){let n=e.slice(8),t=Number.parseInt(n,10);return !Number.isNaN(t)&&t>=0&&t<=100?`.${e} { opacity: ${t/100} }`:null}generateShadowCSS(e){let n=this.config.theme?.boxShadow||{};if(e==="shadow"){let r=n.DEFAULT||n[""];if(r)return `.shadow { box-shadow: ${r} }`}let t=e.slice(7),i=n[t];return i?`.${e} { box-shadow: ${i} }`:null}appendCSS(e){this.styleElement&&(this.styleElement.textContent+=`
2
+ ${e}`);}clear(){this.generatedStyles.clear(),this.styleElement&&(this.styleElement.textContent="");}},u=null;function f(){return u||(u=new h),u}var g=class{isEnabled=false;selectedElement=null;hoveredElement=null;hoverOverlay;selectionOverlay;selectionTagLabel;childrenOverlays=[];resizeObserver=null;constructor(){this.hoverOverlay=this.createOverlay("2px solid #3b82f6",999991),this.selectionOverlay=this.createOverlay("1px solid #3b82f6",999990),this.selectionTagLabel=this.createTagLabel(),this.listen(),this.setupResizeObserver();}createOverlay(e,n){let t=document.createElement("div");return t.className="fb-design-mode-overlay",Object.assign(t.style,{position:"absolute",border:e,pointerEvents:"none",zIndex:String(n),display:"none",boxShadow:"0 0 0 1px rgba(59, 130, 246, 0.2)",transition:"all 0.1s ease-out"}),document.body.appendChild(t),t}createChildOverlay(){let e=document.createElement("div");return e.className="fb-design-mode-overlay fb-child-overlay",Object.assign(e.style,{position:"absolute",border:"1px dashed rgba(59, 130, 246, 0.4)",pointerEvents:"none",zIndex:"999989",display:"none",boxShadow:"0 0 0 1px rgba(59, 130, 246, 0.1)",transition:"all 0.1s ease-out"}),document.body.appendChild(e),e}createTagLabel(){let e=document.createElement("div");return e.className="fb-design-mode-tag",Object.assign(e.style,{position:"absolute",background:"#3b82f6",color:"white",padding:"2px 6px",fontSize:"11px",fontFamily:"monospace",fontWeight:"500",borderRadius:"0 0 4px 0",pointerEvents:"none",zIndex:"999999",display:"none"}),document.body.appendChild(e),e}listen(){window.addEventListener("message",e=>{e.data.type==="ENABLE_DESIGN_MODE"?this.enable():e.data.type==="DISABLE_DESIGN_MODE"?this.disable():e.data.type==="FB_UPDATE_ELEMENT"?this.handleUpdateElement(e.data):e.data.type==="FB_GET_ALL_ELEMENTS_STATE"?this.handleGetAllElementsState():e.data.type==="FB_UPDATE_THEME"?this.handleUpdateTheme(e.data.theme):e.data.type==="FB_DESELECT_ELEMENT"?this.deselectElement():e.data.type==="FB_SELECT_ELEMENT"&&this.handleSelectElement(e.data);});}setupResizeObserver(){window.addEventListener("resize",this.updateOverlayPositions),window.addEventListener("scroll",this.updateOverlayPositions,true),this.resizeObserver=new ResizeObserver(()=>{this.updateOverlayPositions();}),this.resizeObserver.observe(document.body);}updateOverlayPositions=()=>{this.selectedElement&&this.selectionOverlay.style.display!=="none"&&(this.updateOverlayPosition(this.selectionOverlay,this.selectedElement),this.updateTagLabel(this.selectedElement)),this.hoveredElement&&this.hoverOverlay.style.display!=="none"&&this.updateOverlayPosition(this.hoverOverlay,this.hoveredElement);for(let e of this.childrenOverlays)if(e.style.display!=="none"&&this.hoveredElement){let n=Array.from(this.hoveredElement.children).filter(r=>this.getReactFiberSource(r)!==null),t=this.childrenOverlays.indexOf(e),i=n[t];i&&this.updateOverlayPosition(e,i);}};enable(){this.isEnabled||(this.isEnabled=true,document.addEventListener("mousemove",this.handleMouseMove),document.addEventListener("click",this.handleClick,true),document.addEventListener("mouseleave",this.handleMouseLeave),document.body.style.cursor="crosshair");}disable(){this.isEnabled&&(this.isEnabled=false,document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("click",this.handleClick,true),document.removeEventListener("mouseleave",this.handleMouseLeave),this.hoverOverlay.style.display="none",this.selectionOverlay.style.display="none",this.selectionTagLabel.style.display="none",this.hideChildrenOverlays(),this.selectedElement&&this.selectedElement.removeAttribute("data-fb-selected"),this.hoveredElement&&this.hoveredElement.removeAttribute("data-fb-hovered"),document.body.style.cursor="",this.selectedElement=null,this.hoveredElement=null);}deselectElement(){this.selectedElement&&(this.selectedElement.removeAttribute("data-fb-selected"),this.selectedElement=null,this.selectionOverlay.style.display="none",this.selectionTagLabel.style.display="none");}handleSelectElement(e){if(!e.sourceFile||!e.sourceLine||e.sourceColumn===void 0)return;let n=document.querySelectorAll("*");for(let t of n){if(t.classList?.contains("fb-design-mode-overlay")||t.classList?.contains("fb-design-mode-tag"))continue;let i=this.getReactFiberSource(t);if(i&&i.fileName===e.sourceFile&&i.lineNumber===e.sourceLine&&i.columnNumber===e.sourceColumn){let r=t;this.selectedElement&&this.selectedElement.removeAttribute("data-fb-selected"),this.selectedElement=r,this.selectedElement.setAttribute("data-fb-selected","true"),this.updateOverlayPosition(this.selectionOverlay,r),this.selectionOverlay.style.display="block",this.updateTagLabel(r),this.selectionTagLabel.style.display="block",this.sendElementData(r,i);return}}}getReactFiberSource(e){let n=e,t=Object.keys(n).find(s=>s.startsWith("__reactFiber$")||s.startsWith("__reactInternalInstance$"));if(!t)return null;let i=n[t],r=null;for(;i;){if(i._debugSource){let s={fileName:i._debugSource.fileName,lineNumber:i._debugSource.lineNumber,columnNumber:i._debugSource.columnNumber??0};if(r||(r=s),s.fileName.includes("/components/ui/")||s.fileName.includes("/components/common/")){i=i.return;continue}return s}i=i.return;}return r}isContainer(e){return ["div","section","header","footer","main","aside","nav","article","ul","ol","li"].includes(e.tagName.toLowerCase())}hasDirectTextContent(e){return Array.from(e.childNodes).some(n=>n.nodeType===Node.TEXT_NODE&&n.textContent?.trim())}handleMouseLeave=()=>{this.isEnabled&&(this.hoveredElement&&this.hoveredElement.removeAttribute("data-fb-hovered"),this.hoveredElement=null,this.hoverOverlay.style.display="none",this.hideChildrenOverlays());};handleMouseMove=e=>{if(!this.isEnabled)return;let t=document.elementsFromPoint(e.clientX,e.clientY).filter(r=>r.classList.contains("fb-design-mode-overlay")||r.classList.contains("fb-design-mode-tag")?false:this.getReactFiberSource(r)!==null);if(t.length===0){this.hoveredElement&&this.hoveredElement.removeAttribute("data-fb-hovered"),this.hoveredElement=null,this.hoverOverlay.style.display="none",this.hideChildrenOverlays();return}let i=t[0];if(i){if(i===this.selectedElement){this.hoverOverlay.style.display="none",this.hideChildrenOverlays();return}this.hoveredElement&&this.hoveredElement!==i&&this.hoveredElement.removeAttribute("data-fb-hovered"),this.hoveredElement=i,this.hoveredElement.setAttribute("data-fb-hovered","true"),this.updateOverlayPosition(this.hoverOverlay,i),this.hoverOverlay.style.display="block",this.isContainer(i)&&!this.hasDirectTextContent(i)?this.showChildrenOverlays(i):this.hideChildrenOverlays();}};showChildrenOverlays(e){let n=Array.from(e.children).filter(t=>this.getReactFiberSource(t)!==null);for(;this.childrenOverlays.length<n.length;)this.childrenOverlays.push(this.createChildOverlay());n.forEach((t,i)=>{let r=this.childrenOverlays[i];r&&(this.updateOverlayPosition(r,t),r.style.display="block");});for(let t=n.length;t<this.childrenOverlays.length;t++){let i=this.childrenOverlays[t];i&&(i.style.display="none");}}hideChildrenOverlays(){for(let e of this.childrenOverlays)e.style.display="none";}currentSelectionIndex=0;lastClickTime=0;lastClickPosition={x:0,y:0};handleClick=e=>{if(!this.isEnabled||(e.preventDefault(),e.stopPropagation(),!this.hoveredElement))return;let n=Date.now(),t=n-this.lastClickTime,i=Math.hypot(e.clientX-this.lastClickPosition.x,e.clientY-this.lastClickPosition.y),s=document.elementsFromPoint(e.clientX,e.clientY).filter(l=>l.classList.contains("fb-design-mode-overlay")||l.classList.contains("fb-design-mode-tag")?false:this.getReactFiberSource(l)!==null);t<1e3&&i<10&&s.length>1?this.currentSelectionIndex=(this.currentSelectionIndex+1)%s.length:this.currentSelectionIndex=0;let o=s[this.currentSelectionIndex];if(!o)return;let a=this.getReactFiberSource(o);a&&(this.selectedElement&&this.selectedElement.removeAttribute("data-fb-selected"),this.selectedElement=o,this.selectedElement.setAttribute("data-fb-selected","true"),this.updateOverlayPosition(this.selectionOverlay,o),this.selectionOverlay.style.display="block",this.updateTagLabel(o),this.selectionTagLabel.style.display="block",this.sendElementData(o,a),this.lastClickTime=n,this.lastClickPosition={x:e.clientX,y:e.clientY});};updateOverlayPosition(e,n){let t=n.getBoundingClientRect();Object.assign(e.style,{top:`${t.top+window.scrollY}px`,left:`${t.left+window.scrollX}px`,width:`${t.width}px`,height:`${t.height}px`});}updateTagLabel(e){let n=e.getBoundingClientRect(),t=e.tagName.toLowerCase();this.selectionTagLabel.textContent=t,Object.assign(this.selectionTagLabel.style,{top:`${n.top+window.scrollY}px`,left:`${n.left+window.scrollX}px`});}getRelevantStyles(e){let n=window.getComputedStyle(e),t=["display","position","width","height","padding","margin","backgroundColor","color","fontSize","fontFamily"],i={};for(let r of t)i[r]=n.getPropertyValue(r);return i}getDirectTextContent(e){let n=Array.from(e.childNodes).filter(t=>t.nodeType===Node.TEXT_NODE).map(t=>t.textContent?.trim()).filter(Boolean);return n.length>0?n.join(" "):null}sendElementData(e,n){let t=this.getDirectTextContent(e),i={type:"FB_ELEMENT_SELECTED",data:{sourceFile:n.fileName,sourceLine:n.lineNumber,sourceColumn:n.columnNumber,tagName:e.tagName,className:e.className,textContent:t,src:e.getAttribute("src")||void 0,alt:e.getAttribute("alt")||void 0,href:e.getAttribute("href")||void 0,target:e.getAttribute("target")||void 0,rel:e.getAttribute("rel")||void 0,computedStyles:this.getRelevantStyles(e)}};window.parent.postMessage(i,"*");}handleGetAllElementsState(){let e=document.querySelectorAll("*"),n=[];for(let t of e){if(t.classList?.contains("fb-design-mode-overlay")||t.classList?.contains("fb-design-mode-tag"))continue;let i=this.getReactFiberSource(t);if(!i)continue;let r=t,s=r;if(r.tagName!=="IMG"){let l=r.querySelector("img");l&&(s=l);}let o=this.getDirectTextContent(r),a="";r.className&&(typeof r.className=="string"?a=r.className:"baseVal"in r.className&&(a=r.className.baseVal)),n.push({sourceFile:i.fileName,sourceLine:i.lineNumber,sourceColumn:i.columnNumber,className:a,textContent:o,src:s.getAttribute("src")||void 0,alt:s.getAttribute("alt")||void 0,href:r.getAttribute("href")||void 0,target:r.getAttribute("target")||void 0,rel:r.getAttribute("rel")||void 0});}window.parent.postMessage({type:"FB_ALL_ELEMENTS_STATE",data:n},"*");}handleUpdateElement(e){let{sourceFile:n,sourceLine:t,sourceColumn:i,updates:r}=e;if(!n||!t||!r)return;let s=document.querySelectorAll("*");for(let o of s){let a=this.getReactFiberSource(o);if(a?.fileName===n&&a?.lineNumber===t&&a?.columnNumber===i){let l=o;if((r.src!==void 0||r.alt!==void 0)&&l.tagName!=="IMG"){let d=l.querySelector("img");d&&(l=d);}if(r.className!==void 0&&(f().generateClasses(r.className),l.className=r.className),r.textContent!==void 0){let d=Array.from(l.childNodes).find(p=>p.nodeType===Node.TEXT_NODE);d?d.textContent=r.textContent:l.textContent=r.textContent;}r.src!==void 0&&"src"in l&&(l.setAttribute("src",r.src),l.hasAttribute("srcset")&&l.removeAttribute("srcset")),r.alt!==void 0&&"alt"in l&&(l.alt=r.alt),r.href!==void 0&&"href"in l&&l.setAttribute("href",r.href),r.target!==void 0&&"target"in l&&l.setAttribute("target",r.target),r.rel!==void 0&&"rel"in l&&l.setAttribute("rel",r.rel),l===this.hoveredElement&&this.updateOverlayPosition(this.hoverOverlay,l),l===this.selectedElement&&(this.updateOverlayPosition(this.selectionOverlay,l),this.updateTagLabel(l));return}}}handleUpdateTheme(e){if(!e)return;let n=document.getElementById("fb-design-mode-theme");n||(n=document.createElement("style"),n.id="fb-design-mode-theme",document.head.appendChild(n));let t="";if(e.lightVariables&&Object.keys(e.lightVariables).length>0){t+=`:root {
3
3
  `;for(let[i,r]of Object.entries(e.lightVariables))t+=` ${i}: ${r};
4
4
  `;t+=`}
5
5
 
6
6
  `;}if(e.darkVariables&&Object.keys(e.darkVariables).length>0){t+=`.dark {
7
7
  `;for(let[i,r]of Object.entries(e.darkVariables))t+=` ${i}: ${r};
8
8
  `;t+=`}
9
- `;}n.textContent=t;}};typeof window<"u"&&typeof document<"u"&&new h;//# sourceMappingURL=overlay.js.map
9
+ `;}n.textContent=t;}};typeof window<"u"&&typeof document<"u"&&(async()=>{try{let c=await fetch("/src/design-mode/tailwind.config.json");if(c.ok){let e=await c.json();window.__FIREBUZZ_TAILWIND_CONFIG__=e,console.log("[Design Mode] Loaded Tailwind config from JSON");}else console.warn("[Design Mode] Could not load Tailwind config JSON - using empty config"),window.__FIREBUZZ_TAILWIND_CONFIG__={};}catch(c){console.warn("[Design Mode] Error loading Tailwind config:",c),window.__FIREBUZZ_TAILWIND_CONFIG__={};}new g;})();//# sourceMappingURL=overlay.js.map
10
10
  //# sourceMappingURL=overlay.js.map