live2dapi-noa 2.4.3 → 2.4.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/autoload.js +1 -1
- package/css/left.css +17 -9
- package/css/left.min.css +1 -1
- package/css/right.css +17 -9
- package/css/right.min.css +1 -1
- package/docs/en/README.md +3 -3
- package/jsdelivr/random/autoload.js +1 -1
- package/jsdelivr/random/autoload.min.js +1 -1
- package/jsdelivr/random/waifu-tips.js +2 -2
- package/jsdelivr/sequential/autoload.js +1 -1
- package/jsdelivr/sequential/autoload.min.js +1 -1
- package/jsdelivr/sequential/waifu-tips.js +2 -2
- package/npm/random/autoload.js +1 -1
- package/npm/random/waifu-tips.js +2 -2
- package/npm/sequential/autoload.js +1 -1
- package/npm/sequential/waifu-tips.js +2 -2
- package/package.json +1 -1
- package/widget.mjs +1 -1
package/README.md
CHANGED
|
@@ -6,18 +6,18 @@
|
|
|
6
6
|
|
|
7
7
|
## 快速接入
|
|
8
8
|
|
|
9
|
-
选择适合主要访客的 CDN,把一行代码放在 `</body>`
|
|
9
|
+
选择适合主要访客的 CDN,把一行代码放在 `</body>` 前。两个入口都跟随最新稳定版,默认显示简体中文。CDN 缓存更新后,新访问会加载新版本。需要锁定版本时,可将 `widget-latest` 换为 `widget-2.4.4`。
|
|
10
10
|
|
|
11
11
|
**中国大陆**
|
|
12
12
|
|
|
13
13
|
```html
|
|
14
|
-
<script type="module" src="https://cdn.jsdmirror.com/gh/nova1751/live2d-api@widget-
|
|
14
|
+
<script type="module" src="https://cdn.jsdmirror.com/gh/nova1751/live2d-api@widget-latest/girls-frontline.mjs"></script>
|
|
15
15
|
```
|
|
16
16
|
|
|
17
17
|
**海外**
|
|
18
18
|
|
|
19
19
|
```html
|
|
20
|
-
<script type="module" src="https://cdn.jsdelivr.net/gh/nova1751/live2d-api@widget-
|
|
20
|
+
<script type="module" src="https://cdn.jsdelivr.net/gh/nova1751/live2d-api@widget-latest/girls-frontline.mjs"></script>
|
|
21
21
|
```
|
|
22
22
|
|
|
23
23
|
快捷入口在视口宽度达到 768 CSS 像素时显示。首次访问默认展示一阶空袭妖精,后续访问恢复该站上次选择的造型。需要自定显示条件时可使用模块 API。
|
package/autoload.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/*! Live2D API | Generated from src/ | https://github.com/nova1751/live2d-api */
|
|
2
|
-
"use strict";(()=>{function v(e){return e.pathname.toLowerCase().endsWith(".model3.json")}function j(e,t){let s,o,i,c=0,a=!1;function p(){return s??(s=new Promise((n,d)=>{let r=document.createElement("script");r.src=e+"live2d.min.js",r.acceptCubism2=u=>{t=u,n(u)},r.onerror=()=>d(new Error("Failed to load "+r.src)),document.head.appendChild(r)}).catch(n=>{throw s=void 0,n}))}let l=(n,d,r)=>{let u=++c;o?.abort(),o=void 0,i=void 0,a=!1;let h=new URL(d,document.baseURI);if(!v(h))return t?t(n,d,r):p().then(g=>{if(c!==u)return;let R=g(n,d,r);return a&&g.hide?.(),R});t?.hide?.(),o=new AbortController;let{signal:w}=o;return import(e+"modern/renderer.mjs").then(async g=>{if(w.aborted)return;let R=await g.mountModern(document.getElementById(n),h.href,r?.coreUrl,w,r?.dialogue,r?.framing,r?.onPaint);w.aborted||(i=R,a&&i.pause())}).catch(g=>{if(!w.aborted)throw o=void 0,g})};return l.hide=()=>{a=!0,o?i?.pause():t?.hide?.()},l.show=n=>{a=!1,o?i?.resume():t?.show?.(n)},l.prepareInteraction=()=>!o&&!!t?.prepareInteraction?.(),l.capture=()=>(o&&i?.capture(),!!o),l}var M="2.4.
|
|
2
|
+
"use strict";(()=>{function v(e){return e.pathname.toLowerCase().endsWith(".model3.json")}function j(e,t){let s,o,i,c=0,a=!1;function p(){return s??(s=new Promise((n,d)=>{let r=document.createElement("script");r.src=e+"live2d.min.js",r.acceptCubism2=u=>{t=u,n(u)},r.onerror=()=>d(new Error("Failed to load "+r.src)),document.head.appendChild(r)}).catch(n=>{throw s=void 0,n}))}let l=(n,d,r)=>{let u=++c;o?.abort(),o=void 0,i=void 0,a=!1;let h=new URL(d,document.baseURI);if(!v(h))return t?t(n,d,r):p().then(g=>{if(c!==u)return;let R=g(n,d,r);return a&&g.hide?.(),R});t?.hide?.(),o=new AbortController;let{signal:w}=o;return import(e+"modern/renderer.mjs").then(async g=>{if(w.aborted)return;let R=await g.mountModern(document.getElementById(n),h.href,r?.coreUrl,w,r?.dialogue,r?.framing,r?.onPaint);w.aborted||(i=R,a&&i.pause())}).catch(g=>{if(!w.aborted)throw o=void 0,g})};return l.hide=()=>{a=!0,o?i?.pause():t?.hide?.()},l.show=n=>{a=!1,o?i?.resume():t?.show?.(n)},l.prepareInteraction=()=>!o&&!!t?.prepareInteraction?.(),l.capture=()=>(o&&i?.capture(),!!o),l}var M="2.4.5";var D="/gh/nova1751/live2d-api@cdn-b3ac5ae545e2/",U="https://cdn.jsdelivr.net",N=U+D,k=/\/gh\/nova1751\/live2d-api@widget-[^/]+\/?$/,W=/\/live2dapi-noa(?:@[^/]+)?\/?$/;function b(e){let t=new URL(e,document.baseURI);return W.test(t.pathname)?(t.pathname.endsWith("/")||(t.pathname+="/"),t.search=t.hash="",t):new URL(".",t)}function E(e){return/^https?:\/\//.test(e)&&/\/widget\.mjs(?:[?#]|$)/.test(e)?b(e):new URL(U+"/gh/nova1751/live2d-api@widget-"+M+"/")}function L(e){return(e.hostname==="cdn.jsdmirror.com"?e.origin:U)+"/gh/nova1751/live2d-api@catalog-0cb4f982723bf0f0/catalog/library.json"}function I(e){if(!(!W.test(e.pathname)&&!k.test(e.pathname)))return L(e)}var f=Symbol.for("live2dapi-noa.mounting"),y=new Map;function x(e,t){return new Promise((s,o)=>{e.onload=()=>s(),e.onerror=()=>{e.remove(),o(new Error(`Failed to load ${t}`))},document.head.appendChild(e)})}function C(e,t,s){if(!y.has(e)){let o=document.createElement("script");o.src=e,s&&(o.dataset.asteroidsUrl=s);let i=x(o,e).then(()=>{let c=window[t];if(typeof c!="function")throw new Error(`Missing export from ${e}`);return c}).catch(c=>{throw y.delete(e),c});y.set(e,i)}return y.get(e)}async function T(e,t,s,o){let{modelUrl:i,coreUrl:c,modelBaseUrl:a,catalogUrl:p,modelId:l,collection:n,locale:d}=t,r=document.createElement("link");r.rel="stylesheet",r.href=e+`css/${o}.css`;try{let[,,u]=await Promise.all([x(r,r.href),p||i&&v(new URL(i,document.baseURI))?window.loadlive2d=j(e):C(e+"live2d.min.js","loadlive2d"),C(e+`jsdelivr/${s}/waifu-tips.js`,"initWidget",e+"asteroids.js")]);document.body||await new Promise(h=>document.addEventListener("DOMContentLoaded",()=>h(),{once:!0})),document.getElementById("waifu-toggle")||u({cdnPath:e,collection:n,locale:d,catalogUrl:p&&new URL(p,document.baseURI).href,modelId:l,modelBaseUrl:a&&new URL(a,document.baseURI).href,waifuPath:e+(d==="en"?"waifu-tips.en.json":"waifu-tips.json"),modelUrl:i&&new URL(i,document.baseURI).href,coreUrl:c&&new URL(c,document.baseURI).href})}catch(u){throw r.remove(),u}}async function P({mode:e="sequential",position:t="left",baseUrl:s,modelUrl:o,coreUrl:i,modelBaseUrl:c,catalogUrl:a,modelId:p,collection:l,locale:n}={}){if(n&&n!=="en"&&n!=="zh-CN")throw new TypeError("Unsupported widget locale");if(!["random","sequential"].includes(e))throw new TypeError("Invalid Live2D mode");if(!["left","right"].includes(t))throw new TypeError("Invalid Live2D position");if(a&&o)throw new TypeError("Choose catalogUrl or modelUrl");let d=document;if(d[f])return d[f];if(document.getElementById("waifu-toggle"))return;let r=s===void 0?E(document.currentScript.src):new URL(s,document.baseURI);if(r.pathname.endsWith("/")||(r.pathname+="/"),r.search="",r.hash="",!a&&!o&&!c&&(a=l?L(r):I(r)),p&&!a)throw new TypeError("modelId requires a catalog");return d[f]=T(r.href,{modelUrl:o,coreUrl:i,modelBaseUrl:c,catalogUrl:a,modelId:p,collection:l,locale:n},e,t).catch(u=>{throw delete d[f],u}),d[f]}var m=document.currentScript;if(m&&window.innerWidth>=768){let{mode:e,position:t}=m.dataset;P({locale:m.dataset.locale==="en"?"en":"zh-CN",baseUrl:b(m.src),catalogUrl:m.dataset.catalogUrl,modelId:m.dataset.modelId,modelBaseUrl:m.dataset.modelBaseUrl,modelUrl:m.dataset.modelUrl,coreUrl:m.dataset.coreUrl,mode:e,position:t}).catch(s=>console.error("[Live2D]",s))}})();
|
package/css/left.css
CHANGED
|
@@ -2,25 +2,30 @@
|
|
|
2
2
|
#waifu-toggle {
|
|
3
3
|
border: 0;
|
|
4
4
|
background-color: #fa0;
|
|
5
|
-
border-radius: 5px;
|
|
5
|
+
border-radius: 0 5px 5px 0;
|
|
6
6
|
bottom: 66px;
|
|
7
7
|
color: #fff;
|
|
8
8
|
cursor: pointer;
|
|
9
9
|
font-size: 12px;
|
|
10
10
|
left: 0;
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
visibility: hidden;
|
|
12
|
+
box-sizing: border-box;
|
|
13
|
+
margin: 0;
|
|
14
|
+
padding: 7px 0;
|
|
13
15
|
position: fixed;
|
|
14
|
-
|
|
15
|
-
|
|
16
|
+
width: 32px;
|
|
17
|
+
min-height: 48px;
|
|
18
|
+
line-height: 1;
|
|
19
|
+
z-index: 2;
|
|
16
20
|
writing-mode: vertical-rl;
|
|
17
21
|
}
|
|
18
22
|
#waifu-toggle.waifu-toggle-active {
|
|
19
|
-
|
|
23
|
+
visibility: visible;
|
|
20
24
|
}
|
|
21
|
-
|
|
22
|
-
#waifu-toggle
|
|
23
|
-
|
|
25
|
+
@media (pointer: coarse) {
|
|
26
|
+
#waifu-toggle {
|
|
27
|
+
min-width: 44px;
|
|
28
|
+
}
|
|
24
29
|
}
|
|
25
30
|
#waifu {
|
|
26
31
|
bottom: -1000px;
|
|
@@ -50,6 +55,9 @@
|
|
|
50
55
|
inset: 0 var(--waifu-side-space) 0 0;
|
|
51
56
|
overflow: hidden;
|
|
52
57
|
}
|
|
58
|
+
#waifu[data-initial-framing] {
|
|
59
|
+
visibility: hidden;
|
|
60
|
+
}
|
|
53
61
|
.waifu-surface {
|
|
54
62
|
position: absolute;
|
|
55
63
|
left: 50%;
|
package/css/left.min.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
#waifu-toggle{border:0;background-color:#fa0;border-radius:5px;bottom:66px;color:#fff;cursor:pointer;font-size:12px;left:0;
|
|
1
|
+
#waifu-toggle{border:0;background-color:#fa0;border-radius:0 5px 5px 0;bottom:66px;color:#fff;cursor:pointer;font-size:12px;left:0;visibility:hidden;box-sizing:border-box;margin:0;padding:7px 0;position:fixed;width:32px;min-height:48px;line-height:1;z-index:2;writing-mode:vertical-rl}#waifu-toggle.waifu-toggle-active{visibility:visible}@media(pointer:coarse){#waifu-toggle{min-width:44px}}#waifu{bottom:-1000px;line-height:0;margin-bottom:0;position:fixed;transform:translateY(3px);transition:transform .3s ease-in-out,bottom 3s ease-in-out;z-index:1}#waifu.waifu-adaptive{--waifu-rail: 44px;--waifu-gap: 6px;--waifu-side-space: calc(var(--waifu-rail) + var(--waifu-gap));--waifu-top-tools: 0px;--waifu-edge-gap: clamp(12px, 2vw, 24px);--waifu-left-inset: max(var(--waifu-edge-gap), env(safe-area-inset-left, 0px));--waifu-right-inset: max(var(--waifu-edge-gap), env(safe-area-inset-right, 0px));--waifu-max-width: min(480px, calc(100vw - var(--waifu-left-inset) - var(--waifu-right-inset) - var(--waifu-side-space)));--waifu-max-height: min(410px, 60vh);--waifu-model-width: min(var(--waifu-max-width), calc(var(--waifu-max-height) * var(--waifu-aspect, 1)));width:calc(var(--waifu-model-width) + var(--waifu-side-space));height:calc(var(--waifu-model-width) / var(--waifu-aspect, 1))}.waifu-viewport{position:absolute;inset:0 var(--waifu-side-space) 0 0;overflow:hidden}#waifu[data-initial-framing]{visibility:hidden}.waifu-surface{position:absolute;left:50%;bottom:0;transform:translate(-50%);width:max(100%,calc(100% / var(--waifu-aspect, 1)));aspect-ratio:1}.waifu-surface>div,.waifu-surface #live2d{display:block;width:100%;height:100%}#waifu.waifu-adaptive #waifu-tips{box-sizing:border-box;z-index:1;top:auto;bottom:calc(100% + var(--waifu-gap) + var(--waifu-top-tools));left:0;right:var(--waifu-side-space);width:min(320px,var(--waifu-model-width));min-height:0;max-height:min(30vh,160px);margin:0 auto;overflow:auto;overflow-wrap:anywhere;word-break:normal}#waifu.waifu-adaptive #waifu-tips.waifu-tips-active{pointer-events:auto}#waifu.waifu-adaptive #waifu-tool{z-index:2;margin-block:auto;box-sizing:border-box;height:max-content;inset:0 0 0 auto;width:var(--waifu-rail);max-height:100%;overflow-y:auto;scrollbar-width:thin}#waifu.waifu-adaptive #waifu-tool button{width:100%;text-align:center}#waifu:hover{transform:translateY(0)}#waifu-tips{pointer-events:none;animation:shake 50s ease-in-out 5s infinite;background-color:#ecd9bc80;border:1px solid rgba(224,186,140,.62);border-radius:12px;box-shadow:0 3px 15px 2px #bf9e7633;font-size:14px;line-height:24px;margin:-30px 30px;min-height:75px;opacity:0;overflow:hidden;padding:5px 10px;position:absolute;text-overflow:ellipsis;transition:opacity 1s;width:280px;word-break:break-all;top:-60px}#waifu-tips.waifu-tips-active{opacity:1;transition:opacity .2s}#waifu-tips span{color:#09c}#live2d{cursor:grab;height:350px;position:relative;width:350px}#waifu canvas,#waifu-tool button,#waifu-toggle{user-select:none;-webkit-tap-highlight-color:transparent}#waifu canvas:focus:not(:focus-visible),#waifu-tool button:focus:not(:focus-visible),#waifu-toggle:focus:not(:focus-visible){outline:none;box-shadow:none}#waifu[data-model-loading] #live2d,#waifu[data-model-loading] .waifu-model-stage{opacity:0;pointer-events:none}#waifu .waifu-model-still{position:absolute;inset:0;width:100%;height:100%;pointer-events:none}#live2d:active{cursor:grabbing}#waifu-tool{color:#aaa;opacity:0;position:absolute;top:50px;transition:opacity 1s}#waifu:hover #waifu-tool,#waifu:focus-within #waifu-tool{opacity:1}#waifu-tool button{appearance:none;border:0;background:transparent;padding:0 4px;cursor:pointer;display:block;height:40px;text-align:center}#waifu-tool svg{fill:#7b8c9d;cursor:pointer;height:22px;transition:fill .3s}#waifu-tool svg:hover{fill:#0684bd}@keyframes shake{2%{transform:translate(.5px,-1.5px) rotate(-.5deg)}4%{transform:translate(.5px,1.5px) rotate(1.5deg)}6%{transform:translate(1.5px,1.5px) rotate(1.5deg)}8%{transform:translate(2.5px,1.5px) rotate(.5deg)}10%{transform:translate(.5px,2.5px) rotate(.5deg)}12%{transform:translate(1.5px,1.5px) rotate(.5deg)}14%{transform:translate(.5px,.5px) rotate(.5deg)}16%{transform:translate(-1.5px,-.5px) rotate(1.5deg)}18%{transform:translate(.5px,.5px) rotate(1.5deg)}20%{transform:translate(2.5px,2.5px) rotate(1.5deg)}22%{transform:translate(.5px,-1.5px) rotate(1.5deg)}24%{transform:translate(-1.5px,1.5px) rotate(-.5deg)}26%{transform:translate(1.5px,.5px) rotate(1.5deg)}28%{transform:translate(-.5px,-.5px) rotate(-.5deg)}30%{transform:translate(1.5px,-.5px) rotate(-.5deg)}32%{transform:translate(2.5px,-1.5px) rotate(1.5deg)}34%{transform:translate(2.5px,2.5px) rotate(-.5deg)}36%{transform:translate(.5px,-1.5px) rotate(.5deg)}38%{transform:translate(2.5px,-.5px) rotate(-.5deg)}40%{transform:translate(-.5px,2.5px) rotate(.5deg)}42%{transform:translate(-1.5px,2.5px) rotate(.5deg)}44%{transform:translate(-1.5px,1.5px) rotate(.5deg)}46%{transform:translate(1.5px,-.5px) rotate(-.5deg)}48%{transform:translate(2.5px,-.5px) rotate(.5deg)}50%{transform:translate(-1.5px,1.5px) rotate(.5deg)}52%{transform:translate(-.5px,1.5px) rotate(.5deg)}54%{transform:translate(-1.5px,1.5px) rotate(.5deg)}56%{transform:translate(.5px,2.5px) rotate(1.5deg)}58%{transform:translate(2.5px,2.5px) rotate(.5deg)}60%{transform:translate(2.5px,-1.5px) rotate(1.5deg)}62%{transform:translate(-1.5px,.5px) rotate(1.5deg)}64%{transform:translate(-1.5px,1.5px) rotate(1.5deg)}66%{transform:translate(.5px,2.5px) rotate(1.5deg)}68%{transform:translate(2.5px,-1.5px) rotate(1.5deg)}70%{transform:translate(2.5px,2.5px) rotate(.5deg)}72%{transform:translate(-.5px,-1.5px) rotate(1.5deg)}74%{transform:translate(-1.5px,2.5px) rotate(1.5deg)}76%{transform:translate(-1.5px,2.5px) rotate(1.5deg)}78%{transform:translate(-1.5px,2.5px) rotate(.5deg)}80%{transform:translate(-1.5px,.5px) rotate(-.5deg)}82%{transform:translate(-1.5px,.5px) rotate(-.5deg)}84%{transform:translate(-.5px,.5px) rotate(1.5deg)}86%{transform:translate(2.5px,1.5px) rotate(.5deg)}88%{transform:translate(-1.5px,.5px) rotate(1.5deg)}90%{transform:translate(-1.5px,-.5px) rotate(-.5deg)}92%{transform:translate(-1.5px,-1.5px) rotate(1.5deg)}94%{transform:translate(.5px,.5px) rotate(-.5deg)}96%{transform:translate(2.5px,-.5px) rotate(-.5deg)}98%{transform:translate(-1.5px,-1.5px) rotate(-.5deg)}0%,to{transform:translate(0) rotate(0)}}.waifu-sr-only{position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%)}#waifu-tool button:focus-visible,#waifu-toggle:focus-visible{outline:2px solid #126381;outline-offset:2px}@media(hover:none){#waifu-tool{opacity:1}#waifu-tool button{min-width:44px;min-height:44px}}@media(prefers-reduced-motion:reduce){#waifu,#waifu-toggle,#waifu-tool,#waifu-tips,#waifu-tips.waifu-tips-active{animation:none;transition:none}}#waifu{left:0}#waifu.waifu-adaptive{left:var(--waifu-left-inset)}#waifu-tool{right:10px}
|
package/css/right.css
CHANGED
|
@@ -2,25 +2,30 @@
|
|
|
2
2
|
#waifu-toggle {
|
|
3
3
|
border: 0;
|
|
4
4
|
background-color: #fa0;
|
|
5
|
-
border-radius: 5px;
|
|
5
|
+
border-radius: 0 5px 5px 0;
|
|
6
6
|
bottom: 66px;
|
|
7
7
|
color: #fff;
|
|
8
8
|
cursor: pointer;
|
|
9
9
|
font-size: 12px;
|
|
10
10
|
left: 0;
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
visibility: hidden;
|
|
12
|
+
box-sizing: border-box;
|
|
13
|
+
margin: 0;
|
|
14
|
+
padding: 7px 0;
|
|
13
15
|
position: fixed;
|
|
14
|
-
|
|
15
|
-
|
|
16
|
+
width: 32px;
|
|
17
|
+
min-height: 48px;
|
|
18
|
+
line-height: 1;
|
|
19
|
+
z-index: 2;
|
|
16
20
|
writing-mode: vertical-rl;
|
|
17
21
|
}
|
|
18
22
|
#waifu-toggle.waifu-toggle-active {
|
|
19
|
-
|
|
23
|
+
visibility: visible;
|
|
20
24
|
}
|
|
21
|
-
|
|
22
|
-
#waifu-toggle
|
|
23
|
-
|
|
25
|
+
@media (pointer: coarse) {
|
|
26
|
+
#waifu-toggle {
|
|
27
|
+
min-width: 44px;
|
|
28
|
+
}
|
|
24
29
|
}
|
|
25
30
|
#waifu {
|
|
26
31
|
bottom: -1000px;
|
|
@@ -50,6 +55,9 @@
|
|
|
50
55
|
inset: 0 var(--waifu-side-space) 0 0;
|
|
51
56
|
overflow: hidden;
|
|
52
57
|
}
|
|
58
|
+
#waifu[data-initial-framing] {
|
|
59
|
+
visibility: hidden;
|
|
60
|
+
}
|
|
53
61
|
.waifu-surface {
|
|
54
62
|
position: absolute;
|
|
55
63
|
left: 50%;
|
package/css/right.min.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
#waifu-toggle{border:0;background-color:#fa0;border-radius:5px;bottom:66px;color:#fff;cursor:pointer;font-size:12px;left:0;
|
|
1
|
+
#waifu-toggle{border:0;background-color:#fa0;border-radius:0 5px 5px 0;bottom:66px;color:#fff;cursor:pointer;font-size:12px;left:0;visibility:hidden;box-sizing:border-box;margin:0;padding:7px 0;position:fixed;width:32px;min-height:48px;line-height:1;z-index:2;writing-mode:vertical-rl}#waifu-toggle.waifu-toggle-active{visibility:visible}@media(pointer:coarse){#waifu-toggle{min-width:44px}}#waifu{bottom:-1000px;line-height:0;margin-bottom:0;position:fixed;transform:translateY(3px);transition:transform .3s ease-in-out,bottom 3s ease-in-out;z-index:1}#waifu.waifu-adaptive{--waifu-rail: 44px;--waifu-gap: 6px;--waifu-side-space: calc(var(--waifu-rail) + var(--waifu-gap));--waifu-top-tools: 0px;--waifu-edge-gap: clamp(12px, 2vw, 24px);--waifu-left-inset: max(var(--waifu-edge-gap), env(safe-area-inset-left, 0px));--waifu-right-inset: max(var(--waifu-edge-gap), env(safe-area-inset-right, 0px));--waifu-max-width: min(480px, calc(100vw - var(--waifu-left-inset) - var(--waifu-right-inset) - var(--waifu-side-space)));--waifu-max-height: min(410px, 60vh);--waifu-model-width: min(var(--waifu-max-width), calc(var(--waifu-max-height) * var(--waifu-aspect, 1)));width:calc(var(--waifu-model-width) + var(--waifu-side-space));height:calc(var(--waifu-model-width) / var(--waifu-aspect, 1))}.waifu-viewport{position:absolute;inset:0 var(--waifu-side-space) 0 0;overflow:hidden}#waifu[data-initial-framing]{visibility:hidden}.waifu-surface{position:absolute;left:50%;bottom:0;transform:translate(-50%);width:max(100%,calc(100% / var(--waifu-aspect, 1)));aspect-ratio:1}.waifu-surface>div,.waifu-surface #live2d{display:block;width:100%;height:100%}#waifu.waifu-adaptive #waifu-tips{box-sizing:border-box;z-index:1;top:auto;bottom:calc(100% + var(--waifu-gap) + var(--waifu-top-tools));left:0;right:var(--waifu-side-space);width:min(320px,var(--waifu-model-width));min-height:0;max-height:min(30vh,160px);margin:0 auto;overflow:auto;overflow-wrap:anywhere;word-break:normal}#waifu.waifu-adaptive #waifu-tips.waifu-tips-active{pointer-events:auto}#waifu.waifu-adaptive #waifu-tool{z-index:2;margin-block:auto;box-sizing:border-box;height:max-content;inset:0 0 0 auto;width:var(--waifu-rail);max-height:100%;overflow-y:auto;scrollbar-width:thin}#waifu.waifu-adaptive #waifu-tool button{width:100%;text-align:center}#waifu:hover{transform:translateY(0)}#waifu-tips{pointer-events:none;animation:shake 50s ease-in-out 5s infinite;background-color:#ecd9bc80;border:1px solid rgba(224,186,140,.62);border-radius:12px;box-shadow:0 3px 15px 2px #bf9e7633;font-size:14px;line-height:24px;margin:-30px 30px;min-height:75px;opacity:0;overflow:hidden;padding:5px 10px;position:absolute;text-overflow:ellipsis;transition:opacity 1s;width:280px;word-break:break-all;top:-60px}#waifu-tips.waifu-tips-active{opacity:1;transition:opacity .2s}#waifu-tips span{color:#09c}#live2d{cursor:grab;height:350px;position:relative;width:350px}#waifu canvas,#waifu-tool button,#waifu-toggle{user-select:none;-webkit-tap-highlight-color:transparent}#waifu canvas:focus:not(:focus-visible),#waifu-tool button:focus:not(:focus-visible),#waifu-toggle:focus:not(:focus-visible){outline:none;box-shadow:none}#waifu[data-model-loading] #live2d,#waifu[data-model-loading] .waifu-model-stage{opacity:0;pointer-events:none}#waifu .waifu-model-still{position:absolute;inset:0;width:100%;height:100%;pointer-events:none}#live2d:active{cursor:grabbing}#waifu-tool{color:#aaa;opacity:0;position:absolute;top:50px;transition:opacity 1s}#waifu:hover #waifu-tool,#waifu:focus-within #waifu-tool{opacity:1}#waifu-tool button{appearance:none;border:0;background:transparent;padding:0 4px;cursor:pointer;display:block;height:40px;text-align:center}#waifu-tool svg{fill:#7b8c9d;cursor:pointer;height:22px;transition:fill .3s}#waifu-tool svg:hover{fill:#0684bd}@keyframes shake{2%{transform:translate(.5px,-1.5px) rotate(-.5deg)}4%{transform:translate(.5px,1.5px) rotate(1.5deg)}6%{transform:translate(1.5px,1.5px) rotate(1.5deg)}8%{transform:translate(2.5px,1.5px) rotate(.5deg)}10%{transform:translate(.5px,2.5px) rotate(.5deg)}12%{transform:translate(1.5px,1.5px) rotate(.5deg)}14%{transform:translate(.5px,.5px) rotate(.5deg)}16%{transform:translate(-1.5px,-.5px) rotate(1.5deg)}18%{transform:translate(.5px,.5px) rotate(1.5deg)}20%{transform:translate(2.5px,2.5px) rotate(1.5deg)}22%{transform:translate(.5px,-1.5px) rotate(1.5deg)}24%{transform:translate(-1.5px,1.5px) rotate(-.5deg)}26%{transform:translate(1.5px,.5px) rotate(1.5deg)}28%{transform:translate(-.5px,-.5px) rotate(-.5deg)}30%{transform:translate(1.5px,-.5px) rotate(-.5deg)}32%{transform:translate(2.5px,-1.5px) rotate(1.5deg)}34%{transform:translate(2.5px,2.5px) rotate(-.5deg)}36%{transform:translate(.5px,-1.5px) rotate(.5deg)}38%{transform:translate(2.5px,-.5px) rotate(-.5deg)}40%{transform:translate(-.5px,2.5px) rotate(.5deg)}42%{transform:translate(-1.5px,2.5px) rotate(.5deg)}44%{transform:translate(-1.5px,1.5px) rotate(.5deg)}46%{transform:translate(1.5px,-.5px) rotate(-.5deg)}48%{transform:translate(2.5px,-.5px) rotate(.5deg)}50%{transform:translate(-1.5px,1.5px) rotate(.5deg)}52%{transform:translate(-.5px,1.5px) rotate(.5deg)}54%{transform:translate(-1.5px,1.5px) rotate(.5deg)}56%{transform:translate(.5px,2.5px) rotate(1.5deg)}58%{transform:translate(2.5px,2.5px) rotate(.5deg)}60%{transform:translate(2.5px,-1.5px) rotate(1.5deg)}62%{transform:translate(-1.5px,.5px) rotate(1.5deg)}64%{transform:translate(-1.5px,1.5px) rotate(1.5deg)}66%{transform:translate(.5px,2.5px) rotate(1.5deg)}68%{transform:translate(2.5px,-1.5px) rotate(1.5deg)}70%{transform:translate(2.5px,2.5px) rotate(.5deg)}72%{transform:translate(-.5px,-1.5px) rotate(1.5deg)}74%{transform:translate(-1.5px,2.5px) rotate(1.5deg)}76%{transform:translate(-1.5px,2.5px) rotate(1.5deg)}78%{transform:translate(-1.5px,2.5px) rotate(.5deg)}80%{transform:translate(-1.5px,.5px) rotate(-.5deg)}82%{transform:translate(-1.5px,.5px) rotate(-.5deg)}84%{transform:translate(-.5px,.5px) rotate(1.5deg)}86%{transform:translate(2.5px,1.5px) rotate(.5deg)}88%{transform:translate(-1.5px,.5px) rotate(1.5deg)}90%{transform:translate(-1.5px,-.5px) rotate(-.5deg)}92%{transform:translate(-1.5px,-1.5px) rotate(1.5deg)}94%{transform:translate(.5px,.5px) rotate(-.5deg)}96%{transform:translate(2.5px,-.5px) rotate(-.5deg)}98%{transform:translate(-1.5px,-1.5px) rotate(-.5deg)}0%,to{transform:translate(0) rotate(0)}}.waifu-sr-only{position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%)}#waifu-tool button:focus-visible,#waifu-toggle:focus-visible{outline:2px solid #126381;outline-offset:2px}@media(hover:none){#waifu-tool{opacity:1}#waifu-tool button{min-width:44px;min-height:44px}}@media(prefers-reduced-motion:reduce){#waifu,#waifu-toggle,#waifu-tool,#waifu-tips,#waifu-tips.waifu-tips-active{animation:none;transition:none}}#waifu{right:0}#waifu.waifu-adaptive{right:var(--waifu-right-inset)}#waifu-tool{left:10px}
|
package/docs/en/README.md
CHANGED
|
@@ -6,18 +6,18 @@ Add an interactive Girls’ Frontline character to a website. Visitors can chang
|
|
|
6
6
|
|
|
7
7
|
## Quick start
|
|
8
8
|
|
|
9
|
-
Place one module script before `</body>`. Choose the CDN closest to your audience. Both examples select English and
|
|
9
|
+
Place one module script before `</body>`. Choose the CDN closest to your audience. Both examples select English and follow the latest stable release once the CDN cache refreshes. To pin a release, replace `widget-latest` with `widget-2.4.4`.
|
|
10
10
|
|
|
11
11
|
**Global**
|
|
12
12
|
|
|
13
13
|
```html
|
|
14
|
-
<script type="module" src="https://cdn.jsdelivr.net/gh/nova1751/live2d-api@widget-
|
|
14
|
+
<script type="module" src="https://cdn.jsdelivr.net/gh/nova1751/live2d-api@widget-latest/girls-frontline.mjs?lang=en"></script>
|
|
15
15
|
```
|
|
16
16
|
|
|
17
17
|
**Mainland China**
|
|
18
18
|
|
|
19
19
|
```html
|
|
20
|
-
<script type="module" src="https://cdn.jsdmirror.com/gh/nova1751/live2d-api@widget-
|
|
20
|
+
<script type="module" src="https://cdn.jsdmirror.com/gh/nova1751/live2d-api@widget-latest/girls-frontline.mjs?lang=en"></script>
|
|
21
21
|
```
|
|
22
22
|
|
|
23
23
|
The shortcut displays the widget on viewports at least 768 CSS pixels wide. A first visit starts with the tier-one Airstrike Fairy. Subsequent visits restore the last outfit on that site. Use the module API to set your own display rules.
|
|
@@ -8,7 +8,7 @@ const live2d_path = (() => {
|
|
|
8
8
|
return new URL("../../", url).href;
|
|
9
9
|
}
|
|
10
10
|
}
|
|
11
|
-
return "https://cdn.jsdelivr.net/gh/nova1751/live2d-api@widget-2.4.
|
|
11
|
+
return "https://cdn.jsdelivr.net/gh/nova1751/live2d-api@widget-2.4.5/";
|
|
12
12
|
})();
|
|
13
13
|
function loadExternalResource(url, type) {
|
|
14
14
|
let tag;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/*! Live2D API | Generated from src/ | https://github.com/nova1751/live2d-api */
|
|
2
|
-
"use strict";const live2d_path=(()=>{const e=document.currentScript;if(e?.src){const i=new URL(e.src);if(/\/(?:live2dapi-noa|gh\/nova1751\/live2d-api)(?:@[^/]+)?\/(?:npm|jsdelivr)\/(?:random|sequential)\/autoload(?:\.min)?\.js$/.test(i.pathname))return new URL("../../",i).href}return"https://cdn.jsdelivr.net/gh/nova1751/live2d-api@widget-2.4.
|
|
2
|
+
"use strict";const live2d_path=(()=>{const e=document.currentScript;if(e?.src){const i=new URL(e.src);if(/\/(?:live2dapi-noa|gh\/nova1751\/live2d-api)(?:@[^/]+)?\/(?:npm|jsdelivr)\/(?:random|sequential)\/autoload(?:\.min)?\.js$/.test(i.pathname))return new URL("../../",i).href}return"https://cdn.jsdelivr.net/gh/nova1751/live2d-api@widget-2.4.5/"})();function loadExternalResource(e,i){let n;if(i==="css"){const t=document.createElement("link");t.href=e,t.rel="stylesheet",n=t}else{const t=document.createElement("script");t.src=e,e===live2d_path+"jsdelivr/random/waifu-tips.js"&&(t.dataset.asteroidsUrl=live2d_path+"asteroids.js"),n=t}return new Promise((t,s)=>{n.onload=()=>t(e),n.onerror=()=>s(e),document.head.appendChild(n)})}screen.width>=768&&Promise.all([loadExternalResource(live2d_path+"live2d.min.js","js"),loadExternalResource(live2d_path+"jsdelivr/random/waifu-tips.js","js")]).then(async()=>{document.body||await new Promise(e=>document.addEventListener("DOMContentLoaded",()=>e(),{once:!0})),window.initWidget({tools:["hitokoto","asteroids","switch-model","switch-texture","photo","info","quit"],cdnPath:live2d_path,waifuPath:live2d_path+"waifu-tips.json"})}).catch(e=>console.error("[Live2D]",e));
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*! Live2D API | Generated from src/ | https://github.com/nova1751/live2d-api */
|
|
2
|
-
"use strict";(()=>{var Y="zh-CN";function _(o){Y=o??"zh-CN"}function m(o,e){return Y==="en"?e:o}var G={hitokoto:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--! Font Awesome Free 6.4.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2023 Fonticons, Inc. --><path d="M512 240c0 114.9-114.6 208-256 208c-37.1 0-72.3-6.4-104.1-17.9c-11.9 8.7-31.3 20.6-54.3 30.6C73.6 471.1 44.7 480 16 480c-6.5 0-12.3-3.9-14.8-9.9c-2.5-6-1.1-12.8 3.4-17.4l0 0 0 0 0 0 0 0 .3-.3c.3-.3 .7-.7 1.3-1.4c1.1-1.2 2.8-3.1 4.9-5.7c4.1-5 9.6-12.4 15.2-21.6c10-16.6 19.5-38.4 21.4-62.9C17.7 326.8 0 285.1 0 240C0 125.1 114.6 32 256 32s256 93.1 256 208z"/></svg>',asteroids:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--! Font Awesome Free 6.4.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2023 Fonticons, Inc. --><path d="M498.1 5.6c10.1 7 15.4 19.1 13.5 31.2l-64 416c-1.5 9.7-7.4 18.2-16 23s-18.9 5.4-28 1.6L284 427.7l-68.5 74.1c-8.9 9.7-22.9 12.9-35.2 8.1S160 493.2 160 480V396.4c0-4 1.5-7.8 4.2-10.7L331.8 202.8c5.8-6.3 5.6-16-.4-22s-15.7-6.4-22-.7L106 360.8 17.7 316.6C7.1 311.3 .3 300.7 0 288.9s5.9-22.8 16.1-28.7l448-256c10.7-6.1 23.9-5.5 34 1.4z"/></svg>',"switch-model":'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--! Font Awesome Free 6.4.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2023 Fonticons, Inc. --><path d="M399 384.2C376.9 345.8 335.4 320 288 320H224c-47.4 0-88.9 25.8-111 64.2c35.2 39.2 86.2 63.8 143 63.8s107.8-24.7 143-63.8zM0 256a256 256 0 1 1 512 0A256 256 0 1 1 0 256zm256 16a72 72 0 1 0 0-144 72 72 0 1 0 0 144z"/></svg>',"switch-texture":'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--! Font Awesome Free 6.4.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2023 Fonticons, Inc. --><path d="M320 64A64 64 0 1 0 192 64a64 64 0 1 0 128 0zm-96 96c-35.3 0-64 28.7-64 64v48c0 17.7 14.3 32 32 32h1.8l11.1 99.5c1.8 16.2 15.5 28.5 31.8 28.5h38.7c16.3 0 30-12.3 31.8-28.5L318.2 304H320c17.7 0 32-14.3 32-32V224c0-35.3-28.7-64-64-64H224zM132.3 394.2c13-2.4 21.7-14.9 19.3-27.9s-14.9-21.7-27.9-19.3c-32.4 5.9-60.9 14.2-82 24.8c-10.5 5.3-20.3 11.7-27.8 19.6C6.4 399.5 0 410.5 0 424c0 21.4 15.5 36.1 29.1 45c14.7 9.6 34.3 17.3 56.4 23.4C130.2 504.7 190.4 512 256 512s125.8-7.3 170.4-19.6c22.1-6.1 41.8-13.8 56.4-23.4c13.7-8.9 29.1-23.6 29.1-45c0-13.5-6.4-24.5-14-32.6c-7.5-7.9-17.3-14.3-27.8-19.6c-21-10.6-49.5-18.9-82-24.8c-13-2.4-25.5 6.3-27.9 19.3s6.3 25.5 19.3 27.9c30.2 5.5 53.7 12.8 69 20.5c3.2 1.6 5.8 3.1 7.9 4.5c3.6 2.4 3.6 7.2 0 9.6c-8.8 5.7-23.1 11.8-43 17.3C374.3 457 318.5 464 256 464s-118.3-7-157.7-17.9c-19.9-5.5-34.2-11.6-43-17.3c-3.6-2.4-3.6-7.2 0-9.6c2.1-1.4 4.8-2.9 7.9-4.5c15.3-7.7 38.8-14.9 69-20.5z"/></svg>',photo:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--! Font Awesome Free 6.4.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2023 Fonticons, Inc. --><path d="M220.6 121.2L271.1 96 448 96v96H333.2c-21.9-15.1-48.5-24-77.2-24s-55.2 8.9-77.2 24H64V128H192c9.9 0 19.7-2.3 28.6-6.8zM0 128V416c0 35.3 28.7 64 64 64H448c35.3 0 64-28.7 64-64V96c0-35.3-28.7-64-64-64H271.1c-9.9 0-19.7 2.3-28.6 6.8L192 64H160V48c0-8.8-7.2-16-16-16H80c-8.8 0-16 7.2-16 16l0 16C28.7 64 0 92.7 0 128zM168 304a88 88 0 1 1 176 0 88 88 0 1 1 -176 0z"/></svg>',info:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--! Font Awesome Free 6.4.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2023 Fonticons, Inc. --><path d="M256 512A256 256 0 1 0 256 0a256 256 0 1 0 0 512zM216 336h24V272H216c-13.3 0-24-10.7-24-24s10.7-24 24-24h48c13.3 0 24 10.7 24 24v88h8c13.3 0 24 10.7 24 24s-10.7 24-24 24H216c-13.3 0-24-10.7-24-24s10.7-24 24-24zm40-208a32 32 0 1 1 0 64 32 32 0 1 1 0-64z"/></svg>',quit:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 384 512"><!--! Font Awesome Free 6.4.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2023 Fonticons, Inc. --><path d="M342.6 150.6c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L192 210.7 86.6 105.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3L146.7 256 41.4 361.4c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0L192 301.3 297.4 406.6c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3L237.3 256 342.6 150.6z"/></svg>'};function E(o){return Array.isArray(o)?o[Math.floor(Math.random()*o.length)]:o}function L(o){return o.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}var B,H,k;function P(){clearTimeout(H),sessionStorage.removeItem("waifu-text"),document.getElementById("waifu-tips")?.classList.remove("waifu-tips-active")}function z(o,e){clearTimeout(H),sessionStorage.setItem("waifu-text",String(e));let t=document.getElementById("waifu-tips");t.innerHTML=o,t.classList.add("waifu-tips-active")}function v(o,e,t){!o||k||Number(sessionStorage.getItem("waifu-text"))>t||(z(E(o),t),H=setTimeout(P,e))}function J(o,e){if(!e){v(L(o),5e3,11);return}k=e,z(L(o),11)}function X(o){let e=document.getElementById("live2d");if(!e)return;let t=B?.find(({selector:n})=>e.closest(n)),i=t?E(t.text):B?void 0:m("指挥官,我在。","Right here, Commander.");i&&(k=o,z(i.replace("{text}",()=>L(e.textContent??"")),11))}function K(o,e){k===o&&(k=void 0,e?P():H=setTimeout(P,1200))}function de(o){if(location.pathname==="/"){let s=new Date().getHours();for(let{hour:a,text:r}of o){let[c,d=c]=a.split("-").map(Number);if(c<=s&&s<=d)return r}}let e=L(document.title.split(" - ")[0]),t=m(`欢迎阅读<span>「${e}」</span>`,`Welcome to <span>${e}</span>!`);if(!document.referrer)return t;let{hostname:i}=new URL(document.referrer);return i===location.hostname?t:m(`Hello!来自 <span>${L({baidu:"百度",so:"360搜索",google:"谷歌搜索"}[i.split(".")[1]]??i)}</span> 的朋友<br>${t}`,`Hello, visitor from <span>${L(i)}</span>!<br>${t}`)}function ue(o){let[e,t]=o.split("/").map(Number);return e*100+t}function Q(o){B=o.click;let e=[...o.message.default],t=new Date,i=(t.getMonth()+1)*100+t.getDate();for(let{date:u,text:p}of o.seasons){let[l,h=l]=u.split("-").map(ue);l<=i&&i<=h&&e.push(E(p).replace("{year}",String(t.getFullYear())))}let n=2e4,s=Date.now(),a;function r(){if(document.hidden)return;let u=n-(Date.now()-s);u<=0&&!localStorage.getItem("waifu-display")&&v(e,6e3,9),a=setTimeout(r,u>0?u:n)}let c=()=>{s=Date.now()};window.addEventListener("pointermove",c,{passive:!0}),window.addEventListener("pointerdown",c,{passive:!0}),window.addEventListener("keydown",c),document.hidden||(a=setTimeout(r,n)),v(de(o.time),7e3,11);let d;for(let u of["mouseover","click"])window.addEventListener(u,p=>{let l=p.target;if(!(l instanceof Element)||p.live2dHandlesCaption)return;let h=u==="click"&&l.closest("#waifu .waifu-model-stage"),w=h?document.getElementById("live2d"):l.closest("#live2d"),y=o[u].find(({selector:C})=>l.closest(C)||h&&w?.closest(C));!y||u==="mouseover"&&y.selector===d||(u==="mouseover"&&(d=y.selector),v(E(y.text).replace("{text}",()=>L(l.textContent??"")),4e3,u==="click"&&w?11:8))});let f=()=>{};f.toString=()=>(v(o.message.console,6e3,9),""),console.log("%c",f),window.addEventListener("copy",()=>v(o.message.copy,6e3,9)),document.addEventListener("visibilitychange",()=>{clearTimeout(a),document.hidden||(c(),a=setTimeout(r,n),localStorage.getItem("waifu-display")||v(o.message.visibilitychange,6e3,9))})}async function T(o){let e=await fetch(o);if(!e.ok)throw new Error(`Failed to load ${o} (HTTP ${e.status})`);return e.json()}var Z="/gh/nova1751/live2d-api@cdn-b3ac5ae545e2/",ee="https://cdn.jsdelivr.net",j=ee+Z,me=/\/gh\/nova1751\/live2d-api@widget-[^/]+\/?$/,ge=/\/live2dapi-noa(?:@[^/]+)?\/?$/;function te(o){let e=new URL(o,document.baseURI);return!ge.test(e.pathname)&&!me.test(e.pathname)||/@1\.[^/]+\/?$/.test(e.pathname)?o:(e.hostname==="cdn.jsdmirror.com"?e.origin:ee)+Z}var q=()=>m("我的新衣服好看嘛?","How do you like my new outfit?"),A=o=>Number(localStorage.getItem(o))||0,D=class{constructor(e){this.options=e;this.revision=0;this.loaded=!1;this.useCDN=typeof e.cdnPath=="string";let t=e.modelBaseUrl??(e.cdnPath&&te(e.cdnPath))??e.apiPath;if(typeof t!="string")throw new TypeError("Invalid initWidget argument");this.base=t.endsWith("/")?t:t+"/"}reopen(e){if(this.loaded)window.loadlive2d.show?.(e);else return this.load(void 0,void 0,void 0,e)}cancel(){this.revision++}async fetchCatalog(){let e=this.base+"model_list.json",t=await fetch(e);if(t.status===404&&!this.options.modelBaseUrl&&this.base!==j){let i=await T(j+"model_list.json");return this.base=j,i}if(!t.ok)throw new Error(`Failed to load ${e} (HTTP ${t.status})`);return t.json()}list(){return this.catalog??(this.catalog=this.fetchCatalog().catch(e=>{throw this.catalog=void 0,e}))}async load(e=A("modelId"),t=A("modelTexturesId"),i,n=!1,s=++this.revision,a=!1){let r;if(this.options.modelUrl)r=this.options.modelUrl;else if(this.useCDN){let{models:d}=await this.list();d[e]||(e=0);let f=d[e],u=Array.isArray(f)?f:[f];u[t]||(t=0);let p=a?u[t]:E(u);t=u.indexOf(p),r=this.base+"model/"+p+"/index.json"}else r=this.base+"get/?id="+e+"-"+t;if(s!==this.revision)return;let c=window.loadlive2d("live2d",r,{start:n,locale:this.options.locale,coreUrl:this.options.coreUrl});c&&await c,s===this.revision&&(this.options.modelUrl||(localStorage.setItem("modelId",String(e)),localStorage.setItem("modelTexturesId",String(t))),v(i,4e3,10),this.loaded=!0)}async costume(e){if(this.options.modelUrl||!this.useCDN)return;let t=++this.revision,i=A("modelId"),n=(await this.list()).models[i],a=(Array.isArray(n)?n:[n]).findIndex(r=>new URL(this.base+"model/"+r+"/index.json",document.baseURI).href===e);a>=0&&await this.load(i,a,q(),!1,t,!0)}async nextModel(e=!1){let t=++this.revision,i=A("modelId");if(this.useCDN){let{models:s,messages:a}=await this.list(),r=(i+1)%s.length;return this.load(r,0,m(a[r],"Ready for duty!"),e,t)}let{model:n}=await T(this.base+"switch/?id="+i);return this.load(n.id,0,n.message,e,t)}async nextTexture(e=!1){let t=++this.revision,i=A("modelId"),n=A("modelTexturesId");if(this.useCDN){let a=(await this.list()).models[i],r=Array.isArray(a)?a.length:1;return this.load(i,n,q(),e,t)}let{textures:s}=await T(this.base+"rand_textures/?id="+i+"-"+n);s.id===1&&n===1?v(m("我还没有其他衣服呢!","This is my only outfit so far!"),4e3,10):await this.load(i,s.id,q(),e,t)}};var $=class{constructor(){this.revision=0}begin(e){let t=document.getElementById("waifu"),i=t?.querySelector(".waifu-surface"),n=++this.revision;return t&&(this.still&&!this.still.isConnected&&(i??t).prepend(this.still),t.setAttribute("data-model-loading","")),s=>{if(this.revision!==n||!t)return;let a=document.createElement("canvas");a.className="waifu-model-still",a.setAttribute("aria-hidden","true"),a.width=s.width,a.height=s.height;try{let r=a.getContext("2d");r&&r.drawImage(s,0,0),this.still?.remove(),this.still=r?a:void 0}finally{if(i){let r=e();t.style.setProperty("--waifu-aspect",String(r)),t.toggleAttribute("data-wide-model",r>=1.35)}t.removeAttribute("data-model-loading")}}}};var O={scale:1,x:0,y:0},g=128;function W(o,e,t){let i=0;for(let n=0;n<o.length;n++)if(i+=o[n],i>e*t)return n;return o.length-1}function fe(o,e,t,i){let n=new Float64Array(g),s=g,a=0,r=0;for(let x=0;x<o.length;x++){if(!o[x])continue;let M=Math.floor(x/g);n[x%g]+=o[x],r+=o[x],s=Math.min(s,M),a=Math.max(a,M+1)}if(!r)return O;let c=W(n,r,.001),d=W(n,r,.999)+1,f=d-c,u=a-s,p=i?Math.max(.7,Math.min(1.9,f/u*.93/.94)):1;i?.(p);let l=Math.min(1,p),h=Math.min(1,1/p),w=Math.min(.93*g*h/u,.94*g*l/f,5/e.scale),y=0,C=0;if(t)for(let x=s+2;x<a;x+=4)for(let M=c+2;M<d;M+=4){if(o[x*g+M]<96)continue;t((M+.5)/g,(x+.5)/g).some(le=>/^(head|face|body|bust|torso)\d*$/i.test(le))&&(y+=M+.5,C++)}let F=C>=3?y/C:W(n,r,.5)+.5,b=.475*g*l/w,U=Math.max(d-b,Math.min(c+b,F));return{scale:e.scale*w,x:(.5-U/g)*w,y:.5-.03*h+(.5-a/g)*w}}function oe(o){let e={scale:.65,x:0,y:0},t=document.createElement("canvas");t.width=t.height=g;let i=t.getContext("2d",{willReadFrequently:!0}),n=new Uint8Array(g*g),s=0,a=0,r=0;return{initial:e,measure(c,d){if(!i)return O;let f=performance.now();if(!(f<r)){s++;try{i.clearRect(0,0,g,g),i.drawImage(c,0,0,g,g);let{data:u}=i.getImageData(0,0,g,g),p=0;for(let l=0;l<n.length;l++){let h=u[4*l+3];h<24||(n[l]=Math.max(n[l],h),p++)}p>=16&&(a++,r=f+80)}catch{return O}if(!(a<3&&s<10))return a?fe(n,e,d,o):O}}}}var ne=["fairy","doll","adjutant","npc","squad","background"],ie=["default","normal","destroy"];function N(o,e){let t=o.indexOf(e);return t<0?o.length:t}function he(o,e){let t=new Intl.Collator("en",{numeric:!0}),i=o.map(n=>{let[s,a,r,c]=n.split("/"),d=e[[s,a,r].join("/")],f=r==="base"?-1:d??(s==="fairy"&&/^\d+$/.test(r)?Number(r):Number.MAX_SAFE_INTEGER);return{id:n,category:s,character:a,version:r,form:c,order:f}});return i.sort((n,s)=>N(ne,n.category)-N(ne,s.category)||t.compare(n.category,s.category)||t.compare(n.character,s.character)||n.order-s.order||t.compare(n.version,s.version)||N(ie,n.form)-N(ie,s.form)||t.compare(n.form,s.form)),i.map(n=>n.id)}async function se(o,e,t="zh-CN"){let i=new URL(o,document.baseURI),n=await fetch(i);if(!n.ok)throw new Error("Cannot load catalog: HTTP "+n.status);let s=await n.json();if(s.schemaVersion!==1||!s.models||!s.sources)throw new Error("Unsupported model catalog");let a=new Map,r=Object.keys(s.models).filter(l=>(!e||!l.startsWith("other/"))&&s.models[l].some(h=>h.manifest)),c=e?s.presentation:void 0,d=t==="en"?c?.en:c,f=l=>{let h=c?.aliases[l];return h&&r.includes(h)?h:l},u=e?he(r.filter(l=>f(l)===l),c?.outfitOrder??{}):r;function p(l,h){if(e&&!r.includes(l))throw new Error("Model outside the selected collection: "+l);let w=s.models[l]?.find(b=>b.manifest&&(!h||b.source===h));if(!w?.manifest)throw new Error("No model manifest for "+l);let y=new URL(s.sources[w.source].baseUrl,n.url||i);i.hostname==="cdn.jsdmirror.com"&&y.hostname==="cdn.jsdelivr.net"&&y.pathname.startsWith("/gh/nova1751/live2d-api@cdn-")&&(y.hostname=i.hostname);let C=b=>new URL(b.split("/").map(encodeURIComponent).join("/"),y).href,F;if(w.dialogue){let b=a.get(w.source);b||(b=new Map((s.audio?.[w.source]??[]).map(U=>[U.toUpperCase(),C(U)])),a.set(w.source,b)),F={captions:t==="en"?void 0:d?.captions,url:C(w.dialogue),audio:b}}return{captions:d?.captions,modelUrl:C(w.manifest),dialogue:F,soundAliases:w.soundAliases}}return{ids:u,visibleId:f,labels:d?.labels??{},resolve:p,legacyIds:s.legacyIds}}var R=class{constructor(e,t){this.url=e;this.options=t;this.sequence=0;this.transition=new $;let i=t.collection?":"+t.collection:"",n="live2d:model:"+e+i,s=a=>a.replace(/(\/gh\/nova1751\/live2d-api)@catalog-[a-f0-9]{16}(\/catalog\/library\.json:girls-frontline)$/,"$1$2");if(this.key=s(n),this.key!==n&&!localStorage.getItem(this.key)){let a=[n,...Object.keys(localStorage)].find(r=>s(r)===this.key&&localStorage.getItem(r));a&&localStorage.setItem(this.key,localStorage.getItem(a))}}open(){return this.library??(this.library=se(this.url,this.options.collection,this.options.locale).catch(e=>{throw this.library=void 0,e}))}async select(e,t){let i=++this.sequence,n=await this.open();if(i!==this.sequence)return;let s=e(n.ids,n.legacyIds,n.visibleId),{modelUrl:a,dialogue:r,soundAliases:c,captions:d}=n.resolve(s),f=1,u=this.options.collection==="girls-frontline"&&!s.startsWith("background/")?oe(l=>{f=l}):void 0,p=this.options.collection?this.transition.begin(()=>f):void 0;await window.loadlive2d("live2d",a,{start:t,locale:this.options.locale,captions:d,framing:u,onPaint:p,coreUrl:this.options.coreUrl,dialogue:r,soundAliases:c}),i===this.sequence&&(this.active=n.visibleId(s),localStorage.setItem(this.key,s),window.dispatchEvent(new CustomEvent("live2d:model",{detail:s})))}load(e,t,i,n=!1){return this.select((s,a,r)=>{let c=localStorage.getItem(this.key);if(this.options.collection)return this.options.modelId??(c&&s.includes(r(c))?c:s[0]);let d=a?.[Number(localStorage.getItem("modelId"))]?.[Number(localStorage.getItem("modelTexturesId"))];return this.options.modelId??(c&&s.includes(r(c))?c:d&&s.includes(d)?d:s[0])},n)}choose(e){return this.select(()=>e,!1)}cancel(){this.sequence++}reopen(e){if(this.active)window.loadlive2d.show?.(e);else return this.load(void 0,void 0,void 0,e)}character(e){return e.split("/").slice(0,2).join("/")}nextModel(e=!1){return this.select(t=>{let i=[...new Set(t.map(s=>this.character(s)))],n=i[(i.indexOf(this.character(this.active??""))+1)%i.length];return t.find(s=>this.character(s)===n)},e)}nextTexture(e=!1){return this.select(t=>{let i=t.filter(n=>this.character(n)===this.character(this.active??t[0]));{let n=i.filter(s=>s!==this.active);return n.length?n[Math.floor(Math.random()*n.length)]:i[0]}return i[(i.indexOf(this.active??"")+1)%i.length]},e)}async costume(e){let t=await this.open(),i=t.ids.find(n=>t.resolve(n).modelUrl===e);i&&await this.select(()=>i,!1)}};var pe=document.currentScript,we=pe?.dataset.asteroidsUrl??"https://cdn.jsdelivr.net/gh/nova1751/live2d-api@widget-2.4.3/asteroids.js",I=o=>document.getElementById(o);function S(o){console.error("[Live2D]",o);let e=document.getElementById("waifu-status");e&&(e.textContent=m("加载失败,请检查网络或切换模型后重试。","Could not load the model. Check your connection or try another character."),v(e.textContent,5e3,10))}async function ve(o){if(o==="en"){v(["One step at a time, Commander.","Even on a quiet day, there is something worth noticing."],6e3,9);return}let e=await T("https://v1.hitokoto.cn");v(L(e.hitokoto),6e3,9),setTimeout(()=>{v(`这句一言来自 <span>「${L(String(e.from))}」</span>,是 <span>${L(String(e.creator))}</span> 在 hitokoto.cn 投稿的。`,4e3,9)},6e3)}function ye(){if(window.Asteroids)(window.ASTEROIDSPLAYERS??(window.ASTEROIDSPLAYERS=[])).push(new window.Asteroids);else{let o=document.createElement("script");o.src=we,document.head.appendChild(o)}}var ae;function ce(){clearTimeout(ae),localStorage.removeItem("waifu-display"),I("waifu-toggle").setAttribute("tabindex","-1"),I("waifu-toggle").setAttribute("aria-expanded","true"),I("waifu").style.display="",setTimeout(()=>{I("waifu").style.bottom="0"},0)}function V(o){return o.isTrusted&&!!window.loadlive2d.prepareInteraction?.()}function be(){let o=I("waifu").contains(document.activeElement);window.loadlive2d.hide?.(),localStorage.setItem("waifu-display",String(Date.now())),v(m("愿你有一天能与重要的人重逢。","I hope you meet the people you miss again."),2e3,11),I("waifu").style.bottom="-500px",ae=setTimeout(()=>{I("waifu").style.display="none";let e=I("waifu-toggle");e.removeAttribute("tabindex"),e.setAttribute("aria-expanded","false"),e.classList.add("waifu-toggle-active"),o&&e.focus()},window.matchMedia("(prefers-reduced-motion: reduce)").matches?0:3e3)}function re(o,e,t=!1){sessionStorage.removeItem("waifu-text");let i=o.collection==="girls-frontline",n='<canvas id="live2d" width="800" height="800"></canvas>';document.body.insertAdjacentHTML("beforeend",`<div id="waifu" lang="${o.locale==="en"?"en":"zh-CN"}"${i?' class="waifu-adaptive"':""}>
|
|
2
|
+
"use strict";(()=>{var Y="zh-CN";function _(o){Y=o??"zh-CN"}function g(o,e){return Y==="en"?e:o}var G={hitokoto:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--! Font Awesome Free 6.4.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2023 Fonticons, Inc. --><path d="M512 240c0 114.9-114.6 208-256 208c-37.1 0-72.3-6.4-104.1-17.9c-11.9 8.7-31.3 20.6-54.3 30.6C73.6 471.1 44.7 480 16 480c-6.5 0-12.3-3.9-14.8-9.9c-2.5-6-1.1-12.8 3.4-17.4l0 0 0 0 0 0 0 0 .3-.3c.3-.3 .7-.7 1.3-1.4c1.1-1.2 2.8-3.1 4.9-5.7c4.1-5 9.6-12.4 15.2-21.6c10-16.6 19.5-38.4 21.4-62.9C17.7 326.8 0 285.1 0 240C0 125.1 114.6 32 256 32s256 93.1 256 208z"/></svg>',asteroids:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--! Font Awesome Free 6.4.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2023 Fonticons, Inc. --><path d="M498.1 5.6c10.1 7 15.4 19.1 13.5 31.2l-64 416c-1.5 9.7-7.4 18.2-16 23s-18.9 5.4-28 1.6L284 427.7l-68.5 74.1c-8.9 9.7-22.9 12.9-35.2 8.1S160 493.2 160 480V396.4c0-4 1.5-7.8 4.2-10.7L331.8 202.8c5.8-6.3 5.6-16-.4-22s-15.7-6.4-22-.7L106 360.8 17.7 316.6C7.1 311.3 .3 300.7 0 288.9s5.9-22.8 16.1-28.7l448-256c10.7-6.1 23.9-5.5 34 1.4z"/></svg>',"switch-model":'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--! Font Awesome Free 6.4.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2023 Fonticons, Inc. --><path d="M399 384.2C376.9 345.8 335.4 320 288 320H224c-47.4 0-88.9 25.8-111 64.2c35.2 39.2 86.2 63.8 143 63.8s107.8-24.7 143-63.8zM0 256a256 256 0 1 1 512 0A256 256 0 1 1 0 256zm256 16a72 72 0 1 0 0-144 72 72 0 1 0 0 144z"/></svg>',"switch-texture":'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--! Font Awesome Free 6.4.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2023 Fonticons, Inc. --><path d="M320 64A64 64 0 1 0 192 64a64 64 0 1 0 128 0zm-96 96c-35.3 0-64 28.7-64 64v48c0 17.7 14.3 32 32 32h1.8l11.1 99.5c1.8 16.2 15.5 28.5 31.8 28.5h38.7c16.3 0 30-12.3 31.8-28.5L318.2 304H320c17.7 0 32-14.3 32-32V224c0-35.3-28.7-64-64-64H224zM132.3 394.2c13-2.4 21.7-14.9 19.3-27.9s-14.9-21.7-27.9-19.3c-32.4 5.9-60.9 14.2-82 24.8c-10.5 5.3-20.3 11.7-27.8 19.6C6.4 399.5 0 410.5 0 424c0 21.4 15.5 36.1 29.1 45c14.7 9.6 34.3 17.3 56.4 23.4C130.2 504.7 190.4 512 256 512s125.8-7.3 170.4-19.6c22.1-6.1 41.8-13.8 56.4-23.4c13.7-8.9 29.1-23.6 29.1-45c0-13.5-6.4-24.5-14-32.6c-7.5-7.9-17.3-14.3-27.8-19.6c-21-10.6-49.5-18.9-82-24.8c-13-2.4-25.5 6.3-27.9 19.3s6.3 25.5 19.3 27.9c30.2 5.5 53.7 12.8 69 20.5c3.2 1.6 5.8 3.1 7.9 4.5c3.6 2.4 3.6 7.2 0 9.6c-8.8 5.7-23.1 11.8-43 17.3C374.3 457 318.5 464 256 464s-118.3-7-157.7-17.9c-19.9-5.5-34.2-11.6-43-17.3c-3.6-2.4-3.6-7.2 0-9.6c2.1-1.4 4.8-2.9 7.9-4.5c15.3-7.7 38.8-14.9 69-20.5z"/></svg>',photo:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--! Font Awesome Free 6.4.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2023 Fonticons, Inc. --><path d="M220.6 121.2L271.1 96 448 96v96H333.2c-21.9-15.1-48.5-24-77.2-24s-55.2 8.9-77.2 24H64V128H192c9.9 0 19.7-2.3 28.6-6.8zM0 128V416c0 35.3 28.7 64 64 64H448c35.3 0 64-28.7 64-64V96c0-35.3-28.7-64-64-64H271.1c-9.9 0-19.7 2.3-28.6 6.8L192 64H160V48c0-8.8-7.2-16-16-16H80c-8.8 0-16 7.2-16 16l0 16C28.7 64 0 92.7 0 128zM168 304a88 88 0 1 1 176 0 88 88 0 1 1 -176 0z"/></svg>',info:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--! Font Awesome Free 6.4.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2023 Fonticons, Inc. --><path d="M256 512A256 256 0 1 0 256 0a256 256 0 1 0 0 512zM216 336h24V272H216c-13.3 0-24-10.7-24-24s10.7-24 24-24h48c13.3 0 24 10.7 24 24v88h8c13.3 0 24 10.7 24 24s-10.7 24-24 24H216c-13.3 0-24-10.7-24-24s10.7-24 24-24zm40-208a32 32 0 1 1 0 64 32 32 0 1 1 0-64z"/></svg>',quit:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 384 512"><!--! Font Awesome Free 6.4.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2023 Fonticons, Inc. --><path d="M342.6 150.6c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L192 210.7 86.6 105.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3L146.7 256 41.4 361.4c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0L192 301.3 297.4 406.6c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3L237.3 256 342.6 150.6z"/></svg>'};function E(o){return Array.isArray(o)?o[Math.floor(Math.random()*o.length)]:o}function L(o){return o.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}var P,H,U;function z(){clearTimeout(H),sessionStorage.removeItem("waifu-text"),document.getElementById("waifu-tips")?.classList.remove("waifu-tips-active")}function q(o,e){clearTimeout(H),sessionStorage.setItem("waifu-text",String(e));let t=document.getElementById("waifu-tips");t.innerHTML=o,t.classList.add("waifu-tips-active")}function w(o,e,t){!o||U||Number(sessionStorage.getItem("waifu-text"))>t||(q(E(o),t),H=setTimeout(z,e))}function J(o,e){if(!e){w(L(o),5e3,11);return}U=e,q(L(o),11)}function X(o){let e=document.getElementById("live2d");if(!e)return;let t=P?.find(({selector:n})=>e.closest(n)),i=t?E(t.text):P?void 0:g("指挥官,我在。","Right here, Commander.");i&&(U=o,q(i.replace("{text}",()=>L(e.textContent??"")),11))}function K(o,e){U===o&&(U=void 0,e?z():H=setTimeout(z,1200))}function ue(o){if(location.pathname==="/"){let s=new Date().getHours();for(let{hour:a,text:r}of o){let[c,d=c]=a.split("-").map(Number);if(c<=s&&s<=d)return r}}let e=L(document.title.split(" - ")[0]),t=g(`欢迎阅读<span>「${e}」</span>`,`Welcome to <span>${e}</span>!`);if(!document.referrer)return t;let{hostname:i}=new URL(document.referrer);return i===location.hostname?t:g(`Hello!来自 <span>${L({baidu:"百度",so:"360搜索",google:"谷歌搜索"}[i.split(".")[1]]??i)}</span> 的朋友<br>${t}`,`Hello, visitor from <span>${L(i)}</span>!<br>${t}`)}function me(o){let[e,t]=o.split("/").map(Number);return e*100+t}function Q(o){P=o.click;let e=[...o.message.default],t=new Date,i=(t.getMonth()+1)*100+t.getDate();for(let{date:u,text:v}of o.seasons){let[l,m=l]=u.split("-").map(me);l<=i&&i<=m&&e.push(E(v).replace("{year}",String(t.getFullYear())))}let n=2e4,s=Date.now(),a;function r(){if(document.hidden)return;let u=n-(Date.now()-s);u<=0&&!localStorage.getItem("waifu-display")&&w(e,6e3,9),a=setTimeout(r,u>0?u:n)}let c=()=>{s=Date.now()};window.addEventListener("pointermove",c,{passive:!0}),window.addEventListener("pointerdown",c,{passive:!0}),window.addEventListener("keydown",c),document.hidden||(a=setTimeout(r,n)),w(ue(o.time),7e3,11);let d;for(let u of["mouseover","click"])window.addEventListener(u,v=>{let l=v.target;if(!(l instanceof Element)||v.live2dHandlesCaption)return;let m=u==="click"&&l.closest("#waifu .waifu-model-stage"),p=m?document.getElementById("live2d"):l.closest("#live2d"),y=o[u].find(({selector:C})=>l.closest(C)||m&&p?.closest(C));!y||u==="mouseover"&&y.selector===d||(u==="mouseover"&&(d=y.selector),w(E(y.text).replace("{text}",()=>L(l.textContent??"")),4e3,u==="click"&&p?11:8))});let h=()=>{};h.toString=()=>(w(o.message.console,6e3,9),""),console.log("%c",h),window.addEventListener("copy",()=>w(o.message.copy,6e3,9)),document.addEventListener("visibilitychange",()=>{clearTimeout(a),document.hidden||(c(),a=setTimeout(r,n),localStorage.getItem("waifu-display")||w(o.message.visibilitychange,6e3,9))})}async function T(o){let e=await fetch(o);if(!e.ok)throw new Error(`Failed to load ${o} (HTTP ${e.status})`);return e.json()}var Z="/gh/nova1751/live2d-api@cdn-b3ac5ae545e2/",ee="https://cdn.jsdelivr.net",j=ee+Z,fe=/\/gh\/nova1751\/live2d-api@widget-[^/]+\/?$/,ge=/\/live2dapi-noa(?:@[^/]+)?\/?$/;function te(o){let e=new URL(o,document.baseURI);return!ge.test(e.pathname)&&!fe.test(e.pathname)||/@1\.[^/]+\/?$/.test(e.pathname)?o:(e.hostname==="cdn.jsdmirror.com"?e.origin:ee)+Z}var W=()=>g("我的新衣服好看嘛?","How do you like my new outfit?"),k=o=>Number(localStorage.getItem(o))||0,D=class{constructor(e){this.options=e;this.revision=0;this.loaded=!1;this.useCDN=typeof e.cdnPath=="string";let t=e.modelBaseUrl??(e.cdnPath&&te(e.cdnPath))??e.apiPath;if(typeof t!="string")throw new TypeError("Invalid initWidget argument");this.base=t.endsWith("/")?t:t+"/"}reopen(e){if(this.loaded)window.loadlive2d.show?.(e);else return this.load(void 0,void 0,void 0,e)}cancel(){this.revision++}async fetchCatalog(){let e=this.base+"model_list.json",t=await fetch(e);if(t.status===404&&!this.options.modelBaseUrl&&this.base!==j){let i=await T(j+"model_list.json");return this.base=j,i}if(!t.ok)throw new Error(`Failed to load ${e} (HTTP ${t.status})`);return t.json()}list(){return this.catalog??(this.catalog=this.fetchCatalog().catch(e=>{throw this.catalog=void 0,e}))}async load(e=k("modelId"),t=k("modelTexturesId"),i,n=!1,s=++this.revision,a=!1){let r;if(this.options.modelUrl)r=this.options.modelUrl;else if(this.useCDN){let{models:d}=await this.list();d[e]||(e=0);let h=d[e],u=Array.isArray(h)?h:[h];u[t]||(t=0);let v=a?u[t]:E(u);t=u.indexOf(v),r=this.base+"model/"+v+"/index.json"}else r=this.base+"get/?id="+e+"-"+t;if(s!==this.revision)return;let c=window.loadlive2d("live2d",r,{start:n,locale:this.options.locale,coreUrl:this.options.coreUrl});c&&await c,s===this.revision&&(this.options.modelUrl||(localStorage.setItem("modelId",String(e)),localStorage.setItem("modelTexturesId",String(t))),w(i,4e3,10),this.loaded=!0)}async costume(e){if(this.options.modelUrl||!this.useCDN)return;let t=++this.revision,i=k("modelId"),n=(await this.list()).models[i],a=(Array.isArray(n)?n:[n]).findIndex(r=>new URL(this.base+"model/"+r+"/index.json",document.baseURI).href===e);a>=0&&await this.load(i,a,W(),!1,t,!0)}async nextModel(e=!1){let t=++this.revision,i=k("modelId");if(this.useCDN){let{models:s,messages:a}=await this.list(),r=(i+1)%s.length;return this.load(r,0,g(a[r],"Ready for duty!"),e,t)}let{model:n}=await T(this.base+"switch/?id="+i);return this.load(n.id,0,n.message,e,t)}async nextTexture(e=!1){let t=++this.revision,i=k("modelId"),n=k("modelTexturesId");if(this.useCDN){let a=(await this.list()).models[i],r=Array.isArray(a)?a.length:1;return this.load(i,n,W(),e,t)}let{textures:s}=await T(this.base+"rand_textures/?id="+i+"-"+n);s.id===1&&n===1?w(g("我还没有其他衣服呢!","This is my only outfit so far!"),4e3,10):await this.load(i,s.id,W(),e,t)}};var $=class{constructor(){this.revision=0}begin(e){let t=document.getElementById("waifu"),i=t?.querySelector(".waifu-surface"),n=++this.revision;return t&&(this.still&&!this.still.isConnected&&(i??t).prepend(this.still),t.setAttribute("data-model-loading","")),s=>{if(this.revision!==n||!t)return;let a=document.createElement("canvas");a.className="waifu-model-still",a.setAttribute("aria-hidden","true"),a.width=s.width,a.height=s.height;try{let r=a.getContext("2d");r&&r.drawImage(s,0,0),this.still?.remove(),this.still=r?a:void 0}finally{if(i){let r=e();t.style.setProperty("--waifu-aspect",String(r)),t.toggleAttribute("data-wide-model",r>=1.35)}t.removeAttribute("data-model-loading"),t.hasAttribute("data-initial-framing")&&(t.removeAttribute("data-initial-framing"),document.activeElement?.matches("#waifu-toggle:focus-visible")&&t.querySelector("#waifu-tool button")?.focus({preventScroll:!0}))}}}};var B={scale:1,x:0,y:0},f=128;function O(o,e,t){let i=0;for(let n=0;n<o.length;n++)if(i+=o[n],i>e*t)return n;return o.length-1}function he(o,e,t,i){let n=new Float64Array(f),s=new Float64Array(f),a=f,r=0,c=0;for(let b=0;b<o.length;b++){if(!o[b])continue;let M=Math.floor(b/f);n[b%f]+=o[b],s[M]+=o[b],c+=o[b],a=Math.min(a,M),r=Math.max(r,M+1)}if(!c)return B;a=Math.max(a,O(s,c,.001)-2);let d=O(n,c,.001),h=O(n,c,.999)+1,u=h-d,v=r-a,l=i?Math.max(.7,Math.min(1.9,u/v*.93/.94)):1;i?.(l);let m=Math.min(1,l),p=Math.min(1,1/l),y=Math.min(.93*f*p/v,.94*f*m/u,5/e.scale),C=0,A=0;if(t)for(let b=a+2;b<r;b+=4)for(let M=d+2;M<h;M+=4){if(o[b*f+M]<96)continue;t((M+.5)/f,(b+.5)/f).some(de=>/^(head|face|body|bust|torso)\d*$/i.test(de))&&(C+=M+.5,A++)}let x=A>=3?C/A:O(n,c,.5)+.5,R=.475*f*m/y,le=Math.max(h-R,Math.min(d+R,x));return{scale:e.scale*y,x:(.5-le/f)*y,y:.5-.03*p+(.5-r/f)*y}}function oe(o){let e={scale:.65,x:0,y:0},t=document.createElement("canvas");t.width=t.height=f;let i=t.getContext("2d",{willReadFrequently:!0}),n=new Uint8Array(f*f),s=new Uint8Array(n.length),a=0,r=0,c=0;return{initial:e,measure(d,h){if(!i)return B;let u=performance.now();if(!(u<c)){a++;try{i.clearRect(0,0,f,f),i.drawImage(d,0,0,f,f);let{data:v}=i.getImageData(0,0,f,f),l=0;for(let m=0;m<n.length;m++){let p=v[4*m+3];s[m]=p>=24?p:0,s[m]&&l++}l>=16&&(n.set(s),r++,c=u+80)}catch{return B}if(!(r<3&&a<10))return r?he(n,e,h,o):B}}}}var ne=["fairy","doll","adjutant","npc","squad","background"],ie=["default","normal","destroy"];function N(o,e){let t=o.indexOf(e);return t<0?o.length:t}function pe(o,e){let t=new Intl.Collator("en",{numeric:!0}),i=o.map(n=>{let[s,a,r,c]=n.split("/"),d=e[[s,a,r].join("/")],h=r==="base"?-1:d??(s==="fairy"&&/^\d+$/.test(r)?Number(r):Number.MAX_SAFE_INTEGER);return{id:n,category:s,character:a,version:r,form:c,order:h}});return i.sort((n,s)=>N(ne,n.category)-N(ne,s.category)||t.compare(n.category,s.category)||t.compare(n.character,s.character)||n.order-s.order||t.compare(n.version,s.version)||N(ie,n.form)-N(ie,s.form)||t.compare(n.form,s.form)),i.map(n=>n.id)}async function se(o,e,t="zh-CN"){let i=new URL(o,document.baseURI),n=await fetch(i);if(!n.ok)throw new Error("Cannot load catalog: HTTP "+n.status);let s=await n.json();if(s.schemaVersion!==1||!s.models||!s.sources)throw new Error("Unsupported model catalog");let a=new Map,r=Object.keys(s.models).filter(l=>(!e||!l.startsWith("other/"))&&s.models[l].some(m=>m.manifest)),c=e?s.presentation:void 0,d=t==="en"?c?.en:c,h=l=>{let m=c?.aliases[l];return m&&r.includes(m)?m:l},u=e?pe(r.filter(l=>h(l)===l),c?.outfitOrder??{}):r;function v(l,m){if(e&&!r.includes(l))throw new Error("Model outside the selected collection: "+l);let p=s.models[l]?.find(x=>x.manifest&&(!m||x.source===m));if(!p?.manifest)throw new Error("No model manifest for "+l);let y=new URL(s.sources[p.source].baseUrl,n.url||i);i.hostname==="cdn.jsdmirror.com"&&y.hostname==="cdn.jsdelivr.net"&&y.pathname.startsWith("/gh/nova1751/live2d-api@cdn-")&&(y.hostname=i.hostname);let C=x=>new URL(x.split("/").map(encodeURIComponent).join("/"),y).href,A;if(p.dialogue){let x=a.get(p.source);x||(x=new Map((s.audio?.[p.source]??[]).map(R=>[R.toUpperCase(),C(R)])),a.set(p.source,x)),A={captions:t==="en"?void 0:d?.captions,url:C(p.dialogue),audio:x}}return{captions:d?.captions,modelUrl:C(p.manifest),dialogue:A,soundAliases:p.soundAliases}}return{ids:u,visibleId:h,labels:d?.labels??{},resolve:v,legacyIds:s.legacyIds}}var F=class{constructor(e,t){this.url=e;this.options=t;this.sequence=0;this.transition=new $;let i=t.collection?":"+t.collection:"",n="live2d:model:"+e+i,s=a=>a.replace(/(\/gh\/nova1751\/live2d-api)@catalog-[a-f0-9]{16}(\/catalog\/library\.json:girls-frontline)$/,"$1$2");if(this.key=s(n),this.key!==n&&!localStorage.getItem(this.key)){let a=[n,...Object.keys(localStorage)].find(r=>s(r)===this.key&&localStorage.getItem(r));a&&localStorage.setItem(this.key,localStorage.getItem(a))}}open(){return this.library??(this.library=se(this.url,this.options.collection,this.options.locale).catch(e=>{throw this.library=void 0,e}))}async select(e,t){let i=++this.sequence;try{let n=await this.open();if(i!==this.sequence)return;let s=e(n.ids,n.legacyIds,n.visibleId),{modelUrl:a,dialogue:r,soundAliases:c,captions:d}=n.resolve(s),h=1,u=this.options.collection==="girls-frontline"&&!s.startsWith("background/")?oe(l=>{h=l}):void 0,v=this.options.collection?this.transition.begin(()=>h):void 0;await window.loadlive2d("live2d",a,{start:t,locale:this.options.locale,captions:d,framing:u,onPaint:v,coreUrl:this.options.coreUrl,dialogue:r,soundAliases:c}),i===this.sequence&&(this.active=n.visibleId(s),localStorage.setItem(this.key,s),window.dispatchEvent(new CustomEvent("live2d:model",{detail:s})))}catch(n){throw i===this.sequence&&document.getElementById("waifu")?.removeAttribute("data-initial-framing"),n}}load(e,t,i,n=!1){return this.select((s,a,r)=>{let c=localStorage.getItem(this.key);if(this.options.collection)return this.options.modelId??(c&&s.includes(r(c))?c:s[0]);let d=a?.[Number(localStorage.getItem("modelId"))]?.[Number(localStorage.getItem("modelTexturesId"))];return this.options.modelId??(c&&s.includes(r(c))?c:d&&s.includes(d)?d:s[0])},n)}choose(e){return this.select(()=>e,!1)}cancel(){this.sequence++}reopen(e){if(this.active)window.loadlive2d.show?.(e);else return this.load(void 0,void 0,void 0,e)}character(e){return e.split("/").slice(0,2).join("/")}nextModel(e=!1){return this.select(t=>{let i=[...new Set(t.map(s=>this.character(s)))],n=i[(i.indexOf(this.character(this.active??""))+1)%i.length];return t.find(s=>this.character(s)===n)},e)}nextTexture(e=!1){return this.select(t=>{let i=t.filter(n=>this.character(n)===this.character(this.active??t[0]));{let n=i.filter(s=>s!==this.active);return n.length?n[Math.floor(Math.random()*n.length)]:i[0]}return i[(i.indexOf(this.active??"")+1)%i.length]},e)}async costume(e){let t=await this.open(),i=t.ids.find(n=>t.resolve(n).modelUrl===e);i&&await this.select(()=>i,!1)}};var we=document.currentScript,ve=we?.dataset.asteroidsUrl??"https://cdn.jsdelivr.net/gh/nova1751/live2d-api@widget-2.4.5/asteroids.js",I=o=>document.getElementById(o);function S(o){console.error("[Live2D]",o);let e=document.getElementById("waifu-status");e&&(e.textContent=g("加载失败,请检查网络或切换模型后重试。","Could not load the model. Check your connection or try another character."),w(e.textContent,5e3,10))}async function ye(o){if(o==="en"){w(["One step at a time, Commander.","Even on a quiet day, there is something worth noticing."],6e3,9);return}let e=await T("https://v1.hitokoto.cn");w(L(e.hitokoto),6e3,9),setTimeout(()=>{w(`这句一言来自 <span>「${L(String(e.from))}」</span>,是 <span>${L(String(e.creator))}</span> 在 hitokoto.cn 投稿的。`,4e3,9)},6e3)}function be(){if(window.Asteroids)(window.ASTEROIDSPLAYERS??(window.ASTEROIDSPLAYERS=[])).push(new window.Asteroids);else{let o=document.createElement("script");o.src=ve,document.head.appendChild(o)}}var ae;function ce(){clearTimeout(ae),localStorage.removeItem("waifu-display"),I("waifu-toggle").setAttribute("tabindex","-1"),I("waifu-toggle").setAttribute("aria-expanded","true"),I("waifu").style.display="";let o=I("waifu");o.hasAttribute("data-initial-framing")?o.style.bottom="0":setTimeout(()=>{o.style.bottom="0"},0)}function V(o){return o.isTrusted&&!!window.loadlive2d.prepareInteraction?.()}function xe(){let o=I("waifu").contains(document.activeElement);window.loadlive2d.hide?.(),localStorage.setItem("waifu-display",String(Date.now())),w(g("愿你有一天能与重要的人重逢。","I hope you meet the people you miss again."),2e3,11),I("waifu").style.bottom="-500px",ae=setTimeout(()=>{I("waifu").style.display="none";let e=I("waifu-toggle");e.removeAttribute("tabindex"),e.setAttribute("aria-expanded","false"),e.classList.add("waifu-toggle-active"),o&&e.focus()},window.matchMedia("(prefers-reduced-motion: reduce)").matches?0:3e3)}function re(o,e,t=!1){sessionStorage.removeItem("waifu-text");let i=o.collection==="girls-frontline",n='<canvas id="live2d" width="800" height="800"></canvas>';document.body.insertAdjacentHTML("beforeend",`<div id="waifu" lang="${o.locale==="en"?"en":"zh-CN"}"${i?' class="waifu-adaptive"':""}${i&&e instanceof F?" data-initial-framing":""}>
|
|
3
3
|
<div id="waifu-status" role="status" class="waifu-sr-only"></div>
|
|
4
4
|
<div id="waifu-tips"></div>
|
|
5
5
|
${i?`<div class="waifu-viewport"><div class="waifu-surface">${n}</div></div>`:n}
|
|
6
6
|
<div id="waifu-tool"></div>
|
|
7
|
-
</div>`),ce(),window.addEventListener("live2d:dialogue",r=>{let{detail:c,playback:d}=r;typeof c=="string"&&J(c,d)}),window.addEventListener("live2d:preset",r=>{let{playback:c}=r;c&&X(c)}),window.addEventListener("live2d:dialogue-end",r=>{let c=r.detail;c?.playback&&K(c.playback,c.interrupted)}),window.addEventListener("live2d:costume",r=>{let c=r.detail;typeof c=="string"&&e.costume(c).catch(S)});let s={hitokoto:
|
|
7
|
+
</div>`),ce(),window.addEventListener("live2d:dialogue",r=>{let{detail:c,playback:d}=r;typeof c=="string"&&J(c,d)}),window.addEventListener("live2d:preset",r=>{let{playback:c}=r;c&&X(c)}),window.addEventListener("live2d:dialogue-end",r=>{let c=r.detail;c?.playback&&K(c.playback,c.interrupted)}),window.addEventListener("live2d:costume",r=>{let c=r.detail;typeof c=="string"&&e.costume(c).catch(S)});let s={hitokoto:g("听一句话","Hear a quote"),asteroids:g("启动小游戏","Play Asteroids"),"switch-model":g("切换人物","Next character"),"switch-texture":g("切换造型","Next outfit"),photo:g("保存照片","Save a picture"),info:g("项目信息","Project information"),quit:g("收起看板娘","Hide companion")},a={hitokoto:()=>ye(o.locale).catch(S),asteroids:be,"switch-model":r=>e.nextModel(V(r)).catch(S),"switch-texture":r=>e.nextTexture(V(r)).catch(S),photo:()=>{w(g("照好了嘛,是不是很可爱呢?","Did you get my good side?"),6e3,9),!(window.loadlive2d.capture?.()||!window.Live2D)&&(window.Live2D.captureName="photo.png",window.Live2D.captureFrame=!0)},info:()=>window.open("https://github.com/nova1751/live2d-api"),quit:()=>{e.cancel(),xe()}};for(let r of Array.isArray(o.tools)?o.tools:Object.keys(a)){if(o.modelUrl&&(r==="switch-model"||r==="switch-texture")||!Object.prototype.hasOwnProperty.call(a,r))continue;let c=r;I("waifu-tool").insertAdjacentHTML("beforeend",`<button type="button" id="waifu-tool-${c}" aria-label="${s[c]}" title="${s[c]}">${G[c]}</button>`),I("waifu-tool-"+c).addEventListener("click",a[c])}e.load(void 0,void 0,void 0,t).catch(S),T(o.waifuPath).then(Q).catch(S)}window.initWidget=(o,e)=>{let t=typeof o=="string"?{waifuPath:o,apiPath:e}:o;if(document.getElementById("waifu-toggle"))return;_(t.locale),document.body.insertAdjacentHTML("beforeend",`<button type="button" id="waifu-toggle" aria-label="${g("打开看板娘","Show companion")}" aria-controls="waifu"><span>${g("看板娘","Companion")}</span></button>`);let i=I("waifu-toggle");i.setAttribute("aria-expanded","false");let n=t.catalogUrl?new F(t.catalogUrl,t):new D(t);n instanceof F&&Object.defineProperty(window,Symbol.for("live2dapi-noa.selectModel"),{configurable:!0,value:async a=>((i.getAttribute("aria-expanded")==="false"||localStorage.getItem("waifu-display"))&&i.click(),n.choose(a))}),i.addEventListener("click",a=>{let r=V(a);i.classList.remove("waifu-toggle-active"),i.hasAttribute("first-time")?(re(t,n,r),i.removeAttribute("first-time")):(ce(),n.reopen(r)?.catch(S)),a.detail===0&&document.querySelector("#waifu-tool button")?.focus()});let s=Number(localStorage.getItem("waifu-display"));s&&Date.now()-s<=864e5?(i.setAttribute("first-time","true"),setTimeout(()=>i.classList.add("waifu-toggle-active"),0)):re(t,n)};})();
|
|
@@ -8,7 +8,7 @@ const live2d_path = (() => {
|
|
|
8
8
|
return new URL("../../", url).href;
|
|
9
9
|
}
|
|
10
10
|
}
|
|
11
|
-
return "https://cdn.jsdelivr.net/gh/nova1751/live2d-api@widget-2.4.
|
|
11
|
+
return "https://cdn.jsdelivr.net/gh/nova1751/live2d-api@widget-2.4.5/";
|
|
12
12
|
})();
|
|
13
13
|
function loadExternalResource(url, type) {
|
|
14
14
|
let tag;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/*! Live2D API | Generated from src/ | https://github.com/nova1751/live2d-api */
|
|
2
|
-
"use strict";const live2d_path=(()=>{const e=document.currentScript;if(e?.src){const i=new URL(e.src);if(/\/(?:live2dapi-noa|gh\/nova1751\/live2d-api)(?:@[^/]+)?\/(?:npm|jsdelivr)\/(?:random|sequential)\/autoload(?:\.min)?\.js$/.test(i.pathname))return new URL("../../",i).href}return"https://cdn.jsdelivr.net/gh/nova1751/live2d-api@widget-2.4.
|
|
2
|
+
"use strict";const live2d_path=(()=>{const e=document.currentScript;if(e?.src){const i=new URL(e.src);if(/\/(?:live2dapi-noa|gh\/nova1751\/live2d-api)(?:@[^/]+)?\/(?:npm|jsdelivr)\/(?:random|sequential)\/autoload(?:\.min)?\.js$/.test(i.pathname))return new URL("../../",i).href}return"https://cdn.jsdelivr.net/gh/nova1751/live2d-api@widget-2.4.5/"})();function loadExternalResource(e,i){let n;if(i==="css"){const t=document.createElement("link");t.href=e,t.rel="stylesheet",n=t}else{const t=document.createElement("script");t.src=e,e===live2d_path+"jsdelivr/sequential/waifu-tips.js"&&(t.dataset.asteroidsUrl=live2d_path+"asteroids.js"),n=t}return new Promise((t,s)=>{n.onload=()=>t(e),n.onerror=()=>s(e),document.head.appendChild(n)})}screen.width>=768&&Promise.all([loadExternalResource(live2d_path+"live2d.min.js","js"),loadExternalResource(live2d_path+"jsdelivr/sequential/waifu-tips.js","js")]).then(async()=>{document.body||await new Promise(e=>document.addEventListener("DOMContentLoaded",()=>e(),{once:!0})),window.initWidget({tools:["hitokoto","asteroids","switch-model","switch-texture","photo","info","quit"],cdnPath:live2d_path,waifuPath:live2d_path+"waifu-tips.json"})}).catch(e=>console.error("[Live2D]",e));
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*! Live2D API | Generated from src/ | https://github.com/nova1751/live2d-api */
|
|
2
|
-
"use strict";(()=>{var Y="zh-CN";function _(o){Y=o??"zh-CN"}function m(o,e){return Y==="en"?e:o}var G={hitokoto:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--! Font Awesome Free 6.4.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2023 Fonticons, Inc. --><path d="M512 240c0 114.9-114.6 208-256 208c-37.1 0-72.3-6.4-104.1-17.9c-11.9 8.7-31.3 20.6-54.3 30.6C73.6 471.1 44.7 480 16 480c-6.5 0-12.3-3.9-14.8-9.9c-2.5-6-1.1-12.8 3.4-17.4l0 0 0 0 0 0 0 0 .3-.3c.3-.3 .7-.7 1.3-1.4c1.1-1.2 2.8-3.1 4.9-5.7c4.1-5 9.6-12.4 15.2-21.6c10-16.6 19.5-38.4 21.4-62.9C17.7 326.8 0 285.1 0 240C0 125.1 114.6 32 256 32s256 93.1 256 208z"/></svg>',asteroids:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--! Font Awesome Free 6.4.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2023 Fonticons, Inc. --><path d="M498.1 5.6c10.1 7 15.4 19.1 13.5 31.2l-64 416c-1.5 9.7-7.4 18.2-16 23s-18.9 5.4-28 1.6L284 427.7l-68.5 74.1c-8.9 9.7-22.9 12.9-35.2 8.1S160 493.2 160 480V396.4c0-4 1.5-7.8 4.2-10.7L331.8 202.8c5.8-6.3 5.6-16-.4-22s-15.7-6.4-22-.7L106 360.8 17.7 316.6C7.1 311.3 .3 300.7 0 288.9s5.9-22.8 16.1-28.7l448-256c10.7-6.1 23.9-5.5 34 1.4z"/></svg>',"switch-model":'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--! Font Awesome Free 6.4.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2023 Fonticons, Inc. --><path d="M399 384.2C376.9 345.8 335.4 320 288 320H224c-47.4 0-88.9 25.8-111 64.2c35.2 39.2 86.2 63.8 143 63.8s107.8-24.7 143-63.8zM0 256a256 256 0 1 1 512 0A256 256 0 1 1 0 256zm256 16a72 72 0 1 0 0-144 72 72 0 1 0 0 144z"/></svg>',"switch-texture":'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--! Font Awesome Free 6.4.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2023 Fonticons, Inc. --><path d="M320 64A64 64 0 1 0 192 64a64 64 0 1 0 128 0zm-96 96c-35.3 0-64 28.7-64 64v48c0 17.7 14.3 32 32 32h1.8l11.1 99.5c1.8 16.2 15.5 28.5 31.8 28.5h38.7c16.3 0 30-12.3 31.8-28.5L318.2 304H320c17.7 0 32-14.3 32-32V224c0-35.3-28.7-64-64-64H224zM132.3 394.2c13-2.4 21.7-14.9 19.3-27.9s-14.9-21.7-27.9-19.3c-32.4 5.9-60.9 14.2-82 24.8c-10.5 5.3-20.3 11.7-27.8 19.6C6.4 399.5 0 410.5 0 424c0 21.4 15.5 36.1 29.1 45c14.7 9.6 34.3 17.3 56.4 23.4C130.2 504.7 190.4 512 256 512s125.8-7.3 170.4-19.6c22.1-6.1 41.8-13.8 56.4-23.4c13.7-8.9 29.1-23.6 29.1-45c0-13.5-6.4-24.5-14-32.6c-7.5-7.9-17.3-14.3-27.8-19.6c-21-10.6-49.5-18.9-82-24.8c-13-2.4-25.5 6.3-27.9 19.3s6.3 25.5 19.3 27.9c30.2 5.5 53.7 12.8 69 20.5c3.2 1.6 5.8 3.1 7.9 4.5c3.6 2.4 3.6 7.2 0 9.6c-8.8 5.7-23.1 11.8-43 17.3C374.3 457 318.5 464 256 464s-118.3-7-157.7-17.9c-19.9-5.5-34.2-11.6-43-17.3c-3.6-2.4-3.6-7.2 0-9.6c2.1-1.4 4.8-2.9 7.9-4.5c15.3-7.7 38.8-14.9 69-20.5z"/></svg>',photo:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--! Font Awesome Free 6.4.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2023 Fonticons, Inc. --><path d="M220.6 121.2L271.1 96 448 96v96H333.2c-21.9-15.1-48.5-24-77.2-24s-55.2 8.9-77.2 24H64V128H192c9.9 0 19.7-2.3 28.6-6.8zM0 128V416c0 35.3 28.7 64 64 64H448c35.3 0 64-28.7 64-64V96c0-35.3-28.7-64-64-64H271.1c-9.9 0-19.7 2.3-28.6 6.8L192 64H160V48c0-8.8-7.2-16-16-16H80c-8.8 0-16 7.2-16 16l0 16C28.7 64 0 92.7 0 128zM168 304a88 88 0 1 1 176 0 88 88 0 1 1 -176 0z"/></svg>',info:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--! Font Awesome Free 6.4.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2023 Fonticons, Inc. --><path d="M256 512A256 256 0 1 0 256 0a256 256 0 1 0 0 512zM216 336h24V272H216c-13.3 0-24-10.7-24-24s10.7-24 24-24h48c13.3 0 24 10.7 24 24v88h8c13.3 0 24 10.7 24 24s-10.7 24-24 24H216c-13.3 0-24-10.7-24-24s10.7-24 24-24zm40-208a32 32 0 1 1 0 64 32 32 0 1 1 0-64z"/></svg>',quit:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 384 512"><!--! Font Awesome Free 6.4.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2023 Fonticons, Inc. --><path d="M342.6 150.6c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L192 210.7 86.6 105.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3L146.7 256 41.4 361.4c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0L192 301.3 297.4 406.6c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3L237.3 256 342.6 150.6z"/></svg>'};function U(o){return Array.isArray(o)?o[Math.floor(Math.random()*o.length)]:o}function L(o){return o.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}var B,H,E;function P(){clearTimeout(H),sessionStorage.removeItem("waifu-text"),document.getElementById("waifu-tips")?.classList.remove("waifu-tips-active")}function z(o,e){clearTimeout(H),sessionStorage.setItem("waifu-text",String(e));let t=document.getElementById("waifu-tips");t.innerHTML=o,t.classList.add("waifu-tips-active")}function v(o,e,t){!o||E||Number(sessionStorage.getItem("waifu-text"))>t||(z(U(o),t),H=setTimeout(P,e))}function J(o,e){if(!e){v(L(o),5e3,11);return}E=e,z(L(o),11)}function X(o){let e=document.getElementById("live2d");if(!e)return;let t=B?.find(({selector:n})=>e.closest(n)),i=t?U(t.text):B?void 0:m("指挥官,我在。","Right here, Commander.");i&&(E=o,z(i.replace("{text}",()=>L(e.textContent??"")),11))}function K(o,e){E===o&&(E=void 0,e?P():H=setTimeout(P,1200))}function de(o){if(location.pathname==="/"){let s=new Date().getHours();for(let{hour:a,text:r}of o){let[c,d=c]=a.split("-").map(Number);if(c<=s&&s<=d)return r}}let e=L(document.title.split(" - ")[0]),t=m(`欢迎阅读<span>「${e}」</span>`,`Welcome to <span>${e}</span>!`);if(!document.referrer)return t;let{hostname:i}=new URL(document.referrer);return i===location.hostname?t:m(`Hello!来自 <span>${L({baidu:"百度",so:"360搜索",google:"谷歌搜索"}[i.split(".")[1]]??i)}</span> 的朋友<br>${t}`,`Hello, visitor from <span>${L(i)}</span>!<br>${t}`)}function ue(o){let[e,t]=o.split("/").map(Number);return e*100+t}function Q(o){B=o.click;let e=[...o.message.default],t=new Date,i=(t.getMonth()+1)*100+t.getDate();for(let{date:u,text:p}of o.seasons){let[l,h=l]=u.split("-").map(ue);l<=i&&i<=h&&e.push(U(p).replace("{year}",String(t.getFullYear())))}let n=2e4,s=Date.now(),a;function r(){if(document.hidden)return;let u=n-(Date.now()-s);u<=0&&!localStorage.getItem("waifu-display")&&v(e,6e3,9),a=setTimeout(r,u>0?u:n)}let c=()=>{s=Date.now()};window.addEventListener("pointermove",c,{passive:!0}),window.addEventListener("pointerdown",c,{passive:!0}),window.addEventListener("keydown",c),document.hidden||(a=setTimeout(r,n)),v(de(o.time),7e3,11);let d;for(let u of["mouseover","click"])window.addEventListener(u,p=>{let l=p.target;if(!(l instanceof Element)||p.live2dHandlesCaption)return;let h=u==="click"&&l.closest("#waifu .waifu-model-stage"),w=h?document.getElementById("live2d"):l.closest("#live2d"),y=o[u].find(({selector:C})=>l.closest(C)||h&&w?.closest(C));!y||u==="mouseover"&&y.selector===d||(u==="mouseover"&&(d=y.selector),v(U(y.text).replace("{text}",()=>L(l.textContent??"")),4e3,u==="click"&&w?11:8))});let f=()=>{};f.toString=()=>(v(o.message.console,6e3,9),""),console.log("%c",f),window.addEventListener("copy",()=>v(o.message.copy,6e3,9)),document.addEventListener("visibilitychange",()=>{clearTimeout(a),document.hidden||(c(),a=setTimeout(r,n),localStorage.getItem("waifu-display")||v(o.message.visibilitychange,6e3,9))})}async function T(o){let e=await fetch(o);if(!e.ok)throw new Error(`Failed to load ${o} (HTTP ${e.status})`);return e.json()}var Z="/gh/nova1751/live2d-api@cdn-b3ac5ae545e2/",ee="https://cdn.jsdelivr.net",j=ee+Z,me=/\/gh\/nova1751\/live2d-api@widget-[^/]+\/?$/,ge=/\/live2dapi-noa(?:@[^/]+)?\/?$/;function te(o){let e=new URL(o,document.baseURI);return!ge.test(e.pathname)&&!me.test(e.pathname)||/@1\.[^/]+\/?$/.test(e.pathname)?o:(e.hostname==="cdn.jsdmirror.com"?e.origin:ee)+Z}var q=()=>m("我的新衣服好看嘛?","How do you like my new outfit?"),k=o=>Number(localStorage.getItem(o))||0,D=class{constructor(e){this.options=e;this.revision=0;this.loaded=!1;this.useCDN=typeof e.cdnPath=="string";let t=e.modelBaseUrl??(e.cdnPath&&te(e.cdnPath))??e.apiPath;if(typeof t!="string")throw new TypeError("Invalid initWidget argument");this.base=t.endsWith("/")?t:t+"/"}reopen(e){if(this.loaded)window.loadlive2d.show?.(e);else return this.load(void 0,void 0,void 0,e)}cancel(){this.revision++}async fetchCatalog(){let e=this.base+"model_list.json",t=await fetch(e);if(t.status===404&&!this.options.modelBaseUrl&&this.base!==j){let i=await T(j+"model_list.json");return this.base=j,i}if(!t.ok)throw new Error(`Failed to load ${e} (HTTP ${t.status})`);return t.json()}list(){return this.catalog??(this.catalog=this.fetchCatalog().catch(e=>{throw this.catalog=void 0,e}))}async load(e=k("modelId"),t=k("modelTexturesId"),i,n=!1,s=++this.revision,a=!1){let r;if(this.options.modelUrl)r=this.options.modelUrl;else if(this.useCDN){let{models:d}=await this.list();d[e]||(e=0);let f=d[e],u=Array.isArray(f)?f:[f];u[t]||(t=0);let p=u[t];t=u.indexOf(p),r=this.base+"model/"+p+"/index.json"}else r=this.base+"get/?id="+e+"-"+t;if(s!==this.revision)return;let c=window.loadlive2d("live2d",r,{start:n,locale:this.options.locale,coreUrl:this.options.coreUrl});c&&await c,s===this.revision&&(this.options.modelUrl||(localStorage.setItem("modelId",String(e)),localStorage.setItem("modelTexturesId",String(t))),v(i,4e3,10),this.loaded=!0)}async costume(e){if(this.options.modelUrl||!this.useCDN)return;let t=++this.revision,i=k("modelId"),n=(await this.list()).models[i],a=(Array.isArray(n)?n:[n]).findIndex(r=>new URL(this.base+"model/"+r+"/index.json",document.baseURI).href===e);a>=0&&await this.load(i,a,q(),!1,t,!0)}async nextModel(e=!1){let t=++this.revision,i=k("modelId");if(this.useCDN){let{models:s,messages:a}=await this.list(),r=(i+1)%s.length;return this.load(r,0,m(a[r],"Ready for duty!"),e,t)}let{model:n}=await T(this.base+"switch/?id="+i);return this.load(n.id,0,n.message,e,t)}async nextTexture(e=!1){let t=++this.revision,i=k("modelId"),n=k("modelTexturesId");if(this.useCDN){let a=(await this.list()).models[i],r=Array.isArray(a)?a.length:1;return this.load(i,(n+1)%r,q(),e,t)}let{textures:s}=await T(this.base+"rand_textures/?id="+i+"-"+n);s.id===1&&n===1?v(m("我还没有其他衣服呢!","This is my only outfit so far!"),4e3,10):await this.load(i,s.id,q(),e,t)}};var $=class{constructor(){this.revision=0}begin(e){let t=document.getElementById("waifu"),i=t?.querySelector(".waifu-surface"),n=++this.revision;return t&&(this.still&&!this.still.isConnected&&(i??t).prepend(this.still),t.setAttribute("data-model-loading","")),s=>{if(this.revision!==n||!t)return;let a=document.createElement("canvas");a.className="waifu-model-still",a.setAttribute("aria-hidden","true"),a.width=s.width,a.height=s.height;try{let r=a.getContext("2d");r&&r.drawImage(s,0,0),this.still?.remove(),this.still=r?a:void 0}finally{if(i){let r=e();t.style.setProperty("--waifu-aspect",String(r)),t.toggleAttribute("data-wide-model",r>=1.35)}t.removeAttribute("data-model-loading")}}}};var O={scale:1,x:0,y:0},g=128;function W(o,e,t){let i=0;for(let n=0;n<o.length;n++)if(i+=o[n],i>e*t)return n;return o.length-1}function fe(o,e,t,i){let n=new Float64Array(g),s=g,a=0,r=0;for(let x=0;x<o.length;x++){if(!o[x])continue;let M=Math.floor(x/g);n[x%g]+=o[x],r+=o[x],s=Math.min(s,M),a=Math.max(a,M+1)}if(!r)return O;let c=W(n,r,.001),d=W(n,r,.999)+1,f=d-c,u=a-s,p=i?Math.max(.7,Math.min(1.9,f/u*.93/.94)):1;i?.(p);let l=Math.min(1,p),h=Math.min(1,1/p),w=Math.min(.93*g*h/u,.94*g*l/f,5/e.scale),y=0,C=0;if(t)for(let x=s+2;x<a;x+=4)for(let M=c+2;M<d;M+=4){if(o[x*g+M]<96)continue;t((M+.5)/g,(x+.5)/g).some(le=>/^(head|face|body|bust|torso)\d*$/i.test(le))&&(y+=M+.5,C++)}let R=C>=3?y/C:W(n,r,.5)+.5,b=.475*g*l/w,F=Math.max(d-b,Math.min(c+b,R));return{scale:e.scale*w,x:(.5-F/g)*w,y:.5-.03*h+(.5-a/g)*w}}function oe(o){let e={scale:.65,x:0,y:0},t=document.createElement("canvas");t.width=t.height=g;let i=t.getContext("2d",{willReadFrequently:!0}),n=new Uint8Array(g*g),s=0,a=0,r=0;return{initial:e,measure(c,d){if(!i)return O;let f=performance.now();if(!(f<r)){s++;try{i.clearRect(0,0,g,g),i.drawImage(c,0,0,g,g);let{data:u}=i.getImageData(0,0,g,g),p=0;for(let l=0;l<n.length;l++){let h=u[4*l+3];h<24||(n[l]=Math.max(n[l],h),p++)}p>=16&&(a++,r=f+80)}catch{return O}if(!(a<3&&s<10))return a?fe(n,e,d,o):O}}}}var ne=["fairy","doll","adjutant","npc","squad","background"],ie=["default","normal","destroy"];function N(o,e){let t=o.indexOf(e);return t<0?o.length:t}function he(o,e){let t=new Intl.Collator("en",{numeric:!0}),i=o.map(n=>{let[s,a,r,c]=n.split("/"),d=e[[s,a,r].join("/")],f=r==="base"?-1:d??(s==="fairy"&&/^\d+$/.test(r)?Number(r):Number.MAX_SAFE_INTEGER);return{id:n,category:s,character:a,version:r,form:c,order:f}});return i.sort((n,s)=>N(ne,n.category)-N(ne,s.category)||t.compare(n.category,s.category)||t.compare(n.character,s.character)||n.order-s.order||t.compare(n.version,s.version)||N(ie,n.form)-N(ie,s.form)||t.compare(n.form,s.form)),i.map(n=>n.id)}async function se(o,e,t="zh-CN"){let i=new URL(o,document.baseURI),n=await fetch(i);if(!n.ok)throw new Error("Cannot load catalog: HTTP "+n.status);let s=await n.json();if(s.schemaVersion!==1||!s.models||!s.sources)throw new Error("Unsupported model catalog");let a=new Map,r=Object.keys(s.models).filter(l=>(!e||!l.startsWith("other/"))&&s.models[l].some(h=>h.manifest)),c=e?s.presentation:void 0,d=t==="en"?c?.en:c,f=l=>{let h=c?.aliases[l];return h&&r.includes(h)?h:l},u=e?he(r.filter(l=>f(l)===l),c?.outfitOrder??{}):r;function p(l,h){if(e&&!r.includes(l))throw new Error("Model outside the selected collection: "+l);let w=s.models[l]?.find(b=>b.manifest&&(!h||b.source===h));if(!w?.manifest)throw new Error("No model manifest for "+l);let y=new URL(s.sources[w.source].baseUrl,n.url||i);i.hostname==="cdn.jsdmirror.com"&&y.hostname==="cdn.jsdelivr.net"&&y.pathname.startsWith("/gh/nova1751/live2d-api@cdn-")&&(y.hostname=i.hostname);let C=b=>new URL(b.split("/").map(encodeURIComponent).join("/"),y).href,R;if(w.dialogue){let b=a.get(w.source);b||(b=new Map((s.audio?.[w.source]??[]).map(F=>[F.toUpperCase(),C(F)])),a.set(w.source,b)),R={captions:t==="en"?void 0:d?.captions,url:C(w.dialogue),audio:b}}return{captions:d?.captions,modelUrl:C(w.manifest),dialogue:R,soundAliases:w.soundAliases}}return{ids:u,visibleId:f,labels:d?.labels??{},resolve:p,legacyIds:s.legacyIds}}var A=class{constructor(e,t){this.url=e;this.options=t;this.sequence=0;this.transition=new $;let i=t.collection?":"+t.collection:"",n="live2d:model:"+e+i,s=a=>a.replace(/(\/gh\/nova1751\/live2d-api)@catalog-[a-f0-9]{16}(\/catalog\/library\.json:girls-frontline)$/,"$1$2");if(this.key=s(n),this.key!==n&&!localStorage.getItem(this.key)){let a=[n,...Object.keys(localStorage)].find(r=>s(r)===this.key&&localStorage.getItem(r));a&&localStorage.setItem(this.key,localStorage.getItem(a))}}open(){return this.library??(this.library=se(this.url,this.options.collection,this.options.locale).catch(e=>{throw this.library=void 0,e}))}async select(e,t){let i=++this.sequence,n=await this.open();if(i!==this.sequence)return;let s=e(n.ids,n.legacyIds,n.visibleId),{modelUrl:a,dialogue:r,soundAliases:c,captions:d}=n.resolve(s),f=1,u=this.options.collection==="girls-frontline"&&!s.startsWith("background/")?oe(l=>{f=l}):void 0,p=this.options.collection?this.transition.begin(()=>f):void 0;await window.loadlive2d("live2d",a,{start:t,locale:this.options.locale,captions:d,framing:u,onPaint:p,coreUrl:this.options.coreUrl,dialogue:r,soundAliases:c}),i===this.sequence&&(this.active=n.visibleId(s),localStorage.setItem(this.key,s),window.dispatchEvent(new CustomEvent("live2d:model",{detail:s})))}load(e,t,i,n=!1){return this.select((s,a,r)=>{let c=localStorage.getItem(this.key);if(this.options.collection)return this.options.modelId??(c&&s.includes(r(c))?c:s[0]);let d=a?.[Number(localStorage.getItem("modelId"))]?.[Number(localStorage.getItem("modelTexturesId"))];return this.options.modelId??(c&&s.includes(r(c))?c:d&&s.includes(d)?d:s[0])},n)}choose(e){return this.select(()=>e,!1)}cancel(){this.sequence++}reopen(e){if(this.active)window.loadlive2d.show?.(e);else return this.load(void 0,void 0,void 0,e)}character(e){return e.split("/").slice(0,2).join("/")}nextModel(e=!1){return this.select(t=>{let i=[...new Set(t.map(s=>this.character(s)))],n=i[(i.indexOf(this.character(this.active??""))+1)%i.length];return t.find(s=>this.character(s)===n)},e)}nextTexture(e=!1){return this.select(t=>{let i=t.filter(n=>this.character(n)===this.character(this.active??t[0]));return i[(i.indexOf(this.active??"")+1)%i.length]},e)}async costume(e){let t=await this.open(),i=t.ids.find(n=>t.resolve(n).modelUrl===e);i&&await this.select(()=>i,!1)}};var pe=document.currentScript,we=pe?.dataset.asteroidsUrl??"https://cdn.jsdelivr.net/gh/nova1751/live2d-api@widget-2.4.3/asteroids.js",I=o=>document.getElementById(o);function S(o){console.error("[Live2D]",o);let e=document.getElementById("waifu-status");e&&(e.textContent=m("加载失败,请检查网络或切换模型后重试。","Could not load the model. Check your connection or try another character."),v(e.textContent,5e3,10))}async function ve(o){if(o==="en"){v(["One step at a time, Commander.","Even on a quiet day, there is something worth noticing."],6e3,9);return}let e=await T("https://v1.hitokoto.cn");v(L(e.hitokoto),6e3,9),setTimeout(()=>{v(`这句一言来自 <span>「${L(String(e.from))}」</span>,是 <span>${L(String(e.creator))}</span> 在 hitokoto.cn 投稿的。`,4e3,9)},6e3)}function ye(){if(window.Asteroids)(window.ASTEROIDSPLAYERS??(window.ASTEROIDSPLAYERS=[])).push(new window.Asteroids);else{let o=document.createElement("script");o.src=we,document.head.appendChild(o)}}var ae;function ce(){clearTimeout(ae),localStorage.removeItem("waifu-display"),I("waifu-toggle").setAttribute("tabindex","-1"),I("waifu-toggle").setAttribute("aria-expanded","true"),I("waifu").style.display="",setTimeout(()=>{I("waifu").style.bottom="0"},0)}function V(o){return o.isTrusted&&!!window.loadlive2d.prepareInteraction?.()}function be(){let o=I("waifu").contains(document.activeElement);window.loadlive2d.hide?.(),localStorage.setItem("waifu-display",String(Date.now())),v(m("愿你有一天能与重要的人重逢。","I hope you meet the people you miss again."),2e3,11),I("waifu").style.bottom="-500px",ae=setTimeout(()=>{I("waifu").style.display="none";let e=I("waifu-toggle");e.removeAttribute("tabindex"),e.setAttribute("aria-expanded","false"),e.classList.add("waifu-toggle-active"),o&&e.focus()},window.matchMedia("(prefers-reduced-motion: reduce)").matches?0:3e3)}function re(o,e,t=!1){sessionStorage.removeItem("waifu-text");let i=o.collection==="girls-frontline",n='<canvas id="live2d" width="800" height="800"></canvas>';document.body.insertAdjacentHTML("beforeend",`<div id="waifu" lang="${o.locale==="en"?"en":"zh-CN"}"${i?' class="waifu-adaptive"':""}>
|
|
2
|
+
"use strict";(()=>{var Y="zh-CN";function _(o){Y=o??"zh-CN"}function g(o,e){return Y==="en"?e:o}var G={hitokoto:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--! Font Awesome Free 6.4.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2023 Fonticons, Inc. --><path d="M512 240c0 114.9-114.6 208-256 208c-37.1 0-72.3-6.4-104.1-17.9c-11.9 8.7-31.3 20.6-54.3 30.6C73.6 471.1 44.7 480 16 480c-6.5 0-12.3-3.9-14.8-9.9c-2.5-6-1.1-12.8 3.4-17.4l0 0 0 0 0 0 0 0 .3-.3c.3-.3 .7-.7 1.3-1.4c1.1-1.2 2.8-3.1 4.9-5.7c4.1-5 9.6-12.4 15.2-21.6c10-16.6 19.5-38.4 21.4-62.9C17.7 326.8 0 285.1 0 240C0 125.1 114.6 32 256 32s256 93.1 256 208z"/></svg>',asteroids:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--! Font Awesome Free 6.4.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2023 Fonticons, Inc. --><path d="M498.1 5.6c10.1 7 15.4 19.1 13.5 31.2l-64 416c-1.5 9.7-7.4 18.2-16 23s-18.9 5.4-28 1.6L284 427.7l-68.5 74.1c-8.9 9.7-22.9 12.9-35.2 8.1S160 493.2 160 480V396.4c0-4 1.5-7.8 4.2-10.7L331.8 202.8c5.8-6.3 5.6-16-.4-22s-15.7-6.4-22-.7L106 360.8 17.7 316.6C7.1 311.3 .3 300.7 0 288.9s5.9-22.8 16.1-28.7l448-256c10.7-6.1 23.9-5.5 34 1.4z"/></svg>',"switch-model":'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--! Font Awesome Free 6.4.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2023 Fonticons, Inc. --><path d="M399 384.2C376.9 345.8 335.4 320 288 320H224c-47.4 0-88.9 25.8-111 64.2c35.2 39.2 86.2 63.8 143 63.8s107.8-24.7 143-63.8zM0 256a256 256 0 1 1 512 0A256 256 0 1 1 0 256zm256 16a72 72 0 1 0 0-144 72 72 0 1 0 0 144z"/></svg>',"switch-texture":'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--! Font Awesome Free 6.4.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2023 Fonticons, Inc. --><path d="M320 64A64 64 0 1 0 192 64a64 64 0 1 0 128 0zm-96 96c-35.3 0-64 28.7-64 64v48c0 17.7 14.3 32 32 32h1.8l11.1 99.5c1.8 16.2 15.5 28.5 31.8 28.5h38.7c16.3 0 30-12.3 31.8-28.5L318.2 304H320c17.7 0 32-14.3 32-32V224c0-35.3-28.7-64-64-64H224zM132.3 394.2c13-2.4 21.7-14.9 19.3-27.9s-14.9-21.7-27.9-19.3c-32.4 5.9-60.9 14.2-82 24.8c-10.5 5.3-20.3 11.7-27.8 19.6C6.4 399.5 0 410.5 0 424c0 21.4 15.5 36.1 29.1 45c14.7 9.6 34.3 17.3 56.4 23.4C130.2 504.7 190.4 512 256 512s125.8-7.3 170.4-19.6c22.1-6.1 41.8-13.8 56.4-23.4c13.7-8.9 29.1-23.6 29.1-45c0-13.5-6.4-24.5-14-32.6c-7.5-7.9-17.3-14.3-27.8-19.6c-21-10.6-49.5-18.9-82-24.8c-13-2.4-25.5 6.3-27.9 19.3s6.3 25.5 19.3 27.9c30.2 5.5 53.7 12.8 69 20.5c3.2 1.6 5.8 3.1 7.9 4.5c3.6 2.4 3.6 7.2 0 9.6c-8.8 5.7-23.1 11.8-43 17.3C374.3 457 318.5 464 256 464s-118.3-7-157.7-17.9c-19.9-5.5-34.2-11.6-43-17.3c-3.6-2.4-3.6-7.2 0-9.6c2.1-1.4 4.8-2.9 7.9-4.5c15.3-7.7 38.8-14.9 69-20.5z"/></svg>',photo:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--! Font Awesome Free 6.4.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2023 Fonticons, Inc. --><path d="M220.6 121.2L271.1 96 448 96v96H333.2c-21.9-15.1-48.5-24-77.2-24s-55.2 8.9-77.2 24H64V128H192c9.9 0 19.7-2.3 28.6-6.8zM0 128V416c0 35.3 28.7 64 64 64H448c35.3 0 64-28.7 64-64V96c0-35.3-28.7-64-64-64H271.1c-9.9 0-19.7 2.3-28.6 6.8L192 64H160V48c0-8.8-7.2-16-16-16H80c-8.8 0-16 7.2-16 16l0 16C28.7 64 0 92.7 0 128zM168 304a88 88 0 1 1 176 0 88 88 0 1 1 -176 0z"/></svg>',info:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--! Font Awesome Free 6.4.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2023 Fonticons, Inc. --><path d="M256 512A256 256 0 1 0 256 0a256 256 0 1 0 0 512zM216 336h24V272H216c-13.3 0-24-10.7-24-24s10.7-24 24-24h48c13.3 0 24 10.7 24 24v88h8c13.3 0 24 10.7 24 24s-10.7 24-24 24H216c-13.3 0-24-10.7-24-24s10.7-24 24-24zm40-208a32 32 0 1 1 0 64 32 32 0 1 1 0-64z"/></svg>',quit:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 384 512"><!--! Font Awesome Free 6.4.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2023 Fonticons, Inc. --><path d="M342.6 150.6c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L192 210.7 86.6 105.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3L146.7 256 41.4 361.4c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0L192 301.3 297.4 406.6c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3L237.3 256 342.6 150.6z"/></svg>'};function U(o){return Array.isArray(o)?o[Math.floor(Math.random()*o.length)]:o}function L(o){return o.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}var P,H,R;function z(){clearTimeout(H),sessionStorage.removeItem("waifu-text"),document.getElementById("waifu-tips")?.classList.remove("waifu-tips-active")}function q(o,e){clearTimeout(H),sessionStorage.setItem("waifu-text",String(e));let t=document.getElementById("waifu-tips");t.innerHTML=o,t.classList.add("waifu-tips-active")}function w(o,e,t){!o||R||Number(sessionStorage.getItem("waifu-text"))>t||(q(U(o),t),H=setTimeout(z,e))}function J(o,e){if(!e){w(L(o),5e3,11);return}R=e,q(L(o),11)}function X(o){let e=document.getElementById("live2d");if(!e)return;let t=P?.find(({selector:n})=>e.closest(n)),i=t?U(t.text):P?void 0:g("指挥官,我在。","Right here, Commander.");i&&(R=o,q(i.replace("{text}",()=>L(e.textContent??"")),11))}function K(o,e){R===o&&(R=void 0,e?z():H=setTimeout(z,1200))}function ue(o){if(location.pathname==="/"){let s=new Date().getHours();for(let{hour:a,text:r}of o){let[c,d=c]=a.split("-").map(Number);if(c<=s&&s<=d)return r}}let e=L(document.title.split(" - ")[0]),t=g(`欢迎阅读<span>「${e}」</span>`,`Welcome to <span>${e}</span>!`);if(!document.referrer)return t;let{hostname:i}=new URL(document.referrer);return i===location.hostname?t:g(`Hello!来自 <span>${L({baidu:"百度",so:"360搜索",google:"谷歌搜索"}[i.split(".")[1]]??i)}</span> 的朋友<br>${t}`,`Hello, visitor from <span>${L(i)}</span>!<br>${t}`)}function me(o){let[e,t]=o.split("/").map(Number);return e*100+t}function Q(o){P=o.click;let e=[...o.message.default],t=new Date,i=(t.getMonth()+1)*100+t.getDate();for(let{date:u,text:v}of o.seasons){let[l,m=l]=u.split("-").map(me);l<=i&&i<=m&&e.push(U(v).replace("{year}",String(t.getFullYear())))}let n=2e4,s=Date.now(),a;function r(){if(document.hidden)return;let u=n-(Date.now()-s);u<=0&&!localStorage.getItem("waifu-display")&&w(e,6e3,9),a=setTimeout(r,u>0?u:n)}let c=()=>{s=Date.now()};window.addEventListener("pointermove",c,{passive:!0}),window.addEventListener("pointerdown",c,{passive:!0}),window.addEventListener("keydown",c),document.hidden||(a=setTimeout(r,n)),w(ue(o.time),7e3,11);let d;for(let u of["mouseover","click"])window.addEventListener(u,v=>{let l=v.target;if(!(l instanceof Element)||v.live2dHandlesCaption)return;let m=u==="click"&&l.closest("#waifu .waifu-model-stage"),p=m?document.getElementById("live2d"):l.closest("#live2d"),y=o[u].find(({selector:C})=>l.closest(C)||m&&p?.closest(C));!y||u==="mouseover"&&y.selector===d||(u==="mouseover"&&(d=y.selector),w(U(y.text).replace("{text}",()=>L(l.textContent??"")),4e3,u==="click"&&p?11:8))});let h=()=>{};h.toString=()=>(w(o.message.console,6e3,9),""),console.log("%c",h),window.addEventListener("copy",()=>w(o.message.copy,6e3,9)),document.addEventListener("visibilitychange",()=>{clearTimeout(a),document.hidden||(c(),a=setTimeout(r,n),localStorage.getItem("waifu-display")||w(o.message.visibilitychange,6e3,9))})}async function T(o){let e=await fetch(o);if(!e.ok)throw new Error(`Failed to load ${o} (HTTP ${e.status})`);return e.json()}var Z="/gh/nova1751/live2d-api@cdn-b3ac5ae545e2/",ee="https://cdn.jsdelivr.net",j=ee+Z,fe=/\/gh\/nova1751\/live2d-api@widget-[^/]+\/?$/,ge=/\/live2dapi-noa(?:@[^/]+)?\/?$/;function te(o){let e=new URL(o,document.baseURI);return!ge.test(e.pathname)&&!fe.test(e.pathname)||/@1\.[^/]+\/?$/.test(e.pathname)?o:(e.hostname==="cdn.jsdmirror.com"?e.origin:ee)+Z}var W=()=>g("我的新衣服好看嘛?","How do you like my new outfit?"),E=o=>Number(localStorage.getItem(o))||0,D=class{constructor(e){this.options=e;this.revision=0;this.loaded=!1;this.useCDN=typeof e.cdnPath=="string";let t=e.modelBaseUrl??(e.cdnPath&&te(e.cdnPath))??e.apiPath;if(typeof t!="string")throw new TypeError("Invalid initWidget argument");this.base=t.endsWith("/")?t:t+"/"}reopen(e){if(this.loaded)window.loadlive2d.show?.(e);else return this.load(void 0,void 0,void 0,e)}cancel(){this.revision++}async fetchCatalog(){let e=this.base+"model_list.json",t=await fetch(e);if(t.status===404&&!this.options.modelBaseUrl&&this.base!==j){let i=await T(j+"model_list.json");return this.base=j,i}if(!t.ok)throw new Error(`Failed to load ${e} (HTTP ${t.status})`);return t.json()}list(){return this.catalog??(this.catalog=this.fetchCatalog().catch(e=>{throw this.catalog=void 0,e}))}async load(e=E("modelId"),t=E("modelTexturesId"),i,n=!1,s=++this.revision,a=!1){let r;if(this.options.modelUrl)r=this.options.modelUrl;else if(this.useCDN){let{models:d}=await this.list();d[e]||(e=0);let h=d[e],u=Array.isArray(h)?h:[h];u[t]||(t=0);let v=u[t];t=u.indexOf(v),r=this.base+"model/"+v+"/index.json"}else r=this.base+"get/?id="+e+"-"+t;if(s!==this.revision)return;let c=window.loadlive2d("live2d",r,{start:n,locale:this.options.locale,coreUrl:this.options.coreUrl});c&&await c,s===this.revision&&(this.options.modelUrl||(localStorage.setItem("modelId",String(e)),localStorage.setItem("modelTexturesId",String(t))),w(i,4e3,10),this.loaded=!0)}async costume(e){if(this.options.modelUrl||!this.useCDN)return;let t=++this.revision,i=E("modelId"),n=(await this.list()).models[i],a=(Array.isArray(n)?n:[n]).findIndex(r=>new URL(this.base+"model/"+r+"/index.json",document.baseURI).href===e);a>=0&&await this.load(i,a,W(),!1,t,!0)}async nextModel(e=!1){let t=++this.revision,i=E("modelId");if(this.useCDN){let{models:s,messages:a}=await this.list(),r=(i+1)%s.length;return this.load(r,0,g(a[r],"Ready for duty!"),e,t)}let{model:n}=await T(this.base+"switch/?id="+i);return this.load(n.id,0,n.message,e,t)}async nextTexture(e=!1){let t=++this.revision,i=E("modelId"),n=E("modelTexturesId");if(this.useCDN){let a=(await this.list()).models[i],r=Array.isArray(a)?a.length:1;return this.load(i,(n+1)%r,W(),e,t)}let{textures:s}=await T(this.base+"rand_textures/?id="+i+"-"+n);s.id===1&&n===1?w(g("我还没有其他衣服呢!","This is my only outfit so far!"),4e3,10):await this.load(i,s.id,W(),e,t)}};var $=class{constructor(){this.revision=0}begin(e){let t=document.getElementById("waifu"),i=t?.querySelector(".waifu-surface"),n=++this.revision;return t&&(this.still&&!this.still.isConnected&&(i??t).prepend(this.still),t.setAttribute("data-model-loading","")),s=>{if(this.revision!==n||!t)return;let a=document.createElement("canvas");a.className="waifu-model-still",a.setAttribute("aria-hidden","true"),a.width=s.width,a.height=s.height;try{let r=a.getContext("2d");r&&r.drawImage(s,0,0),this.still?.remove(),this.still=r?a:void 0}finally{if(i){let r=e();t.style.setProperty("--waifu-aspect",String(r)),t.toggleAttribute("data-wide-model",r>=1.35)}t.removeAttribute("data-model-loading"),t.hasAttribute("data-initial-framing")&&(t.removeAttribute("data-initial-framing"),document.activeElement?.matches("#waifu-toggle:focus-visible")&&t.querySelector("#waifu-tool button")?.focus({preventScroll:!0}))}}}};var B={scale:1,x:0,y:0},f=128;function O(o,e,t){let i=0;for(let n=0;n<o.length;n++)if(i+=o[n],i>e*t)return n;return o.length-1}function he(o,e,t,i){let n=new Float64Array(f),s=new Float64Array(f),a=f,r=0,c=0;for(let b=0;b<o.length;b++){if(!o[b])continue;let M=Math.floor(b/f);n[b%f]+=o[b],s[M]+=o[b],c+=o[b],a=Math.min(a,M),r=Math.max(r,M+1)}if(!c)return B;a=Math.max(a,O(s,c,.001)-2);let d=O(n,c,.001),h=O(n,c,.999)+1,u=h-d,v=r-a,l=i?Math.max(.7,Math.min(1.9,u/v*.93/.94)):1;i?.(l);let m=Math.min(1,l),p=Math.min(1,1/l),y=Math.min(.93*f*p/v,.94*f*m/u,5/e.scale),C=0,A=0;if(t)for(let b=a+2;b<r;b+=4)for(let M=d+2;M<h;M+=4){if(o[b*f+M]<96)continue;t((M+.5)/f,(b+.5)/f).some(de=>/^(head|face|body|bust|torso)\d*$/i.test(de))&&(C+=M+.5,A++)}let x=A>=3?C/A:O(n,c,.5)+.5,F=.475*f*m/y,le=Math.max(h-F,Math.min(d+F,x));return{scale:e.scale*y,x:(.5-le/f)*y,y:.5-.03*p+(.5-r/f)*y}}function oe(o){let e={scale:.65,x:0,y:0},t=document.createElement("canvas");t.width=t.height=f;let i=t.getContext("2d",{willReadFrequently:!0}),n=new Uint8Array(f*f),s=new Uint8Array(n.length),a=0,r=0,c=0;return{initial:e,measure(d,h){if(!i)return B;let u=performance.now();if(!(u<c)){a++;try{i.clearRect(0,0,f,f),i.drawImage(d,0,0,f,f);let{data:v}=i.getImageData(0,0,f,f),l=0;for(let m=0;m<n.length;m++){let p=v[4*m+3];s[m]=p>=24?p:0,s[m]&&l++}l>=16&&(n.set(s),r++,c=u+80)}catch{return B}if(!(r<3&&a<10))return r?he(n,e,h,o):B}}}}var ne=["fairy","doll","adjutant","npc","squad","background"],ie=["default","normal","destroy"];function N(o,e){let t=o.indexOf(e);return t<0?o.length:t}function pe(o,e){let t=new Intl.Collator("en",{numeric:!0}),i=o.map(n=>{let[s,a,r,c]=n.split("/"),d=e[[s,a,r].join("/")],h=r==="base"?-1:d??(s==="fairy"&&/^\d+$/.test(r)?Number(r):Number.MAX_SAFE_INTEGER);return{id:n,category:s,character:a,version:r,form:c,order:h}});return i.sort((n,s)=>N(ne,n.category)-N(ne,s.category)||t.compare(n.category,s.category)||t.compare(n.character,s.character)||n.order-s.order||t.compare(n.version,s.version)||N(ie,n.form)-N(ie,s.form)||t.compare(n.form,s.form)),i.map(n=>n.id)}async function se(o,e,t="zh-CN"){let i=new URL(o,document.baseURI),n=await fetch(i);if(!n.ok)throw new Error("Cannot load catalog: HTTP "+n.status);let s=await n.json();if(s.schemaVersion!==1||!s.models||!s.sources)throw new Error("Unsupported model catalog");let a=new Map,r=Object.keys(s.models).filter(l=>(!e||!l.startsWith("other/"))&&s.models[l].some(m=>m.manifest)),c=e?s.presentation:void 0,d=t==="en"?c?.en:c,h=l=>{let m=c?.aliases[l];return m&&r.includes(m)?m:l},u=e?pe(r.filter(l=>h(l)===l),c?.outfitOrder??{}):r;function v(l,m){if(e&&!r.includes(l))throw new Error("Model outside the selected collection: "+l);let p=s.models[l]?.find(x=>x.manifest&&(!m||x.source===m));if(!p?.manifest)throw new Error("No model manifest for "+l);let y=new URL(s.sources[p.source].baseUrl,n.url||i);i.hostname==="cdn.jsdmirror.com"&&y.hostname==="cdn.jsdelivr.net"&&y.pathname.startsWith("/gh/nova1751/live2d-api@cdn-")&&(y.hostname=i.hostname);let C=x=>new URL(x.split("/").map(encodeURIComponent).join("/"),y).href,A;if(p.dialogue){let x=a.get(p.source);x||(x=new Map((s.audio?.[p.source]??[]).map(F=>[F.toUpperCase(),C(F)])),a.set(p.source,x)),A={captions:t==="en"?void 0:d?.captions,url:C(p.dialogue),audio:x}}return{captions:d?.captions,modelUrl:C(p.manifest),dialogue:A,soundAliases:p.soundAliases}}return{ids:u,visibleId:h,labels:d?.labels??{},resolve:v,legacyIds:s.legacyIds}}var k=class{constructor(e,t){this.url=e;this.options=t;this.sequence=0;this.transition=new $;let i=t.collection?":"+t.collection:"",n="live2d:model:"+e+i,s=a=>a.replace(/(\/gh\/nova1751\/live2d-api)@catalog-[a-f0-9]{16}(\/catalog\/library\.json:girls-frontline)$/,"$1$2");if(this.key=s(n),this.key!==n&&!localStorage.getItem(this.key)){let a=[n,...Object.keys(localStorage)].find(r=>s(r)===this.key&&localStorage.getItem(r));a&&localStorage.setItem(this.key,localStorage.getItem(a))}}open(){return this.library??(this.library=se(this.url,this.options.collection,this.options.locale).catch(e=>{throw this.library=void 0,e}))}async select(e,t){let i=++this.sequence;try{let n=await this.open();if(i!==this.sequence)return;let s=e(n.ids,n.legacyIds,n.visibleId),{modelUrl:a,dialogue:r,soundAliases:c,captions:d}=n.resolve(s),h=1,u=this.options.collection==="girls-frontline"&&!s.startsWith("background/")?oe(l=>{h=l}):void 0,v=this.options.collection?this.transition.begin(()=>h):void 0;await window.loadlive2d("live2d",a,{start:t,locale:this.options.locale,captions:d,framing:u,onPaint:v,coreUrl:this.options.coreUrl,dialogue:r,soundAliases:c}),i===this.sequence&&(this.active=n.visibleId(s),localStorage.setItem(this.key,s),window.dispatchEvent(new CustomEvent("live2d:model",{detail:s})))}catch(n){throw i===this.sequence&&document.getElementById("waifu")?.removeAttribute("data-initial-framing"),n}}load(e,t,i,n=!1){return this.select((s,a,r)=>{let c=localStorage.getItem(this.key);if(this.options.collection)return this.options.modelId??(c&&s.includes(r(c))?c:s[0]);let d=a?.[Number(localStorage.getItem("modelId"))]?.[Number(localStorage.getItem("modelTexturesId"))];return this.options.modelId??(c&&s.includes(r(c))?c:d&&s.includes(d)?d:s[0])},n)}choose(e){return this.select(()=>e,!1)}cancel(){this.sequence++}reopen(e){if(this.active)window.loadlive2d.show?.(e);else return this.load(void 0,void 0,void 0,e)}character(e){return e.split("/").slice(0,2).join("/")}nextModel(e=!1){return this.select(t=>{let i=[...new Set(t.map(s=>this.character(s)))],n=i[(i.indexOf(this.character(this.active??""))+1)%i.length];return t.find(s=>this.character(s)===n)},e)}nextTexture(e=!1){return this.select(t=>{let i=t.filter(n=>this.character(n)===this.character(this.active??t[0]));return i[(i.indexOf(this.active??"")+1)%i.length]},e)}async costume(e){let t=await this.open(),i=t.ids.find(n=>t.resolve(n).modelUrl===e);i&&await this.select(()=>i,!1)}};var we=document.currentScript,ve=we?.dataset.asteroidsUrl??"https://cdn.jsdelivr.net/gh/nova1751/live2d-api@widget-2.4.5/asteroids.js",I=o=>document.getElementById(o);function S(o){console.error("[Live2D]",o);let e=document.getElementById("waifu-status");e&&(e.textContent=g("加载失败,请检查网络或切换模型后重试。","Could not load the model. Check your connection or try another character."),w(e.textContent,5e3,10))}async function ye(o){if(o==="en"){w(["One step at a time, Commander.","Even on a quiet day, there is something worth noticing."],6e3,9);return}let e=await T("https://v1.hitokoto.cn");w(L(e.hitokoto),6e3,9),setTimeout(()=>{w(`这句一言来自 <span>「${L(String(e.from))}」</span>,是 <span>${L(String(e.creator))}</span> 在 hitokoto.cn 投稿的。`,4e3,9)},6e3)}function be(){if(window.Asteroids)(window.ASTEROIDSPLAYERS??(window.ASTEROIDSPLAYERS=[])).push(new window.Asteroids);else{let o=document.createElement("script");o.src=ve,document.head.appendChild(o)}}var ae;function ce(){clearTimeout(ae),localStorage.removeItem("waifu-display"),I("waifu-toggle").setAttribute("tabindex","-1"),I("waifu-toggle").setAttribute("aria-expanded","true"),I("waifu").style.display="";let o=I("waifu");o.hasAttribute("data-initial-framing")?o.style.bottom="0":setTimeout(()=>{o.style.bottom="0"},0)}function V(o){return o.isTrusted&&!!window.loadlive2d.prepareInteraction?.()}function xe(){let o=I("waifu").contains(document.activeElement);window.loadlive2d.hide?.(),localStorage.setItem("waifu-display",String(Date.now())),w(g("愿你有一天能与重要的人重逢。","I hope you meet the people you miss again."),2e3,11),I("waifu").style.bottom="-500px",ae=setTimeout(()=>{I("waifu").style.display="none";let e=I("waifu-toggle");e.removeAttribute("tabindex"),e.setAttribute("aria-expanded","false"),e.classList.add("waifu-toggle-active"),o&&e.focus()},window.matchMedia("(prefers-reduced-motion: reduce)").matches?0:3e3)}function re(o,e,t=!1){sessionStorage.removeItem("waifu-text");let i=o.collection==="girls-frontline",n='<canvas id="live2d" width="800" height="800"></canvas>';document.body.insertAdjacentHTML("beforeend",`<div id="waifu" lang="${o.locale==="en"?"en":"zh-CN"}"${i?' class="waifu-adaptive"':""}${i&&e instanceof k?" data-initial-framing":""}>
|
|
3
3
|
<div id="waifu-status" role="status" class="waifu-sr-only"></div>
|
|
4
4
|
<div id="waifu-tips"></div>
|
|
5
5
|
${i?`<div class="waifu-viewport"><div class="waifu-surface">${n}</div></div>`:n}
|
|
6
6
|
<div id="waifu-tool"></div>
|
|
7
|
-
</div>`),ce(),window.addEventListener("live2d:dialogue",r=>{let{detail:c,playback:d}=r;typeof c=="string"&&J(c,d)}),window.addEventListener("live2d:preset",r=>{let{playback:c}=r;c&&X(c)}),window.addEventListener("live2d:dialogue-end",r=>{let c=r.detail;c?.playback&&K(c.playback,c.interrupted)}),window.addEventListener("live2d:costume",r=>{let c=r.detail;typeof c=="string"&&e.costume(c).catch(S)});let s={hitokoto:
|
|
7
|
+
</div>`),ce(),window.addEventListener("live2d:dialogue",r=>{let{detail:c,playback:d}=r;typeof c=="string"&&J(c,d)}),window.addEventListener("live2d:preset",r=>{let{playback:c}=r;c&&X(c)}),window.addEventListener("live2d:dialogue-end",r=>{let c=r.detail;c?.playback&&K(c.playback,c.interrupted)}),window.addEventListener("live2d:costume",r=>{let c=r.detail;typeof c=="string"&&e.costume(c).catch(S)});let s={hitokoto:g("听一句话","Hear a quote"),asteroids:g("启动小游戏","Play Asteroids"),"switch-model":g("切换人物","Next character"),"switch-texture":g("切换造型","Next outfit"),photo:g("保存照片","Save a picture"),info:g("项目信息","Project information"),quit:g("收起看板娘","Hide companion")},a={hitokoto:()=>ye(o.locale).catch(S),asteroids:be,"switch-model":r=>e.nextModel(V(r)).catch(S),"switch-texture":r=>e.nextTexture(V(r)).catch(S),photo:()=>{w(g("照好了嘛,是不是很可爱呢?","Did you get my good side?"),6e3,9),!(window.loadlive2d.capture?.()||!window.Live2D)&&(window.Live2D.captureName="photo.png",window.Live2D.captureFrame=!0)},info:()=>window.open("https://github.com/nova1751/live2d-api"),quit:()=>{e.cancel(),xe()}};for(let r of Array.isArray(o.tools)?o.tools:Object.keys(a)){if(o.modelUrl&&(r==="switch-model"||r==="switch-texture")||!Object.prototype.hasOwnProperty.call(a,r))continue;let c=r;I("waifu-tool").insertAdjacentHTML("beforeend",`<button type="button" id="waifu-tool-${c}" aria-label="${s[c]}" title="${s[c]}">${G[c]}</button>`),I("waifu-tool-"+c).addEventListener("click",a[c])}e.load(void 0,void 0,void 0,t).catch(S),T(o.waifuPath).then(Q).catch(S)}window.initWidget=(o,e)=>{let t=typeof o=="string"?{waifuPath:o,apiPath:e}:o;if(document.getElementById("waifu-toggle"))return;_(t.locale),document.body.insertAdjacentHTML("beforeend",`<button type="button" id="waifu-toggle" aria-label="${g("打开看板娘","Show companion")}" aria-controls="waifu"><span>${g("看板娘","Companion")}</span></button>`);let i=I("waifu-toggle");i.setAttribute("aria-expanded","false");let n=t.catalogUrl?new k(t.catalogUrl,t):new D(t);n instanceof k&&Object.defineProperty(window,Symbol.for("live2dapi-noa.selectModel"),{configurable:!0,value:async a=>((i.getAttribute("aria-expanded")==="false"||localStorage.getItem("waifu-display"))&&i.click(),n.choose(a))}),i.addEventListener("click",a=>{let r=V(a);i.classList.remove("waifu-toggle-active"),i.hasAttribute("first-time")?(re(t,n,r),i.removeAttribute("first-time")):(ce(),n.reopen(r)?.catch(S)),a.detail===0&&document.querySelector("#waifu-tool button")?.focus()});let s=Number(localStorage.getItem("waifu-display"));s&&Date.now()-s<=864e5?(i.setAttribute("first-time","true"),setTimeout(()=>i.classList.add("waifu-toggle-active"),0)):re(t,n)};})();
|
package/npm/random/autoload.js
CHANGED
|
@@ -8,7 +8,7 @@ const live2d_path = (() => {
|
|
|
8
8
|
return new URL("../../", url).href;
|
|
9
9
|
}
|
|
10
10
|
}
|
|
11
|
-
return "https://cdn.jsdelivr.net/gh/nova1751/live2d-api@widget-2.4.
|
|
11
|
+
return "https://cdn.jsdelivr.net/gh/nova1751/live2d-api@widget-2.4.5/";
|
|
12
12
|
})();
|
|
13
13
|
function loadExternalResource(url, type) {
|
|
14
14
|
let tag;
|
package/npm/random/waifu-tips.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*! Live2D API | Generated from src/ | https://github.com/nova1751/live2d-api */
|
|
2
|
-
"use strict";(()=>{var Y="zh-CN";function _(o){Y=o??"zh-CN"}function m(o,e){return Y==="en"?e:o}var G={hitokoto:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--! Font Awesome Free 6.4.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2023 Fonticons, Inc. --><path d="M512 240c0 114.9-114.6 208-256 208c-37.1 0-72.3-6.4-104.1-17.9c-11.9 8.7-31.3 20.6-54.3 30.6C73.6 471.1 44.7 480 16 480c-6.5 0-12.3-3.9-14.8-9.9c-2.5-6-1.1-12.8 3.4-17.4l0 0 0 0 0 0 0 0 .3-.3c.3-.3 .7-.7 1.3-1.4c1.1-1.2 2.8-3.1 4.9-5.7c4.1-5 9.6-12.4 15.2-21.6c10-16.6 19.5-38.4 21.4-62.9C17.7 326.8 0 285.1 0 240C0 125.1 114.6 32 256 32s256 93.1 256 208z"/></svg>',asteroids:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--! Font Awesome Free 6.4.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2023 Fonticons, Inc. --><path d="M498.1 5.6c10.1 7 15.4 19.1 13.5 31.2l-64 416c-1.5 9.7-7.4 18.2-16 23s-18.9 5.4-28 1.6L284 427.7l-68.5 74.1c-8.9 9.7-22.9 12.9-35.2 8.1S160 493.2 160 480V396.4c0-4 1.5-7.8 4.2-10.7L331.8 202.8c5.8-6.3 5.6-16-.4-22s-15.7-6.4-22-.7L106 360.8 17.7 316.6C7.1 311.3 .3 300.7 0 288.9s5.9-22.8 16.1-28.7l448-256c10.7-6.1 23.9-5.5 34 1.4z"/></svg>',"switch-model":'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--! Font Awesome Free 6.4.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2023 Fonticons, Inc. --><path d="M399 384.2C376.9 345.8 335.4 320 288 320H224c-47.4 0-88.9 25.8-111 64.2c35.2 39.2 86.2 63.8 143 63.8s107.8-24.7 143-63.8zM0 256a256 256 0 1 1 512 0A256 256 0 1 1 0 256zm256 16a72 72 0 1 0 0-144 72 72 0 1 0 0 144z"/></svg>',"switch-texture":'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--! Font Awesome Free 6.4.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2023 Fonticons, Inc. --><path d="M320 64A64 64 0 1 0 192 64a64 64 0 1 0 128 0zm-96 96c-35.3 0-64 28.7-64 64v48c0 17.7 14.3 32 32 32h1.8l11.1 99.5c1.8 16.2 15.5 28.5 31.8 28.5h38.7c16.3 0 30-12.3 31.8-28.5L318.2 304H320c17.7 0 32-14.3 32-32V224c0-35.3-28.7-64-64-64H224zM132.3 394.2c13-2.4 21.7-14.9 19.3-27.9s-14.9-21.7-27.9-19.3c-32.4 5.9-60.9 14.2-82 24.8c-10.5 5.3-20.3 11.7-27.8 19.6C6.4 399.5 0 410.5 0 424c0 21.4 15.5 36.1 29.1 45c14.7 9.6 34.3 17.3 56.4 23.4C130.2 504.7 190.4 512 256 512s125.8-7.3 170.4-19.6c22.1-6.1 41.8-13.8 56.4-23.4c13.7-8.9 29.1-23.6 29.1-45c0-13.5-6.4-24.5-14-32.6c-7.5-7.9-17.3-14.3-27.8-19.6c-21-10.6-49.5-18.9-82-24.8c-13-2.4-25.5 6.3-27.9 19.3s6.3 25.5 19.3 27.9c30.2 5.5 53.7 12.8 69 20.5c3.2 1.6 5.8 3.1 7.9 4.5c3.6 2.4 3.6 7.2 0 9.6c-8.8 5.7-23.1 11.8-43 17.3C374.3 457 318.5 464 256 464s-118.3-7-157.7-17.9c-19.9-5.5-34.2-11.6-43-17.3c-3.6-2.4-3.6-7.2 0-9.6c2.1-1.4 4.8-2.9 7.9-4.5c15.3-7.7 38.8-14.9 69-20.5z"/></svg>',photo:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--! Font Awesome Free 6.4.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2023 Fonticons, Inc. --><path d="M220.6 121.2L271.1 96 448 96v96H333.2c-21.9-15.1-48.5-24-77.2-24s-55.2 8.9-77.2 24H64V128H192c9.9 0 19.7-2.3 28.6-6.8zM0 128V416c0 35.3 28.7 64 64 64H448c35.3 0 64-28.7 64-64V96c0-35.3-28.7-64-64-64H271.1c-9.9 0-19.7 2.3-28.6 6.8L192 64H160V48c0-8.8-7.2-16-16-16H80c-8.8 0-16 7.2-16 16l0 16C28.7 64 0 92.7 0 128zM168 304a88 88 0 1 1 176 0 88 88 0 1 1 -176 0z"/></svg>',info:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--! Font Awesome Free 6.4.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2023 Fonticons, Inc. --><path d="M256 512A256 256 0 1 0 256 0a256 256 0 1 0 0 512zM216 336h24V272H216c-13.3 0-24-10.7-24-24s10.7-24 24-24h48c13.3 0 24 10.7 24 24v88h8c13.3 0 24 10.7 24 24s-10.7 24-24 24H216c-13.3 0-24-10.7-24-24s10.7-24 24-24zm40-208a32 32 0 1 1 0 64 32 32 0 1 1 0-64z"/></svg>',quit:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 384 512"><!--! Font Awesome Free 6.4.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2023 Fonticons, Inc. --><path d="M342.6 150.6c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L192 210.7 86.6 105.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3L146.7 256 41.4 361.4c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0L192 301.3 297.4 406.6c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3L237.3 256 342.6 150.6z"/></svg>'};function E(o){return Array.isArray(o)?o[Math.floor(Math.random()*o.length)]:o}function L(o){return o.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}var B,H,k;function P(){clearTimeout(H),sessionStorage.removeItem("waifu-text"),document.getElementById("waifu-tips")?.classList.remove("waifu-tips-active")}function z(o,e){clearTimeout(H),sessionStorage.setItem("waifu-text",String(e));let t=document.getElementById("waifu-tips");t.innerHTML=o,t.classList.add("waifu-tips-active")}function v(o,e,t){!o||k||Number(sessionStorage.getItem("waifu-text"))>t||(z(E(o),t),H=setTimeout(P,e))}function J(o,e){if(!e){v(L(o),5e3,11);return}k=e,z(L(o),11)}function X(o){let e=document.getElementById("live2d");if(!e)return;let t=B?.find(({selector:n})=>e.closest(n)),i=t?E(t.text):B?void 0:m("指挥官,我在。","Right here, Commander.");i&&(k=o,z(i.replace("{text}",()=>L(e.textContent??"")),11))}function K(o,e){k===o&&(k=void 0,e?P():H=setTimeout(P,1200))}function de(o){if(location.pathname==="/"){let s=new Date().getHours();for(let{hour:a,text:r}of o){let[c,d=c]=a.split("-").map(Number);if(c<=s&&s<=d)return r}}let e=L(document.title.split(" - ")[0]),t=m(`欢迎阅读<span>「${e}」</span>`,`Welcome to <span>${e}</span>!`);if(!document.referrer)return t;let{hostname:i}=new URL(document.referrer);return i===location.hostname?t:m(`Hello!来自 <span>${L({baidu:"百度",so:"360搜索",google:"谷歌搜索"}[i.split(".")[1]]??i)}</span> 的朋友<br>${t}`,`Hello, visitor from <span>${L(i)}</span>!<br>${t}`)}function ue(o){let[e,t]=o.split("/").map(Number);return e*100+t}function Q(o){B=o.click;let e=[...o.message.default],t=new Date,i=(t.getMonth()+1)*100+t.getDate();for(let{date:u,text:p}of o.seasons){let[l,h=l]=u.split("-").map(ue);l<=i&&i<=h&&e.push(E(p).replace("{year}",String(t.getFullYear())))}let n=2e4,s=Date.now(),a;function r(){if(document.hidden)return;let u=n-(Date.now()-s);u<=0&&!localStorage.getItem("waifu-display")&&v(e,6e3,9),a=setTimeout(r,u>0?u:n)}let c=()=>{s=Date.now()};window.addEventListener("pointermove",c,{passive:!0}),window.addEventListener("pointerdown",c,{passive:!0}),window.addEventListener("keydown",c),document.hidden||(a=setTimeout(r,n)),v(de(o.time),7e3,11);let d;for(let u of["mouseover","click"])window.addEventListener(u,p=>{let l=p.target;if(!(l instanceof Element)||p.live2dHandlesCaption)return;let h=u==="click"&&l.closest("#waifu .waifu-model-stage"),w=h?document.getElementById("live2d"):l.closest("#live2d"),y=o[u].find(({selector:C})=>l.closest(C)||h&&w?.closest(C));!y||u==="mouseover"&&y.selector===d||(u==="mouseover"&&(d=y.selector),v(E(y.text).replace("{text}",()=>L(l.textContent??"")),4e3,u==="click"&&w?11:8))});let f=()=>{};f.toString=()=>(v(o.message.console,6e3,9),""),console.log("%c",f),window.addEventListener("copy",()=>v(o.message.copy,6e3,9)),document.addEventListener("visibilitychange",()=>{clearTimeout(a),document.hidden||(c(),a=setTimeout(r,n),localStorage.getItem("waifu-display")||v(o.message.visibilitychange,6e3,9))})}async function T(o){let e=await fetch(o);if(!e.ok)throw new Error(`Failed to load ${o} (HTTP ${e.status})`);return e.json()}var Z="/gh/nova1751/live2d-api@cdn-b3ac5ae545e2/",ee="https://cdn.jsdelivr.net",j=ee+Z,me=/\/gh\/nova1751\/live2d-api@widget-[^/]+\/?$/,ge=/\/live2dapi-noa(?:@[^/]+)?\/?$/;function te(o){let e=new URL(o,document.baseURI);return!ge.test(e.pathname)&&!me.test(e.pathname)||/@1\.[^/]+\/?$/.test(e.pathname)?o:(e.hostname==="cdn.jsdmirror.com"?e.origin:ee)+Z}var q=()=>m("我的新衣服好看嘛?","How do you like my new outfit?"),A=o=>Number(localStorage.getItem(o))||0,D=class{constructor(e){this.options=e;this.revision=0;this.loaded=!1;this.useCDN=typeof e.cdnPath=="string";let t=e.modelBaseUrl??(e.cdnPath&&te(e.cdnPath))??e.apiPath;if(typeof t!="string")throw new TypeError("Invalid initWidget argument");this.base=t.endsWith("/")?t:t+"/"}reopen(e){if(this.loaded)window.loadlive2d.show?.(e);else return this.load(void 0,void 0,void 0,e)}cancel(){this.revision++}async fetchCatalog(){let e=this.base+"model_list.json",t=await fetch(e);if(t.status===404&&!this.options.modelBaseUrl&&this.base!==j){let i=await T(j+"model_list.json");return this.base=j,i}if(!t.ok)throw new Error(`Failed to load ${e} (HTTP ${t.status})`);return t.json()}list(){return this.catalog??(this.catalog=this.fetchCatalog().catch(e=>{throw this.catalog=void 0,e}))}async load(e=A("modelId"),t=A("modelTexturesId"),i,n=!1,s=++this.revision,a=!1){let r;if(this.options.modelUrl)r=this.options.modelUrl;else if(this.useCDN){let{models:d}=await this.list();d[e]||(e=0);let f=d[e],u=Array.isArray(f)?f:[f];u[t]||(t=0);let p=a?u[t]:E(u);t=u.indexOf(p),r=this.base+"model/"+p+"/index.json"}else r=this.base+"get/?id="+e+"-"+t;if(s!==this.revision)return;let c=window.loadlive2d("live2d",r,{start:n,locale:this.options.locale,coreUrl:this.options.coreUrl});c&&await c,s===this.revision&&(this.options.modelUrl||(localStorage.setItem("modelId",String(e)),localStorage.setItem("modelTexturesId",String(t))),v(i,4e3,10),this.loaded=!0)}async costume(e){if(this.options.modelUrl||!this.useCDN)return;let t=++this.revision,i=A("modelId"),n=(await this.list()).models[i],a=(Array.isArray(n)?n:[n]).findIndex(r=>new URL(this.base+"model/"+r+"/index.json",document.baseURI).href===e);a>=0&&await this.load(i,a,q(),!1,t,!0)}async nextModel(e=!1){let t=++this.revision,i=A("modelId");if(this.useCDN){let{models:s,messages:a}=await this.list(),r=(i+1)%s.length;return this.load(r,0,m(a[r],"Ready for duty!"),e,t)}let{model:n}=await T(this.base+"switch/?id="+i);return this.load(n.id,0,n.message,e,t)}async nextTexture(e=!1){let t=++this.revision,i=A("modelId"),n=A("modelTexturesId");if(this.useCDN){let a=(await this.list()).models[i],r=Array.isArray(a)?a.length:1;return this.load(i,n,q(),e,t)}let{textures:s}=await T(this.base+"rand_textures/?id="+i+"-"+n);s.id===1&&n===1?v(m("我还没有其他衣服呢!","This is my only outfit so far!"),4e3,10):await this.load(i,s.id,q(),e,t)}};var $=class{constructor(){this.revision=0}begin(e){let t=document.getElementById("waifu"),i=t?.querySelector(".waifu-surface"),n=++this.revision;return t&&(this.still&&!this.still.isConnected&&(i??t).prepend(this.still),t.setAttribute("data-model-loading","")),s=>{if(this.revision!==n||!t)return;let a=document.createElement("canvas");a.className="waifu-model-still",a.setAttribute("aria-hidden","true"),a.width=s.width,a.height=s.height;try{let r=a.getContext("2d");r&&r.drawImage(s,0,0),this.still?.remove(),this.still=r?a:void 0}finally{if(i){let r=e();t.style.setProperty("--waifu-aspect",String(r)),t.toggleAttribute("data-wide-model",r>=1.35)}t.removeAttribute("data-model-loading")}}}};var O={scale:1,x:0,y:0},g=128;function W(o,e,t){let i=0;for(let n=0;n<o.length;n++)if(i+=o[n],i>e*t)return n;return o.length-1}function fe(o,e,t,i){let n=new Float64Array(g),s=g,a=0,r=0;for(let x=0;x<o.length;x++){if(!o[x])continue;let M=Math.floor(x/g);n[x%g]+=o[x],r+=o[x],s=Math.min(s,M),a=Math.max(a,M+1)}if(!r)return O;let c=W(n,r,.001),d=W(n,r,.999)+1,f=d-c,u=a-s,p=i?Math.max(.7,Math.min(1.9,f/u*.93/.94)):1;i?.(p);let l=Math.min(1,p),h=Math.min(1,1/p),w=Math.min(.93*g*h/u,.94*g*l/f,5/e.scale),y=0,C=0;if(t)for(let x=s+2;x<a;x+=4)for(let M=c+2;M<d;M+=4){if(o[x*g+M]<96)continue;t((M+.5)/g,(x+.5)/g).some(le=>/^(head|face|body|bust|torso)\d*$/i.test(le))&&(y+=M+.5,C++)}let F=C>=3?y/C:W(n,r,.5)+.5,b=.475*g*l/w,U=Math.max(d-b,Math.min(c+b,F));return{scale:e.scale*w,x:(.5-U/g)*w,y:.5-.03*h+(.5-a/g)*w}}function oe(o){let e={scale:.65,x:0,y:0},t=document.createElement("canvas");t.width=t.height=g;let i=t.getContext("2d",{willReadFrequently:!0}),n=new Uint8Array(g*g),s=0,a=0,r=0;return{initial:e,measure(c,d){if(!i)return O;let f=performance.now();if(!(f<r)){s++;try{i.clearRect(0,0,g,g),i.drawImage(c,0,0,g,g);let{data:u}=i.getImageData(0,0,g,g),p=0;for(let l=0;l<n.length;l++){let h=u[4*l+3];h<24||(n[l]=Math.max(n[l],h),p++)}p>=16&&(a++,r=f+80)}catch{return O}if(!(a<3&&s<10))return a?fe(n,e,d,o):O}}}}var ne=["fairy","doll","adjutant","npc","squad","background"],ie=["default","normal","destroy"];function N(o,e){let t=o.indexOf(e);return t<0?o.length:t}function he(o,e){let t=new Intl.Collator("en",{numeric:!0}),i=o.map(n=>{let[s,a,r,c]=n.split("/"),d=e[[s,a,r].join("/")],f=r==="base"?-1:d??(s==="fairy"&&/^\d+$/.test(r)?Number(r):Number.MAX_SAFE_INTEGER);return{id:n,category:s,character:a,version:r,form:c,order:f}});return i.sort((n,s)=>N(ne,n.category)-N(ne,s.category)||t.compare(n.category,s.category)||t.compare(n.character,s.character)||n.order-s.order||t.compare(n.version,s.version)||N(ie,n.form)-N(ie,s.form)||t.compare(n.form,s.form)),i.map(n=>n.id)}async function se(o,e,t="zh-CN"){let i=new URL(o,document.baseURI),n=await fetch(i);if(!n.ok)throw new Error("Cannot load catalog: HTTP "+n.status);let s=await n.json();if(s.schemaVersion!==1||!s.models||!s.sources)throw new Error("Unsupported model catalog");let a=new Map,r=Object.keys(s.models).filter(l=>(!e||!l.startsWith("other/"))&&s.models[l].some(h=>h.manifest)),c=e?s.presentation:void 0,d=t==="en"?c?.en:c,f=l=>{let h=c?.aliases[l];return h&&r.includes(h)?h:l},u=e?he(r.filter(l=>f(l)===l),c?.outfitOrder??{}):r;function p(l,h){if(e&&!r.includes(l))throw new Error("Model outside the selected collection: "+l);let w=s.models[l]?.find(b=>b.manifest&&(!h||b.source===h));if(!w?.manifest)throw new Error("No model manifest for "+l);let y=new URL(s.sources[w.source].baseUrl,n.url||i);i.hostname==="cdn.jsdmirror.com"&&y.hostname==="cdn.jsdelivr.net"&&y.pathname.startsWith("/gh/nova1751/live2d-api@cdn-")&&(y.hostname=i.hostname);let C=b=>new URL(b.split("/").map(encodeURIComponent).join("/"),y).href,F;if(w.dialogue){let b=a.get(w.source);b||(b=new Map((s.audio?.[w.source]??[]).map(U=>[U.toUpperCase(),C(U)])),a.set(w.source,b)),F={captions:t==="en"?void 0:d?.captions,url:C(w.dialogue),audio:b}}return{captions:d?.captions,modelUrl:C(w.manifest),dialogue:F,soundAliases:w.soundAliases}}return{ids:u,visibleId:f,labels:d?.labels??{},resolve:p,legacyIds:s.legacyIds}}var R=class{constructor(e,t){this.url=e;this.options=t;this.sequence=0;this.transition=new $;let i=t.collection?":"+t.collection:"",n="live2d:model:"+e+i,s=a=>a.replace(/(\/gh\/nova1751\/live2d-api)@catalog-[a-f0-9]{16}(\/catalog\/library\.json:girls-frontline)$/,"$1$2");if(this.key=s(n),this.key!==n&&!localStorage.getItem(this.key)){let a=[n,...Object.keys(localStorage)].find(r=>s(r)===this.key&&localStorage.getItem(r));a&&localStorage.setItem(this.key,localStorage.getItem(a))}}open(){return this.library??(this.library=se(this.url,this.options.collection,this.options.locale).catch(e=>{throw this.library=void 0,e}))}async select(e,t){let i=++this.sequence,n=await this.open();if(i!==this.sequence)return;let s=e(n.ids,n.legacyIds,n.visibleId),{modelUrl:a,dialogue:r,soundAliases:c,captions:d}=n.resolve(s),f=1,u=this.options.collection==="girls-frontline"&&!s.startsWith("background/")?oe(l=>{f=l}):void 0,p=this.options.collection?this.transition.begin(()=>f):void 0;await window.loadlive2d("live2d",a,{start:t,locale:this.options.locale,captions:d,framing:u,onPaint:p,coreUrl:this.options.coreUrl,dialogue:r,soundAliases:c}),i===this.sequence&&(this.active=n.visibleId(s),localStorage.setItem(this.key,s),window.dispatchEvent(new CustomEvent("live2d:model",{detail:s})))}load(e,t,i,n=!1){return this.select((s,a,r)=>{let c=localStorage.getItem(this.key);if(this.options.collection)return this.options.modelId??(c&&s.includes(r(c))?c:s[0]);let d=a?.[Number(localStorage.getItem("modelId"))]?.[Number(localStorage.getItem("modelTexturesId"))];return this.options.modelId??(c&&s.includes(r(c))?c:d&&s.includes(d)?d:s[0])},n)}choose(e){return this.select(()=>e,!1)}cancel(){this.sequence++}reopen(e){if(this.active)window.loadlive2d.show?.(e);else return this.load(void 0,void 0,void 0,e)}character(e){return e.split("/").slice(0,2).join("/")}nextModel(e=!1){return this.select(t=>{let i=[...new Set(t.map(s=>this.character(s)))],n=i[(i.indexOf(this.character(this.active??""))+1)%i.length];return t.find(s=>this.character(s)===n)},e)}nextTexture(e=!1){return this.select(t=>{let i=t.filter(n=>this.character(n)===this.character(this.active??t[0]));{let n=i.filter(s=>s!==this.active);return n.length?n[Math.floor(Math.random()*n.length)]:i[0]}return i[(i.indexOf(this.active??"")+1)%i.length]},e)}async costume(e){let t=await this.open(),i=t.ids.find(n=>t.resolve(n).modelUrl===e);i&&await this.select(()=>i,!1)}};var pe=document.currentScript,we=pe?.dataset.asteroidsUrl??"https://cdn.jsdelivr.net/gh/nova1751/live2d-api@widget-2.4.3/asteroids.js",I=o=>document.getElementById(o);function S(o){console.error("[Live2D]",o);let e=document.getElementById("waifu-status");e&&(e.textContent=m("加载失败,请检查网络或切换模型后重试。","Could not load the model. Check your connection or try another character."),v(e.textContent,5e3,10))}async function ve(o){if(o==="en"){v(["One step at a time, Commander.","Even on a quiet day, there is something worth noticing."],6e3,9);return}let e=await T("https://v1.hitokoto.cn");v(L(e.hitokoto),6e3,9),setTimeout(()=>{v(`这句一言来自 <span>「${L(String(e.from))}」</span>,是 <span>${L(String(e.creator))}</span> 在 hitokoto.cn 投稿的。`,4e3,9)},6e3)}function ye(){if(window.Asteroids)(window.ASTEROIDSPLAYERS??(window.ASTEROIDSPLAYERS=[])).push(new window.Asteroids);else{let o=document.createElement("script");o.src=we,document.head.appendChild(o)}}var ae;function ce(){clearTimeout(ae),localStorage.removeItem("waifu-display"),I("waifu-toggle").setAttribute("tabindex","-1"),I("waifu-toggle").setAttribute("aria-expanded","true"),I("waifu").style.display="",setTimeout(()=>{I("waifu").style.bottom="0"},0)}function V(o){return o.isTrusted&&!!window.loadlive2d.prepareInteraction?.()}function be(){let o=I("waifu").contains(document.activeElement);window.loadlive2d.hide?.(),localStorage.setItem("waifu-display",String(Date.now())),v(m("愿你有一天能与重要的人重逢。","I hope you meet the people you miss again."),2e3,11),I("waifu").style.bottom="-500px",ae=setTimeout(()=>{I("waifu").style.display="none";let e=I("waifu-toggle");e.removeAttribute("tabindex"),e.setAttribute("aria-expanded","false"),e.classList.add("waifu-toggle-active"),o&&e.focus()},window.matchMedia("(prefers-reduced-motion: reduce)").matches?0:3e3)}function re(o,e,t=!1){sessionStorage.removeItem("waifu-text");let i=o.collection==="girls-frontline",n='<canvas id="live2d" width="800" height="800"></canvas>';document.body.insertAdjacentHTML("beforeend",`<div id="waifu" lang="${o.locale==="en"?"en":"zh-CN"}"${i?' class="waifu-adaptive"':""}>
|
|
2
|
+
"use strict";(()=>{var Y="zh-CN";function _(o){Y=o??"zh-CN"}function g(o,e){return Y==="en"?e:o}var G={hitokoto:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--! Font Awesome Free 6.4.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2023 Fonticons, Inc. --><path d="M512 240c0 114.9-114.6 208-256 208c-37.1 0-72.3-6.4-104.1-17.9c-11.9 8.7-31.3 20.6-54.3 30.6C73.6 471.1 44.7 480 16 480c-6.5 0-12.3-3.9-14.8-9.9c-2.5-6-1.1-12.8 3.4-17.4l0 0 0 0 0 0 0 0 .3-.3c.3-.3 .7-.7 1.3-1.4c1.1-1.2 2.8-3.1 4.9-5.7c4.1-5 9.6-12.4 15.2-21.6c10-16.6 19.5-38.4 21.4-62.9C17.7 326.8 0 285.1 0 240C0 125.1 114.6 32 256 32s256 93.1 256 208z"/></svg>',asteroids:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--! Font Awesome Free 6.4.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2023 Fonticons, Inc. --><path d="M498.1 5.6c10.1 7 15.4 19.1 13.5 31.2l-64 416c-1.5 9.7-7.4 18.2-16 23s-18.9 5.4-28 1.6L284 427.7l-68.5 74.1c-8.9 9.7-22.9 12.9-35.2 8.1S160 493.2 160 480V396.4c0-4 1.5-7.8 4.2-10.7L331.8 202.8c5.8-6.3 5.6-16-.4-22s-15.7-6.4-22-.7L106 360.8 17.7 316.6C7.1 311.3 .3 300.7 0 288.9s5.9-22.8 16.1-28.7l448-256c10.7-6.1 23.9-5.5 34 1.4z"/></svg>',"switch-model":'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--! Font Awesome Free 6.4.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2023 Fonticons, Inc. --><path d="M399 384.2C376.9 345.8 335.4 320 288 320H224c-47.4 0-88.9 25.8-111 64.2c35.2 39.2 86.2 63.8 143 63.8s107.8-24.7 143-63.8zM0 256a256 256 0 1 1 512 0A256 256 0 1 1 0 256zm256 16a72 72 0 1 0 0-144 72 72 0 1 0 0 144z"/></svg>',"switch-texture":'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--! Font Awesome Free 6.4.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2023 Fonticons, Inc. --><path d="M320 64A64 64 0 1 0 192 64a64 64 0 1 0 128 0zm-96 96c-35.3 0-64 28.7-64 64v48c0 17.7 14.3 32 32 32h1.8l11.1 99.5c1.8 16.2 15.5 28.5 31.8 28.5h38.7c16.3 0 30-12.3 31.8-28.5L318.2 304H320c17.7 0 32-14.3 32-32V224c0-35.3-28.7-64-64-64H224zM132.3 394.2c13-2.4 21.7-14.9 19.3-27.9s-14.9-21.7-27.9-19.3c-32.4 5.9-60.9 14.2-82 24.8c-10.5 5.3-20.3 11.7-27.8 19.6C6.4 399.5 0 410.5 0 424c0 21.4 15.5 36.1 29.1 45c14.7 9.6 34.3 17.3 56.4 23.4C130.2 504.7 190.4 512 256 512s125.8-7.3 170.4-19.6c22.1-6.1 41.8-13.8 56.4-23.4c13.7-8.9 29.1-23.6 29.1-45c0-13.5-6.4-24.5-14-32.6c-7.5-7.9-17.3-14.3-27.8-19.6c-21-10.6-49.5-18.9-82-24.8c-13-2.4-25.5 6.3-27.9 19.3s6.3 25.5 19.3 27.9c30.2 5.5 53.7 12.8 69 20.5c3.2 1.6 5.8 3.1 7.9 4.5c3.6 2.4 3.6 7.2 0 9.6c-8.8 5.7-23.1 11.8-43 17.3C374.3 457 318.5 464 256 464s-118.3-7-157.7-17.9c-19.9-5.5-34.2-11.6-43-17.3c-3.6-2.4-3.6-7.2 0-9.6c2.1-1.4 4.8-2.9 7.9-4.5c15.3-7.7 38.8-14.9 69-20.5z"/></svg>',photo:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--! Font Awesome Free 6.4.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2023 Fonticons, Inc. --><path d="M220.6 121.2L271.1 96 448 96v96H333.2c-21.9-15.1-48.5-24-77.2-24s-55.2 8.9-77.2 24H64V128H192c9.9 0 19.7-2.3 28.6-6.8zM0 128V416c0 35.3 28.7 64 64 64H448c35.3 0 64-28.7 64-64V96c0-35.3-28.7-64-64-64H271.1c-9.9 0-19.7 2.3-28.6 6.8L192 64H160V48c0-8.8-7.2-16-16-16H80c-8.8 0-16 7.2-16 16l0 16C28.7 64 0 92.7 0 128zM168 304a88 88 0 1 1 176 0 88 88 0 1 1 -176 0z"/></svg>',info:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--! Font Awesome Free 6.4.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2023 Fonticons, Inc. --><path d="M256 512A256 256 0 1 0 256 0a256 256 0 1 0 0 512zM216 336h24V272H216c-13.3 0-24-10.7-24-24s10.7-24 24-24h48c13.3 0 24 10.7 24 24v88h8c13.3 0 24 10.7 24 24s-10.7 24-24 24H216c-13.3 0-24-10.7-24-24s10.7-24 24-24zm40-208a32 32 0 1 1 0 64 32 32 0 1 1 0-64z"/></svg>',quit:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 384 512"><!--! Font Awesome Free 6.4.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2023 Fonticons, Inc. --><path d="M342.6 150.6c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L192 210.7 86.6 105.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3L146.7 256 41.4 361.4c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0L192 301.3 297.4 406.6c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3L237.3 256 342.6 150.6z"/></svg>'};function E(o){return Array.isArray(o)?o[Math.floor(Math.random()*o.length)]:o}function L(o){return o.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}var P,H,U;function z(){clearTimeout(H),sessionStorage.removeItem("waifu-text"),document.getElementById("waifu-tips")?.classList.remove("waifu-tips-active")}function q(o,e){clearTimeout(H),sessionStorage.setItem("waifu-text",String(e));let t=document.getElementById("waifu-tips");t.innerHTML=o,t.classList.add("waifu-tips-active")}function w(o,e,t){!o||U||Number(sessionStorage.getItem("waifu-text"))>t||(q(E(o),t),H=setTimeout(z,e))}function J(o,e){if(!e){w(L(o),5e3,11);return}U=e,q(L(o),11)}function X(o){let e=document.getElementById("live2d");if(!e)return;let t=P?.find(({selector:n})=>e.closest(n)),i=t?E(t.text):P?void 0:g("指挥官,我在。","Right here, Commander.");i&&(U=o,q(i.replace("{text}",()=>L(e.textContent??"")),11))}function K(o,e){U===o&&(U=void 0,e?z():H=setTimeout(z,1200))}function ue(o){if(location.pathname==="/"){let s=new Date().getHours();for(let{hour:a,text:r}of o){let[c,d=c]=a.split("-").map(Number);if(c<=s&&s<=d)return r}}let e=L(document.title.split(" - ")[0]),t=g(`欢迎阅读<span>「${e}」</span>`,`Welcome to <span>${e}</span>!`);if(!document.referrer)return t;let{hostname:i}=new URL(document.referrer);return i===location.hostname?t:g(`Hello!来自 <span>${L({baidu:"百度",so:"360搜索",google:"谷歌搜索"}[i.split(".")[1]]??i)}</span> 的朋友<br>${t}`,`Hello, visitor from <span>${L(i)}</span>!<br>${t}`)}function me(o){let[e,t]=o.split("/").map(Number);return e*100+t}function Q(o){P=o.click;let e=[...o.message.default],t=new Date,i=(t.getMonth()+1)*100+t.getDate();for(let{date:u,text:v}of o.seasons){let[l,m=l]=u.split("-").map(me);l<=i&&i<=m&&e.push(E(v).replace("{year}",String(t.getFullYear())))}let n=2e4,s=Date.now(),a;function r(){if(document.hidden)return;let u=n-(Date.now()-s);u<=0&&!localStorage.getItem("waifu-display")&&w(e,6e3,9),a=setTimeout(r,u>0?u:n)}let c=()=>{s=Date.now()};window.addEventListener("pointermove",c,{passive:!0}),window.addEventListener("pointerdown",c,{passive:!0}),window.addEventListener("keydown",c),document.hidden||(a=setTimeout(r,n)),w(ue(o.time),7e3,11);let d;for(let u of["mouseover","click"])window.addEventListener(u,v=>{let l=v.target;if(!(l instanceof Element)||v.live2dHandlesCaption)return;let m=u==="click"&&l.closest("#waifu .waifu-model-stage"),p=m?document.getElementById("live2d"):l.closest("#live2d"),y=o[u].find(({selector:C})=>l.closest(C)||m&&p?.closest(C));!y||u==="mouseover"&&y.selector===d||(u==="mouseover"&&(d=y.selector),w(E(y.text).replace("{text}",()=>L(l.textContent??"")),4e3,u==="click"&&p?11:8))});let h=()=>{};h.toString=()=>(w(o.message.console,6e3,9),""),console.log("%c",h),window.addEventListener("copy",()=>w(o.message.copy,6e3,9)),document.addEventListener("visibilitychange",()=>{clearTimeout(a),document.hidden||(c(),a=setTimeout(r,n),localStorage.getItem("waifu-display")||w(o.message.visibilitychange,6e3,9))})}async function T(o){let e=await fetch(o);if(!e.ok)throw new Error(`Failed to load ${o} (HTTP ${e.status})`);return e.json()}var Z="/gh/nova1751/live2d-api@cdn-b3ac5ae545e2/",ee="https://cdn.jsdelivr.net",j=ee+Z,fe=/\/gh\/nova1751\/live2d-api@widget-[^/]+\/?$/,ge=/\/live2dapi-noa(?:@[^/]+)?\/?$/;function te(o){let e=new URL(o,document.baseURI);return!ge.test(e.pathname)&&!fe.test(e.pathname)||/@1\.[^/]+\/?$/.test(e.pathname)?o:(e.hostname==="cdn.jsdmirror.com"?e.origin:ee)+Z}var W=()=>g("我的新衣服好看嘛?","How do you like my new outfit?"),k=o=>Number(localStorage.getItem(o))||0,D=class{constructor(e){this.options=e;this.revision=0;this.loaded=!1;this.useCDN=typeof e.cdnPath=="string";let t=e.modelBaseUrl??(e.cdnPath&&te(e.cdnPath))??e.apiPath;if(typeof t!="string")throw new TypeError("Invalid initWidget argument");this.base=t.endsWith("/")?t:t+"/"}reopen(e){if(this.loaded)window.loadlive2d.show?.(e);else return this.load(void 0,void 0,void 0,e)}cancel(){this.revision++}async fetchCatalog(){let e=this.base+"model_list.json",t=await fetch(e);if(t.status===404&&!this.options.modelBaseUrl&&this.base!==j){let i=await T(j+"model_list.json");return this.base=j,i}if(!t.ok)throw new Error(`Failed to load ${e} (HTTP ${t.status})`);return t.json()}list(){return this.catalog??(this.catalog=this.fetchCatalog().catch(e=>{throw this.catalog=void 0,e}))}async load(e=k("modelId"),t=k("modelTexturesId"),i,n=!1,s=++this.revision,a=!1){let r;if(this.options.modelUrl)r=this.options.modelUrl;else if(this.useCDN){let{models:d}=await this.list();d[e]||(e=0);let h=d[e],u=Array.isArray(h)?h:[h];u[t]||(t=0);let v=a?u[t]:E(u);t=u.indexOf(v),r=this.base+"model/"+v+"/index.json"}else r=this.base+"get/?id="+e+"-"+t;if(s!==this.revision)return;let c=window.loadlive2d("live2d",r,{start:n,locale:this.options.locale,coreUrl:this.options.coreUrl});c&&await c,s===this.revision&&(this.options.modelUrl||(localStorage.setItem("modelId",String(e)),localStorage.setItem("modelTexturesId",String(t))),w(i,4e3,10),this.loaded=!0)}async costume(e){if(this.options.modelUrl||!this.useCDN)return;let t=++this.revision,i=k("modelId"),n=(await this.list()).models[i],a=(Array.isArray(n)?n:[n]).findIndex(r=>new URL(this.base+"model/"+r+"/index.json",document.baseURI).href===e);a>=0&&await this.load(i,a,W(),!1,t,!0)}async nextModel(e=!1){let t=++this.revision,i=k("modelId");if(this.useCDN){let{models:s,messages:a}=await this.list(),r=(i+1)%s.length;return this.load(r,0,g(a[r],"Ready for duty!"),e,t)}let{model:n}=await T(this.base+"switch/?id="+i);return this.load(n.id,0,n.message,e,t)}async nextTexture(e=!1){let t=++this.revision,i=k("modelId"),n=k("modelTexturesId");if(this.useCDN){let a=(await this.list()).models[i],r=Array.isArray(a)?a.length:1;return this.load(i,n,W(),e,t)}let{textures:s}=await T(this.base+"rand_textures/?id="+i+"-"+n);s.id===1&&n===1?w(g("我还没有其他衣服呢!","This is my only outfit so far!"),4e3,10):await this.load(i,s.id,W(),e,t)}};var $=class{constructor(){this.revision=0}begin(e){let t=document.getElementById("waifu"),i=t?.querySelector(".waifu-surface"),n=++this.revision;return t&&(this.still&&!this.still.isConnected&&(i??t).prepend(this.still),t.setAttribute("data-model-loading","")),s=>{if(this.revision!==n||!t)return;let a=document.createElement("canvas");a.className="waifu-model-still",a.setAttribute("aria-hidden","true"),a.width=s.width,a.height=s.height;try{let r=a.getContext("2d");r&&r.drawImage(s,0,0),this.still?.remove(),this.still=r?a:void 0}finally{if(i){let r=e();t.style.setProperty("--waifu-aspect",String(r)),t.toggleAttribute("data-wide-model",r>=1.35)}t.removeAttribute("data-model-loading"),t.hasAttribute("data-initial-framing")&&(t.removeAttribute("data-initial-framing"),document.activeElement?.matches("#waifu-toggle:focus-visible")&&t.querySelector("#waifu-tool button")?.focus({preventScroll:!0}))}}}};var B={scale:1,x:0,y:0},f=128;function O(o,e,t){let i=0;for(let n=0;n<o.length;n++)if(i+=o[n],i>e*t)return n;return o.length-1}function he(o,e,t,i){let n=new Float64Array(f),s=new Float64Array(f),a=f,r=0,c=0;for(let b=0;b<o.length;b++){if(!o[b])continue;let M=Math.floor(b/f);n[b%f]+=o[b],s[M]+=o[b],c+=o[b],a=Math.min(a,M),r=Math.max(r,M+1)}if(!c)return B;a=Math.max(a,O(s,c,.001)-2);let d=O(n,c,.001),h=O(n,c,.999)+1,u=h-d,v=r-a,l=i?Math.max(.7,Math.min(1.9,u/v*.93/.94)):1;i?.(l);let m=Math.min(1,l),p=Math.min(1,1/l),y=Math.min(.93*f*p/v,.94*f*m/u,5/e.scale),C=0,A=0;if(t)for(let b=a+2;b<r;b+=4)for(let M=d+2;M<h;M+=4){if(o[b*f+M]<96)continue;t((M+.5)/f,(b+.5)/f).some(de=>/^(head|face|body|bust|torso)\d*$/i.test(de))&&(C+=M+.5,A++)}let x=A>=3?C/A:O(n,c,.5)+.5,R=.475*f*m/y,le=Math.max(h-R,Math.min(d+R,x));return{scale:e.scale*y,x:(.5-le/f)*y,y:.5-.03*p+(.5-r/f)*y}}function oe(o){let e={scale:.65,x:0,y:0},t=document.createElement("canvas");t.width=t.height=f;let i=t.getContext("2d",{willReadFrequently:!0}),n=new Uint8Array(f*f),s=new Uint8Array(n.length),a=0,r=0,c=0;return{initial:e,measure(d,h){if(!i)return B;let u=performance.now();if(!(u<c)){a++;try{i.clearRect(0,0,f,f),i.drawImage(d,0,0,f,f);let{data:v}=i.getImageData(0,0,f,f),l=0;for(let m=0;m<n.length;m++){let p=v[4*m+3];s[m]=p>=24?p:0,s[m]&&l++}l>=16&&(n.set(s),r++,c=u+80)}catch{return B}if(!(r<3&&a<10))return r?he(n,e,h,o):B}}}}var ne=["fairy","doll","adjutant","npc","squad","background"],ie=["default","normal","destroy"];function N(o,e){let t=o.indexOf(e);return t<0?o.length:t}function pe(o,e){let t=new Intl.Collator("en",{numeric:!0}),i=o.map(n=>{let[s,a,r,c]=n.split("/"),d=e[[s,a,r].join("/")],h=r==="base"?-1:d??(s==="fairy"&&/^\d+$/.test(r)?Number(r):Number.MAX_SAFE_INTEGER);return{id:n,category:s,character:a,version:r,form:c,order:h}});return i.sort((n,s)=>N(ne,n.category)-N(ne,s.category)||t.compare(n.category,s.category)||t.compare(n.character,s.character)||n.order-s.order||t.compare(n.version,s.version)||N(ie,n.form)-N(ie,s.form)||t.compare(n.form,s.form)),i.map(n=>n.id)}async function se(o,e,t="zh-CN"){let i=new URL(o,document.baseURI),n=await fetch(i);if(!n.ok)throw new Error("Cannot load catalog: HTTP "+n.status);let s=await n.json();if(s.schemaVersion!==1||!s.models||!s.sources)throw new Error("Unsupported model catalog");let a=new Map,r=Object.keys(s.models).filter(l=>(!e||!l.startsWith("other/"))&&s.models[l].some(m=>m.manifest)),c=e?s.presentation:void 0,d=t==="en"?c?.en:c,h=l=>{let m=c?.aliases[l];return m&&r.includes(m)?m:l},u=e?pe(r.filter(l=>h(l)===l),c?.outfitOrder??{}):r;function v(l,m){if(e&&!r.includes(l))throw new Error("Model outside the selected collection: "+l);let p=s.models[l]?.find(x=>x.manifest&&(!m||x.source===m));if(!p?.manifest)throw new Error("No model manifest for "+l);let y=new URL(s.sources[p.source].baseUrl,n.url||i);i.hostname==="cdn.jsdmirror.com"&&y.hostname==="cdn.jsdelivr.net"&&y.pathname.startsWith("/gh/nova1751/live2d-api@cdn-")&&(y.hostname=i.hostname);let C=x=>new URL(x.split("/").map(encodeURIComponent).join("/"),y).href,A;if(p.dialogue){let x=a.get(p.source);x||(x=new Map((s.audio?.[p.source]??[]).map(R=>[R.toUpperCase(),C(R)])),a.set(p.source,x)),A={captions:t==="en"?void 0:d?.captions,url:C(p.dialogue),audio:x}}return{captions:d?.captions,modelUrl:C(p.manifest),dialogue:A,soundAliases:p.soundAliases}}return{ids:u,visibleId:h,labels:d?.labels??{},resolve:v,legacyIds:s.legacyIds}}var F=class{constructor(e,t){this.url=e;this.options=t;this.sequence=0;this.transition=new $;let i=t.collection?":"+t.collection:"",n="live2d:model:"+e+i,s=a=>a.replace(/(\/gh\/nova1751\/live2d-api)@catalog-[a-f0-9]{16}(\/catalog\/library\.json:girls-frontline)$/,"$1$2");if(this.key=s(n),this.key!==n&&!localStorage.getItem(this.key)){let a=[n,...Object.keys(localStorage)].find(r=>s(r)===this.key&&localStorage.getItem(r));a&&localStorage.setItem(this.key,localStorage.getItem(a))}}open(){return this.library??(this.library=se(this.url,this.options.collection,this.options.locale).catch(e=>{throw this.library=void 0,e}))}async select(e,t){let i=++this.sequence;try{let n=await this.open();if(i!==this.sequence)return;let s=e(n.ids,n.legacyIds,n.visibleId),{modelUrl:a,dialogue:r,soundAliases:c,captions:d}=n.resolve(s),h=1,u=this.options.collection==="girls-frontline"&&!s.startsWith("background/")?oe(l=>{h=l}):void 0,v=this.options.collection?this.transition.begin(()=>h):void 0;await window.loadlive2d("live2d",a,{start:t,locale:this.options.locale,captions:d,framing:u,onPaint:v,coreUrl:this.options.coreUrl,dialogue:r,soundAliases:c}),i===this.sequence&&(this.active=n.visibleId(s),localStorage.setItem(this.key,s),window.dispatchEvent(new CustomEvent("live2d:model",{detail:s})))}catch(n){throw i===this.sequence&&document.getElementById("waifu")?.removeAttribute("data-initial-framing"),n}}load(e,t,i,n=!1){return this.select((s,a,r)=>{let c=localStorage.getItem(this.key);if(this.options.collection)return this.options.modelId??(c&&s.includes(r(c))?c:s[0]);let d=a?.[Number(localStorage.getItem("modelId"))]?.[Number(localStorage.getItem("modelTexturesId"))];return this.options.modelId??(c&&s.includes(r(c))?c:d&&s.includes(d)?d:s[0])},n)}choose(e){return this.select(()=>e,!1)}cancel(){this.sequence++}reopen(e){if(this.active)window.loadlive2d.show?.(e);else return this.load(void 0,void 0,void 0,e)}character(e){return e.split("/").slice(0,2).join("/")}nextModel(e=!1){return this.select(t=>{let i=[...new Set(t.map(s=>this.character(s)))],n=i[(i.indexOf(this.character(this.active??""))+1)%i.length];return t.find(s=>this.character(s)===n)},e)}nextTexture(e=!1){return this.select(t=>{let i=t.filter(n=>this.character(n)===this.character(this.active??t[0]));{let n=i.filter(s=>s!==this.active);return n.length?n[Math.floor(Math.random()*n.length)]:i[0]}return i[(i.indexOf(this.active??"")+1)%i.length]},e)}async costume(e){let t=await this.open(),i=t.ids.find(n=>t.resolve(n).modelUrl===e);i&&await this.select(()=>i,!1)}};var we=document.currentScript,ve=we?.dataset.asteroidsUrl??"https://cdn.jsdelivr.net/gh/nova1751/live2d-api@widget-2.4.5/asteroids.js",I=o=>document.getElementById(o);function S(o){console.error("[Live2D]",o);let e=document.getElementById("waifu-status");e&&(e.textContent=g("加载失败,请检查网络或切换模型后重试。","Could not load the model. Check your connection or try another character."),w(e.textContent,5e3,10))}async function ye(o){if(o==="en"){w(["One step at a time, Commander.","Even on a quiet day, there is something worth noticing."],6e3,9);return}let e=await T("https://v1.hitokoto.cn");w(L(e.hitokoto),6e3,9),setTimeout(()=>{w(`这句一言来自 <span>「${L(String(e.from))}」</span>,是 <span>${L(String(e.creator))}</span> 在 hitokoto.cn 投稿的。`,4e3,9)},6e3)}function be(){if(window.Asteroids)(window.ASTEROIDSPLAYERS??(window.ASTEROIDSPLAYERS=[])).push(new window.Asteroids);else{let o=document.createElement("script");o.src=ve,document.head.appendChild(o)}}var ae;function ce(){clearTimeout(ae),localStorage.removeItem("waifu-display"),I("waifu-toggle").setAttribute("tabindex","-1"),I("waifu-toggle").setAttribute("aria-expanded","true"),I("waifu").style.display="";let o=I("waifu");o.hasAttribute("data-initial-framing")?o.style.bottom="0":setTimeout(()=>{o.style.bottom="0"},0)}function V(o){return o.isTrusted&&!!window.loadlive2d.prepareInteraction?.()}function xe(){let o=I("waifu").contains(document.activeElement);window.loadlive2d.hide?.(),localStorage.setItem("waifu-display",String(Date.now())),w(g("愿你有一天能与重要的人重逢。","I hope you meet the people you miss again."),2e3,11),I("waifu").style.bottom="-500px",ae=setTimeout(()=>{I("waifu").style.display="none";let e=I("waifu-toggle");e.removeAttribute("tabindex"),e.setAttribute("aria-expanded","false"),e.classList.add("waifu-toggle-active"),o&&e.focus()},window.matchMedia("(prefers-reduced-motion: reduce)").matches?0:3e3)}function re(o,e,t=!1){sessionStorage.removeItem("waifu-text");let i=o.collection==="girls-frontline",n='<canvas id="live2d" width="800" height="800"></canvas>';document.body.insertAdjacentHTML("beforeend",`<div id="waifu" lang="${o.locale==="en"?"en":"zh-CN"}"${i?' class="waifu-adaptive"':""}${i&&e instanceof F?" data-initial-framing":""}>
|
|
3
3
|
<div id="waifu-status" role="status" class="waifu-sr-only"></div>
|
|
4
4
|
<div id="waifu-tips"></div>
|
|
5
5
|
${i?`<div class="waifu-viewport"><div class="waifu-surface">${n}</div></div>`:n}
|
|
6
6
|
<div id="waifu-tool"></div>
|
|
7
|
-
</div>`),ce(),window.addEventListener("live2d:dialogue",r=>{let{detail:c,playback:d}=r;typeof c=="string"&&J(c,d)}),window.addEventListener("live2d:preset",r=>{let{playback:c}=r;c&&X(c)}),window.addEventListener("live2d:dialogue-end",r=>{let c=r.detail;c?.playback&&K(c.playback,c.interrupted)}),window.addEventListener("live2d:costume",r=>{let c=r.detail;typeof c=="string"&&e.costume(c).catch(S)});let s={hitokoto:
|
|
7
|
+
</div>`),ce(),window.addEventListener("live2d:dialogue",r=>{let{detail:c,playback:d}=r;typeof c=="string"&&J(c,d)}),window.addEventListener("live2d:preset",r=>{let{playback:c}=r;c&&X(c)}),window.addEventListener("live2d:dialogue-end",r=>{let c=r.detail;c?.playback&&K(c.playback,c.interrupted)}),window.addEventListener("live2d:costume",r=>{let c=r.detail;typeof c=="string"&&e.costume(c).catch(S)});let s={hitokoto:g("听一句话","Hear a quote"),asteroids:g("启动小游戏","Play Asteroids"),"switch-model":g("切换人物","Next character"),"switch-texture":g("切换造型","Next outfit"),photo:g("保存照片","Save a picture"),info:g("项目信息","Project information"),quit:g("收起看板娘","Hide companion")},a={hitokoto:()=>ye(o.locale).catch(S),asteroids:be,"switch-model":r=>e.nextModel(V(r)).catch(S),"switch-texture":r=>e.nextTexture(V(r)).catch(S),photo:()=>{w(g("照好了嘛,是不是很可爱呢?","Did you get my good side?"),6e3,9),!(window.loadlive2d.capture?.()||!window.Live2D)&&(window.Live2D.captureName="photo.png",window.Live2D.captureFrame=!0)},info:()=>window.open("https://github.com/nova1751/live2d-api"),quit:()=>{e.cancel(),xe()}};for(let r of Array.isArray(o.tools)?o.tools:Object.keys(a)){if(o.modelUrl&&(r==="switch-model"||r==="switch-texture")||!Object.prototype.hasOwnProperty.call(a,r))continue;let c=r;I("waifu-tool").insertAdjacentHTML("beforeend",`<button type="button" id="waifu-tool-${c}" aria-label="${s[c]}" title="${s[c]}">${G[c]}</button>`),I("waifu-tool-"+c).addEventListener("click",a[c])}e.load(void 0,void 0,void 0,t).catch(S),T(o.waifuPath).then(Q).catch(S)}window.initWidget=(o,e)=>{let t=typeof o=="string"?{waifuPath:o,apiPath:e}:o;if(document.getElementById("waifu-toggle"))return;_(t.locale),document.body.insertAdjacentHTML("beforeend",`<button type="button" id="waifu-toggle" aria-label="${g("打开看板娘","Show companion")}" aria-controls="waifu"><span>${g("看板娘","Companion")}</span></button>`);let i=I("waifu-toggle");i.setAttribute("aria-expanded","false");let n=t.catalogUrl?new F(t.catalogUrl,t):new D(t);n instanceof F&&Object.defineProperty(window,Symbol.for("live2dapi-noa.selectModel"),{configurable:!0,value:async a=>((i.getAttribute("aria-expanded")==="false"||localStorage.getItem("waifu-display"))&&i.click(),n.choose(a))}),i.addEventListener("click",a=>{let r=V(a);i.classList.remove("waifu-toggle-active"),i.hasAttribute("first-time")?(re(t,n,r),i.removeAttribute("first-time")):(ce(),n.reopen(r)?.catch(S)),a.detail===0&&document.querySelector("#waifu-tool button")?.focus()});let s=Number(localStorage.getItem("waifu-display"));s&&Date.now()-s<=864e5?(i.setAttribute("first-time","true"),setTimeout(()=>i.classList.add("waifu-toggle-active"),0)):re(t,n)};})();
|
|
@@ -8,7 +8,7 @@ const live2d_path = (() => {
|
|
|
8
8
|
return new URL("../../", url).href;
|
|
9
9
|
}
|
|
10
10
|
}
|
|
11
|
-
return "https://cdn.jsdelivr.net/gh/nova1751/live2d-api@widget-2.4.
|
|
11
|
+
return "https://cdn.jsdelivr.net/gh/nova1751/live2d-api@widget-2.4.5/";
|
|
12
12
|
})();
|
|
13
13
|
function loadExternalResource(url, type) {
|
|
14
14
|
let tag;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/*! Live2D API | Generated from src/ | https://github.com/nova1751/live2d-api */
|
|
2
|
-
"use strict";(()=>{var Y="zh-CN";function _(o){Y=o??"zh-CN"}function m(o,e){return Y==="en"?e:o}var G={hitokoto:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--! Font Awesome Free 6.4.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2023 Fonticons, Inc. --><path d="M512 240c0 114.9-114.6 208-256 208c-37.1 0-72.3-6.4-104.1-17.9c-11.9 8.7-31.3 20.6-54.3 30.6C73.6 471.1 44.7 480 16 480c-6.5 0-12.3-3.9-14.8-9.9c-2.5-6-1.1-12.8 3.4-17.4l0 0 0 0 0 0 0 0 .3-.3c.3-.3 .7-.7 1.3-1.4c1.1-1.2 2.8-3.1 4.9-5.7c4.1-5 9.6-12.4 15.2-21.6c10-16.6 19.5-38.4 21.4-62.9C17.7 326.8 0 285.1 0 240C0 125.1 114.6 32 256 32s256 93.1 256 208z"/></svg>',asteroids:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--! Font Awesome Free 6.4.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2023 Fonticons, Inc. --><path d="M498.1 5.6c10.1 7 15.4 19.1 13.5 31.2l-64 416c-1.5 9.7-7.4 18.2-16 23s-18.9 5.4-28 1.6L284 427.7l-68.5 74.1c-8.9 9.7-22.9 12.9-35.2 8.1S160 493.2 160 480V396.4c0-4 1.5-7.8 4.2-10.7L331.8 202.8c5.8-6.3 5.6-16-.4-22s-15.7-6.4-22-.7L106 360.8 17.7 316.6C7.1 311.3 .3 300.7 0 288.9s5.9-22.8 16.1-28.7l448-256c10.7-6.1 23.9-5.5 34 1.4z"/></svg>',"switch-model":'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--! Font Awesome Free 6.4.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2023 Fonticons, Inc. --><path d="M399 384.2C376.9 345.8 335.4 320 288 320H224c-47.4 0-88.9 25.8-111 64.2c35.2 39.2 86.2 63.8 143 63.8s107.8-24.7 143-63.8zM0 256a256 256 0 1 1 512 0A256 256 0 1 1 0 256zm256 16a72 72 0 1 0 0-144 72 72 0 1 0 0 144z"/></svg>',"switch-texture":'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--! Font Awesome Free 6.4.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2023 Fonticons, Inc. --><path d="M320 64A64 64 0 1 0 192 64a64 64 0 1 0 128 0zm-96 96c-35.3 0-64 28.7-64 64v48c0 17.7 14.3 32 32 32h1.8l11.1 99.5c1.8 16.2 15.5 28.5 31.8 28.5h38.7c16.3 0 30-12.3 31.8-28.5L318.2 304H320c17.7 0 32-14.3 32-32V224c0-35.3-28.7-64-64-64H224zM132.3 394.2c13-2.4 21.7-14.9 19.3-27.9s-14.9-21.7-27.9-19.3c-32.4 5.9-60.9 14.2-82 24.8c-10.5 5.3-20.3 11.7-27.8 19.6C6.4 399.5 0 410.5 0 424c0 21.4 15.5 36.1 29.1 45c14.7 9.6 34.3 17.3 56.4 23.4C130.2 504.7 190.4 512 256 512s125.8-7.3 170.4-19.6c22.1-6.1 41.8-13.8 56.4-23.4c13.7-8.9 29.1-23.6 29.1-45c0-13.5-6.4-24.5-14-32.6c-7.5-7.9-17.3-14.3-27.8-19.6c-21-10.6-49.5-18.9-82-24.8c-13-2.4-25.5 6.3-27.9 19.3s6.3 25.5 19.3 27.9c30.2 5.5 53.7 12.8 69 20.5c3.2 1.6 5.8 3.1 7.9 4.5c3.6 2.4 3.6 7.2 0 9.6c-8.8 5.7-23.1 11.8-43 17.3C374.3 457 318.5 464 256 464s-118.3-7-157.7-17.9c-19.9-5.5-34.2-11.6-43-17.3c-3.6-2.4-3.6-7.2 0-9.6c2.1-1.4 4.8-2.9 7.9-4.5c15.3-7.7 38.8-14.9 69-20.5z"/></svg>',photo:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--! Font Awesome Free 6.4.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2023 Fonticons, Inc. --><path d="M220.6 121.2L271.1 96 448 96v96H333.2c-21.9-15.1-48.5-24-77.2-24s-55.2 8.9-77.2 24H64V128H192c9.9 0 19.7-2.3 28.6-6.8zM0 128V416c0 35.3 28.7 64 64 64H448c35.3 0 64-28.7 64-64V96c0-35.3-28.7-64-64-64H271.1c-9.9 0-19.7 2.3-28.6 6.8L192 64H160V48c0-8.8-7.2-16-16-16H80c-8.8 0-16 7.2-16 16l0 16C28.7 64 0 92.7 0 128zM168 304a88 88 0 1 1 176 0 88 88 0 1 1 -176 0z"/></svg>',info:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--! Font Awesome Free 6.4.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2023 Fonticons, Inc. --><path d="M256 512A256 256 0 1 0 256 0a256 256 0 1 0 0 512zM216 336h24V272H216c-13.3 0-24-10.7-24-24s10.7-24 24-24h48c13.3 0 24 10.7 24 24v88h8c13.3 0 24 10.7 24 24s-10.7 24-24 24H216c-13.3 0-24-10.7-24-24s10.7-24 24-24zm40-208a32 32 0 1 1 0 64 32 32 0 1 1 0-64z"/></svg>',quit:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 384 512"><!--! Font Awesome Free 6.4.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2023 Fonticons, Inc. --><path d="M342.6 150.6c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L192 210.7 86.6 105.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3L146.7 256 41.4 361.4c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0L192 301.3 297.4 406.6c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3L237.3 256 342.6 150.6z"/></svg>'};function U(o){return Array.isArray(o)?o[Math.floor(Math.random()*o.length)]:o}function L(o){return o.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}var B,H,E;function P(){clearTimeout(H),sessionStorage.removeItem("waifu-text"),document.getElementById("waifu-tips")?.classList.remove("waifu-tips-active")}function z(o,e){clearTimeout(H),sessionStorage.setItem("waifu-text",String(e));let t=document.getElementById("waifu-tips");t.innerHTML=o,t.classList.add("waifu-tips-active")}function v(o,e,t){!o||E||Number(sessionStorage.getItem("waifu-text"))>t||(z(U(o),t),H=setTimeout(P,e))}function J(o,e){if(!e){v(L(o),5e3,11);return}E=e,z(L(o),11)}function X(o){let e=document.getElementById("live2d");if(!e)return;let t=B?.find(({selector:n})=>e.closest(n)),i=t?U(t.text):B?void 0:m("指挥官,我在。","Right here, Commander.");i&&(E=o,z(i.replace("{text}",()=>L(e.textContent??"")),11))}function K(o,e){E===o&&(E=void 0,e?P():H=setTimeout(P,1200))}function de(o){if(location.pathname==="/"){let s=new Date().getHours();for(let{hour:a,text:r}of o){let[c,d=c]=a.split("-").map(Number);if(c<=s&&s<=d)return r}}let e=L(document.title.split(" - ")[0]),t=m(`欢迎阅读<span>「${e}」</span>`,`Welcome to <span>${e}</span>!`);if(!document.referrer)return t;let{hostname:i}=new URL(document.referrer);return i===location.hostname?t:m(`Hello!来自 <span>${L({baidu:"百度",so:"360搜索",google:"谷歌搜索"}[i.split(".")[1]]??i)}</span> 的朋友<br>${t}`,`Hello, visitor from <span>${L(i)}</span>!<br>${t}`)}function ue(o){let[e,t]=o.split("/").map(Number);return e*100+t}function Q(o){B=o.click;let e=[...o.message.default],t=new Date,i=(t.getMonth()+1)*100+t.getDate();for(let{date:u,text:p}of o.seasons){let[l,h=l]=u.split("-").map(ue);l<=i&&i<=h&&e.push(U(p).replace("{year}",String(t.getFullYear())))}let n=2e4,s=Date.now(),a;function r(){if(document.hidden)return;let u=n-(Date.now()-s);u<=0&&!localStorage.getItem("waifu-display")&&v(e,6e3,9),a=setTimeout(r,u>0?u:n)}let c=()=>{s=Date.now()};window.addEventListener("pointermove",c,{passive:!0}),window.addEventListener("pointerdown",c,{passive:!0}),window.addEventListener("keydown",c),document.hidden||(a=setTimeout(r,n)),v(de(o.time),7e3,11);let d;for(let u of["mouseover","click"])window.addEventListener(u,p=>{let l=p.target;if(!(l instanceof Element)||p.live2dHandlesCaption)return;let h=u==="click"&&l.closest("#waifu .waifu-model-stage"),w=h?document.getElementById("live2d"):l.closest("#live2d"),y=o[u].find(({selector:C})=>l.closest(C)||h&&w?.closest(C));!y||u==="mouseover"&&y.selector===d||(u==="mouseover"&&(d=y.selector),v(U(y.text).replace("{text}",()=>L(l.textContent??"")),4e3,u==="click"&&w?11:8))});let f=()=>{};f.toString=()=>(v(o.message.console,6e3,9),""),console.log("%c",f),window.addEventListener("copy",()=>v(o.message.copy,6e3,9)),document.addEventListener("visibilitychange",()=>{clearTimeout(a),document.hidden||(c(),a=setTimeout(r,n),localStorage.getItem("waifu-display")||v(o.message.visibilitychange,6e3,9))})}async function T(o){let e=await fetch(o);if(!e.ok)throw new Error(`Failed to load ${o} (HTTP ${e.status})`);return e.json()}var Z="/gh/nova1751/live2d-api@cdn-b3ac5ae545e2/",ee="https://cdn.jsdelivr.net",j=ee+Z,me=/\/gh\/nova1751\/live2d-api@widget-[^/]+\/?$/,ge=/\/live2dapi-noa(?:@[^/]+)?\/?$/;function te(o){let e=new URL(o,document.baseURI);return!ge.test(e.pathname)&&!me.test(e.pathname)||/@1\.[^/]+\/?$/.test(e.pathname)?o:(e.hostname==="cdn.jsdmirror.com"?e.origin:ee)+Z}var q=()=>m("我的新衣服好看嘛?","How do you like my new outfit?"),k=o=>Number(localStorage.getItem(o))||0,D=class{constructor(e){this.options=e;this.revision=0;this.loaded=!1;this.useCDN=typeof e.cdnPath=="string";let t=e.modelBaseUrl??(e.cdnPath&&te(e.cdnPath))??e.apiPath;if(typeof t!="string")throw new TypeError("Invalid initWidget argument");this.base=t.endsWith("/")?t:t+"/"}reopen(e){if(this.loaded)window.loadlive2d.show?.(e);else return this.load(void 0,void 0,void 0,e)}cancel(){this.revision++}async fetchCatalog(){let e=this.base+"model_list.json",t=await fetch(e);if(t.status===404&&!this.options.modelBaseUrl&&this.base!==j){let i=await T(j+"model_list.json");return this.base=j,i}if(!t.ok)throw new Error(`Failed to load ${e} (HTTP ${t.status})`);return t.json()}list(){return this.catalog??(this.catalog=this.fetchCatalog().catch(e=>{throw this.catalog=void 0,e}))}async load(e=k("modelId"),t=k("modelTexturesId"),i,n=!1,s=++this.revision,a=!1){let r;if(this.options.modelUrl)r=this.options.modelUrl;else if(this.useCDN){let{models:d}=await this.list();d[e]||(e=0);let f=d[e],u=Array.isArray(f)?f:[f];u[t]||(t=0);let p=u[t];t=u.indexOf(p),r=this.base+"model/"+p+"/index.json"}else r=this.base+"get/?id="+e+"-"+t;if(s!==this.revision)return;let c=window.loadlive2d("live2d",r,{start:n,locale:this.options.locale,coreUrl:this.options.coreUrl});c&&await c,s===this.revision&&(this.options.modelUrl||(localStorage.setItem("modelId",String(e)),localStorage.setItem("modelTexturesId",String(t))),v(i,4e3,10),this.loaded=!0)}async costume(e){if(this.options.modelUrl||!this.useCDN)return;let t=++this.revision,i=k("modelId"),n=(await this.list()).models[i],a=(Array.isArray(n)?n:[n]).findIndex(r=>new URL(this.base+"model/"+r+"/index.json",document.baseURI).href===e);a>=0&&await this.load(i,a,q(),!1,t,!0)}async nextModel(e=!1){let t=++this.revision,i=k("modelId");if(this.useCDN){let{models:s,messages:a}=await this.list(),r=(i+1)%s.length;return this.load(r,0,m(a[r],"Ready for duty!"),e,t)}let{model:n}=await T(this.base+"switch/?id="+i);return this.load(n.id,0,n.message,e,t)}async nextTexture(e=!1){let t=++this.revision,i=k("modelId"),n=k("modelTexturesId");if(this.useCDN){let a=(await this.list()).models[i],r=Array.isArray(a)?a.length:1;return this.load(i,(n+1)%r,q(),e,t)}let{textures:s}=await T(this.base+"rand_textures/?id="+i+"-"+n);s.id===1&&n===1?v(m("我还没有其他衣服呢!","This is my only outfit so far!"),4e3,10):await this.load(i,s.id,q(),e,t)}};var $=class{constructor(){this.revision=0}begin(e){let t=document.getElementById("waifu"),i=t?.querySelector(".waifu-surface"),n=++this.revision;return t&&(this.still&&!this.still.isConnected&&(i??t).prepend(this.still),t.setAttribute("data-model-loading","")),s=>{if(this.revision!==n||!t)return;let a=document.createElement("canvas");a.className="waifu-model-still",a.setAttribute("aria-hidden","true"),a.width=s.width,a.height=s.height;try{let r=a.getContext("2d");r&&r.drawImage(s,0,0),this.still?.remove(),this.still=r?a:void 0}finally{if(i){let r=e();t.style.setProperty("--waifu-aspect",String(r)),t.toggleAttribute("data-wide-model",r>=1.35)}t.removeAttribute("data-model-loading")}}}};var O={scale:1,x:0,y:0},g=128;function W(o,e,t){let i=0;for(let n=0;n<o.length;n++)if(i+=o[n],i>e*t)return n;return o.length-1}function fe(o,e,t,i){let n=new Float64Array(g),s=g,a=0,r=0;for(let x=0;x<o.length;x++){if(!o[x])continue;let M=Math.floor(x/g);n[x%g]+=o[x],r+=o[x],s=Math.min(s,M),a=Math.max(a,M+1)}if(!r)return O;let c=W(n,r,.001),d=W(n,r,.999)+1,f=d-c,u=a-s,p=i?Math.max(.7,Math.min(1.9,f/u*.93/.94)):1;i?.(p);let l=Math.min(1,p),h=Math.min(1,1/p),w=Math.min(.93*g*h/u,.94*g*l/f,5/e.scale),y=0,C=0;if(t)for(let x=s+2;x<a;x+=4)for(let M=c+2;M<d;M+=4){if(o[x*g+M]<96)continue;t((M+.5)/g,(x+.5)/g).some(le=>/^(head|face|body|bust|torso)\d*$/i.test(le))&&(y+=M+.5,C++)}let R=C>=3?y/C:W(n,r,.5)+.5,b=.475*g*l/w,F=Math.max(d-b,Math.min(c+b,R));return{scale:e.scale*w,x:(.5-F/g)*w,y:.5-.03*h+(.5-a/g)*w}}function oe(o){let e={scale:.65,x:0,y:0},t=document.createElement("canvas");t.width=t.height=g;let i=t.getContext("2d",{willReadFrequently:!0}),n=new Uint8Array(g*g),s=0,a=0,r=0;return{initial:e,measure(c,d){if(!i)return O;let f=performance.now();if(!(f<r)){s++;try{i.clearRect(0,0,g,g),i.drawImage(c,0,0,g,g);let{data:u}=i.getImageData(0,0,g,g),p=0;for(let l=0;l<n.length;l++){let h=u[4*l+3];h<24||(n[l]=Math.max(n[l],h),p++)}p>=16&&(a++,r=f+80)}catch{return O}if(!(a<3&&s<10))return a?fe(n,e,d,o):O}}}}var ne=["fairy","doll","adjutant","npc","squad","background"],ie=["default","normal","destroy"];function N(o,e){let t=o.indexOf(e);return t<0?o.length:t}function he(o,e){let t=new Intl.Collator("en",{numeric:!0}),i=o.map(n=>{let[s,a,r,c]=n.split("/"),d=e[[s,a,r].join("/")],f=r==="base"?-1:d??(s==="fairy"&&/^\d+$/.test(r)?Number(r):Number.MAX_SAFE_INTEGER);return{id:n,category:s,character:a,version:r,form:c,order:f}});return i.sort((n,s)=>N(ne,n.category)-N(ne,s.category)||t.compare(n.category,s.category)||t.compare(n.character,s.character)||n.order-s.order||t.compare(n.version,s.version)||N(ie,n.form)-N(ie,s.form)||t.compare(n.form,s.form)),i.map(n=>n.id)}async function se(o,e,t="zh-CN"){let i=new URL(o,document.baseURI),n=await fetch(i);if(!n.ok)throw new Error("Cannot load catalog: HTTP "+n.status);let s=await n.json();if(s.schemaVersion!==1||!s.models||!s.sources)throw new Error("Unsupported model catalog");let a=new Map,r=Object.keys(s.models).filter(l=>(!e||!l.startsWith("other/"))&&s.models[l].some(h=>h.manifest)),c=e?s.presentation:void 0,d=t==="en"?c?.en:c,f=l=>{let h=c?.aliases[l];return h&&r.includes(h)?h:l},u=e?he(r.filter(l=>f(l)===l),c?.outfitOrder??{}):r;function p(l,h){if(e&&!r.includes(l))throw new Error("Model outside the selected collection: "+l);let w=s.models[l]?.find(b=>b.manifest&&(!h||b.source===h));if(!w?.manifest)throw new Error("No model manifest for "+l);let y=new URL(s.sources[w.source].baseUrl,n.url||i);i.hostname==="cdn.jsdmirror.com"&&y.hostname==="cdn.jsdelivr.net"&&y.pathname.startsWith("/gh/nova1751/live2d-api@cdn-")&&(y.hostname=i.hostname);let C=b=>new URL(b.split("/").map(encodeURIComponent).join("/"),y).href,R;if(w.dialogue){let b=a.get(w.source);b||(b=new Map((s.audio?.[w.source]??[]).map(F=>[F.toUpperCase(),C(F)])),a.set(w.source,b)),R={captions:t==="en"?void 0:d?.captions,url:C(w.dialogue),audio:b}}return{captions:d?.captions,modelUrl:C(w.manifest),dialogue:R,soundAliases:w.soundAliases}}return{ids:u,visibleId:f,labels:d?.labels??{},resolve:p,legacyIds:s.legacyIds}}var A=class{constructor(e,t){this.url=e;this.options=t;this.sequence=0;this.transition=new $;let i=t.collection?":"+t.collection:"",n="live2d:model:"+e+i,s=a=>a.replace(/(\/gh\/nova1751\/live2d-api)@catalog-[a-f0-9]{16}(\/catalog\/library\.json:girls-frontline)$/,"$1$2");if(this.key=s(n),this.key!==n&&!localStorage.getItem(this.key)){let a=[n,...Object.keys(localStorage)].find(r=>s(r)===this.key&&localStorage.getItem(r));a&&localStorage.setItem(this.key,localStorage.getItem(a))}}open(){return this.library??(this.library=se(this.url,this.options.collection,this.options.locale).catch(e=>{throw this.library=void 0,e}))}async select(e,t){let i=++this.sequence,n=await this.open();if(i!==this.sequence)return;let s=e(n.ids,n.legacyIds,n.visibleId),{modelUrl:a,dialogue:r,soundAliases:c,captions:d}=n.resolve(s),f=1,u=this.options.collection==="girls-frontline"&&!s.startsWith("background/")?oe(l=>{f=l}):void 0,p=this.options.collection?this.transition.begin(()=>f):void 0;await window.loadlive2d("live2d",a,{start:t,locale:this.options.locale,captions:d,framing:u,onPaint:p,coreUrl:this.options.coreUrl,dialogue:r,soundAliases:c}),i===this.sequence&&(this.active=n.visibleId(s),localStorage.setItem(this.key,s),window.dispatchEvent(new CustomEvent("live2d:model",{detail:s})))}load(e,t,i,n=!1){return this.select((s,a,r)=>{let c=localStorage.getItem(this.key);if(this.options.collection)return this.options.modelId??(c&&s.includes(r(c))?c:s[0]);let d=a?.[Number(localStorage.getItem("modelId"))]?.[Number(localStorage.getItem("modelTexturesId"))];return this.options.modelId??(c&&s.includes(r(c))?c:d&&s.includes(d)?d:s[0])},n)}choose(e){return this.select(()=>e,!1)}cancel(){this.sequence++}reopen(e){if(this.active)window.loadlive2d.show?.(e);else return this.load(void 0,void 0,void 0,e)}character(e){return e.split("/").slice(0,2).join("/")}nextModel(e=!1){return this.select(t=>{let i=[...new Set(t.map(s=>this.character(s)))],n=i[(i.indexOf(this.character(this.active??""))+1)%i.length];return t.find(s=>this.character(s)===n)},e)}nextTexture(e=!1){return this.select(t=>{let i=t.filter(n=>this.character(n)===this.character(this.active??t[0]));return i[(i.indexOf(this.active??"")+1)%i.length]},e)}async costume(e){let t=await this.open(),i=t.ids.find(n=>t.resolve(n).modelUrl===e);i&&await this.select(()=>i,!1)}};var pe=document.currentScript,we=pe?.dataset.asteroidsUrl??"https://cdn.jsdelivr.net/gh/nova1751/live2d-api@widget-2.4.3/asteroids.js",I=o=>document.getElementById(o);function S(o){console.error("[Live2D]",o);let e=document.getElementById("waifu-status");e&&(e.textContent=m("加载失败,请检查网络或切换模型后重试。","Could not load the model. Check your connection or try another character."),v(e.textContent,5e3,10))}async function ve(o){if(o==="en"){v(["One step at a time, Commander.","Even on a quiet day, there is something worth noticing."],6e3,9);return}let e=await T("https://v1.hitokoto.cn");v(L(e.hitokoto),6e3,9),setTimeout(()=>{v(`这句一言来自 <span>「${L(String(e.from))}」</span>,是 <span>${L(String(e.creator))}</span> 在 hitokoto.cn 投稿的。`,4e3,9)},6e3)}function ye(){if(window.Asteroids)(window.ASTEROIDSPLAYERS??(window.ASTEROIDSPLAYERS=[])).push(new window.Asteroids);else{let o=document.createElement("script");o.src=we,document.head.appendChild(o)}}var ae;function ce(){clearTimeout(ae),localStorage.removeItem("waifu-display"),I("waifu-toggle").setAttribute("tabindex","-1"),I("waifu-toggle").setAttribute("aria-expanded","true"),I("waifu").style.display="",setTimeout(()=>{I("waifu").style.bottom="0"},0)}function V(o){return o.isTrusted&&!!window.loadlive2d.prepareInteraction?.()}function be(){let o=I("waifu").contains(document.activeElement);window.loadlive2d.hide?.(),localStorage.setItem("waifu-display",String(Date.now())),v(m("愿你有一天能与重要的人重逢。","I hope you meet the people you miss again."),2e3,11),I("waifu").style.bottom="-500px",ae=setTimeout(()=>{I("waifu").style.display="none";let e=I("waifu-toggle");e.removeAttribute("tabindex"),e.setAttribute("aria-expanded","false"),e.classList.add("waifu-toggle-active"),o&&e.focus()},window.matchMedia("(prefers-reduced-motion: reduce)").matches?0:3e3)}function re(o,e,t=!1){sessionStorage.removeItem("waifu-text");let i=o.collection==="girls-frontline",n='<canvas id="live2d" width="800" height="800"></canvas>';document.body.insertAdjacentHTML("beforeend",`<div id="waifu" lang="${o.locale==="en"?"en":"zh-CN"}"${i?' class="waifu-adaptive"':""}>
|
|
2
|
+
"use strict";(()=>{var Y="zh-CN";function _(o){Y=o??"zh-CN"}function g(o,e){return Y==="en"?e:o}var G={hitokoto:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--! Font Awesome Free 6.4.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2023 Fonticons, Inc. --><path d="M512 240c0 114.9-114.6 208-256 208c-37.1 0-72.3-6.4-104.1-17.9c-11.9 8.7-31.3 20.6-54.3 30.6C73.6 471.1 44.7 480 16 480c-6.5 0-12.3-3.9-14.8-9.9c-2.5-6-1.1-12.8 3.4-17.4l0 0 0 0 0 0 0 0 .3-.3c.3-.3 .7-.7 1.3-1.4c1.1-1.2 2.8-3.1 4.9-5.7c4.1-5 9.6-12.4 15.2-21.6c10-16.6 19.5-38.4 21.4-62.9C17.7 326.8 0 285.1 0 240C0 125.1 114.6 32 256 32s256 93.1 256 208z"/></svg>',asteroids:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--! Font Awesome Free 6.4.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2023 Fonticons, Inc. --><path d="M498.1 5.6c10.1 7 15.4 19.1 13.5 31.2l-64 416c-1.5 9.7-7.4 18.2-16 23s-18.9 5.4-28 1.6L284 427.7l-68.5 74.1c-8.9 9.7-22.9 12.9-35.2 8.1S160 493.2 160 480V396.4c0-4 1.5-7.8 4.2-10.7L331.8 202.8c5.8-6.3 5.6-16-.4-22s-15.7-6.4-22-.7L106 360.8 17.7 316.6C7.1 311.3 .3 300.7 0 288.9s5.9-22.8 16.1-28.7l448-256c10.7-6.1 23.9-5.5 34 1.4z"/></svg>',"switch-model":'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--! Font Awesome Free 6.4.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2023 Fonticons, Inc. --><path d="M399 384.2C376.9 345.8 335.4 320 288 320H224c-47.4 0-88.9 25.8-111 64.2c35.2 39.2 86.2 63.8 143 63.8s107.8-24.7 143-63.8zM0 256a256 256 0 1 1 512 0A256 256 0 1 1 0 256zm256 16a72 72 0 1 0 0-144 72 72 0 1 0 0 144z"/></svg>',"switch-texture":'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--! Font Awesome Free 6.4.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2023 Fonticons, Inc. --><path d="M320 64A64 64 0 1 0 192 64a64 64 0 1 0 128 0zm-96 96c-35.3 0-64 28.7-64 64v48c0 17.7 14.3 32 32 32h1.8l11.1 99.5c1.8 16.2 15.5 28.5 31.8 28.5h38.7c16.3 0 30-12.3 31.8-28.5L318.2 304H320c17.7 0 32-14.3 32-32V224c0-35.3-28.7-64-64-64H224zM132.3 394.2c13-2.4 21.7-14.9 19.3-27.9s-14.9-21.7-27.9-19.3c-32.4 5.9-60.9 14.2-82 24.8c-10.5 5.3-20.3 11.7-27.8 19.6C6.4 399.5 0 410.5 0 424c0 21.4 15.5 36.1 29.1 45c14.7 9.6 34.3 17.3 56.4 23.4C130.2 504.7 190.4 512 256 512s125.8-7.3 170.4-19.6c22.1-6.1 41.8-13.8 56.4-23.4c13.7-8.9 29.1-23.6 29.1-45c0-13.5-6.4-24.5-14-32.6c-7.5-7.9-17.3-14.3-27.8-19.6c-21-10.6-49.5-18.9-82-24.8c-13-2.4-25.5 6.3-27.9 19.3s6.3 25.5 19.3 27.9c30.2 5.5 53.7 12.8 69 20.5c3.2 1.6 5.8 3.1 7.9 4.5c3.6 2.4 3.6 7.2 0 9.6c-8.8 5.7-23.1 11.8-43 17.3C374.3 457 318.5 464 256 464s-118.3-7-157.7-17.9c-19.9-5.5-34.2-11.6-43-17.3c-3.6-2.4-3.6-7.2 0-9.6c2.1-1.4 4.8-2.9 7.9-4.5c15.3-7.7 38.8-14.9 69-20.5z"/></svg>',photo:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--! Font Awesome Free 6.4.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2023 Fonticons, Inc. --><path d="M220.6 121.2L271.1 96 448 96v96H333.2c-21.9-15.1-48.5-24-77.2-24s-55.2 8.9-77.2 24H64V128H192c9.9 0 19.7-2.3 28.6-6.8zM0 128V416c0 35.3 28.7 64 64 64H448c35.3 0 64-28.7 64-64V96c0-35.3-28.7-64-64-64H271.1c-9.9 0-19.7 2.3-28.6 6.8L192 64H160V48c0-8.8-7.2-16-16-16H80c-8.8 0-16 7.2-16 16l0 16C28.7 64 0 92.7 0 128zM168 304a88 88 0 1 1 176 0 88 88 0 1 1 -176 0z"/></svg>',info:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><!--! Font Awesome Free 6.4.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2023 Fonticons, Inc. --><path d="M256 512A256 256 0 1 0 256 0a256 256 0 1 0 0 512zM216 336h24V272H216c-13.3 0-24-10.7-24-24s10.7-24 24-24h48c13.3 0 24 10.7 24 24v88h8c13.3 0 24 10.7 24 24s-10.7 24-24 24H216c-13.3 0-24-10.7-24-24s10.7-24 24-24zm40-208a32 32 0 1 1 0 64 32 32 0 1 1 0-64z"/></svg>',quit:'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 384 512"><!--! Font Awesome Free 6.4.0 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License) Copyright 2023 Fonticons, Inc. --><path d="M342.6 150.6c12.5-12.5 12.5-32.8 0-45.3s-32.8-12.5-45.3 0L192 210.7 86.6 105.4c-12.5-12.5-32.8-12.5-45.3 0s-12.5 32.8 0 45.3L146.7 256 41.4 361.4c-12.5 12.5-12.5 32.8 0 45.3s32.8 12.5 45.3 0L192 301.3 297.4 406.6c12.5 12.5 32.8 12.5 45.3 0s12.5-32.8 0-45.3L237.3 256 342.6 150.6z"/></svg>'};function U(o){return Array.isArray(o)?o[Math.floor(Math.random()*o.length)]:o}function L(o){return o.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}var P,H,R;function z(){clearTimeout(H),sessionStorage.removeItem("waifu-text"),document.getElementById("waifu-tips")?.classList.remove("waifu-tips-active")}function q(o,e){clearTimeout(H),sessionStorage.setItem("waifu-text",String(e));let t=document.getElementById("waifu-tips");t.innerHTML=o,t.classList.add("waifu-tips-active")}function w(o,e,t){!o||R||Number(sessionStorage.getItem("waifu-text"))>t||(q(U(o),t),H=setTimeout(z,e))}function J(o,e){if(!e){w(L(o),5e3,11);return}R=e,q(L(o),11)}function X(o){let e=document.getElementById("live2d");if(!e)return;let t=P?.find(({selector:n})=>e.closest(n)),i=t?U(t.text):P?void 0:g("指挥官,我在。","Right here, Commander.");i&&(R=o,q(i.replace("{text}",()=>L(e.textContent??"")),11))}function K(o,e){R===o&&(R=void 0,e?z():H=setTimeout(z,1200))}function ue(o){if(location.pathname==="/"){let s=new Date().getHours();for(let{hour:a,text:r}of o){let[c,d=c]=a.split("-").map(Number);if(c<=s&&s<=d)return r}}let e=L(document.title.split(" - ")[0]),t=g(`欢迎阅读<span>「${e}」</span>`,`Welcome to <span>${e}</span>!`);if(!document.referrer)return t;let{hostname:i}=new URL(document.referrer);return i===location.hostname?t:g(`Hello!来自 <span>${L({baidu:"百度",so:"360搜索",google:"谷歌搜索"}[i.split(".")[1]]??i)}</span> 的朋友<br>${t}`,`Hello, visitor from <span>${L(i)}</span>!<br>${t}`)}function me(o){let[e,t]=o.split("/").map(Number);return e*100+t}function Q(o){P=o.click;let e=[...o.message.default],t=new Date,i=(t.getMonth()+1)*100+t.getDate();for(let{date:u,text:v}of o.seasons){let[l,m=l]=u.split("-").map(me);l<=i&&i<=m&&e.push(U(v).replace("{year}",String(t.getFullYear())))}let n=2e4,s=Date.now(),a;function r(){if(document.hidden)return;let u=n-(Date.now()-s);u<=0&&!localStorage.getItem("waifu-display")&&w(e,6e3,9),a=setTimeout(r,u>0?u:n)}let c=()=>{s=Date.now()};window.addEventListener("pointermove",c,{passive:!0}),window.addEventListener("pointerdown",c,{passive:!0}),window.addEventListener("keydown",c),document.hidden||(a=setTimeout(r,n)),w(ue(o.time),7e3,11);let d;for(let u of["mouseover","click"])window.addEventListener(u,v=>{let l=v.target;if(!(l instanceof Element)||v.live2dHandlesCaption)return;let m=u==="click"&&l.closest("#waifu .waifu-model-stage"),p=m?document.getElementById("live2d"):l.closest("#live2d"),y=o[u].find(({selector:C})=>l.closest(C)||m&&p?.closest(C));!y||u==="mouseover"&&y.selector===d||(u==="mouseover"&&(d=y.selector),w(U(y.text).replace("{text}",()=>L(l.textContent??"")),4e3,u==="click"&&p?11:8))});let h=()=>{};h.toString=()=>(w(o.message.console,6e3,9),""),console.log("%c",h),window.addEventListener("copy",()=>w(o.message.copy,6e3,9)),document.addEventListener("visibilitychange",()=>{clearTimeout(a),document.hidden||(c(),a=setTimeout(r,n),localStorage.getItem("waifu-display")||w(o.message.visibilitychange,6e3,9))})}async function T(o){let e=await fetch(o);if(!e.ok)throw new Error(`Failed to load ${o} (HTTP ${e.status})`);return e.json()}var Z="/gh/nova1751/live2d-api@cdn-b3ac5ae545e2/",ee="https://cdn.jsdelivr.net",j=ee+Z,fe=/\/gh\/nova1751\/live2d-api@widget-[^/]+\/?$/,ge=/\/live2dapi-noa(?:@[^/]+)?\/?$/;function te(o){let e=new URL(o,document.baseURI);return!ge.test(e.pathname)&&!fe.test(e.pathname)||/@1\.[^/]+\/?$/.test(e.pathname)?o:(e.hostname==="cdn.jsdmirror.com"?e.origin:ee)+Z}var W=()=>g("我的新衣服好看嘛?","How do you like my new outfit?"),E=o=>Number(localStorage.getItem(o))||0,D=class{constructor(e){this.options=e;this.revision=0;this.loaded=!1;this.useCDN=typeof e.cdnPath=="string";let t=e.modelBaseUrl??(e.cdnPath&&te(e.cdnPath))??e.apiPath;if(typeof t!="string")throw new TypeError("Invalid initWidget argument");this.base=t.endsWith("/")?t:t+"/"}reopen(e){if(this.loaded)window.loadlive2d.show?.(e);else return this.load(void 0,void 0,void 0,e)}cancel(){this.revision++}async fetchCatalog(){let e=this.base+"model_list.json",t=await fetch(e);if(t.status===404&&!this.options.modelBaseUrl&&this.base!==j){let i=await T(j+"model_list.json");return this.base=j,i}if(!t.ok)throw new Error(`Failed to load ${e} (HTTP ${t.status})`);return t.json()}list(){return this.catalog??(this.catalog=this.fetchCatalog().catch(e=>{throw this.catalog=void 0,e}))}async load(e=E("modelId"),t=E("modelTexturesId"),i,n=!1,s=++this.revision,a=!1){let r;if(this.options.modelUrl)r=this.options.modelUrl;else if(this.useCDN){let{models:d}=await this.list();d[e]||(e=0);let h=d[e],u=Array.isArray(h)?h:[h];u[t]||(t=0);let v=u[t];t=u.indexOf(v),r=this.base+"model/"+v+"/index.json"}else r=this.base+"get/?id="+e+"-"+t;if(s!==this.revision)return;let c=window.loadlive2d("live2d",r,{start:n,locale:this.options.locale,coreUrl:this.options.coreUrl});c&&await c,s===this.revision&&(this.options.modelUrl||(localStorage.setItem("modelId",String(e)),localStorage.setItem("modelTexturesId",String(t))),w(i,4e3,10),this.loaded=!0)}async costume(e){if(this.options.modelUrl||!this.useCDN)return;let t=++this.revision,i=E("modelId"),n=(await this.list()).models[i],a=(Array.isArray(n)?n:[n]).findIndex(r=>new URL(this.base+"model/"+r+"/index.json",document.baseURI).href===e);a>=0&&await this.load(i,a,W(),!1,t,!0)}async nextModel(e=!1){let t=++this.revision,i=E("modelId");if(this.useCDN){let{models:s,messages:a}=await this.list(),r=(i+1)%s.length;return this.load(r,0,g(a[r],"Ready for duty!"),e,t)}let{model:n}=await T(this.base+"switch/?id="+i);return this.load(n.id,0,n.message,e,t)}async nextTexture(e=!1){let t=++this.revision,i=E("modelId"),n=E("modelTexturesId");if(this.useCDN){let a=(await this.list()).models[i],r=Array.isArray(a)?a.length:1;return this.load(i,(n+1)%r,W(),e,t)}let{textures:s}=await T(this.base+"rand_textures/?id="+i+"-"+n);s.id===1&&n===1?w(g("我还没有其他衣服呢!","This is my only outfit so far!"),4e3,10):await this.load(i,s.id,W(),e,t)}};var $=class{constructor(){this.revision=0}begin(e){let t=document.getElementById("waifu"),i=t?.querySelector(".waifu-surface"),n=++this.revision;return t&&(this.still&&!this.still.isConnected&&(i??t).prepend(this.still),t.setAttribute("data-model-loading","")),s=>{if(this.revision!==n||!t)return;let a=document.createElement("canvas");a.className="waifu-model-still",a.setAttribute("aria-hidden","true"),a.width=s.width,a.height=s.height;try{let r=a.getContext("2d");r&&r.drawImage(s,0,0),this.still?.remove(),this.still=r?a:void 0}finally{if(i){let r=e();t.style.setProperty("--waifu-aspect",String(r)),t.toggleAttribute("data-wide-model",r>=1.35)}t.removeAttribute("data-model-loading"),t.hasAttribute("data-initial-framing")&&(t.removeAttribute("data-initial-framing"),document.activeElement?.matches("#waifu-toggle:focus-visible")&&t.querySelector("#waifu-tool button")?.focus({preventScroll:!0}))}}}};var B={scale:1,x:0,y:0},f=128;function O(o,e,t){let i=0;for(let n=0;n<o.length;n++)if(i+=o[n],i>e*t)return n;return o.length-1}function he(o,e,t,i){let n=new Float64Array(f),s=new Float64Array(f),a=f,r=0,c=0;for(let b=0;b<o.length;b++){if(!o[b])continue;let M=Math.floor(b/f);n[b%f]+=o[b],s[M]+=o[b],c+=o[b],a=Math.min(a,M),r=Math.max(r,M+1)}if(!c)return B;a=Math.max(a,O(s,c,.001)-2);let d=O(n,c,.001),h=O(n,c,.999)+1,u=h-d,v=r-a,l=i?Math.max(.7,Math.min(1.9,u/v*.93/.94)):1;i?.(l);let m=Math.min(1,l),p=Math.min(1,1/l),y=Math.min(.93*f*p/v,.94*f*m/u,5/e.scale),C=0,A=0;if(t)for(let b=a+2;b<r;b+=4)for(let M=d+2;M<h;M+=4){if(o[b*f+M]<96)continue;t((M+.5)/f,(b+.5)/f).some(de=>/^(head|face|body|bust|torso)\d*$/i.test(de))&&(C+=M+.5,A++)}let x=A>=3?C/A:O(n,c,.5)+.5,F=.475*f*m/y,le=Math.max(h-F,Math.min(d+F,x));return{scale:e.scale*y,x:(.5-le/f)*y,y:.5-.03*p+(.5-r/f)*y}}function oe(o){let e={scale:.65,x:0,y:0},t=document.createElement("canvas");t.width=t.height=f;let i=t.getContext("2d",{willReadFrequently:!0}),n=new Uint8Array(f*f),s=new Uint8Array(n.length),a=0,r=0,c=0;return{initial:e,measure(d,h){if(!i)return B;let u=performance.now();if(!(u<c)){a++;try{i.clearRect(0,0,f,f),i.drawImage(d,0,0,f,f);let{data:v}=i.getImageData(0,0,f,f),l=0;for(let m=0;m<n.length;m++){let p=v[4*m+3];s[m]=p>=24?p:0,s[m]&&l++}l>=16&&(n.set(s),r++,c=u+80)}catch{return B}if(!(r<3&&a<10))return r?he(n,e,h,o):B}}}}var ne=["fairy","doll","adjutant","npc","squad","background"],ie=["default","normal","destroy"];function N(o,e){let t=o.indexOf(e);return t<0?o.length:t}function pe(o,e){let t=new Intl.Collator("en",{numeric:!0}),i=o.map(n=>{let[s,a,r,c]=n.split("/"),d=e[[s,a,r].join("/")],h=r==="base"?-1:d??(s==="fairy"&&/^\d+$/.test(r)?Number(r):Number.MAX_SAFE_INTEGER);return{id:n,category:s,character:a,version:r,form:c,order:h}});return i.sort((n,s)=>N(ne,n.category)-N(ne,s.category)||t.compare(n.category,s.category)||t.compare(n.character,s.character)||n.order-s.order||t.compare(n.version,s.version)||N(ie,n.form)-N(ie,s.form)||t.compare(n.form,s.form)),i.map(n=>n.id)}async function se(o,e,t="zh-CN"){let i=new URL(o,document.baseURI),n=await fetch(i);if(!n.ok)throw new Error("Cannot load catalog: HTTP "+n.status);let s=await n.json();if(s.schemaVersion!==1||!s.models||!s.sources)throw new Error("Unsupported model catalog");let a=new Map,r=Object.keys(s.models).filter(l=>(!e||!l.startsWith("other/"))&&s.models[l].some(m=>m.manifest)),c=e?s.presentation:void 0,d=t==="en"?c?.en:c,h=l=>{let m=c?.aliases[l];return m&&r.includes(m)?m:l},u=e?pe(r.filter(l=>h(l)===l),c?.outfitOrder??{}):r;function v(l,m){if(e&&!r.includes(l))throw new Error("Model outside the selected collection: "+l);let p=s.models[l]?.find(x=>x.manifest&&(!m||x.source===m));if(!p?.manifest)throw new Error("No model manifest for "+l);let y=new URL(s.sources[p.source].baseUrl,n.url||i);i.hostname==="cdn.jsdmirror.com"&&y.hostname==="cdn.jsdelivr.net"&&y.pathname.startsWith("/gh/nova1751/live2d-api@cdn-")&&(y.hostname=i.hostname);let C=x=>new URL(x.split("/").map(encodeURIComponent).join("/"),y).href,A;if(p.dialogue){let x=a.get(p.source);x||(x=new Map((s.audio?.[p.source]??[]).map(F=>[F.toUpperCase(),C(F)])),a.set(p.source,x)),A={captions:t==="en"?void 0:d?.captions,url:C(p.dialogue),audio:x}}return{captions:d?.captions,modelUrl:C(p.manifest),dialogue:A,soundAliases:p.soundAliases}}return{ids:u,visibleId:h,labels:d?.labels??{},resolve:v,legacyIds:s.legacyIds}}var k=class{constructor(e,t){this.url=e;this.options=t;this.sequence=0;this.transition=new $;let i=t.collection?":"+t.collection:"",n="live2d:model:"+e+i,s=a=>a.replace(/(\/gh\/nova1751\/live2d-api)@catalog-[a-f0-9]{16}(\/catalog\/library\.json:girls-frontline)$/,"$1$2");if(this.key=s(n),this.key!==n&&!localStorage.getItem(this.key)){let a=[n,...Object.keys(localStorage)].find(r=>s(r)===this.key&&localStorage.getItem(r));a&&localStorage.setItem(this.key,localStorage.getItem(a))}}open(){return this.library??(this.library=se(this.url,this.options.collection,this.options.locale).catch(e=>{throw this.library=void 0,e}))}async select(e,t){let i=++this.sequence;try{let n=await this.open();if(i!==this.sequence)return;let s=e(n.ids,n.legacyIds,n.visibleId),{modelUrl:a,dialogue:r,soundAliases:c,captions:d}=n.resolve(s),h=1,u=this.options.collection==="girls-frontline"&&!s.startsWith("background/")?oe(l=>{h=l}):void 0,v=this.options.collection?this.transition.begin(()=>h):void 0;await window.loadlive2d("live2d",a,{start:t,locale:this.options.locale,captions:d,framing:u,onPaint:v,coreUrl:this.options.coreUrl,dialogue:r,soundAliases:c}),i===this.sequence&&(this.active=n.visibleId(s),localStorage.setItem(this.key,s),window.dispatchEvent(new CustomEvent("live2d:model",{detail:s})))}catch(n){throw i===this.sequence&&document.getElementById("waifu")?.removeAttribute("data-initial-framing"),n}}load(e,t,i,n=!1){return this.select((s,a,r)=>{let c=localStorage.getItem(this.key);if(this.options.collection)return this.options.modelId??(c&&s.includes(r(c))?c:s[0]);let d=a?.[Number(localStorage.getItem("modelId"))]?.[Number(localStorage.getItem("modelTexturesId"))];return this.options.modelId??(c&&s.includes(r(c))?c:d&&s.includes(d)?d:s[0])},n)}choose(e){return this.select(()=>e,!1)}cancel(){this.sequence++}reopen(e){if(this.active)window.loadlive2d.show?.(e);else return this.load(void 0,void 0,void 0,e)}character(e){return e.split("/").slice(0,2).join("/")}nextModel(e=!1){return this.select(t=>{let i=[...new Set(t.map(s=>this.character(s)))],n=i[(i.indexOf(this.character(this.active??""))+1)%i.length];return t.find(s=>this.character(s)===n)},e)}nextTexture(e=!1){return this.select(t=>{let i=t.filter(n=>this.character(n)===this.character(this.active??t[0]));return i[(i.indexOf(this.active??"")+1)%i.length]},e)}async costume(e){let t=await this.open(),i=t.ids.find(n=>t.resolve(n).modelUrl===e);i&&await this.select(()=>i,!1)}};var we=document.currentScript,ve=we?.dataset.asteroidsUrl??"https://cdn.jsdelivr.net/gh/nova1751/live2d-api@widget-2.4.5/asteroids.js",I=o=>document.getElementById(o);function S(o){console.error("[Live2D]",o);let e=document.getElementById("waifu-status");e&&(e.textContent=g("加载失败,请检查网络或切换模型后重试。","Could not load the model. Check your connection or try another character."),w(e.textContent,5e3,10))}async function ye(o){if(o==="en"){w(["One step at a time, Commander.","Even on a quiet day, there is something worth noticing."],6e3,9);return}let e=await T("https://v1.hitokoto.cn");w(L(e.hitokoto),6e3,9),setTimeout(()=>{w(`这句一言来自 <span>「${L(String(e.from))}」</span>,是 <span>${L(String(e.creator))}</span> 在 hitokoto.cn 投稿的。`,4e3,9)},6e3)}function be(){if(window.Asteroids)(window.ASTEROIDSPLAYERS??(window.ASTEROIDSPLAYERS=[])).push(new window.Asteroids);else{let o=document.createElement("script");o.src=ve,document.head.appendChild(o)}}var ae;function ce(){clearTimeout(ae),localStorage.removeItem("waifu-display"),I("waifu-toggle").setAttribute("tabindex","-1"),I("waifu-toggle").setAttribute("aria-expanded","true"),I("waifu").style.display="";let o=I("waifu");o.hasAttribute("data-initial-framing")?o.style.bottom="0":setTimeout(()=>{o.style.bottom="0"},0)}function V(o){return o.isTrusted&&!!window.loadlive2d.prepareInteraction?.()}function xe(){let o=I("waifu").contains(document.activeElement);window.loadlive2d.hide?.(),localStorage.setItem("waifu-display",String(Date.now())),w(g("愿你有一天能与重要的人重逢。","I hope you meet the people you miss again."),2e3,11),I("waifu").style.bottom="-500px",ae=setTimeout(()=>{I("waifu").style.display="none";let e=I("waifu-toggle");e.removeAttribute("tabindex"),e.setAttribute("aria-expanded","false"),e.classList.add("waifu-toggle-active"),o&&e.focus()},window.matchMedia("(prefers-reduced-motion: reduce)").matches?0:3e3)}function re(o,e,t=!1){sessionStorage.removeItem("waifu-text");let i=o.collection==="girls-frontline",n='<canvas id="live2d" width="800" height="800"></canvas>';document.body.insertAdjacentHTML("beforeend",`<div id="waifu" lang="${o.locale==="en"?"en":"zh-CN"}"${i?' class="waifu-adaptive"':""}${i&&e instanceof k?" data-initial-framing":""}>
|
|
3
3
|
<div id="waifu-status" role="status" class="waifu-sr-only"></div>
|
|
4
4
|
<div id="waifu-tips"></div>
|
|
5
5
|
${i?`<div class="waifu-viewport"><div class="waifu-surface">${n}</div></div>`:n}
|
|
6
6
|
<div id="waifu-tool"></div>
|
|
7
|
-
</div>`),ce(),window.addEventListener("live2d:dialogue",r=>{let{detail:c,playback:d}=r;typeof c=="string"&&J(c,d)}),window.addEventListener("live2d:preset",r=>{let{playback:c}=r;c&&X(c)}),window.addEventListener("live2d:dialogue-end",r=>{let c=r.detail;c?.playback&&K(c.playback,c.interrupted)}),window.addEventListener("live2d:costume",r=>{let c=r.detail;typeof c=="string"&&e.costume(c).catch(S)});let s={hitokoto:
|
|
7
|
+
</div>`),ce(),window.addEventListener("live2d:dialogue",r=>{let{detail:c,playback:d}=r;typeof c=="string"&&J(c,d)}),window.addEventListener("live2d:preset",r=>{let{playback:c}=r;c&&X(c)}),window.addEventListener("live2d:dialogue-end",r=>{let c=r.detail;c?.playback&&K(c.playback,c.interrupted)}),window.addEventListener("live2d:costume",r=>{let c=r.detail;typeof c=="string"&&e.costume(c).catch(S)});let s={hitokoto:g("听一句话","Hear a quote"),asteroids:g("启动小游戏","Play Asteroids"),"switch-model":g("切换人物","Next character"),"switch-texture":g("切换造型","Next outfit"),photo:g("保存照片","Save a picture"),info:g("项目信息","Project information"),quit:g("收起看板娘","Hide companion")},a={hitokoto:()=>ye(o.locale).catch(S),asteroids:be,"switch-model":r=>e.nextModel(V(r)).catch(S),"switch-texture":r=>e.nextTexture(V(r)).catch(S),photo:()=>{w(g("照好了嘛,是不是很可爱呢?","Did you get my good side?"),6e3,9),!(window.loadlive2d.capture?.()||!window.Live2D)&&(window.Live2D.captureName="photo.png",window.Live2D.captureFrame=!0)},info:()=>window.open("https://github.com/nova1751/live2d-api"),quit:()=>{e.cancel(),xe()}};for(let r of Array.isArray(o.tools)?o.tools:Object.keys(a)){if(o.modelUrl&&(r==="switch-model"||r==="switch-texture")||!Object.prototype.hasOwnProperty.call(a,r))continue;let c=r;I("waifu-tool").insertAdjacentHTML("beforeend",`<button type="button" id="waifu-tool-${c}" aria-label="${s[c]}" title="${s[c]}">${G[c]}</button>`),I("waifu-tool-"+c).addEventListener("click",a[c])}e.load(void 0,void 0,void 0,t).catch(S),T(o.waifuPath).then(Q).catch(S)}window.initWidget=(o,e)=>{let t=typeof o=="string"?{waifuPath:o,apiPath:e}:o;if(document.getElementById("waifu-toggle"))return;_(t.locale),document.body.insertAdjacentHTML("beforeend",`<button type="button" id="waifu-toggle" aria-label="${g("打开看板娘","Show companion")}" aria-controls="waifu"><span>${g("看板娘","Companion")}</span></button>`);let i=I("waifu-toggle");i.setAttribute("aria-expanded","false");let n=t.catalogUrl?new k(t.catalogUrl,t):new D(t);n instanceof k&&Object.defineProperty(window,Symbol.for("live2dapi-noa.selectModel"),{configurable:!0,value:async a=>((i.getAttribute("aria-expanded")==="false"||localStorage.getItem("waifu-display"))&&i.click(),n.choose(a))}),i.addEventListener("click",a=>{let r=V(a);i.classList.remove("waifu-toggle-active"),i.hasAttribute("first-time")?(re(t,n,r),i.removeAttribute("first-time")):(ce(),n.reopen(r)?.catch(S)),a.detail===0&&document.querySelector("#waifu-tool button")?.focus()});let s=Number(localStorage.getItem("waifu-display"));s&&Date.now()-s<=864e5?(i.setAttribute("first-time","true"),setTimeout(()=>i.classList.add("waifu-toggle-active"),0)):re(t,n)};})();
|
package/package.json
CHANGED
package/widget.mjs
CHANGED