1import{E as gt,r as E,k as mt,c,a as i,u as r,h as pt,w as h,b as t,y as xt,t as n,m as L,n as U,o as u,F as M,f as N,z as J,e as S,v as Y,d as B,s as x}from"./app-CGV-KKkc.js";import{_ as bt}from"./AuthenticatedLayout-Ba4VoB_-.js";import{_ as I}from"./Modal-DGE22nt6.js";import{_ as T}from"./TextInput-D2P5Wd9e.js";import{_ as b}from"./InputLabel-_LSWszv6.js";import{_ as z}from"./SearchableSelect-CQGT4HrW.js";import{c as $}from"./carrierImages-B0GjsJcK.js";import{u as vt}from"./useToast-DgW1jhhr.js";import{d as ht}from"./debounce-ETe2odyl.js";import{a as k,O as yt}from"./OrderStatus-CPEl4X_T.js";import{n as ft,g as wt}from"./LocationNormalizer-DNefYGSh.js";import{_ as kt}from"./_plugin-vue_export-helper-DlAUqK2U.js";import"https://cdn.jsdelivr.net/npm/@undecaf/[email protected]/dist/main.js";import"./sweetalert2.esm.all-BZR39-dk.js";import"./ToastList-D_b9QKdq.js";import"./useSettings-2peX7i3H.js";import"./useUiTheme-oriybOun.js";import"./useBackgroundTasks-CslIcTpN.js";const _t={class:"w-full py-6"},Ct={class:"sticky top-0 z-30 bg-gray-50 dark:bg-gray-900 py-3 px-4 border-b border-gray-200 dark:border-gray-700 shadow-sm mb-4 transition-all"},Vt={class:"flex flex-row flex-wrap items-center justify-between gap-3"},jt={class:"flex items-center gap-2 min-w-0"},Et={class:"flex flex-col min-w-0"},Mt={class:"flex items-center gap-2"},$t={class:"text-lg sm:text-2xl font-bold text-gray-900 dark:text-white truncate"},Pt={class:"flex items-center gap-2 flex-shrink-0"},Ot=["value"],Lt=["disabled"],Nt={class:"grid grid-cols-1 md:grid-cols-2 gap-6"},St={class:"bg-white dark:bg-gray-800 rounded-2xl shadow-sm border border-gray-100 dark:border-gray-700 p-6 hover:shadow-md transition-shadow relative group"},Tt={class:"space-y-3"},zt={class:"text-base font-medium text-gray-900 dark:text-gray-200"},Ut={class:"grid grid-cols-2 gap-4"},Bt={class:"text-sm text-gray-700 dark:text-gray-300"},It=["title"],At={class:"text-sm text-gray-700 dark:text-gray-300 line-clamp-2"},Rt={class:"bg-white dark:bg-gray-800 rounded-2xl shadow-sm border border-gray-100 dark:border-gray-700 p-6 hover:shadow-md transition-shadow relative group"},Dt={class:"space-y-3"},qt={class:"grid grid-cols-2 gap-4"},Kt={class:"text-sm font-medium text-gray-900 dark:text-gray-200"},Ft={class:"px-2 py-1 text-xs rounded-full bg-gray-100 text-gray-700 dark:bg-gray-700 dark:text-gray-300"},Gt={class:"bg-white dark:bg-gray-800 rounded-2xl shadow-sm border border-gray-100 dark:border-gray-700 p-6 hover:shadow-md transition-shadow relative group md:col-span-2"},Ht={class:"flex items-center gap-3 mb-4"},Wt={class:"text-lg font-bold text-gray-800 dark:text-white"},Jt={class:"space-y-3"},Yt={class:"h-10 w-10 rounded-md bg-gray-200 dark:bg-gray-700 overflow-hidden flex-shrink-0"},Qt=["src"],Xt={class:"flex-1 min-w-0"},Zt={class:"text-sm font-medium text-gray-900 dark:text-white truncate"},te={class:"text-xs text-gray-500"},ee={class:"text-right"},se={class:"text-sm font-bold text-gray-900 dark:text-white"},oe={key:0,class:"text-center pt-2"},re={class:"text-xs text-gray-500 font-medium"},ae={class:"bg-white dark:bg-gray-800 rounded-2xl shadow-sm border border-gray-100 dark:border-gray-700 p-6 hover:shadow-md transition-shadow relative group"},ne={class:"space-y-2"},le={class:"flex justify-between items-center text-sm"},ie={class:"font-medium text-gray-900 dark:text-white"},de={class:"flex justify-between items-center text-sm"},ce={class:"font-medium text-gray-900 dark:text-white"},ue={class:"pt-2 border-t border-dashed mt-2 flex justify-between items-center"},ge={class:"text-lg font-bold text-green-600"},me={class:"bg-white dark:bg-gray-800 rounded-2xl shadow-sm border border-gray-100 dark:border-gray-700 p-6 hover:shadow-md transition-shadow relative group"},pe={class:"p-6"},xe={class:"flex justify-between items-center mb-4 border-b pb-2"},be={class:"space-y-4"},ve={class:"grid grid-cols-1 sm:grid-cols-2 gap-4"},he={class:"mt-6 flex justify-end"},ye={class:"p-6"},fe={class:"flex justify-between items-center mb-4 border-b pb-2"},we={class:"space-y-4"},ke=["value"],_e={class:"mt-6 flex justify-end"},Ce={class:"p-6 h-[80vh] flex flex-col"},Ve={class:"mb-4 border-b pb-4"},je={class:"flex justify-between items-center mb-2"},Ee={class:"flex gap-2"},Me={class:"flex-1 relative"},$e={key:0,class:"flex items-center gap-2"},Pe={key:0,class:"text-xs text-gray-500"},Oe={key:1},Le={key:0,class:"font-bold text-gray-900 dark:text-white py-1 break-words"},Ne={class:"flex-shrink-0"},Se=["src"],Te={class:"flex flex-col min-w-0 flex-1"},ze={class:"font-medium text-gray-800 dark:text-gray-200 break-words"},Ue={key:0,class:"text-gray-400 mr-1"},Be={class:"flex flex-wrap items-center gap-x-2 gap-y-1 mt-0.5 text-xs text-gray-500 dark:text-gray-400"},Ie={class:"break-all"},Ae={class:"ml-auto font-bold text-gray-700 dark:text-gray-300 whitespace-nowrap"},Re=["disabled"],De={class:"flex-1 overflow-y-auto border rounded-lg bg-gray-50 dark:bg-gray-900"},qe={class:"w-full text-left text-xs"},Ke={class:"divide-y divide-gray-200 dark:divide-gray-700"},Fe={key:0},Ge={class:"px-2 py-1.5"},He={class:"flex items-center gap-2"},We=["src"],Je={class:"min-w-0"},Ye={class:"font-bold text-gray-900 dark:text-white truncate max-w-[120px] sm:max-w-[200px]"}
1,Qe={class:"text-[10px] text-gray-500 truncate"},Xe={class:"px-2 py-1.5 text-right"},Ze=["onUpdate:modelValue"],ts={class:"px-2 py-1.5 text-center"},es={class:"flex items-center justify-center gap-1"},ss=["onClick"],os={class:"w-5 text-center font-medium"},rs=["onClick"],as={class:"px-2 py-1.5 text-right font-medium text-gray-900 dark:text-white"},ns={class:"px-2 py-1.5 text-right"},ls=["onClick"],is={class:"mt-4 pt-2 border-t flex flex-wrap gap-4 justify-between items-center"},ds={class:"text-sm flex gap-4"},cs={class:"font-bold text-gray-900 dark:text-white"},us={class:"font-bold text-brand-start dark:text-brand-end"},gs={__name:"Edit",props:{order:{type:Object,required:!0},availableProducts:{type:Array,default:()=>[]}},setup(Q){var q,K,F,G;const P=vt(),l=Q,X=((q=l.order.customer)==null?void 0:q.region)||(l.order.shipping_address?l.order.shipping_address.province:""),Z=((K=l.order.customer)==null?void 0:K.commune)||(l.order.shipping_address?l.order.shipping_address.city:""),A=ft(X,Z,((F=l.order.customer)==null?void 0:F.country)||"Chile"),o=gt({status:l.order.status,carrier:l.order.carrier,shipping_type:l.order.shipping_type,customer:{...l.order.customer,country:((G=l.order.customer)==null?void 0:G.country)||"Chile",region:A.region,commune:A.commune},products:l.order.products.map(a=>({...a})),financials:{...l.order.financials},observations:l.order.observations}),_=E(!1),C=E(!1),y=E(!1),f=E(null),tt=yt,et=x(()=>{var d,H;const a=((d=l.filterOptions)==null?void 0:d.inactive_carriers)||[],e=((H=l.filterOptions)==null?void 0:H.carriers)||{},s=[],g=[];return Object.keys(e).forEach(p=>{const v=a.includes(p),j=p.toLowerCase();let w=$[j]||null;w||(j.includes("blue")?w=$.blue_express:j.includes("starken")?w=$.starken:j.includes("chilexpress")?w=$.chilexpress:j.includes("correos")&&(w=$.correos));const W={code:p,name:v?`${e[p]} (No disponible)`:e[p],disabled:v,image:w};v?g.push(W):s.push(W)}),s.sort((p,v)=>p.name.localeCompare(v.name)),g.sort((p,v)=>p.name.localeCompare(v.name)),[...s,...g]}),st=["POR PAGAR","PAGADO","GRATIS"],R=x(()=>wt(o.value.customer.country||"Chile")),ot=x(()=>R.value.map(a=>a.name)),rt=x(()=>{if(!o.value.customer.region)return[];const a=R.value.find(e=>e.name===o.value.customer.region);return a?a.communes:[]}),O=E([...l.availableProducts]);watch(()=>l.availableProducts,a=>{O.value=[...a]});const at=ht(async a=>{if(!(!a||a.length<1))try{const s=(await mt.get(route("supplier.inventory.products.search"),{params:{search:a}})).data,g=new Set(O.value.map(d=>d.id));s.forEach(d=>{g.has(d.id)||O.value.push({id:d.id,name:d.name,sku:d.sku,price:d.price,cost:d.cost||0,stock:d.stock||0,image:d.image||"https://placehold.co/50",variants:d.sub_products||[]})})}catch(e){console.error("Error searching products:",e)}},300),nt=x(()=>{let a=[];return O.value.forEach(e=>{e.variants&&e.variants.length>0?(a.push({id:`group-${e.id}`,label:e.name,disabled:!0,isGroup:!0}
1),e.variants.forEach(s=>{a.push({id:s.id,name:s.name,label:`${s.name} - ${m(s.price)}`,sku:s.sku,price:s.price,stock:s.stock||0,image:s.image||e.image||"https://placehold.co/50",isChild:!0,parentName:e.name,value:{...s,name:`${e.name} - ${s.name}`,image:s.image||e.image}})})):a.push({id:e.id,name:e.name,label:`${e.name} - ${m(e.price)}`,sku:e.sku,price:e.price,stock:e.stock||0,image:e.image||"https://placehold.co/50",isChild:!1,value:{...e}})}),a}),lt=x(()=>{const a=o.financials.total_sales-o.financials.product_cost,e=a-o.financials.shipping_cost;return{grossProfit:a,netProfit:e}}),D=x(()=>o.products.reduce((a,e)=>a+(Number(e.qty)||0),0)),it=x(()=>o.products.reduce((a,e)=>a+(Number(e.price)||0)*(Number(e.qty)||0),0)),V=()=>{let a=0,e=0;o.products.forEach(s=>{a+=(Number(s.price)||0)*(Number(s.qty)||0),e+=(Number(s.cost)||0)*(Number(s.qty)||0)}),o.financials.total_sales=a,o.financials.product_cost=e},dt=()=>{if(!f.value)return;const a=f.value,e=o.products.findIndex(s=>s.sku===a.sku);e>=0?(o.products[e].qty++,P.success("Cantidad actualizada")):(o.products.push({name:a.name,sku:a.sku,qty:1,price:a.price,cost:a.cost,image:a.image}),P.success("Producto agregado")),V(),f.value=null},ct=a=>{o.products.splice(a,1),V()},ut=()=>{o.processing||(Swal.fire({title:"Procesando...",text:"Por favor espere",allowOutsideClick:!1,didOpen:()=>{Swal.showLoading()}}),o.transform(a=>({...a,_method:"put"})).post(route("supplier.inventory.orders.update",l.order.id),{preserveScroll:!0,onSuccess:()=>{Swal.close(),P.success("Pedido actualizado correctamente")},onError:()=>{Swal.close(),P.error("Ocurrió un error al actualizar el pedido")}}))},m=a=>new Intl.NumberFormat("es-CL",{style:"currency",currency:"CLP"}).format(a);return(a,e)=>(u(),c(M,null,[i(r(pt),{title:`Editar Pedido ${l.order.code}`},null,8,["title"]),i(bt,null,{default:h(()=>[t("div",_t,[t("div",Ct,[t("div",Vt,[t("div",jt,[i(r(xt),{href:a.route("supplier.inventory.orders.show",l.order.id),class:"text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200 transition-colors flex-shrink-0"},{default:h(()=>[...e[25]||(e[25]=[t("svg",{xmlns:"http://www.w3.org/2000/svg",class:"h-6 w-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[t("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M10 19l-7-7m0 0l7-7m-7 7h18"})],-1)])]),_:1},8,["href"]),t("div",Et,[t("div",Mt,[t("h1",$t,n(l.order.code),1)]),e[26]||(e[26]=t("p",{class:"text-xs text-gray-500 hidden sm:block"},"Edición simplificada",-1))])]),t("div",Pt,[L(t("select",{"onUpdate:modelValue":e[0]||(e[0]=s=>r(o).status=s),class:U(["block w-32 sm:w-40 rounded-lg border-gray-300 dark:border-gray-600 dark:bg-gray-700 text-xs sm:text-sm font-medium focus:ring-brand-start focus:border-brand-start shadow-sm transition-all py-1.5",{"text-yellow-600 bg-yellow-50":[r(k).PENDING,r(k).WITHDRAWN].includes(r(o).status),"text-brand-start bg-gradient-to-r from-brand-start to-brand-end border-none text-white hover:opacity-90 transition-opacity/5":r(o).status===r(k).OUT_FOR_DELIVERY,"text-green-600 bg-green-50":r(o).status===r(k).DELIVERED,"text-red-600 bg-red-50":[r(k).CANCELLED,r(k).REJECTED].includes(r(o).status)}])},[(u(!0),c(M,null,N(r(tt),s=>(u(),c("option",{key:s.value,value:s.value},n(s.label),9,Ot))),128))],2),[[J,r(o).status]]),t("button",{onClick:ut,disabled:r(o).processing,class:"px-4 py-1.5 bg-gradient-to-r from-brand-start to-brand-end border-none text-white text-white rounded-lg font-bold hover:opacity-90 transition-opacity shadow-md transition-all active:scale-95 flex items-center justify-center gap-2 text-xs sm:text-sm disabled:opacity-50"},[...e[27]||(e[27]=[t("svg",{xmlns:"http://www.w3.org/2000/svg",class:"h-4 w-4 sm:h-5 sm:w-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[t("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M5 13l4 4L19 7"})],-1),t("span",{class:""},"Guardar",-1)])],8,Lt)])])]),t("div",Nt,[t("div",St,[t("button",{onClick:e[1]||(e[1]=s=>_.value=!0),class:"absolute top-4 right-4 p-2 text-gray-400 hover:text-brand-start hover:bg-gradient-to-r from-brand-start to-brand-end border-none text-white hover:opacity-90 transition-opacity/5 rounded-full transition-all"},[...e[28]||(e[28]=[t("svg",{xmlns:"http://www.w3.org/2000/svg",class:"h-5 w-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[t("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M15.232 5.232l3.536 3.536m-2.036-5.036a2.5 2.5 0 113.536 3.536L6.5 21.036H3v-3.572L16.732 3.732z"})],-1)])]),e[33]||(e[33]=t("div",{class:"flex items-center gap-3 mb-4"},[t("div",{class:"p-2 bg-brand-start/10 text-brand-start rounded-lg dark:bg-brand-start/20 dark:text-brand-end"},[t("svg",{xmlns:"http://www.w3.org/2000/svg",class:"h-6 w-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[t("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M16 7a4 4 0 11-8 0 4 4 0 018 0zM12 14a7 7 0 00-7 7h14a7 7 0 00-7-7z"})])]),t("h2",{class:"text-lg font-bold text-gray-800 dark:text-white"},"Cliente")],-1)),t("div",Tt,[t("div",null,[e[29]||(e[29]=t("p",{class:"text-xs font-bold text-gray-400 uppercase tracking-wider"},"Nombre",-1)),t("p",zt,n(r(o).customer.name),1)]),t("div",Ut,[t("div",null,[e[30]||(e[30]=t("p",{class:"text-xs font-bold text-gray-400 uppercase tracking-wider"},"Teléfono",-1)),t("p",Bt,n(r(o).customer.phone),1)]),t("div",null,[e[31]||(e[31]=t("p",{class:"text-xs font-bold text-gray-400 uppercase tracking-wider"},"Email",-1)),t("p",{class:"text-sm text-gray-700 dark:text-gray-300 truncate",title:r(o).customer.email},n(r(o).customer.email),9,It)])]),t("div",null,[e[32]||(e[32]=t("p",{class:"text-xs font-bold text-gray-400 uppercase tracking-wider"},"Dirección",-1)),t("p",At,n(r(o).customer.address)+", "+n(r(o).customer.commune),1)])])]),t("div",Rt,[t("button",{onClick:e[2]||(e[2]=s=>C.value=!0),class:"absolute top-4 right-4 p-2 text-gray-400 hover:text-brand-start hover:bg-gradient-to-r from-brand-start to-brand-end border-none text-white hover:opacity-90 transition-opacity/5 rounded-full transition-all"},[...e[34]||(e[34]=[t("svg",{xmlns:"http://www.w3.org/2000/svg",class:"h-5 w-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[t("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M15.232 5.232l3.536 3.536m-2.036-5.036a2.5 2.5 0 113.536 3.536L6.5 21.036H3v-3.572L16.732 3.732z"})],-1)])]),e[37]||(e[37]=t("div",{class:"flex items-center gap-3 mb-4"},[t("div",{class:"p-2 bg-orange-50 text-orange-600 rounded-lg"},[t("svg",{xmlns:"http://www.w3.org/2000/svg",class:"h-6 w-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"}
1,[t("path",{d:"M9 17a2 2 0 11-4 0 2 2 0 014 0zM19 17a2 2 0 11-4 0 2 2 0 014 0z"}),t("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M13 16V6a1 1 0 00-1-1H4a1 1 0 00-1 1v10a1 1 0 001 1h1m8-1a1 1 0 01-1 1H9m4-1V8a1 1 0 011-1h2.586a1 1 0 01.707.293l3.414 3.414a1 1 0 01.293.707V16a1 1 0 01-1 1h-1m-6-1a1 1 0 001 1h1M5 17a2 2 0 104 0m-4 0a2 2 0 114 0m6 0a2 2 0 104 0m-4 0a2 2 0 114 0"})])]),t("h2",{class:"text-lg font-bold text-gray-800 dark:text-white"},"EnvÃo")],-1)),t("div",Dt,[t("div",qt,[t("div",null,[e[35]||(e[35]=t("p",{class:"text-xs font-bold text-gray-400 uppercase tracking-wider"},"Transportista",-1)),t("p",Kt,n(r(o).carrier),1)]),t("div",null,[e[36]||(e[36]=t("p",{class:"text-xs font-bold text-gray-400 uppercase tracking-wider"},"Tipo",-1)),t("span",Ft,n(r(o).shipping_type),1)])])])]),t("div",Gt,[t("button",{onClick:e[3]||(e[3]=s=>y.value=!0),class:"absolute top-4 right-4 p-2 text-gray-400 hover:text-brand-start hover:bg-gradient-to-r from-brand-start to-brand-end border-none text-white hover:opacity-90 transition-opacity/5 rounded-full transition-all"},[...e[38]||(e[38]=[t("svg",{xmlns:"http://www.w3.org/2000/svg",class:"h-5 w-5",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[t("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M15.232 5.232l3.536 3.536m-2.036-5.036a2.5 2.5 0 113.536 3.536L6.5 21.036H3v-3.572L16.732 3.732z"})],-1)])]),t("div",Ht,[e[39]||(e[39]=t("div",{class:"p-2 bg-gradient-to-r from-brand-start to-brand-end border-none text-white hover:opacity-90 transition-opacity/5 text-brand-start rounded-lg"},[t("svg",{xmlns:"http://www.w3.org/2000/svg",class:"h-6 w-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[t("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M20 7l-8-4-8 4m16 0l-8 4m8-4v10l-8 4m0-10L4 7m8 4v10M4 7v10l8 4"})])],-1)),t("h2",Wt,"Productos ("+n(D.value)+")",1)]),t("div",Jt,[(u(!0),c(M,null,N(r(o).products.slice(0,3),(s,g)=>(u(),c("div",{key:g,class:"flex items-center gap-3 p-2 hover:bg-gray-50 dark:hover:bg-gray-700/50 rounded-lg transition-colors"},[t("div",Yt,[t("img",{src:s.image||"https://placehold.co/50?text=No+Img",alt:"",class:"h-full w-full object-cover"},null,8,Qt)]),t("div",Xt,[t("p",Zt,n(s.name),1),t("p",te,n(s.sku),1)]),t("div",ee,[t("p",se,n(s.qty)+" x "+n(m(s.price)),1)])]))),128)),r(o).products.length>3?(u(),c("div",oe,[t("span",re,"+ "+n(r(o).products.length-3)+" más...",1)])):S("",!0),t("button",{onClick:e[4]||(e[4]=s=>y.value=!0),class:"w-full py-2 mt-2 text-sm text-brand-start font-medium hover:bg-gradient-to-r from-brand-start to-brand-end border-none text-white hover:opacity-90 transition-opacity/5 rounded-lg transition-colors border border-dashed border-brand-start/50"}," Ver todos / Editar Productos ")])]),t("div",ae,[e[43]||(e[43]=t("div",{class:"flex items-center gap-3 mb-4"},[t("div",{class:"p-2 bg-green-50 text-green-600 rounded-lg"},[t("svg",{xmlns:"http://www.w3.org/2000/svg",class:"h-6 w-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[t("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M12 8c-1.657 0-3 .895-3 2s1.343 2 3 2 3 .895 3 2-1.343 2-3 2m0-8c1.11 0 2.08.402 2.599 1M12 8V7m0 1v8m0 0v1m0-1c-1.11 0-2.08-.402-2.599-1M21 12a9 9 0 11-18 0 9 9 0 0118 0z"})])]),t("h2",{class:"text-lg font-bold text-gray-800 dark:text-white"},"Finanzas")],-1)),t("div",ne,[t("div",le,[e[40]||(e[40]=t("span",{class:"text-gray-500"},"Ventas Totales",-1)),t("span",ie,n(m(r(o).financials.total_sales)),1)]),t("div",de,[e[41]||(e[41]=t("span",{class:"text-gray-500"},"Costo EnvÃo",-1)),t("span",ce,n(m(r(o).financials.shipping_cost)),1)]),t("div",ue,[e[42]||(e[42]=t("span",{class:"text-sm font-bold text-gray-700 dark:text-gray-300"},"Utilidad Neta",-1)),t("span",ge,n(m(lt.value.netProfit)),1)])])]),t("div",me,[e[44]||(e[44]=t("div",{class:"flex items-center gap-3 mb-4"},[t("div",{class:"p-2 bg-gradient-to-r from-brand-start to-brand-end border-none text-white hover:opacity-90 transition-opacity/5 text-brand-start rounded-lg"},[t("svg",{xmlns:"http://www.w3.org/2000/svg",class:"h-6 w-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[t("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M7 8h10M7 12h4m1 8l-4-4H5a2 2 0 01-2-2V6a2 2 0 012-2h14a2 2 0 012 2v8a2 2 0 01-2 2h-3l-4 4z"})])]),t("h2",{class:"text-lg font-bold text-gray-800 dark:text-white"},"Observaciones")],-1)),L(t("textarea",{"onUpdate:modelValue":e[5]||(e[5]=s=>r(o).observations=s),rows:"3",class:"w-full rounded-lg border-gray-200 dark:border-gray-700 dark:bg-gray-900 text-sm focus:ring-brand-start focus:border-brand-start resize-none",placeholder:"Agregar notas..."},null,512),[[Y,r(o).observations]])])])]),i(I,{show:_.value,onClose:e[15]||(e[15]=s=>_.value=!1),maxWidth:"md"},{default:h(()=>[t("div",pe,[t("div",xe,[e[46]||(e[46]=t("h2",{class:"text-lg font-bold text-gray-900 dark:text-white"},"Editar Cliente",-1)),t("button",{onClick:e[6]||(e[6]=s=>_.value=!1),class:"text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 transition-colors"},[...e[45]||(e[45]=[t("svg",{xmlns:"http://www.w3.org/2000/svg",class:"h-6 w-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[t("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M6 18L18 6M6 6l12 12"})],-1)])])]),t("div",be,[t("div",null,[i(b,{value:"Nombre"}),i(T,{modelValue:r(o).customer.name,"onUpdate:modelValue":e[7]||
1(e[7]=s=>r(o).customer.name=s),class:"w-full mt-1"},null,8,["modelValue"])]),t("div",null,[i(b,{value:"Teléfono"}),i(T,{modelValue:r(o).customer.phone,"onUpdate:modelValue":e[8]||(e[8]=s=>r(o).customer.phone=s),class:"w-full mt-1"},null,8,["modelValue"])]),t("div",null,[i(b,{value:"Email"}),i(T,{modelValue:r(o).customer.email,"onUpdate:modelValue":e[9]||(e[9]=s=>r(o).customer.email=s),class:"w-full mt-1",type:"email"},null,8,["modelValue"])]),t("div",ve,[t("div",null,[i(b,{value:"Región"}),i(z,{modelValue:r(o).customer.region,"onUpdate:modelValue":[e[10]||(e[10]=s=>r(o).customer.region=s),e[11]||(e[11]=s=>r(o).customer.commune="")],options:ot.value,placeholder:"Seleccione Región...",showAllOption:!1,class:"w-full mt-1"},null,8,["modelValue","options"])]),t("div",null,[i(b,{value:"Comuna"}),i(z,{modelValue:r(o).customer.commune,"onUpdate:modelValue":e[12]||(e[12]=s=>r(o).customer.commune=s),options:rt.value,placeholder:"Seleccione Comuna...",disabled:!r(o).customer.region,showAllOption:!1,class:"w-full mt-1",valueKey:"name"},null,8,["modelValue","options","disabled"])])]),t("div",null,[i(b,{value:"Dirección"}),i(T,{modelValue:r(o).customer.address,"onUpdate:modelValue":e[13]||(e[13]=s=>r(o).customer.address=s),class:"w-full mt-1"},null,8,["modelValue"])])]),t("div",he,[t("button",{onClick:e[14]||(e[14]=s=>_.value=!1),class:"px-4 py-2 bg-gradient-to-r from-brand-start to-brand-end border-none text-white text-white rounded-lg font-bold hover:opacity-90 transition-opacity"},"Listo")])])]),_:1},8,["show"]),i(I,{show:C.value,onClose:e[20]||(e[20]=s=>C.value=!1),maxWidth:"md"},{default:h(()=>[t("div",ye,[t("div",fe,[e[48]||(e[48]=t("h2",{class:"text-lg font-bold text-gray-900 dark:text-white"},"Editar EnvÃo",-1)),t("button",{onClick:e[16]||(e[16]=s=>C.value=!1),class:"text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 transition-colors"},[...e[47]||(e[47]=[t("svg",{xmlns:"http://www.w3.org/2000/svg",class:"h-6 w-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[t("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M6 18L18 6M6 6l12 12"})],-1)])])]),t("div",we,[t("div",null,[i(b,{value:"Transportista"}),i(z,{modelValue:r(o).carrier,"onUpdate:modelValue":e[17]||(e[17]=s=>r(o).carrier=s),options:et.value,valueKey:"code",labelKey:"name",placeholder:"Seleccionar transportista",showAllOption:!1,class:"mt-1"},null,8,["modelValue","options"])]),t("div",null,[i(b,{value:"Tipo de EnvÃo"}),L(t("select",{"onUpdate:modelValue":e[18]||(e[18]=s=>r(o).shipping_type=s),class:"w-full mt-1 rounded-lg border-gray-300 dark:border-gray-600 dark:bg-gray-700 text-sm"},[(u(),c(M,null,N(st,s=>t("option",{key:s,value:s},n(s),9,ke)),64))],512),[[J,r(o).shipping_type]])])]),t("div",_e,[t("button",{onClick:e[19]||(e[19]=s=>C.value=!1),class:"px-4 py-2 bg-gradient-to-r from-brand-start to-brand-end border-none text-white text-white rounded-lg font-bold hover:opacity-90 transition-opacity"},"Listo")])])]),_:1},8,["show"]),i(I,{show:y.value,onClose:e[24]||(e[24]=s=>y.value=!1),maxWidth:"lg"},{default:h(()=>[t("div",Ce,[t("div",Ve,[t("div",je,[e[50]||(e[50]=t("h2",{class:"text-lg font-bold text-gray-900 dark:text-white"},"Gestionar Productos",-1)),t("button",{onClick:e[21]||(e[21]=s=>y.value=!1),class:"text-gray-400 hover:text-gray-600 dark:hover:text-gray-300 transition-colors"},[...e[49]||(e[49]=[t("svg",{xmlns:"http://www.w3.org/2000/svg",class:"h-6 w-6",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[t("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M6 18L18 6M6 6l12 12"})],-1)])])]),t("div",Ee,[t("div",Me,[i(z,{modelValue:f.value,"onUpdate:modelValue":e[22]||(e[22]=s=>f.value=s),options:nt.value,placeholder:"Buscar producto (Nombre, SKU)...",class:"w-full",labelKey:"label",valueKey:"value",searchKeys:["label","sku","short_id","barcode"],showAllOption:!1,onSearch:r(at)},{trigger:h(({selected:s,placeholder:g})=>[s?(u(),c("span",$e,[t("span",null,n(s.label),1),s.sku?(u(),c("span",Pe,"("+n(s.sku)+")",1)):S("",!0)])):(u(),c("span",Oe,n(g),1))]),option:h(({option:s})=>[s.isGroup?(u(),c("div",Le,n(s.label),1)):(u(),c("div",{key:1,class:U([{"pl-4":s.isChild},"flex items-center gap-3 min-w-0 py-1"])},[t("div",Ne,[t("img",{src:s.image,class:"w-10 h-10 object-cover rounded border border-gray-200 dark:border-gray-700",alt:""},null,8,Se)]),t("div",Te,[t("span",ze,[s.isChild?(u(),c("span",Ue,"â")):S("",!0),B(" "+n(s.name),1)]),t("div",Be,[t("span",Ie,"SKU: "+n(s.sku),1),t("span",{class:U(["font-bold",s.stock>0?"text-green-600 dark:text-green-400":"text-red-600 dark:text-red-400"])},"Stock: "+n(s.stock),3),t("span",Ae,"Precio: "+n(m(s.price)),1)])])],2))]),_:1},8,["modelValue","options","onSearch"])]),t("button",{onClick:dt,disabled:!f.value,class:"bg-gradient-to-r from-brand-start to-brand-end border-none text-white text-white px-4 py-2 rounded-lg font-bold hover:opacity-90 transition-opacity disabled:opacity-50 disabled:cursor-not-allowed"}," Agregar ",8,Re)])]),t("div",De,[t("table",qe,[e[53]||(e[53]=t("thead",{class:"bg-gray-100 dark:bg-gray-800 uppercase text-gray-500 sticky top-0 z-10"},[t("tr",null,[t("th",{class:"px-2 py-2"},"Producto"),t("th",{class:"px-2 py-2 w-24 text-right"},"Precio"),t("th",{class:"px-2 py-2 text-center"},"Cant."),t("th",{class:"px-2 py-2 text-right"},"Total"),t("th",{class:"px-2 py-2 w-8"})])],-1)),t("tbody",Ke,[r(o).products.length===0?(u(),c("tr",Fe,[...e[51]||(e[51]=[t("td",{colspan:"5",class:"px-2 py-6 text-center text-gray-400"}," No hay productos ",-1)])])):S("",!0),(u(!0),c(M,null,N(r(o).products,(s,g)=>(u(),c("tr",{key:g,class:"bg-white dark:bg-gray-800 hover:bg-gray-50 dark:hover:bg-gray-700"},[t("td",Ge,[t("div",He,[t("img",{src:s.image||"https://placehold.co/50?text=No+Img",class:"h-6 w-6 rounded object-cover border hidden sm:block"},null,8,We),t("div",Je,[t("div",Ye,n(s.name),1),t("div",Qe,n(s.sku),1)])])]),t("td",Xe,[L(t("input",{type:"number","onUpdate:modelValue":d=>s.price=d,onInput:V,class:"w-20 px-1 py-0.5 text-right text-xs border-gray-300 dark:border-gray-600 dark:bg-gray-700 rounded focus:ring-brand-start focus:border-brand-start"},null,40,Ze),[[Y,s.price]])]),t("td",ts,[t("div",es,[t("button",{onClick:d=>{s.qty>1&&s.qty--,V()},class:"w-5 h-5 bg-gray-200 rounded hover:bg-gray-300 font-bold text-gray-600 flex items-center justify-center"},"-",8,ss),t("span",os,n(s.qty),1),t("button",{onClick:d=>{s.qty++,V()},class:"w-5 h-5 bg-gray-200 rounded hover:bg-gray-300 font-bold text-gray-600 flex items-center justify-center"},"+",8,rs)])]),t("td",as,n(m(s.price*s.qty)),1),t("td",ns,[t("button",{onClick:d=>ct(g),class:"text-gray-400 hover:text-red-500 transition-colors"},[...e[52]||(e[52]=[t("svg",{xmlns:"http://www.w3.org/2000/svg",class:"h-4 w-4",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor"},[t("path",{"stroke-linecap":"round","stroke-linejoin":"round","stroke-width":"2",d:"M6 18L18 6M6 6l12 12"})],-1)])],8,ls)])]))),128))])])]),t("div",is,[t("div",ds,[t("div",null,[e[54]||(e[54]=t("span",{class:"text-gray-500"},"Items:",-1)),e[55]||(e[55]=B()),t("span",cs,n(D.value),1)]),t("div",null,[e[56]||(e[56]=t("span",{class:"text-gray-500"},"Total:",-1)),e[57]||(e[57]=B()),t("span",us,n(m(it.value)),1)])]),t("button",{onClick:e[23]||(e[23]=s=>y.value=!1),class:"px-6 py-2 bg-gradient-to-r from-brand-start to-brand-end border-none text-white text-white rounded-lg font-bold hover:opacity-90 transition-opacity shadow-sm"}," Confirmar Cambios ")])])]),_:1},8,["show"])]),_:1})],64))}},Os=kt(gs,[["__scopeId","data-v-255b7db4"]]);export{Os as default};
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.