(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,33525,(e,t,i)=>{"use strict";Object.defineProperty(i,"__esModule",{value:!0}),Object.defineProperty(i,"warnOnce",{enumerable:!0,get:function(){return r}});let r=e=>{}},18272,e=>{e.v({actions:"ShadowboardConfigurator-module-scss-module__BDToMW__actions",board:"ShadowboardConfigurator-module-scss-module__BDToMW__board",boardContainer:"ShadowboardConfigurator-module-scss-module__BDToMW__boardContainer",cmInput:"ShadowboardConfigurator-module-scss-module__BDToMW__cmInput",collabCross:"ShadowboardConfigurator-module-scss-module__BDToMW__collabCross",controls:"ShadowboardConfigurator-module-scss-module__BDToMW__controls",field:"ShadowboardConfigurator-module-scss-module__BDToMW__field",grid:"ShadowboardConfigurator-module-scss-module__BDToMW__grid",headerDivider:"ShadowboardConfigurator-module-scss-module__BDToMW__headerDivider",hiddenInput:"ShadowboardConfigurator-module-scss-module__BDToMW__hiddenInput",library:"ShadowboardConfigurator-module-scss-module__BDToMW__library",libraryItem:"ShadowboardConfigurator-module-scss-module__BDToMW__libraryItem",placedItemRow:"ShadowboardConfigurator-module-scss-module__BDToMW__placedItemRow",placedItems:"ShadowboardConfigurator-module-scss-module__BDToMW__placedItems",shadowItem:"ShadowboardConfigurator-module-scss-module__BDToMW__shadowItem",subtitle:"ShadowboardConfigurator-module-scss-module__BDToMW__subtitle",svgTitle:"ShadowboardConfigurator-module-scss-module__BDToMW__svgTitle",wrapper:"ShadowboardConfigurator-module-scss-module__BDToMW__wrapper"})},89172,e=>{"use strict";var t=e.i(43476),i=e.i(71645),r=e.i(18272);let a="shadowboard-config",o=[{id:"blue",label:"Blue",value:"#1e5bb8"},{id:"red",label:"Red",value:"#c4362f"},{id:"green",label:"Green",value:"#2f8f50"},{id:"yellow",label:"Yellow",value:"#dfc530"},{id:"white",label:"White",value:"#f5f5f5"}],l=[{id:"squeegee",label:"Squeegee",widthCm:17,heightCm:5,kind:"squeegee"},{id:"brush",label:"Brush",widthCm:13,heightCm:7,kind:"brush"},{id:"bucket",label:"Bucket",widthCm:9,heightCm:9,kind:"bucket"},{id:"handle",label:"Handle",widthCm:24,heightCm:2.4,kind:"handle"}],s={version:1,title:"Custom shadow board",boardColor:o[0].value,boardColorId:o[0].id,customerLogoDataUrl:"",customerLogoRatio:1,items:[]};function d(e){return e.replaceAll("&","&").replaceAll("<","<").replaceAll(">",">").replaceAll('"',""").replaceAll("'","'")}function n(e,t){let i=e.widthCm??t.widthCm,r=e.heightCm??t.heightCm;return{widthCm:i,heightCm:r,widthPx:10*i,heightPx:10*r}}function h(e){if(!e){let e={x:612,y:42,width:150,height:54};return{dividerX:e.x-24,igeax:e,customer:null}}let t={x:438,y:42,width:138,height:52};return{dividerX:t.x-24,igeax:t,customer:{x:620,y:42,width:138,height:52}}}function u(e,t,i){if(!Number.isFinite(i)||i<=0)return{width:e,height:t};let r=t*i;return r<=e?{width:r,height:t}:{width:e,height:e/i}}function c(e,t){let i=u(e.igeax.width,e.igeax.height,2),r=e.igeax.x+(e.igeax.width-i.width)/2,a=e.igeax.y+(e.igeax.height-i.height)/2;if(!e.customer)return{dividerX:e.dividerX,igeax:{...i,x:r,y:a},customer:null,cross:null};let o=u(e.customer.width,e.customer.height,t),l=e.customer.x+(e.customer.width-o.width)/2,s=e.customer.y+(e.customer.height-o.height)/2,d=(r+i.width+l)/2;return{dividerX:Math.max(198,r-22),igeax:{...i,x:r,y:a},customer:{...o,x:l,y:s},cross:{x:d,y:74}}}function m(e,t,i){let r=(e||"").trim();if(!r)return[""];let a=r.split(/\s+/),o=[],l="";return a.forEach(e=>{let r=l?`${l} ${e}`:e;if(r.length*i*.56<=t||!l){l=r;return}o.push(l),l=e}),l&&o.push(l),o}function g(e,t,i){let r=29;for(;r>=14;){let a=m(e,t,r),o=1.15*r;if(a.length*o<=i)return{lines:a,fontSize:r,lineHeight:o};r-=1}return{lines:m(e,t,14),fontSize:14,lineHeight:16.099999999999998}}function x(e){switch(e.kind){case"squeegee":return`
`;case"brush":return`
`;case"bucket":return`
`;case"handle":return`
`;default:return""}}function f(){let[e,u]=(0,i.useState)(s),[m,f]=(0,i.useState)(""),[w,p]=(0,i.useState)(null),b=(0,i.useRef)(null),y=(0,i.useMemo)(()=>o.find(t=>t.id===e.boardColorId)||o[0],[e.boardColorId]),v=(0,i.useMemo)(()=>h(!!e.customerLogoDataUrl),[e.customerLogoDataUrl]),_=(0,i.useMemo)(()=>c(v,e.customerLogoRatio),[v,e.customerLogoRatio]),C=(0,i.useMemo)(()=>{let t=Math.max(120,_.dividerX-58-18);return g(e.title,t,76)},[e.title,_.dividerX]);function $(e,t){let i=b.current;if(!i)return null;let r=i.getBoundingClientRect();return{x:(e-r.left)/r.width*800,y:(t-r.top)/r.height*1200}}function M(e,t,i){let r=Number.parseFloat(i);if(!Number.isFinite(r))return;let a=Math.max(.5,r);u(i=>({...i,items:i.items.map(i=>{if(i.id!==e)return i;let r=l.find(e=>e.id===i.templateId);if(!r)return i;let o={...i,[t]:a},s=n(o,r);return{...o,x:Math.max(s.widthPx/2,Math.min(800-s.widthPx/2,o.x)),y:Math.max(s.heightPx/2+130,Math.min(1200-s.heightPx/2,o.y))}})}))}function j(){p(null)}return(0,t.jsxs)("section",{className:`container ${r.default.wrapper}`,children:[(0,t.jsx)("h1",{className:"title is-3",children:"Shadowboard configurator"}),(0,t.jsx)("p",{className:r.default.subtitle,children:"Board dummy 120x80 cm con ombre semitrasparenti stile alluminio."}),(0,t.jsxs)("div",{className:r.default.controls,children:[(0,t.jsxs)("label",{className:r.default.field,children:["Title",(0,t.jsx)("input",{className:"input",value:e.title,onChange:e=>u(t=>({...t,title:e.target.value}))})]}),(0,t.jsxs)("label",{className:r.default.field,children:["Background color",(0,t.jsx)("select",{className:"input",value:y.id,onChange:e=>{let t=o.find(t=>t.id===e.target.value)||o[0];u(e=>({...e,boardColorId:t.id,boardColor:t.value}))},children:o.map(e=>(0,t.jsx)("option",{value:e.id,children:e.label},e.id))})]}),(0,t.jsxs)("label",{className:r.default.field,children:["Customer logo",(0,t.jsx)("input",{type:"file",accept:"image/*,.svg",onChange:function(e){let t=e.target.files?.[0];if(!t)return;let i=new FileReader;i.onload=()=>{let e="string"==typeof i.result?i.result:"",t=new window.Image;t.onload=()=>{let i=t.naturalWidth>0&&t.naturalHeight>0?t.naturalWidth/t.naturalHeight:1;u(t=>({...t,customerLogoDataUrl:e,customerLogoRatio:i}))},t.src=e},i.readAsDataURL(t)}})]}),(0,t.jsxs)("div",{className:r.default.actions,children:[(0,t.jsx)("button",{className:"button is-link",type:"button",onClick:function(){var t,i;let r,o,s,u,m,f,w,p,b,y,v;o=(r=c(h(!!e.customerLogoDataUrl),e.customerLogoRatio)).customer?``:"",s=r.cross?`\xd7`:"",u=e.items.map(e=>{let t,i,r,a,o=l.find(t=>t.id===e.templateId);return o?(t=n(e,o),i=e.x-t.widthPx/2,r=e.y-t.heightPx/2,a=`translate(${i} ${r}) rotate(${e.rotation||0} ${t.widthPx/2} ${t.heightPx/2})`,`
${x({...o,width:t.widthPx,height:t.heightPx})}
`):""}).join(""),m=d(JSON.stringify(e)),f=Math.max(120,r.dividerX-58-18),p=(w=g(e.title,f,76)).lines.map((e,t)=>`${d(e)}`).join(""),t=`
`,i=`shadowboard-${(e.title||"custom").replace(/[^a-zA-Z0-9_-]/g,"-")}.svg`,b=new Blob([t],{type:"image/svg+xml;charset=utf-8"}),y=URL.createObjectURL(b),(v=document.createElement("a")).href=y,v.download=i,v.click(),URL.revokeObjectURL(y)},children:"Download SVG"}),(0,t.jsxs)("label",{className:"button is-light",children:["Load SVG",(0,t.jsx)("input",{className:r.default.hiddenInput,type:"file",accept:".svg,image/svg+xml",onChange:function(e){let t=e.target.files?.[0];if(!t)return;let i=new FileReader;i.onload=()=>{let e="string"==typeof i.result?i.result:"",t=new DOMParser().parseFromString(e,"image/svg+xml").querySelector(`metadata#${a}`);if(!t?.textContent)return void window.alert("File SVG non supportato: metadati configuratore mancanti.");try{let e=JSON.parse(t.textContent);u({...s,...e,customerLogoRatio:e.customerLogoRatio||1,items:Array.isArray(e.items)?e.items:[]})}catch{window.alert("Impossibile leggere i metadati del file SVG.")}},i.readAsText(t)}})]})]})]}),(0,t.jsxs)("div",{className:r.default.grid,children:[(0,t.jsxs)("aside",{className:r.default.library,children:[(0,t.jsx)("h2",{className:"title is-5",children:"Items"}),l.map(e=>(0,t.jsxs)("button",{className:r.default.libraryItem,draggable:!0,onDragStart:t=>{t.dataTransfer.setData("text/shadow-item",e.id),f(e.id)},onDragEnd:()=>f(""),type:"button",children:[(0,t.jsx)("strong",{children:e.label}),(0,t.jsxs)("span",{children:[e.widthCm," x ",e.heightCm," cm"]}),m===e.id?(0,t.jsx)("em",{children:"Drop on board"}):null]},e.id))]}),(0,t.jsx)("div",{className:r.default.boardContainer,onDrop:function(e){e.preventDefault();let t=e.dataTransfer.getData("text/shadow-item");if(!t)return;let i=$(e.clientX,e.clientY);i&&function(e,t){let i=l.find(t=>t.id===e);if(!i)return;let r=n({},i),a=Math.max(r.widthPx/2,Math.min(800-r.widthPx/2,t.x)),o=Math.max(r.heightPx/2+130,Math.min(1200-r.heightPx/2,t.y));u(t=>({...t,items:[...t.items,{id:`item-${Date.now()}-${Math.round(9999*Math.random())}`,templateId:e,widthCm:i.widthCm,heightCm:i.heightCm,x:a,y:o,rotation:0}]}))}(t,i)},onDragOver:e=>e.preventDefault(),children:(0,t.jsxs)("svg",{ref:b,className:r.default.board,viewBox:"0 0 800 1200",onPointerMove:function(e){if(!w)return;let t=$(e.clientX,e.clientY);if(!t)return;let i=t.x-w.startX,r=t.y-w.startY;p({...w,startX:t.x,startY:t.y}),u(e=>({...e,items:e.items.map(e=>{if(e.id!==w.itemId)return e;let t=l.find(t=>t.id===e.templateId);if(!t)return e;let a=n(e,t);return{...e,x:Math.max(a.widthPx/2,Math.min(800-a.widthPx/2,e.x+i)),y:Math.max(a.heightPx/2+130,Math.min(1200-a.heightPx/2,e.y+r))}})}))},onPointerUp:j,onPointerLeave:j,children:[(0,t.jsx)("rect",{x:"0",y:"0",width:800,height:1200,fill:"#c2c6cb"}),(0,t.jsx)("rect",{x:"0",y:"0",width:800,height:1200,fill:e.boardColor}),(0,t.jsx)("rect",{x:"20",y:"20",width:760,height:1160,fill:"none",stroke:"#5d5d5d",strokeWidth:"2"}),(0,t.jsx)("text",{textAnchor:"start",className:r.default.svgTitle,style:{fontSize:`${C.fontSize}px`},children:C.lines.map((e,i)=>(0,t.jsx)("tspan",{x:58,y:54+i*C.lineHeight,children:e},`${e}-${i}`))}),(0,t.jsx)("line",{x1:_.dividerX,y1:"26",x2:_.dividerX,y2:"106",className:r.default.headerDivider}),(0,t.jsx)("image",{href:"/img/igeax-logo.svg",x:_.igeax.x,y:_.igeax.y,width:_.igeax.width,height:_.igeax.height,opacity:"0.56",preserveAspectRatio:"xMidYMid meet"}),_.cross?(0,t.jsx)("text",{x:_.cross.x,y:_.cross.y,textAnchor:"middle",className:r.default.collabCross,children:"×"}):null,e.customerLogoDataUrl?(0,t.jsx)("image",{href:e.customerLogoDataUrl,x:_.customer.x,y:_.customer.y,width:_.customer.width,height:_.customer.height,opacity:"0.55",preserveAspectRatio:"xMidYMid meet"}):null,e.items.map(e=>{let i=l.find(t=>t.id===e.templateId);if(!i)return null;let a=n(e,i),o=e.x-a.widthPx/2,s=e.y-a.heightPx/2,d=`translate(${o} ${s}) rotate(${e.rotation||0} ${a.widthPx/2} ${a.heightPx/2})`;return(0,t.jsxs)("g",{transform:d,className:r.default.shadowItem,onPointerDown:t=>{var i;let r;return i=e.id,t.preventDefault(),void((r=$(t.clientX,t.clientY))&&p({itemId:i,startX:r.x,startY:r.y}))},children:[(0,t.jsx)("title",{children:i.label}),(0,t.jsx)("g",{dangerouslySetInnerHTML:{__html:x({...i,width:a.widthPx,height:a.heightPx})}})]},e.id)})]})})]}),(0,t.jsxs)("div",{className:r.default.placedItems,children:[(0,t.jsx)("h2",{className:"title is-5",children:"Placed items"}),0===e.items.length?(0,t.jsx)("p",{children:"No items yet."}):(0,t.jsx)("ul",{children:e.items.map(e=>{let i=l.find(t=>t.id===e.templateId);if(!i)return null;let a=n(e,i);return(0,t.jsxs)("li",{className:r.default.placedItemRow,children:[(0,t.jsxs)("span",{children:[i.label," (",Math.round(e.x),", ",Math.round(e.y),") - ",a.widthCm.toFixed(1)," x"," ",a.heightCm.toFixed(1)," cm"]}),(0,t.jsxs)("div",{children:[(0,t.jsx)("input",{className:r.default.cmInput,type:"number",min:"0.5",step:"0.1",value:a.widthCm,onChange:t=>M(e.id,"widthCm",t.target.value),"aria-label":"width in centimeters"}),(0,t.jsx)("input",{className:r.default.cmInput,type:"number",min:"0.5",step:"0.1",value:a.heightCm,onChange:t=>M(e.id,"heightCm",t.target.value),"aria-label":"height in centimeters"}),(0,t.jsx)("button",{className:"button is-small is-light",type:"button",onClick:()=>{var t;return t=e.id,void u(e=>({...e,items:e.items.map(e=>e.id===t?{...e,rotation:180*(180!==e.rotation)}:e)}))},children:"Flip 180°"}),(0,t.jsx)("button",{className:"button is-small is-danger is-light",type:"button",onClick:()=>{var t;return t=e.id,void u(e=>({...e,items:e.items.filter(e=>e.id!==t)}))},children:"Remove"})]})]},e.id)})})]})]})}e.s(["default",()=>f])}]);