PageSourceSearch

https://vip.xiaoxiaodong.ai/style-similarity.238e996ad0.js

js xiaoxiaodong.ai collected 2026-10-03 23:20:25 UTC 9,101 bytes, 1 lines download raw bytes

1(function(d,z){const E=z(d?.XxdColorUtils);typeof module<"u"&&module.exports&&(module.exports=E),d&&(d.XxdStyleSimilarity=E)})(typeof globalThis<"u"?globalThis:this,function(d={}){function B(t){if(typeof d.normalizeHexColor=="function")return d.normalizeHexColor(t);const n=String(t||"").trim().match(/^#?([0-9a-fA-F]{6})$/);return n?`#${n[1].toLowerCase()}`:""}function A(t){if(typeof d.hexToRgb=="function")return d.hexToRgb(t);const r=B(t);if(!r)return null;const n=Number.parseInt(r.slice(1),16);return{r:n>>16&255,g:n>>8&255,b:n&255}}function C(t){return t?typeof d.rgbToHex=="function"?d.rgbToHex(t):`#${[t.r,t.g,t.b].map(r=>Math.max(0,Math.min(255,Math.round(r))).toString(16).padStart(2,"0")).join("")}`:""}function D(t){const r=Number(t);return Number.isFinite(r)?Math.max(0,Math.min(255,Math.round(r))):null}function T(t){if(Array.isArray(t)&&t.length>=3){const o=t.slice(0,3).map(D);return o.every(c=>c!==null)?{r:o[0],g:o[1],b:o[2]}:null}if(t&&typeof t=="object"){const o=[t.r,t.g,t.b].map(D);return o.every(c=>c!==null)?{r:o[0],g:o[1],b:o[2]}:T(t.color??t.rgb??t.value??t.hex)}const r=String(t||"").trim();if(!r)return null;const n=A(r);if(n)return n;const e=r.match(/rgba?\(\s*(\d{1,3})[\s,]+(\d{1,3})[\s,]+(\d{1,3})/i);return e?T(e.slice(1,4)):null}function I(t){const r=Number(t);return!Number.isFinite(r)||r<=0?0:r<=1?r*100:Math.min(r,100)}function g(t,r=0){if(!t)return[];if(Array.isArray(t)){if(t.length>=3&&t.slice(0,3).every(e=>Number.isFinite(Number(e)))){const e=T(t);return e?[{rgb:e,ratio:I(r)||100}]:[]}return t.flatMap(e=>g(e,r))}if(typeof t=="object"){const e=T(t),o=I(t.ratio??t.percent??t.weight??r);return e?[{rgb:e,ratio:o||100}]:[]}const n=T(t);return n?[{rgb:n,ratio:I(r)||100}]:[]}function b(t={}){return!t||typeof t!="object"?[]:[g(t.palettes),g(t.palette),g(t.dominantColors),g(t.dominantColor,100),g(t.primaryColor,100),g(t.backgroundColor,100),g(t.color,100),g(t.colors),g(t.colorTags)].flat()}function L(t=[]){return t.map((r,n)=>({rgb:r?.rgb||null,ratio:I(r?.ratio),index:n})).filter(r=>r.rgb&&r.ratio>0)}function X(t=[]){const r=L(t),n=r.filter(e=>e.ratio>=18);return n.length?n:r.slice(0,3).filter((e,o)=>o===0||e.ratio>=10)}function y(t=[]){const r=L(t).sort((n,e)=>e.ratio-n.ratio||n.index-e.index);return r.length?r.filter((n,e)=>e===0||n.ratio>=3).slice(0,8):[]}function k(t=[]){return y(t)}function _(t=[]){return y(t)}function w(t,r){if(!t||!r)return Number.POSITIVE_INFINITY;const n=t.r-r.r,e=t.g-r.g,o=t.b-r.b;return Math.sqrt(.299*n*n+.587*e*e+.114*o*o)}function O(t){const r=t/255;return r<=.04045?r/12.92:((r+.055)/1.055)**2.4}function F(t){return t>.008856?Math.cbrt(t):7.787*t+16/116}function Y(t){if(!t)return null;const r=O(t.r),n=O(t.g),e=O(t.b),o=(r*.4124+n*.3576+e*.1805)/.95047,c=r*.2126+n*.7152+e*.0722,s=(r*.0193+n*.1192+e*.9505)/1.08883,i=F(o),a=F(c),f=F(s);return{l:116*a-16,a:500*(i-a),b:200*(a-f)}}function G(t,r){const n=Y(t),e=Y(r);if(!n||!e)return Number.POSITIVE_INFINITY;const o=n.l-e.l,c=n.a-e.a,s=n.b-e.b;return Math.sqrt(o*o+c*c+s*s)}function R(t=[],r=null){if(!r)return Number.POSITIVE_INFINITY;const n=k(t).map(e=>{const o=I(e.ratio);if(!e.rgb||o<=0)return Number.POSITIVE_INFINITY;const c=G(r,e.rgb),s=w(r,e.rgb);return c+s*.16-Math.min(10,o/8)});return n.length?Math.min(...n):Number.POSITIVE_INFINITY}function S(t={}){return Array.isArray(t.previewImages)?t.previewImages.filter(r=>r?.thumbPath||r?.imagePath):[]}function V(t={}){if(t.favoritePreview?.thumbPath||t.favoritePreview?.imagePath)return t.favoritePreview;const r=S(t),n=String(t.coverThumbImage||""),e=String(t.coverImage||"");if(n||e){const o=r.find(c=>n&&String(c?.thumbPath||"")===n||e&&String(c?.imagePath||"")===e);return o||{thumbPath:n,imagePath:e}}return r[0]||null}function q(t={}){return[...b(t),...S(t).flatMap(b)]}function $(t={},r=""){const n=typeof r=="string"?A(r):r?.rgb||r,e=S(t),o=V(t);let c=null;for(const s of e){const i=b(s);if(!i.length)continue;const a=R(i,n);(!c||a<c.score)&&(c={preview:s,score:a})}return c?.preview?c:{preview:o,score:R(q(t),n)}}function N(t={}){return String(t.favoriteIdentity||t.favoriteId||t.thumbPath||t.imagePath||t.title||"")}function H(t={}){return[t.favoriteIdentity,t.favoriteId,t.thumbPath,t.imagePath,t.title].map(r=>
1String(r||"").trim()).filter(Boolean)}function J(t={},r={},n={}){const e=r?.style||{},o=Array.isArray(r?.prompts)?r.prompts:[],c=[...S(e),...S(t)],s=N(n.focusItem||{})||String(n.focusKey||""),a=[n.focusItem||c.find(u=>N(u)===s)||null,...c,e,t,...o].filter(u=>u&&typeof u=="object"),f=new Set;return a.filter(u=>{const m=N(u);return m?f.has(m)?!1:(f.add(m),!0):!0})}function Q(t={},r={}){const n=r?.style||{},e=Array.isArray(r?.prompts)?r.prompts.filter(i=>i?.thumbPath||i?.imagePath):[],o=[...S(n),...S(t),...e].filter(i=>i&&typeof i=="object"),c=[],s=new Map;for(const i of o){const a=N(i);if(!a||!s.has(a)){a&&s.set(a,c.length),c.push(i);continue}const f=s.get(a),u=c[f];!b(u).length&&b(i).length&&(c[f]={...u,...i})}return c}function j(t={},r=0){return String(t.title||t.name||t.promptTitle||`æ ·å¼  ${r+1}`).trim()}function W(t={},r={},n={}){if(n.perSource){const c=Math.max(1,Number(n.maxTargetsPerSource)||5),s=n.focusSourceOnly?new Set([...H(n.focusItem||{}),String(n.focusKey||"").trim()].filter(Boolean)):null,i=Q(t,r);s&&n.focusItem&&i.push(n.focusItem);const a=[];for(const[f,u]of i.entries()){if(s&&!H(u).some(l=>s.has(l)))continue;const m=N(u)||`source-${f}`,p=[];for(const l of _(b(u))){const x=C(l.rgb);if(!x)continue;const P=p.find(ot=>w(ot.rgb,l.rgb)<=14);if(P){P.ratio=Math.max(P.ratio,I(l.ratio));continue}const et=p.length,K={key:`${m}:${x}`,hex:x,rgb:l.rgb,ratio:I(l.ratio),label:j(u,f),source:u,sourceKey:m,sourceIndex:f,colorIndex:et,selected:a.length===0};if(p.push(K),a.push(K),p.length>=c)break}if(s&&p.length)return p}return s?[]:a}const e=Number(n.maxTargets)||5,o=[];for(const c of J(t,r,n)){const s=_(b(c));for(const i of s){const a=C(i.rgb);if(!a)continue;const f=o.find(m=>w(m.rgb,i.rgb)<=14);if(f){f.ratio=Math.max(f.ratio,I(i.ratio));continue}const u=o.length;if(o.push({key:`${a}:${u}`,hex:a,rgb:i.rgb,ratio:I(i.ratio),label:j(c,u),source:c,sourceIndex:u,selected:u===0}),o.length>=e)return o}}return o}function h(t,r,n,e=0){const o=t?.[r];if(typeof o!="function")return e;const c=Number(o(n));return Number.isFinite(c)?c:e}function M(t={}){return String(t.topicId||t.topicName||"").trim()}function Z({activeStyle:t={},candidateStyles:r=[],selectedColor:n="",helpers:e={}}={}){const o=String(t?.id||""),c=M(t),s=typeof n=="string"?A(n):n?.rgb||n;return(r||[]).filter(i=>
1String(i?.id||"")&&String(i?.id||"")!==o).map(i=>{const a=$(i,s),f=Number.isFinite(a.score)?a.score:Number.POSITIVE_INFINITY,u=c&&M(i)===c?.18:0,m=Math.min(.3,Math.log1p(h(e,"favCount",i))*.04),p=h(e,"styleRating",i)*.06,l=e?.isAdminLikedStyle?.(i)?.12:0,x=Math.min(.1,(Number(i.promptCount)||0)*.004),P=h(e,"styleRank",i)*.01;return{style:i,matchedPreview:a.preview,colorScore:f,sortScore:Number.isFinite(f)?f:9999,tieBreakScore:u+m+p+l+x+P,reason:Number.isFinite(f)?"色彩接近":u?"同主题":"相似风格"}}).sort((i,a)=>i.sortScore-a.sortScore||a.tieBreakScore-i.tieBreakScore||h(e,"favCount",a.style)-h(e,"favCount",i.style)||String(i.style.name||"").localeCompare(String(a.style.name||""),"zh-Hans-CN"))}function U(t={}){const r=Array.isArray(t.prompts)?t.prompts:[];return[t.name,t.topicId,t.topicName,t.folder,t.basePrompt,t.basePromptExcerpt,t.searchPromptText,...S(t).flatMap(n=>[n.title,n.prompt,n.content]),...r.flatMap(n=>[n.title,n.basePrompt,n.content])].join(" ")}function tt(t){return String(t||"").toLowerCase().replace(/[^\w\u3400-\u9fff]+/g," ").trim()}function v(t={}){const r=tt(U(t)),n=new Set(r.split(/\s+/).filter(e=>e.length>=2));for(const e of r.match(/[\u3400-\u9fff]{2,}/g)||[]){for(let o=0;o<e.length-1;o+=1)n.add(e.slice(o,o+2));for(let o=0;o<e.length-2;o+=1)n.add(e.slice(o,o+3));for(let o=0;o<e.length-3;o+=1)n.add(e.slice(o,o+4))}return n}function rt(t,r){if(!t?.size||!r?.size)return 0;let n=0;for(const o of t)r.has(o)&&(n+=o.length>=4?1.35:1);const e=t.size+r.size-n;return e>0?n/e:0}function nt({activeStyle:t={},candidateStyles:r=[],helpers:n={}}={}){const e=String(t?.id||""),o=M(t),c=v(t);return(r||[]).filter(s=>
1String(s?.id||"")&&String(s?.id||"")!==e).map(s=>{const i=rt(c,v(s)),a=o&&M(s)===o?.18:0,f=Math.min(.18,Math.log1p(h(n,"favCount",s))*.03),u=h(n,"styleRating",s)*.04,m=n?.isAdminLikedStyle?.(s)?.08:0,p=h(n,"styleRank",s)*.01,l=i+a+f+u+m+p;return{style:s,matchedPreview:V(s),semanticScore:i,score:l,reason:i>.04?"提示词接近":a?"同主题":"相似风格"}}).sort((s,i)=>i.score-s.score||i.semanticScore-s.semanticScore||h(n,"favCount",i.style)-h(n,"favCount",s.style)||String(s.style.name||"").localeCompare(String(i.style.name||""),"zh-Hans-CN"))}return{normalizeHexColor:B,hexToRgb:A,rgbToHex:C,rgbFromColorValue:T,paletteEntriesFromValue:g,paletteEntriesFromItem:b,dominantPaletteEntries:X,expressivePaletteEntries:y,paletteMatchEntries:k,paletteTargetEntries:_,colorMatchScoreForEntries:R,bestPreviewForColor:$,paletteTargetsForStyleDetail:W,semanticTokenSet:v,rankColorSimilarStyles:Z,rankPromptSimilarStyles:nt}});

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.