"use strict"; (function (global) { const events = global.TarinaiEvents; if (!events) return; events.on("world:phase", () => { global.audio?.phase?.(); }); function playLogSoundForEntry(entry = {}) { if (!entry || entry.hiddenFromObservation || entry.sound === false || entry.silentAudio) return; const audio = global.audio; if (!audio) return; const kind = entry.kind || "note"; const text = String(entry.text || ""); if (kind === "death") return audio.death?.(); if (kind === "birth") return audio.birth?.(); if (kind === "fight") return /\u6c7a\u7740|\u52dd|\u8ca0|\u899a\u3048/.test(text) ? audio.fightFinish?.() : audio.fight?.(); if (kind === "food") return audio.eat?.(); if (kind === "grass") return audio.play?.("sfx_grass", { category: "ops", minGap: 0.25 }); if (kind === "weather") return audio.phase?.(); if (kind === "relation") return audio.notify?.(); if (kind === "accident") { if (/\u914d\u7f6e|\u7f6e\u3044\u305f|\u8a2d\u7f6e/.test(text)) return audio.place?.(/\u7206\u7af9/.test(text) ? "firecracker" : ""); if (/\u3052\u3093\u3053\u3064/.test(text)) return audio.genkotsuImpact?.(); if (/\u7206\u7af9|\u7206\u767a/.test(text)) return audio.explode?.(); if (/\u77f3/.test(text)) return audio.stoneImpact?.(); if (/\u30dc\u30fc\u30eb/.test(text)) return audio.ballHit?.(); return audio.damage?.(18); } if (kind === "event") { if (/\u5973\u738b\u30a2\u30ea/.test(text)) return audio.queenAnt?.(); if (/\u30a2\u30ea|\u5de3/.test(text)) return audio.antNest?.(); if (/\u75c5|\u767a\u75c5/.test(text)) return audio.disease?.(); if (/\u56de\u5fa9|\u6cbb/.test(text)) return audio.heal?.(); } } events.on("log:entry", (event) => { const detail = event.detail || {}; const worldRef = detail.world || global.world; const entry = detail.entry; if (!entry) return; playLogSoundForEntry(entry); renderLog(worldRef?.logs || []); pushLogNotification(entry); }); events.on("tool:placed", (event) => { const detail = event.detail || {}; if (detail.dropped) global.audio?.place?.(detail.type || detail.item?.type || ""); }); })(typeof window !== "undefined" ? window : globalThis);