var __gh = require("react").createElement, __gf = require("react").Fragment; var __defProp=Object.defineProperty;var __getOwnPropDesc=Object.getOwnPropertyDescriptor;var __getOwnPropNames=Object.getOwnPropertyNames;var __hasOwnProp=Object.prototype.hasOwnProperty;var __export=(target,all)=>{for(var name in all)__defProp(target,name,{get:all[name],enumerable:!0})},__copyProps=(to,from,except,desc)=>{if(from&&typeof from=="object"||typeof from=="function")for(let key of __getOwnPropNames(from))!__hasOwnProp.call(to,key)&&key!==except&&__defProp(to,key,{get:()=>from[key],enumerable:!(desc=__getOwnPropDesc(from,key))||desc.enumerable});return to};var __toCommonJS=mod=>__copyProps(__defProp({},"__esModule",{value:!0}),mod);var stdin_exports={};__export(stdin_exports,{default:()=>stdin_default,featureConfig:()=>featureConfig});module.exports=__toCommonJS(stdin_exports);var dataSources=[{table:"pedidos__productos",access:"public:read"},{table:"pedidos__solicitudes",access:"public:write"}];var import_react=require("react");var IDIOMAS=["es","en","fr","it","de","nl"],DICCIONARIOS={es:{heroTitulo:"Cat\xE1logo para tiendas y distribuidores",heroSub:"Precios para profesionales. Elija lo que necesita y le confirmamos el pedido.",catalogo:"Cat\xE1logo",buscar:"Buscar por nombre o c\xF3digo",sinResultados:"Ning\xFAn producto coincide con la b\xFAsqueda.",cargando:"Cargando el cat\xE1logo\u2026",uds:"uds",precioConsultar:"Precio a consultar",total:"Total aproximado",pedir:"Pedir",tusDatos:"Sus datos",empresa:"Empresa",contacto:"Persona de contacto",correo:"Correo electr\xF3nico",telefono:"Tel\xE9fono",pais:"Pa\xEDs",fecha:"Fecha en la que la necesita",enviar:"Enviar pedido",enviando:"Enviando\u2026",enviado:"Hemos recibido su pedido. Le confirmaremos disponibilidad y el total final.",errorCampos:"Revise los campos marcados.",errorVacio:"A\xF1ada al menos un producto.",errorGeneral:"No se ha podido enviar. Int\xE9ntelo de nuevo.",idioma:"Idioma",nuevo:"Nuevo pedido",menos:"Quitar uno",mas:"A\xF1adir uno"},en:{heroTitulo:"Catalogue for shops and distributors",heroSub:"Professional prices. Choose what you need and we confirm your order.",catalogo:"Catalogue",buscar:"Search by name or code",sinResultados:"No product matches the search.",cargando:"Loading the catalogue\u2026",uds:"pcs",precioConsultar:"Price on request",total:"Approximate total",pedir:"Order",tusDatos:"Your details",empresa:"Company",contacto:"Contact person",correo:"Email",telefono:"Phone",pais:"Country",fecha:"Date you need it",enviar:"Send order",enviando:"Sending\u2026",enviado:"We have received your order. We will confirm availability and the final total.",errorCampos:"Check the highlighted fields.",errorVacio:"Add at least one product.",errorGeneral:"The order could not be sent. Please try again.",idioma:"Language",nuevo:"New order",menos:"Remove one",mas:"Add one"},fr:{heroTitulo:"Catalogue pour boutiques et distributeurs",heroSub:"Prix professionnels. Choisissez ce dont vous avez besoin, nous confirmons votre commande.",catalogo:"Catalogue",buscar:"Rechercher par nom ou code",sinResultados:"Aucun produit ne correspond \xE0 la recherche.",cargando:"Chargement du catalogue\u2026",uds:"pcs",precioConsultar:"Prix sur demande",total:"Total approximatif",pedir:"Commander",tusDatos:"Vos coordonn\xE9es",empresa:"Entreprise",contacto:"Personne de contact",correo:"E-mail",telefono:"T\xE9l\xE9phone",pais:"Pays",fecha:"Date souhait\xE9e",enviar:"Envoyer la commande",enviando:"Envoi\u2026",enviado:"Nous avons bien re\xE7u votre commande. Nous confirmerons la disponibilit\xE9 et le total final.",errorCampos:"V\xE9rifiez les champs signal\xE9s.",errorVacio:"Ajoutez au moins un produit.",errorGeneral:"La commande n'a pas pu \xEAtre envoy\xE9e. R\xE9essayez.",idioma:"Langue",nuevo:"Nouvelle commande",menos:"Retirer un",mas:"Ajouter un"},it:{heroTitulo:"Catalogo per negozi e distributori",heroSub:"Prezzi professionali. Scegli ci\xF2 che ti serve e confermiamo il tuo ordine.",catalogo:"Catalogo",buscar:"Cerca per nome o codice",sinResultados:"Nessun prodotto corrisponde alla ricerca.",cargando:"Caricamento del catalogo\u2026",uds:"pz",precioConsultar:"Prezzo su richiesta",total:"Totale indicativo",pedir:"Ordina",tusDatos:"I tuoi dati",empresa:"Azienda",contacto:"Persona di riferimento",correo:"Email",telefono:"Telefono",pais:"Paese",fecha:"Data in cui ti serve",enviar:"Invia ordine",enviando:"Invio\u2026",enviado:"Abbiamo ricevuto il tuo ordine. Confermeremo la disponibilit\xE0 e il totale finale.",errorCampos:"Controlla i campi evidenziati.",errorVacio:"Aggiungi almeno un prodotto.",errorGeneral:"Non \xE8 stato possibile inviare l'ordine. Riprova.",idioma:"Lingua",nuevo:"Nuovo ordine",menos:"Togline uno",mas:"Aggiungine uno"},de:{heroTitulo:"Katalog f\xFCr Gesch\xE4fte und H\xE4ndler",heroSub:"Professionelle Preise. W\xE4hlen Sie, was Sie brauchen, wir best\xE4tigen Ihre Bestellung.",catalogo:"Katalog",buscar:"Nach Name oder Code suchen",sinResultados:"Kein Produkt entspricht der Suche.",cargando:"Katalog wird geladen\u2026",uds:"Stk.",precioConsultar:"Preis auf Anfrage",total:"Ungef\xE4hrer Gesamtbetrag",pedir:"Bestellen",tusDatos:"Ihre Angaben",empresa:"Firma",contacto:"Ansprechpartner",correo:"E-Mail",telefono:"Telefon",pais:"Land",fecha:"Gew\xFCnschtes Datum",enviar:"Bestellung senden",enviando:"Wird gesendet\u2026",enviado:"Wir haben Ihre Bestellung erhalten. Wir best\xE4tigen Verf\xFCgbarkeit und den Endbetrag.",errorCampos:"Bitte pr\xFCfen Sie die markierten Felder.",errorVacio:"F\xFCgen Sie mindestens ein Produkt hinzu.",errorGeneral:"Die Bestellung konnte nicht gesendet werden. Bitte versuchen Sie es erneut.",idioma:"Sprache",nuevo:"Neue Bestellung",menos:"Eins weniger",mas:"Eins mehr"},nl:{heroTitulo:"Catalogus voor winkels en distributeurs",heroSub:"Professionele prijzen. Kies wat u nodig heeft, wij bevestigen uw bestelling.",catalogo:"Catalogus",buscar:"Zoek op naam of code",sinResultados:"Geen product komt overeen met de zoekopdracht.",cargando:"Catalogus laden\u2026",uds:"st.",precioConsultar:"Prijs op aanvraag",total:"Geschat totaal",pedir:"Bestellen",tusDatos:"Uw gegevens",empresa:"Bedrijf",contacto:"Contactpersoon",correo:"E-mail",telefono:"Telefoon",pais:"Land",fecha:"Datum waarop u het nodig heeft",enviar:"Bestelling versturen",enviando:"Versturen\u2026",enviado:"We hebben uw bestelling ontvangen. We bevestigen de beschikbaarheid en het definitieve totaal.",errorCampos:"Controleer de gemarkeerde velden.",errorVacio:"Voeg minstens \xE9\xE9n product toe.",errorGeneral:"De bestelling kon niet worden verstuurd. Probeer het opnieuw.",idioma:"Taal",nuevo:"Nieuwe bestelling",menos:"E\xE9n minder",mas:"E\xE9n meer"}};function detectaIdioma(lang){let c=(lang||"").slice(0,2).toLowerCase();return IDIOMAS.includes(c)?c:"es"}var LOGO_SVG='',LOGO_SRC=`data:image/svg+xml;utf8,${encodeURIComponent(LOGO_SVG)}`;var ESTILOS=` @import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;650;800&display=swap'); .lv{--ink:#32206B;--texto:#2a2440;--muted:#6f6a85;--linea:rgba(50,32,107,.12);--azul:#1F69FF;--fondo:#ffffff;--suave:#f5f4fb;--m:clamp(18px,4.6vw,64px);font-family:Inter,-apple-system,BlinkMacSystemFont,'Helvetica Neue',Arial,sans-serif;color:var(--texto);background:var(--fondo);-webkit-font-smoothing:antialiased;min-height:100%} .lv *{box-sizing:border-box} .lv .w{width:min(1100px,100% - 2*var(--m));margin:0 auto} .lv .cab{position:sticky;top:0;z-index:5;background:rgba(255,255,255,.86);backdrop-filter:saturate(180%) blur(18px);-webkit-backdrop-filter:saturate(180%) blur(18px);border-bottom:1px solid var(--linea)} .lv .cab .w{display:flex;align-items:center;justify-content:space-between;height:64px;gap:16px} .lv .cab img{height:26px;display:block} .lv .idiomas{display:flex;gap:2px;flex-wrap:wrap;justify-content:flex-end} .lv .idiomas button{border:0;background:transparent;padding:7px 9px;border-radius:999px;font:600 12.5px/1 Inter,sans-serif;color:var(--muted);cursor:pointer} .lv .idiomas button[aria-pressed=true]{background:var(--ink);color:#fff} .lv .heroe{padding:clamp(56px,10vw,128px) 0 clamp(40px,6vw,76px)} .lv .heroe h1{font-size:clamp(40px,7.6vw,92px);line-height:.98;letter-spacing:-.045em;font-weight:800;color:var(--ink);margin:0 0 22px;max-width:15ch} .lv .heroe p{font-size:clamp(17px,1.6vw,20px);line-height:1.5;color:var(--muted);max-width:46ch;margin:0} .lv h2{font-size:clamp(26px,3.4vw,38px);letter-spacing:-.03em;font-weight:750;color:var(--ink);margin:0 0 20px} .lv .seccion{padding:0 0 clamp(56px,8vw,96px)} .lv .buscar{width:100%;height:52px;border-radius:14px;border:1px solid var(--linea);padding:0 16px;font:500 16px Inter,sans-serif;color:var(--texto);background:#fff;outline:none;margin-bottom:8px} .lv .buscar:focus,.lv input:focus{border-color:var(--azul);box-shadow:0 0 0 4px rgba(31,105,255,.12)} .lv .fila{display:grid;grid-template-columns:minmax(0,1fr) auto auto;align-items:center;gap:18px;padding:18px 2px;border-top:1px solid var(--linea)} .lv .fila:first-of-type{border-top:0} .lv .fila .nombre{font-size:17px;font-weight:650;color:var(--ink);line-height:1.25;overflow-wrap:anywhere} .lv .fila .ref{font-size:13px;color:var(--muted);margin-top:4px} .lv .fila .precio{font-size:17px;font-weight:650;color:var(--texto);font-variant-numeric:tabular-nums;white-space:nowrap;text-align:right} .lv .fila .sinprecio{font-size:14px;color:var(--muted);font-weight:500} .lv .paso{display:inline-flex;align-items:center;border:1px solid var(--linea);border-radius:999px;height:42px;overflow:hidden;background:#fff} .lv .paso button{width:42px;height:42px;border:0;background:transparent;font:500 22px/1 Inter,sans-serif;color:var(--ink);cursor:pointer} .lv .paso button:hover{background:var(--suave)} .lv .paso button:disabled{opacity:.35;cursor:default} .lv .paso span{min-width:40px;text-align:center;font:650 15px Inter,sans-serif;font-variant-numeric:tabular-nums} .lv .pedido{background:var(--suave);padding:clamp(56px,8vw,104px) 0} .lv .grid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:16px 18px} .lv .ancho{grid-column:1/-1} .lv label{display:grid;gap:7px;font-size:14px;font-weight:550;color:var(--ink)} .lv input{height:52px;border-radius:14px;border:1px solid var(--linea);padding:0 16px;font:500 16px Inter,sans-serif;color:var(--texto);background:#fff;outline:none;width:100%;min-width:0} .lv .enviar{height:56px;width:100%;margin-top:24px;border:0;border-radius:16px;background:var(--azul);color:#fff;font:650 17px Inter,sans-serif;cursor:pointer} .lv .enviar:disabled{opacity:.6;cursor:default} .lv .mensaje{margin-top:16px;font-size:15px;line-height:1.5;color:var(--ink)} .lv .barra{position:sticky;bottom:0;z-index:6;background:rgba(255,255,255,.94);backdrop-filter:saturate(180%) blur(18px);-webkit-backdrop-filter:saturate(180%) blur(18px);border-top:1px solid var(--linea);padding:12px 0 calc(12px + env(safe-area-inset-bottom))} .lv .barra .w{display:flex;align-items:center;justify-content:space-between;gap:16px} .lv .barra .resumen{font-size:14px;color:var(--muted);line-height:1.35} .lv .barra .resumen strong{display:block;font-size:17px;color:var(--ink);font-weight:700;font-variant-numeric:tabular-nums} .lv .barra a{height:48px;padding:0 22px;border-radius:14px;background:var(--ink);color:#fff;text-decoration:none;display:inline-flex;align-items:center;font:650 16px Inter,sans-serif;white-space:nowrap} .lv .pie{padding:36px 0 calc(36px + 84px);border-top:1px solid var(--linea);color:var(--muted);font-size:13px} @media (max-width:640px){ .lv .fila{grid-template-columns:minmax(0,1fr) auto;row-gap:12px} .lv .fila .paso{grid-column:1 / -1;justify-self:end} .lv .grid{grid-template-columns:minmax(0,1fr)} .lv .cab .w{height:58px} } `;function Stepper({cantidad,onCambio,menos,mas}){return __gh("div",{className:"paso","data-gufi-src":"page.tsx:61"},__gh("button",{type:"button","aria-label":menos,disabled:cantidad<=0,onClick:()=>onCambio(cantidad-1),"data-gufi-src":"page.tsx:62"},"\u2212"),__gh("span",{"data-gufi-src":"page.tsx:63"},cantidad),__gh("button",{type:"button","aria-label":mas,onClick:()=>onCambio(cantidad+1),"data-gufi-src":"page.tsx:64"},"+"))}function Portal({gufi}){let[idioma,setIdioma]=(0,import_react.useState)(()=>detectaIdioma(typeof navigator<"u"?navigator.language:"es")),t=DICCIONARIOS[idioma],productos=gufi.useData("pedidos__productos",{pageSize:500}),[texto,setTexto]=(0,import_react.useState)(""),[cantidades,setCantidades]=(0,import_react.useState)({}),[datos,setDatos]=(0,import_react.useState)({empresa:"",contacto:"",email:"",telefono:"",pais:"",fecha:""}),[enviando,setEnviando]=(0,import_react.useState)(!1),[estado,setEstado]=(0,import_react.useState)("inicio"),activos=productos.data.filter(p=>p.activo===!0).sort((a,b)=>String(a.nombre??"").localeCompare(String(b.nombre??""),"es")),q=texto.trim().toLowerCase(),visibles=activos.filter(p=>!q||`${p.nombre??""} ${p.sku??""}`.toLowerCase().includes(q)),lineas=activos.filter(p=>(cantidades[p.id]??0)>0),unidades=lineas.reduce((s,p)=>s+(cantidades[p.id]??0),0),total=lineas.reduce((s,p)=>s+(cantidades[p.id]??0)*Number(p.precio_venta??0),0),precioTexto=n=>n.toLocaleString(idioma==="es"?"es-ES":idioma,{style:"currency",currency:"EUR"});function cambia(id,n){setCantidades(c=>({...c,[id]:Math.max(0,n)}))}async function enviar(e){if(e.preventDefault(),lineas.length===0){setEstado("vacio");return}let correoOk=/\S+@\S+\.\S+/.test(datos.email.trim());if(!datos.empresa.trim()||!datos.contacto.trim()||!correoOk){setEstado("campos");return}setEnviando(!0);try{await gufi.dataProvider.create({resource:gufi.tables.pedidos__solicitudes,variables:{empresa:datos.empresa.trim(),contacto:datos.contacto.trim(),email:datos.email.trim(),telefono:datos.telefono.trim(),pais:datos.pais.trim(),idioma,fecha_deseada:datos.fecha?new Date(datos.fecha).toISOString():null,lineas:lineas.map(p=>`${p.sku??""} ${p.nombre??""} \xD7 ${cantidades[p.id]}`).join(` `),total:Math.round(total*100)/100,estado:"nueva"}}),setCantidades({}),setDatos({empresa:"",contacto:"",email:"",telefono:"",pais:"",fecha:""}),setEstado("ok")}catch{setEstado("error")}finally{setEnviando(!1)}}let campo=(clave,etiqueta,tipo="text",ancho=!1)=>__gh("label",{className:ancho?"ancho":"","data-gufi-src":"page.tsx:126"},etiqueta,__gh("input",{type:tipo,value:datos[clave],onChange:e=>setDatos(d=>({...d,[clave]:e.target.value})),"data-gufi-src":"page.tsx:128"}));return __gh("div",{className:"lv","data-gufi-src":"page.tsx:133"},__gh("style",{"data-gufi-src":"page.tsx:134"},ESTILOS),__gh("header",{className:"cab","data-gufi-src":"page.tsx:136"},__gh("div",{className:"w","data-gufi-src":"page.tsx:137"},__gh("img",{src:LOGO_SRC,alt:"Levata","data-gufi-src":"page.tsx:138"}),__gh("nav",{className:"idiomas","aria-label":t.idioma,"data-gufi-src":"page.tsx:139"},IDIOMAS.map(id=>__gh("button",{key:id,type:"button","aria-pressed":id===idioma,onClick:()=>setIdioma(id),"data-gufi-src":"page.tsx:141"},id.toUpperCase()))))),__gh("section",{className:"heroe","data-gufi-src":"page.tsx:147"},__gh("div",{className:"w","data-gufi-src":"page.tsx:148"},__gh("h1",{"data-gufi-src":"page.tsx:149"},t.heroTitulo),__gh("p",{"data-gufi-src":"page.tsx:150"},t.heroSub))),__gh("section",{className:"seccion","data-gufi-src":"page.tsx:154"},__gh("div",{className:"w","data-gufi-src":"page.tsx:155"},__gh("h2",{"data-gufi-src":"page.tsx:156"},t.catalogo),__gh("input",{className:"buscar",value:texto,onChange:e=>setTexto(e.target.value),placeholder:t.buscar,"aria-label":t.buscar,"data-gufi-src":"page.tsx:157"}),productos.loading?__gh("p",{className:"mensaje","data-gufi-src":"page.tsx:159"},t.cargando):visibles.length===0?__gh("p",{className:"mensaje","data-gufi-src":"page.tsx:161"},t.sinResultados):visibles.map(p=>{let n=cantidades[p.id]??0;return __gh("div",{className:"fila",key:p.id,"data-gufi-src":"page.tsx:165"},__gh("div",{"data-gufi-src":"page.tsx:166"},__gh("div",{className:"nombre","data-gufi-src":"page.tsx:167"},p.nombre??""),__gh("div",{className:"ref","data-gufi-src":"page.tsx:168"},p.sku??"")),p.precio_venta==null?__gh("span",{className:"sinprecio","data-gufi-src":"page.tsx:170"},t.precioConsultar):__gh("span",{className:"precio","data-gufi-src":"page.tsx:170"},precioTexto(Number(p.precio_venta))),__gh(Stepper,{cantidad:n,onCambio:v=>cambia(p.id,v),menos:t.menos,mas:t.mas}))}))),__gh("section",{className:"pedido",id:"pedido","data-gufi-src":"page.tsx:178"},__gh("div",{className:"w","data-gufi-src":"page.tsx:179"},__gh("h2",{"data-gufi-src":"page.tsx:180"},t.tusDatos),__gh("form",{onSubmit:enviar,"data-gufi-src":"page.tsx:181"},__gh("div",{className:"grid","data-gufi-src":"page.tsx:182"},campo("empresa",t.empresa,"text",!0),campo("contacto",t.contacto),campo("email",t.correo,"email"),campo("telefono",t.telefono,"tel"),campo("pais",t.pais),campo("fecha",t.fecha,"date")),__gh("button",{className:"enviar",type:"submit",disabled:enviando,"data-gufi-src":"page.tsx:190"},enviando?t.enviando:t.enviar),estado==="ok"&&__gh("p",{className:"mensaje","data-gufi-src":"page.tsx:191"},t.enviado),estado==="campos"&&__gh("p",{className:"mensaje","data-gufi-src":"page.tsx:192"},t.errorCampos),estado==="vacio"&&__gh("p",{className:"mensaje","data-gufi-src":"page.tsx:193"},t.errorVacio),estado==="error"&&__gh("p",{className:"mensaje","data-gufi-src":"page.tsx:194"},t.errorGeneral)))),__gh("footer",{className:"pie","data-gufi-src":"page.tsx:199"},__gh("div",{className:"w","data-gufi-src":"page.tsx:200"},"\xA9 2026 Levata")),__gh("div",{className:"barra","data-gufi-src":"page.tsx:203"},__gh("div",{className:"w","data-gufi-src":"page.tsx:204"},__gh("div",{className:"resumen","data-gufi-src":"page.tsx:205"},unidades," ",t.uds,__gh("strong",{"data-gufi-src":"page.tsx:207"},t.total,": ",precioTexto(total))),__gh("a",{href:"#pedido","data-gufi-src":"page.tsx:209"},t.pedir))))}var featureConfig={dataSources,meta:{name:"Portal de clientes",version:"1.0.0"}};var stdin_default=Portal;