var e=`xyxp_global_location`;function t(e){return e?.trim()??``}function n(e){if(!e)return;let n=t(e.province),i=t(e.city),a=t(e.area);if(!(!n&&!i&&!a))return{text:r({province:n,city:i,area:a}),province:n||void 0,city:i||void 0,area:a||void 0}}function r(e){return[e.province,e.city,e.area].map(t).filter(Boolean).join(` `)}function i(e){return e?!!(t(e.province)&&t(e.city)&&t(e.area)):!1}function a(e,t){let r=n(e),i=n(t);return!r&&!i?!0:!r||!i?!1:r.province===i.province&&r.city===i.city&&r.area===i.area}function o(e){if(!e||typeof e!=`object`)return!1;let t=e;return typeof t.text==`string`||typeof t.province==`string`||typeof t.city==`string`}async function s(){try{let t=(await chrome.storage.local.get(e))[e];return n(o(t)?t:void 0)}catch{return}}async function c(t){let r=n(t);r?await chrome.storage.local.set({[e]:r}):await chrome.storage.local.remove(e)}function l(e,t){let r=n(e.location);if(r&&i(r))return r;let a=n(t);if(a&&i(a))return a}function u(e){return e.replace(/\p{Extended_Pictographic}/gu,``).replace(/\uFE0F/g,``).replace(/\u200D/g,``).replace(/[ \t]+\n/g,`
`).replace(/\n{3,}/g,`

`).replace(/[ \t]{2,}/g,` `).trim()}function d(e){return u(e)}var f=`.,*?!:;'"()[]+\\-%&#@_~，。、；：？！「」『』（）【】《》·～×°/-`;function p(e){return e.replace(/[\\^\-\]]/g,`\\$&`)}var m=RegExp(`[^\\u4e00-\\u9fffA-Za-z0-9\\s${p(f)}]`,`g`);function h(e){return e.replace(/\p{Extended_Pictographic}/gu,``).replace(/[\u0000-\u001f\u007f-\u009f]/g,``).replace(m,``).replace(/\s+/g,` `).trim()}function g(e,t){let n=Math.min(e.length,t.length);for(let r=n;r>0;r--)if(e.slice(-r)===t.slice(0,r))return r;return 0}function _(e){let t=e.map(e=>h(e)).filter(Boolean);if(t.length<=1)return t;let n=[];for(let e of t)if(!n.join(` `).includes(e)){for(let t=n.length-1;t>=0;t--)e.includes(n[t])&&n.splice(t,1);n.some(t=>t.includes(e))||n.push(e)}if(n.length<=1)return n;let r=[n[0]];for(let e=1;e<n.length;e++){let t=r[r.length-1],i=n[e];if(t.includes(i))continue;if(i.includes(t)){r[r.length-1]=i;continue}let a=g(t,i);a>0?r[r.length-1]=t+i.slice(a):r.push(i)}return r}var v=`0123456789abcdefghijklmnopqrstuvwxyz`,y=null;function b(e=[]){y=new Set(e.map(e=>h(e)).filter(Boolean))}function x(){y=null}function S(e){y||=new Set;for(let t of e){let e=h(t);e&&y.add(e)}}function C(e){let t=0;for(let n=0;n<e.length;n+=1)t=t*31+e.charCodeAt(n)|0;return Math.abs(t)}function w(e,t,n){let r=e.slice(0,11),i=v[C(t)%36],a=[i,...v.split(``).filter(e=>e!==i)];for(let e of a){let t=`${r}${e}`;if(!n.has(t))return t}return`${r.slice(0,10)}z`}function T(e,t,n){let r=h(e)||`默认`,i=y??new Set;if(r.length<=t){if(!i.has(r))return i.add(r),y&&=i,r;if(r.length<t){let e=w(r.slice(0,t-1),n,i);return i.add(e),y&&=i,e}}let a=w(r.slice(0,11),n,i);return i.add(a),y&&=i,a}function E(e,t=12){return T(_(e.properties.map(e=>h(e.value)).filter(Boolean)).join(` `).trim()||h(e.skuId)||`默认`,t,e.skuId)}function D(e,t=12){let n=h(e);return n?n.length<=t?n:n.slice(0,t).replace(/\s+$/,``):`默认`}function O(e){return h(e).toLowerCase()}function k(e){return _(e.properties.map(e=>h(e.value)).filter(Boolean)).join(` `).trim()||h(e.skuId)}function A(e,t=12){return e.properties.length>=2?e.properties.some(e=>h(e.value).length>t):k(e).length>t}var j=`xyxp_global_category_path`;function M(e){return e?.length?e.map(e=>e.trim()).filter(Boolean):[]}async function N(){try{let e=(await chrome.storage.local.get(j))[j];return Array.isArray(e)?M(e):[]}catch{return[]}}async function P(e){let t=M(e);t.length?await chrome.storage.local.set({[j]:t}):await chrome.storage.local.remove(j)}function F(e,t){let n=M(e.categoryPath);return n.length?n:M(t)}export{a as _,E as a,c as b,A as c,D as d,h as f,s as g,i as h,b as i,O as l,r as m,F as n,x as o,d as p,P as r,k as s,N as t,S as u,n as v,l as y};