import{B as A,k as E,f as F,o as v,c,m as y,g as O,z as R,t as k,h as C,_ as L,O as M,G as T,a as s,e as t,u as a,y as h,w as u,Q as W,H as _,A as m,C as j}from"./index-0UBdiff-.js";import{s as H,a as d,b as K,c as I}from"./index-aOv36DCp.js";import{s as $}from"./index-CUzG0H3y.js";import{s as B}from"./index-DyXHV6MN.js";var Q=`
    .p-progressbar {
        display: block;
        position: relative;
        overflow: hidden;
        height: dt('progressbar.height');
        background: dt('progressbar.background');
        border-radius: dt('progressbar.border.radius');
    }

    .p-progressbar-value {
        margin: 0;
        background: dt('progressbar.value.background');
    }

    .p-progressbar-label {
        color: dt('progressbar.label.color');
        font-size: dt('progressbar.label.font.size');
        font-weight: dt('progressbar.label.font.weight');
    }

    .p-progressbar-determinate .p-progressbar-value {
        height: 100%;
        width: 0%;
        position: absolute;
        display: none;
        display: flex;
        align-items: center;
        justify-content: center;
        overflow: hidden;
        transition: width 1s ease-in-out;
    }

    .p-progressbar-determinate .p-progressbar-label {
        display: inline-flex;
    }

    .p-progressbar-indeterminate .p-progressbar-value::before {
        content: '';
        position: absolute;
        background: inherit;
        inset-block-start: 0;
        inset-inline-start: 0;
        inset-block-end: 0;
        will-change: inset-inline-start, inset-inline-end;
        animation: p-progressbar-indeterminate-anim 2.1s cubic-bezier(0.65, 0.815, 0.735, 0.395) infinite;
    }

    .p-progressbar-indeterminate .p-progressbar-value::after {
        content: '';
        position: absolute;
        background: inherit;
        inset-block-start: 0;
        inset-inline-start: 0;
        inset-block-end: 0;
        will-change: inset-inline-start, inset-inline-end;
        animation: p-progressbar-indeterminate-anim-short 2.1s cubic-bezier(0.165, 0.84, 0.44, 1) infinite;
        animation-delay: 1.15s;
    }

    @keyframes p-progressbar-indeterminate-anim {
        0% {
            inset-inline-start: -35%;
            inset-inline-end: 100%;
        }
        60% {
            inset-inline-start: 100%;
            inset-inline-end: -90%;
        }
        100% {
            inset-inline-start: 100%;
            inset-inline-end: -90%;
        }
    }
    @-webkit-keyframes p-progressbar-indeterminate-anim {
        0% {
            inset-inline-start: -35%;
            inset-inline-end: 100%;
        }
        60% {
            inset-inline-start: 100%;
            inset-inline-end: -90%;
        }
        100% {
            inset-inline-start: 100%;
            inset-inline-end: -90%;
        }
    }

    @keyframes p-progressbar-indeterminate-anim-short {
        0% {
            inset-inline-start: -200%;
            inset-inline-end: 100%;
        }
        60% {
            inset-inline-start: 107%;
            inset-inline-end: -8%;
        }
        100% {
            inset-inline-start: 107%;
            inset-inline-end: -8%;
        }
    }
    @-webkit-keyframes p-progressbar-indeterminate-anim-short {
        0% {
            inset-inline-start: -200%;
            inset-inline-end: 100%;
        }
        60% {
            inset-inline-start: 107%;
            inset-inline-end: -8%;
        }
        100% {
            inset-inline-start: 107%;
            inset-inline-end: -8%;
        }
    }
`,q={root:function(b){var p=b.instance;return["p-progressbar p-component",{"p-progressbar-determinate":p.determinate,"p-progressbar-indeterminate":p.indeterminate}]},value:"p-progressbar-value",label:"p-progressbar-label"},J=A.extend({name:"progressbar",style:Q,classes:q}),X={name:"BaseProgressBar",extends:E,props:{value:{type:Number,default:null},mode:{type:String,default:"determinate"},showValue:{type:Boolean,default:!0}},style:J,provide:function(){return{$pcProgressBar:this,$parentInstance:this}}},x={name:"ProgressBar",extends:X,inheritAttrs:!1,computed:{progressStyle:function(){return{width:this.value+"%",display:"flex"}},indeterminate:function(){return this.mode==="indeterminate"},determinate:function(){return this.mode==="determinate"},dataP:function(){return F({determinate:this.determinate,indeterminate:this.indeterminate})}}},Y=["aria-valuenow","data-p"],Z=["data-p"],ee=["data-p"],ne=["data-p"];function te(r,b,p,w,g,o){return v(),c("div",y({role:"progressbar",class:r.cx("root"),"aria-valuemin":"0","aria-valuenow":r.value,"aria-valuemax":"100","data-p":o.dataP},r.ptmi("root")),[o.determinate?(v(),c("div",y({key:0,class:r.cx("value"),style:o.progressStyle,"data-p":o.dataP},r.ptm("value")),[r.value!=null&&r.value!==0&&r.showValue?(v(),c("div",y({key:0,class:r.cx("label"),"data-p":o.dataP},r.ptm("label")),[O(r.$slots,"default",{},function(){return[R(k(r.value+"%"),1)]})],16,ee)):C("",!0)],16,Z)):o.indeterminate?(v(),c("div",y({key:1,class:r.cx("value"),"data-p":o.dataP},r.ptm("value")),null,16,ne)):C("",!0)],16,Y)}x.render=te;const ae={class:"page module-accent",style:{"--accent-color":"var(--module-imports)"}},re={class:"page-header"},se={class:"card-block"},ie={class:"page-subtitle",style:{"font-size":"0.72rem"}},le={class:"field"},oe={class:"field"},de={class:"field"},ue={class:"field"},pe={class:"grid-2"},me={class:"field"},fe={class:"field"},ve={__name:"Imports",setup(r){const b=j(),p=M(),w=m([]),g=m(!0),o=m([]),V=m([]);async function S(){g.value=!0;const{data:i}=await _.getImports();w.value=i,g.value=!1}function z(i){return{Onboarding:"warn","Pending Approval":"info",Integrated:"success",Unintegrated:"secondary"}[i]||"secondary"}function U(i){return i.total_rows?Math.round((i.onboarded_rows+i.discarded_rows)/i.total_rows*100):0}function N(i){b.push({name:"import-onboarding",params:{id:i.id}})}const f=m(!1),l=m({import_number:"",supplier_id:null,product_group_id:null,season:"",effective_from:new Date,effective_to:new Date});async function D(){if(f.value=!0,o.value.length===0){const[i,e]=await Promise.all([_.getSuppliers(),_.getProductGroups()]);o.value=i.data,V.value=e.data}}function P(i){return new Date(i).toISOString().slice(0,10)}async function G(){var i,e;try{const n={...l.value,effective_from:P(l.value.effective_from),effective_to:P(l.value.effective_to)};await _.createImport(n),p.add({severity:"success",summary:"Import created",detail:"Ready for onboarding",life:3e3}),f.value=!1,S()}catch(n){p.add({severity:"error",summary:"Error",detail:((e=(i=n.response)==null?void 0:i.data)==null?void 0:e.error)||"Create failed",life:4e3})}}return T(S),(i,e)=>(v(),c("div",ae,[s("div",re,[e[8]||(e[8]=s("div",null,[s("h1",null,"Import Management"),s("p",{class:"page-subtitle"},"Supplier price file imports, working through the style onboarding wizard.")],-1)),t(a(h),{label:"Create Import",icon:"pi pi-plus",onClick:D})]),s("div",se,[t(a(H),{value:w.value,loading:g.value,dataKey:"id",stripedRows:"",responsiveLayout:"scroll"},{empty:u(()=>[...e[9]||(e[9]=[s("div",{class:"empty-state"},"No imports yet. Create one to start onboarding styles.",-1)])]),default:u(()=>[t(a(d),{field:"import_number",header:"Import"}),t(a(d),{field:"supplier_name",header:"Supplier"}),t(a(d),{field:"product_group_name",header:"Product Group"}),t(a(d),{field:"season",header:"Season"}),t(a(d),{field:"status",header:"Status"},{body:u(({data:n})=>[t(a(K),{value:n.status,severity:z(n.status)},null,8,["value","severity"])]),_:1}),t(a(d),{header:"Progress",style:{width:"200px"}},{body:u(({data:n})=>[t(a(x),{value:U(n),showValue:!0,style:{height:"0.8rem"}},null,8,["value"]),s("span",ie,k(n.onboarded_rows+n.discarded_rows)+" / "+k(n.total_rows)+" classified ",1)]),_:1}),t(a(d),{field:"imported_by",header:"Imported By"}),t(a(d),{header:"",style:{width:"140px"}},{body:u(({data:n})=>[t(a(h),{label:"Open",icon:"pi pi-arrow-right",text:"",onClick:ce=>N(n)},null,8,["onClick"])]),_:1})]),_:1},8,["value","loading"])]),t(a(W),{visible:f.value,"onUpdate:visible":e[7]||(e[7]=n=>f.value=n),modal:"",header:"Create Import",style:{width:"480px"}},{footer:u(()=>[t(a(h),{label:"Cancel",text:"",onClick:e[6]||(e[6]=n=>f.value=!1)}),t(a(h),{label:"Create",onClick:G})]),default:u(()=>[s("div",le,[e[10]||(e[10]=s("label",null,"Import Reference",-1)),t(a($),{modelValue:l.value.import_number,"onUpdate:modelValue":e[0]||(e[0]=n=>l.value.import_number=n),fluid:"",placeholder:"Import File 4"},null,8,["modelValue"])]),s("div",oe,[e[11]||(e[11]=s("label",null,"Supplier",-1)),t(a(I),{modelValue:l.value.supplier_id,"onUpdate:modelValue":e[1]||(e[1]=n=>l.value.supplier_id=n),options:o.value,optionLabel:"name",optionValue:"id",fluid:"",placeholder:"Select a supplier"},null,8,["modelValue","options"])]),s("div",de,[e[12]||(e[12]=s("label",null,"Product Group",-1)),t(a(I),{modelValue:l.value.product_group_id,"onUpdate:modelValue":e[2]||(e[2]=n=>l.value.product_group_id=n),options:V.value,optionLabel:"name",optionValue:"id",fluid:"",placeholder:"Select a product group"},null,8,["modelValue","options"])]),s("div",ue,[e[13]||(e[13]=s("label",null,"Season",-1)),t(a($),{modelValue:l.value.season,"onUpdate:modelValue":e[3]||(e[3]=n=>l.value.season=n),fluid:"",placeholder:"AW26"},null,8,["modelValue"])]),s("div",pe,[s("div",me,[e[14]||(e[14]=s("label",null,"Effective From",-1)),t(a(B),{modelValue:l.value.effective_from,"onUpdate:modelValue":e[4]||(e[4]=n=>l.value.effective_from=n),dateFormat:"yy-mm-dd",fluid:""},null,8,["modelValue"])]),s("div",fe,[e[15]||(e[15]=s("label",null,"Effective To",-1)),t(a(B),{modelValue:l.value.effective_to,"onUpdate:modelValue":e[5]||(e[5]=n=>l.value.effective_to=n),dateFormat:"yy-mm-dd",fluid:""},null,8,["modelValue"])])])]),_:1},8,["visible"])]))}},_e=L(ve,[["__scopeId","data-v-81c3b58f"]]);export{_e as default};
