PageSourceSearch

https://www.goodness.ro/_next/static/chunks/28326-5a44914d41ca08a2.js?dpl=dpl_BgESgPTRQhW6jbz36AWJAZwfp5yY

js goodness.ro collected 2026-10-09 22:36:51 UTC 129,512 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[28326],{28326:(e,t,o)=>{o.r(t),o.d(t,{default:()=>eq});var n=o(95155),r=o(12115),i=o(33887);function s(e){let{text:t}=e,o=e=>(0,n.jsx)("div",{className:"ai-target-skeleton rounded bg-slate-100 ".concat(e),"aria-hidden":"true"});return(0,n.jsx)("div",{className:"w-full px-6 py-10",role:"status","aria-live":"polite",children:(0,n.jsxs)("div",{className:"max-w-3xl mx-auto space-y-4",children:[(0,n.jsxs)("div",{className:"flex flex-col items-center gap-3",children:[o("h-3 w-20"),o("h-8 w-2/3"),o("h-4 w-1/2")]}),(0,n.jsx)("div",{className:"grid grid-cols-3 gap-4 pt-4",children:[0,1,2].map(e=>(0,n.jsxs)("div",{className:"space-y-2",children:[o("h-24 w-full"),o("h-3 w-3/4"),o("h-3 w-1/2")]},e))}),t&&(0,n.jsx)("p",{className:"pt-2 text-center text-xs text-slate-500",children:t})]})})}var a=o(86651),l=o(83457),d=o(52987),c=o(76907),p=o(46398),u=o(23952),m=o(39347),g=o(45345),h=o(21873),f=o(95740),x=o(5917),b=o(91169),y=o(26617),v=o(26983),E=o(11503),j=o(95664),w=o(60709),N=o(39068),S=o(56154),C=o(5937),T=o(90812),I=o(21786);function A(e){let{src:t,alt:o,className:i="",isEditMode:s=!1,onImageChange:a,storeId:l,showUrlInput:d=!0,uploadFolder:c="components"}=e,[p,u]=(0,r.useState)(!1),[m,g]=(0,r.useState)(t),h="editable-image-".concat(Math.random().toString(36).substr(2,9));r.useEffect(()=>{g(t)},[t]);let f=async e=>{if(!e||!l)return void console.warn("Missing file or storeId for image upload");u(!0);try{let t=new FormData;t.append("file",e),t.append("storeId",l),t.append("folder",c);let o=await fetch("/api/upload/image",{method:"POST",body:t}),n=await o.json();n.success&&n.url?(g(n.url),a&&a(n.url)):(console.error("Upload failed:",n.error),alert("Failed to upload image. Please try again."))}catch(e){console.error("Upload error:",e),alert("Failed to upload image. Please try again.")}finally{u(!1)}};return s?(0,n.jsxs)("div",{className:"relative",children:[(0,n.jsx)("input",{type:"file",id:h,accept:"image/*",onChange:e=>{var t;let o=null==(t=e.target.files)?void 0:t[0];if(o){if(!["image/jpeg","image/jpg","image/png","image/gif","image/webp"].includes(o.type))return void alert("Please select a valid image file (JPEG, PNG, GIF, or WebP)");if(o.size>5242880)return void alert("File size must be less than 5MB");f(o)}},className:"hidden"}),(0,n.jsxs)("div",{className:"relative group",children:[(0,n.jsx)("img",{src:m,alt:o,className:"".concat(i," ").concat(p?"opacity-50":""," cursor-pointer transition-opacity"),onClick:()=>{if(!p&&l){var e;null==(e=document.getElementById(h))||e.click()}}}),(0,n.jsx)("div",{className:"absolute inset-0 flex flex-col items-center justify-center bg-black/60 opacity-0 group-hover:opacity-100 transition-opacity cursor-pointer rounded-[inherit]",onClick:()=>{if(!p&&l){var e;null==(e=document.getElementById(h))||e.click()}},children:p?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("div",{className:"animate-spin rounded-full h-12 w-12 border-4 border-white border-t-transparent mb-3"}),(0,n.jsx)("span",{className:"text-white font-medium",children:"Uploading..."})]}):l?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(I.A,{className:"w-12 h-12 text-white mb-3"}),(0,n.jsx)("span",{className:"text-white font-medium",children:"Click to upload image"}),d&&(0,n.jsx)("span",{className:"text-white/90 text-sm mt-1",children:"or paste URL below"})]}):(0,n.jsx)("span",{className:"text-white/90 text-sm",children:"Upload not available"})})]}),d&&(0,n.jsx)("div",{className:"mt-3",children:(0,n.jsx)("input",{type:"text",value:m,onChange:e=>{var t;g(t=e.target.value),a&&a(t)},placeholder:"Or paste image URL here",className:"w-full px-3 py-2 rounded-lg text-sm border border-gray-300 focus:outline-none focus:ring-2 focus:ring-primary bg-white text-gray-900",onClick:e=>e.stopPropagation()})})]}):(0,n.jsx)("img",{src:m,alt:o,className:i})}var R=o(79627),L=o(15239),k=o(8353),D=o(24228),M=o(78237),O=o(37897),P=o(32394),_=o(84319),F=o(70143);let B=e=>"number"==typeof e?"".concat(4*e,"px"):void 0,H={sm:"640px",md:"768px",lg:"1024px",xl:"1280px","2xl":"1536px",full:void 0},z={xs:"12px",sm:"14px",md:"16px",lg:"18px",xl:"20px","2xl":"24px","3xl":"30px","4xl":"36px","5xl":"48px","6xl":"60px","7xl":"72px"},W={normal:400,medium:500,semibold:600,bold:700,black:900},U={none:"0",sm:"4px",md:"8px",lg:"12px",xl:"20px",full:"9999px"},J={none:"none",sm:"0 1px 3px rgba(0,0,0,.08)",md:"0 6px 20px rgba(0,0,0,.08)",lg:"0 20px 50px rgba(0,0,0,.12)"},V={"1:1":"100%","4:5":"125%","3:4":"133.333%","16:9":"56.25%","21:9":"42.857%"},G={sm:640,md:768,lg:1024},Y={bg:"var(--theme-background, #ffffff)",fg:"var(--theme-text, #1f2937)",muted:"color-mix(in srgb, var(--theme-text, #1f2937) 60%, transparent)",primary:"var(--theme-primary, #3b82f6)","primary-soft":"color-mix(in srgb, var(--theme-primary, #3b82f6) 12%, var(--theme-background, #ffffff))",secondary:"var(--theme-secondary, #10b981)",surface:"color-mix(in srgb, var(--theme-text, #1f2937) 4%, var(--theme-background, #ffffff))",border:"color-mix(in srgb, var(--theme-text, #1f2937) 12%, transparent)"};function q(e){if(e)return Y[e]||e}function K(e){return!!e&&"object"==typeof e}function X(e,t){let o=[];for(let{prop:n,value:r,map:i}of t)if(K(r))for(let[t,s]of Object.entries(r)){if(void 0===s)continue;let r="#".concat(e,"{").concat(n,":").concat(i(s),"}");o.push("base"===t?r:"@container (min-width:".concat(G[t],"px){").concat(r,"}"))}return o.join("\n")}function $(e){if(!e)return{};let t={};for(let[o,n]of Object.entries(e))void 0!==n&&""!==n&&(t[o]=n);return t}function Q(e){let{nodeId:t,elementId:o,title:r,cta:i,ctaHref:s,isEditMode:a,onUpdate:l}=e;return r||i?(0,n.jsxs)("div",{className:"mb-5 flex items-end justify-between gap-4",children:[void 0!==r&&(0,n.jsx)(T.A,{id:"".concat(o,"-title"),value:r,tag:"h2",className:"m-0 text-3xl font-black tracking-tight",isEditMode:a,onSave:e=>l({title:e}),dataPropName:"nodes.".concat(t,".props.title")}),i&&(0,n.jsx)("a",{href:s||"#",onClick:e=>{a&&e.preventDefault()},className:"font-bold",style:{color:q("fg")},children:(0,n.jsx)(T.A,{id:"".concat(o,"-cta"),value:i.text,tag:"span",isEditMode:a,onSave:e=>l({cta:{...i,text:e}}),href:i.href,onHrefChange:e=>l({cta:{...i,href:e}}),dataPropName:"nodes.".concat(t,".props.cta.text")})})]}):null}function Z(e){var t,o;let{slot:i,isEditMode:s,nodeId:a,elementId:l,onSlotUpdate:d,storeId:c,storeSlug:p,isCustomDomain:u=!1,storeLanguage:m="en",cartEnabled:g=!1,showWishlistOnCard:h=!1,enableWishlistFolders:f=!1,wishlistMultiFolder:x=!1,wishlistIcon:b}=e,{t:v}=(0,F.Bd)(m),[E,j]=(0,r.useState)(!1),w=i.count||10,N=i.card||{},S=(0,k.H)({storeId:c,storeSlug:p,isEditMode:!1,numberOfListings:w,sortMode:"random"===i.sort?"random":"newest",listingTypeId:i.listingTypeId,customFieldFilters:i.customFieldFilters,cartEnabled:g&&!s,wishlistEnabled:h&&!s,loadListingTypes:E}),C="".concat(l,"-grid"),T=null!=(o=i.cols)?o:{base:2,md:3,lg:5},I="number"==typeof T?"#".concat(C,"{grid-template-columns:repeat(").concat(T,",minmax(0,1fr))}"):X(C,[{prop:"grid-template-columns",value:T,map:e=>"repeat(".concat(Number(e)||1,",minmax(0,1fr))")}]),A=e=>{var t,o,r;let a=(0,P.$g)(e.price,{currency:e.currency,freeLabel:v("common.free")}),l=(null==(t=e.seller)?void 0:t.businessName)||(null==(o=e.seller)?void 0:o.firstName);return(0,n.jsxs)("a",{href:s?void 0:S.getListingUrl(e),onClick:e=>{s&&e.preventDefault()},className:"block ".concat("row"===i.layout?"w-[220px] flex-none":""),"data-no-visual-edit":"true",children:[(0,n.jsxs)("div",{className:"relative overflow-hidden rounded-md",style:{paddingTop:V[N.ratio||"4:5"],background:q("surface")},children:[(null==(r=e.images)?void 0:r[0])?(0,n.jsx)(L.default,{src:e.images[0],alt:e.title,fill:!0,className:"object-cover",sizes:"(max-width: 768px) 50vw, 20vw"}):(0,n.jsx)("div",{className:"absolute inset-0 flex items-center justify-center",children:(0,n.jsx)(y.A,{className:"h-10 w-10 opacity-30"})}),!1!==N.showPrice&&"overlay"===(N.pricePosition||"overlay")&&(0,n.jsx)("span",{className:"absolute bottom-2 left-2 rounded-full px-2.5 py-1 text-xs font-semibold",style:{background:q("fg"),color:q("bg")},children:a}),h&&!s&&(0,n.jsx)(M.A,{isWishlisted:S.wishlist.wishlistedIds.has(e._id
1),isLoading:S.wishlist.isToggling===e._id,onClick:(t,o)=>S.wishlist.onClick(e._id,t,o),foldersEnabled:f,multiFolder:x,storeSlug:p,listingId:e._id,language:m,iconName:b})]}),(0,n.jsxs)("div",{className:"pt-2 text-[13px] leading-snug",children:[(0,n.jsx)("div",{className:"line-clamp-2 font-medium",style:{color:q("fg")},children:e.title}),!1!==N.showPrice&&"below"===N.pricePosition&&(0,n.jsx)("div",{className:"mt-0.5 font-semibold",children:a}),!1!==N.showSeller&&l&&(0,n.jsx)("div",{className:"mt-0.5 text-xs",style:{color:q("muted")},children:l})]})]},e._id)},R=S.listings.slice(0,w),B=(null==(t=i.cta)?void 0:t.href)?(0,_.r1)(i.cta.href,{storeSlug:p,isCustomDomain:u}):void 0;return(0,n.jsxs)("div",{className:"relative",children:[s&&(0,n.jsx)(D.A,{listingTypes:S.listingTypes,loadingTypes:S.loadingTypes,onOpenChange:j,hide:["headingTag","buttonText","viewAll","columns","mobileColumns","cardStyle"],onTextChange:(e,t)=>{"numberOfListings"===e?d({count:Number(t)}):"sortMode"===e?d({sort:t}):"listingTypeId"===e?d({listingTypeId:t||void 0}):"customFieldFilters"===e?d({customFieldFilters:t&&"object"==typeof t?t:void 0}):"showPrice"===e&&d({card:{...N,showPrice:t}})},listingTypeId:i.listingTypeId,customFieldFilters:i.customFieldFilters,numberOfListings:w,columns:"number"==typeof T?T:T.lg||5,mobileColumns:1,buttonText:"",showViewAllButton:!1,viewAllButtonText:"",sortMode:"random"===i.sort?"random":"newest",sortByDistance:!1,distanceUnit:"km",showViewCounts:!1,showPrice:!1!==N.showPrice}),(0,n.jsx)(Q,{nodeId:a,elementId:l,title:i.title,cta:i.cta,ctaHref:B,isEditMode:s,onUpdate:d}),S.loading?(0,n.jsxs)("div",{id:C,className:"grid gap-4",children:[(0,n.jsx)("style",{dangerouslySetInnerHTML:{__html:I}}),Array.from({length:Math.min(w,10)}).map((e,t)=>(0,n.jsx)("div",{className:"animate-pulse rounded-md",style:{paddingTop:V[N.ratio||"4:5"],background:q("surface")}},t))]}):S.catalogGated?(0,n.jsx)("div",{className:"py-8 text-center",style:{color:q("muted")},children:v("catalogGate.sectionBody")}):0===R.length?(0,n.jsx)("div",{className:"py-8 text-center",style:{color:q("muted")},children:"No listings available yet"}):"row"===i.layout?(0,n.jsx)("div",{className:"flex gap-4 overflow-x-auto pb-1 [scrollbar-width:none]",children:R.map(A)}):(0,n.jsxs)("div",{id:C,className:"grid gap-x-4 gap-y-5",children:[(0,n.jsx)("style",{dangerouslySetInnerHTML:{__html:I}}),R.map(A)]}),h&&(0,n.jsx)(O.A,{isOpen:S.wishlist.showSignInModal,onClose:()=>S.wishlist.setShowSignInModal(!1),storeSlug:p||"",isCustomDomain:u,message:v("wishlist.signInToSave"),language:m})]})}let ee=["Outerwear","Tops","Denim","Footwear","Bags","Accessories","Knitwear","Vintage"].map(e=>({id:e,name:e,slug:e.toLowerCase()}));function et(e){var t;let{slot:o,isEditMode:i,nodeId:s,elementId:a,onSlotUpdate:l,storeId:d,storeSlug:c,isCustomDomain:p=!1}=e,[u,m]=(0,r.useState)([]);(0,r.useEffect)(()=>{d&&fetch("/api/store/".concat(d)).then(e=>e.ok?e.json():null).then(e=>{var t,o;m(((null==e||null==(o=e.store)||null==(t=o.productListingSettings)?void 0:t.listingTypes)||[]).map(e=>({id:e.id,name:e.name,slug:e.slug,image:e.image})))}).catch(()=>{})},[d]);let g=(u.length?u:i?ee:[]).slice(0,o.count||12),h=e=>(0,_.r1)("/listings?type=".concat(encodeURIComponent(e.slug)),{storeSlug:c,isCustomDomain:p}),f=o.layout||"chips",x=i?{onClick:e=>e.preventDefault()}:{},b=(null==(t=o.cta)?void 0:t.href)?(0,_.r1)(o.cta.href,{storeSlug:c,isCustomDomain:p}):void 0;return(0,n.jsxs)("div",{"data-no-visual-edit":"true",children:[(0,n.jsx)(Q,{nodeId:s,elementId:a,title:o.title,cta:o.cta,ctaHref:b,isEditMode:i,onUpdate:l}),"chips"===f?(0,n.jsxs)("div",{className:"flex gap-2 overflow-x-auto pb-1 [scrollbar-width:none]",children:[(0,n.jsx)("a",{href:(0,_.r1)("/listings",{storeSlug:c,isCustomDomain:p}),...x,className:"flex-none rounded-full px-4 py-2 text-sm",style:{background:q("fg"),color:q("bg")},children:"All"}),g.map(e=>(0,n.jsx)("a",{href:h(e),...x,className:"flex-none rounded-full px-4 py-2 text-sm",style:{border:"1px solid ".concat(q("border")),color:q("fg")},children:e.name},e.id))]}):(0,n.jsx)("div",{className:"row"===f?"flex gap-4 overflow-x-auto pb-1 [scrollbar-width:none]":"grid gap-4 [grid-template-columns:repeat(auto-fill,minmax(160px,1fr))]",children:g.map((e,t)=>(0,n.jsxs)("a",{href:h(e),...x,className:"block hover:opacity-80 ".concat("row"===f?"w-[200px] flex-none":""),children:[(0,n.jsxs)("div",{className:"relative overflow-hidden rounded-md",style:{paddingTop:V[o.tileRatio||"1:1"],background:q("surface")},children:[e.image&&(0,n.jsx)("img",{src:e.image,alt:e.name,className:"absolute inset-0 h-full w-full object-cover"}),!e.image&&(0,n.jsx)("span",{className:"absolute inset-0 flex items-center justify-center text-4xl font-black opacity-10",children:t+1})]}),(0,n.jsx)("div",{className:"pt-2 text-xs font-bold uppercase tracking-wide",style:{color:q("fg")},children:e.name})]},e.id))})]})}
1function eo(e){let{slot:t,isEditMode:o,storeSlug:i,isCustomDomain:s=!1}=e,[l,d]=(0,r.useState)(""),c="lg"===t.size;return(0,n.jsxs)("form",{onSubmit:e=>{e.preventDefault(),!o&&l.trim()&&(window.location.href=(0,_.r1)("/listings?search=".concat(encodeURIComponent(l.trim().toLowerCase())),{storeSlug:i,isCustomDomain:s}))},className:"flex items-center gap-3 rounded-full px-5 ".concat(c?"h-14 text-[17px]":"h-11 text-[15px]"),style:{background:q("surface"),color:q("muted")},"data-no-visual-edit":"true",children:[(0,n.jsx)(a.A,{className:"h-[18px] w-[18px] flex-none"}),(0,n.jsx)("input",{value:l,onChange:e=>d(e.target.value),placeholder:t.placeholder||"Search",className:"w-full bg-transparent outline-none",style:{color:q("fg")},readOnly:o})]})}let en=["Trash Show","Kira Archive","Adi Studio","Mossroom","Vintage Vera","Archive Ola"].map((e,t)=>({id:String(t),firstName:e,lastName:"",listingCount:20+7*t}));function er(e){var t;let{slot:o,isEditMode:i,nodeId:s,elementId:a,onSlotUpdate:l,storeId:d,storeSlug:c,isCustomDomain:p=!1}=e,[u,m]=(0,r.useState)([]);(0,r.useEffect)(()=>{d&&!i&&fetch("/api/stores/".concat(d,"/sellers?limit=").concat(o.count||8)).then(e=>e.ok?e.json():null).then(e=>m((null==e?void 0:e.sellers)||[])).catch(()=>{})},[d,i,o.count]);let g=(i?en:u).slice(0,o.count||8),h=e=>e.businessName||"".concat(e.firstName," ").concat(e.lastName).trim(),f=(null==(t=o.cta)?void 0:t.href)?(0,_.r1)(o.cta.href,{storeSlug:c,isCustomDomain:p}):void 0;return(0,n.jsxs)("div",{"data-no-visual-edit":"true",children:[(0,n.jsx)(Q,{nodeId:s,elementId:a,title:o.title,cta:o.cta,ctaHref:f,isEditMode:i,onUpdate:l}),(0,n.jsx)("div",{className:"grid"===o.layout?"grid gap-4 [grid-template-columns:repeat(auto-fill,minmax(140px,1fr))]":"flex gap-4 overflow-x-auto pb-1 [scrollbar-width:none]",children:g.map(e=>(0,n.jsxs)("a",{href:(0,_.r1)("/sellers/".concat(e.profileSlug||e.id),{storeSlug:c,isCustomDomain:p}),onClick:e=>{i&&e.preventDefault()},className:"flex w-[120px] flex-none flex-col items-center gap-2 text-center text-[13px]",children:[(0,n.jsx)("div",{className:"h-[72px] w-[72px] overflow-hidden rounded-full",style:{background:q("surface")},children:e.profileImage&&(0,n.jsx)("img",{src:e.profileImage,alt:h(e),className:"h-full w-full object-cover"})}),(0,n.jsxs)("div",{style:{color:q("fg")},children:[(0,n.jsx)("b",{children:h(e)}),(0,n.jsxs)("div",{className:"text-xs",style:{color:q("muted")},children:[e.listingCount," items"]})]})]},e.id))})]})}let ei={search:a.A,heart:l.A,"arrow-right":d.A,"shield-check":c.A,truck:p.A,recycle:u.A,star:m.A,tag:g.A,"map-pin":h.A,sparkles:f.A,check:x.A,users:b.A,package:y.A,clock:v.A,leaf:E.A,camera:j.A,gift:w.A,globe:N.A,zap:S.A,"message-circle":C.A},es="inline-flex items-center gap-2 rounded-full font-semibold whitespace-nowrap transition-opacity hover:opacity-90",ea={sm:"px-3.5 py-1.5 text-[13px]",md:"px-5 py-2.5 text-sm",lg:"px-7 py-3.5 text-base"};function el(e){let{sectionId:t,props:o,isEditMode:i=!1,onPropsUpdate:s,...a}=e,l=(0,r.useMemo)(()=>o.nodes||{},[o.nodes]),d=(0,r.useCallback)(e=>"".concat(t,"-").concat(e),[t]),c=(0,r.useCallback)((e,o)=>{let n=l[e];if(!n||!s)return;let r={...n,...o,props:{...n.props,...o.props||{}},style:{...n.style,...o.style||{}}};s(t,{nodes:{...l,[e]:r}})},[l,s,t]),p=(0,r.useMemo)(()=>{let e=[];for(let n of Object.values(l)){var t,o;let r=d(n.id),i=n.props||{};e.push(X(r,[{prop:"font-size",value:null==(t=n.style)?void 0:t.size,map:e=>z[String(e)]||"16px"},{prop:"display",value:null==(o=n.style)?void 0:o.hide,map:e=>e?"none":"stack"===n.type?"flex":"grid"===n.type?"grid":"block"},{prop:"flex-direction",value:"stack"===n.type?i.direction:void 0,map:e=>String(e)},{prop:"grid-template-columns",value:"grid"===n.type?i.cols:void 0,map:e=>"repeat(".concat(Number(e)||1,",minmax(0,1fr))")}]))}return e.filter(Boolean).join("\n")},[l,d]),u=e=>{var o,r,s;let p=l[e];if(!p)return null;let m=p.props||{},g=d(p.id),h=function(e){if(!e)return{};let t={};return null!=e.padding&&(t.padding=B(e.padding)),null!=e.paddingX&&(t.paddingLeft=B(e.paddingX),t.paddingRight=B(e.paddingX)),null!=e.paddingY&&(t.paddingTop=B(e.paddingY),t.paddingBottom=B(e.paddingY)),null!=e.paddingTop&&(t.paddingTop=B(e.paddingTop)),null!=e.paddingBottom&&(t.paddingBottom=B(e.paddingBottom)),null!=e.paddingLeft&&(t.paddingLeft=B(e.paddingLeft)),null!=e.paddingRight&&(t.paddingRight=B(e.paddingRight)),null!=e.margin&&(t.margin=B(e.margin)),null!=e.marginTop&&(t.marginTop=B(e.marginTop)),null!=e.marginBottom&&(t.marginBottom=B(e.marginBottom)),e.maxWidth&&H[e.maxWidth]&&(t.maxWidth=H[e.maxWidth]),e.center&&(t.marginLeft="auto",t.marginRight="auto"),e.background&&(t.background=q(e.background)),e.color&&(t.color=q(e.color)),"mono"===e.font&&(t.fontFamily="ui-monospace, SFMono-Regular, Menlo, monospace"),"display"===e.font&&(t.fontWeight=900,t.letterSpacing="-0.02em"),!K(e.size)&&e.size&&(t.fontSize=z[e.size]),e.weight&&(t.fontWeight=W[e.weight]),"tight"===e.tracking&&(t.letterSpacing="-0.03em"),"wide"===e.tracking&&(t.letterSpacing="0.08em"),"caps"===e.tracking&&(t.letterSpacing="0.08em",t.textTransform="uppercase"),e.leading&&(t.lineHeight=({tight:1.05,normal:1.5,loose:1.75})[e.leading]),e.align&&(t.textAlign=e.align),e.radius&&(t.borderRadius=U[e.radius],t.overflow="hidden"),"thin"===e.border&&(t.border="1px solid ".concat(Y.border)),"thick"===e.border&&(t.border="2px s
1olid ".concat(Y.fg)),e.shadow&&(t.boxShadow=J[e.shadow]),e.width&&(t.width=({full:"100%",auto:"auto","1/2":"50%","1/3":"33.333%","2/3":"66.666%"})[e.width]),e.minHeight&&(t.minHeight="".concat(e.minHeight,"px")),!K(e.hide)&&e.hide&&(t.display="none"),t}(p.style),x={id:g,"data-section-id":t,"data-node-id":p.id,"data-node-type":p.type},b=(null==(o=p.style)?void 0:o.hover)==="lift"?"transition-transform hover:-translate-y-0.5":(null==(r=p.style)?void 0:r.hover)==="dim"?"hover:opacity-80 transition-opacity":"";switch(p.type){case"box":case"stack":case"grid":{let e={...h,...$(m.containerStyles)};return"stack"===p.type&&(e.display="flex","string"==typeof m.direction&&(e.flexDirection=m.direction),null!=m.gap&&(e.gap=B(m.gap)),m.align&&(e.alignItems=({start:"flex-start",center:"center",end:"flex-end",stretch:"stretch"})[m.align]),m.justify&&(e.justifyContent=({start:"flex-start",center:"center",end:"flex-end",between:"space-between"})[m.justify]),m.wrap&&(e.flexWrap="wrap")),"grid"===p.type&&(e.display="grid",null!=m.gap&&(e.gap=B(m.gap)),"number"==typeof m.cols&&(e.gridTemplateColumns="repeat(".concat(m.cols,",minmax(0,1fr))"))),(0,n.jsx)("div",{...x,className:b,style:e,"data-prop-name":"nodes.".concat(p.id,".props.container"),children:(p.children||[]).map(u)},g)}case"spacer":return(0,n.jsx)("div",{...x,style:{height:B(null!=(s=m.size)?s:4)},"data-no-visual-edit":"true"},g);case"divider":return(0,n.jsx)("hr",{...x,style:{border:0,borderTop:"1px solid ".concat(q("border")),margin:0,...h},"data-prop-name":"nodes.".concat(p.id,".props.container")},g);case"heading":case"text":{let e="heading"===p.type?"h".concat(m.level||2):"p";return(0,n.jsx)("div",{"data-section-id":t,style:{...h,...$(m.textStyles)},className:b,children:(0,n.jsx)(T.A,{id:g,value:m.text||"",tag:e,className:"m-0",isEditMode:i,onSave:e=>c(p.id,{props:{text:e}}),onStyleChange:e=>c(p.id,{props:{textStyles:{...m.textStyles||{},...e}}}),currentStyles:m.textStyles,dataPropName:"nodes.".concat(p.id,".props.text")})},g)}case"image":{let e=m.ratio&&"auto"!==m.ratio?m.ratio.replace(":"," / "):void 0;return(0,n.jsxs)("div",{...x,"data-prop-name":"nodes.".concat(p.id,".props.src"),className:"relative overflow-hidden [&>div]:h-full [&>div>div]:h-full ".concat(b),style:{...h,...$(m.srcStyles),...e?{aspectRatio:e}:{}},children:[(0,n.jsx)(A,{src:m.src||"",alt:m.alt||"",className:"h-full w-full object-cover",isEditMode:i,onImageChange:e=>c(p.id,{props:{src:e}}),storeId:a.storeId,showUrlInput:!1}),!!m.credit&&(0,n.jsx)(R.A,{credit:m.credit,currentImageUrl:m.src||"",isEditMode:i})]},g)}case"button":{let e=ea[m.buttonSize||"md"],o={...function(e){switch(e){case"secondary":return{background:q("surface"),color:q("fg")};case"outline":return{border:"1px solid ".concat(q("fg")),color:q("fg")};case"ghost":return{color:q("fg")};case"link":return{color:q("fg"),padding:0,fontWeight:700};default:return{background:q("primary"),color:"#fff"}}}(m.variant),...h,...$(m.textStyles)},r=(0,n.jsx)(T.A,{id:g,value:m.text||"",tag:"span",isEditMode:i,onSave:e=>c(p.id,{props:{text:e}}),onStyleChange:e=>c(p.id,{props:{textStyles:{...m.textStyles||{},...e}}}),currentStyles:m.textStyles,href:m.href,onHrefChange:e=>c(p.id,{props:{href:e}}),dataPropName:"nodes.".concat(p.id,".props.text")});return i?(0,n.jsx)("span",{"data-section-id":t,className:"".concat(es," ").concat(e),style:o,children:r},g):(0,n.jsx)("a",{href:m.href||"#","data-section-id":t,className:"".concat(es," ").concat(e),style:o,children:r},g)}case"icon":{let e=ei[m.name||""]||f.A;return(0,n.jsx)(e,{...x,"data-prop-name":"nodes.".concat(p.id,".props.container"),style:{width:m.iconSize||20,height:m.iconSize||20,...h,...$(m.containerStyles)}},g)}case"badge":return(0,n.jsx)("span",{"data-section-id":t,className:"inline-block rounded-full px-2.5 py-1 text-xs font-semibold",style:{background:q("fg"),color:q("bg"),...h,...$(m.textStyles)},children:(0,n.jsx)(T.A,{id:g,value:m.text||"",tag:"span",isEditMode:i,onSave:e=>c(p.id,{props:{text:e}}),currentStyles:m.textStyles,dataPropName:"nodes.".concat(p.id,".props.text")})},g);case"marquee":{let e=(m.items||[]).join("  ✦  ");return(0,n.jsx)("div",{...x,"data-prop-name":"nodes.".concat(p.id,".props.container"),className:"overflow-hidden whitespace-nowrap",style:{...h,...$(m.containerStyles)},children:(0,n.jsxs)("div",{className:"inline-block animate-[canvas-marquee_40s_linear_infinite]",children:[e,"  ✦  ",e,"  ✦  "]})},g)}case"slot":{let e=m.kind?m:void 0;if(!e)return null;let t=e=>(0,n.jsx)("div",{...x,"data-prop-name":"nodes.".concat(p.id,".props.container"),style:{...h,...$(m.containerStyles)},children:e},g),o=e=>c(p.id,{props:e});switch(e.kind){case"listings":return t((0,n.jsx)(Z,{slot:e,isEditMode:i,onSlotUpdate:o,nodeId:p.id,elementId:g,...a}));case"categories":return t((0,n.jsx)(et,{slot:e,isEditMode:i,onSlotUpdate:o,nodeId:p.id,elementId:g,...a}));case"search":return t((0,n.jsx)(eo,{slot:e,isEditMode:i,...a}));case"sellers":return t((0,n.jsx)(er,{slot:e,isEditMode:i,onSlotUpdate:o,nodeId:p.id,elementId:g,...a}));default:return null}}default:return null}};
1return(0,n.jsxs)("section",{id:t,"data-section-id":t,"data-prop-name":"sectionWrapper",className:"w-full",style:$(o.sectionWrapperStyles),children:[p&&(0,n.jsx)("style",{dangerouslySetInnerHTML:{__html:p}}),(0,n.jsx)("style",{dangerouslySetInnerHTML:{__html:"@keyframes canvas-marquee{from{transform:translateX(0)}to{transform:translateX(-50%)}}"}}),u(o.root)]})}var ed=o(42949),ec=o(98394),ep=o(6191);function eu(e){let{position:t,onDrop:o,isVisible:r=!0,label:i}=e,[{isOver:s,canDrop:a},l]=(0,ec.H)({accept:"COMPONENT",drop:e=>{o(e.componentType,e.componentId,e.defaultProps,t)},collect:e=>({isOver:e.isOver(),canDrop:e.canDrop()})});return r||s?(0,n.jsx)("div",{ref:l,className:"transition-all duration-200 relative ".concat(s&&a?"h-32 my-6":r?"h-20 my-4":"h-16"),style:{zIndex:s?50:10,pointerEvents:"auto"},children:(0,n.jsx)("div",{className:"h-full rounded-lg border-2 border-dashed transition-all duration-200 flex items-center justify-center ".concat(s&&a?"border-primary bg-primary/20 scale-105 shadow-lg":r?"border-base-300 bg-base-100/50 hover:border-primary/50 hover:bg-primary/5":"border-base-300/30 bg-base-100/20 hover:border-primary/40 hover:bg-primary/5"),children:(0,n.jsxs)("div",{className:"flex items-center gap-2 text-sm transition-opacity ".concat(r||s?"opacity-100 text-base-content/60":"opacity-40 text-base-content/40"),children:[(0,n.jsx)(ep.A,{className:"w-4 h-4"}),(0,n.jsx)("span",{className:"font-medium",children:s&&a?"✨ Drop component here":i||"Drop zone - Drag component here"})]})})}):(0,n.jsx)("div",{ref:l,className:"h-16 transition-all duration-200"})}var em=o(81458);function eg(e){let{htmlStructure:t,editableFields:o,isEditMode:i=!1,onFieldUpdate:s,onStyleChange:a,onNavigate:l,onHrefChange:d,useContainerQueries:c=!1,visualEdits:p={},storeId:u,sectionId:m}=e;(0,r.useEffect)(()=>{Object.values(p).forEach(e=>{e.fontFamily&&(0,em.Fd)(e.fontFamily)})},[p]);let g=c?function(e){if(!e)return e;let t=e;return Object.entries({"2xl":"7xl",xl:"7xl",lg:"5xl",md:"3xl",sm:"3xl"}).forEach(e=>{let[o,n]=e,r=RegExp('(class(?:Name)?="[^"]*?)\\b'.concat(o,":"),"g");t=t.replace(r,"$1@".concat(n,":"));let i=RegExp("(class(?:Name)?='[^']*?)\\b".concat(o,":"),"g");t=t.replace(i,"$1@".concat(n,":"))}),["onmouseover","onmouseout","onmouseenter","onmouseleave","onclick","ondblclick","oncontextmenu","onfocus","onblur","onkeydown","onkeyup","onkeypress"].forEach(e=>{let o=RegExp("\\s".concat(e,'="[^"]*"'),"gi");t=t.replace(o,"");let n=RegExp("\\s".concat(e,"='[^']*'"),"gi");t=t.replace(n,"")}),t}(t):t,h=0,f=m?"".concat(m,"-"):"";g=g.replace(/<(section|div|h[1-6]|p|span|button|a|img|video)\s+/g,(e,t)=>{if(e.includes(' id="'))return e;let o="auto-id-".concat(f).concat(t,"-").concat(h++);return"<".concat(t,' id="').concat(o,'" ')}),Object.keys(p).length>0&&Object.entries(p).forEach(e=>{let[t,o]=e,n=[];o.backgroundColor&&(n.push("background-image: none !important"),n.push("background-color: ".concat(o.backgroundColor," !important")),n.push("background: ".concat(o.backgroundColor," !important"))),o.color&&n.push("color: ".concat(o.color," !important")),o.fontSize&&n.push("font-size: ".concat(o.fontSize," !important")),o.fontFamily&&n.push("font-family: ".concat(o.fontFamily," !important")),o.display&&n.push("display: ".concat(o.display," !important")),o.padding&&n.push("padding: ".concat(o.padding," !important")),o.paddingTop&&n.push("padding-top: ".concat(o.paddingTop," !important")),o.paddingRight&&n.push("padding-right: ".concat(o.paddingRight," !important")),o.paddingBottom&&n.push("padding-bottom: ".concat(o.paddingBottom," !important")),o.paddingLeft&&n.push("padding-left: ".concat(o.paddingLeft," !important")),o.margin&&n.push("margin: ".concat(o.margin," !important")),o.marginTop&&n.push("margin-top: ".concat(o.marginTop," !important")),o.marginRight&&n.push("margin-right: ".concat(o.marginRight," !important")),o.marginBottom&&n.push("margin-bottom: ".concat(o.marginBottom," !important")),o.marginLeft&&n.push("margin-left: ".concat(o.marginLeft," !important")),o.width&&n.push("width: ".concat(o.width," !important")),o.height&&n.push("height: ".concat(o.height," !important")),o.borderWidth&&(n.push("border-width: ".concat(o.borderWidth," !important")),n.push("border-style: solid !important")),o.borderColor&&n.push("border-color: ".concat(o.borderColor," !important")),o.borderRadius&&n.push("border-radius: ".concat(o.borderRadius," !important")),o.fontWeight&&n.push("font-weight: ".concat(o.fontWeight," !important")),o.textAlign&&n.push("text-align: ".concat(o.textAlign," !important")),o.lineHeight&&n.push("line-height: ".concat(o.lineHeight," !important")),o.letterSpacing&&n.push("letter-spacing: ".concat(o.letterSpacing," !important")),o.textTransform&&n.push("text-transform: ".concat(o.textTransform," !important")),o.textDecoration&&n.push("text-decoration: ".concat(o.textDecoration," !important")),o.display&&n.push("display: ".concat(o.display," !important")),o.flexDirection&&n.push("flex-direction: ".concat(o.flexDirection," !important")),o.justifyContent&&n.push("justify-content: ".concat(o.justifyContent," !important")),o.alignItems&&n.push("al
1ign-items: ".concat(o.alignItems," !important")),o.gap&&n.push("gap: ".concat(o.gap," !important")),o.opacity&&n.push("opacity: ".concat(o.opacity," !important"));let r=RegExp('id="'.concat(t,'"'),"g");if(g.match(r)){if(void 0!==o.text){let e=RegExp('(<[^>]*?id="'.concat(t,'"[^>]*?>)([^<]*)(</[^>]+>)'),"g");g=g.replace(e,(e,t,n,r)=>{let i=o.text.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#039;");return"".concat(t).concat(i).concat(r)})}if(void 0!==o.href){let e=RegExp('(<[^>]*id="'.concat(t,'"[^>]*>)'),"g");g=g.replace(e,e=>/href=["'][^"']*["']/.test(e)?e.replace(/href=["'][^"']*["']/,'href="'.concat(o.href,'"')):e.replace(/>$/,' href="'.concat(o.href,'">')))}if(void 0!==o.src){let e=RegExp('(id="'.concat(t,'"[^>]*?)src="[^"]*"'),"g");g=g.match(e)?g.replace(e,'$1src="'.concat(o.src,'"')):g.replace(RegExp('(id="'.concat(t,'"[^>]*?)>'),"g"),'$1 src="'.concat(o.src,'">'))}if(n.length>0){let e=n.join("; "),o=RegExp('(id="'.concat(t,'"[^>]*?)style="([^"]*)"'),"g");g=g.match(o)?g.replace(o,(t,o,n)=>{let r=n.split(";").filter(e=>e.trim()),i=e.split(";").filter(e=>e.trim()),s=i.map(e=>e.split(":")[0].trim()),a=r.filter(e=>!s.includes(e.split(":")[0].trim())).concat(i);return"".concat(o,'style="').concat(a.join("; "),'"')}):g.replace(RegExp('(id="'.concat(t,'"[^>]*?)>'),"g"),'$1 style="'.concat(e,'">'))}}});try{if(!t||"string"!=typeof t)return console.warn("Invalid HTML structure provided:",t),(0,n.jsx)("div",{className:"p-4 text-gray-500",children:"No content to display"});if(t.length>5e4)return console.warn("HTML structure too large, truncating"),(0,n.jsx)("div",{className:"p-4 border border-yellow-300 bg-yellow-50",children:(0,n.jsx)("p",{className:"text-yellow-800",children:"Content too large to render safely"})});return eh(g,o,p,m)}catch(e){return console.error("Error parsing HTML structure:",e),console.error("HTML Structure:",(null==g?void 0:g.substring(0,500))+"..."),eh(g,o,p,m)}}function eh(e,t){let o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=arguments.length>3?arguments[3]:void 0,i=e;return Object.entries(t).forEach(e=>{let[t,o]=e;if(i=i.replace(RegExp("{{".concat(t,"}}"),"g"),o.value),o.styles&&Object.keys(o.styles).length>0){let e=Object.entries(o.styles).map(e=>{let[t,o]=e,n=t.replace(/([A-Z])/g,"-$1").toLowerCase();return"".concat(n,":").concat(o)}).join(";"),n=RegExp("(data-editable=['\"]".concat(t,"['\"][^>]*)(style=['\"][^'\"]*['\"])?"),"gi");if(!(i=i.replace(n,(t,o)=>"".concat(o,' style="').concat(e,'"'))).includes('style="'.concat(e,'"'))){let t=RegExp("(<[^>]+id=['\"]editable-[^'\"]*['\"][^>]*)(>)","gi");i=i.replace(t,'$1 style="'.concat(e,'"$2'))}}}),i=(i=(i=i.replace(/\{\{primaryColor\}\}/g,"#0F4C75")).replace(/\{\{secondaryColor\}\}/g,"#3282B8")).replace(/\{\{accentColor\}\}/g,"#00D4FF"),Object.keys(o).length>0&&Object.entries(o).forEach(e=>{let[t,o]=e,n=[];o.backgroundColor&&n.push("background-color: ".concat(o.backgroundColor)),o.color&&n.push("color: ".concat(o.color)),o.fontSize&&n.push("font-size: ".concat(o.fontSize)),o.fontFamily&&n.push("font-family: ".concat(o.fontFamily)),o.display&&n.push("display: ".concat(o.display)),o.padding&&n.push("padding: ".concat(o.padding)),o.paddingTop&&n.push("padding-top: ".concat(o.paddingTop)),o.paddingRight&&n.push("padding-right: ".concat(o.paddingRight)),o.paddingBottom&&n.push("padding-bottom: ".concat(o.paddingBottom)),o.paddingLeft&&n.push("padding-left: ".concat(o.paddingLeft)),o.margin&&n.push("margin: ".concat(o.margin)),o.marginTop&&n.push("margin-top: ".concat(o.marginTop)),o.marginRight&&n.push("margin-right: ".concat(o.marginRight)),o.marginBottom&&n.push("margin-bottom: ".concat(o.marginBottom)),o.marginLeft&&n.push("margin-left: ".concat(o.marginLeft)),o.width&&n.push("width: ".concat(o.width)),o.height&&n.push("height: ".concat(o.height)),o.border&&n.push("border: ".concat(o.border)),o.borderWidth&&(n.push("border-width: ".concat(o.borderWidth)),o.borderStyle||n.push("border-style: solid")),o.borderStyle&&n.push("border-style: ".concat(o.borderStyle)),o.borderColor&&n.push("border-color: ".concat(o.borderColor)),o.borderRadius&&n.push("border-radius: ".concat(o.borderRadius)),o.borderTop&&n.push("border-top: ".concat(o.borderTop)),o.borderRight&&n.push("border-right: ".concat(o.borderRight)),o.borderBottom&&n.push("border-bottom: ".concat(o.borderBottom)),o.borderLeft&&n.push("border-left: ".concat(o.borderLeft)),o.borderTopWidth&&n.push("border-top-width: ".concat(o.borderTopWidth)),o.borderRightWidth&&n.push("border-right-width: ".concat(o.borderRightWidth)),o.borderBottomWidth&&n.push("border-bottom-width: ".concat(o.borderBottomWidth)),o.borderLeftWidth&&n.push("border-left-width: ".concat(o.borderLeftWidth)),o.borderTopStyle&&n.push("border-top-style: ".concat(o.borderTopStyle)),o.borderRightStyle&&n.push("border-right-style: ".concat(o.borderRightStyle)),o.borderBottomStyle&&n.push("border-bottom-style: ".concat(o.borderBottomStyle)),o.borderLeftStyle&&n.push("border-left-style: ".concat(o.borderLeftStyle)),o.borderTopColor&&n.push("border-top-color: ".concat(o.borderTopColor)),o.borderRightColor&&n.push("border-right-color: ".concat(o.borderRightColor)),o.borderBottomColor&&n.push("border-bottom-color: ".concat(o.borderBottomColor)),o.borderLeftColor&&n.push("border-left-color: ".concat(o.borderLeftColor)),o.fontWeight&&n.push("font-weight: ".concat(o.fontWeight)),o.textAlign&&n.push("text-align: ".concat(o.textAlign)),o.lineHeight&&n.push("line-height: ".concat(o.lineHeight)),o.letterSpacing&&n.push("letter-spacing: ".concat(o.letterSpacing)),o.textTransform&&n.push("text-transform: ".concat(o.textTransform)),o.textDecoration&&n.push("text-decoration: ".concat(o.textDecoration)),o.display&&n.push("display: ".concat(o.display)),o.flexDirection&&n.push("flex-direction: ".concat(o.flexDirection)),o.justifyContent&&n.push("justify-content: ".concat(o.justifyContent)),o.alignItems&&n.push("al
1ign-items: ".concat(o.alignItems)),o.gap&&n.push("gap: ".concat(o.gap)),o.opacity&&n.push("opacity: ".concat(o.opacity)),o.visibility&&n.push("visibility: ".concat(o.visibility));let r=RegExp('id="'.concat(t,'"'),"g");if(i.match(r)){if(void 0!==o.href){let e=RegExp('(<[^>]*id="'.concat(t,'"[^>]*>)'),"g");i=i.replace(e,e=>/href=["'][^"']*["']/.test(e)?e.replace(/href=["'][^"']*["']/,'href="'.concat(o.href,'"')):e.replace(/>$/,' href="'.concat(o.href,'">')))}if(void 0!==o.src){let e=RegExp('(id="'.concat(t,'"[^>]*?)src="[^"]*"'),"g");i=i.match(e)?i.replace(e,'$1src="'.concat(o.src,'"')):i.replace(RegExp('(id="'.concat(t,'"[^>]*?)>'),"g"),'$1 src="'.concat(o.src,'">'))}if(n.length>0){let e=n.join("; "),o=RegExp('(id="'.concat(t,'"[^>]*?)style="([^"]*)"'),"g");i=i.match(o)?i.replace(o,(t,o,n)=>{let r=n.split(";").filter(e=>e.trim()),i=e.split(";").filter(e=>e.trim()),s=i.map(e=>e.split(":")[0].trim()),a=r.filter(e=>!s.includes(e.split(":")[0].trim())).concat(i);return"".concat(o,'style="').concat(a.join("; "),'"')}):i.replace(RegExp('(id="'.concat(t,'"[^>]*?)>'),"g"),'$1 style="'.concat(e,'">'))}}}),(0,n.jsx)("div",{"data-section-id":r,dangerouslySetInnerHTML:{__html:i}})}var ef=o(71360);function ex(e){let{isEditMode:t=!1,showControls:o=!1,onDelete:r}=e;return t&&o?(0,n.jsx)(n.Fragment,{children:r&&(0,n.jsx)("div",{className:"absolute top-4 left-4 bg-white/95 backdrop-blur-sm rounded-lg shadow-lg border border-red-300 p-2 z-[110]","data-edit-controls":!0,children:(0,n.jsx)("button",{onClick:e=>{e.stopPropagation(),console.log("\uD83D\uDDD1️ Delete button clicked!"),r?(console.log("\uD83D\uDDD1️ Calling onDelete..."),r()):console.log("❌ onDelete is undefined!")},className:"p-2 hover:bg-red-50 rounded transition-colors",title:"Delete Component","data-edit-controls":!0,children:(0,n.jsx)(ef.A,{className:"w-4 h-4 text-red-600"})})})}):null}function eb(e){let{section:t,isEditMode:o=!1,onSectionUpdate:i,onSectionDelete:s,onNavigate:a,selectedDevice:l="desktop",storeId:d}=e,[c,p]=(0,r.useState)(!1),u=t.props||{},m=u.htmlStructure,g=u.editableFields||{},h=u.backgroundStyle||"light",f=u.customBackgroundColor,x=u.textAlignment||"center",b=u.layout||"default",y=u.visualEdits||{};return m?(0,n.jsxs)("section",{"data-section-id":t.id,className:"relative ".concat(""," ").concat("center"===x?"text-center":"left"===x?"text-left":"text-right"),style:{},onMouseEnter:()=>p(!0),onMouseLeave:()=>p(!1),children:[(0,n.jsx)(ex,{isEditMode:o,showControls:c,onDelete:()=>null==s?void 0:s(t.id),textAlignment:x,onTextAlignmentChange:e=>null==i?void 0:i(t.id,{textAlignment:e}),backgroundStyle:h,customBackgroundColor:f,backgroundOptions:[{id:"gradient",label:"Gradient",color:"bg-gradient-to-r from-blue-500 to-purple-600"},{id:"solid",label:"Solid",color:"bg-blue-600"},{id:"light",label:"Light",color:"bg-gray-100"},{id:"custom",label:"Custom",color:"bg-white border-dashed"}],onBackgroundChange:(e,o)=>{"custom"===e?null==i||i(t.id,{backgroundStyle:e,customBackgroundColor:o||"#3b82f6"}):null==i||i(t.id,{backgroundStyle:e,customBackgroundColor:void 0})},layout:b,layoutOptions:[{id:"default",label:"Default"},{id:"wide",label:"Wide"},{id:"narrow",label:"Narrow"}],onLayoutChange:e=>null==i?void 0:i(t.id,{layout:e})}),(0,n.jsx)("div",{className:"wide"===b?"px-4 sm:px-6 lg:px-8":"narrow"===b?"px-8 sm:px-16 lg:px-32":"px-6 lg:px-8",children:(0,n.jsx)(eg,{sectionId:t.id,htmlStructure:m,editableFields:g,isEditMode:o,onFieldUpdate:(e,o)=>{let n=g[e],r={...g,[e]:{...n,value:o}};null==i||i(t.id,{editableFields:r})},onNavigate:a,onStyleChange:(e,o)=>{let n=g[e],r=(null==n?void 0:n.styles)||{},s={...g,[e]:{...n,styles:{...r,...o}}};null==i||i(t.id,{editableFields:s})},onHrefChange:(e,o)=>{let n=g[e],r={...g,[e]:{...n,href:o}};null==i||i(t.id,{editableFields:r})},useContainerQueries:"tablet"===l||"mobile"===l,visualEdits:y,storeId:d})})]}):(0,n.jsxs)("div",{className:"p-4 border border-yellow-300 bg-yellow-50",children:[(0,n.jsx)("p",{className:"text-yellow-800",children:"No HTML structure provided for freeform component"}),(0,n.jsxs)("p",{className:"text-yellow-600 text-sm",children:["Section ID: ",t.id]})]})}var ey=o(94266),ev=o(12108),eE=o(24033),ej=o(49476),ew=o(11010),eN=o(57828),eS=o(70532),eC=o(47650),eT=o(14122);function eI(e){let{isOpen:t,onConfirm:o,onCancel:r}=e;return t&&"undefined"!=typeof document?(0,eC.createPortal)((0,n.jsx)("div",{"data-no-visual-edit":"true",className:"fixed inset-0 bg-black/30 backdrop-blur-sm flex items-center justify-center z-[100010] p-4",children:(0,n.jsxs)("div",{className:"bg-base-100 rounded-xl shadow-2xl border border-base-300 w-full max-w-sm animate-in fade-in zoom-in-95 duration-150",children:[(0,n.jsx)("div",{className:"p-5 pb-3",children:(0,n.jsxs)("div",{className:"flex items-center gap-3",children:[(0,n.jsx)("div",{className:"w-10 h-10 rounded-full bg-error/20 flex items-center justify-center flex-shrink-0",children:(0,n.jsx)(ef.A,{className:"w-5 h-5 text-error"})}),(0,n.jsx)("div",{children:(0,n.jsx)("h3",{className:"text-base font-semibold text-base-content",children:"Delete Component"})})]})}),(0,n.jsxs)("div",{className:"px-5 pb-4",children:[(0,n.jsx)("p",{className:"text-sm text-base-content/80",children:"Are you sure you want to delete this component?"}),(0,n.jsxs)("div",{className:"flex items-center gap-2 mt-3 p-2.5 bg-info/10 rounded-lg border border-info/20",children:[(0,n.jsx)(eT.A,{className:"w-4 h-4 text-info flex-shrink-0"}),(0,n.jsxs)("p",{className:"text-xs text-info",children:["You can use ",(0,n.jsx)("span",{className:"font-semibold",children:"Discard"})," to undo this action."]})]})]}),(0,n.jsxs)("div",{className:"p-5 pt-2 flex gap-2",children:[(0,n.jsx)("button",{onClick:r,className:"flex-1 px-4 py-2 text-sm font-medium bg-base-200 text-base-content roun
1ded-lg hover:bg-base-300 transition-colors",children:"Cancel"}),(0,n.jsxs)("button",{onClick:o,className:"flex-1 px-4 py-2 text-sm font-medium bg-error text-error-content rounded-lg hover:opacity-90 transition-colors flex items-center justify-center gap-2",children:[(0,n.jsx)(ef.A,{className:"w-4 h-4"}),"Delete"]})]})]})}),document.body):null}function eA(e){let{section:t,children:o,onReorder:i,onEdit:s,onDelete:a,onToggleHidden:l,onMoveUp:d,onMoveDown:c,isEditing:p=!1}=e,u=!!t.hidden,[{isDragging:m},g,h]=(0,ey.i)({type:"PAGE_COMPONENT",item:{id:t.id,type:"PAGE_COMPONENT",section:t},collect:e=>({isDragging:e.isDragging()})}),[{isOver:f},x]=(0,ec.H)({accept:"PAGE_COMPONENT",hover:(e,o)=>{var n;if("PAGE_COMPONENT"!==e.type||e.id===t.id)return;let r=null==(n=v.current)?void 0:n.getBoundingClientRect();if(!r)return;let i=(r.bottom-r.top)/2,s=o.getClientOffset();s&&y(s.y-r.top<i?"before":"after")},drop:e=>{"PAGE_COMPONENT"===e.type&&e.id!==t.id&&i(e.id,t.id,b||"after")},collect:e=>({isOver:e.isOver()})}),[b,y]=r.useState(null),v=r.useRef(null),E=r.useRef(null),[j,w]=r.useState(!1),[N,S]=r.useState(!1);r.useEffect(()=>{if(!p)return;let e=E.current;if(!e)return;let t=()=>{w(e.getBoundingClientRect().height<=8)};t();let o=new ResizeObserver(t);return o.observe(e),()=>o.disconnect()},[p]);let C=r.useCallback(e=>{v.current=e,x(e),h(e)},[x,h]);return(0,n.jsxs)("div",{ref:C,className:"relative group transition-all duration-200 ".concat(m?"opacity-50 scale-95":""," ").concat(f?"z-10":""),children:[f&&"before"===b&&(0,n.jsx)("div",{className:"absolute -top-2 left-0 right-0 h-1 bg-primary rounded-full z-20"}),(0,n.jsxs)("div",{className:"relative",children:[p&&(0,n.jsxs)("div",{"data-no-visual-edit":"true",className:"absolute top-2 right-2 z-[90] flex items-center gap-1 opacity-0 group-hover:opacity-100 transition-opacity pointer-events-auto",children:[(d||c)&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("button",{onClick:d,disabled:!d,className:"p-1 bg-white/90 hover:bg-white rounded shadow-sm border disabled:opacity-30 disabled:cursor-not-allowed",title:"Move up",children:(0,n.jsx)(ev.A,{className:"w-4 h-4 text-gray-600"})}),(0,n.jsx)("button",{onClick:c,disabled:!c,className:"p-1 bg-white/90 hover:bg-white rounded shadow-sm border disabled:opacity-30 disabled:cursor-not-allowed",title:"Move down",children:(0,n.jsx)(eE.A,{className:"w-4 h-4 text-gray-600"})})]}),(0,n.jsx)("button",{ref:g,className:"p-1 bg-white/90 hover:bg-white rounded shadow-sm border cursor-grab active:cursor-grabbing",title:"Drag to reorder",children:(0,n.jsx)(ej.A,{className:"w-4 h-4 text-gray-600"})}),s&&(0,n.jsx)("button",{onClick:()=>s(t.id),className:"p-1 bg-white/90 hover:bg-white rounded shadow-sm border",title:"Edit component",children:(0,n.jsx)(ew.A,{className:"w-4 h-4 text-blue-600"})}),l&&(0,n.jsx)("button",{onClick:()=>l(t.id),className:"p-1 bg-white/90 hover:bg-white rounded shadow-sm border",title:u?"Show component":"Hide component (kept, not shown on the storefront)",children:u?(0,n.jsx)(eN.A,{className:"w-4 h-4 text-green-600"}):(0,n.jsx)(eS.A,{className:"w-4 h-4 text-gray-600"})}),a&&(0,n.jsx)("button",{onClick:()=>S(!0),className:"p-1 bg-white/90 hover:bg-white rounded shadow-sm border",title:"Delete component",children:(0,n.jsx)(ef.A,{className:"w-4 h-4 text-red-600"})})]}),(0,n.jsx)("div",{className:"".concat(p?"border-2 border-dashed border-transparent group-hover:border-primary/50 rounded-lg":""),children:(0,n.jsx)("div",{ref:E,children:p&&u?(0,n.jsxs)("div",{id:"".concat(t.id,"-hidden-component"),"data-section-id":t.id,"data-collapsed-section-placeholder":"true","data-no-visual-edit":"true",className:"mx-4 my-2 flex flex-wrap items-center gap-2 rounded-lg border-2 border-dashed border-amber-300 bg-amber-50 px-4 py-3 text-sm text-amber-900",children:[(0,n.jsx)(eS.A,{className:"h-4 w-4 flex-shrink-0"}),(0,n.jsxs)("span",{children:[(0,n.jsx)("strong",{children:t.name||t.templateId||"Component"})," ","is hidden. It stays in the page with all its settings, but visitors do not see it."]}),l&&(0,n.jsxs)("button",{type:"button",onClick:()=>l(t.id),className:"inline-flex items-center gap-1 rounded border border-amber-300 bg-white px-2 py-1 text-xs font-medium text-amber-900 hover:bg-amber-100",children:[(0,n.jsx)(eN.A,{className:"h-3.5 w-3.5"})," Show"]})]}):o})}),p&&j&&!u&&(0,n.jsxs)("div",{id:"".concat(t.id,"-hidden-placeholder"),"data-section-id":t.id,"data-collapsed-section-placeholder":"true","data-no-visual-edit":"true",className:"mx-4 my-2 flex items-center gap-2 rounded-lg border-2 border-dashed border-gray-300 bg-gray-50 px-4 py-3 text-sm text-gray-500",children:[(0,n.jsx)(eS.A,{className:"h-4 w-4 flex-shrink-0"}),(0,n.jsxs)("span",{children:[(0,n.jsx)("strong",{children:t.name||t.templateId||"Component"})," ","has no visible content (all elements were deleted). Right-click here to delete the component."]})]})]}),f&&"after"===b&&(0,n.jsx)("div",{className:"absolute -bottom-2 left-0 right-0 h-1 bg-primary rounded-full z-20"}),a&&N&&(0,n.jsx)("div",{"data-no-visual-edit":"true",children:(0,n.jsx)(eI,{isOpen:N,onConfirm:()=>{S(!1),a(t.id)},onCancel:()=>S(!1)})}),m&&(0,n.jsx)("div",{className:"absolute inset-0 bg-primary/10 border-2 border-dashed border-primary rounded-lg flex items-center justify-center z-20",children:(0,n.jsx)("div",{className:"bg-white/90 px-3 py-1 rounded-full text-sm font-medium text-primary",children:"Dragging..."})})]})}let eR={HERO_SIMPLE:"hero-simple",HERO_SPLIT:"hero-split",TEXT_BLOCK:"text-block",IMAGE_TEXT:"image-text",CTA_BUTTON:"cta-button",TESTIMONIAL:"testimonial"};var eL=o(93221);
1function ek(e){let{componentType:t,componentId:o,props:i,isEditMode:s=!1,onEdit:a,onDelete:l,onPropsUpdate:d,storeId:c,storeSlug:p,isCustomDomain:u=!1,visualEdits:m={},sectionId:g,themePrimaryColor:h,cartEnabled:f=!1,storeLanguage:x="en",emojiReactionsEnabled:b=!1,showWishlistOnCard:y=!1,enableWishlistFolders:v=!1,wishlistMultiFolder:E=!1,wishlistIcon:j}=e,[w,N]=(0,r.useState)(i),S=(0,r.useRef)(null);(0,r.useEffect)(()=>{s&&N(i)},[i,s]);let C=s?w:i,T=r.useMemo(()=>{if(!m||0===Object.keys(m).length)return C;let e={...C},t={"main-image":"imageUrl","left-image":"leftImageUrl","right-image":"rightImageUrl","bg-image":"backgroundImageUrl","background-image":"backgroundImageUrl","hero-image":"imageUrl","profile-image":"profileImageUrl","author-image":"authorImageUrl","company-logo":"companyLogoUrl",avatar:"avatarUrl",logo:"logoUrl",image:"imageUrl"},o={title:"title",subtitle:"subtitle",description:"description",heading:"heading",subheading:"subheading",announcement:"announcement","btn-primary":"primaryButtonText","btn-secondary":"secondaryButtonText",quote:"quote",author:"author",content:"content"};return Object.entries(m).forEach(n=>{let[r,i]=n;if(i.src&&"string"==typeof i.src){for(let[o,n]of Object.entries(t))if(r.endsWith("-".concat(o))){e[n]=i.src;break}}if(i.text&&"string"==typeof i.text){for(let[t,n]of Object.entries(o))if(r.endsWith("-".concat(t))){e[n]=i.text;break}}}),e},[C,m]);(0,r.useEffect)(()=>{Object.values(m).forEach(e=>{e.fontFamily&&"string"==typeof e.fontFamily&&(0,em.Fd)(e.fontFamily)})},[m]),(0,r.useEffect)(()=>{S.current&&S.current.querySelectorAll("H1, H2, H3, H4, H5, H6, P, SPAN, A, BUTTON, IMG, VIDEO, DIV, SECTION").forEach((e,t)=>{e.id||(e.id="".concat(g||o,"-el-").concat(t))})},[g,o,T]);let I=(0,r.useRef)(new Set),A=(0,r.useRef)(new Map);(0,r.useEffect)(()=>{if(!S.current)return;let e=S.current,t={padding:"padding",paddingTop:"padding-top",paddingRight:"padding-right",paddingBottom:"padding-bottom",paddingLeft:"padding-left",margin:"margin",marginTop:"margin-top",marginRight:"margin-right",marginBottom:"margin-bottom",marginLeft:"margin-left",width:"width",height:"height",color:"color",backgroundColor:"background-color",border:"border",borderStyle:"border-style",borderWidth:"border-width",borderColor:"border-color",borderRadius:"border-radius",borderTop:"border-top",borderRight:"border-right",borderBottom:"border-bottom",borderLeft:"border-left",borderTopWidth:"border-top-width",borderRightWidth:"border-right-width",borderBottomWidth:"border-bottom-width",borderLeftWidth:"border-left-width",borderTopStyle:"border-top-style",borderRightStyle:"border-right-style",borderBottomStyle:"border-bottom-style",borderLeftStyle:"border-left-style",borderTopColor:"border-top-color",borderRightColor:"border-right-color",borderBottomColor:"border-bottom-color",borderLeftColor:"border-left-color",fontSize:"font-size",fontFamily:"font-family",fontWeight:"font-weight",textAlign:"text-align",lineHeight:"line-height",letterSpacing:"letter-spacing",textTransform:"text-transform",textDecoration:"text-decoration",display:"display",flexDirection:"flex-direction",justifyContent:"justify-content",alignItems:"align-items",gap:"gap",opacity:"opacity",visibility:"visibility"},o=new Set(Object.keys(m||{}));console.log("\uD83D\uDD0D Reset check:",{currentEditIds:Array.from(o),previouslyEditedIds:Array.from(I.current),willReset:Array.from(I.current).filter(e=>!o.has(e))}),I.current.forEach(t=>{if(!o.has(t)){let o=e.querySelector("#".concat(t));if(!o&&t.startsWith("editable-text-")&&(o=e.querySelector('[data-legacy-id="'.concat(t,'"]'))),console.log("\uD83D\uDD27 Resetting element:",{elementId:t,found:!!o,hasOriginalValues:A.current.has(t)}),o){let e=A.current.get(t);console.log("\uD83D\uDCE6 Original values for",t,":",e),e?(void 0!==e.style?(console.log("✅ Restoring style:",e.style),o.setAttribute("style",e.style)):(console.log("✅ Removing style attribute (no original)"),o.removeAttribute("style")),void 0!==e.href&&(o instanceof HTMLAnchorElement?o.href=e.href:o.setAttribute("href",e.href)),void 0!==e.src&&(o instanceof HTMLImageElement||o instanceof HTMLVideoElement?o.src=e.src:o.setAttribute("src",e.src)),void 0!==e.className&&(o.className=e.className),A.current.delete(t)):o.removeAttribute("style")}}}),I.current.clear(),m&&0!==Object.keys(m).length&&Object.entries(m).forEach(o=>{let[n,r]=o;I.current.add(n);let i=e.querySelector("#".concat(n));!i&&n.startsWith("editable-text-")&&(i=e.querySelector('[data-legacy-id="'.concat(n,'"]'))),i&&(A.current.has(n)||A.current.set(n,{text:i.textContent||void 0,href:i instanceof HTMLAnchorElement?i.href:i.getAttribute("href")||void 0,src:i instanceof HTMLImageElement||i instanceof HTMLVideoElement?i.src:i.getAttribute("src")||void 0,className:i.className||void 0,style:i.getAttribute("style")||void 0}),void 0!==r.text&&null!==i.textContent&&(i.textContent=r.text,r.text.includes("\n")&&(i.style.whiteSpace="pre-line")),void 0!==r.href&&(i instanceof HTMLAnchorElement?i.href=r.href:i.setAttribute("href",r.href)),void 0!==r.src&&(i instanceof HTMLImageElement||i instanceof HTMLVideoElement?i.src=r.src:i.setAttribute("src",r.src)),Object.entries(r).forEach(e
1=>{let[o,n]=e;if(["text","href","src","timestamp","addClasses","removeClasses","className"].includes(o)||null==n)return;let r=t[o]||o;"backgroundColor"===o&&(i.style.setProperty("background-image","none","important"),i.style.setProperty("background",n,"important")),i.style.setProperty(r,n,"important")}),void 0!==r.className&&(i.className=r.className),void 0!==r.addClasses&&r.addClasses.split(" ").filter(Boolean).forEach(e=>i.classList.add(e)),void 0!==r.removeClasses&&r.removeClasses.split(" ").filter(Boolean).forEach(e=>i.classList.remove(e)))})},[m]);let R=(e,t)=>{N({...{...T,[e]:t}}),d?d(o,{[e]:t}):console.warn("⚠️ ComponentRenderer: onPropsUpdate is not defined!")};return(0,n.jsx)("div",{ref:S,className:"relative group","data-section-id":g,children:(()=>{switch(t){case eR.HERO_SIMPLE:return(0,n.jsxs)("div",{className:"bg-gradient-to-r from-blue-500 to-purple-600 text-white p-12 text-center",children:[(0,n.jsx)("h1",{className:"text-4xl font-bold mb-4",children:T.title}),(0,n.jsx)("p",{className:"text-xl mb-8 opacity-90",children:T.description}),(0,n.jsx)("a",{href:T.buttonLink,className:"bg-white text-blue-600 px-6 py-3 rounded-lg text-lg font-semibold hover:bg-gray-100 transition-colors",children:T.buttonText})]});case eR.HERO_SPLIT:return(0,n.jsxs)("div",{className:"flex items-center bg-gray-100 p-12",children:[(0,n.jsxs)("div",{className:"flex-1 pr-8",children:[(0,n.jsx)("h1",{className:"text-4xl font-bold mb-4",children:T.title}),(0,n.jsx)("p",{className:"text-xl mb-8 text-gray-600",children:T.description}),(0,n.jsx)("a",{href:T.buttonLink,className:"bg-blue-500 text-white px-6 py-3 rounded-lg text-lg font-semibold hover:bg-blue-600 transition-colors",children:T.buttonText})]}),(0,n.jsx)("div",{className:"w-96 h-64 bg-gray-300 rounded-lg flex items-center justify-center",children:(0,n.jsx)("span",{className:"text-gray-500",children:"Image Placeholder"})})]});case eR.TEXT_BLOCK:return(0,n.jsx)(eL.VJ,{...T,sectionId:g,isEditMode:s,onTextChange:R});case eR.IMAGE_TEXT:return(0,n.jsxs)("div",{className:"flex items-center p-8",children:[(0,n.jsx)("div",{className:"w-64 h-64 bg-gray-300 rounded-lg flex items-center justify-center mr-8",children:(0,n.jsx)("span",{className:"text-gray-500",children:"Image Placeholder"})}),(0,n.jsxs)("div",{className:"flex-1",children:[(0,n.jsx)("h3",{className:"text-2xl font-bold mb-4",children:T.title}),(0,n.jsx)("p",{className:"text-lg text-gray-600",children:T.description})]})]});case eR.CTA_BUTTON:return(0,n.jsxs)("div",{className:"bg-gray-50 p-12 text-center",children:[(0,n.jsx)("h2",{className:"text-3xl font-bold mb-4",children:T.title}),(0,n.jsx)("p",{className:"text-lg text-gray-600 mb-8",children:T.description}),(0,n.jsx)("a",{href:T.buttonLink,className:"bg-green-500 text-white px-8 py-4 rounded-lg text-xl font-semibold hover:bg-green-600 transition-colors",children:T.buttonText})]});case eR.TESTIMONIAL:return(0,n.jsxs)("div",{className:"bg-white border border-gray-200 p-8 rounded-lg shadow-sm",children:[(0,n.jsxs)("div",{className:"text-lg text-gray-600 italic mb-6",children:["“",T.quote,"”"]}),(0,n.jsxs)("div",{className:"flex items-center",children:[(0,n.jsx)("div",{className:"w-12 h-12 bg-gray-300 rounded-full mr-4"}),(0,n.jsxs)("div",{children:[(0,n.jsx)("div",{className:"font-bold",children:T.author}),(0,n.jsxs)("div",{className:"text-gray-500",children:[T.title,", ",T.company]})]})]})]});case eL.Ju.HERO_CENTERED:return(0,n.jsx)(eL.hg,{...T,sectionId:g,isEditMode:s,onTextChange:R,storeSlug:p,isCustomDomain:u});case eL.Ju.HERO_SPLIT:return(0,n.jsx)(eL.Zx,{...T,sectionId:g,isEditMode:s,onTextChange:R,storeSlug:p,isCustomDomain:u});case eL.Ju.CTA_CENTERED:return(0,n.jsx)(eL.zd,{...T,sectionId:g,isEditMode:s,onTextChange:R,storeSlug:p,isCustomDomain:u});case eL.Ju.CTA_DARK_PANEL:return(0,n.jsx)(eL.Zq,{...T,sectionId:g,isEditMode:s,onTextChange:R,storeSlug:p,isCustomDomain:u});case eL.Ju.TESTIMONIAL_CENTERED:return(0,n.jsx)(eL.WK,{...T,sectionId:g,isEditMode:s,onTextChange:R});case eL.Ju.FEATURES_WITH_ICONS:return(0,n.jsx)(eL.AP,{...T,sectionId:g,isEditMode:s,onTextChange:R});case eL.Ju.SIDE_BY_SIDE_IMAGES:return(0,n.jsx)(eL.g_,{...T,sectionId:g,isEditMode:s,onTextChange:R});case eL.Ju.IMAGE_WITH_TEXT:return(0,n.jsx)(eL.F,{...T,sectionId:g,isEditMode:s,onTextChange:R,storeSlug:p,isCustomDomain:u});case eL.Ju.BACKGROUND_IMAGE_SECTION:return(0,n.jsx)(eL.rz,{...T,sectionId:g,isEditMode:s,onTextChange:R,storeSlug:p,isCustomDomain:u});case eL.Ju.MARKETPLACE_HERO:return(0,n.jsx)(eL.eY,{...T,sectionId:g,isEditMode:s,onTextChange:R,storeId:c});case eL.Ju.VIDEO_HERO:return(0,n.jsx)(eL.IZ,{...T,sectionId:g,isEditMode:s,onTextChange:R,storeId:c,storeSlug:p,isCustomDomain:u});case eL.Ju.FEATURED_LISTINGS:return(0,n.jsx)(eL.QA,{...T,sectionId:g,isEditMode:s,onTextChange:R,storeId:c,storeSlug:p,isCustomDomain:u,cartEnabled:f,storeLanguage:x,emojiReactionsEnabled:b,showWishlistOnCard:y,enableWishlistFolders:v,wishlistMultiFolder:E,wishlistIcon:j});case eL.Ju.FEATURED_SELLERS:return(0,n.jsx)(eL.tw,{...T,sectionId:g,isEditMode:s,onTextChange:R,storeId:c,storeSlug:p,isCustomDomain:u,storeLanguage:x});case eL.Ju.CATEGORY_SHOWCASE:return(0,n.jsx)(eL.gr,{...T,sectionId:g,isEditMode:s,onTextChange:R,storeId:c,storeSlug:p});case eL.Ju.LINK_GALLERY:return(0,n.jsx)(eL.XV,{...T,sectionId:g,isEditMode:s,onTextChange:R,storeId:c,storeSlug:p});case eL.Ju.LISTING_FINDER_WIZARD:return(0,n.jsx)(eL.SW,{...T,sectionId:g,isEditMode:s,onTextChange:R,storeId:c,storeSlug:p});case eL.Ju.HERO_WITH_SEARCH:return(0,n.jsx)(eL.Ru,{...T,sectionId:g,isEditMode:s,onTextChange:R,storeId:c,storeSlug:p,themePrimaryColor:h});case eL.Ju.CAR_MARKETPLACE_HERO:return(0,n.jsx)(eL.or,{...T,sectionId:g,isEditMode:s,onTextChange:R});case eL.Ju.CAR_MARKETPLACE_FEATURES:return(0,n.jsx)(eL.Rb,{...T,sectionId:g,isEditMode:s,onTextChange:R});case eL.Ju.CAR_MARKETPLACE_FAQ:return(0,n.jsx)(eL.kt,{...T,sectionId:g,isEditMode:s,onTextChange:R});case eL.Ju.CAR_MARKETPLACE_ABOUT_HERO:return(0,n.jsx)(eL.D7,{...T,sectionId:g,isEditMode:s,onTextChange:R,storeId:c});case eL.Ju.CAR_MARKETPLACE_CONTACT:return(0,n.jsx)(eL.iK,{...T,sectionId:g,isEditMode:s,onTextChange:R});case eL.Ju.P2P_DELIVERY_HERO:return(0,n.jsx)(eL.lq,{...T,sectionId:g,isEditMode:s,onTextChange:R});case eL.Ju.P2P_DELIVERY_FEATURED_ROUTES:return(0,n.jsx)(eL.B8,{...T,sectionId:g,isEditMode:s,onTextChange:R});case eL.Ju.P2P_DELIVERY_FAQ:return(0,n.jsx)(eL.Tw,{...T,sectionId:g,isEditMode:s,onTextChange:R});case eL.Ju.P2P_DELIVERY_CONTACT:return(0,n.jsx)(eL.vo,{...T,sectionId:g,isEditMode:s,onTextChange:R});case eL.Ju.P2P_DELIVERY_ABOUT:return(0,n.jsx)(eL.eP,{...T,sectionId:g,isEditMode:s,onTextChange:R,storeId:c});case eL.Ju.TERMS_OF_SERVICE:return(0,n.jsx)(eL.UP,{...T,sectionId:g,isEditMode:s,onTextChange:R});case eL.Ju.PRIVACY_POLICY:return(0,n.jsx)(eL.te,{...T,sectionId:g,isEditMode:s,onTextChange:R});case eL.Ju.REFUND_POLICY:return(0,n.jsx)(eL.hI,{...T,sectionId:g,isEditMode:s,onTextChange:R});case eL.Ju.BLOG_OVERVIEW:return(0,n.jsx)(eL.A0,{...T,sectionId:g,isEditMode:s,onTextChange:R,storeId:c,storeSlug:p,isCustomDomain:u});case eL.Ju.BLOG_POST_DETAIL:return(0,n.jsx)(eL.As,{...T,sectionId:g,isEditMode:s,onTextChange:R,storeId:c,storeSlug:p,isCustomDomain:u});case eL.Ju.CONTACT_FORM:return(0,n.jsx)(eL.DH,{...T,sectionId:g,isEditMode:s,onTextChange:R,storeId:c});case eL.Ju.REFUND_REQUEST_FORM:return(0,n.jsx)(eL._1,{...T,sectionId:g,isEditMode:s,onTextChange:R,storeId:c});case eL.Ju.TEXT_BLOCK:return(0,n.jsx)(eL.VJ,{...T,sectionId:g,isEditMode:s,onTextChange:R});case eL.Ju.CUSTOM_HTML:return(0,n.jsx)(eL.BD,{...T,sectionId:g,isEditMode:s,onTextChange:R});case eL.Ju.SECTION_DIVIDER:return(0,n.jsx)(eL.nB,{...T,sectionId:g,isEditMode:s,onTextChange:R});case eL.Ju.VIDEO_EMBED:return(0,n.jsx)(eL.n5,{...T,sectionId:g,isEditMode:s,onTextChange:R});case eL.Ju.FAQ_SECTION:return(0,n.jsx)(eL.YS,{...T,sectionId:g,isEditMode:s,onTextChange:R});case eL.Ju.STATS_SECTION:return(0,n.jsx)(eL.nU,{...T,sectionId:g,isEditMode:s,onTextChange:R});case eL.Ju.LOGO_CLOUD:return(0,n.jsx)(eL.TO,{...T,sectionId:g,isEditMode:s,onTextChange:R});case eL.Ju.PRICING_TABLE:return(0,n.jsx)(eL.nm,{...T,sectionId:g,isEditMode:s,onTextChange:R});case eL.Ju.IMAGE_BLOCK:return(0,n.jsx)(eL.Dq,{...T,sectionId:g,isEditMode:s,onTextChange:R});case eL.Ju.IMAGE_GALLERY:return(0,n.jsx)(eL.i_,{...T,sectionId:g,isEditMode:s,onTextChange:R});case eL.Ju.TRUST_BADGES:return(0,n.jsx)(eL.tO,{...T,sectionId:g,isEditMode:s,onTextChange:R});default:return(0,n.jsx)("div",{className:"p-8 bg-gray-100 border border-gray-300 rounded",children:(0,n.jsxs)("p",{className:"text-gray-600",children:["Unknown component type: ",t]})})}})()})}function eD(e){let{elementId:t,width:o,height:i,top:s,left:a,mode:l="resize",initialFontSize:d=16,onResize:c,onFontResize:p}=e,[u,m]=(0,r.useState)(!1),[g,h]=(0,r.useState)(null),[f,x]=(0,r.useState)({x:0,y:0}),[b,y]=(0,r.useState)({width:0,height:0}),[v,E]=(0,r.useState)(d),j=(0,r.useCallback)((e,t)=>{t.preventDefault(),t.stopPropagation(),m(!0),h(e),x({x:t.clientX,y:t.clientY}),y({width:o,height:i}),E(d)},[o,i,d]);(0,r.useEffect)(()=>
1{if(!u||!g)return;let e=e=>{e.preventDefault();let o=e.clientX-f.x,n=e.clientY-f.y;if("font-scale"===l&&p){let e=0;switch(g){case"nw":e=(-o-n)/2;break;case"ne":e=(o-n)/2;break;case"se":e=(o+n)/2;break;case"sw":e=(-o+n)/2;break;default:return}p(t,Math.round(10*Math.max(8,Math.min(200,v+.5*e)))/10)}else if("resize"===l&&c){let e=b.width,r=b.height;switch(g){case"nw":e=b.width-o,r=b.height-n;break;case"n":r=b.height-n;break;case"ne":e=b.width+o,r=b.height-n;break;case"e":e=b.width+o;break;case"se":e=b.width+o,r=b.height+n;break;case"s":r=b.height+n;break;case"sw":e=b.width-o,r=b.height+n;break;case"w":e=b.width-o}c(t,e=Math.max(20,e),r=Math.max(20,r))}},o=()=>{m(!1),h(null)};return document.addEventListener("mousemove",e),document.addEventListener("mouseup",o),()=>{document.removeEventListener("mousemove",e),document.removeEventListener("mouseup",o)}},[u,g,f,b,v,t,c,p,l]);let w="font-scale"===l?[{position:"nw",cursor:"nw-resize",style:{top:-5,left:-5}},{position:"ne",cursor:"ne-resize",style:{top:-5,right:-5}},{position:"se",cursor:"se-resize",style:{bottom:-5,right:-5}},{position:"sw",cursor:"sw-resize",style:{bottom:-5,left:-5}}]:[{position:"nw",cursor:"nw-resize",style:{top:-4,left:-4}},{position:"ne",cursor:"ne-resize",style:{top:-4,right:-4}},{position:"se",cursor:"se-resize",style:{bottom:-4,right:-4}},{position:"sw",cursor:"sw-resize",style:{bottom:-4,left:-4}},{position:"n",cursor:"n-resize",style:{top:-4,left:"50%",transform:"translateX(-50%)"}},{position:"e",cursor:"e-resize",style:{top:"50%",right:-4,transform:"translateY(-50%)"}},{position:"s",cursor:"s-resize",style:{bottom:-4,left:"50%",transform:"translateX(-50%)"}},{position:"w",cursor:"w-resize",style:{top:"50%",left:-4,transform:"translateY(-50%)"}}],N="font-scale"===l?"border-purple-500":"border-green-500",S="font-scale"===l?"hover:bg-purple-100":"hover:bg-green-100",C="font-scale"===l?"bg-purple-200":"bg-green-200";return(0,n.jsxs)("div",{className:"absolute pointer-events-none",style:{top:"".concat(s,"px"),left:"".concat(a,"px"),width:"".concat(o,"px"),height:"".concat(i,"px")},children:[w.map(e=>{let{position:t,cursor:o,style:r}=e;return(0,n.jsx)("div",{className:"absolute w-3 h-3 bg-white border-2 ".concat(N," rounded-sm pointer-events-auto ").concat(S," transition-colors ").concat(u&&g===t?C:""),style:{...r,cursor:o,zIndex:100002},onMouseDown:e=>j(t,e),"data-resize-handle":t,"data-resize-mode":l},t)}),"font-scale"===l&&u&&(0,n.jsxs)("div",{className:"absolute -top-8 left-1/2 transform -translate-x-1/2 bg-purple-600 text-white text-xs px-2 py-1 rounded font-mono whitespace-nowrap shadow-lg",style:{zIndex:100003},children:[d,"px"]})]})}let eM=["H1","H2","H3","H4","H5","H6","P","SPAN","A","BUTTON","LABEL","LI"];function eO(e){var t,o;let{containerRef:i,selectedElementId:s,isActive:a=!0,onElementSelect:l,onResize:d,onFontResize:c,refreshTrigger:p=0}=e,[u,m]=(0,r.useState)(null),[g,h]=(0,r.useState)(null),[f,x]=(0,r.useState)(!1),b=(0,r.useCallback)((e,t)=>{let o=e.getBoundingClientRect(),n=window.getComputedStyle(e);return{dimensions:{width:o.width,height:o.height,top:o.top,left:o.left},elementId:e.id,isHovered:!1,isSelected:e.id===s,tagName:e.tagName.toLowerCase(),computedStyles:{margin:n.margin,marginTop:n.marginTop,marginRight:n.marginRight,marginBottom:n.marginBottom,marginLeft:n.marginLeft,padding:n.padding,paddingTop:n.paddingTop,paddingRight:n.paddingRight,paddingBottom:n.paddingBottom,paddingLeft:n.paddingLeft,position:n.position,fontSize:n.fontSize}}},[s]);return((0,r.useEffect)(()=>{if(!s||!i.current)return void h(null);let e=document.getElementById(s);if(!e)return void h(null);let t=()=>{e&&h(b(e,i.current))};t();let o=()=>{t()};return window.addEventListener("scroll",o,!0),()=>{window.removeEventListener("scroll",o,!0)}},[s,i,b,p]),(0,r.useEffect)(()=>{if(!a||!i.current)return;let e=i.current,t=t=>{let o=t.target;if(o.closest("[data-overlay-element]")||o.closest("[data-quick-edit-panel]")||o.closest("[data-floating-toolbar]"))return void m(null);let n=o.closest("[data-no-visual-edit]"),r=!1;for(;n&&!r;){var i,a;let e=window.getComputedStyle(n).position;r="absolute"===e||"fixed"===e,n=null!=(a=null==(i=n.parentElement)?void 0:i.closest("[data-no-visual-edit]"))?a:null}
1if(r){m(null),x(!0);return}x(!1);let l=["H1","H2","H3","H4","H5","H6","P","SPAN","A","BUTTON","IMG","VIDEO","DIV","SECTION"],d=o;for(;d&&d!==e;){if(l.includes(d.tagName)&&d.id){if(d.id===s)return void m(null);m(b(d,e));return}d=d.parentElement}m(null)},o=()=>{m(null),x(!1)},n=()=>{m(null)};return e.addEventListener("mousemove",t),e.addEventListener("mouseleave",o),window.addEventListener("scroll",n,!0),()=>{e.removeEventListener("mousemove",t),e.removeEventListener("mouseleave",o),window.removeEventListener("scroll",n,!0)}},[a,i,s,b]),a&&"undefined"!=typeof document)?(0,eC.createPortal)((0,n.jsxs)("div",{className:"fixed inset-0 pointer-events-none z-[60]",style:{overflow:"visible"},"data-overlay-element":!0,children:[u&&!u.isSelected&&(0,n.jsx)(eP,{rect:u}),g&&!f&&(0,n.jsx)(e_,{rect:g}),g&&!f&&d&&(null==(t=g.computedStyles)?void 0:t.position)==="absolute"&&(0,n.jsx)(eD,{elementId:g.elementId,width:g.dimensions.width,height:g.dimensions.height,top:g.dimensions.top,left:g.dimensions.left,mode:"resize",onResize:d}),g&&!f&&c&&eM.includes(g.tagName.toUpperCase())&&(0,n.jsx)(eD,{elementId:g.elementId,width:g.dimensions.width,height:g.dimensions.height,top:g.dimensions.top,left:g.dimensions.left,mode:"font-scale",initialFontSize:parseFloat((null==(o=g.computedStyles)?void 0:o.fontSize)||"16"),onFontResize:c})]}),document.body):null}function eP(e){let{rect:t}=e;return(0,n.jsxs)("div",{className:"absolute pointer-events-none",style:{top:"".concat(t.dimensions.top,"px"),left:"".concat(t.dimensions.left,"px"),width:"".concat(t.dimensions.width,"px"),height:"".concat(t.dimensions.height,"px")},children:[(0,n.jsx)("svg",{width:t.dimensions.width,height:t.dimensions.height,className:"overflow-visible",children:(0,n.jsx)("rect",{width:t.dimensions.width,height:t.dimensions.height,fill:"none",stroke:"#3b82f6",strokeWidth:"1",strokeLinecap:"round",strokeLinejoin:"round"})}),(0,n.jsx)("div",{className:"absolute -top-5 left-0 bg-blue-500 text-white text-[10px] px-1.5 py-0.5 rounded font-mono",children:t.tagName})]})}function e_(e){let{rect:t}=e,{width:o,height:r,top:i,left:s}=t.dimensions;return(0,n.jsxs)("div",{className:"absolute pointer-events-none",style:{top:"".concat(i,"px"),left:"".concat(s,"px"),width:"".concat(o,"px"),height:"".concat(r,"px")},children:[(0,n.jsxs)("svg",{width:o,height:r,className:"overflow-visible",viewBox:"0 0 ".concat(o," ").concat(r),children:[(0,n.jsx)("rect",{width:o,height:r,fill:"none",stroke:"#10b981",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),t.computedStyles&&(0,n.jsx)(eF,{width:o,height:r,marginTop:t.computedStyles.marginTop||"0px",marginRight:t.computedStyles.marginRight||"0px",marginBottom:t.computedStyles.marginBottom||"0px",marginLeft:t.computedStyles.marginLeft||"0px"}),t.computedStyles&&(0,n.jsx)(eB,{width:o,height:r,paddingTop:t.computedStyles.paddingTop||"0px",paddingRight:t.computedStyles.paddingRight||"0px",paddingBottom:t.computedStyles.paddingBottom||"0px",paddingLeft:t.computedStyles.paddingLeft||"0px"})]}),(0,n.jsx)("div",{className:"absolute -top-5 left-0 bg-green-500 text-white text-[10px] px-1.5 py-0.5 rounded font-mono font-semibold",children:t.tagName}),(0,n.jsxs)("div",{className:"absolute -top-5 right-0 bg-gray-700 text-white text-[10px] px-1.5 py-0.5 rounded font-mono",children:[Math.round(o)," \xd7 ",Math.round(r)]})]})}function eF(e){let{width:t,height:o,marginTop:r,marginRight:i,marginBottom:s,marginLeft:a}=e,l=parseFloat(r)||0,d=parseFloat(i)||0,c=parseFloat(s)||0,p=parseFloat(a)||0;return 0===l&&0===d&&0===c&&0===p?null:(0,n.jsxs)("g",{children:[(0,n.jsx)("defs",{children:(0,n.jsxs)("pattern",{id:"margin-pattern",patternUnits:"userSpaceOnUse",width:"20",height:"20",children:[(0,n.jsx)("rect",{width:"20",height:"20",fill:"#3b82f6",fillOpacity:"0.1"}),(0,n.jsx)("line",{x1:"0",y1:"20",x2:"20",y2:"0",stroke:"#3b82f6",strokeWidth:"0.3"})]})}),l>0&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("rect",{x:"0",y:-l,width:t,height:l,fill:"url(#margin-pattern)"}),(0,n.jsx)("text",{x:t/2,y:-l/2,fill:"#1d4ed8",fontSize:"10",textAnchor:"middle",dominantBaseline:"middle",className:"font-mono",children:l})]}),c>0&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("rect",{x:"0",y:o,width:t,height:c,fill:"url(#margin-pattern)"}),(0,n.jsx)("text",{x:t/2,y:o+c/2,fill:"#1d4ed8",fontSize:"10",textAnchor:"middle",dominantBaseline:"middle",className:"font-mono",children:c})]}),p>0&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("rect",{x:-p,y:"0",width:p,height:o,fill:"url(#margin-pattern)"}),(0,n.jsx)("text",{x:-p/2,y:o/2,fill:"#1d4ed8",fontSize:"10",textAnchor:"middle",dominantBaseline:"middle",className:"font-mono",children:p})]}),d>0&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("rect",{x:t,y:"0",width:d,height:o,fill:"url(#margin-pattern)"}),(0,n.jsx)("text",{x:t+d/2,y:o/2,fill:"#1d4ed8",fontSize:"10",textAnchor:"middle",dominantBaseline:"middle",className:"font-mono",children:d})]})]})}function eB(e){let{width:t,height:o,paddingTop:r,paddingRight:i,paddingBottom:s,paddingLeft:a}=e,l=parseFloat(r)||0,d=parseFloat(i)||0,c=parseFloat(s)||0,p=parseFloat(a)||0;return 0===l&&0===d&&0===c&&0===p?null:(0,n.jsxs)("g",{children:[(0,n.jsx)("defs",{children:(0,n.jsxs)("pattern",{id:"padding-pattern",patternUnits:"userSpaceOnUse",width:"20",height:"20",children:[(0,n.jsx)("rect",{width:"20",height:"20",fill:"#10b981",fillOpacity:"0.1"}),(0,n.jsx)("line",{x1:"0",y1:"20",x2:"20",y2:"0",stroke:"#10b981",strokeWidth:"0.3"})]})}),l>0&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("rect",{x:"0",y:"0",width:t,height:l,fill:"url(#padding-pattern)"}),(0,n.jsx)("text",{x:t/2,y:l/2,fill:"#047857",fontSize:"10",textAnchor:"middle",dominantBaseline:"middle",className:"font-mono",children:l})]}),c>0&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("rect",{x:"0",y:o-c,width:t,height:c,fill:"url(#padding-pattern)"}),(0,n.jsx)("text",{x:t/2,y:o-c/2,fill:"#047857",fontSize:"10",textAnchor:"middle",dominantBaseline:"middle",className:"font-mono",children:c})]}),p>0&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("rect",{x:"0",y:"0",width:p,height:o,fill:"url(#padding-pattern)"}),(0,n.jsx)("text",{x:p/2,y:o/2,fill:"#047857",fontSize:"10",textAnchor:"middle",dominantBaseline:"middle",className:"font-mono",children:p})]}),d>0&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("rect",{x:t-d,y:"0",width:d,height:o,fill:"url(#padding-pattern)"}),(0,n.jsx)("text",{x:t-d/2,y:o/2,fill:"#047857",fontSize:"10",textAnchor:"middle",dominantBaseline:"middle",className:"font-mono",children:d})]})]})}var eH=o(90799),ez=o(65229);function eW(e){let{selectedElementId:t,onEdit:o,onAIEdit:i,onClose:s}=e,[a,l]=(0,r.useState)(null),[d,c]=(0,r.useState)(!1);return((0,r.useEffect)(()=>
1{if(!t){c(!1),l(null);return}let e=document.getElementById(t);if(!e)return void c(!1);let o=()=>{let t=e.getBoundingClientRect(),o=t.bottom<0||t.top>window.innerHeight||t.right<0||t.left>window.innerWidth,n=t.top<72;if(o||n)return void c(!1);l({top:t.top-48-12,left:t.left+t.width/2}),c(!0)};return o(),window.addEventListener("scroll",o,!0),window.addEventListener("resize",o),()=>{window.removeEventListener("scroll",o,!0),window.removeEventListener("resize",o)}},[t]),a&&d&&"undefined"!=typeof document)?(0,eC.createPortal)((0,n.jsxs)("div",{className:"fixed z-[80] pointer-events-auto",style:{top:"".concat(a.top,"px"),left:"".concat(a.left,"px"),transform:"translate(-50%, 0)"},"data-floating-toolbar":!0,children:[(0,n.jsxs)("div",{className:"flex items-center gap-1 bg-white shadow-2xl rounded-lg border-2 border-green-500 px-2 py-1.5 animate-in slide-in-from-bottom-2 duration-200",onClick:e=>e.stopPropagation(),children:[i&&(0,n.jsxs)("button",{onClick:i,className:"flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium text-purple-700 hover:bg-purple-50 rounded transition-colors",title:"AI Edit",children:[(0,n.jsx)(f.A,{className:"w-3.5 h-3.5"}),(0,n.jsx)("span",{children:"AI"})]}),i&&(0,n.jsx)("div",{className:"w-px h-5 bg-gray-300"}),(0,n.jsxs)("button",{onClick:o,className:"flex items-center gap-1.5 px-3 py-1.5 text-xs font-medium text-blue-700 hover:bg-blue-50 rounded transition-colors",title:"Edit Properties",children:[(0,n.jsx)(eH.A,{className:"w-3.5 h-3.5"}),(0,n.jsx)("span",{children:"Edit"})]}),(0,n.jsx)("div",{className:"w-px h-5 bg-gray-300"}),(0,n.jsx)("button",{onClick:s,className:"flex items-center justify-center p-1.5 text-gray-600 hover:bg-gray-100 rounded transition-colors",title:"Close (Esc)",children:(0,n.jsx)(ez.A,{className:"w-3.5 h-3.5"})})]}),(0,n.jsxs)("div",{className:"absolute left-1/2 -translate-x-1/2 top-full",children:[(0,n.jsx)("div",{className:"w-0 h-0 border-l-[6px] border-l-transparent border-r-[6px] border-r-transparent border-t-[6px] border-t-green-500"}),(0,n.jsx)("div",{className:"w-0 h-0 border-l-[5px] border-l-transparent border-r-[5px] border-r-transparent border-t-[5px] border-t-white absolute left-1/2 -translate-x-1/2 -top-[5px]"})]})]}),document.body):null}var eU=o(75426);function eJ(e){return e.replace(/\./g," ").replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/\b\w/g,e=>e.toUpperCase())}function eV(e){var t;let{onDeleteElement:o,onDeleteSection:i,onDuplicateSection:s,onToggleSectionHidden:a,isSectionHidden:l,onRestoreHiddenElements:d,getHiddenElementCount:c,getSectionName:p,isEditMode:u=!1}=e,[m,g]=(0,r.useState)({isOpen:!1,position:null,targetElementId:null,targetSectionId:null,elementType:null,targetPropName:null,hiddenElementCount:0,targetIsSectionPlaceholder:!1,targetSectionName:null}),[h,f]=(0,r.useState)(!1),[x,b]=(0,r.useState)(null),y=(0,r.useCallback)(()=>{g({isOpen:!1,position:null,targetElementId:null,targetSectionId:null,elementType:null,targetPropName:null,hiddenElementCount:0,targetIsSectionPlaceholder:!1,targetSectionName:null})},[]),v=(0,r.useCallback)(e=>{if(!u)return;let t=e.target,o=t.closest("[id]");if(!o)return;let n=t.closest("[data-section-id]"),r=null==n?void 0:n.getAttribute("data-section-id");(t.closest("[data-editable-area]")||t.closest(".dynamic-page-renderer")||n)&&(e.preventDefault(),e.stopPropagation(),g({isOpen:!0,position:{x:e.clientX,y:e.clientY},targetElementId:o.id,targetSectionId:r||null,elementType:o.tagName.toLowerCase(),targetPropName:o.getAttribute("data-prop-name"),hiddenElementCount:r&&c?c(r):0,targetSectionName:r&&p?p(r):null,targetIsSectionPlaceholder:o.hasAttribute("data-collapsed-section-placeholder")}))},[u,c,p]);(0,r.useEffect)(()=>(document.addEventListener("contextmenu",v),()=>{document.removeEventListener("contextmenu",v)}),[v]),(0,r.useEffect)(()=>{if(!m.isOpen||!m.targetElementId)return;let e=document.getElementById(m.targetElementId);if(!e)return;let t=e.style.outline,o=e.style.outlineOffset;return e.style.outline="2px solid #3b82f6",e.style.outlineOffset="2px",()=>{e.style.outline=t,e.style.outlineOffset=o}},[m.isOpen,m.targetElementId]),(0,r.useEffect)(()=>
1{if(!m.isOpen)return;let e=e=>{"Escape"===e.key&&y()};return document.addEventListener("keydown",e),()=>{document.removeEventListener("keydown",e)}},[m.isOpen,y]);let E=m.position?m.position.x+200>window.innerWidth?window.innerWidth-200-10:m.position.x:0,j=m.position?m.position.y+150>window.innerHeight?window.innerHeight-150-10:m.position.y:0;return"undefined"==typeof document?null:(0,eC.createPortal)((0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(eI,{isOpen:h,onConfirm:()=>{x&&i(x),f(!1),b(null)},onCancel:()=>{f(!1),b(null)}}),m.isOpen&&m.position&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("div",{className:"fixed inset-0 z-[100001]",onClick:y,onContextMenu:e=>{e.preventDefault(),y()}}),(0,n.jsxs)("div",{className:"fixed z-[100002] bg-white rounded-lg shadow-xl border border-gray-200 py-1 min-w-[180px] animate-in fade-in zoom-in-95 duration-100",style:{left:"".concat(E,"px"),top:"".concat(j,"px")},onClick:e=>e.stopPropagation(),children:[(0,n.jsx)("div",{className:"px-3 py-1.5 border-b border-gray-100",children:(0,n.jsxs)("span",{className:"text-[10px] font-medium text-gray-500 uppercase tracking-wide",children:[m.targetPropName?eJ(m.targetPropName):(null==(t=m.elementType)?void 0:t.toUpperCase())||"Element",m.targetSectionName&&(0,n.jsxs)("span",{className:"text-gray-400",children:[" \xb7 in ",eJ(m.targetSectionName)]})]})}),(0,n.jsxs)("div",{className:"py-1",children:[m.targetSectionId&&s&&(0,n.jsxs)("button",{onClick:()=>{m.targetSectionId&&s&&s(m.targetSectionId),y()},className:"w-full flex items-center gap-2.5 px-3 py-1.5 text-sm text-gray-700 hover:bg-gray-50 transition-colors",children:[(0,n.jsx)(eU.A,{className:"w-4 h-4 text-blue-600"}),(0,n.jsx)("span",{children:"Duplicate Component"})]}),m.targetSectionId&&a&&(0,n.jsx)("button",{onClick:()=>{m.targetSectionId&&a&&a(m.targetSectionId),y()},className:"w-full flex items-center gap-2.5 px-3 py-1.5 text-sm text-gray-700 hover:bg-gray-50 transition-colors",children:(null==l?void 0:l(m.targetSectionId))?(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(eN.A,{className:"w-4 h-4 text-green-600"}),(0,n.jsx)("span",{children:"Show Component"})]}):(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(eS.A,{className:"w-4 h-4 text-gray-500"}),(0,n.jsx)("span",{children:"Hide Component"})]})}),m.targetSectionId&&m.hiddenElementCount>0&&d&&(0,n.jsxs)("button",{onClick:()=>{m.targetSectionId&&d(m.targetSectionId),y()},className:"w-full flex items-center gap-2.5 px-3 py-1.5 text-sm text-gray-700 hover:bg-gray-50 transition-colors",children:[(0,n.jsx)(eN.A,{className:"w-4 h-4 text-green-600"}),(0,n.jsxs)("span",{children:["Restore Hidden Elements (",m.hiddenElementCount,")"]})]}),!m.targetIsSectionPlaceholder&&(0,n.jsxs)("button",{onClick:()=>{m.targetElementId&&o(m.targetElementId),y()},className:"w-full flex items-center gap-2.5 px-3 py-1.5 text-sm text-red-600 hover:bg-red-50 transition-colors",children:[(0,n.jsx)(ef.A,{className:"w-4 h-4"}),(0,n.jsx)("span",{children:"Delete Element"}),(0,n.jsx)("span",{className:"ml-auto text-xs text-red-400",children:"⌫"})]}),m.targetSectionId&&(0,n.jsxs)("button",{onClick:()=>{m.targetSectionId&&(b(m.targetSectionId),f(!0)),y()},className:"w-full flex items-center gap-2.5 px-3 py-1.5 text-sm text-red-600 hover:bg-red-50 transition-colors",children:[(0,n.jsx)(ef.A,{className:"w-4 h-4"}),(0,n.jsx)("span",{children:"Delete Entire Component"}),(0,n.jsx)("span",{className:"ml-auto text-xs text-red-400",children:"⇧⌫"})]})]})]})]})]}),document.body)}var eG=o(73728);function eY(e){let{active:t,progress:o,skeletonRef:r,children:i}=e;return t&&o?(0,n.jsxs)("div",{ref:r,className:"relative",children:[i,(0,n.jsx)("div",{className:"absolute inset-0 z-[105] flex items-center justify-center bg-white/70 backdrop-blur-[1px]","data-no-visual-edit":"true",children:(0,n.jsx)("div",{className:"w-full max-w-md px-4",children:(0,n.jsx)(s,{progress:o.progress,text:o.text})})})]}):(0,n.jsx)(n.Fragment,{children:i})}function eq(e){let{pageId:t,customization:o,selectedDevice:a="desktop",storeId:l,isEditMode:d=!1,generatingMessage:c,onComponentReorder:p,onSectionUpdate:u,onCustomizationUpdate:m,onSectionDeleted:g,onDraftStateCheck:h,pageSlug:f,pageName:x,storeSlug:b,isCustomDomain:y=!1,onNavigate:v,isVisualSelectionMode:E=!1,onElementSelected:j,onEditingElementChange:w,onPropertyChange:N,onEditButtonClick:S,visualEditRefreshTrigger:C=0,componentStreamingProgress:T=null,themePrimaryColor:I,themeFontFamily:A,cartEnabled:R=!1,storeLanguage:L="en",emojiReactionsEnabled:k=!1,showWishlistOnCard:D=!1,enableWishlistFolders:M=!1,wishlistMultiFolder:O=!1,wishlistIcon:P}=e,[_,F]=(0,r.useState)(0),B=(0,r.useRef)(null),H=(0,r.useRef)(o),z=(0,r.useRef)(t),W=(0,r.useRef)(l);(0,r.useEffect)(()=>{H.current=o},[o]),(0,r.useEffect)(()=>{z.current=t,W.current=l},[t,l]);let U=(0,r.useCallback)((e,t)=>W.current?fetch(e,t):Promise.resolve(new Response(JSON.stringify({success:!0}),{headers:{"Content-Type":"application/json"}})),[]);(0,r.useEffect)(()=>
1{(0,em.Fd)(A),(0,em.w$)(null==o?void 0:o.sections).forEach(e=>(0,em.Fd)(e))},[null==o?void 0:o.sections,A]);let[J,V]=(0,r.useState)(null);(0,r.useEffect)(()=>{V(null)},[t]);let[G,Y]=(0,r.useState)(!1),[q,K]=(0,r.useState)([]),X=(0,r.useRef)(null);(0,r.useEffect)(()=>{null==w||w(J)},[J,w]),(0,r.useEffect)(()=>{let e=e=>{if(!J)return;let t=e.target;"INPUT"!==t.tagName&&"TEXTAREA"!==t.tagName&&!t.isContentEditable&&("Escape"!==e.key||(0,ed.Zc)(J.id)||V(null),("Delete"===e.key||"Backspace"===e.key)&&(e.preventDefault(),confirm("Are you sure you want to delete this element?")&&er(J.id)))};return window.addEventListener("keydown",e),()=>window.removeEventListener("keydown",e)},[J]);let $=(0,r.useRef)(null),Q=(0,r.useRef)(null),Z=(0,r.useRef)(0);(0,r.useEffect)(()=>{let e=()=>{Z.current+=1,$.current&&(clearTimeout($.current),$.current=null),Q.current&&(clearTimeout(Q.current),Q.current=null)};return window.addEventListener("editor:discard-started",e),()=>{window.removeEventListener("editor:discard-started",e),e()}},[]),(0,r.useEffect)(()=>{if(!(null==T?void 0:T.isStreaming)||!B.current)return;let e=B.current.closest(".overflow-auto");if(!e)return;let t=B.current.getBoundingClientRect(),o=e.getBoundingClientRect(),n="top"===T.position||"replace"===T.position?e.scrollTop+t.top-o.top-24:e.scrollTop+t.top-o.top-o.height+t.height+100;e.scrollTo({top:Math.max(0,n),behavior:"smooth"})},[null==T?void 0:T.isStreaming,null==T?void 0:T.position,null==T?void 0:T.sectionId]),(0,r.useEffect)(()=>{var e,n;let r=(null==o?void 0:o.sections)||[];if(!(1===r.length&&(null==(e=r[0])?void 0:e.id)==="generating"&&(null==(n=r[0])?void 0:n.props)&&!0===r[0].props.isGenerating)||!l||!m)return;console.log("\uD83D\uDD04 AI generation in progress, polling for completion...");let i=setInterval(async()=>{try{let r=await fetch("/api/store/".concat(l)),s=await r.json();if(s.success&&s.store){let r=s.store.draftPages&&s.store.draftPages.length>0?s.store.draftPages:s.store.pages,a=null==r?void 0:r.find(e=>e.pageId===t);if(a&&a.sections){var e,o,n;1===a.sections.length&&(null==(e=a.sections[0])?void 0:e.id)==="generating"&&(null==(n=a.sections[0])||null==(o=n.props)?void 0:o.isGenerating)===!0?(F(e=>e+1),console.log("⏳ Still generating... (".concat(3*_,"s)"))):(console.log("✅ AI generation complete! Updating page..."),m({pageId:t,contentMode:a.contentMode||"custom",componentOverrides:a.componentOverrides||{},sections:a.sections||[],customCSS:a.customCSS||"",lastModified:a.lastModified?new Date(a.lastModified):new Date}),clearInterval(i))}}}catch(e){console.error("❌ Polling error:",e)}},3e3);return()=>{clearInterval(i)}},[o,l,t,m,_]),(0,r.useEffect)(()=>{if(!d&&!E||!X.current)return;let e=X.current,t=t=>{var o,n;if(!d&&!E)return;let r=t.target;if(r.closest("[data-quick-edit-panel]")||r.closest("[data-edit-controls]")||r.closest("[data-no-visual-edit]"))return;let i=["INPUT","TEXTAREA","SELECT"],s=i.includes(r.tagName)&&r.hasAttribute("data-prop-name");if(!s&&(i.includes(r.tagName)||"LABEL"===r.tagName||r.closest("label")&&(null==(o=r.closest("label"))?void 0:o.querySelector("input, textarea, select"))))return;"VIDEO"===r.tagName&&(console.log("\uD83C\uDFA5 Video element clicked, preventing default behavior"),t.preventDefault(),t.stopPropagation());let a=r.closest("[data-video-field]");t.stopPropagation(),a||t.preventDefault();let l=r,c=["A","BUTTON"],p=r,u=!1;for(let t=0;t<3&&p&&p!==e;t++){if(c.includes(p.tagName)){l=p,u=!0;break}p=p.parentElement}if(!u)if(("IMG"===l.tagName||"VIDEO"===l.tagName)&&l.id);else if(s);else{let t=["H1","H2","H3","H4","H5","H6","P","SPAN","LI","IMG","VIDEO","DIV","SECTION","UL","OL"];for(;l&&l!==e;){if(t.includes(l.tagName)){if("SPAN"===l.tagName&&!l.hasAttribute("data-prop-name")){l=l.parentElement;continue}break}l=l.parentElement}if(!l||l===e)return;if("DIV"===l.tagName&&!l.hasAttribute("data-prop-name")){let e=l.querySelectorAll("[data-prop-name]");if(1===e.length)l=e[0];else if(0===e.length){let e=null==(n=l.parentElement)?void 0:n.closest("[data-prop-name]");e&&(l=e)}}}if(!l.id){let e="auto-edit-".concat(l.tagName.toLowerCase(),"-").concat(Date.now(),"-").concat(Math.random().toString(36).substr(2,9));l.id=e,console.log("\uD83C\uDD94 Auto-generated ID for element:",l.tagName,"→",e)}let m=window.getComputedStyle(l),g=l.innerHTML||l.textContent||"",h=l instanceof HTMLAnchorElement?l.href:l.getAttribute("href")||l.getAttribute("data-href")||void 0;if(!h){let e=l.parentElement;for(;e&&e!==document.body;){if(e instanceof HTMLAnchorElement){h=e.href;break}let t=e.getAttribute("href")||e.getAttribute("data-href");if(t){h=t;break}e=e.parentElement}}let f=l instanceof HTMLImageElement||l instanceof HTMLVideoElement?l.src:l.getAttribute("src")||void 0,x=l.getAttribute("data-video-field")||void 0,b=l.getAttribute("data-background-position"),y=l.getAttribute("data-section-id")||void 0,v="true"===l.getAttribute("data-editable-icon"),w=l.getAttribute("data-feature-index"),N=w?parseInt(w,10):void 0,S=l.getAttribute("data-prop-name")||void 0,C={id:l.id,tagName:l.tagName.toLowerCase(),text:g,originalText:g,classes:l.className,originalClasses:l.className,href:h,originalHref:h,src:f,originalSrc:f,videoField:x,isBackgroun
1dImage:!!b,backgroundPosition:b,sectionId:y,isEditableIcon:v,featureIndex:N,propName:S,computedStyles:{fontSize:m.fontSize,fontFamily:m.fontFamily,color:m.color,backgroundColor:m.backgroundColor,fontWeight:m.fontWeight,textAlign:m.textAlign,padding:m.padding,paddingTop:m.paddingTop,paddingRight:m.paddingRight,paddingBottom:m.paddingBottom,paddingLeft:m.paddingLeft,margin:m.margin,marginTop:m.marginTop,marginRight:m.marginRight,marginBottom:m.marginBottom,marginLeft:m.marginLeft,lineHeight:m.lineHeight,letterSpacing:m.letterSpacing,textTransform:m.textTransform,textDecoration:m.textDecoration,display:m.display,flexDirection:m.flexDirection,justifyContent:m.justifyContent,alignItems:m.alignItems,gap:m.gap,rowGap:m.rowGap,columnGap:m.columnGap,gridTemplateColumns:m.gridTemplateColumns,opacity:m.opacity,borderWidth:m.borderWidth,borderColor:m.borderColor,borderRadius:m.borderRadius}};if(E&&j)return void j({id:C.id,tagName:C.tagName,text:C.text,classes:C.classes,computedStyles:{fontSize:C.computedStyles.fontSize,color:C.computedStyles.color,backgroundColor:C.computedStyles.backgroundColor}});console.log("✅ Setting selected element for QuickEditPanel:",C.tagName,C.id),V(C),Y(!1)};return e.addEventListener("click",t,!0),()=>{e.removeEventListener("click",t,!0)}},[d,E,j,null==o?void 0:o.sections]),(0,r.useEffect)(()=>{if(!d&&!E||!X.current)return;let e=X.current.querySelectorAll("video");return e.forEach(e=>{e.style.cursor="pointer",e.paused||e.pause()}),()=>{e.forEach(e=>{e.style.cursor=""})}},[d,E,null==o?void 0:o.sections]);let ee=(0,r.useCallback)((e,t,o)=>{console.log("\uD83D\uDCD0 handleElementResize called:",{elementId:e,width:t,height:o});let n=document.getElementById(e);if(!n)return void console.error("❌ Element not found for resize:",e);n.style.width="".concat(t,"px"),n.style.height="".concat(o,"px"),eo(e,{width:"".concat(t,"px"),height:"".concat(o,"px")})},[]),et=(0,r.useCallback)((e,t)=>{console.log("\uD83D\uDD24 handleFontResize called:",{elementId:e,newFontSize:t});let o=document.getElementById(e);if(!o)return void console.error("❌ Element not found for font resize:",e);o.style.setProperty("font-size","".concat(t,"px"),"important"),V(o=>o&&o.id===e?{...o,computedStyles:{...o.computedStyles,fontSize:"".concat(t,"px")}}:o),Q.current&&clearTimeout(Q.current);let n=Z.current;Q.current=setTimeout(()=>{Z.current===n&&N&&N(e,"fontSize","".concat(t,"px"))},150)},[N]),eo=async(e,n)=>{console.log("\uD83D\uDCBE handleQuickEditSave called:",{elementId:e,changes:n});let r=document.getElementById(e);if(!r)return void console.error("❌ Element not found in DOM:",e);if(console.log("✅ Element found:",r.tagName,r.className),void 0!==n.src&&("IMG"===r.tagName||"VIDEO"===r.tagName)){let e=r.getAttribute("data-image-editable")||r.getAttribute("data-video-editable");if(console.log("\uD83D\uDDBC️ ".concat(r.tagName," element found with editable ID:"),e),e&&(null==o?void 0:o.sections)){let t=r.closest("[data-section-id]");if(t){var s;let i=t.getAttribute("data-section-id");console.log("\uD83D\uDCCD Found section:",i);let a=o.sections.find(e=>e.id===i);if(a&&(null==(s=a.props)?void 0:s.editableFields)){let t=a.props.editableFields;if(t[e]){console.log("✏️ Updating editableField:",e,"with new src:",n.src);let s=o.sections.map(o=>o.id===i?{...o,props:{...o.props,editableFields:{...t,[e]:{...t[e],value:n.src}}}}:o);m&&m({...o,sections:s,lastModified:new Date}),U("/api/store/update-section",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({storeId:W.current,pageId:z.current,sectionId:i,updatedProps:{editableFields:{...t,[e]:{...t[e],value:n.src}}}})}).then(e=>e.json()).then(e=>{e.success?(console.log("✅ ".concat(r.tagName," editableField saved to database")),null==h||h()):console.error("❌ Failed to save ".concat(r.tagName," editableField:"),e.error)}).catch(e=>{console.error("❌ Error saving ".concat(r.tagName," editableField:"),e)})}}}}}void 0!==n.text&&null!==r.textContent&&(console.log("\uD83D\uDCDD Applying text change:",n.text),r.innerHTML=function(e){let t=e.replace(/<\/p>\s*<p>/gi,"<br><br>").replace(/^<p>/i,"").replace(/<\/p>$/i,"").replace(/<\/?p>/gi,"");return(0,i.a)(t)}(n.text)),void 0!==n.href&&(console.log("\uD83D\uDD17 Applying href change:",n.href),r instanceof HTMLAnchorElement?r.href=n.href:r.setAttribute("href",n.href)),void 0!==n.src&&(console.log("\uD83D\uDDBC️ Applying src change:",n.src),r instanceof HTMLImageElement||r instanceof HTMLVideoElement?r.src=n.src:r.setAttribute("src",n.src)),n.fontSize&&(console.log("\uD83D\uDCCF Applying fontSize:",n.fontSize),r.style.setProperty("font-size",n.fontSize,"important")),n.color&&(console.log("\uD83C\uDFA8 Applying color:",n.color),r.style.setProperty("color",n.color,"important")),n.backgroundColor&&(console.log("\uD83C\uDFA8 Applying backgroundColor:",n.backgroundColor),r.style.setProperty("background-image","none","important"),r.style.setProperty("background-color",n.backgroundColor,"important"),r.style.setProperty("background",n.backgroundColor,"important")),void 0!==n.padding&&(console.log("\uD83D\uDCE6 Applying padding:",n.padding),r.style.setProperty("padding",n.padding,"important")),void 0!==n.margin&&(console.log("\uD83D\uDCE6 Applying margin:",n.margin),r.style.setProperty("margin",n.margin,"important")),void 0!==n.paddingTop&&(console.log("\uD83D\uDCE6 Applying paddingTop:",n.paddingTop),r.style.setProperty("padding-top",n.paddingTop,"important")),void 0!==n.paddingRight&&(console.log("\uD83D\uDCE6 Applying paddingRight:",n.paddingRight),r.style.setProperty("padding-right",n.paddingRight,"important")),void 0!==n.paddingBottom&&(console.log("\uD83D\uDCE6 Applying paddingBottom:",n.paddingBottom),r.style.setProperty("padding-bottom",n.paddingBottom,"important")),void 0!==n.paddingLeft&&(console.log("\uD83D\uDCE6 Applying paddingLeft:",n.paddingLeft),r.style.setProperty("padding-left",n.paddingLeft,"important")),void 0!==n.marginTop&&(console.log("\uD83D\uDCE6 Applying marginTop:",n.marginTop),r.style.setProperty("margin-top",n.marginTop,"important")),void 0!==n.marginRight&&(console.log("\uD83D\uDCE6 Applying marginRight:",n.marginRight),r.style.setProperty("margin-right",n.marginRight,"important")),void 0!==n.marginBottom&&(console.log("\uD83D\uDCE6 Applying marginBottom:",n.marginBottom),r.style.setProperty("margin-bottom",n.marginBottom,"important")),void 0!==n.marginLeft&&(console.log("\uD83D\uDCE6 Applying marginLeft:",n.marginLeft),r.style.setProperty("margin-left",n.marginLeft,"important")),void 0!==n.width&&(console.log("\uD83D\uDCD0 Applying width:",n.width),r.style.setProperty("width",n.width,"important")),void 0!==n.height&&(console.log("\uD83D\uDCD0 Applying height:",n.height),r.style.setProperty("height",n.height,"important")),void 0!==n.borderWidth&&(console.log("\uD83D\uDD32 Applying borderWidth:",n.borderWidth),r.style.setProperty("border-width",n.borderWidth,"important"),r.style.borderStyle||r.style.setProperty("border-style","solid","important")),void 0!==n.borderColor&&(console.log("\uD83D\uDD32 Applying borderColor:",n.borderColor),r.style.setProperty("border-color",n.borderColor,"important")),void 0!==n.borderRadius&&(console.log("\uD83D\uDD32 Applying borderRadius:",n.borderRadius),r.style.setProperty("border-radius",n.borderRadius,"important")),void 0!==n.textAlign&&(console.log("\uD83D\uDCDD Applying textAlign:",n.textAlign),r.style.setProperty("text-align",n.textAlign,"important")),void 0!==n.fontFamily&&
1(console.log("\uD83D\uDCDD Applying fontFamily:",n.fontFamily),r.style.setProperty("font-family",n.fontFamily,"important")),void 0!==n.fontWeight&&(console.log("\uD83D\uDCDD Applying fontWeight:",n.fontWeight),r.style.setProperty("font-weight",n.fontWeight,"important")),void 0!==n.lineHeight&&(console.log("\uD83D\uDCDD Applying lineHeight:",n.lineHeight),r.style.setProperty("line-height",n.lineHeight,"important")),void 0!==n.letterSpacing&&(console.log("\uD83D\uDCDD Applying letterSpacing:",n.letterSpacing),r.style.setProperty("letter-spacing",n.letterSpacing,"important")),void 0!==n.textTransform&&(console.log("\uD83D\uDCDD Applying textTransform:",n.textTransform),r.style.setProperty("text-transform",n.textTransform,"important")),void 0!==n.textDecoration&&(console.log("\uD83D\uDCDD Applying textDecoration:",n.textDecoration),r.style.setProperty("text-decoration",n.textDecoration,"important")),void 0!==n.opacity&&(console.log("\uD83D\uDC41️ Applying opacity:",n.opacity),r.style.setProperty("opacity",n.opacity,"important")),void 0!==n.display&&(console.log("\uD83D\uDCD0 Applying display:",n.display),r.style.setProperty("display",n.display,"important")),void 0!==n.classes&&(r.className=n.classes),K([...q,{elementId:e,type:n.text&&(n.classes||n.fontSize||n.color||n.backgroundColor)?"both":n.text?"text":"style",oldValues:{text:null==J?void 0:J.text,classes:null==J?void 0:J.classes},newValues:n,timestamp:Date.now()}]);let a=r.closest("[data-section-id]");if(!a)return void console.warn("⚠️ Element is not within a section, cannot persist to database");let l=a.getAttribute("data-section-id");if(!l||!t)return void console.warn("⚠️ Missing required IDs for persisting visual edit");$.current&&clearTimeout($.current);let d=Z.current;$.current=setTimeout(async()=>{if(Z.current===d)try{var t,i,s,a,c,p;let d=void 0!==n.src&&("IMG"===r.tagName||"VIDEO"===r.tagName),u=r.hasAttribute("data-image-editable")||r.hasAttribute("data-video-editable");if(d&&u){console.log("ℹ️ Skipping save-visual-edit API for media src change (already saved via update-section)"),null==h||h();return}if(d&&!u&&r.hasAttribute("data-prop-name")){console.log("\uD83D\uDDBC️ Template component image change detected, updating prop directly");let a=r.getAttribute("data-prop-name");if(!a||!n.src)return void console.error("❌ Missing prop name or new src for template component image change");let d=null==o||null==(t=o.sections)?void 0:t.find(e=>e.id===l);if(!d)return void console.error("❌ Section not found for template component image change");let c=n.src;console.log("\uD83D\uDDBC️ Updating template component prop:",{propName:a,newImageUrl:c});try{let{[e]:t,...o}=(null==(i=d.props)?void 0:i.visualEdits)||{},n=await U("/api/store/update-section",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({storeId:W.current,pageId:z.current,sectionId:l,updatedProps:{[a]:c,visualEdits:o}})}),r=await n.json();if(r.success){console.log("✅ Template component prop updated successfully");let e=H.current;if(m&&e){let t=(null==(s=e.sections)?void 0:s.map(e=>e.id===l?{...e,props:{...e.props,[a]:c,visualEdits:o}}:e))||[];m({...e,sections:t,lastModified:new Date})}null==h||h()}else console.error("❌ Failed to update template component prop:",r.error)}catch(e){console.error("❌ Error updating template component prop:",e)}return}let g=r.hasAttribute("data-pill-id")?r:r.closest("[data-pill-id]");if(void 0!==n.text&&g){console.log("\uD83D\uDC8A Pill text change detected, updating popularSearches array");let e=g.getAttribute("data-pill-id");if(!e)return void console.error("❌ Missing pill ID for pill text change");let t=null==o||null==(a=o.sections)?void 0:a.find(e=>e.id===l);if(!t)return void console.error("❌ Section not found for pill text change");let r=(null==(c=t.props)?void 0:c.popularSearches)||[],i=n.text,s=r.map(t=>t.id===e?{...t,label:i,query:i}:t);console.log("\uD83D\uDC8A Updating pill text:",{pillId:e,newText:i,updatedSearches:s});try{let e=await U("/api/store/update-section",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({storeId:W.current,pageId:z.current,sectionId:l,updatedProps:{popularSearches:s}})}
1),t=await e.json();if(t.success){console.log("✅ Pill text updated successfully");let e=H.current;if(m&&e){let t=(null==(p=e.sections)?void 0:p.map(e=>e.id===l?{...e,props:{...e.props,popularSearches:s}}:e))||[];m({...e,sections:t,lastModified:new Date})}null==h||h()}else console.error("❌ Failed to update pill text:",t.error)}catch(e){console.error("❌ Error updating pill text:",e)}return}if(!r.hasAttribute("data-prop-name"))return void console.warn('[DynamicPageRenderer] Element "'.concat(e,'" has no data-prop-name. ')+"Style changes will not be saved to visualEdits. Please audit this component.");console.log('[DynamicPageRenderer] Element "'.concat(e,'" has data-prop-name="').concat(r.getAttribute("data-prop-name"),'". ')+"Style changes should be handled by action system."),null==h||h()}catch(e){console.error("❌ Error persisting visual edit:",e)}},500)},en=(e,t)=>{if(!e||!t)return;let o=document.getElementById(t)||e,n=o.querySelectorAll("[id]"),r=Array.from(n).filter(e=>!((e,t)=>{let o=e;for(;o&&o!==t;){if("none"===window.getComputedStyle(o).display)return!0;o=o.parentElement}return!1})(e,o));console.log("\uD83D\uDD0D Component ".concat(t,": ").concat(r.length,"/").concat(n.length," elements visible")),0===r.length&&n.length>0&&(console.log("\uD83D\uDDD1️ All elements hidden in component ".concat(t,", auto-deleting component...")),setTimeout(()=>{ep(t)},100))},er=e=>{var t,o,n,r,i,s;console.log("\uD83D\uDDD1️ handleElementDelete called:",e);let a=document.getElementById(e);if(!a)return void console.error("❌ Element not found in DOM:",e);let l=a.getAttribute("data-section-id");if(l&&a.id===l){console.log("\uD83C\uDFAF Element is a template component wrapper, deleting entire section:",l),ep(l);return}if(a.hasAttribute("data-collapsed-section-placeholder")){l&&ep(l);return}let d=a.closest("[data-section-id]"),c=null==d?void 0:d.getAttribute("data-section-id"),p=a.getAttribute("data-prop-name");if(p&&c){console.log("\uD83C\uDFAF Element has data-prop-name, using action system:",{elementId:e,propName:p,sectionId:c}),a.style.setProperty("display","none","important");let i=function(e){let t=(0,eG.iN)(e);return t[t.length-1]="".concat(t[t.length-1],"Styles"),t}(p);if(i.length>1){let e=(null==(n=H.current)||null==(o=n.sections)||null==(t=o.find(e=>e.id===c))?void 0:t.props)||{},r=(0,eG.A6)(e,i.slice(0,-1));r&&"object"==typeof r||(i=["".concat(p,"Styles")])}let s=i.join("."),l={...(()=>{var e,t,o;let n=(null==(o=H.current)||null==(t=o.sections)||null==(e=t.find(e=>e.id===c))?void 0:e.props)||{},r=(0,eG.A6)(n,i);return{...(i.length>1?n[s]:void 0)||{},...r||{}}})(),display:"none"},u=H.current;if(m&&u){let e=(null==(r=u.sections)?void 0:r.map(e=>{if(e.id===c){let t=function(e,t,o){let n={...e},r=n;for(let e=0;e<t.length-1;e++){let o=t[e],n=r[o],i=/^\d+$/.test(t[e+1]),s=Array.isArray(n)?[...n]:n&&"object"==typeof n?{...n}:i?[]:{};r[o]=s,r=s}return r[t[t.length-1]]=o,n}(e.props||{},i,l);return i.length>1&&delete t[s],{...e,props:t}}return e}))||[];m({...u,sections:e,lastModified:new Date})}null==h||h(),W.current&&z.current&&U("/api/store/update-section",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({storeId:W.current,pageId:z.current,sectionId:c,updatedProps:{[s]:l}})}).then(e=>e.json()).then(e=>{e.success?console.log("✅ Element hide persisted via action system"):console.error("❌ Failed to persist element hide:",e.error)}).catch(e=>{console.error("❌ Error persisting element hide:",e)}),console.log("✅ Element hidden via action system (no flickering on reload)."),V(null),en(d,c);return}let u=e.match(/^auto-id-/),g=e.match(/-el-\d+$/);if(u||g){console.warn('[DEPRECATED] Legacy element hide using visualEdits: "'.concat(e,'". ')+"This will cause flickering on reload. Please audit this component and add data-prop-name."),a.style.setProperty("display","none","important");let t=H.current;if(m&&t&&c){let o=(null==(i=t.sections)?void 0:i.map(t=>{if(t.id===c){var o;let n=(null==(o=t.props)?void 0:o.visualEdits)||{};return{...t,props:{...t.props,visualEdits:{...n,[e]:{...n[e]||{},display:"none",timestamp:Date.now()}}}}}return t}))||[];m({...t,sections:o,lastModified:new Date})}null==h||h(),c&&W.current&&z.current&&U("/api/store/save-visual-edit",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({storeId:W.current,pageId:z.current,sectionId:c,elementId:e,styleChanges:{display:"none"}})}).then(e=>e.json()).then(e=>
1{e.success?console.log("✅ Element deletion persisted to database (legacy visualEdits)"):console.error("❌ Failed to persist element deletion:",e.error)}).catch(e=>{console.error("❌ Error persisting element deletion:",e)});let o={elementId:e,type:"style",oldValues:{classes:a.className},newValues:{},timestamp:Date.now()};K(e=>[...e,o]),h&&h(),console.log("✅ Element hidden (legacy). Changes saved to draft."),V(null),en(d,c);return}console.warn('[DEPRECATED] Fallback element hide using visualEdits: "'.concat(e,'". ')+"This will cause flickering on reload. Please audit this component and add data-prop-name."),a.style.setProperty("display","none","important");let f=H.current;if(m&&f&&c){let t=(null==(s=f.sections)?void 0:s.map(t=>{if(t.id===c){var o;let n=(null==(o=t.props)?void 0:o.visualEdits)||{};return{...t,props:{...t.props,visualEdits:{...n,[e]:{...n[e]||{},display:"none",timestamp:Date.now()}}}}}return t}))||[];m({...f,sections:t,lastModified:new Date})}null==h||h(),c&&W.current&&z.current&&U("/api/store/save-visual-edit",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({storeId:W.current,pageId:z.current,sectionId:c,elementId:e,styleChanges:{display:"none"}})}).then(e=>e.json()).then(e=>{e.success&&console.log("✅ Fallback element deletion persisted to database")}).catch(e=>{console.error("❌ Error persisting fallback element deletion:",e)});let x={elementId:e,type:"style",oldValues:{classes:a.className},newValues:{},timestamp:Date.now()};K(e=>[...e,x]),console.log("✅ Element hidden. Changes saved to draft."),V(null),en(d,c)};if((0,r.useEffect)(()=>{window&&(window.clearPendingVisualChanges=()=>{console.log("\uD83E\uDDF9 Clearing pending visual changes after publish"),K([])})},[]),!d&&(null==o?void 0:o.sections)){let e=new Map;o.sections.forEach(t=>{e.has(t.id)||e.set(t.id,t)});let t=Array.from(e.values());return t.length!==o.sections.length&&console.warn("⚠️ Found ".concat(o.sections.length-t.length," duplicate sections, filtered to ").concat(t.length," unique")),(0,n.jsxs)("div",{className:"dynamic-page",style:A?{fontFamily:A}:void 0,children:[o.customCSS&&(0,n.jsx)("style",{dangerouslySetInnerHTML:{__html:(0,i.L)(o.customCSS)}}),[...t].filter(e=>!e.hidden).sort((e,t)=>e.order-t.order).map(e=>{var t;return"ai-generated"===e.type&&(null==(t=e.props)?void 0:t.htmlStructure)?(0,n.jsx)(eg,{sectionId:e.id,htmlStructure:e.props.htmlStructure,editableFields:e.props.editableFields||{},visualEdits:e.props.visualEdits||{},onFieldUpdate:()=>{},isEditMode:!1},e.id):"template-component"===e.type?(0,n.jsx)(eK,{section:e,onNavigate:v,storeId:l,storeSlug:b,isCustomDomain:y,selectedDevice:a,themePrimaryColor:I,cartEnabled:R,storeLanguage:L,emojiReactionsEnabled:k,showWishlistOnCard:D,enableWishlistFolders:M,wishlistMultiFolder:O,wishlistIcon:P},e.id):null})]})}let ei=async(e,n,r,i)=>{if(!t)return void console.error("❌ No page ID - cannot save component");if(!o)return void console.error("❌ No customization - cannot add component");console.log("\uD83C\uDFAF Dropping component at position:",i);let s={id:"".concat(n,"-").concat(Date.now()),type:"template-component",templateId:e,order:i,props:JSON.parse(JSON.stringify(r))};if(m){let e=[...o.sections||[]];e.sort((e,t)=>e.order-t.order),e.splice(i,0,s);let t=e.map((e,t)=>({...e,order:t})),n={...o,sections:t,lastModified:new Date};console.log("⚡ Optimistic update: Showing component at position",i,"with",t.length,"total sections"),m(n),h&&h()}try{let e=await U("/api/store/add-component",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({storeId:W.current,pageId:z.current,section:s})}),t=await e.json();if(t.success)console.log("✅ Component saved to database");else if(console.error("❌ Failed to save component:",t.error),m){let e=(o.sections||[]).filter(e=>
1e.id!==s.id);m({...o,sections:e})}}catch(e){if(console.error("❌ Error saving component:",e),m){let e=(o.sections||[]).filter(e=>e.id!==s.id);m({...o,sections:e})}}},es=async e=>{var t;if(!o)return void console.error("❌ Missing customization for duplicate");let n=H.current,r=null==n||null==(t=n.sections)?void 0:t.find(t=>t.id===e);if(!r||!n)return void console.error("❌ Source section not found for duplicate:",e);let i="".concat(r.type||"component","-").concat(Date.now(),"-").concat(Math.random().toString(36).substring(7)),s=r.order,a="function"==typeof structuredClone?structuredClone(r):JSON.parse(JSON.stringify(r)),l={...n,sections:[...(n.sections||[]).map(e=>e.order>s?{...e,order:e.order+1}:e),{...a,id:i,order:s+1,name:a.name?"".concat(a.name," (Copy)"):void 0}].sort((e,t)=>e.order-t.order)};null==m||m(l),null==h||h();try{let t=await U("/api/store/duplicate-component",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({componentId:e,storeId:W.current,pageId:z.current,insertAfterId:e,newSectionId:i})}),o=await t.json();if(!t.ok||!o.success)throw Error(o.error||"Failed to duplicate component")}catch(e){console.error("❌ Failed to duplicate section:",e),null==m||m(n)}},ea=e=>{var t,o;let n=null==(o=H.current)||null==(t=o.sections)?void 0:t.find(t=>t.id===e);if(!(null==n?void 0:n.props))return 0;let r=0;for(let[e,t]of Object.entries(n.props))if(e.endsWith("Styles")&&t&&"object"==typeof t&&"none"===t.display&&r++,Array.isArray(t)){for(let e of t)if(e&&"object"==typeof e)for(let[t,o]of Object.entries(e))t.endsWith("Styles")&&o&&"object"==typeof o&&"none"===o.display&&r++}let i=n.props.visualEdits;return i&&(r+=Object.values(i).filter(e=>e&&"object"==typeof e&&"none"===e.display).length),r},el=e=>{var t,o;let n=null==(o=H.current)||null==(t=o.sections)?void 0:t.find(t=>t.id===e);return n&&(n.name||n.templateId||n.type)||null},ec=e=>{var t,o;let n=H.current,r=null==n||null==(t=n.sections)?void 0:t.find(t=>t.id===e);if(!(null==r?void 0:r.props)||!n)return;let i={},s=[];for(let[e,t]of Object.entries(r.props)){if(e.endsWith("Styles")&&t&&"object"==typeof t&&"none"===t.display){let o={...t};delete o.display,i[e]=o,s.push(e.slice(0,-6))}if(Array.isArray(t)){let o=!1,n=t.map((t,n)=>{if(!t||"object"!=typeof t)return t;let r=!1,i={...t};for(let[t,o]of Object.entries(i))if(t.endsWith("Styles")&&o&&"object"==typeof o&&"none"===o.display){let a={...o};delete a.display,i[t]=a,s.push("".concat(e,".").concat(n,".").concat(t.slice(0,-6))),r=!0}return r&&(o=!0),r?i:t});o&&(i[e]=n)}}let a=r.props.visualEdits,l=[];if(a){let e={};for(let[t,o]of Object.entries(a))if(o&&"object"==typeof o&&"none"===o.display){let n={...o};delete n.display,e[t]=n,l.push(t)}else e[t]=o;l.length>0&&(i.visualEdits=e)}if(0===s.length&&0===l.length)return;let d=(null==(o=n.sections)?void 0:o.map(t=>t.id===e?{...t,props:{...t.props,...i}}:t))||[];null==m||m({...n,sections:d,lastModified:new Date}),null==h||h();let c=document.getElementById(e);s.forEach(e=>{let t=(null==c?void 0:c.getAttribute("data-prop-name"))===e?c:null==c?void 0:c.querySelector('[data-prop-name="'.concat(CSS.escape(e),'"]'));null==t||t.style.removeProperty("display")}),l.forEach(e=>{var t;null==(t=document.getElementById(e))||t.style.removeProperty("display")}),W.current&&z.current&&U("/api/store/update-section",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({storeId:W.current,pageId:z.current,sectionId:e,updatedProps:i})}).then(e=>e.json()).then(e=>{e.success||console.error("❌ Failed to persist hidden-element restore:",e.error)}).catch(e=>{console.error("❌ Error persisting hidden-element restore:",e)})},ep=async e=>{if(console.log("\uD83D\uDDD1️ Section delete:",{sectionId:e}),!o)return void console.error("❌ Missing customization");null==g||g(e),V(null);let t=H.current;if(m&&(null==t?void 0:t.sections)){let o=[...t.sections.filter(t=>t.id!==e)].sort((e,t)=>e.order-t.order).map((e,t)=>({...e,order:t}));m({...t,sections:o}),h&&h()}try{let t=await U("/api/store/delete-section",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({storeId:W.current,pageId:z.current,sectionId:e})}),o=await t.json();if(o.success)console.log("✅ Section deleted successfully from database"),h&&h();else throw Error(o.error||"Failed to delete section")}catch(e){console.error("❌ Failed to delete section from database:",e)}},eh=async(e,t)=>{console.log("\uD83D\uDD35 Section update:",{sectionId:e,updatedProps:t});let o=H.current;if(!o)return void console.error("❌ Missing customization");if(m&&o.sections){let n=o.sections.map(o=>o.id===e?{...o,props:{...o.props,...t}}
1:o),r={...o,sections:n};H.current=r,m(r),null==h||h()}try{let o=await U("/api/store/update-section",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({storeId:W.current,pageId:z.current,sectionId:e,updatedProps:t})}),n=await o.json();if(n.success)console.log("✅ Section updated successfully in database"),h&&h();else throw Error(n.error||"Failed to update section")}catch(e){console.error("❌ Failed to update section in database:",e)}},ef=async e=>{let t=H.current;if(!(null==t?void 0:t.sections))return;let o=t.sections.find(t=>t.id===e);if(!o)return;let n=!o.hidden;V(null);let r=o=>{if(!m)return;let n=H.current||t,r={...n,sections:(n.sections||[]).map(t=>t.id===e?{...t,hidden:o}:t)};H.current=r,m(r),null==h||h()};r(n);try{let t=await U("/api/store/update-section",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({storeId:W.current,pageId:z.current,sectionId:e,hidden:n})}),o=await t.json();if(!o.success)throw Error(o.error||"Failed to update section");null==h||h()}catch(e){console.error("❌ Failed to toggle section visibility:",e),r(!n),alert("Could not ".concat(n?"hide":"show"," the component. Please try again."))}},ex=e=>{var t,o,n;return!!(null==(n=H.current)||null==(o=n.sections)||null==(t=o.find(t=>t.id===e))?void 0:t.hidden)},eb=e=>{console.log("\uD83D\uDD27 Section edit:",{sectionId:e}),alert("Edit functionality for section ".concat(e," - modal coming soon!"))};if(!o)return(0,n.jsx)("div",{className:"p-6 text-center",children:(0,n.jsx)("p",{className:"text-gray-500",children:"No customization data available"})});if("template"===o.contentMode)return["products","cart","checkout"].includes(t)?(0,n.jsx)("div",{className:"min-h-screen flex items-center justify-center bg-base-100",children:(0,n.jsxs)("div",{className:"text-center max-w-md p-8",children:[(0,n.jsx)("div",{className:"text-6xl mb-4",children:"\uD83D\uDECD️"}),(0,n.jsx)("h2",{className:"text-2xl font-bold text-base-content mb-3",children:"E-commerce Page"}),(0,n.jsx)("p",{className:"text-base-content/60 mb-6",children:"This page is a functional e-commerce template with database integration. View it on the live storefront to see it in action."}),(0,n.jsx)("a",{href:"/s/".concat(l,"/").concat(t),target:"_blank",rel:"noopener noreferrer",className:"btn btn-primary",children:"View on Storefront →"})]})}):(0,n.jsx)("div",{className:"min-h-screen flex items-center justify-center bg-base-100",children:(0,n.jsxs)("div",{className:"text-center max-w-md p-8",children:[(0,n.jsx)("div",{className:"text-6xl mb-4",children:"✨"}),(0,n.jsx)("h2",{className:"text-2xl font-bold text-base-content mb-3",children:"Ready for AI Content"}),(0,n.jsx)("p",{className:"text-base-content/60 mb-6",children:"This page is ready to be customized with AI-generated content. Use the chat interface to add sections and components."})]})});if("hybrid"===o.contentMode){let e=o.sections||[],t=new Map;e.forEach(e=>{t.has(e.id)||t.set(e.id,e)});let c=Array.from(t.values());c.length!==e.length&&console.warn("⚠️ [Hybrid] Found ".concat(e.length-c.length," duplicate sections, filtered to ").concat(c.length," unique"));let u=[...c].filter(e=>d||!e.hidden).sort((e,t)=>e.order-t.order);return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("div",{className:"dynamic-page",ref:X,style:A?{fontFamily:A}:void 0,children:[o.customCSS&&(0,n.jsx)("style",{dangerouslySetInnerHTML:{__html:(0,i.L)(o.customCSS)}}),d&&(0,n.jsx)(eu,{position:0,onDrop:ei,isVisible:!0},"dropzone-0"),(null==T?void 0:T.isStreaming)&&"top"===T.position&&(0,n.jsx)("div",{ref:B,className:"py-8",children:(0,n.jsx)(s,{progress:T.progress,text:T.text})}),u.map((e,t)=>(0,n.jsx)(r.Fragment,{children:(0,n.jsxs)(eY,{active:(null==T?void 0:T.isStreaming)===!0&&"replace"===T.position&&T.sectionId===e.id,progress:T,skeletonRef:B,children:[d&&p?(0,n.jsx)(eA,{section:e,onReorder:p,onDelete:ep,onToggleHidden:ef,onMoveUp:t>0?()=>p(e.id,u[t-1].id,"before"):void 0,onMoveDown:t<u.length-1?()=>p(e.id,u[t+1].id,"after"):void 0,isEditing:d,children:(0,n.jsx)(eK,{section:e,isEditMode:d,onSectionUpdate:eh,onSectionDelete:ep,onSectionEdit:eb,onComponentReorder:p,onNavigate:v,storeId:l,storeSlug:b,isCustomDomain:y,selectedDevice:a,themePrimaryColor:I,cartEnabled:R,storeLanguage:L})}):(0,n.jsx)(eK,{section:e,onNavigate:v,storeId:l,storeSlug:b,isCustomDomain:y,themePrimaryColor:I,selectedDevice:a,cartEnabled:R,storeLanguage:L,emojiReactionsEnabled:k,showWishlistOnCard:D,enableWishlistFolders:M,wishlistMultiFolder:O,wishlistIcon:P}),d&&(0,n.jsx)(eu,{position:t+1,onDrop:ei,isVisible:!0},"dropzone-".concat(t+1))]})},e.id)),(null==T?void 0:T.isStreaming)&&"top"!==T.position&&"replace"!==T.position&&(0,n.jsx)("div",{ref:B,className:"py-8",children:(0,n.jsx)(s,{progress:T.progress,text:T.text})})]}),d&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(eO,{containerRef:X,selectedElementId:null==J?void 0:J.id,isActive:d,onResize:ee,onFontResize:et,refreshTrigger:C}),J&&(0,n.jsx)(eW,{selectedElementId:J.id,onEdit:()=>{null==S||S()},onAIEdit:()=>{window.dispatchEvent(new Event("expandInlineChat"))},onClose:()=>V(null)}),(0,n.jsx)(eV,{onDeleteElement:er,onDeleteSection:ep,onDuplicateSection:es,onToggleSectionHidden:ef,isSectionHidden:ex,onRestoreHiddenElements:ec,getHiddenElementCount:ea,getSectionName:el,isEditMode:d})]})]})}if("custom"===o.contentMode){var ey,ev,eE;let e=o.sections||[],u=new Map;
1e.forEach(e=>{u.has(e.id)||u.set(e.id,e)});let m=Array.from(u.values());if(m.length!==e.length&&console.warn("⚠️ [Custom] Found ".concat(e.length-m.length," duplicate sections, filtered to ").concat(m.length," unique")),1===m.length&&(null==(ey=m[0])?void 0:ey.id)==="generating"&&(null==(ev=m[0])?void 0:ev.props)&&!0===m[0].props.isGenerating){let e=null==(eE=m[0].props)?void 0:eE.generatingMessage,o=c||e,r=(()=>{if(f){if(""===f||"frontpage"===f)return"Homepage";if("about"===f)return"About Page";if("contact"===f)return"Contact Page"}return"frontpage"===t?"Homepage":"about"===t?"About Page":"contact"===t?"Contact Page":x||"Page"})();return(0,n.jsx)("div",{className:"min-h-screen flex items-center justify-center bg-gradient-to-br from-primary/5 to-secondary/5",children:(0,n.jsxs)("div",{className:"text-center max-w-md p-8",children:[(0,n.jsx)("div",{className:"relative mb-6",children:(0,n.jsx)("div",{className:"w-20 h-20 mx-auto bg-gradient-to-br from-primary to-secondary rounded-full flex items-center justify-center animate-pulse",children:(0,n.jsx)("svg",{className:"w-10 h-10 text-white animate-spin",style:{animationDuration:"3s"},fill:"none",viewBox:"0 0 24 24",children:(0,n.jsx)("path",{fill:"currentColor",d:"M12 2L15.09 8.26L22 9.27L17 14.14L18.18 21.02L12 17.77L5.82 21.02L7 14.14L2 9.27L8.91 8.26L12 2Z"})})})}),(0,n.jsxs)("h2",{className:"text-2xl font-bold text-base-content mb-3",children:["✨ Crafting Your ",r]}),(0,n.jsx)("p",{className:"text-base-content/60 mb-4 text-lg font-medium",children:o?o.split(/(\*\*.*?\*\*)/).map((e,t)=>e.startsWith("**")&&e.endsWith("**")?(0,n.jsx)("span",{className:"text-primary font-bold",children:e.slice(2,-2)},t):(0,n.jsx)("span",{children:e},t)):"AI is designing a beautiful, tailored ".concat(r.toLowerCase()," for your store...")}),(0,n.jsxs)("div",{className:"flex items-center justify-center gap-2 mb-6",children:[(0,n.jsx)("div",{className:"w-2 h-2 bg-primary rounded-full animate-bounce"}),(0,n.jsx)("div",{className:"w-2 h-2 bg-primary rounded-full animate-bounce",style:{animationDelay:"0.2s"}}),(0,n.jsx)("div",{className:"w-2 h-2 bg-primary rounded-full animate-bounce",style:{animationDelay:"0.4s"}})]}),o?(0,n.jsx)("p",{className:"text-sm text-base-content/50",children:"Hang tight! Your marketplace is being crafted with AI magic ✨"}):(0,n.jsx)("p",{className:"text-sm text-base-content/50",children:"This usually takes 30-60 seconds. Feel free to explore other pages!"})]})})}if(0===m.length)return(0,n.jsx)("div",{className:"bg-gray-50 min-h-screen",children:(0,n.jsx)("div",{className:"p-12 text-center flex items-center justify-center min-h-screen",children:(0,n.jsxs)("div",{children:[(0,n.jsx)("h2",{className:"text-2xl font-semibold text-gray-900 mb-4",children:"Empty Canvas"}),(0,n.jsx)("p",{className:"text-gray-600 mb-6",children:"Start by describing what you'd like to create!"}),(0,n.jsx)("div",{className:"text-sm text-gray-500 mb-8",children:'Try: "Create a hero section with a call-to-action" or "Add a product grid"'}),d&&(0,n.jsx)(eu,{position:0,onDrop:ei,isVisible:!0,label:"Drop component here to start building"},"dropzone-empty-canvas")]})})});let g=[...m].filter(e=>d||!e.hidden).sort((e,t)=>e.order-t.order);return(0,n.jsxs)(n.Fragment,{children:[E&&(0,n.jsxs)("div",{className:"fixed top-4 left-1/2 transform -translate-x-1/2 z-50 bg-blue-600 text-white px-6 py-3 rounded-lg shadow-lg flex items-center gap-3 animate-pulse",children:[(0,n.jsx)("span",{className:"text-2xl",children:"\uD83C\uDFAF"}),(0,n.jsxs)("div",{children:[(0,n.jsx)("div",{className:"font-semibold",children:"Selection Mode Active"}),(0,n.jsx)("div",{className:"text-sm opacity-90",children:"Click any element to edit it"})]})]}),(0,n.jsxs)("div",{className:"dynamic-page",ref:X,style:A?{fontFamily:A}:void 0,children:[o.customCSS&&(0,n.jsx)("style",{dangerouslySetInnerHTML:{__html:(0,i.L)(o.customCSS)}}),d&&(0,n.jsx)(eu,{position:0,onDrop:ei,isVisible:!0},"dropzone-custom-0"),(null==T?void 0:T.isStreaming)&&"top"===T.position&&(0,n.jsx)("div",{ref:B,className:"py-8",children:(0,n.jsx)(s,{progress:T.progress,text:T.text})}),g.map((e,t)=>(0,n.jsx)(r.Fragment,{children:(0,n.jsxs)(eY,{active:(null==T?void 0:T.isStreaming)===!0&&"replace"===T.position&&T.sectionId===e.id,progress:T,skeletonRef:B,children:[d&&p?(0,n.jsx)(eA,{section:e,onReorder:p,onDelete:ep,onToggleHidden:ef,onMoveUp:t>0?()=>p(e.id,g[t-1].id,"before"):void 0,onMoveDown:t<g.length-1?()=>p(e.id,g[t+1].id,"after"):void 0,isEditing:d,children:(0,n.jsx)(eK,{section:e,isEditMode:d,onSectionUpdate:eh,onSectionDelete:ep,onSectionEdit:eb,onComponentReorder:p,onNavigate:v,storeId:l,storeSlug:b,isCustomDomain:y,selectedDevice:a,themePrimaryColor:I,cartEnabled:R,storeLanguage:L})}):(0,n.jsx)(eK,{section:e,onNavigate:v,storeId:l,storeSlug:b,isCustomDomain:y,themePrimaryColor:I,selectedDevice:a,cartEnabled:R,storeLanguage:L,emojiReactionsEnabled:k,showWishlistOnCard:D,enableWishlistFolders:M,wishlistMultiFolder:O,wishlistIcon:P}),d&&(0,n.jsx)(eu,{position:t+1,onDrop:ei,isVisible:!0},"dropzone-custom-".concat(t+1))]})},e.id)),(null==T?void 0:T.isStreaming)&&"top"!==T.position&&"replace"!==T.position&&(0,n.jsx)("div",{ref:B,className:"py-8",children:(0,n.jsx)(s,{progress:T.progress,text:T.text})})]}),d&&(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(eO,{containerRef:X,selectedElementId:null==J?void 0:J.id,isActive:d,onResize:ee,onFontResize:et,refreshTrigger:C}),J&&(0,n.jsx)(eW,{selectedElementId:J.id,onEdit:()=>{null==S||S()},onAIEdit:()=>{window.dispatchEvent(new Event("expandInlineChat"))},onClose:()=>V(null)}),(0,n.jsx)(eV,{onDeleteElement:er,onDeleteSection:ep,onDuplicateSection:es,onToggleSectionHidden:ef,isSectionHidden:ex,onRestoreHiddenElements:ec,getHiddenElementCount:ea,getSectionName:el,isEditMode:d})]})]})}return(0,n.jsxs)("div",{className:"p-6 text-center",children:[(0,n.jsx)("h2",{className:"text-xl font-semibold text-red-600",children:"Invalid Content Mode"}),(0,n.jsxs)("p",{className:"text-gray-600",children:["Unknown content mode: ",o.contentMode]})]})}function eK(e){let{section:t,isEditMode:o,onSectionUpdate:r,onSectionDelete:i,onNavigate:s,storeId:a,storeSlug:l,isCustomDomain:d,selectedDevice:c,themePrimaryColor:p,cartEnabled:u,storeLanguage:m,emojiReactionsEnabled:g,showWishlistOnCard:h,enableWishlistFolders:f,wishlistMultiFolder:x,wishlistIcon:b}=e;try{if("ai-generated"===t.type&&"freeform"===t.templateId)return(0,n.jsx)(eb,{section:t,isEditMode:o,onSectionUpdate:r,onSectionDelete:i,onNavigate:s,selectedDevice:c,storeId:a});if("template-component"===t.type&&"canvas"===t.templateId)return(0,n.jsx)(el,{sectionId:t.id,props:t.props,isEditMode:o,onPropsUpdate:r,storeId:a,storeSlug:l,isCustomDomain:d,storeLanguage:m,cartEnabled:u,showWishlistOnCard:h,enableWishlistFolders:f,wishlistMultiFolder:x,wishlistIcon:b});if("template-component"===t.type){var y;return(0,n.jsx)(ek,{componentType:t.templateId||"",componentId:t.id,props:t.props||{},isEditMode:o,onPropsUpdate:r,onDelete:i,storeId:a,storeSlug:l,isCustomDomain:d,visualEdits:(null==(y=t.props)?void 0:y.visualEdits)||{},sectionId:t.id,themePrimaryColor:p,cartEnabled:u,storeLanguage:m,emojiReactionsEnabled:g,showWishlistOnCard:h,enableWishlistFolders:f,wishlistMultiFolder:x,wishlistIcon:b})}if("product-catalog"===t.type)return(0,n.jsx)("div",{className:"bg-gray-50 py-24",children:(0,n.jsx)("div",{className:"max-w-7xl mx-auto px-6",children:(0,n.jsxs)("div",{className:"text-center mb-12",children:[(0,n.jsx)("h2",{className:"text-4xl font-bold text-gray-900 mb-4",children:"Product Catalog"}),(0,n.jsx)("p",{className:"text-gray-600",children:"Dynamic product catalog coming in Phase 2"}),(0,n.jsx)("p",{className:"text-sm text-gray-500 mt-4",children:"This will display products from your database"})]})})});return(0,n.jsxs)("div",{className:"p-4 border border-gray-300 bg-gray-50",children:[(0,n.jsxs)("p",{className:"text-gray-800",children:["Unknown section type: ",t.type]}),(0,n.jsxs)("p",{className:"text-sm text-gray-600",children:["Template ID: ",t.templateId]})]})}catch(e){return console.error("Error rendering section:",e),(0,n.jsxs)("div",{className:"p-4 border border-red-300 bg-red-50",children:[(0,n.jsx)("p",{className:"text-red-800",children:"Error rendering section"}),(0,n.jsxs)("details",{className:"mt-2",children:[(0,n.jsx)("summary",{className:"cursor-pointer text-sm",children:"Show error details"}),(0,n.jsx)("pre",{className:"text-xs mt-2 overflow-auto",children:e instanceof Error?e.message:String(e)})]})]})}}},42949:(e,t,o)=>{function n(e){let t=document.getElementById(e);if(!t)return[];let o=null;for(let e=t.parentElement;e;e=e.parentElement)e.hasAttribute("data-section-id")&&(o=e);let n=[],r=t.parentElement;for(;r&&o&&(r===o||o.contains(r));)r.hasAttribute("data-prop-name")&&!r.hasAttribute("data-no-visual-edit")&&n.push(r),r=r.parentElement;return n}function r(e){e.dispatchEvent(new MouseEvent("click",{bubbles:!0,cancelable:!0}))}function i(e){let[t]=n(e);return!!t&&(r(t),!0)}function s(e){let t=e.getAttribute("data-prop-name")||"",o=t.split(".").filter(
1Boolean).pop()||"",n=e.getAttribute("data-node-type");return"sectionWrapper"===t?"Section":n||("container"===o?e.tagName.toLowerCase():o)}o.d(t,{A2:()=>s,Zc:()=>i,hy:()=>n,sc:()=>r})},73728:(e,t,o)=>{function n(e){let t=e.id;if(!t)return console.warn("[prop-mapping] Element has no ID:",e),null;let o=e.getAttribute("data-prop-name");if(!o)return console.warn("[prop-mapping] Element has no data-prop-name:",t),null;let n=function(e){let t=e.getAttribute("data-section-id");if(t)return t;let o=e.closest("[data-section-id]");return o?o.getAttribute("data-section-id"):null}(e);return(n||(n=function(e,t){for(let o of["-".concat(t.toLowerCase()),"-".concat(t),"-title","-subtitle","-btn-primary","-btn-secondary","-btn-search","-popular-label","-bg-image","-image","-video"])if(e.endsWith(o))return e.slice(0,-o.length);let o=e.match(/^(.+?-section-\d+|section-[^-]+-\d+)/);return o?o[1]:null}(t,o)),n)?{sectionId:n,propName:o,elementId:t}:(console.warn("[prop-mapping] Could not determine sectionId for element:",t),null)}function r(e){return e.split(".")}function i(e,t){let o=e;for(let e of t){if(null==o||"object"!=typeof o)return;o=o[e]}return o}function s(e,t,o){if(0===t.length)return e;let n=e;for(let e=0;e<t.length-1;e++){let o=t[e],r=t[e+1],i=/^\d+$/.test(r);(void 0===n[o]||null===n[o])&&(n[o]=i?[]:{}),n=n[o]}return n[t[t.length-1]]=o,e}o.d(t,{A6:()=>i,gv:()=>n,iN:()=>r,uT:()=>s})},93221:(e,t,o)=>{o.d(t,{A0:()=>G.default,AP:()=>l.default,As:()=>Y.default,B8:()=>B.default,BD:()=>x.default,D7:()=>P.default,DH:()=>g.default,Dq:()=>N.default,F:()=>c.default,IZ:()=>u.default,Ju:()=>q,QA:()=>T.default,Rb:()=>M.default,Ru:()=>m.default,SW:()=>L.default,TO:()=>j.default,Tw:()=>H.default,UP:()=>U.default,VJ:()=>f.default,WK:()=>a.default,XV:()=>R.default,YS:()=>v.default,Zq:()=>s.default,Zx:()=>r.default,_1:()=>h.default,eP:()=>W.default,eY:()=>k.default,g_:()=>d.default,gr:()=>A.default,hI:()=>V.default,hg:()=>n.default,iK:()=>_.default,i_:()=>S.default,kt:()=>O.default,lq:()=>F.default,n5:()=>y.default,nB:()=>b.default,nU:()=>E.default,nm:()=>w.default,or:()=>D.default,rz:()=>p.default,tO:()=>C.default,te:()=>J.default,tw:()=>I.default,vo:()=>z.default,zd:()=>i.default});var n=o(10123),r=o(99609),i=o(3123),s=o(68647),a=o(72996),l=o(98796),d=o(12558),c=o(56359),p=o(48587),u=o(88992),m=o(49095),g=o(88471),h=o(70942),f=o(82777),x=o(19649),b=o(72203),y=o(54539),v=o(12750),E=o(24965),j=o(34825),w=o(47029),N=o(6941),S=o(67512),C=o(53807),T=o(6e3),I=o(37701),A=o(46086),R=o(93625),L=o(35638);o(13132);var k=o(80312);o(10344),o(84565),o(8707),o(99272);var D=o(10456),M=o(36469),O=o(28360),P=o(20931),_=o(82088),F=o(46806),B=o(25098),H=o(18942),z=o(87802),W=o(12774);o(82242),o(13508),o(69572),o(48530),o(90789),o(48983),o(49439),o(39564),o(9107);var U=o(30088),J=o(35019),V=o(72591),G=o(31021),Y=o(74201);let q={HERO_CENTERED:"hero-centered-tailwind",HERO_SPLIT:"hero-split-tailwind",VIDEO_HERO:"video-hero",HERO_WITH_SEARCH:"hero-with-search",CTA_CENTERED:"cta-centered-tailwind",CTA_DARK_PANEL:"cta-dark-panel-tailwind",TESTIMONIAL_CENTERED:"testimonial-centered-tailwind",FEATURES_WITH_ICONS:"features-with-icons-tailwind",SIDE_BY_SIDE_IMAGES:"side-by-side-images",IMAGE_WITH_TEXT:"image-with-text",BACKGROUND_IMAGE_SECTION:"background-image-section",CONTACT_FORM:"contact-form",TEXT_BLOCK:"text-block",CUSTOM_HTML:"custom-html",SECTION_DIVIDER:"section-divider",VIDEO_EMBED:"video-embed",FAQ_SECTION:"faq-section",STATS_SECTION:"stats-section",LOGO_CLOUD:"logo-cloud",PRICING_TABLE:"pricing-table",IMAGE_BLOCK:"image-block",IMAGE_GALLERY:"image-gallery",TRUST_BADGES:"trust-badges",FEATURED_LISTINGS:"featured-listings",FEATURED_SELLERS:"featured-sellers",CATEGORY_SHOWCASE:"category-showcase",LINK_GALLERY:"link-gallery",LISTING_FINDER_WIZARD:"listing-finder-wizard",SEARCH_WIZARD:"search-wizard",MARKETPLACE_HERO:"marketplace-hero",MARKETPLACE_FAQ:"marketplace-faq",MARKETPLACE_FEATURES:"marketplace-features",MARKETPLACE_ABOUT_HERO:"marketplace-about-hero",MARKETPLACE_CONTACT:"marketplace-contact",CAR_MARKETPLACE_HERO:"car-marketplace-hero",CAR_MARKETPLACE_FEATURES:"car-marketplace-features",CAR_MARKETPLACE_FAQ:"car-marketplace-faq",CAR_MARKETPLACE_ABOUT_HERO:"car-marketplace-about-hero",CAR_MARKETPLACE_CONTACT:"car-marketplace-contact",P2P_DELIVERY_HERO:"p2p-delivery-hero",P2P_DELIVERY_FEATURED_ROUTES:"p2p-delivery-featured-routes",P2P_DELIVERY_FAQ:"p2p-delivery-faq",P2P_DELIVERY_CONTACT:"p2p-delivery-contact",P2P_DELIVERY_ABOUT:"p2p-delivery-about",WEDDING_HERO:"wedding-hero",WEDDING_FEATURES_TWO_SIDED:"wedding-features-two-sided",WEDDING_FAQ:"wedding-faq",WEDDING_ABOUT:"wedding-about",WEDDING_CONTACT:"wedding-contact",WELLNESS_HERO:"wellness-hero",WELLNESS_FAQ:"wellness-faq",WELLNESS_ABOUT:"wellness-about",WELLNESS_CONTACT:"wellness-contact",TERMS_OF_SERVICE:"terms-of-service",PRIVACY_POLICY:"privacy-policy",REFUND_POLICY:"refund-policy",BLOG_OVERVIEW:"blog-overview",BLOG_POST_DETAIL:"blog-post-detail",REFUND_REQUEST_FORM:"refund-request-form"}}}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.