(function(){const e={NONE:0,USD:1,CAD:2,JPY:3,CNY:4,AUD:5,NZD:6,INR:7,BRL:8,ZAR:9,RUB:10,KRW:11,MXN:12,AED:13,SAR:14,EUR:15,GBP:16,CHF:17,SEK:18,DKK:19,NOK:20,HRK:21,HUF:22,CZK:23,PLN:24,BGN:25,RON:26,BAM:27,RSD:28,ALL:29,MKD:30,ISK:31,BHD:35,KWD:36};function x(e,t){try{n=e.toString().split(".")[1].length}catch{n=0}try{s=t.toString().split(".")[1].length}catch{s=0}var n,s,o=Math.pow(10,Math.max(n,s));return(e*o+t*o)/o}function O(e,t){try{n=e.toString().split(".")[1].length}catch{n=0}try{s=t.toString().split(".")[1].length}catch{s=0}var n,s,o=Math.pow(10,Math.max(n,s)),i=n>=s?n:s;return Number(((e*o-t*o)/o).toFixed(i))}function w(e,t){var n=0,s=e.toString(),o=t.toString();try{n+=s.split(".")[1].length}catch{}try{n+=o.split(".")[1].length}catch{}return Number(s.replace(".",""))*Number(o.replace(".",""))/Math.pow(10,n)}function d(e,t){var o,i,n=0,s=0;try{n=e.toString().split(".")[1].length}catch{}try{s=t.toString().split(".")[1].length}catch{}return o=Number(e.toString().replace(".","")),i=Number(t.toString().replace(".","")),o/i*Math.pow(10,s-n)}var t={add:x,sub:O,mul:w,div:d};window.__xcotton_is_debug_mode__=!1,window.__xcotton_calculate__currency__={[e.NONE]:{CNameEn:"None",CSymbol:"None"},[e.USD]:{CNameEn:"USD",CSymbol:"$"},[e.CAD]:{CNameEn:"CAD",CSymbol:"$"},[e.JPY]:{CNameEn:"JPY",CSymbol:"¥"},[e.CNY]:{CNameEn:"CNY",CSymbol:"¥"},[e.AUD]:{CNameEn:"AUD",CSymbol:"$"},[e.NZD]:{CNameEn:"NZD",CSymbol:"$"},[e.INR]:{CNameEn:"INR",CSymbol:"₹"},[e.BRL]:{CNameEn:"BRL",CSymbol:"R$"},[e.ZAR]:{CNameEn:"ZAR",CSymbol:"R"},[e.RUB]:{CNameEn:"RUB",CSymbol:"₽"},[e.KRW]:{CNameEn:"KRW",CSymbol:"₩"},[e.MXN]:{CNameEn:"MXN",CSymbol:"$"},[e.AED]:{CNameEn:"AED",CSymbol:"د.إ"},[e.SAR]:{CNameEn:"SAR",CSymbol:"﷼"},[e.EUR]:{CNameEn:"EUR",CSymbol:"€"},[e.GBP]:{CNameEn:"GBP",CSymbol:"£"},[e.CHF]:{CNameEn:"CHF",CSymbol:"Fr."},[e.SEK]:{CNameEn:"SEK",CSymbol:"kr"},[e.DKK]:{CNameEn:"DKK",CSymbol:"kr"},[e.NOK]:{CNameEn:"NOK",CSymbol:"kr"},[e.HRK]:{CNameEn:"HRK",CSymbol:"kn"},[e.HUF]:{CNameEn:"HUF",CSymbol:"Ft"},[e.CZK]:{CNameEn:"CZK",CSymbol:"Kč"},[e.PLN]:{CNameEn:"PLN",CSymbol:"zł"},[e.BGN]:{CNameEn:"BGN",CSymbol:"лв."},[e.RON]:{CNameEn:"RON",CSymbol:"lei"},[e.BAM]:{CNameEn:"BAM",CSymbol:"KM"},[e.RSD]:{CNameEn:"RSD",CSymbol:"din."},[e.ALL]:{CNameEn:"ALL",CSymbol:"L"},[e.MKD]:{CNameEn:"MKD",CSymbol:"ден"},[e.ISK]:{CNameEn:"ISK",CSymbol:"kr"},[e.BHD]:{CNameEn:"BHD",CSymbol:".ب.د"},[e.KWD]:{CNameEn:"KWD",CSymbol:"د.ك"}},window.__xcotton_auth__={isOpenForSP:!0,isOpenForPP:!1},window.__xcotton_isCartDefaultOpen=!1,window.__xcotton_shopId__="34102",window.__xcotton_cdnVersion__="1.0.10_man0ijut",window.__xcotton_calculate__data__={AssetsConfig:{SPMoreUrl:"https://www.xcottons.com/XCotton#/more",SPServiceUrl:"https://www.xcottons.com/XCotton#/service",PPMoreUrl:"https://www.xcottons.com/XCotton#/ppmore",PPServiceUrl:"https://www.xcottons.com/XCotton#/ppservice"},XmhItemSkuPrefix:"XMHPACELSKU",XmhItemSkuPrefixForPP:"XMHPPSKU",CONST_MAX_AMOUNT:"13000",calcRate:"0.020",TextConfig:{SPTextConfigTitle:`Shipping Protection`,SPTextConfigDesc:`Quick refund for lost, damaged or delayed package.`,PPTextConfigTitle:``,PPTextConfigDesc:``,SPOnlyShowPrice:"",ExtendExt:"{}",SpShowBrand:!1,PpShowBrand:!1},ShopifyCurrencyList:[window.__xcotton_calculate__currency__[e.USD].CNameEn,window.__xcotton_calculate__currency__[e.CAD].CNameEn,window.__xcotton_calculate__currency__[e.EUR].CNameEn,window.__xcotton_calculate__currency__[e.AUD].CNameEn,window.__xcotton_calculate__currency__[e.GBP].CNameEn,window.__xcotton_calculate__currency__[e.JPY].CNameEn,window.__xcotton_calculate__currency__[e.AED].CNameEn,window.__xcotton_calculate__currency__[e.SAR].CNameEn,window.__xcotton_calculate__currency__[e.BHD].CNameEn,window.__xcotton_calculate__currency__[e.KWD].CNameEn,window.__xcotton_calculate__currency__[e.BRL].CNameEn,window.__xcotton_calculate__currency__[e.DKK].CNameEn,window.__xcotton_calculate__currency__[e.SEK].CNameEn],PublishedAt:"2025-12-15T17:07:43+08:00",XcottonAuth:{IsShowCartPPButton:!0},spConfig:{spMaxCoverage:"13000",spMinCoverage:"0",spGreaterMaxCoverAgeTip:`Sorry, you cannot purchase Shipping Protection for this order as the total amount exceeds the limit of `,spBelowMinCoverageTip:`Sorry, Shipping Protection is unavailable for orders under `,originalRate:""},XmhSupportCurrency:["USD","CAD","EUR","AUD","GBP","JPY","AED","SAR","BHD","KWD","BRL","DKK","SEK","PLN","NOK","MXN","NZD"],XmhSupportLocale:[{languageISO:"en",languageName:"English (US)",languageExtISO:"en-US",languageZHName:"英语（美国）"},{languageISO:"en",languageName:"English (UK)",languageExtISO:"en-GB",languageZHName:"英语（英国）"},{languageISO:"de",languageName:"Deutsch (Deutschland)",languageExtISO:"de-DE",languageZHName:"德语（德国）"},{languageISO:"fr",languageName:"Français (France)",languageExtISO:"fr-FR",languageZHName:"法语（法国）"},{languageISO:"it",languageName:"Italiano (Italia)",languageExtISO:"it-IT",languageZHName:"意大利语（意大利）"},{languageISO:"nl",languageName:"Nederlands (Nederland)",languageExtISO:"nl-NL",languageZHName:"荷兰语（荷兰）"},{languageISO:"sv",languageName:"Svenska (Sverige)",languageExtISO:"sv-SE",languageZHName:"瑞典语（瑞典）"},{languageISO:"fi",languageName:"Suomi (Suomi)",languageExtISO:"fi-FI",languageZHName:"芬兰语（芬兰）"},{languageISO:"no",languageName:"Norsk (Bokmål, nb-NO anbefales)",languageExtISO:"no-NO",languageZHName:"挪威语（博克马尔，nb-NO更精确）"},{languageISO:"nb",languageName:"Norsk Bokmål",languageExtISO:"nb-NO",languageZHName:"挪威语"},{languageISO:"pt",languageName:"Português (Portugal)",languageExtISO:"pt-PT",languageZHName:"葡萄牙语（葡萄牙）"},{languageISO:"pt",languageName:"Português (Brasil)",languageExtISO:"pt-BR",languageZHName:"葡萄牙语（巴西）"},{languageISO:"es",languageName:"Español (España)",languageExtISO:"es-ES",languageZHName:"西班牙语（西班牙）"},{languageISO:"es",languageName:"Español (Latinoamérica)",languageExtISO:"es-MX",languageZHName:"西班牙语（拉美）"},{languageISO:"ja",languageName:"日本語 (日本)",languageExtISO:"ja-JP",languageZHName:"日语（日本）"},{languageISO:"ar",languageName:"العربية (السعودية)",languageExtISO:"ar-SA",languageZHName:"阿拉伯语（沙特阿拉伯，通用）"},{languageISO:"ko",languageName:"한국어 (대한민국)",languageExtISO:"ko-KR",languageZHName:"韩语（韩国）"},{languageISO:"zh",languageName:"中文（简体）",languageExtISO:"zh-CN",languageZHName:"简体中文（中国大陆）"},{languageISO:"pl",languageName:"Polski (Polska)",languageExtISO:"pl-PL",languageZHName:"波兰语（波兰）"},{languageISO:"da",languageName:"Dansk (Danmark)",languageExtISO:"da-DK",languageZHName:"丹麦语（丹麦）"},{languageISO:"ro",languageName:"Română (România)",languageExtISO:"ro-RO",languageZHName:"罗马尼亚语"},{languageISO:"bg",languageName:"Български (България)",languageExtISO:"bg-BG",languageZHName:"保加利亚语（保加利亚）"}],SpVersion:{popup:"SP-DL-5",faqUrl:"https://sp.xcottons.com/parcel#/more/SPDL5",terms:"https://www.xcottons.com/#/terms/SP-delay"},PpVersion:{popup:"xcotton",faqUrl:"https://sp.xcottons.com/parcel#/ppmore",terms:"https://www.xcottons.com/#/terms/ppservice"},PPProductInfo:{handle:"",publishAt:""},metaData:{shopLineShopThemeVersion:"2.1"},IsSpItemFunc:void 0,LimitSpFunc:void 0,IsPpItemFunc:void 0},window.__xcotton_handle="shipping-protection",window.shopifyPluginVersion=1;function l(e){const t=e.filter(e=>{const t=window.__xcotton_calculate__data__.isspItem(e.sku||"",e.title),n=window.__xcotton_calculate__data__.isPpItem(e.sku||"",e.title),s=e.requires_shipping,o=e.gift_card;return!t&&!n&&s&&!o}).map(e=>({...e,product_id:String(e.product_id),variant_id:String(e.variant_id)}));console.debug("validItems=>",t),t.sort((e,t)=>e.product_id.localeCompare(t.product_id));let n="";for(let e of t)n+=`${e.product_id}:${e.variant_id}:${e.final_price}:${e.quantity}|`;return v(n)}function v(e){let t=0;for(let n=0;n<e.length;n++){const s=e.charCodeAt(n);t=(t<<5)-t+s,t=t&t}return(t>>>0).toString(16).padStart(8,"0")}function g(){const e={};for(const[t,s]of Object.entries(window.__xcotton_calculate__currency__||{})){let n=t;isNaN(t)?typeof t=="string"&&t.length===1&&(n=t.padStart(2,"0")):n=String(t).padStart(2,"0"),e[s.CNameEn]=n}return e}const u=g();function b(e){const t=e.toUpperCase();return u[t]||"00"}function n(e,t,n,s){const o=new Date,i=o.getUTCFullYear(),a=String(o.getUTCMonth()+1).padStart(2,"0"),r=String(o.getUTCDate()).padStart(2,"0"),c=`${i-2e3}${a}${r}`,d=Math.round(t*100),u=Math.round(n*100),h=l(e),m=b(s),f=d.toString(36).padStart(4,"0"),p=u.toString(36).padStart(4,"0"),g=window.__xcotton_shopId__,v=Number(g).toString(36).padStart(4,"0"),j=c+v+f+p+m+h;return j}const h=`
self.onmessage = function(e) {
    const { url, data } = e.data;
    fetch(url, {
        method: 'POST',
        headers: {
            'Content-Type': 'application/json'
        },
        body: JSON.stringify(data)
    }).then(response => {
        // console.debug('Report success');
    }).catch(error => {
        // console.error('Report error:', error);
    });
};
`,m=new Blob([h],{type:"application/javascript"}),f=URL.createObjectURL(m),p=new Worker(f),c="xcotton_report_cache";function r(e,t){try{const o=window.__xcotton_shopId__,s=t.disComputeId||"";let n={};try{const e=localStorage.getItem(c);e&&(n=JSON.parse(e)||{})}catch(e){console.warn("Failed to read report cache:",e)}const a=Date.now()-5*60*1e3;Object.keys(n).forEach(e=>{n[e]<a&&delete n[e]});const i=`${o}_${s}`;if(!s||n[i]){console.debug("Skip reporting: same disComputeId already reported or empty",s);return}const r={shop_id:parseInt(o),quotation_id:s,cart_content:JSON.stringify(e),calc_result:JSON.stringify(t)};n[i]=Date.now();try{localStorage.setItem(c,JSON.stringify(n))}catch(e){console.warn("Failed to save report cache:",e)}p.postMessage({url:"https://seller.xcottons.com/go/packageOpenApiWeb/report/CalcReport",data:r}),console.debug("Report sent:",s)}catch(e){console.error("Report calc data error:",e)}}window.__xcotton_calculate__data__.isPpItem=function(t,n){if(!t)return!1;if(t.indexOf(window.__xcotton_calculate__data__.XmhItemSkuPrefixForPP)===0)return!0;let s="xCotton Product Protection";return n===s},window.__xcotton_calculate__data__.isspItem=function(t,n){if(!t)return!1;if(t.indexOf(window.__xcotton_calculate__data__.XmhItemSkuPrefix)===0)return!0;if(window.__xcotton_calculate__data__.IsSpItemFunc!==void 0&&window.__xcotton_calculate__data__.IsSpItemFunc(t))return!0;let s="Xcottons Shipping Protection",o="Xcotton Shipping Protection",i="Shipping Protection";return n===s||n===o||n===i};function o(e){for(const t of Object.values(window.__xcotton_calculate__currency__))if(t.CNameEn===e)return t;return null}function j(){const e={};for(const t of window.__xcotton_calculate__data__.ShopifyCurrencyList)e[t]=1;return e}function y(e){console.debug("transToCalcParam cartjs=>",e);let s=o(e.currency);if(e.items===null||e.items.length===0){if(console.debug("No items in cart."),e.total_price!==0){let n=o(e.currency);return{OrderInfo:{TotalPayPrice:t.div(e.total_price,100).toFixed(2),Currency:e.currency,CurrencySymbol:n.CSymbol},originalCartItems:e.items||[]}}return console.debug("calc err no items and no price available"),{OrderInfo:{TotalPayPrice:0,Currency:e.currency,ItemValidNum:0,CurrencySymbol:s.CSymbol},originalCartItems:e.items||[]}}let i=0,n=0;for(let s of e.items){let o={};if(o.IsPackageItem=window.__xcotton_calculate__data__.isspItem(s.sku,s.title),o.IsPPItem=window.__xcotton_calculate__data__.isPpItem(s.sku,s.title),o.TotalPrice=s.final_line_price,o.TotalPriceInt=t.mul(s.final_line_price,100).toFixed(2),o.IsPackageItem||o.IsPPItem){console.debug(`id =>${s.id} price=>${s.final_line_price} is IsPackageItem or IsPPItem`);continue}if(i++,!s.requires_shipping){console.debug(`id =>${s.id} price=>${s.final_line_price} is no need ship`);continue}if(s.gift_card){console.debug(`id =>${s.id} price=>${s.final_line_price} is gift`);continue}n=t.add(n,o.TotalPrice)}return console.debug(`finalPrice is =>${n}`),{OrderInfo:{TotalPayPrice:n.toFixed(2),Currency:e.currency,CurrencySymbol:s.CSymbol,ItemValidNum:i},originalCartItems:e.items||[]}}function _(e){console.debug("calc  input=>",e);let i=e.OrderInfo.Currency,h=j()[i];if(!h)return{calcResult:{currency:i,currencySymbol:"",totalPrice:"0",totalPriceInt:0,extId:"0",calcState:801001},hasOriginal:!1};let l=o(i),d=parseFloat(e.OrderInfo.TotalPayPrice),u=parseFloat(window.__xcotton_calculate__data__.calcRate||0);const r=window.__xcotton_calculate__data__.spConfig.originalRate,m=r!=null&&r!==""&&!isNaN(parseFloat(r))&&parseFloat(r)>0;if(console.debug("calc rate =>",u,"original rate =>",r),d===0)return{calcResult:{currency:i,currencySymbol:l.CSymbol,totalPrice:"0",totalPriceInt:0,extId:"0",calcState:801028,disComputeId:""},hasOriginal:!1};let c=t.mul(d,u);console.debug("fee is =>",c);let s=a(c,e.shoplineProductInfo);if(s.currency=i,s.currencySymbol=l.CSymbol,typeof n=="function"&&e.isReportComputeId===!0?(s.disComputeId=n(e.originalCartItems||[],c,s.totalPrice,i),console.debug("Generated calc ID for normal quote:",s.disComputeId)):s.disComputeId="",m){const h=parseFloat(r);let u=t.mul(d,h);console.debug("originalFee is =>",u);let o=a(u,e.shoplineProductInfo);return o.currency=i,o.currencySymbol=l.CSymbol,typeof n=="function"&&e.isReportComputeId===!0?s.disComputeId=n(e.originalCartItems||[],c,s.totalPrice,i):s.disComputeId="",{calcResult:s,originalCalcResult:o,hasOriginal:!0}}return{calcResult:s,hasOriginal:!1}}function a(e,n){if(console.debug("shoplineProductInfo is =>",n),console.debug("fee is =>",e),e===0){let s=n.variants[0],e=s.price,o=2;return e>=1e4&&(o=0),{totalPrice:t.div(e,100).toFixed(o),totalPriceInt:e,extId:s.id}}let i=t.mul(e,100),a=0,s=-1;for(let e=0;e<n.variants.length;e++){let t=n.variants[e].price;if(i>a&&i<=t){s=e,console.debug("targetIndex is =>",s),console.debug("variantPrice is =>",t);break}s=e,a=t}let r=n.variants[s],o=r.price,c=2;return o>=1e4&&(c=0),{totalPrice:t.div(o,100).toFixed(c),totalPriceInt:o,extId:r.id}}window.__xcotton_calculate__limit=function(n){if(n.items.length===0)return!1;let s=0;for(let e of n.items){if(window.__xcotton_calculate__data__.isspItem(e.sku,e.title)||window.__xcotton_calculate__data__.isPpItem(e.sku,e.title)){console.debug(`id =>${e.id} price=>${e.final_line_price} is IsPackageItem or IsPPItem`);continue}s=t.add(s,e.final_line_price)}return console.debug(`current tPrice is =>${s}`),s>t.mul(window.__xcotton_calculate__data__.CONST_MAX_AMOUNT,100)},window.__xcotton_calculate__=function(e){console.debug(e);let t=null,n=null;try{return n=y(e.cartJson),console.debug("toCalcParam => ",n),n.OrderInfo.TotalPayPrice===0||n.OrderInfo.ItemValidNum===0?{computeResult:{disComputeId:"",computeState:0,computeMsg:"cart is null or no valid item",currency:n.OrderInfo.Currency,currencySymbol:n.OrderInfo.CurrencySymbol,totalPrice:"0",totalPriceInt:0,extId:"0"}}:(n.shoplineProductInfo=e.shoplineProductInfo,n.isReportComputeId=e.isReportComputeId,t=_(n),console.debug("__xcotton_calculate__ result => ",t),t&&t.hasOriginal&&t.originalCalcResult&&t.originalCalcResult.totalPriceInt!==0?{computeResult:{disComputeId:t.calcResult.disComputeId,computeState:t.calcResult&&t.calcResult.calcState||0,computeMsg:"",currency:t.calcResult.currency,currencySymbol:t.calcResult.currencySymbol,totalPrice:t.calcResult.totalPrice,totalPriceInt:t.calcResult.totalPriceInt,extId:t.calcResult.extId,originalCurrency:t.originalCalcResult.currency,originalCurrencySymbol:t.originalCalcResult.currencySymbol,originalTotalPrice:t.originalCalcResult.totalPrice,originalTotalPriceInt:t.originalCalcResult.totalPriceInt,originalExtId:t.originalCalcResult.extId,hasOriginal:t.hasOriginal}}:{computeResult:{disComputeId:t.calcResult.disComputeId,computeState:t.calcResult&&t.calcResult.calcState||0,computeMsg:"",currency:t.calcResult.currency,currencySymbol:t.calcResult.currencySymbol,totalPrice:t.calcResult.totalPrice,totalPriceInt:t.calcResult.totalPriceInt,extId:t.calcResult.extId,hasOriginal:t.hasOriginal}})}catch(e){return console.debug("calc error => ",e.stack),{computeResult:{disComputeId:"",computeState:620032,computeMsg:e.message,currency:"",currencySymbol:"",totalPrice:"0",totalPriceInt:0,extId:"0"}}}finally{if(e.isReportComputeId===!0&&typeof r=="function"&&n&&t)try{let s=n.originalCartItems.map(e=>({product_id:String(e.product_id||e.id||""),variant_id:String(e.variant_id||""),final_price:String(e.final_line_price||e.price||0),quantity:e.quantity||1}));const e={cartItems:s||null,calcResult:t?.calcResult||null};console.debug("reportData=> ",e),setTimeout(()=>{r(e.cartItems,e.calcResult)},0)}catch(e){console.error("数据上报失败:",e)}}},window.__xcotton_calculate__limit_sp=function(e){if(window.__xcotton_calculate__data__.LimitSpFunc!==void 0)return window.__xcotton_calculate__data__.LimitSpFunc(e);let n=0;for(let s of e.items){if(window.__xcotton_calculate__data__.isspItem(s.sku,s.title)||window.__xcotton_calculate__data__.isPpItem(s.sku,s.title)){console.debug(`id =>${s.id} price=>${s.final_line_price} is IsPackageItem or IsPPItem`);continue}n=t.add(n,s.final_line_price)}console.debug(`__xcotton_calculate__limit_sp tPrice is =>${n}`);let s=i(parseFloat(window.__xcotton_calculate__data__.spConfig.spMinCoverage),"USD",e.currency),o=i(parseFloat(window.__xcotton_calculate__data__.spConfig.spMaxCoverage),"USD",e.currency),a=__xcotton_calculate__data__.spConfig.spGreaterMaxCoverAgeTip,r=__xcotton_calculate__data__.spConfig.spBelowMinCoverageTip;return n<s?(console.debug("negative"),{showBoard:!1,state:!1,tips:r+s.toFixed(2),priceRange:"negative"}):n>o?(console.debug("premium"),{showBoard:!1,state:!1,tips:a+o.toFixed(2),priceRange:"premium"}):n<=o&&n>=s?(console.debug("standard"),{showBoard:!0,state:!0,tips:"",priceRange:"standard"}):(console.debug("unknown"),{showBoard:!1,state:!1,tips:"",priceRange:"unknown"})};function i(e,n,s){if(!n||!s)throw new Error(`Invalid currency: ${n} => ${s}`);if(isNaN(e))throw new Error(`Invalid amount: ${e}`);if(n===s)return e;const o=C();if(!o[n])throw new Error(`Exchange rate not found for currency: ${n}`);if(!o[s])throw new Error(`Exchange rate not found for currency: ${s}`);const i=o[n],a=o[s],r=t.div(e,i);return t.mul(r,a)}let s=null;function C(){if(s)return s;const e={},t=window.Shopline?.currencyConfig?.currencyDetailList;if(!t||!Array.isArray(t))return console.error("Currency config not found or invalid"),e;for(const n of t)n.currencyCode&&n.exchangeRate&&(e[n.currencyCode]=n.exchangeRate);return s=e,e}})()