1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[3852],{3852:function(e,t,l){l.r(t),l.d(t,{default:function(){return r}});var i=l(5893),a=l(7294),n=l(1041);let o={W:1e3,TOP_H:650,BANNER_H:250,BOTTOM_H:600,fontSize:64,format:"png"},s=["#FFFFFF","#000000","#1e3a5f","#7f1d1d","#166534","#C8963E","#4c1d95","#0f172a","#374151","#831843","#0d7377"];function r(e){var t;let{templates:l=[]}=e,[r,d]=(0,a.useState)(""),[c,p]=(0,a.useState)(!1),[h,g]=(0,a.useState)(null),[f,u]=(0,a.useState)(""),[x,y]=(0,a.useState)([]),[b,m]=(0,a.useState)(!1),[v,S]=(0,a.useState)(!1),[j,w]=(0,a.useState)("");(0,a.useEffect)(()=>{fetch("/api/hp-saved-pins?platform=pin").then(e=>e.json()).then(e=>{e.success&&y(e.sessions||[])}).catch(()=>{})},[]);let[C,F]=(0,a.useState)("#C8963E"),[k,T]=(0,a.useState)("#FFFFFF"),[z,R]=(0,a.useState)("Poppins, sans-serif"),[D,O]=(0,a.useState)(""),[B,P]=(0,a.useState)(26),[I,A]=(0,a.useState)(""),[W,U]=(0,a.useState)(0),[_,E]=(0,a.useState)(0),[H,M]=(0,a.useState)("top"),N=h?[...h.photos||[],...h.floorPlans||[]]:[],[L,J]=(0,a.useState)([]),[G,q]=(0,a.useState)(!1),[V,Z]=(0,a.useState)([{text:"",color:"#000000",textColors:["#FFFFFF","#fbbf24"],font:"Poppins, sans-serif",opacity:.8}]),[$,Y]=(0,a.useState)([]),[K,Q]=(0,a.useState)(!1),[X,ee]=(0,a.useState)(""),[et,el]=(0,a.useState)(!1),[ei,ea]=(0,a.useState)(null),[en,eo]=(0,a.useState)(!1),[es,er]=(0,a.useState)(null),[ed,ec]=(0,a.useState)(""),ep=(0,a.useCallback)(async()=>{if(r.trim()){p(!0),u(""),g(null),J([]),Y([]);try{let e=await fetch("/api/hp-scrape-hs",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({url:r.trim()})}),t=await e.json();if(!t.success)throw Error(t.error||"Scrape failed");g({photos:t.photos||[],floorPlans:t.floorPlans||[],title:t.title||"House Plan",specs:t.specs||{},sourceUrl:r.trim()})}catch(e){u(e.message)}p(!1)}},[r]),eh=async()=>{if(!N.length){u("No images found â scrape a URL first");return}let e=N[W],t=N[_];if(!e||!t){u("Select both a top and bottom image");return}q(!0),u("");try{let l=I.trim()||h.title,i=await (0,n.qZ)(e,t,l,{bgColor:C,textColor:k,fontFamily:z,ctaText:D,ctaSize:B},o);if(!i){u("Render failed â could not load images"),q(!1);return}J(e=>[...e,{base64:i,title:l}])}catch(e){u("Stitch error: "+(e.message||e))}q(!1)},eg=async()=>{if(0===L.length){u("Add at least one stitched image first");return}Q(!0),ee("Creating pins..."),Y([]),er(null);let e=V.filter(e=>e.text.trim()),t=0,l=[];for(let e=0;e<L.length;e++)l.push({id:"s".concat(t++),base64:L[e].base64,title:"",pinDescription:"",source:"stitched",selected:!0});if(e.length>0){ee("Rendering ".concat(e.length," overlay version(s)..."));for(let i=0;i<e.length;i++){let a=e[i],o=i%L.length;try{let e={overlayColor:a.color,overlayTextColors:a.textColors,overlayFont:a.font,overlayOpacity:a.opacity},i=await (0,n.j3)(L[o].base64,a.text.trim(),e);l.push({id:"o".concat(t++),base64:i,title:"",pinDescription:"",source:"overlay",selected:!0,overlayText:a.text.trim(),overlaySettings:e,stitchedIdx:o})}catch(e){console.warn("Overlay render failed:",e)}}}Y(l);let i=l.length;ee("Generating pin titles & descriptions...");try{let e=await fetch("/api/hp-pin-text",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({title:h.title,specs:h.specs,sourceUrl:h.sourceUrl,count:i,platform:"pin"})}),t=await e.json();t.success&&t.items&&Y(e=>e.map((e,l)=>{var i,a;return{...e,title:(null===(i=t.items[l])||void 0===i?void 0:i.title)||e.title||h.title,pinDescription:(null===(a=t.items[l])||void 0===a?void 0:a.pinDescription)||""}}))}catch(e){console.warn("Title gen failed:",e)}ee(""),Q(!1)},ef=async()=>{let e=$.filter(e=>e.selected&&e.base64);if(0!==e.length&&h){eo(!0),er(null),u("");try{let t=[];for(let l=0;l<e.length;l++){u("Uploading pin ".concat(l+1," of ").concat(e.length,"..."));let i=e[l].base64.split(",")[1]||e[l].base64,a=await fetch("/api/pin-upload-pin",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({account:"hs",base64:i,mime_type:"image/png",pin_title:e[l].title||h.title,pin_description:e[l].pinDescription||"",link:h.sourceUrl})}),n=await a.json();
1n.success&&n.pin_id&&t.push({id:n.pin_id,label:"HP-".concat(l+1)})}if(0===t.length){u("All uploads failed"),eo(!1);return}u("Creating campaign with ".concat(t.length," pins..."));let l=await fetch("/api/pin-create-ad",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({account:"hs",post_url:h.sourceUrl,title:h.title,pin_ids:t,campaign_name:ed.trim()||"".concat(new Date().toLocaleDateString("en-US",{month:"short",day:"numeric"})," - House Plan - ").concat(h.title.substring(0,50)," - /").concat(h.sourceUrl.replace(/\/$/,"").split("/").pop()||"","/"),performance_plus:!0})}),i=await l.json();i.success?(er(i),u("")):u(i.error||"Failed")}catch(e){u(e.message)}eo(!1)}},eu=async()=>{if(0!==$.length){S(!0),w("");try{u("Saving images...");let e=[];for(let t=0;t<$.length;t++){let l=$[t],i=l.imageUrl||null;if(l.base64&&l.base64.startsWith("data:")&&!i)try{let e=await new Promise(e=>{let t=new Image;t.onload=()=>{let l=document.createElement("canvas");l.width=t.width,l.height=t.height,l.getContext("2d").drawImage(t,0,0),e(l.toDataURL("image/jpeg",.8).split(",")[1])},t.onerror=()=>e(l.base64.split(",")[1]),t.src=l.base64}),a=await fetch("/api/hp-saved-pins",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"upload-image",base64:e,index:t})}),n=await a.json();n.url?i=n.url:n.error&&console.warn("Upload failed:",n.error)}catch(e){console.warn("Upload error:",e)}e.push({id:l.id,title:l.title,pinDescription:l.pinDescription,source:l.source,selected:l.selected,overlayText:l.overlayText,overlaySettings:l.overlaySettings,stitchedIdx:l.stitchedIdx,imageUrl:i})}u("");let t={title:(null==h?void 0:h.title)||"House Plan",sourceUrl:(null==h?void 0:h.sourceUrl)||r,pinCount:$.length,pins:e,overlays:V,planData:{...h,photos:(null==h?void 0:h.photos)||[],floorPlans:(null==h?void 0:h.floorPlans)||[]}},l=await fetch("/api/hp-saved-pins",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"save",platform:"pin",data:t})}),i=await l.json();i.success&&(w("Saved!"),y(e=>[{id:i.id,title:t.title,sourceUrl:t.sourceUrl,pinCount:t.pinCount,createdAt:new Date().toISOString()},...e]),setTimeout(()=>w(""),2e3))}catch(e){w("Save failed")}S(!1)}},ex=async e=>{m(!0);try{let t=await fetch("/api/hp-saved-pins",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"load",id:e})}),l=await t.json();if(l.success&&l.data){let e=(l.data.pins||[]).map(e=>({...e,base64:e.base64||e.imageUrl||null}));Y(e),J(l.data.stitched||[]),Z(l.data.overlays||[{text:"",color:"#000000",textColors:["#FFFFFF","#fbbf24"],font:"Poppins, sans-serif",opacity:.8}]),g(l.data.planData||null),l.data.sourceUrl&&d(l.data.sourceUrl)}}catch(e){}m(!1)},ey=async e=>{try{await fetch("/api/hp-saved-pins",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"delete",id:e})}),y(t=>t.filter(t=>t.id!==e))}catch(e){}},eb=$.filter(e=>e.selected).length,em=$.filter(e=>e.selected&&e.base64).length;return(0,i.jsxs)("div",{children:[(0,i.jsxs)("div",{style:n.S.panel,children:[(0,i.jsx)("label",{style:n.S.label,children:"Home Stratosphere House Plan URL"}),(0,i.jsxs)("div",{style:{display:"flex",gap:8},children:[(0,i.jsx)("input",{value:r,onChange:e=>d(e.target.value),placeholder:"e.g. homestratosphere.com/woodland-drive-farmhouse-thd-12403-house-plan/",style:{...n.S.input,flex:1},disabled:c}),(0,i.jsx)("button",{onClick:ep,disabled:c||!r.trim(),style:n.S.btn("#3b82f6"),children:c?"Scraping...":"Scrape"})]}),h&&(0,i.jsxs)("div",{style:{color:"#e2e8f0",fontSize:13,fontWeight:600,marginTop:8},children:[h.title," ",(null===(t=h.specs)||void 0===t?void 0:t.sqft)&&(0,i.jsxs)("span",{style:{color:"#94a3b8",fontWeight:400},children:["\xb7 ",h.specs.sqft," sq ft \xb7 ",h.specs.bedrooms," bed \xb7 ",h.specs.bathrooms," bath"]})]})]}),h&&(0,i.jsxs)(i.Fragment,{children:[(0,i.jsxs)("div",{style:n.S.panel,children:[(0,i.jsx)("label",{style:{...n.S.label,fontSize:14,marginBottom:8,color:"#e2e8f0",fontWeight:600},children:"Step 1: Create Stitched Images"}),(0,i.jsxs)("div",{style:{marginBottom:12},children:[(0,i.jsxs)("label",{style:n.S.label,children:["All Images (",N.length,") â click to set Top or Bottom image"]}),(0,i.jsxs)("div",{style:{display:"flex",gap:4,marginBottom:6},children:[(0,i.jsx)("button",{onClick:()=>M("top"),style:{...n.S.btn("top"===H?"#3b82f6":"#334155"),fontSize:11,padding:"4px 10px"},children:"Selecting: Top Image"}),(0,i.jsx)("button",{onClick:()=>M("bottom"),style:{...n.S.btn("bottom"===H?"#f59e0b":"#334155"),fontSize:11,padding:"4px 10px"},children:"Selecting: Bottom Image"})]}),(0,i.jsx)("div",{style:{display:"flex",gap:3,flexWrap:"wrap"},children:N.map((e,t)=>{let l=W===t,a=_===t;return(0,i.jsxs)("div",{style:{position:"relative"},children:[(0,i.jsx)("img",{src:(0,n.qy)(e),onClick:()=>{"bottom"===H?E(t):U(t)},style:{width:52,height:40,objectFit:"cover",borderRadius:3,cursor:"pointer",border:l?"2px solid #3b82f6":a?"2px solid #f59e0b":"1px solid #334155"}}),l&&(0,i.jsx)("div",{style:{position:"absolute",top:1,left:1,background:"#3b82f6",color:"#fff",fontSize:8,padding:"0 3px",borderRadius:2},children:"TOP"}),a&&(0,i.jsx)("div",{style:{position:"absolute",bottom:1,left:1,background:"#f59e0b",color:"#000",fontSize:8,padding:"0 3px",borderRadius:2},children:"BTM"})]},t)})})]}),(0,i.jsx)("label",{style:n.S.label,children:"Banner Text"}),(0,i.jsx)("input",{value:I,onChange:e=>A(e.target.value),placeholder:h.title,style:{...n.S.input,fontWeight:600,marginBottom:10}}),(0,i.jsxs)("div",{style:{display:"flex",gap:14,flexWrap:"wrap",marginBottom:10},children:[(0,i.jsxs)("div",{children:[(0,i.jsx)("label",{style:n.S.label,children:"Banner Color"}),(0,i.jsx)("div",{style:{display:"flex",gap:2,flexWrap:"wrap",maxWidth:160},children:n.gJ.map(e=>(0,i.jsx)("div",{onClick:()=>F(e),style:{width:20,height:20,borderRadius:3,background:e,cursor:"pointer",border:C===e?"2px solid #60a5fa":"2px solid transparent"}},e))})]}),(0,i.jsxs)("div",{children:[(0,i.jsx)("label",{style:n.S.label,children:"Text"}),(0,i.jsx)("div",{style:{display:"flex",gap:2},children:["#FFFFFF","#1a1a1a","#f5e6c8","#C8963E"].map(e=>(0,i.jsx)("div",{onClick:()=>T(e),style:{width:20,height:20,borderRadius:3,background:e,cursor:"pointer",border:k===e?"2px solid #60a5fa":"1px solid #475569"}},e))})]}),(0,i.jsxs)("div",{children:[(0,i.jsx)("label",{style:n.S.label,children:"Font"}),(0,i.jsx)("select",{value:z,onChange:e=>R(e.target.value),style:{...n.S.input,width:"auto",padding:"5px 8px"},children:n.g5.map(e=>(0,i.jsx)("option",{value:e.value,children:e.label},e.value))})]}),(0,i.jsxs)("div",{children:[(0,i.jsx)("label",{style:n.S.label,children:"CTA"}),(0,i.jsx)("input",{value:D,onChange:e=>O(e.target.value),style:{...n.S.input,width:140,padding:"5px 8px"}})]})]}),(0,i.jsx)("button",{onClick:eh,disabled:G,style:n.S.btn("#e11d48"),children:G?"Rendering...":"+ Add Stitched Image".concat(L.length>0?" (".concat(L.length," added)"):"")}),f&&(0,i.jsx)("p",{style:{color:"#ef4444",fontSize:12,marginTop:6},children:f}),L.length>0&&(0,i.jsx)("div",{style:{display:"flex",gap:6,marginTop:10,flexWrap:"wrap"},children:L.map((e,t)=>(0,i.jsxs)("div",{style:{position:"relative"},children:[(0,i.jsx)("img",{src:e.base64,style:{height:100,borderRadius:4,border:"1px solid #334155"}}),(0,i.jsx)("button",{onClick:()=>J(e=>e.filter((e,l)=>l!==t)),style:{position:"absolute",top:2,right:2,background:"#ef4444",color:"#fff",border:"none",borderRadius:"50%",width:18,height:18,fontSize:10,
1cursor:"pointer",lineHeight:"18px",padding:0},children:"â"})]},t))})]}),(0,i.jsxs)("div",{style:n.S.panel,children:[(0,i.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:8},children:[(0,i.jsxs)("label",{style:{...n.S.label,fontSize:14,margin:0,color:"#e2e8f0",fontWeight:600},children:["Step 2: Overlay Versions (",V.length,")"]}),(0,i.jsx)("button",{onClick:()=>Z(e=>[...e,{text:"",color:"#1e3a5f",textColors:["#FFFFFF","#fbbf24"],font:"Poppins, sans-serif",opacity:.8}]),style:n.S.ghost,children:"+ Add Overlay"})]}),(0,i.jsx)("p",{style:{color:"#64748b",fontSize:12,margin:"0 0 10px"},children:"Each overlay creates one pin. With multiple stitched images, overlays round-robin across them. Text auto-sizes to fill the pin. Leave text blank to skip."}),V.map((e,t)=>(0,i.jsxs)("div",{style:{background:"#0f172a",borderRadius:8,padding:12,marginBottom:8,border:"1px solid #1e293b"},children:[(0,i.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:6},children:[(0,i.jsxs)("span",{style:{color:"#94a3b8",fontSize:11,fontWeight:600},children:["Overlay ",t+1]}),(0,i.jsxs)("div",{style:{display:"flex",gap:4},children:[(0,i.jsx)("button",{onClick:()=>Z(e=>[...e.slice(0,t+1),{...e[t]},...e.slice(t+1)]),style:{background:"none",border:"none",color:"#60a5fa",fontSize:11,cursor:"pointer"},children:"Duplicate"}),V.length>1&&(0,i.jsx)("button",{onClick:()=>Z(e=>e.filter((e,l)=>l!==t)),style:{background:"none",border:"none",color:"#ef4444",fontSize:14,cursor:"pointer"},children:"â"})]})]}),(0,i.jsx)("input",{value:e.text,onChange:e=>Z(l=>l.map((l,i)=>i===t?{...l,text:e.target.value}:l)),placeholder:"e.g. This 3-Bed Dream Home Has Everyone Talking â",style:{...n.S.input,fontWeight:600,marginBottom:8}}),(0,i.jsxs)("div",{style:{display:"flex",gap:12,flexWrap:"wrap"},children:[(0,i.jsxs)("div",{children:[(0,i.jsx)("label",{style:n.S.label,children:"Overlay Color"}),(0,i.jsx)("div",{style:{display:"flex",gap:2,flexWrap:"wrap",maxWidth:140},children:s.map(l=>(0,i.jsx)("div",{onClick:()=>Z(e=>e.map((e,i)=>i===t?{...e,color:l}:e)),style:{width:18,height:18,borderRadius:3,background:l,cursor:"pointer",border:e.color===l?"2px solid #60a5fa":"2px solid transparent"}},l))})]}),(0,i.jsxs)("div",{children:[(0,i.jsx)("label",{style:n.S.label,children:"Text Colors (click multiple)"}),(0,i.jsx)("div",{style:{display:"flex",gap:2},children:["#FFFFFF","#f5e6c8","#fbbf24","#1a1a1a","#ef4444","#3b82f6","#22c55e"].map(l=>(0,i.jsx)("div",{onClick:()=>Z(e=>e.map((e,i)=>{if(i!==t)return e;let a=e.textColors.includes(l)?e.textColors.filter(e=>e!==l):[...e.textColors,l];return{...e,textColors:a.length>0?a:[l]}})),style:{width:18,height:18,borderRadius:3,background:l,cursor:"pointer",border:e.textColors.includes(l)?"2px solid #60a5fa":"1px solid #475569"}},l))}),e.textColors.length>1&&(0,i.jsxs)("span",{style:{color:"#64748b",fontSize:9},children:[e.textColors.length," colors â alternates by line"]})]}),(0,i.jsxs)("div",{children:[(0,i.jsx)("label",{style:n.S.label,children:"Font"}),(0,i.jsx)("select",{value:e.font,onChange:e=>Z(l=>l.map((l,i)=>i===t?{...l,font:e.target.value}:l)),style:{...n.S.input,width:"auto",padding:"4px 6px",fontSize:11},children:n.g5.map(e=>(0,i.jsx)("option",{value:e.value,children:e.label},e.value))})]}),(0,i.jsxs)("div",{children:[(0,i.jsxs)("label",{style:n.S.label,children:["Opacity (",Math.round(100*e.opacity),"%)"]}),(0,i.jsx)("input",{type:"range",min:"0.2",max:"0.9",step:"0.05",value:e.opacity,onChange:e=>Z(l=>l.map((l,i)=>i===t?{...l,opacity:parseFloat(e.target.value)}:l)),style:{width:80,accentColor:"#60a5fa"}})]})]})]},t)),(0,i.jsx)("button",{onClick:async()=>{let e=V.filter(e=>e.text.trim());if(0!==e.length&&0!==L.length){el(!0);for(let t=0;t<e.length;t++){let l=e[t],i=t%L.length;try{let e={overlayColor:l.color,overlayTextColors:l.textColors,overlayFont:l.font,overlayOpacity:l.opacity},a=await (0,n.j3)(L[i].base64,l.text.trim(),e);Y(n=>[...n,{id:"ov".concat(Date.now(),"_").concat(t),base64:a,title:"",pinDescription:"",source:"overlay",selected:!0,overlayText:l.text.trim(),overlaySettings:e,stitchedIdx:i}])}catch(e){console.warn("Overlay render failed:",e)}}el(!1)}},disabled:et||0===L.length||V.every(e=>!e.text.trim()),style:{...n.S.btn("#8b5cf6"),marginTop:8,opacity:et||0===L.length||V.every(e=>!e.text.trim())?.5:1},children:et?"Rendering...":"+ Add Overlay Image".concat(V.filter(e=>e.text.trim()).length>0&&L.length>0?" (".concat(V.filter(e=>e.text.trim()).length,")"):"")})]}),(0,i.jsxs)("div",{style:{...n.S.panel,borderColor:"#8b5cf640"},children:[(0,i.jsx)("label",{style:{...n.S.label,fontSize:14,marginBottom:8,color:"#e2e8f0",fontWeight:600},children:"Step 3: Generate"}),0===L.length&&(0,i.jsx)("p",{style:{color:"#f59e0b",fontSize:12,margin:"0 0 8px"},children:"Add at least one stitched image in Step 1 first"}),(0,i.jsx)("button",{onClick:eg,disabled:K||0===L.length,style:{...n.S.btn("#8b5cf6"),padding:"12px 24px",fontSize:14,opacity:K||0===L.length?.5:1},children:K?X||"Generating...":0===L.length?"â¡ Generate All":(()=>{let e=V.filter(e=>e.text.trim()).length,t=L.length+e;return"â¡ Generate All (".concat(t," pins)")})()})]}),f&&(0,i.jsx)("div",{style:{...n.S.panel,borderColor:"#ef444440",color:"#ef4444",fontSize:13},children:f}),$.length>0&&(0,i.jsxs)("div",{style:n.S.panel,children:[(0,i.jsxs)("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",marginBottom:12},children:[(0,i.jsxs)("label",{style:{...n.S.label,margin:0,fontSize:13},children:["Review Pins (",eb," of ",$.length," selected)"]}),(0,i.jsxs)("div",{style:{display:"flex",gap:4},children:[(0,i.jsx)("button",{onClick:eu,disabled:v,style:n.S.btn("#7c3aed"),children:v?"Saving...":j||"\uD83D\uDCBE Save Session"}),(0,i.jsx)("button",{onClick:()=>Y(e=>e.map(e=>({...e,selected:!0}))),style:n.S.ghost,children:"Select All"}),(0,i.jsx)("button",{onClick:()=>Y(e=>e.map(e=>({...e,selected:!1}))),style:n.S.ghost,children:"Deselect All"})]})]}),(0,i.jsx)("div",{style:{display:"grid",gridTemplateColumns:"repeat(".concat(Math.min($.length,3),", 1fr)"),gap:10},children:$.map((e,t)=>(0,i.jsxs)("div",{style:{background:"#0f172a",borderRadius:8,overflow:"hidden",border:e.selected?"2px solid #3b82f6":"1px solid #1e293b",opacity:e.selected?1:.5},children:[(0,i.jsxs)("div",{onClick:()=>Y(e=>e.map((e,l)=>l===t?{...e,selected:!e.selected}:e)),style:{cursor:"pointer",position:"relative"},children:["overlay"===e.source&&(0,i.jsx)("div",{style:{background:"#4c1d9520",color:"#a78bfa",fontSize:10,padding:"2px 8px",fontWeight:600},children:"OVERLAY"}),(0,i.jsx)("img",{src:e.base64,style:{width:"100%",height:"auto",display:"block"},alt:""}),(0,i.jsx)("div",{style:{position:"absolute",top:4,left:4,width:20,height:20,borderRadius:4,background:e.selected?"#3b82f6":"#33415580",color:"#fff",fontSize:12,textAlign:"center",lineHeight:"20px"},children:e.selected?"â":""})]}),(0,i.jsxs)("div",{style:{padding:8},children:[(0,i.jsxs)("label",{style:{color:"#64748b",fontSize:9},children:["Title (",(e.title||"").length,"/97)"]}),(0,i.jsx)("textarea",{value:e.title||"",onChange:e=>Y(l=>l.map((l,i)=>i===t?{...l,title:e.target.value.substring(0,97)}:l)),rows:2,style:{...n.S.input,fontSize:11,padding:"4px 6px",marginBottom:4}}),(0,i.jsxs)("label",{style:{color:"#64748b",fontSize:9},children:["Description (",(e.pinDescription||"").length,"/500)"]}),(0,i.jsx)("textarea",{value:e.pinDescription||"",onChange:e=>Y(l=>l.map((l,i)=>i===t?{...l,pinDescription:e.target.value.substring(0,450)}:l)),rows:3,style:{...n.S.input,fontSize:10,padding:"4px 6px",marginBottom:4}}),"overlay"===e.source&&e.overlaySettings&&(0,i.jsxs)("div",{style:{background:"#1e293b",borderRadius:4,padding:6,marginBottom:4},children:[(0,i.jsx)("div",{style:{display:"flex",gap:4,alignItems:"center",marginBottom:4},children:(0,i.jsx)("input",{value:e.overlayText||"",onChange:e=>Y(l=>l.map((l,i)=>i===t?{...l,overlayText:e.target.value}:l)),placeholder:"Overlay text",style:{...n.S.input,flex:1,fontSize:10,padding:"3px 5px"}})}),(0,i.jsxs)("div",{style:{display:"flex",gap:4,alignItems:"center",flexWrap:"wrap"},children:[(0,i.jsxs)("label",{style:{color:"#64748b",fontSize:9},children:["Opacity ",Math.round(100*e.overlaySettings.overlayOpacity),"%"]}),(0,i.jsx)("input",{type:"range",min:"0.2",max:"0.9",step:"0.05",value:e.overlaySettings.overlayOpacity,onChange:e=>Y(l=>l.map((l,i)=>i===t?{...l,overlaySettings:{...l.overlaySettings,overlayOpacity:parseFloat(e.target.value)}}:l)),onMouseUp:async l=>{var i;let a=null===(i=L[e.stitchedIdx])||void 0===i?void 0:i.base64;if(!a||!e.overlayText)return;let o=await (0,n.j3)(a,e.overlayText,{...e.overlaySettings,overlayOpacity:parseFloat(l.target.value)});Y(e=>e.map((e,l)=>l===t?{...e,base64:o}:e))},style:{width:60,accentColor:"#60a5fa"}}),(0,i.jsx)("button",{onClick:async()=>{var l;let i=null===(l=L[e.stitchedIdx])||void 0===l?void 0:l.base64;if(!i||!e.overlayText)return;let a=await (0,n.j3)(i,e.overlayText,e.overlaySettings);Y(e=>e.map((e,l)=>l===t?{...e,base64:a}:e))},style:{...n.S.btn("#f59e0b"),fontSize:9,padding:"3px 8px"},children:"Re-render"})]})]}),(0,i.jsxs)("div",{style:{display:"flex",gap:3},children:[(0,i.jsx)("button",{onClick:()=>
1{let l=document.createElement("a");l.href=e.base64,l.download="hp-pin-".concat(t+1,".png"),l.click()},style:{...n.S.btn("#3b82f6"),flex:1,fontSize:10,padding:"4px 8px"},children:"\uD83D\uDCBE"}),(0,i.jsx)("button",{onClick:()=>Y(e=>e.filter((e,l)=>l!==t)),style:{...n.S.ghost,padding:"4px 8px",fontSize:10},children:"â"})]})]})]},e.id))})]}),$.length>0&&em>0&&(0,i.jsxs)("div",{style:n.S.panel,children:[(0,i.jsx)("label",{style:{...n.S.label,fontSize:13,marginBottom:8},children:"Submit to Pinterest Ads"}),(0,i.jsxs)("div",{style:{display:"flex",gap:8,alignItems:"flex-end",flexWrap:"wrap"},children:[(0,i.jsxs)("div",{style:{flex:1},children:[(0,i.jsx)("label",{style:n.S.label,children:"Campaign Name (optional)"}),(0,i.jsx)("input",{value:ed,onChange:e=>ec(e.target.value),placeholder:"Auto-generated if blank",style:n.S.input})]}),(0,i.jsx)("button",{onClick:ef,disabled:en||!!es,style:{...n.S.btn(es?"#065f46":"#e11d48"),padding:"10px 20px",fontSize:13,opacity:en?.6:1},children:en?"Submitting...":es?"â
".concat(es.successful_pins," pins submitted"):"\uD83D\uDCCC Submit ".concat(em," Selected Pins")})]}),es&&(0,i.jsxs)("div",{style:{background:"#052e16",border:"1px solid #166534",borderRadius:6,padding:"10px 14px",fontSize:12,color:"#4ade80",marginTop:8},children:["â
Campaign submitted to Pinterest Ads Manager",(0,i.jsx)("br",{}),(0,i.jsx)("strong",{style:{color:"#fff",fontSize:14},children:es.campaign_name}),(0,i.jsx)("br",{}),(0,i.jsxs)("span",{style:{color:"#86efac"},children:["Budget: $",es.daily_budget_usd,"/day \xb7 ",es.successful_pins,"/",es.total_pins," pins \xb7 ID: ",es.campaign_id||"â"]})]})]})]}),x.length>0&&(0,i.jsxs)("div",{style:n.S.panel,children:[(0,i.jsxs)("label",{style:{...n.S.label,fontSize:13,marginBottom:8},children:["Saved Sessions (",x.length,")"]}),(0,i.jsx)("div",{style:{display:"flex",flexDirection:"column",gap:6},children:x.map(e=>{let t=e.createdAt?new Date(e.createdAt).toLocaleDateString("en-US",{month:"short",day:"numeric"}):"";return(0,i.jsxs)("div",{style:{background:"#0f172a",border:"1px solid #334155",borderRadius:6,padding:"10px 14px",display:"flex",justifyContent:"space-between",alignItems:"center",gap:10},children:[(0,i.jsxs)("div",{style:{flex:1,minWidth:0},children:[(0,i.jsx)("div",{style:{fontSize:13,color:"#e2e8f0",fontWeight:600,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:e.title||"Session"}),(0,i.jsxs)("div",{style:{fontSize:11,color:"#64748b",marginTop:2},children:[t,t?" \xb7 ":"",e.pinCount," pins"]})]}),(0,i.jsxs)("div",{style:{display:"flex",gap:6},children:[(0,i.jsx)("button",{onClick:()=>ex(e.id),disabled:b,style:{...n.S.btn("#3b82f6"),fontSize:11,padding:"5px 10px"},children:"Load"}),(0,i.jsx)("button",{onClick:()=>ey(e.id),style:{...n.S.ghost,fontSize:11,padding:"5px 10px",color:"#ef4444"},children:"Delete"})]})]},e.id)})})]})]})}},1041:function(e,t,l){l.d(t,{S:function(){return h},g5:function(){return a},gJ:function(){return i},j3:function(){return c},lB:function(){return p},nD:function(){return d},qZ:function(){return r},qy:function(){return n}});let i=["#C8963E","#1e3a5f","#166534","#7f1d1d","#374151","#f5f5f5","#0f172a","#6b8e6b","#c4918a","#0d7377","#f5e6c8","#8b5cf6"],a=[{value:"Georgia, serif",label:"Georgia"},{value:"Arial Black, sans-serif",label:"Arial Black"},{value:"Verdana, sans-serif",label:"Verdana"},{value:"Impact, sans-serif",label:"Impact"},{value:"Palatino, serif",label:"Palatino"},{value:"Anton, sans-serif",label:"Anton"},{value:"Poppins, sans-serif",label:"Poppins Bold"},{value:"Alice, serif",label:"Alice Bold"}],n=e=>"/api/hp-image-proxy?raw=1&url=".concat(encodeURIComponent(e));function o(e){return new Promise(t=>{let l=new Image;l.crossOrigin="anonymous",l.onload=()=>t(l),l.onerror=()=>t(null),l.src=n(e)})}function s(e,t,l,i,a,n){let o=Math.max(a/t.width,n/t.height),s=a/o,r=n/o,d=(t.width-s)/2,c=(t.height-r)/2;e.drawImage(t,d,c,s,r,l,i,a,n)}async function r(e,t,l,i,a){let{W:n,TOP_H:r,BANNER_H:d,BOTTOM_H:c}=a,p=document.createElement("canvas");p.width=n,p.height=r+d+c;let h=p.getContext("2d");h.fillStyle="#FFFFFF",h.fillRect(0,0,n,p.height);let[g,f]=await Promise.all([o(e),o(t)]);g?s(h,g,0,0,n,r):(h.fillStyle="#334155",h.fillRect(0,0,n,r));let u=function(e){let t=e.replace("#","");return(299*parseInt(t.substr(0,2),16)+587*parseInt(t.substr(2,2),16)+114*parseInt(t.substr(4,2),16))/1e3>150}(i.bgColor),x=i.textColor||(u?"#1a1a1a":"#FFFFFF");h.textAlign="center",h.textBaseline="middle";let y=a.fontSize||64;h.font="bold ".concat(y,"px ").concat(i.fontFamily);let b=n-80,m=e=>{h.font="bold ".concat(e,"px ").concat(i.fontFamily);let t=l.split(" "),a="",n=[];for(let e of t){let t=a+(a?" ":"")+e;h.measureText(t).width>b&&a?(n.push(a),a=e):a=t}return a&&n.push(a),n},v=m(y);for(;y>28&&v.length*(y+8)+60>d;)y-=2,v=m(y);let S=y+8,j=v.length*S,w=Math.max(d,j+60);if(w>d){let e=r+w+c;p.height=e,h.fillStyle="#FFFFFF",h.fillRect(0,0,n,e),g&&s(h,g,0,0,n,r)}h.fillStyle=i.bgColor,h.fillRect(0,r,n,w),h.fillStyle=x,h.font="bold ".concat(y,"px ").concat(i.fontFamily);let C=r+(w-j)/2+S/2;v.forEach((e,t)=>h.fillText(e,n/2,C+t*S));let F=r+w;return h.fillStyle="#FFFFFF",h.fillRect(0,F,n,c),f&&function(e,t,l,i,a,n){let o=Math.min(a/t.width,n/t.height),s=t.width*o,r
1=t.height*o;e.drawImage(t,20+(a-s)/2,i+(n-r)/2,s,r)}(h,f,0,F+10,n-40,c-20),"jpeg"===(a.format||"png")?p.toDataURL("image/jpeg",.92):p.toDataURL("image/png")}function d(e,t,l){return new Promise(i=>{let a=new Image;a.onload=()=>{let e=document.createElement("canvas");l.targetWidth&&l.targetHeight?(e.width=l.targetWidth,e.height=l.targetHeight):(e.width=a.width,e.height=a.height);let n=e.getContext("2d");l.targetWidth&&l.targetHeight?s(n,a,0,0,e.width,e.height):n.drawImage(a,0,0);let o=l.font||"Georgia, serif",r=l.ribbonColor||"#C8963E",d=l.textColors||[l.textColor||"#FFFFFF"],c="bold"===l.variant,p=e.width-(c?80:60),h=c?48:24,g=c?6:4,f=Math.round(e.width*(c?.1:.065));n.font="bold ".concat(f,"px ").concat(o);let u=e=>{n.font="bold ".concat(e,"px ").concat(o);let l=t.split(" "),i="",a=[];for(let e of l){let t=i+(i?" ":"")+e;n.measureText(t).width>p&&i?(a.push(i),i=e):i=t}return i&&a.push(i),a},x=u(f);for(;f>h&&x.length>g;)f-=2,x=u(f);let y=f+(c?18:10),b=x.length*y,m=b+2*(c?28:24),v=(e.height-m)/2;n.fillStyle=r,n.fillRect(0,v,e.width,m),n.textAlign="center",n.textBaseline="middle",n.font="bold ".concat(f,"px ").concat(o);let S=v+(m-b)/2+y/2,j=d.length>1?Math.max(1,Math.ceil(x.length/(2*d.length))):x.length;x.forEach((t,l)=>{let i=Math.floor(l/j)%d.length;n.fillStyle=d[i],n.fillText(t,e.width/2,S+l*y)}),i(e.toDataURL("image/png"))},a.onerror=()=>i(e),a.src=e})}function c(e,t,l){return new Promise(i=>{let a=new Image;a.onload=()=>{let e=document.createElement("canvas");l.targetWidth&&l.targetHeight?(e.width=l.targetWidth,e.height=l.targetHeight):(e.width=a.width,e.height=a.height);let n=e.getContext("2d");l.targetWidth&&l.targetHeight?s(n,a,0,0,e.width,e.height):n.drawImage(a,0,0);let o=l.overlayOpacity||.65;n.fillStyle=l.overlayColor||"#000000",n.globalAlpha=o,n.fillRect(0,0,e.width,e.height),n.globalAlpha=1;let r=l.overlayFont||"Georgia, serif",d=e.width-80,c=.7*e.height,p=l.overlayTextColors||[l.overlayTextColor||"#FFFFFF"],h=e=>{n.font="bold ".concat(e,"px ").concat(r);let l=t.split(" "),i="",a=[];for(let e of l){let t=i+(i?" ":"")+e;n.measureText(t).width>d&&i?(a.push(i),i=e):i=t}return i&&a.push(i),a},g=30,f=Math.round(.14*e.width),u=g,x=h(g);for(;g<=f;){let e=Math.floor((g+f)/2),t=h(e);t.length*(e+14)<=c?(u=e,x=t,g=e+1):f=e-1}n.font="bold ".concat(u,"px ").concat(r),n.textAlign="center",n.textBaseline="middle";let y=u+14,b=x.length*y,m=(e.height-b)/2+y/2,v=p.length>1?Math.max(1,Math.ceil(x.length/(2*p.length))):x.length;x.forEach((t,l)=>{let i=Math.floor(l/v)%p.length;n.fillStyle=p[i],n.fillText(t,e.width/2,m+l*y)}),i(e.toDataURL("image/png"))},a.onerror=()=>i(e),a.src=e})}async function p(e){if(e.imageBase64)return e.imageBase64;if(!e.image_url)return null;try{let t=await fetch(e.image_url),l=await t.blob();return new Promise(e=>{let t=new FileReader;t.onload=()=>e(t.result.split(",")[1]),t.onerror=()=>e(null),t.readAsDataURL(l)})}catch(e){return null}}let h={panel:{background:"#1e293b",borderRadius:8,padding:16,border:"1px solid #334155",marginBottom:12},label:{color:"#94a3b8",fontSize:11,display:"block",marginBottom:4},input:{width:"100%",padding:"8px 10px",background:"#0f172a",color:"#e2e8f0",border:"1px solid #334155",borderRadius:6,fontSize:13,boxSizing:"border-box"},btn:e=>({background:e,color:"#fff",border:"none",borderRadius:6,padding:"8px 14px",fontSize:12,fontWeight:600,cursor:"pointer"}),ghost:{background:"transparent",color:"#94a3b8",border:"1px solid #334155",borderRadius:6,padding:"6px 12px",fontSize:11,cursor:"pointer"}}}}]);
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.