PageSourceSearch

https://1x1.systems/_nuxt/cart.ecZ5euuP.js

js 1x1.systems collected 2026-10-06 13:50:14 UTC 5,686 bytes, 1 lines download raw bytes

1import{i as s,E as C,j as p,b as c,I as y,J as v}from"./entry.2ehg4ZD6.js";function _(t,r){const e=encodeURIComponent(r).match(/.{1,4000}/g);e.forEach((n,a)=>{s(`${t}_${a}`,{encode:o=>o}).value=n}),s(t+"_length").value=e.length+"",s(t).value=void 0;let i=e.length;for(;s(`${t}_${i}`).value;)s(`${t}_${i}`).value=void 0,i++}function L(t){const r=parseInt(s(t+"_length").value);if(r){let e="";for(let i=0;i<r;i++)e+=s(`${t}_${i}`,{decode:n=>n}).value;return decodeURIComponent(e)}return s(t).value}const S=C("cart",{state:()=>({cartList:[],currency:"eur",subscription:null,discounts:[],formData:{name:"",company:"",email:"",confirmEmail:"",consent:!1,newsletterStatus:!1}}),actions:{productInCart(t){return this.cartList.find(r=>{var e;return((e=r.product)==null?void 0:e.id)===t.id})},addProductToCart({id:t,product:r,quantity:e=1,parameters:i,variations:n,outputs:a}){this.productInCart(r)&&this.removeProductFromCart(r),r!=null&&r.id&&(p("media"+t,"").value=void 0),this.cartList.push({id:t,product:r,quantity:e,parameters:i,variations:n,outputs:a})},removeProductFromCart(t,r){const e=this.productInCart(t);e!=null&&e.id&&(p("media"+(e==null?void 0:e.id),"").value=void 0),e&&(r&&e.quantity>=2?e.quantity-=r:this.cartList.splice(this.cartList.indexOf(e),1))},printedPartInCart(t){return this.cartList.find(r=>{var e;return((e=r.printed_part)==null?void 0:e.url)===t.url})},addPrintedPartToCart(t,r=1,e,i){this.printedPartInCart(t)&&this.removePrintedPartFromCart(t),this.cartList.push({printed_part:{...t,id:parseInt(t.id.replace("p-",""))},quantity:r,parameters:e,variations:i})},removePrintedPartFromCart(t,r){const e=this.printedPartInCart(t);e&&(r&&e.quantity>=2?e.quantity-=r:this.cartList.splice(this.cartList.indexOf(e),1))},addSubscriptionToCart(t){this.subscription=t},removeSubscriptionFromCart(){this.subscription=null},clearCart(){this.cartList=[],this.subscription=null},async applyCoupon(t){console.log(t);const r=c();if(this.discounts.find(e=>e.code.toLowerCase()===t.toLowerCase()))return!1;try{const{data:e}=await r.fetchCoupon({code:t});return console.log(e),e.value?(this.discounts.push(e.value),!0):!1}catch(e){return console.error("Error applying coupon:",e),!1}},async createMemberDownloadOrder(t,r,e,i,n){try{const a=y(),o=v(),h={name:r.title,price:0,quantity:1,product:r.id,parameters:e,variations:i,outputs:n},f={user:t.id,cart:[h],total:0,currency:"eur",customer_details:{name:t.username,email:t.email,registered:!0},order_state:"Processing...",order_method:"Member Download",order_method_id:null},l=await await a("/orders",{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${o.value}`},body:{data:f}}),u=l.data;if(u&&u.id){const{id:g,attributes:m}=u,d={...m,id:g};return console.log("Order successfully created:",d),d}else return console.error("Error in order creation:",l),null}catch(a){console.error("Error creating order:",a.message||a.description||a)}},updateFormData(t){this.formData={...this.formData,...t,fullName:t.name&&t.lastname?`${t.name} ${t.lastname}`:t.name}},getFormData(){return this.formData},setCurrency(t){this.currency=t}},getters:{getCartList(t){return t.cartList.filter(r=>{var e,i;return((e=r.product)==null?void 0:e.title)||((i=r.printed_part)==null?void 0:i.title)}).sort((r,e)=>{var i,n,a,o;return(((i=r.product)==null?void 0:i.title)||((n=r.printed_part)==null?void 0:n.title)).localeCompare(((a=e.product)==null?void 0:a.title)||((o=e.printed_part)==null?void 0:o.title))})},isCartEmpty:t=>t.cartList.length===0&&(t.subscription===null||Object.keys(t.subscription).length===0),countProducts(){return this.getCartList.reduce((t,r)=>(r.quantity&&(t+=r.quantity),t),null)},getCartTotal(t){return t.subscription&&Object.keys(t.subscription).length>0?t.subscription.price[t.currency]||t.subscription.price.eur||0:this.getCartList.reduce((r,e)=>(e.quantity&&(r+=e.quantity*this.getProductPrice(e.product||e.printed_part)),r),null)},getTax(){const t=this.getCartTotal;return(t-t*(81/100)).toFixed(2)},getCartSubtotal(){const t=this.getCartTotal,r=parseFloat(this.getTax),e=t-r;return Math.max(e,0).toFixed(2)},getCartTotalWithDiscounts(t){if(t.discounts.length>0){const r=t.discounts.reduce((e,i)=>(e+=i.amount,e),null);return(this.getCartTotal*((100-r)/100)).toFixed(2)}else return this.getCartTotal},getProductQuantityInCart(){return t=>{const r=this.getCartList.find(e=>e.product.id===t.id);return r&&r.quantity||0}},getProductPrice:t=>r=>r.price!=null&&(r.price[t.currency]||r.price.eur)||0,getProductStartingFromPrice:t=>r=>r.starting_from_price!=null?r.starting_from_price[t.currency]||r.starting_from_price.eur||0:r.price!=null&&(r.price[t.currency]||r.price.eur)||0,getCurrency:t=>t.currency,getDiscounts:t=>t.discounts},persist:{key:"1x1_CART",storage:{getItem:L,setItem:_},afterRestore(t){t.store.cartList&&Promise.all(t.store.cartList.map(r=>
1r.product?c().fetchProduct({id:r.product}).then(e=>e.data.value?{id:r.id,product:e.data.value,quantity:r.quantity,parameters:r.parameters,variations:r.variations,outputs:r.outputs}:null):r.printed_part?c().fetchPrintedPart({id:r.printed_part}).then(e=>e.data.value?{id:r.id,printed_part:e.data.value,quantity:r.quantity,parameters:r.parameters,variations:r.variations,outputs:r.outputs}:null):null)).then(r=>{t.store.$patch({cartList:r.filter(e=>e)})})},serializer:{serialize:t=>JSON.stringify({cartList:t.cartList.map(r=>{var e,i;return{id:r.id,product:(e=r.product)==null?void 0:e.id,printed_part:(i=r.printed_part)==null?void 0:i.id,quantity:r.quantity,parameters:r.parameters,variations:r.variations,outputs:r.outputs}}),currency:t.currency,subscription:t.subscription,formData:t.formData}),deserialize:JSON.parse}}});export{L as g,_ as s,S as u};

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.