import{n as e}from"./appConfig-CuVl6yRs.js";import{r as t}from"./norm-CeclA1Tu.js";import{n}from"./webAppConfig-CqZlh029.js";import{t as r}from"./privacyMask-CsOBYv0S.js";var i={maskEnabled:!0,maskPhoneNumber:!0,maskEmail:!0,maskIdNumber:!0,maskBankNumber:!0,maskUrl:!0},a=e=>{let t=String(e||``);return t=t.replace(/<script\b[^>]*>[\s\S]*?<\/script>/gi,``),t=t.replace(/<!--[\s\S]*?-->/g,``),t=t.replace(/\son[a-z]+\s*=\s*(['"]).*?\1/gi,``),t=t.replace(/\son[a-z]+\s*=\s*[^\s>]+/gi,``),t=t.replace(/javascript:/gi,``),t},o=e=>String(e||``).replace(/>\s+</g,`><`).replace(/\n{2,}/g,`
`).replace(/[ \t]{2,}/g,` `).trim(),s=e=>{let t=String(e||``);for(let e of[/<(p|div|li|section|article)[^>]*>[\s\S]{0,260}?(?:手机号|手机|电话|邮箱|微信|wechat|contact|email|phone|address|地址|location|linkedin|github)[\s\S]*?<\/\1>/gi,/<(p|div|li|section|article)[^>]*>[\s\S]{0,260}?\[(?:PHONE|EMAIL|URL|ID|BANK)\][\s\S]*?<\/\1>/gi])t=t.replace(e,``);return t},c=e=>{let t=a(e);return t=s(t),t=t.replace(/<title\b[^>]*>[\s\S]*?<\/title>/i,`<title>匿名候选人简历</title>`),t=t.replace(/<h1\b[^>]*>[\s\S]*?<\/h1>/i,`<h1>匿名候选人</h1>`),t=t.replace(/<meta\b[^>]*name=["']robots["'][^>]*>/i,`<meta name="robots" content="noindex,nofollow">`),/<meta\b[^>]*name=["']robots["']/i.test(t)||(t=t.replace(/<head([^>]*)>/i,`<head$1><meta name="robots" content="noindex,nofollow">`)),t},l=async()=>{try{let t=(await e().catch(()=>null))?.privacy||{};return{...i,...t&&typeof t==`object`?t:{},maskEnabled:!0,maskPhoneNumber:!0,maskEmail:!0,maskIdNumber:!0,maskBankNumber:!0,maskUrl:!0}}catch{return i}},u=e=>{let n=e.match(/<h1\b[^>]*>([\s\S]*?)<\/h1>/i)?.[1]||``;return t(String(n||``).replace(/<[^>]+>/g,` `).replace(/\s+/g,` `).trim()).slice(0,80)||`匿名候选人简历`},d=()=>{let e=`https://bysjob.com`,r=t(n());if(!r)return e;try{let n=new URL(r),i=t(n.hostname).toLowerCase();return i===`localhost`||i===`127.0.0.1`||/^\d{1,3}(?:\.\d{1,3}){3}$/.test(i)?e:n.origin}catch{return e}},f=async e=>{let n=await l(),i=r(o(c(String(e.html||``))),n).trim();if(!i)throw Error(`网页简历内容为空，无法生成分享链接`);if(i.length>11e4)throw Error(`网页简历内容过大（${i.length} 字符），请精简内容后重试`);return{title:u(i),html:i,createdAt:Date.now(),source:`resume_optimize`,styleVariant:t(e.styleVariant),privacy:{anonymous:!0,maskedPhone:!0,maskedEmail:!0,maskedUrl:!0}}},p=e=>{let n=t(e);if(!n)return``;let r=d(),i=`/web/share/resume/${encodeURIComponent(n)}`;return r?`${r}${i}`:i};export{p as n,f as t};