import{r as e,t}from"./jsx-runtime-BbTa8W_M-1776590214964.js";import{a as n,n as r,o as i,r as a,t as o}from"./app-CXDQ5oEH-1776590214964.js";import{t as s}from"./useTranslation-D1etqd9u-1776590214964.js";import{t as c}from"./arrow-left-BFhIh_le-1776590214964.js";import{t as l}from"./DashboardLayout-CKvr2qsf-1776590214964.js";import{t as u}from"./loader-circle-BF-wgoyu-1776590214964.js";import{t as d}from"./AiAssistantWindow-DsxCkq5F-1776590214964.js";import{t as f}from"./save-DLvESXbJ-1776590214964.js";import{t as p}from"./button-WiAFyHfP-1776590214964.js";import{PRODUCT_SECTIONS_REGISTRY as m}from"./Registry-BGe6oW1l-1776590214964.js";e();var h=t();function g({categories:e,currencies:t}){let{t:g}=s(),{appSettings:_}=i().props,v=t?.find(e=>e.is_default)?.code||`USD`,y=m.map(e=>({id:e.id,label:g(e.label),icon:e.icon})),{data:b,setData:x,post:S,processing:C,errors:w}=n({title:``,category_id:``,subcategory_id:``,description:``,currency_code:v,price:``,stock:``,moq:`1`,existing_images:[],images:[],shipping_time:``,delivery_via:``,refund_policy:``,customization_options:[],specifications:[],variations:[],coupon_code:``,discount_percentage:``,max_discount_percentage:``,min_order_amount_for_discount:``,is_free_shipping:!1,shipping_charge:``,shipping_charge_type:`flat_rate`});return(0,h.jsxs)(l,{mode:`seller`,children:[(0,h.jsx)(r,{title:g(`Publish New Product`)}),_?.ai_product_assistant&&(0,h.jsx)(d,{apiEndpoint:route(`seller.ai.product_form`),contextData:b,onDataUpdate:e=>{x(t=>({...t,...e}))},categories:e,currencies:t,slashCommands:y,title:g(`Product Co-Pilot`),placeholder:g(`Type '/' for commands...`)}),(0,h.jsxs)(`div`,{className:`max-w-5xl mx-auto pb-12 flex flex-col lg:flex-row gap-8 items-start`,children:[(0,h.jsxs)(`div`,{className:`flex-1 w-full space-y-6`,children:[(0,h.jsxs)(`div`,{className:`flex items-center gap-3 mb-2`,children:[(0,h.jsx)(p,{variant:`ghost`,size:`icon`,asChild:!0,className:`rounded-full`,children:(0,h.jsx)(a,{href:route(`dashboard.seller`),children:(0,h.jsx)(c,{className:`w-5 h-5 rtl:rotate-180`})})}),(0,h.jsxs)(`div`,{children:[(0,h.jsx)(`h1`,{className:`text-2xl font-bold tracking-tight`,children:g(`Publish Product`)}),(0,h.jsx)(`p`,{className:`text-muted-foreground text-sm`,children:g(`Add a new item to your global catalog.`)})]})]}),(0,h.jsx)(`form`,{id:`product-form`,onSubmit:e=>{if(e.preventDefault(),!b.title||!b.category_id||!b.price||!b.shipping_time){o.error(g(`Please fill all required fields marked with *`));return}if(b.images.length===0){o.error(g(`Please upload at least one product image.`));return}S(route(`seller.products.store`),{preserveScroll:!0,onSuccess:()=>o.success(g(`Product published successfully!`)),onError:()=>o.error(g(`Failed to create product. Please check the form for errors.`))})},className:`space-y-6`,children:m.map(n=>{let r=n.Component;return(0,h.jsx)(`div`,{id:`section-${n.id}`,className:`scroll-mt-24`,children:(0,h.jsx)(r,{data:b,setData:x,errors:w,categories:e,currencies:t,existingImages:[]})},n.id)})})]}),(0,h.jsx)(`div`,{className:`w-full lg:w-64 shrink-0 lg:sticky lg:top-24 hidden md:block`,children:(0,h.jsxs)(`div`,{className:`p-4 border rounded-xl bg-card shadow-sm space-y-4`,children:[(0,h.jsx)(`h3`,{className:`font-bold text-sm uppercase tracking-wider text-muted-foreground mb-2`,children:g(`Form Sections`)}),(0,h.jsx)(`nav`,{className:`flex flex-col gap-1`,children:m.map(e=>(0,h.jsxs)(`button`,{type:`button`,onClick:()=>document.getElementById(`section-${e.id}`)?.scrollIntoView({behavior:`smooth`}),className:`flex items-center gap-3 px-3 py-2 text-sm font-medium rounded-md hover:bg-muted text-start text-muted-foreground hover:text-foreground transition-colors`,children:[(0,h.jsx)(e.icon,{className:`w-4 h-4`}),g(e.label)]},e.id))}),(0,h.jsx)(`div`,{className:`pt-4 border-t mt-4`,children:(0,h.jsxs)(p,{type:`submit`,form:`product-form`,disabled:C,className:`w-full gap-2 bg-blue-600 hover:bg-blue-700 text-white`,children:[C?(0,h.jsx)(u,{className:`w-4 h-4 animate-spin`}):(0,h.jsx)(f,{className:`w-4 h-4`}),g(`Publish Product`)]})})]})}),(0,h.jsx)(`div`,{className:`fixed bottom-4 right-4 left-4 md:hidden z-40`,children:(0,h.jsxs)(p,{type:`submit`,form:`product-form`,disabled:C,size:`lg`,className:`w-full gap-2 bg-blue-600 hover:bg-blue-700 text-white shadow-xl`,children:[C?(0,h.jsx)(u,{className:`w-4 h-4 animate-spin`}):(0,h.jsx)(f,{className:`w-4 h-4`}),g(`Publish Product`)]})})]})]})}export{g as default};