import{a as e,l as t,m as n,n as r}from"./pageDetailHtml-CA9cVLla.js";function i(e){let t=e.toLowerCase();return t===`sooxie.com`||t.endsWith(`.sooxie.com`)}function a(e){return/\/detail\/\d+/i.test(e)}function o(e){try{let t=typeof e==`string`?new URL(e):e;return i(t.hostname)&&a(t.pathname)}catch{return!1}}function s(e){try{let t=new URL(e).pathname.match(/\/detail\/(\d+)/i);if(t?.[1])return t[1]}catch{}return``}function c(e){let t=e.trim();return t?(t.startsWith(`//`)&&(t=`https:${t}`),t.replace(/!first\s*$/i,`!bac`)):``}function l(e){let t=c(e).toLowerCase();return!t||t.includes(`bigload.gif`)||t.includes(`/images/tools/`)?!1:/xiecdn\.com/i.test(t)||/\.(jpg|jpeg|png|webp)(\?|!|$)/i.test(t)}function u(t,r,i){return n(e(t,r,i*2).map(c).filter(l)).slice(0,i)}function d(e,t=80){let r=[];return e.querySelectorAll(`#details img`).forEach(e=>{let t=e,n=[t.getAttribute(`data-url`),t.getAttribute(`data-src`),t.getAttribute(`src`),t.getAttribute(`alt`)];for(let e of n){let t=c(e??``);l(t)&&r.push(t)}}),n(r).slice(0,t)}function f(e,t){for(let n of e.querySelectorAll(`script`)){let e=n.textContent??``,r=RegExp(`\\b${t}\\s*=\\s*["']([^"']+)["']`),i=e.match(r);if(i?.[1])return i[1].trim()}return``}function p(e,t){let n=s(t.href);if(n)return n;let r=e.querySelector(`form#dfm input[name="id"]`);return r?.value?.trim()?r.value.trim():f(e,`id`)}function m(e){return e.querySelector(`.shop-details p u`)?.textContent?.trim()||f(e,`spid`)}function h(e){return e.querySelector(`.meri-price`)?.textContent?.trim()||f(e,`price`)}function g(e,t){let r=e.querySelector(`#${t}`);return r?n(Array.from(r.querySelectorAll(`em`)).map(e=>e.textContent?.trim()??``).filter(Boolean)):[]}function _(e){return e?.trim()?n(e.split(/[,，、|/]/).map(e=>e.trim()).filter(Boolean)):[]}function v(e){let t=e.querySelector(`.shop-details`)??e,n=g(t,`color`),r=g(t,`size`);return n.length||(n=_(e.querySelector(`#txtcolor`)?.value)),r.length||(r=_(e.querySelector(`#txtsize`)?.value)),{colors:n,sizes:r}}function y(e){for(let t of e.querySelectorAll(`script`)){let e=t.textContent??``,n=e.match(/\burl\s*=\s*['"]([^'"]+)['"]/),r=e.match(/\bid\s*=\s*['"](\d+)['"]/);if(n?.[1]&&r?.[1])return{shop:n[1].trim(),id:r[1].trim()}}return null}async function b(e=document){let t=y(e);if(!t)return[];try{let e=await(await fetch(`https://sooxie.com/api/Detail/Stock`,{method:`POST`,headers:{"Content-Type":`application/x-www-form-urlencoded`},body:new URLSearchParams({url:t.shop,id:t.id}),credentials:`include`})).json();if(e?.success&&Array.isArray(e.data))return e.data.filter(e=>e?.color?.trim())}catch{}return[]}function x(e){let t=[];return e.querySelectorAll(`#photoSmall li img`).forEach(e=>{let n=e,r=c(n.getAttribute(`alt`)||n.getAttribute(`src`)||``);l(r)&&t.push(r)}),n(t)}function S(e,t=``){let n=e.getAttribute(`data-name`)?.trim();if(n)return n;let r=e.cloneNode(!0);return r.querySelectorAll(`img`).forEach(e=>e.remove()),r.textContent?.trim()||t}function C(e,t,n=[]){let r=new Map;for(let e of n){let t=e.color?.trim(),n=e.pic?c(e.pic):``;t&&n&&l(n)&&r.set(t,n)}let i=e.querySelector(`#color`),a=x(e);i&&Array.from(i.querySelectorAll(`em`)).forEach((e,n)=>{let i=S(e,t[n]??``);if(!i||r.has(i))return;let o=e.querySelector(`img`)?.getAttribute(`src`);if(o){let e=c(o);if(l(e)){r.set(i,e);return}}let s=a[n]??a[0];s&&r.set(i,s)});let o=c(e.querySelector(`#lnk_thumb`)?.getAttribute(`src`)??``),s=(o&&l(o)?o:``)||a[0]||``;for(let e of t)!r.has(e)&&s&&r.set(e,s);return r}var w={key:`sooxie`,match(e){return o(e)},extractProduct(e,r){let i=p(e,r),a=m(e),o=t(e,[`.shop-title h2`,`h2`,`title`])||e.title.replace(/^[^-]+-/,``).trim(),s=h(e),{colors:f,sizes:g}=v(e),_=n([...C(e,f).values()]),y=[];a&&y.push(`货号:${a}`);for(let e of f)y.push(`颜色:${e}`);for(let e of g)y.push(`尺码:${e}`);let b=e.querySelector(`meta[property="og:image"]`)?.content?.trim(),x=n([...b?[c(b)]:[],...u(e,[`#lnk_thumb`,`#photoSmall img`,`#gallery-preview img`],24)]).filter(l),S=n([...d(e),...u(e,[`#details img`],80)]).filter(l),w=[o];return a&&w.push(`货号：${a}`),f.length&&w.push(`颜色：${f.join(`、`)}`),g.length&&w.push(`尺码：${g.join(`、`)}`),{id:i,sourceSite:`sooxie`,url:r.href,title:o||`搜鞋商品`,priceText:s?`¥${s}`:``,description:w.join(`
`),specs:y,mainImages:x,detailImages:S,skuImages:_,commentImages:[]}},extractCommentImages(){return[]},async fetchExtraCommentImagesById(){return[]},extractDetailHtml:e=>r(e,[`#details`,`.shop-details`])};export{o as a,C as i,v as n,s as o,b as r,w as t};