var e,t;"function"==typeof(e=globalThis.define)&&(t=e,e=null),function(t,r,o,a,n){var s="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:"undefined"!=typeof global?global:{},i="function"==typeof s[a]&&s[a],l=i.cache||{},c="undefined"!=typeof module&&"function"==typeof module.require&&module.require.bind(module);function u(e,r){if(!l[e]){if(!t[e]){var o="function"==typeof s[a]&&s[a];if(!r&&o)return o(e,!0);if(i)return i(e,!0);if(c&&"string"==typeof e)return c(e);var n=Error("Cannot find module '"+e+"'");throw n.code="MODULE_NOT_FOUND",n}d.resolve=function(r){var o=t[e][1][r];return null!=o?o:r},d.cache={};var p=l[e]=new u.Module(e);t[e][0].call(p.exports,d,p,p.exports,this)}return l[e].exports;function d(e){var t=d.resolve(e);return!1===t?{}:u(t)}}u.isParcelRequire=!0,u.Module=function(e){this.id=e,this.bundle=u,this.exports={}},u.modules=t,u.cache=l,u.parent=i,u.register=function(e,r){t[e]=[function(e,t){t.exports=r},{}]},Object.defineProperty(u,"root",{get:function(){return s[a]}}),s[a]=u;for(var p=0;p<r.length;p++)u(r[p]);if(o){var d=u(o);"object"==typeof exports&&"undefined"!=typeof module?module.exports=d:"function"==typeof e&&e.amd?e(function(){return d}):n&&(this[n]=d)}}({lEgxJ:[function(e,t,r){var o=e("@parcel/transformer-js/src/esmodule-helpers.js");o.defineInteropFlag(r),o.export(r,"config",()=>c);var a=e("../services/api"),n=e("../services/scraper"),s=e("../background/types"),i=e("../constants/partnerCode"),l=e("../utils/partnerContextClient");let c={matches:["https://detail.1688.com/*"],all_frames:!1},u="store-ops-alibaba-collector",p="__storeOpsAlibabaCollectorRouteWatch",d="__storeOpsAlibabaCollectorStorageWatch",m=null,CSS=`
:host { all: initial; }
* { box-sizing: border-box; }
.root {
  position: fixed;
  right: 20px;
  bottom: 120px;
  z-index: 2147483647;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}
.panel {
  width: 268px;
  background: #1f1f1f;
  color: #fff;
  border-radius: 12px;
  padding: 12px;
  box-shadow: 0 10px 28px rgba(0,0,0,0.25);
}
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 700;
}
.badge {
  width: 18px;
  height: 18px;
  border-radius: 6px;
  background: #ff6b35;
  display: inline-block;
}
.collapse {
  border: 0;
  background: transparent;
  color: rgba(255,255,255,0.75);
  cursor: pointer;
  font-size: 16px;
  line-height: 16px;
  padding: 4px 6px;
}
.collapse:hover { color: rgba(255,255,255,0.95); }
.desc {
  margin: 8px 0 10px;
  font-size: 12px;
  line-height: 1.4;
  color: rgba(255,255,255,0.82);
}
.btn {
  width: 100%;
  border: 0;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 13px;
  font-weight: 700;
  background: #ff6b35;
  color: #fff;
  cursor: pointer;
}
.btn:disabled {
  opacity: 0.65;
  cursor: not-allowed;
}
.status {
  margin-top: 8px;
  min-height: 16px;
  font-size: 12px;
  line-height: 1.35;
  color: rgba(255,255,255,0.85);
  word-break: break-word;
  text-align: center;
}
.status[data-type="success"] { color: #7CFFB2; }
.status[data-type="error"] { color: #ff6b6b; }
.fab {
  width: 52px;
  height: 52px;
  border-radius: 26px;
  border: 0;
  background: #ff6b35;
  color: #fff;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 10px 24px rgba(0,0,0,0.25);
}
.hidden { display: none !important; }
`;function h(e){if(e instanceof Error)return e.message;try{return String(e)}catch{return"\u672a\u77e5\u9519\u8bef"}}async function f(){let e;let t=(0,n.ScraperFactory).createScraper();if(!t)throw Error("\u65e0\u6cd5\u8bc6\u522b\u5f53\u524d\u9875\u9762\u5e73\u53f0\uff0c\u8bf7\u786e\u4fdd\u5728\u652f\u6301\u7684\u7535\u5546\u5e73\u53f0\u9875\u9762\u64cd\u4f5c");let r=t.extractContentHTML();if(!r){let e="alibaba"===t.platform?'id="content"':"\u5185\u5bb9\u5bb9\u5668";throw Error(`\u672a\u627e\u5230 ${e} \u7684\u5bb9\u5668\u5143\u7d20`)}let o=function(e,t){let r=t||document.title||"\u5546\u54c1\u8be6\u60c5";return`<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <title>${r}</title>
</head>
<body>
${e}
</body>
</html>`}(r.html,r.title);try{e=await (0,a.submitProductDetailHtml)(o)}catch(e){throw Error(`API \u8c03\u7528\u5931\u8d25: ${e instanceof Error?e.message:"\u672a\u77e5\u9519\u8bef"}`)}if(0!==e.code)throw Error(`API \u8c03\u7528\u5931\u8d25: ${e.msg||"\u672a\u77e5\u9519\u8bef"} (code: ${e.code})`);let s=window.open("about:blank","_blank");if(!s)throw Error("\u65e0\u6cd5\u6253\u5f00\u65b0\u6807\u7b7e\u9875\uff0c\u8bf7\u68c0\u67e5\u6d4f\u89c8\u5668\u5f39\u7a97\u62e6\u622a\u8bbe\u7f6e");try{let t={src:`store-ops-${r.platform}-collector`,flow:"alibaba"===r.platform?"alibaba":r.platform,ts:Date.now(),baseUrl:r.baseUrl,data:e.data},o=JSON.stringify(t);if(o.length>2097152){let e=o.length/1048576;throw Error(`\u6570\u636e\u8fc7\u5927\uff08${e.toFixed(2)}MB\uff09\uff0c\u65e0\u6cd5\u4f20\u9012\u3002\u8bf7\u8054\u7cfb\u6280\u672f\u652f\u6301\u3002`)}return s.name=o,s.location.href="https://noon-catalog.noon.partners/",e.data?.title||"\u672a\u77e5"}catch(e){try{s.close()}catch{}throw e}}function g(e){try{let t=new URL(e);return t.pathname.includes("/offer/")}catch{return!1}}function y(){return!!document.getElementById("content")}function w(){if(m)try{m.destroy()}finally{m=null}}let b=Promise.resolve(),S=()=>b=b.then(E).catch(E);async function E(){let e=function(){let e=window.location.href;return!!g(e)&&y()}();if(!e){w();let e=document.getElementById(u);if(e)try{e.remove()}catch{}return}let t=function(){try{let e=new URL(window.location.href);return`${e.origin}${e.pathname}`}catch{return window.location.href}}();m?.pageKey!==t&&(w(),m=function(e){let t=document.getElementById(u);if(t)try{t.remove()}catch{}let r=document.createElement("div");r.id=u,r.style.cssText="position: fixed; inset: auto; right: 20px; bottom: 120px; z-index: 2147483647;";let o=r.attachShadow({mode:"open"}),a=document.createElement("style");a.textContent=CSS;let n=document.createElement("div");n.className="root";let s=document.createElement("div");s.className="panel";let i=document.createElement("div");i.className="header";let c=document.createElement("div");c.className="title";let p=document.createElement("span");p.className="badge";let d=document.createElement("span");d.textContent="1688 \u91c7\u96c6",c.appendChild(p),c.appendChild(d);let m=document.createElement("button");m.className="collapse",m.type="button",m.title="\u7f29\u5c0f",m.textContent="\u2014",i.appendChild(c),i.appendChild(m);let g=document.createElement("div");g.className="desc",g.textContent="\u91c7\u96c6\u5f53\u524d\u5546\u54c1\u8be6\u60c5\u5e76\u8df3\u8f6c\u5230 Noon Catalog\u3002";let y=document.createElement("button");y.className="btn",y.type="button",y.textContent="\u70b9\u51fb\u91c7\u96c6";let w=document.createElement("div");w.className="status",w.dataset.type="info",s.appendChild(i),s.appendChild(g),s.appendChild(y),s.appendChild(w);let b=document.createElement("button");b.className="fab hidden",b.type="button",b.title="\u5c55\u5f00\u91c7\u96c6\u5de5\u5177",b.textContent="\u91c7",n.appendChild(s),n.appendChild(b),o.appendChild(a),o.appendChild(n),(document.body||document.documentElement).appendChild(r);let S=()=>document.getElementById(u)===r,E=!1,x=!1,A=null,T=!1,v=e=>{S()&&(E=e,s.classList.toggle("hidden",E),b.classList.toggle("hidden",!E))},C=e=>{S()&&(x=e,y.disabled=e||!T,y.textContent=e?"\u91c7\u96c6\u4e2d\u2026":"\u70b9\u51fb\u91c7\u96c6")},_=(e,t,r=3500)=>{S()&&(w.dataset.type=e,w.textContent=t,A&&(window.clearTimeout(A),A=null),r>0&&(A=window.setTimeout(()=>{S()&&(w.textContent="",w.dataset.type="info",A=null)},r)))},L=async()=>{if(S()){y.disabled=!0;try{let e=await (0,l.getPartnerContext)();if(!S())return;let t=(0,l.canUseCollectors)(e);(T=t.allowed)?_("success",t.message,t.showNoonCatalogHint?2500:1200):_("error",t.message,0)}catch(e){T=!1,_("error",h(e),0)}finally{S()&&(y.disabled=x||!T)}}};return m.addEventListener("click",()=>v(!0)),b.addEventListener("click",()=>v(!1)),y.addEventListener("click",async()=>{if(S()&&!x&&(T||(await L(),S()&&T))){C(!0),_("info","\u6b63\u5728\u91c7\u96c6\u2026",0);try{let e=await f();_("success",`\u91c7\u96c6\u6210\u529f\uff1a${e}\uff0c\u6b63\u5728\u6253\u5f00 Noon Catalog\u2026`,2500)}catch(e){_("error",h(e),5e3)}finally{C(!1)}}}),v(!1),L(),{pageKey:e,applyPermission:L,destroy:()=>{if(A){try{window.clearTimeout(A)}catch{}A=null}try{r.remove()}catch{}}}}(t))}function x(){(function(){let e=window;if(!e[d]){e[d]=!0;try{chrome.storage.local.onChanged.addListener(e=>{let t=!!e[i.NOON_PARTNER_CODE_STORAGE_KEY]||!!e[s.STORAGE_KEYS.AUTH_TOKEN]||!!e[s.STORAGE_KEYS.USER_INFO]||!!e[s.STORAGE_KEYS.IS_AUTHENTICATED]||!!e[s.STORAGE_KEYS.LOGIN_TIME];t&&m?.applyPermission()})}catch{}}})(),function(){let e=window;if(e[p])return;let t=window.location.href,r=g(t),o=y(),a=()=>{let e=window.location.href,a=g(e),n=y();(e!==t||a!==r||n!==o)&&(t=e,r=a,o=n,S())};window.addEventListener("popstate",a),window.addEventListener("hashchange",a);let n=window.setInterval(a,700);e[p]=n,S()}()}"loading"===document.readyState?document.addEventListener("DOMContentLoaded",x,{once:!0}):x()},{"../services/api":"kD7wG","../services/scraper":"4trOd","../background/types":"PieoM","../constants/partnerCode":"j19Rj","../utils/partnerContextClient":"44yHH","@parcel/transformer-js/src/esmodule-helpers.js":"e86qr"}],kD7wG:[function(e,t,r){var o=e("@parcel/transformer-js/src/esmodule-helpers.js");o.defineInteropFlag(r),o.export(r,"API_ENDPOINTS",()=>c),o.export(r,"NoonAPIClient",()=>p),o.export(r,"ApiError",()=>d),o.export(r,"extractSkuFromNoonUrl",()=>m),o.export(r,"fetchProductDetails",()=>f),o.export(r,"fetchProductDetailsWithHeaders",()=>g),o.export(r,"fetchProductTitle",()=>y),o.export(r,"fetchProductVariants",()=>w),o.export(r,"convertNoonUrlToApiUrl",()=>b),o.export(r,"haleemyRequest",()=>S),o.export(r,"submitAlibabaHtmlDetail",()=>E),o.export(r,"submitProductDetailHtml",()=>x),o.export(r,"submitAmazonProductDetailHtml",()=>A),o.export(r,"haleemyRequestSW",()=>T),o.export(r,"PROCESSING_TIME_OPTIONS",()=>v),o.export(r,"fetchFBPWarehouse",()=>C),o.export(r,"getCategoryList",()=>_),o.export(r,"recommendCate",()=>L),o.export(r,"apiClient",()=>U);var a=e("../background/storage"),n=e("../background/types"),s=e("../utils/debug"),i=e("../utils/messaging"),l=e("../utils/security");let c={LOGIN:"https://super.haleemy.com/api/customer/login",CUSTOMER_DETAIL:"https://super.haleemy.com/api/customer/detail",WAREHOUSE:"https://super.haleemy.com/api/customer/warehouse",GPT_SKU_TITLE:"https://super.haleemy.com/api/gpt/v1/chat/skutitle",GPT_TRANSLATE:"https://super.haleemy.com/api/gpt/v1/chat/batch_translate",ALIBABA_HTML_DETAIL:"https://super.haleemy.com/api/alibaba/html_detail",ALIBABA_TRANSLATE_IMG:"https://super.haleemy.com/api/alibaba/translate_img",AMAZON_HTML_DETAIL:"https://super.haleemy.com/api/amazon/html_msg",SKU_LIST:"https://api.noon.partners/v1/sku/list",SKU_UPDATE:"https://api.noon.partners/v1/sku/update",SKU_STATUS:"https://api.noon.partners/v1/sku/status"},u={"Content-Type":"application/json","User-Agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36",Accept:"application/json, text/plain, */*","Accept-Language":"en-US,en;q=0.9","Cache-Control":"no-cache",Pragma:"no-cache"};class p{constructor(){this.authToken=null,this.loadAuthToken()}async loadAuthToken(){(0,s.debugLog)("API Client: \u52a0\u8f7d\u8ba4\u8bc1token");try{let e=await (0,l.secureRetrieve)(n.STORAGE_KEYS.AUTH_TOKEN);this.authToken=e||null,(0,s.debugLog)("API Client: token\u52a0\u8f7d\u6210\u529f",{hasToken:!!this.authToken})}catch(e){(0,s.debugError)("API Client: \u52a0\u8f7dtoken\u5931\u8d25",e)}}setAuthToken(e){this.authToken=e}getHeaders(e=!0){let t={...u};return e&&this.authToken&&(t.Authorization=`Bearer ${this.authToken}`),t}async request(e,t={},r=!0){return(0,s.debugLog)("API \u8bf7\u6c42\u5f00\u59cb",{url:e,method:t.method||"GET",includeAuth:r}),(0,s.measurePerformance)(`API-${t.method||"GET"}-${e}`,async()=>{try{let o=await (0,s.debugFetch)(e,{...t,headers:{...this.getHeaders(r),...t.headers}}),a=await o.json();if(!o.ok)throw(0,s.debugError)("API \u8bf7\u6c42\u5931\u8d25",{url:e,status:o.status,statusText:o.statusText,data:(0,s.safeLog)(a)}),new d(a.message||`HTTP ${o.status}: ${o.statusText}`,o.status,a);return(0,s.debugLog)("API \u8bf7\u6c42\u6210\u529f",{url:e,status:o.status}),{success:!0,data:a,status:o.status}}catch(t){if((0,s.debugError)("API \u8bf7\u6c42\u5f02\u5e38",{url:e,error:t}),t instanceof d)throw t;throw new d(t instanceof Error?t.message:"Unknown error occurred",0,null)}})}async getSKUList(e){let t=new URLSearchParams;e&&Object.entries(e).forEach(([e,r])=>{null!=r&&t.append(e,String(r))});let r=`${c.SKU_LIST}?${t.toString()}`;return this.request(r)}async updateSKUStatus(e,t){return this.request(c.SKU_STATUS,{method:"PUT",body:JSON.stringify({sku_id:e,status:t})})}async batchUpdateSKUStatus(e){return this.request(`${c.SKU_STATUS}/batch`,{method:"PUT",body:JSON.stringify({updates:e})})}}class d extends Error{constructor(e,t,r){super(e),this.status=t,this.data=r,this.name="ApiError"}}function m(e){try{let t=new URL(e),r=t.pathname,o=r.replace(/^\//,"").replace(/\/p\/?$/,"");o=o.replace(/^[a-z]+-[a-z]{2}\//,"");let a=o.split("/");if(a.length<2)throw Error("URL\u683c\u5f0f\u4e0d\u6b63\u786e\uff0c\u65e0\u6cd5\u63d0\u53d6SKU");let n=a[a.length-1],s=a.slice(0,-1).join("/");if(!/^[A-Z0-9]+$/.test(n))throw Error(`\u63d0\u53d6\u7684SKU\u683c\u5f0f\u4e0d\u6b63\u786e: ${n}`);return{sku:n,productName:s,fullPath:o}}catch(e){throw Error(`SKU\u63d0\u53d6\u5931\u8d25: ${e instanceof Error?e.message:"Unknown error"}`)}}function h(e){try{let t=new URL(e).pathname,r=t.split("/").filter(Boolean)[0]||"",o=r.match(/^([a-z]+)-([a-z]{2})$/);if(o){let e=o[1],t=o[2],r={uae:"ae",saudi:"sa"}[e];if(r)return`${t}-${r}`}}catch{}return"en-sa"}async function f(e){return g(e)}async function g(t,r){try{if(!t.includes("noon.com")||!t.includes("/p/"))throw Error("\u8bf7\u8f93\u5165\u6709\u6548\u7684 Noon \u4ea7\u54c1\u9875\u9762 URL");let o=new URL(t),a=o.pathname,n=o.searchParams,s=a.replace(/^\//,"").replace(/\/p\/?$/,"");s=s.replace(/^[a-z]+-[a-z]{2}\//,"");let i=`https://noon-catalog.noon.partners/_svc/catalog/api/u/${s}/p`,l=new URL(i);n.forEach((e,t)=>{l.searchParams.set(t,e)});let{sendMessage:c}=await e("4105d7b7f9c4a16f"),u={Accept:"application/json","User-Agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36","X-Platform":"web","X-Lang":"en","X-Locale":h(t)},p={...u,...r},d=await c({action:"httpRequest",url:l.toString(),method:"GET",headers:p});if(!d.success)throw Error(`API \u8bf7\u6c42\u5931\u8d25: ${d.error}`);let m=d.data;if(!m.product)throw Error("\u65e0\u6cd5\u4ece\u54cd\u5e94\u4e2d\u83b7\u53d6\u4ea7\u54c1\u4fe1\u606f");let f=m.product,g=f.product_title,y=f.sku,w=f.brand,b=f.groups||[];if(!g)throw Error("\u65e0\u6cd5\u4ece\u54cd\u5e94\u4e2d\u83b7\u53d6\u4ea7\u54c1\u6807\u9898");let S=null,E=null;if(f.variants&&f.variants.length>0){let e=f.variants[0];if(e.offers&&e.offers.length>0){let t=e.offers[0];S=t.price||null,E=t.sale_price||null}}let x=function(e){let t=[];if(!e||0===e.length)return console.log("\u4ea7\u54c1\u6ca1\u6709 groups \u6570\u636e"),t;let r=e.find(e=>"color"===e.code);return r&&r.options&&r.options.length>0?(console.log(`\u627e\u5230\u989c\u8272\u53d8\u4f53\u7ec4: ${r.name}\uff0c\u5305\u542b ${r.options.length} \u4e2a\u9009\u9879`),r.options.forEach(e=>{t.push({name:e.name,sku:e.sku,attributes:{color:e.name,isAvailable:1===e.is_available,url:e.url,offerCode:e.offer_code,imageUrl:e.image_key?`https://f.nooncdn.com/p/${e.image_key}`:null}})}),console.log("\u63d0\u53d6\u5230\u7684\u989c\u8272\u53d8\u4f53:",t.map(e=>`${e.name} (${e.sku})`))):(console.log('\u672a\u627e\u5230 code \u4e3a "color" \u7684\u53d8\u4f53\u7ec4'),e.forEach(e=>{console.log(`\u53ef\u7528\u7684\u53d8\u4f53\u7ec4: ${e.name} (code: ${e.code})`)})),t}(b),A=[];f.feature_bullets&&Array.isArray(f.feature_bullets)&&f.feature_bullets.forEach(e=>{e&&"string"==typeof e&&e.trim()&&A.push(e.trim())});let T=[];return f.image_keys&&Array.isArray(f.image_keys)&&f.image_keys.forEach(e=>{if(e&&"string"==typeof e){let t;t=e.startsWith("http")?e:`https://f.nooncdn.com/p/${e}`,T.push(function(e){if(!e||"string"!=typeof e)return e;try{let t=new URL(e),r=t.pathname,o=[".jpg",".jpeg",".png",".webp",".gif"].some(e=>r.toLowerCase().endsWith(e));o||(t.pathname=r+".jpg");let a=t.searchParams;return a.set("width","660"),t.toString()}catch(o){console.warn("[normalizeNoonImageUrl] URL \u89e3\u6790\u5931\u8d25\uff0c\u4f7f\u7528\u7b80\u5355\u5904\u7406:",o);let t=[".jpg",".jpeg",".png",".webp",".gif"].some(t=>e.toLowerCase().includes(t)),r=e;if(!t){let[t,o]=e.split("?");r=t+".jpg",o&&(r+="?"+o)}if(r.includes("?")){let[e,t]=r.split("?"),o=new URLSearchParams(t);o.set("width","660"),r=e+"?"+o.toString()}else r+="?width=660";return r}}(t))}}),{title:g,price:S,salePrice:E,sku:y,brand:w,groups:b,variants:x,rawData:m,featureBullets:A.length>0?A:void 0,productImages:T.length>0?T:void 0}}catch(e){throw console.error("\u83b7\u53d6\u4ea7\u54c1\u8be6\u7ec6\u4fe1\u606f\u5931\u8d25:",e),e instanceof Error?e:Error("\u83b7\u53d6\u4ea7\u54c1\u8be6\u7ec6\u4fe1\u606f\u65f6\u53d1\u751f\u672a\u77e5\u9519\u8bef")}}async function y(e){try{let t=await f(e);return t.title}catch(e){throw console.error("\u83b7\u53d6\u4ea7\u54c1\u6807\u9898\u5931\u8d25:",e),e instanceof Error?e:Error("\u83b7\u53d6\u4ea7\u54c1\u6807\u9898\u65f6\u53d1\u751f\u672a\u77e5\u9519\u8bef")}}async function w(e){try{if(!e.includes("noon.com")||!e.includes("/p/"))throw Error("\u8bf7\u8f93\u5165\u6709\u6548\u7684 Noon \u4ea7\u54c1\u9875\u9762 URL");let t=new URL(e),r=t.pathname,o=t.searchParams,a=r.replace(/^\//,"").replace(/\/p\/?$/,"");a=a.replace(/^[a-z]+-[a-z]{2}\//,"");let n=`https://noon-catalog.noon.partners/_svc/catalog/api/u/${a}/p`,s=new URL(n);o.forEach((e,t)=>{s.searchParams.set(t,e)});let i={Accept:"application/json","User-Agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36","Accept-Language":"en-US,en;q=0.9","Cache-Control":"no-cache",Pragma:"no-cache","X-Platform":"web","X-Lang":"en","X-Locale":h(e)},l=await fetch(s.toString(),{method:"GET",headers:i});if(!l.ok)throw Error(`API \u8bf7\u6c42\u5931\u8d25: ${l.status} ${l.statusText}`);let c=await l.json(),u=[],p=c.product;return p.groups&&p.groups.length>0&&p.groups.forEach(e=>{e.options&&e.options.length>0&&e.options.forEach(t=>{u.push({variantId:t.sku,variantName:t.name,variantType:e.name,variantCode:e.code,isAvailable:1===t.is_available,url:t.url,offerCode:t.offer_code,imageUrl:t.image_key?`https://f.nooncdn.com/p/${t.image_key}`:null})})}),0===u.length&&p.variants&&p.variants.length>0&&p.variants.forEach(e=>{u.push({variantId:e.sku,variantName:e.variant||"\u9ed8\u8ba4\u53d8\u4f53",variantType:"default",variantCode:"default",isAvailable:!0,url:null,offerCode:null,imageUrl:null})}),{success:!0,productInfo:{sku:p.sku,title:p.product_title,brand:p.brand,brandCode:p.brand_code,category:p.category_code,breadcrumbs:p.breadcrumbs||[]},variants:u,totalVariants:u.length,apiUrl:s.toString(),originalUrl:e}}catch(e){throw console.error("\u83b7\u53d6\u5546\u54c1\u53d8\u4f53\u5931\u8d25:",e),e instanceof Error?e:Error("\u83b7\u53d6\u5546\u54c1\u53d8\u4f53\u65f6\u53d1\u751f\u672a\u77e5\u9519\u8bef")}}function b(e){try{let t=new URL(e),r=t.pathname,o=t.searchParams,a=r.replace(/^\//,"").replace(/\/p\/?$/,"");a=a.replace(/^[a-z]+-[a-z]{2}\//,"");let n=`https://noon-catalog.noon.partners/_svc/catalog/api/u/${a}/p`,s={};o.forEach((e,t)=>{s[t]=e});let i=new URL(n);return o.forEach((e,t)=>{i.searchParams.set(t,e)}),{success:!0,apiUrl:n,apiUrlWithParams:i.toString(),queryParams:s,originalUrl:e,productPath:a}}catch(e){throw Error(`URL\u89e3\u6790\u5931\u8d25: ${e instanceof Error?e.message:"\u672a\u77e5\u9519\u8bef"}`)}}async function S(e,t={}){let r=await (0,l.secureRetrieve)("authToken");if(!r)throw Error("\u8bf7\u5148\u767b\u5f55\u540e\u518d\u4f7f\u7528");let o=await (0,i.sendMessage)({action:"httpRequest",url:e,method:t.method||"GET",headers:{Accept:"application/json","User-Agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36",Token:r,...t.headers},body:t.body});if(!o.success)throw Error(`API\u8bf7\u6c42\u5931\u8d25: ${o.error}`);return o.data}async function E(e){return x(e)}async function x(e){return S(c.ALIBABA_HTML_DETAIL,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({html:e})})}async function A(e){return S(c.AMAZON_HTML_DETAIL,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({html:e})})}async function T(e,t,r={}){let o=await (0,a.getAuthStatus)();if(o.expired)throw await (0,a.clearAuthData)(),Error("\u767b\u5f55\u5df2\u8fc7\u671f\uff0c\u8bf7\u91cd\u65b0\u767b\u5f55");let n=await fetch(e,{method:r.method||"GET",headers:{Accept:"application/json","User-Agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36",Token:t,...r.headers},body:r.body,cache:"no-store",referrerPolicy:"no-referrer"});if(!n.ok)throw Error(`API\u8bf7\u6c42\u5931\u8d25: ${n.status}`);let s=await n.json();if(401===s.code&&s.msg?.includes("expired"))throw await (0,a.clearAuthData)(),Error("\u767b\u5f55\u5df2\u8fc7\u671f\uff0c\u8bf7\u91cd\u65b0\u767b\u5f55");return s}let v=[{value:0,label:"same day"},{value:1,label:"1 Day"},{value:2,label:"2 Day"},{value:3,label:"3 Day"},{value:4,label:"4 Day"},{value:5,label:"5 Day"},{value:6,label:"6 Day"},{value:7,label:"7 Day"},{value:8,label:"8 Day"},{value:9,label:"9 Day"},{value:10,label:"10 Day"},{value:11,label:"11 Day"},{value:12,label:"12 Day"},{value:13,label:"13 Day"},{value:14,label:"14 Day"},{value:15,label:"15 Day"},{value:16,label:"16 Day"},{value:17,label:"17 Day"},{value:18,label:"18 Day"},{value:19,label:"19 Day"},{value:20,label:"20 Day"},{value:21,label:"21 Day"},{value:22,label:"22 Day"},{value:23,label:"23 Day"},{value:24,label:"24 Day"},{value:25,label:"25 Day"},{value:26,label:"26 Day"},{value:27,label:"27 Day"},{value:28,label:"28 Day"},{value:29,label:"29 Day"},{value:30,label:"30 Day"}];async function C(e,t){try{let r=`${c.WAREHOUSE}?cid=${e}&country=${{sa:"saudi",ae:"uae"}[t]||t}`,o=await S(r);if(0!==o.code)throw Error(`\u83b7\u53d6FBP\u4ed3\u5e93\u5931\u8d25: ${o.msg}`);return o.data.Rows}catch(e){throw console.error("[fetchFBPWarehouse] \u83b7\u53d6FBP\u4ed3\u5e93\u5217\u8868\u5931\u8d25:",e),e instanceof Error?e:Error("\u83b7\u53d6FBP\u4ed3\u5e93\u65f6\u53d1\u751f\u672a\u77e5\u9519\u8bef")}}async function _(e={}){let t=new URLSearchParams;t.append("keyword",e.keyword||""),t.append("page_index",String(e.page_index||1)),t.append("page_size",String(e.page_size||30));let r=`https://super.haleemy.com/api/cate/list?${t.toString()}`;return S(r)}async function L(e){return S("https://super.haleemy.com/api/amazon/recommend_cate",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})}let U=new p},{"../background/storage":"d5Ogk","../background/types":"PieoM","../utils/debug":"joY53","../utils/messaging":"c8pCH","../utils/security":"cYUCX","4105d7b7f9c4a16f":"c8pCH","@parcel/transformer-js/src/esmodule-helpers.js":"e86qr"}],d5Ogk:[function(e,t,r){var o=e("@parcel/transformer-js/src/esmodule-helpers.js");o.defineInteropFlag(r),o.export(r,"setAuthData",()=>s),o.export(r,"updateUserInfo",()=>i),o.export(r,"getAuthStatus",()=>l),o.export(r,"getAuthToken",()=>c),o.export(r,"clearAuthData",()=>u),o.export(r,"isAuthenticated",()=>p),o.export(r,"setStorageData",()=>d),o.export(r,"getStorageData",()=>m),o.export(r,"removeStorageData",()=>h);var a=e("../utils/security"),n=e("./types");async function s(e){try{let t=Date.now();await Promise.all([(0,a.secureStore)(n.STORAGE_KEYS.AUTH_TOKEN,e.token),(0,a.secureStore)(n.STORAGE_KEYS.USER_INFO,e.userInfo),(0,a.secureStore)(n.STORAGE_KEYS.LOGIN_TIME,t),(0,a.secureStore)(n.STORAGE_KEYS.IS_AUTHENTICATED,!0)]),console.log("Authentication data stored successfully with timestamp:",t)}catch(e){throw console.error("Failed to store authentication data:",e),e}}async function i(e){try{await (0,a.secureStoreIfChanged)(n.STORAGE_KEYS.USER_INFO,e)}catch(e){throw console.error("Failed to update user info:",e),e}}async function l(){try{let[e,t,r,o]=await Promise.all([(0,a.secureRetrieve)(n.STORAGE_KEYS.AUTH_TOKEN),(0,a.secureRetrieve)(n.STORAGE_KEYS.USER_INFO),(0,a.secureRetrieve)(n.STORAGE_KEYS.LOGIN_TIME),(0,a.secureRetrieve)(n.STORAGE_KEYS.IS_AUTHENTICATED)]),s=!!r&&Date.now()-r>36e5*n.AUTH_CONFIG.TOKEN_EXPIRY_HOURS;if(s)return await u(),{isAuthenticated:!1,expired:!0};return{isAuthenticated:!!o&&!!e&&!!t,userInfo:t||null,loginTime:r||null}}catch(e){throw console.error("Failed to get authentication status:",e),e}}async function c(){try{let e=await (0,a.secureRetrieve)(n.STORAGE_KEYS.AUTH_TOKEN);return e||null}catch(e){return console.error("Failed to get auth token:",e),null}}async function u(){try{await Promise.all([(0,a.secureRemove)(n.STORAGE_KEYS.AUTH_TOKEN),(0,a.secureRemove)(n.STORAGE_KEYS.USER_INFO),(0,a.secureRemove)(n.STORAGE_KEYS.LOGIN_TIME),(0,a.secureRemove)(n.STORAGE_KEYS.IS_AUTHENTICATED)]),console.log("Authentication data cleared successfully")}catch(e){throw console.error("Failed to clear authentication data:",e),e}}async function p(){let e=await l();return e.isAuthenticated&&!e.expired}async function d(e,t){try{await (0,a.secureStore)(e,t)}catch(t){throw console.error(`Failed to set storage data for key: ${e}`,t),t}}async function m(e){try{let t=await (0,a.secureRetrieve)(e);return t||null}catch(t){return console.error(`Failed to get storage data for key: ${e}`,t),null}}async function h(e){try{await (0,a.secureRemove)(e)}catch(t){throw console.error(`Failed to remove storage data for key: ${e}`,t),t}}},{"../utils/security":"cYUCX","./types":"PieoM","@parcel/transformer-js/src/esmodule-helpers.js":"e86qr"}],cYUCX:[function(e,t,r){var o=e("@parcel/transformer-js/src/esmodule-helpers.js");function a(e){try{return btoa(encodeURIComponent(e))}catch(t){return console.error("Encode error:",t),e}}function n(e){try{return decodeURIComponent(atob(e))}catch(t){return console.error("Decode error:",t),e}}function s(){let e=new Uint8Array(16);return crypto.getRandomValues(e),Array.from(e,e=>e.toString(16).padStart(2,"0")).join("")}async function i(e,t){try{let r=new TextEncoder,o=r.encode(e+t),a=await crypto.subtle.digest("SHA-256",o),n=Array.from(new Uint8Array(a));return n.map(e=>e.toString(16).padStart(2,"0")).join("")}catch(t){return console.error("Hash password error:",t),e}}async function l(e,t,r){try{let o=await i(e,r);return o===t}catch(e){return console.error("Verify password error:",e),!1}}async function c(e,t){try{let r=JSON.stringify(t),o=a(r),n=await m(r);await chrome.storage.local.set({[e]:{data:o,timestamp:Date.now(),checksum:n}})}catch(e){throw console.error("Secure store error:",e),Error("Failed to store data securely")}}async function u(e,t){try{let r=JSON.stringify(t),o=await m(r);if(!o)return await c(e,t),!0;let n=await chrome.storage.local.get([e]),s=n[e];if(s?.checksum&&s.checksum===o)return!1;let i=a(r);return await chrome.storage.local.set({[e]:{data:i,timestamp:Date.now(),checksum:o}}),!0}catch(e){throw console.error("Secure store-if-changed error:",e),Error("Failed to store data securely")}}async function p(e){try{let t=await chrome.storage.local.get([e]),r=t[e];if(!r||!r.data)return null;let o=n(r.data),a=await m(o);if(r.checksum!==a)return console.warn("Data integrity check failed for key:",e),await chrome.storage.local.remove([e]),null;return JSON.parse(o)}catch(e){return console.error("Secure retrieve error:",e),null}}async function d(e){try{await chrome.storage.local.remove([e])}catch(e){console.error("Secure remove error:",e)}}async function m(e){try{let t=new TextEncoder,r=t.encode(e),o=await crypto.subtle.digest("SHA-256",r),a=Array.from(new Uint8Array(o));return a.map(e=>e.toString(16).padStart(2,"0")).join("")}catch(e){return console.error("Generate checksum error:",e),""}}function h(e){return e.trim().replace(/[<>"'&]/g,"").substring(0,1e3)}function f(e){try{let t=new URL(e);if("https:"!==t.protocol)return!1;return["noon.com","noon.partners","login.noon.partners","api.noon.partners"].some(e=>t.hostname===e||t.hostname.endsWith("."+e))}catch{return!1}}function g(e=!1,t){let r={"Content-Type":"application/json",Accept:"application/json","Cache-Control":"no-cache",Pragma:"no-cache","X-Requested-With":"XMLHttpRequest"};return e&&t&&(r.Authorization=`Bearer ${t}`),r}function y(e){if(!e||"object"!=typeof e)return!1;let t=JSON.stringify(e);return![/<script/i,/javascript:/i,/on\w+\s*=/i,/eval\s*\(/i,/function\s*\(/i].some(e=>e.test(t))}o.defineInteropFlag(r),o.export(r,"encodeString",()=>a),o.export(r,"decodeString",()=>n),o.export(r,"generateSalt",()=>s),o.export(r,"hashPassword",()=>i),o.export(r,"verifyPassword",()=>l),o.export(r,"secureStore",()=>c),o.export(r,"secureStoreIfChanged",()=>u),o.export(r,"secureRetrieve",()=>p),o.export(r,"secureRemove",()=>d),o.export(r,"sanitizeInput",()=>h),o.export(r,"isSecureUrl",()=>f),o.export(r,"generateSecureHeaders",()=>g),o.export(r,"validateApiResponse",()=>y),o.export(r,"RateLimiter",()=>w),o.export(r,"loginRateLimiter",()=>b),o.export(r,"maskSensitiveData",()=>S),o.export(r,"secureLog",()=>E),o.export(r,"logError",()=>x);class w{constructor(e=5,t=9e5){this.maxAttempts=e,this.windowMs=t,this.attempts=new Map}isAllowed(e){let t=Date.now(),r=this.attempts.get(e)||[],o=r.filter(e=>t-e<this.windowMs);return!(o.length>=this.maxAttempts)&&(o.push(t),this.attempts.set(e,o),!0)}reset(e){this.attempts.delete(e)}getRemainingAttempts(e){let t=this.attempts.get(e)||[],r=Date.now(),o=t.filter(e=>r-e<this.windowMs);return Math.max(0,this.maxAttempts-o.length)}getTimeUntilReset(e){let t=this.attempts.get(e)||[];if(0===t.length)return 0;let r=Math.min(...t)+this.windowMs;return Math.max(0,r-Date.now())}}let b=new w(5,9e5);function S(e){if("object"!=typeof e||null===e)return e;let t=["password","token","secret","key","auth"],r={...e};for(let e in r)t.some(t=>e.toLowerCase().includes(t))?"string"==typeof r[e]&&r[e].length>0&&(r[e]="*".repeat(Math.min(r[e].length,8))):"object"==typeof r[e]&&(r[e]=S(r[e]));return r}function E(e,t){let r=t?S(t):void 0;console.log(`[Noon Extension] ${e}`,r)}function x(e,t){let r=e instanceof Error?e.message:String(e),o={error:r,context:t||"Unknown",timestamp:new Date().toISOString(),userAgent:navigator.userAgent};console.error("[Noon Extension Error]",o)}},{"@parcel/transformer-js/src/esmodule-helpers.js":"e86qr"}],e86qr:[function(e,t,r){r.interopDefault=function(e){return e&&e.__esModule?e:{default:e}},r.defineInteropFlag=function(e){Object.defineProperty(e,"__esModule",{value:!0})},r.exportAll=function(e,t){return Object.keys(e).forEach(function(r){"default"===r||"__esModule"===r||t.hasOwnProperty(r)||Object.defineProperty(t,r,{enumerable:!0,get:function(){return e[r]}})}),t},r.export=function(e,t,r){Object.defineProperty(e,t,{enumerable:!0,get:r})}},{}],PieoM:[function(e,t,r){var o=e("@parcel/transformer-js/src/esmodule-helpers.js");o.defineInteropFlag(r),o.export(r,"STORAGE_KEYS",()=>a),o.export(r,"AUTH_CONFIG",()=>n),o.export(r,"API_CONFIG",()=>s);let a={AUTH_TOKEN:"authToken",USER_INFO:"userInfo",LOGIN_TIME:"loginTime",IS_AUTHENTICATED:"isAuthenticated"},n={TOKEN_EXPIRY_HOURS:720},s={CATALOG_BASE_URL:"https://noon-catalog.noon.partners"}},{"@parcel/transformer-js/src/esmodule-helpers.js":"e86qr"}],joY53:[function(e,t,r){var o=e("@parcel/transformer-js/src/esmodule-helpers.js");o.defineInteropFlag(r),o.export(r,"DEBUG",()=>a),o.export(r,"debugLog",()=>n),o.export(r,"debugError",()=>s),o.export(r,"debugWarn",()=>i),o.export(r,"logDebugInfo",()=>l),o.export(r,"measurePerformance",()=>c),o.export(r,"measurePerformanceSync",()=>u),o.export(r,"logMemoryUsage",()=>p),o.export(r,"safeLog",()=>d),o.export(r,"debugFetch",()=>m),o.export(r,"debugSendMessage",()=>h),o.export(r,"createComponentDebugger",()=>f),o.export(r,"isDebugMode",()=>g),o.export(r,"assertDebugMode",()=>y);let a=!1;function n(e,t){if(a){let r=new Date().toISOString();console.log(`[DEBUG ${r}] ${e}`,t)}}function s(e,t){if(a){let r=new Date().toISOString();console.error(`[ERROR ${r}] ${e}`,t)}}function i(e,t){if(a){let r=new Date().toISOString();console.warn(`[WARN ${r}] ${e}`,t)}}function l(e){a&&console.log("[\u8c03\u8bd5\u4fe1\u606f]",{...e,timestamp:new Date(e.timestamp).toISOString()})}function c(e,t){if(!a)return t();let r=performance.now();return t().finally(()=>{let t=performance.now()-r;n(`[\u6027\u80fd] ${e}: ${t.toFixed(2)}ms`)})}function u(e,t){if(!a)return t();let r=performance.now();try{let o=t(),a=performance.now()-r;return n(`[\u6027\u80fd] ${e}: ${a.toFixed(2)}ms`),o}catch(o){let t=performance.now()-r;throw s(`[\u6027\u80fd\u5f02\u5e38] ${e}: ${t.toFixed(2)}ms`,o),o}}function p(){if(a&&performance.memory){let e={used:Math.round(performance.memory.usedJSHeapSize/1024/1024),total:Math.round(performance.memory.totalJSHeapSize/1024/1024),limit:Math.round(performance.memory.jsHeapSizeLimit/1024/1024)};n("\u5185\u5b58\u4f7f\u7528\u60c5\u51b5 (MB)",e)}}function d(e){if(!a)return{};let t={...e};return["password","token","apiKey","secret","auth"].forEach(e=>{t[e]&&(t[e]="***")}),console.log("[\u5b89\u5168\u65e5\u5fd7]",t),t}async function m(e,t={}){a&&n("API\u8bf7\u6c42\u5f00\u59cb",{url:e,method:t.method||"GET"});let r=performance.now();try{let o=await fetch(e,t),s=performance.now()-r;return a&&n("API\u8bf7\u6c42\u5b8c\u6210",{url:e,status:o.status,statusText:o.statusText,duration:`${s.toFixed(2)}ms`,headers:Object.fromEntries(o.headers.entries())}),o}catch(o){let t=performance.now()-r;throw s("API\u8bf7\u6c42\u5931\u8d25",{url:e,duration:`${t.toFixed(2)}ms`,error:o.message}),o}}async function h(e){a&&n("\u53d1\u9001Chrome\u6d88\u606f",d(e));try{let t=await chrome.runtime.sendMessage(e);return a&&n("\u6536\u5230Chrome\u6d88\u606f\u54cd\u5e94",d(t)),t}catch(t){throw s("Chrome\u6d88\u606f\u53d1\u9001\u5931\u8d25",{message:d(e),error:t}),t}}function f(e){return{logAction:(t,r)=>{l({component:e,action:t,data:d(r),timestamp:Date.now()})},logError:(t,r)=>{s(`[${e}] ${t}`,r)},measureAction:(t,r)=>c(`${e}.${t}`,r)}}function g(){return a}function y(){if(!a)throw Error("\u6b64\u529f\u80fd\u4ec5\u5728\u8c03\u8bd5\u6a21\u5f0f\u4e0b\u53ef\u7528")}},{"@parcel/transformer-js/src/esmodule-helpers.js":"e86qr"}],c8pCH:[function(e,t,r){var o=e("@parcel/transformer-js/src/esmodule-helpers.js");o.defineInteropFlag(r),o.export(r,"sendMessage",()=>n),o.export(r,"sendMessageToTab",()=>s),o.export(r,"getCurrentTab",()=>i),o.export(r,"isNoonSite",()=>l),o.export(r,"setStorage",()=>c),o.export(r,"getStorage",()=>u),o.export(r,"removeStorage",()=>p),o.export(r,"clearStorage",()=>d),o.export(r,"onStorageChanged",()=>m),o.export(r,"formatError",()=>h),o.export(r,"delay",()=>f),o.export(r,"retry",()=>g),o.export(r,"isValidEmail",()=>y),o.export(r,"validatePassword",()=>w),o.export(r,"isExtensionContextValid",()=>b),o.export(r,"isContextInvalidationError",()=>S),o.export(r,"getEnhancedErrorMessage",()=>E),o.export(r,"sendMessageWithRetry",()=>x),o.export(r,"generateId",()=>A),o.export(r,"safeJsonParse",()=>T),o.export(r,"formatDate",()=>v);var a=e("./debug");async function n(e){return(0,a.debugLog)("\u53d1\u9001Chrome\u6d88\u606f",(0,a.safeLog)(e)),(0,a.measurePerformance)("sendMessage",async()=>new Promise(t=>{if(!chrome?.runtime?.id){t({success:!1,error:"Extension context invalidated. Please reload the extension."});return}try{chrome.runtime.sendMessage(e,r=>{if(chrome.runtime.lastError){let r=chrome.runtime.lastError.message;(0,a.debugError)("\u6d88\u606f\u53d1\u9001\u5931\u8d25",{request:(0,a.safeLog)(e),error:r}),r.includes("Extension context invalidated")||r.includes("message port closed")||r.includes("Receiving end does not exist")?t({success:!1,error:"\u6269\u5c55\u4e0a\u4e0b\u6587\u5df2\u5931\u6548\uff0c\u8bf7\u91cd\u65b0\u52a0\u8f7d\u6269\u5c55\u3002\u5982\u679c\u95ee\u9898\u6301\u7eed\u5b58\u5728\uff0c\u8bf7\u91cd\u542f\u6d4f\u89c8\u5668\u3002"}):t({success:!1,error:r})}else(0,a.debugLog)("\u6536\u5230Chrome\u6d88\u606f\u54cd\u5e94",(0,a.safeLog)(r)),t(r||{success:!1,error:"No response received"})})}catch(o){let r=o instanceof Error?o.message:String(o);(0,a.debugError)("\u6d88\u606f\u53d1\u9001\u5f02\u5e38",{request:(0,a.safeLog)(e),error:r}),t({success:!1,error:`\u6d88\u606f\u53d1\u9001\u5f02\u5e38: ${r}`})}}))}async function s(e,t){return new Promise(r=>{chrome.tabs.sendMessage(e,t,e=>{chrome.runtime.lastError?r({success:!1,error:chrome.runtime.lastError.message}):r(e||{success:!1,error:"No response received"})})})}async function i(){return new Promise(e=>{chrome.tabs.query({active:!0,currentWindow:!0},t=>{e(t[0]||null)})})}function l(e){try{let t=new URL(e);return t.hostname.includes("noon.com")||t.hostname.includes("noon.partners")}catch{return!1}}async function c(e){return(0,a.debugLog)("\u5b58\u50a8\u6570\u636e\u5230Chrome Storage",(0,a.safeLog)(e)),(0,a.measurePerformance)("setStorage",async()=>new Promise((t,r)=>{chrome.storage.local.set(e,()=>{if(chrome.runtime.lastError){let t=Error(chrome.runtime.lastError.message);(0,a.debugError)("\u5b58\u50a8\u6570\u636e\u5931\u8d25",{data:(0,a.safeLog)(e),error:t}),r(t)}else(0,a.debugLog)("\u6570\u636e\u5b58\u50a8\u6210\u529f"),t()})}))}async function u(e){return(0,a.debugLog)("\u4ece Chrome Storage \u83b7\u53d6\u6570\u636e",{keys:e}),(0,a.measurePerformance)("getStorage",async()=>new Promise((t,r)=>{chrome.storage.local.get(e,o=>{if(chrome.runtime.lastError){let t=Error(chrome.runtime.lastError.message);(0,a.debugError)("\u83b7\u53d6\u6570\u636e\u5931\u8d25",{keys:e,error:t}),r(t)}else(0,a.debugLog)("\u6570\u636e\u83b7\u53d6\u6210\u529f",(0,a.safeLog)(o)),t(o)})}))}async function p(e){return new Promise((t,r)=>{chrome.storage.local.remove(e,()=>{chrome.runtime.lastError?r(Error(chrome.runtime.lastError.message)):t()})})}async function d(){return new Promise((e,t)=>{chrome.storage.local.clear(()=>{chrome.runtime.lastError?t(Error(chrome.runtime.lastError.message)):e()})})}function m(e){chrome.storage.onChanged.addListener((t,r)=>{"local"===r&&e(t)})}function h(e){return e instanceof Error?e.message:"string"==typeof e?e:"Unknown error occurred"}function f(e){return new Promise(t=>setTimeout(t,e))}async function g(e,t=3,r=1e3){let o;for(let a=1;a<=t;a++)try{return await e()}catch(e){if(o=e,a===t)break;await f(r*a)}throw o}function y(e){return/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e)}function w(e){let t=[];return e.length<6&&t.push("\u5bc6\u7801\u957f\u5ea6\u81f3\u5c116\u4f4d"),e.length>128&&t.push("\u5bc6\u7801\u957f\u5ea6\u4e0d\u80fd\u8d85\u8fc7128\u4f4d"),{isValid:0===t.length,errors:t}}function b(){try{return!!chrome?.runtime?.id}catch{return!1}}function S(e){return["Extension context invalidated","message port closed","Receiving end does not exist","Could not establish connection","The message port closed before a response was received","\u6269\u5c55\u4e0a\u4e0b\u6587\u5df2\u5931\u6548"].some(t=>e.toLowerCase().includes(t.toLowerCase()))}function E(e){return S(e)?"\u6269\u5c55\u5df2\u91cd\u65b0\u52a0\u8f7d\uff0c\u8bf7\u5237\u65b0\u9875\u9762\u540e\u91cd\u8bd5\u3002\u5982\u679c\u95ee\u9898\u6301\u7eed\u5b58\u5728\uff0c\u8bf7\uff1a\n1. \u5173\u95ed\u5e76\u91cd\u65b0\u6253\u5f00\u6b64\u6807\u7b7e\u9875\n2. \u5728 chrome://extensions/ \u4e2d\u91cd\u65b0\u52a0\u8f7d\u6269\u5c55\n3. \u91cd\u542f\u6d4f\u89c8\u5668":e}async function x(e,t=2,r=1e3){let o="";for(let a=0;a<=t;a++)try{if(!b())throw Error("Extension context invalidated");let s=await n(e);if(s.success||!S(s.error||""))return s;if(o=s.error||"Unknown error",a===t)break;await f(r)}catch(e){if(o=e instanceof Error?e.message:String(e),a===t)break;await f(r)}return{success:!1,error:E(o)}}function A(){return Date.now().toString(36)+Math.random().toString(36).substring(2)}function T(e,t){try{return JSON.parse(e)}catch{return t}}function v(e){let t="string"==typeof e?new Date(e):e;return t.toLocaleString("zh-CN",{year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit"})}},{"./debug":"joY53","@parcel/transformer-js/src/esmodule-helpers.js":"e86qr"}],"4trOd":[function(e,t,r){var o=e("@parcel/transformer-js/src/esmodule-helpers.js");o.defineInteropFlag(r),o.export(r,"BaseScraper",()=>a.BaseScraper),o.export(r,"AlibabaScraper",()=>n.AlibabaScraper),o.export(r,"AmazonScraper",()=>s.AmazonScraper),o.export(r,"ScraperFactory",()=>i.ScraperFactory);var a=e("./base/BaseScraper"),n=e("./impl/AlibabaScraper"),s=e("./impl/AmazonScraper"),i=e("./ScraperFactory")},{"./base/BaseScraper":"dDKAq","./impl/AlibabaScraper":"bC3Hv","./impl/AmazonScraper":"cgXsb","./ScraperFactory":"8okkL","@parcel/transformer-js/src/esmodule-helpers.js":"e86qr"}],dDKAq:[function(e,t,r){var o=e("@parcel/transformer-js/src/esmodule-helpers.js");o.defineInteropFlag(r),o.export(r,"BaseScraper",()=>n);var a=e("../../../utils/urlUtils");class n{getPageTitle(){return document.title||`${this.platform} \u5546\u54c1\u8be6\u60c5`}getBaseUrl(e){return(0,a.getBaseUrl)(e)}mergeOptions(e){return{...this.defaultOptions,...e}}extractShadowDOMContent(e){return e.shadowRoot?e.shadowRoot.innerHTML:""}extractVueComponentContent(e){let t=this.extractShadowDOMContent(e);if(t.trim())return t;if(e.innerHTML.trim())return e.innerHTML;let r=e.textContent?.trim();if(r&&r.length>10)return`<div>${r}</div>`;let o=e.parentElement;if(o){for(let t of[".html-description-content",".detail-content",".detail-description",'[class*="detail-content"]','[class*="description-content"]','[class*="detail"]','[class*="description"]']){let r=o.querySelector(t);if(r&&r!==e&&r.innerHTML.trim())return r.innerHTML;let a=e.querySelector(t);if(a&&a.innerHTML.trim())return a.innerHTML}let t=[e.nextElementSibling,e.previousElementSibling];for(let e of t)if(e&&e.innerHTML.trim()&&e.innerHTML.length>50)return e.innerHTML}let a=Array.from(e.children);if(a.length>0){let e=a.map(e=>e.outerHTML).join("");if(e.trim())return e}return""}processElementForShadowDOM(e,t){if(e.shadowRoot){t.innerHTML=e.shadowRoot.innerHTML;return}if(e.tagName.toLowerCase().startsWith("v-")){let r=this.extractVueComponentContent(e);if(r){t.innerHTML=r;return}}let r=Array.from(e.children),o=Array.from(t.children);r.forEach((e,t)=>{let r=o[t];r&&this.processElementForShadowDOM(e,r)})}constructor(){this.defaultOptions={includeShadowDOM:!0,includeVueComponents:!0,customSelector:""}}}},{"../../../utils/urlUtils":"8zYQE","@parcel/transformer-js/src/esmodule-helpers.js":"e86qr"}],"8zYQE":[function(e,t,r){var o=e("@parcel/transformer-js/src/esmodule-helpers.js");function a(){try{let e=new URLSearchParams(window.location.search),t=e.get("project");if(t&&t.trim())return t.trim();let r=window.location.hash;if(r){let e=r.match(/project=([^&]+)/);if(e&&e[1]&&e[1].trim())return decodeURIComponent(e[1].trim())}return null}catch(e){return console.warn("\u65e0\u6cd5\u4ece URL \u4e2d\u83b7\u53d6 partnerCode:",e),null}}function n(e){return!!e&&/^PRJ\d{6}$/.test(e)}function s(){let e=a();if(!e)return{partnerCode:null,isValid:!1,error:"\u65e0\u6cd5\u4ece\u5f53\u524d\u9875\u9762URL\u4e2d\u83b7\u53d6\u5408\u4f5c\u4f19\u4f34\u4ee3\u7801(project\u53c2\u6570)\uff0c\u8bf7\u786e\u4fdd\u5728Noon\u540e\u53f0\u7ba1\u7406\u9875\u9762\u4e2d\u64cd\u4f5c"};let t=n(e);return t?{partnerCode:e,isValid:!0}:{partnerCode:e,isValid:!1,error:`\u5408\u4f5c\u4f19\u4f34\u4ee3\u7801\u683c\u5f0f\u65e0\u6548: ${e}\uff0c\u671f\u671b\u683c\u5f0f\u5982: PRJ410413`}}function i(e){try{let t=new URL(e),r=t.pathname,o=r.split("/").filter(e=>e.length>0),a=o.findIndex(e=>"p"===e);if(a>0){let e=o[a-1];if(e&&/^[A-Z0-9]{8,}$/.test(e))return e}return null}catch(e){return console.warn("\u4eceURL\u4e2d\u63d0\u53d6SKU\u5931\u8d25:",e),null}}function l(e,t){try{let r=new URL(e);return r.searchParams.set("project",t),r.toString()}catch(t){return console.warn("\u6784\u5efaURL\u5931\u8d25:",t),e}}function c(e){try{let t=e||window.location.href,r=new URL(t);return r.origin+r.pathname}catch(t){return console.warn("\u63d0\u53d6\u57fa\u7840URL\u5931\u8d25:",t),e||window.location.href}}o.defineInteropFlag(r),o.export(r,"getPartnerCodeFromUrl",()=>a),o.export(r,"isValidPartnerCode",()=>n),o.export(r,"getValidatedPartnerCode",()=>s),o.export(r,"extractSkuFromUrl",()=>i),o.export(r,"buildUrlWithPartnerCode",()=>l),o.export(r,"getBaseUrl",()=>c)},{"@parcel/transformer-js/src/esmodule-helpers.js":"e86qr"}],bC3Hv:[function(e,t,r){var o=e("@parcel/transformer-js/src/esmodule-helpers.js");o.defineInteropFlag(r),o.export(r,"AlibabaScraper",()=>n);var a=e("../base/BaseScraper");class n extends a.BaseScraper{canHandle(e){try{let t=new URL(e);return t.hostname.includes("1688.com")}catch{return!1}}extractContentHTML(e){let t=this.mergeOptions(e),r=t.customSelector||"#content",o=document.getElementById(r.replace("#",""));if(!o)return null;let a=o.cloneNode(!0);if((t.includeShadowDOM||t.includeVueComponents)&&this.processElementForShadowDOM(o,a),t.includeVueComponents){let e=o.querySelector("v-detail-n"),t=a.querySelector("v-detail-n");if(e&&t){let r=this.extractVueComponentContent(e);if(!r||r.trim().length<50){let t=e.parentElement;if(t){let o=t.querySelectorAll("*");for(let t of Array.from(o))if(t!==e&&"v-detail-n"!==t.tagName.toLowerCase()&&t.innerHTML.trim().length>100){r=t.innerHTML;break}}if(!r||r.trim().length<50){let t=e.parentElement;if(t){let e=t.cloneNode(!0),o=e.querySelector("v-detail-n");o&&o.remove();let a=e.innerHTML.trim();a.length>100&&(r=a)}}}r&&r.trim().length>10?t.innerHTML=r:console.warn("\u65e0\u6cd5\u63d0\u53d6 v-detail-n \u7684\u5185\u5bb9\uff0c\u4fdd\u7559\u7a7a\u5143\u7d20")}}return{html:a.outerHTML,title:this.getPageTitle(),platform:this.platform,baseUrl:this.getBaseUrl()}}constructor(...e){super(...e),this.platform="alibaba"}}},{"../base/BaseScraper":"dDKAq","@parcel/transformer-js/src/esmodule-helpers.js":"e86qr"}],cgXsb:[function(e,t,r){var o=e("@parcel/transformer-js/src/esmodule-helpers.js");o.defineInteropFlag(r),o.export(r,"AmazonScraper",()=>s);var a=e("../base/BaseScraper"),n=e("../../../utils/amazonDomains");class s extends a.BaseScraper{canHandle(e){try{let t=new URL(e);return(0,n.isAmazonHostname)(t.hostname)}catch{return!1}}extractContentHTML(e){let t=this.mergeOptions(e),r=t.customSelector||"#dp",o=document.getElementById(r.replace("#",""));if(!o)return null;let a=o.cloneNode(!0);return t.includeShadowDOM&&this.processElementForShadowDOM(o,a),{html:a.outerHTML,title:this.getPageTitle(),platform:this.platform,baseUrl:this.getBaseUrl()}}constructor(...e){super(...e),this.platform="amazon"}}},{"../base/BaseScraper":"dDKAq","../../../utils/amazonDomains":"7xI7i","@parcel/transformer-js/src/esmodule-helpers.js":"e86qr"}],"7xI7i":[function(e,t,r){var o=e("@parcel/transformer-js/src/esmodule-helpers.js");o.defineInteropFlag(r),o.export(r,"AMAZON_HOST_SUFFIXES",()=>a),o.export(r,"isAmazonHostname",()=>n),o.export(r,"AMAZON_MATCH_PATTERNS",()=>s);let a=["amazon.com","amazon.sa","amazon.ae","amazon.eg","amazon.co.uk","amazon.de","amazon.fr","amazon.it","amazon.es","amazon.nl","amazon.se","amazon.pl","amazon.com.be","amazon.ca","amazon.com.mx","amazon.com.br","amazon.co.jp","amazon.sg","amazon.in","amazon.com.au","amazon.com.tr"];function n(e){let t=(e||"").toLowerCase();return a.some(e=>t===e||t.endsWith(`.${e}`))}let s=a.flatMap(e=>[`https://${e}/*`,`https://*.${e}/*`])},{"@parcel/transformer-js/src/esmodule-helpers.js":"e86qr"}],"8okkL":[function(e,t,r){var o=e("@parcel/transformer-js/src/esmodule-helpers.js");o.defineInteropFlag(r),o.export(r,"ScraperFactory",()=>s);var a=e("./impl/AlibabaScraper"),n=e("./impl/AmazonScraper");class s{static{this.scrapers=[a.AlibabaScraper,n.AmazonScraper]}static{this.instances=new Map}static createScraper(e){let t=e||window.location.href;for(let e of this.scrapers){let r=this.getInstance(e);if(r&&r.canHandle(t))return r}return null}static getScraperByPlatform(e){if(this.instances.has(e))return this.instances.get(e);for(let t of this.scrapers){let r=new t;if(r.platform===e)return this.instances.set(e,r),r}return null}static getInstance(e){let t=new e,r=t.platform;return this.instances.has(r)||this.instances.set(r,t),this.instances.get(r)}static registerScraper(e){let t=this.scrapers.some(t=>t===e);t||this.scrapers.push(e)}static getRegisteredPlatforms(){return this.scrapers.map(e=>{let t=new e;return t.platform})}}},{"./impl/AlibabaScraper":"bC3Hv","./impl/AmazonScraper":"cgXsb","@parcel/transformer-js/src/esmodule-helpers.js":"e86qr"}],j19Rj:[function(e,t,r){var o=e("@parcel/transformer-js/src/esmodule-helpers.js");o.defineInteropFlag(r),o.export(r,"NOON_PARTNER_CODE_STORAGE_KEY",()=>a);let a="NOON_PARTNER_CODE"},{"@parcel/transformer-js/src/esmodule-helpers.js":"e86qr"}],"44yHH":[function(e,t,r){var o=e("@parcel/transformer-js/src/esmodule-helpers.js");o.defineInteropFlag(r),o.export(r,"getPartnerContext",()=>n),o.export(r,"canUseCollectors",()=>s);var a=e("./messaging");async function n(){let e=await (0,a.sendMessage)({action:"getPartnerContext"});return e.success&&e.data?e.data:{isAuthenticated:!1,currentPartnerCode:null,nextStep:e.error||"\u65e0\u6cd5\u83b7\u53d6\u4e0a\u4e0b\u6587\u4fe1\u606f"}}function s(e){if(!e.isAuthenticated)return{allowed:!1,message:e.nextStep||"\u8bf7\u5148\u767b\u5f55\u540e\u518d\u4f7f\u7528",showNoonCatalogHint:!1};let t=!e.currentPartnerCode;return{allowed:!0,message:"\u5df2\u767b\u5f55\uff0c\u53ef\u4ee5\u91c7\u96c6",showNoonCatalogHint:t}}},{"./messaging":"c8pCH","@parcel/transformer-js/src/esmodule-helpers.js":"e86qr"}]},["lEgxJ"],"lEgxJ","parcelRequiredb96"),globalThis.define=t;