var T=Object.defineProperty,b=Object.defineProperties;var z=Object.getOwnPropertyDescriptors;var y=Object.getOwnPropertySymbols;var I=Object.prototype.hasOwnProperty,a=Object.prototype.propertyIsEnumerable;var S=(t,e,i)=>e in t?T(t,e,{enumerable:!0,configurable:!0,writable:!0,value:i}):t[e]=i,O=(t,e)=>{for(var i in e||(e={}))I.call(e,i)&&S(t,i,e[i]);if(y)for(var i of y(e))a.call(e,i)&&S(t,i,e[i]);return t},q=(t,e)=>b(t,z(e));var D=(t,e)=>{var i={};for(var o in t)I.call(t,o)&&e.indexOf(o)<0&&(i[o]=t[o]);if(t!=null&&y)for(var o of y(t))e.indexOf(o)<0&&a.call(t,o)&&(i[o]=t[o]);return i};var l=(t,e,i)=>new Promise((o,r)=>{var s=n=>{try{d(i.next(n))}catch(u){r(u)}},c=n=>{try{d(i.throw(n))}catch(u){r(u)}},d=n=>n.done?o(n.value):Promise.resolve(n.value).then(s,c);d((i=i.apply(t,e)).next())});import{cb as B,bf as g}from"./bootstrap-Bqxdt4iG.js";const C="*, inventoryDetail:inventoryDetailId(inventory:inventoryId(tdSku, originalSku, name), location:locationId(code))";function E(t){var r,s,c,d,n,u,f,_,k,v,w,h;const o=t,{inventoryDetail:e}=o,i=D(o,["inventoryDetail"]);return q(O({},i),{inventoryTdSku:(c=(s=(r=e==null?void 0:e.inventory)==null?void 0:r.tdSku)!=null?s:i.inventoryTdSku)!=null?c:"",inventoryOriginalSku:(u=(n=(d=e==null?void 0:e.inventory)==null?void 0:d.originalSku)!=null?n:i.inventoryOriginalSku)!=null?u:"",inventoryName:(k=(_=(f=e==null?void 0:e.inventory)==null?void 0:f.name)!=null?_:i.inventoryName)!=null?k:"",locationCode:(h=(w=(v=e==null?void 0:e.location)==null?void 0:v.code)!=null?w:i.locationCode)!=null?h:""})}const A=B("packing-order-details",{state:()=>({version:0}),getters:{isMockMode:()=>!1},actions:{getList(t){return l(this,null,function*(){var f,_;let e=g.from("packing_order_details").select(C,{count:"exact"});e=e.eq("isDelete",!1),t!=null&&t.packingOrderId&&(e=e.eq("packingOrderId",t.packingOrderId)),t!=null&&t.inventoryDetailId&&(e=e.eq("inventoryDetailId",t.inventoryDetailId)),e=t!=null&&t.sortBy?e.order(t.sortBy,{ascending:t.sortOrder!=="desc"}):e.order("createdAt",{ascending:!1});const i=(f=t==null?void 0:t.page)!=null?f:1,o=(_=t==null?void 0:t.pageSize)!=null?_:10,r=(i-1)*o,s=r+o-1;e=e.range(r,s);const{data:c,error:d,count:n}=yield e;if(d)throw d;return{items:(c!=null?c:[]).map(k=>E(k)),total:n!=null?n:0,page:i,pageSize:o}})},getListByPackingOrderId(t,e){return l(this,null,function*(){var d,n;const i=(d=e==null?void 0:e.page)!=null?d:1,o=(n=e==null?void 0:e.pageSize)!=null?n:20,{data:r,error:s}=yield g.rpc("get_packing_order_details",{p_packing_order_id:t,p_sort_by:(e==null?void 0:e.sortBy)||"inventoryTdSku",p_sort_order:(e==null?void 0:e.sortOrder)||"asc",p_limit:o,p_offset:(i-1)*o});if(s)throw s;const c=r!=null?r:[];return{items:c,total:c.length,page:i,pageSize:o}})},getDetail(t){return l(this,null,function*(){const{data:e,error:i}=yield g.from("packing_order_details").select(C).eq("id",t).eq("isDelete",!1).single();if(i)throw i;return e?E(e):null})},create(t){return l(this,null,function*(){const{data:e,error:i}=yield g.from("packing_order_details").insert(t).select().single();if(i||!e)throw i!=null?i:new Error("Create failed");return this.version++,e})},update(t,e){return l(this,null,function*(){const{data:i,error:o}=yield g.from("packing_order_details").update(e).eq("id",t).select().single();if(o)throw o;return this.version++,i})},remove(t){return l(this,null,function*(){const{error:e}=yield g.from("packing_order_details").update({isDelete:!0}).eq("id",t);if(e)throw e;return this.version++,!0})},restore(t){return l(this,null,function*(){const{error:e}=yield g.from("packing_order_details").update({isDelete:!1}).eq("id",t);if(e)throw e;return this.version++,!0})},hardDelete(t){return l(this,null,function*(){const{error:e}=yield g.from("packing_order_details").delete().eq("id",t);if(e)throw e;return this.version++,!0})},invalidate(){this.version++}}});export{A as u};
