var t=(t,e,i)=>new Promise((r,n)=>{var o=t=>{try{l(i.next(t))}catch(e){n(e)}},s=t=>{try{l(i.throw(t))}catch(e){n(e)}},l=t=>t.done?r(t.value):Promise.resolve(t.value).then(o,s);l((i=i.apply(t,e)).next())});import{bm as e,bt as i,bu as r}from"./vendor-core-Nc7YMZCV.js";import{j as n,u as o}from"./index-WIJVsNja.js";import{d as s}from"./logo-BYTYlt9V.js";const l={},a=(t,e,i)=>{const r=t.trim();if(!r)return"";const n=r.includes("<template")?r:`<template>${r}</template>`,o=e.trim()?`\n<style>${e}</style>`:"";if(!i.trim())return`${n}${o}`;var s;return`${n}${`\n<script setup lang="ts">\nimport { onMounted } from 'vue'\n${`\nonMounted(() => {\n  try {\n    const root = document.querySelector('[data-ext-theme-root]') || document.body\n    const fn = new Function('root', 'window', 'document', \`${s=i,String(s||"").replace(/\\/g,"\\\\").replace(/`/g,"\\`").replace(/\$\{/g,"\\${")}\`)\n    fn(root, window, document)\n  } catch (e) {\n    console.error('External theme runtime script failed:', e)\n  }\n})`}\n<\/script>`}${o}`},c=t=>{if(!t)return"";if(/^https?:\/\//i.test(t)||t.startsWith("data:"))return t;const e="undefined"!=typeof window?window.location.origin:"";if(t.startsWith("/src/")||t.startsWith("/assets/"))return e?`${e}${t}`:t;const i=String("").trim(),r=(()=>{if(!i)return e;try{return new URL(i,e||void 0).href}catch(t){return e}})();if(!r)return t.startsWith("/")?t:`/${t}`;try{return new URL(t,r).href}catch(n){return t.startsWith("/")?t:`/${t}`}},d=(t,e,i)=>{var r;const n=window.__ADVANCED_THEME_CONTEXT__||{},o=c(s),l=c(e.siteLogo||(null==(r=e.siteConfig)?void 0:r.site_logo)||"")||o,a={"{{siteName}}":e.siteName||"","{{siteLogo}}":l,"{{siteLogoImg}}":l?`<img src="${l}" alt="logo" />`:"","{{siteDescription}}":e.siteDescription||"","{{siteKeywords}}":e.siteKeywords||"","{{siteCopyright}}":e.siteCopyright||"","{{siteIcp}}":e.siteIcp||"","{{siteDianzeng}}":e.siteDianzeng||""};if("article_list"===i){const t=e.faqs||[],i=t=>String(null!=t?t:"").replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;");a["{{articleListHtml}}"]=t.map(t=>{const e=null==t?void 0:t.id,r=i((null==t?void 0:t.title)||""),n=i((null==t?void 0:t.create_time)||"");return e?`<a class="simple-article-item" href="/articles/${encodeURIComponent(String(e))}"><div class="simple-article-item-title">${r}</div><div class="simple-article-item-date">${n}</div></a>`:`<div class="simple-article-item simple-article-item-disabled"><div class="simple-article-item-title">${r}</div><div class="simple-article-item-date">${n}</div></div>`}).join("")}if("article_detail"===i){const t=n.article||{};a["{{articleTitle}}"]=t.title||"",a["{{articleDate}}"]=t.create_time||"",a["{{articleContentHtml}}"]=t.content||""}if("order"===i){const t=n.order||{};a["{{orderTradeNo}}"]=t.trade_no||"",a["{{orderStatus}}"]=t.status||"",a["{{orderAmount}}"]=t.amount||"",a["{{orderProductName}}"]=t.product_name||"",a["{{orderSearchWidget}}"]='\n<div class="order-search-widget" data-ext-order-widget>\n  <div class="flex flex-col gap-3">\n    <div class="flex flex-col sm:flex-row gap-2">\n      <input data-field="keyword" type="text" placeholder="请输入订单号或联系方式" class="flex-1 px-3 py-2 border rounded text-sm" />\n      <button data-action="submit" class="px-4 py-2 text-sm rounded bg-blue-600 text-white disabled:opacity-60" type="button">查询订单</button>\n    </div>\n    <div data-field="error" class="text-sm text-red-500"></div>\n    <div data-field="result" class="mt-4 space-y-3"></div>\n  </div>\n</div>'}if("shop_home"===i){const t=n.shop||{};a["{{shopName}}"]=t.name||"",a["{{shopAvatar}}"]=t.avatar||"",a["{{shopNotice}}"]=t.notice||"",a["{{shopStatusText}}"]=t.status_text||"",a["{{shopProductsHtml}}"]=t.products_html||""}let d=t;return Object.keys(a).forEach(t=>{const e=a[t];d=d.split(t).join(e)}),d},m=(e,i)=>t(null,null,function*(){const t=`${e}:${i}`;if(l[t])return l[t];try{const s=yield(r=e,o=i,n.get({url:"/api/theme/payload",params:{module:r,id:o}}));return l[t]=s||null,l[t]}catch(s){return l[t]=null,null}var r,o}),u=(n,s)=>e(()=>t(null,null,function*(){const t=o();yield t.fetchSiteConfig();const e=yield m(n,s),l=d(String((null==e?void 0:e.html)||""),t,n),c=d(String((null==e?void 0:e.css)||""),t,n),u=d(String((null==e?void 0:e.js)||""),t,n),p=`<div data-ext-theme-root>${l}</div>`;if(!l.trim()&&!c.trim()&&!u.trim())return{template:'<div class="p-10 text-center">Template content is empty or failed to load.</div>'};const v=a(p,c,u||""),f={moduleCache:{vue:r},getFile:()=>v,addStyle(t){const e=document.createElement("style");e.textContent=t;const i=document.head.getElementsByTagName("style")[0]||null;document.head.insertBefore(e,i)}};return yield i("custom.vue",f)}));export{u as l};
