// @license magnet:?xt=urn:btih:0b31508aeb0634b347b8270c7bee4d411b5d4109&dn=agpl-3.0.txt AGPL-3.0-or-later // @source: https://gitlab.com/soapbox-pub/ditto/-/tree/f0a3877c import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{qi as t}from"./lucide-icons-BdRF0moN.js";import{t as n}from"./jsx-runtime-By8HlURe.js";import{t as r}from"./utils-BFSTDHdM.js";import{n as i}from"./haptics-Cp_uF-bV.js";import{B as a,V as o,W as s,y as c}from"./blobbi-CLChx8JU.js";import{t as l}from"./purify.es-DCh266OY.js";var u={blinkLeft:`blobbi-blink-left`,blinkRight:`blobbi-blink-right`,blink:`blobbi-blink`,eyeLeft:`blobbi-eye-left`,eyeRight:`blobbi-eye-right`,eye:`blobbi-eye`,gazeLeft:`blobbi-eye-gaze-left`,gazeRight:`blobbi-eye-gaze-right`,gaze:`blobbi-eye-gaze`,eyelidLeft:`blobbi-eyelid-left`,eyelidRight:`blobbi-eyelid-right`,eyelid:`blobbi-eyelid`,effectTrackLeft:`blobbi-eye-effect-track-left`,effectTrackRight:`blobbi-eye-effect-track-right`,effectFixedLeft:`blobbi-eye-effect-fixed-left`,effectFixedRight:`blobbi-eye-effect-fixed-right`,clipRect:`blobbi-blink-clip-rect`,pupil:`blobbi-pupil`,highlight:`blobbi-highlight`,sadHighlight:`blobbi-sad-highlight`,sadWater:`blobbi-sad-water`,starEye:`blobbi-star-eye`,dizzySpiral:`blobbi-dizzy-spiral`,closedEye:`blobbi-closed-eye`},d={cx:`data-eye-cx`,cy:`data-eye-cy`,rx:`data-eye-rx`,ry:`data-eye-ry`,side:`data-eye-side`,clipId:`data-clip-id`,clipTop:`data-clip-top`,clipHeight:`data-clip-height`,legacyCx:`data-cx`,legacyCy:`data-cy`,legacyEyeTop:`data-eye-top`,legacyEyeBottom:`data-eye-bottom`},f=.7,p=2e3,m=5e3,h=.95,g=.2,_=2.4,v=4.5,y=4.5,b=2.7,x=[`#1f2937`,`#374151`,`#1e293b`,`#111827`,`#0f172a`,`#64748b`,`#1e1b4b`,`#0891b2`];function S(e){let t=C(e);return t.length>0?t:w(e)}function C(e){let t=[],n=/class="[^"]*blobbi-eye-(left|right)[^"]*"/g,r,i=new Set;for(;(r=n.exec(e))!==null;){let n=r[1];if(r[0].includes(`blobbi-eye-gaze`)||i.has(n))continue;i.add(n);let a=e.slice(0,r.index),o=a.lastIndexOf(`blobbi-blink`);if(o===-1)continue;let s=a.lastIndexOf(``,o);if(s===-1||c===-1)continue;let l=a.slice(s,c+1),u=l.match(/data-eye-cx="([\d.]+)"/)||l.match(/data-cx="([\d.]+)"/),d=l.match(/data-eye-cy="([\d.]+)"/)||l.match(/data-cy="([\d.]+)"/);if(!u||!d)continue;let f=parseFloat(u[1]),p=parseFloat(d[1]),m=e.slice(r.index,r.index+500).match(/\br="([\d.]+)"/),h=m?parseFloat(m[1]):6,g=l.match(/data-eye-ry="([\d.]+)"/),_=g?parseFloat(g[1]):void 0;t.push({cx:f,cy:p,radius:h,side:n,eyeWhiteRy:_})}return t}function w(e){return T(ee(e)).map(e=>({cx:e.blinkCenterX,cy:e.blinkCenterY,radius:e.pupil.radius,side:e.side}))}function ee(e){let t=/<(circle|ellipse)[^>]*\/>/g,n=[],r;for(;(r=t.exec(e))!==null;){let e=te(r[0]);if(!e)continue;let t=`other`;D(r[0])?t=`pupil`:E(r[0],e.radius)?t=`eye-white`:O(r[0],e.radius)&&(t=`highlight`),n.push({match:r[0],index:r.index,endIndex:r.index+r[0].length,cx:e.cx,cy:e.cy,radius:e.radius,type:t})}return n}function T(e){let t=e.filter(e=>e.type===`pupil`),n=e.filter(e=>e.type===`eye-white`),r=e.filter(e=>e.type===`highlight`);if(t.length===0)return[];let i=[...t].sort((e,t)=>e.cx-t.cx),a=i.length>1?(i[0].cx+i[i.length-1].cx)/2:i[0].cx,o=[],s=new Set,c=new Set;for(let e of t){let t=null,i=15;for(let r of n){if(s.has(r))continue;let n=ne(e.cx,e.cy,r.cx,r.cy);nc.has(t)?!1:ne(e.cx,e.cy,t.cx,t.cy)<15);l.forEach(e=>c.add(e));let u=t||e,d=null;if(t){let e=t.match.match(/rx="(\d+\.?\d*)"/),n=t.match.match(/ry="(\d+\.?\d*)"/),r=t.match.match(/\br="(\d+\.?\d*)"/);if(e&&n)d={rx:parseFloat(e[1]),ry:parseFloat(n[1])};else if(r){let e=parseFloat(r[1]);d={rx:e,ry:e}}}o.push({eyeWhite:t,pupil:e,highlights:l,side:e.cx=8)}function D(e){if(e.includes(`data-blobbi-pupil`)||/fill="url\(#[^"]*[Pp]upil[^"]*\)"/.test(e))return!0;for(let t of x)if(e.includes(`fill="${t}"`)||e.includes(`fill='${t}'`))return!0;return!1}function O(e,t){return(e.includes(`fill="white"`)||e.includes(`fill='white'`)||e.includes(`fill="#fff"`)||e.includes(`fill="#ffffff"`)||e.includes(`fill="#FFF"`)||e.includes(`fill="#FFFFFF"`))&&t<8}function te(e){let t=e.match(/cx="(-?\d+\.?\d*)"/),n=e.match(/cy="(-?\d+\.?\d*)"/);if(!t||!n)return null;let r=parseFloat(t[1]),i=parseFloat(n[1]),a=e.match(/\br="(\d+\.?\d*)"/);if(a)return{cx:r,cy:i,radius:parseFloat(a[1])};let o=e.match(/rx="(\d+\.?\d*)"/),s=e.match(/ry="(\d+\.?\d*)"/);return o&&s?{cx:r,cy:i,radius:(parseFloat(o[1])+parseFloat(s[1]))/2}:null}function ne(e,t,n,r){return Math.sqrt((n-e)**2+(r-t)**2)}function k(e,t,n){let r=e.indexOf(`class="${u.gaze} ${u.gaze}-${t}"`);if(r===-1&&e.indexOf(`class="${u.gaze}-${t}`)===-1||e.lastIndexOf(``,r);if(i===-1)return e;let a=oe(e,i+1,`g`);return a===-1?e:e.slice(0,a)+`\n ${n}\n `+e.slice(a)}function re(e,t,n){let r=RegExp(`(]*class="[^"]*${u.blink}-${t}[^"]*"[^>]*>)([\\s\\S]*?)(]*class="[^"]*${u.eye}-${t}[^"]*"[^>]*>)`,`i`),i=e.match(r);if(!i)return e;let[a,o,s,c]=i,l=`${o}${s}${n}\n ${c}`;return e.replace(a,l)}function A(e,t){let n=t===`both`?[`left`,`right`]:[t];for(let t of n)e=ce(e,t,e=>e.replace(/]*fill="white"[^/]*)\s*\/>/gi,``));return e}function j(e,t){let n=``;return e.includes(``)?e.replace(``,`\n ${n}`):e.replace(/(]*>)/,`$1\n ${n}`)}function ie(e,t){return e.replace(/]*)>/,(e,n)=>n.includes(`class="`)?e.replace(/class="([^"]*)"/,`class="$1 ${t}"`):n.includes(`class='`)?e.replace(/class='([^']*)'/,`class='$1 ${t}'`):``)}function ae(e,t){return e.replace(``,`${t}\n`)}function oe(e,t,n){let r=1,i=t,a=RegExp(`<${n}(?:\\s|>)`,`gi`),o=RegExp(``,`gi`);for(;i0;){a.lastIndex=i,o.lastIndex=i;let t=a.exec(e),n=o.exec(e);if(!n)return-1;if(!t||n.index`,n);if(i===-1)return null;let a=oe(e,i+1,`g`);if(a===-1)return null;let o=a+4;return{openTagStart:r,openTagEnd:i+1,closeTagStart:a,closeTagEnd:o}}function ce(e,t,n){let r=se(e,`class="${u.gaze} ${u.gaze}-${t}"`);if(!r){let r=se(e,`class="${u.gaze}-${t}`);if(!r)return e;let i=n(e.substring(r.openTagEnd,r.closeTagStart));return e.substring(0,r.openTagEnd)+i+e.substring(r.closeTagStart)}let i=n(e.substring(r.openTagEnd,r.closeTagStart));return e.substring(0,r.openTagEnd)+i+e.substring(r.closeTagStart)}var le=/^#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i,ue=/^(?:rgb|rgba|hsl|hsla)\(\s*[\d.,\s%]+\)$/i,de=/^[a-z]{3,24}$/i;function fe(e,t=`#000`){return le.test(e)||ue.test(e)||de.test(e)?e:t}function M(e){let t=e.match(/<(path|circle|ellipse|rect)\s([^>]*data-blobbi-body="true"[^>]*)\/>/);if(t){let e=t[1],n=t[2];return pe(e,n)}let n=e.match(/]*d="([^"]+)"[^>]*fill="url\(#[^"]*[Bb]ody[^"]*\)"[^>]*\/>/);if(n){let e=n[1];return{pathD:e,..._e(e)}}let r=e.match(/\s*]*d="([^"]+)"/);if(r){let e=r[1];return{pathD:e,..._e(e)}}return null}function pe(e,t){if(e===`path`){let e=me(t,`d`);return e?{pathD:e,..._e(e)}:null}if(e===`circle`){let e=N(t,`cx`),n=N(t,`cy`),r=N(t,`r`);return e===null||n===null||r===null?null:he(e,n,r,r)}if(e===`ellipse`){let e=N(t,`cx`),n=N(t,`cy`),r=N(t,`rx`),i=N(t,`ry`);return e===null||n===null||r===null||i===null?null:he(e,n,r,i)}if(e===`rect`){let e=N(t,`x`)??0,n=N(t,`y`)??0,r=N(t,`width`),i=N(t,`height`),a=N(t,`rx`)??0;return r===null||i===null?null:ge(e,n,r,i,a)}return null}function N(e,t){let n=e.match(RegExp(`${t}="([^"]+)"`));if(!n)return null;let r=parseFloat(n[1]);return isNaN(r)?null:r}function me(e,t){let n=e.match(RegExp(`${t}="([^"]+)"`));return n?n[1]:null}function he(e,t,n,r){return{pathD:`M ${e-n} ${t} A ${n} ${r} 0 1 0 ${e+n} ${t} A ${n} ${r} 0 1 0 ${e-n} ${t} Z`,minX:e-n,maxX:e+n,minY:t-r,maxY:t+r,centerX:e,width:n*2,height:r*2}}function ge(e,t,n,r,i){let a=Math.min(i,n/2,r/2),o;return o=a>0?`M ${e+a} ${t} L ${e+n-a} ${t} A ${a} ${a} 0 0 1 ${e+n} ${t+a} L ${e+n} ${t+r-a} A ${a} ${a} 0 0 1 ${e+n-a} ${t+r} L ${e+a} ${t+r} A ${a} ${a} 0 0 1 ${e} ${t+r-a} L ${e} ${t+a} A ${a} ${a} 0 0 1 ${e+a} ${t} Z`:`M ${e} ${t} L ${e+n} ${t} L ${e+n} ${t+r} L ${e} ${t+r} Z`,{pathD:o,minX:e,maxX:e+n,minY:t,maxY:t+r,centerX:e+n/2,width:n,height:r}}function _e(e){let t=e.match(/-?\d+\.?\d*/g)?.map(Number)||[],n=1/0,r=-1/0,i=1/0,a=-1/0;for(let e=0;e`}function Ce(e){if(!e.enabled)return``;let t=e.count??3,n=e.variant??`adult`,r=e.intensity??.6,i=[],a;if(a=n===`adult`&&e.bodyPath?be(e.bodyPath,t,r):n===`baby`?ye.slice(0,t+Math.min(t,3)).map(e=>({...e,weight:e.weight*r})):xe.slice(0,t+Math.min(t,3)).map(e=>({...e,weight:e.weight*r})),a.forEach((e,t)=>{i.push(`${Se(e)}`)}),a.length>=2){let e=a[0],t=a[1],o=n===`baby`?8:16,s=(.08*r).toFixed(2);i.push(``)}return i.join(` `)}function we(e){if(!e.enabled)return``;let t=e.variant??`adult`,n=e.intensity??.6,r=[],i;if(t===`adult`&&e.bodyPath){let{minX:t,maxX:n,maxY:r,width:a,height:o}=e.bodyPath,s=Math.max(1.2,a*.015),c=r-o*.15;i=[{x:t+a*.15,y:c,r:s,delay:0},{x:n-a*.15,y:c-o*.05,r:s*.85,delay:.6},{x:t+a*.4,y:c+o*.08,r:s*.7,delay:1.2}]}else i=t===`baby`?[{x:32,y:79,r:1,delay:0},{x:66,y:77,r:.9,delay:.6},{x:48,y:83,r:.75,delay:1.2}]:[{x:80,y:140,r:1.5,delay:0},{x:120,y:137,r:1.3,delay:.6},{x:98,y:150,r:1.1,delay:1.2}];let a=.35*n;return i.forEach((e,t)=>{r.push(` `)}),r.join(` `)}var Te=[{x:28,y:45,delay:0,drift:-1},{x:72,y:42,delay:1,drift:1},{x:50,y:30,delay:2,drift:-1},{x:38,y:48,delay:2.8,drift:1}],Ee=[{x:58,y:90,delay:0,drift:-1},{x:142,y:85,delay:1,drift:1},{x:100,y:60,delay:2,drift:-1},{x:70,y:95,delay:2.8,drift:1}];function De(e,t,n,r){let i=18*r,a=3.5*r,o=n;return`M ${e} ${t} C ${e+a*o} ${t-i*.15}, ${e-a*o} ${t-i*.35}, ${e+a*.3*o} ${t-i*.5} C ${e+a*o} ${t-i*.65}, ${e-a*o} ${t-i*.85}, ${e} ${t-i}`}function Oe(e){if(!e.enabled)return``;let t=e.count??3,n=e.variant??`adult`,r=[],i=n===`baby`,a=i?1:2,o=i?10:20,s=(i?Te:Ee).slice(0,t),c=i?1.2:2,l=i?2:4;if(s.forEach((e,t)=>{let n=De(e.x,e.y,e.drift,a);r.push(` `)}),e.flies){let t=je(e);t&&r.push(t)}return r.join(` `)}var ke=[{cx:58,cy:80,rx:5,ry:3,dur:2.2,delay:0},{cx:38,cy:78,rx:4.5,ry:2.5,dur:2.8,delay:.5},{cx:50,cy:84,rx:4,ry:2.5,dur:3.2,delay:1}],Ae=[{cx:120,cy:155,rx:10,ry:6,dur:2.2,delay:0},{cx:78,cy:150,rx:9,ry:5,dur:2.8,delay:.5},{cx:100,cy:162,rx:8,ry:5,dur:3.2,delay:1}];function je(e){let t=e.flyCount??2,n=(e.variant??`adult`)===`baby`,r=(n?ke:Ae).slice(0,t),i=n?.8:1.4,a=[];return r.forEach((e,t)=>{let n=`M ${e.cx-e.rx} ${e.cy} A ${e.rx} ${e.ry} 0 1 1 ${e.cx+e.rx} ${e.cy} A ${e.rx} ${e.ry} 0 1 1 ${e.cx-e.rx} ${e.cy} Z`;a.push(` `)}),a.join(` `)}function Me(e,t,n){let{pathD:r,minX:i,maxX:a,minY:o,maxY:s}=e,c=s-o,l=a-i,u=fe(t.color),d=n??Math.random().toString(36).slice(2,8),f=`blobbi-anger-clip-${d}`,p=`blobbi-anger-gradient-${d}`,m=t.level!==void 0&&t.level!==null,h=m?Math.max(0,Math.min(1,t.level)):0,g=t.bottomOpacity??.55,_=t.edgeOpacity??.45;return{defs:m?` `:` `,overlay:` `}}function Ne(e,t={includeWaterFill:!0},n){let r=n||S(e);if(r.length===0)return e;for(let n of r){e=A(e,n.side);let r=Pe(n);if(e=k(e,n.side,r),t.includeWaterFill){let t=Fe(n);e=re(e,n.side,t)}}return e}function Pe(e){let t=e.cx-e.radius*.25,n=e.cy-e.radius*.55,r=e.radius*.4,i=e.cx+e.radius*.15,a=e.cy+e.radius*.35,o=e.radius*.25;return` `}function Fe(e){let t=e.radius*1.35,n=e.radius*1.65,r=e.cy-e.radius*.15,i=r+n*.3,a=r+n*.95,o=t*.85;return` `}function Ie(e,t={points:5,color:`#fbbf24`,scale:.9},n){let r=n||S(e);if(r.length===0)return e;e=ie(e,`blobbi-star-eyes`),e=j(e,` /* Hide original pupil circles */ .blobbi-star-eyes .${u.eye} > circle:not(.${u.starEye} *), .blobbi-star-eyes .${u.eye} > circle[fill]:not([fill="white"]) { opacity: 0; } /* Ensure star elements are visible */ .blobbi-star-eyes .${u.starEye} { opacity: 1; } `);for(let n of r){let r=Re(n,t);e=k(e,n.side,r)}let i=M(e),a=ze(t.color,i);return e=ae(e,` ${a} `),e}function Le(e,t,n,r,i){let a=[],o=-Math.PI/2;for(let s=0;s `}function ze(e,t){let n=t?.centerX??50,r=t?t.minY+t.height/2:50,i=t?t.width/2*1.6:40,a=t?t.height/2*1.5:42,o=t?Math.max(2,t.width*.04):2.5;return[{angle:-90,sizeMul:1,delay:0},{angle:-45,sizeMul:.8,delay:.2},{angle:-135,sizeMul:.85,delay:.4},{angle:0,sizeMul:.9,delay:.15},{angle:180,sizeMul:.75,delay:.5},{angle:30,sizeMul:.7,delay:.35},{angle:150,sizeMul:.65,delay:.45},{angle:60,sizeMul:.6,delay:.1},{angle:120,sizeMul:.7,delay:.25},{angle:-60,sizeMul:.9,delay:.8},{angle:-120,sizeMul:.8,delay:.6}].map(({angle:t,sizeMul:s,delay:c})=>{let l=t*Math.PI/180;return Be(n+Math.cos(l)*i,r+Math.sin(l)*a,o*s,e,c,2+c*.3)}).join(` `)}function Be(e,t,n,r,i,a){return` `}function Ve(e,t={rotationDuration:2},n){let r=n||S(e);if(r.length===0)return e;e=ie(e,`blobbi-dizzy`),e=j(e,` /* Hide normal eyes when dizzy */ .blobbi-dizzy .${u.blink} { opacity: 0; } `);let i=r.map(e=>He(e,t)).join(` `);return e=ae(e,` ${i} `),e}function He(e,t){let n=e.radius*1.2,r=Ue(e.cx,e.cy,n);return` `}function Ue(e,t,n){let r=[];for(let i=0;i<=40;i++){let a=i/40*2*2*Math.PI,o=i/40*n,s=e+o*Math.cos(a),c=t+o*Math.sin(a);i===0?r.push(`M ${s.toFixed(2)} ${c.toFixed(2)}`):r.push(`L ${s.toFixed(2)} ${c.toFixed(2)}`)}return r.join(` `)}function We(e){return Ke(e)||Je(e)}function Ge(e){let t=e.position;return{cx:(t.startX+t.endX)/2,cy:t.controlY}}function Ke(e){let t=e.match(//i);if(!t||t.index===void 0)return null;let n=t.index+t[0].length,r=e.slice(n),i=r.match(/(?:/i);if(!n||n.index===void 0)return null;let r=n.index+n[0].length,i=e.slice(r),a=i.match(/(?: `}function ot(e,t){let n=2.8,r=3.2;return` `}function st(e){let t=(e.startX+e.endX)/2,n=(e.startY+e.endY)/2,r=n+(e.controlY-n)*.55,i=Math.abs(e.endX-e.startX)/2,a=Math.min(9,Math.max(4,i*.18));return{cx:t,cy:r,rx:a,ryEating:a*1.2,ryChewOpen:a*1,ryChewClosed:Math.max(1,a*.2)}}function ct(e){let t=st(e);return``}var lt=.3;function ut(e){let t=st(e),n=lt;return` `}function dt(e,t){return Ze(e,ot(t.cx,t.cy))}var I={group:`blobbi-eyebrow-group`,groupLeft:`blobbi-eyebrow-group-left`,groupRight:`blobbi-eyebrow-group-right`,eyebrow:`blobbi-eyebrow`,eyebrowLeft:`blobbi-eyebrow-left`,eyebrowRight:`blobbi-eyebrow-right`,animated:`blobbi-animated-brows`,bounceKeyframe:`blobbi-eyebrow-bounce`},ft=8;function pt(e,t,n=`adult`,r){return e.map(e=>{let r=e.side===`left`?t.leftEyeOverride:t.rightEyeOverride,i=r?.angle??t.angle,a=r?.offsetY??t.offsetY,o=r?.curve??t.curve,s=r?.strokeWidth??t.strokeWidth,c=r?.color??t.color,l=e.radius*2,u;if(n===`baby`)u=e.cy+a-2;else{let t=e.eyeWhiteRy??ft;u=e.cy-t+(a+ft)}let d=e.side===`left`?i:-i,f=e.cx-l/2,p=e.cx+l/2,m;if(o&&o!==0){let t=o*e.radius,n=e.cx,r=u-t;m=`M ${f} ${u} Q ${n} ${r} ${p} ${u}`}else m=`M ${f} ${u} L ${p} ${u}`;let h=e.side===`left`?I.groupLeft:I.groupRight,g=e.side===`left`?I.eyebrowLeft:I.eyebrowRight;return` `}).join(` `)}function mt(e){let t=e.bounceDuration,n=e.bounceAmount;return` `}function ht(e,t){e=e.replace(/]*)>/,(e,t)=>t.includes(`class="`)?e.replace(/class="([^"]*)"/,`class="$1 ${I.animated}"`):t.includes(`class='`)?e.replace(/class='([^']*)'/,`class='$1 ${I.animated}'`):``);let n=mt(t);return e=e.includes(``)?e.replace(``,``+n):e.replace(/(]*>)/,`$1`+n),e}function gt(e,t){let n=[],r=[],i=t.idPrefix??Math.random().toString(36).slice(2,8),a=t.variant??`adult`,o=a===`adult`?M(e):null;if(t.dirtyMarks?.enabled){let e=Ce({...t.dirtyMarks,variant:a,bodyPath:o??void 0});e&&n.push(e);let r=we({...t.dirtyMarks,variant:a,bodyPath:o??void 0});r&&n.push(r)}if(t.stinkClouds?.enabled){let e=Oe({...t.stinkClouds,variant:a});e&&n.push(e)}if(t.angerRise){let n=M(e);if(n){let a=Me(n,{type:`anger-rise`,color:t.angerRise.color,duration:t.angerRise.duration,level:t.angerRise.level,bottomOpacity:t.angerRise.bottomOpacity,edgeOpacity:t.angerRise.edgeOpacity},i);r.push(a.defs);let o=e.match(/<(?:path|circle|ellipse|rect)\s[^>]*data-blobbi-body="true"[^>]*\/>/)??e.match(/]*d="[^"]*"[^>]*fill="url\(#[^"]*[Bb]ody[^"]*\)"[^>]*\/>/);if(o&&o.index!==void 0){let t=o.index+o[0].length;e=e.slice(0,t)+a.overlay+e.slice(t)}}}if(r.length>0){let t=r.join(` `);e=e.includes(``)?e.replace(``,``+t):e.replace(/(]*>)/,`$1\n ${t}\n `)}if(n.length>0){let t=` ${n.join(` `)} `;e=e.replace(``,t+` `)}return e}var L=e(t(),1),R=n(),_t={neutral:{},sad:{eyes:{wateryEyes:{includeWaterFill:!0}},mouth:{sadMouth:!0},eyebrows:{config:{angle:-18,offsetY:-10,strokeWidth:1.4,color:`#4b5563`,curve:.15}},extras:{tears:{enabled:!0,eye:`alternating`,duration:6,pauseBetween:3}}},boring:{mouth:{droopyMouth:{widthScale:.9,curveScale:.35}},eyebrows:{config:{angle:0,offsetY:-8,strokeWidth:1.2,color:`#6b7280`}}},dirty:{mouth:{droopyMouth:{widthScale:.8,curveScale:.2}},eyebrows:{config:{angle:10,offsetY:-9,strokeWidth:1.3,color:`#6b7280`}},bodyEffects:{dirtMarks:{enabled:!0,count:4,intensity:.65},stinkClouds:{enabled:!0,count:3}}},happy:{},blissful:{eyes:{happyArc:!0},mouth:{bigSmile:{widthScale:1.1,curveScale:1.2}}},angry:{mouth:{sadMouth:!0},eyebrows:{config:{angle:22,offsetY:-9,strokeWidth:2.2,color:`#374151`}},bodyEffects:{angerRise:{color:`#ef4444`,duration:2}}},surprised:{mouth:{roundMouth:{rx:5,ry:6,filled:!0}},eyebrows:{config:{angle:-15,offsetY:-13,strokeWidth:1.4,color:`#4b5563`,curve:.35}}},sleepy:{eyes:{sleepyBlink:{cycleDuration:8}},mouth:{sleepyMouth:!0}},curious:{mouth:{roundMouth:{rx:3,ry:3.5,filled:!0}},eyebrows:{config:{angle:-10,offsetY:-11,strokeWidth:1.3,color:`#4b5563`,curve:.2,rightEyeOverride:{angle:-16,offsetY:-13,curve:.3}}}},dizzy:{eyes:{dizzySpirals:{rotationDuration:2}},mouth:{roundMouth:{rx:4,ry:5,filled:!0}},eyebrows:{config:{angle:-12,offsetY:-11,strokeWidth:1.3,color:`#6b7280`,curve:.2}}},excited:{eyes:{starEyes:{points:5,color:`#fbbf24`,scale:.9}},mouth:{bigSmile:{widthScale:1.15,curveScale:1.2}}},excitedB:{eyes:{starEyes:{points:5,color:`#fbbf24`,scale:.9}},mouth:{roundMouth:{rx:3.5,ry:4,filled:!0}}},mischievous:{eyebrows:{config:{angle:18,offsetY:-10,strokeWidth:2,color:`#374151`},animated:{enabled:!0,bounceDuration:.6,bounceAmount:2.5}},mouth:{smallSmile:{scale:.7}}},adoring:{eyes:{wateryEyes:{includeWaterFill:!1}},mouth:{roundMouth:{rx:2.5,ry:3,filled:!0}}},eating:{mouth:{eatingMouth:!0}},chewing:{mouth:{chewingMouth:!0}},hungry:{eyes:{wateryEyes:{includeWaterFill:!1}},eyebrows:{config:{angle:-14,offsetY:-10,strokeWidth:1.3,color:`#6b7280`,curve:.15}},mouth:{smallSmile:{scale:.75}},extras:{drool:{enabled:!0,side:`right`},foodIcon:{enabled:!0,type:`utensils`}}}};function vt(e){return _t[e]??{}}function yt(e){let t=0;for(let n=0;n{let a=n.cy+n.radius+2,o=a+30,s=r*i,c=i*e.length;return` `}).join(` `);let a;if(t.eye===`both`)a=e;else if(t.eye===`random`){let t=e[n===void 0?0:Math.abs(n)%e.length];a=t?[t]:[]}else{let n=e.find(e=>e.side===t.eye);a=n?[n]:[]}return a.map((e,n)=>{let r=e.cy+e.radius+2,a=r+30,o=n*(t.duration/2);return` `}).join(` `)}function xt(e){let t=e;return` `}function St(e,t){let n=t,r=RegExp(``,`g`);return e.replace(r,(e,t,r,i,a)=>{let o=parseFloat(r),s=parseFloat(a),c=s*.95,l=o+c,d=s-c,f=`${o};${o};${l};${l};${o};${o}`,p=`${s};${s};${d};${d};${s};${s}`,m=`0;0.10;0.35;0.62;0.75;1`;return` `})}function Ct(e){return e.map(e=>{let t=e.radius*1.6,n=e.cx-t/2,r=e.cx+t/2,i=e.radius*.5,a=e.radius*.75,o=e.cy+a;return``}).join(` `)}function wt(){return` z z z `}function Tt(e,t,n,r){e=e.replace(/]*)>/,(e,t)=>t.includes(`class="`)?e.replace(/class="([^"]*)"/,`class="$1 blobbi-sleepy"`):t.includes(`class='`)?e.replace(/class='([^']*)'/,`class='$1 blobbi-sleepy'`):``);let i=xt(r);e=e.includes(``)?e.replace(``,``+i):e.replace(/(]*>)/,`$1`+i),e=St(e,r),n&&(e=dt(e,n));let a=` ${Ct(t)} ${wt()} `;return e=e.replace(``,a+` `),e}function Et(){return` `}function Dt(){return` z z z `}function Ot(e,t){let n=RegExp(``,`g`);e=e.replace(n,(e,t,n,r,i)=>{let a=parseFloat(n),o=parseFloat(i),s=o*.95,c=a+s,l=o-s;return``});let r=` ${t.map(e=>{let t=e.radius*1.6,n=e.cx-t/2,r=e.cx+t/2,i=e.radius*.5,a=e.radius*.75,o=e.cy+a;return``}).join(` `)} `;return e=e.replace(``,r+` `),e}function kt(e,t,n){e=e.replace(/]*)>/,(e,t)=>t.includes(`class="`)?e.replace(/class="([^"]*)"/,`class="$1 blobbi-sleeping"`):t.includes(`class='`)?e.replace(/class='([^']*)'/,`class='$1 blobbi-sleeping'`):``);let r=Et();e=e.includes(``)?e.replace(``,``+r):e.replace(/(]*>)/,`$1`+r);let i=RegExp(``,`g`);e=e.replace(i,(e,t,n,r,i)=>{let a=parseFloat(n),o=parseFloat(i),s=o*.95,c=a+s,l=o-s;return``}),n&&(e=dt(e,n));let a=` ${t.map(e=>{let t=e.radius*1.6,n=e.cx-t/2,r=e.cx+t/2,i=e.radius*.5,a=e.radius*.75,o=e.cy+a;return``}).join(` `)} ${Dt()} `;return e=e.replace(``,a+` `),e}function At(e){return{eyes:{sleepingClosed:!0},mouth:{sleepyMouth:!0},eyebrows:void 0,bodyEffects:e?.bodyEffects,extras:e?.extras?{foodIcon:e.extras.foodIcon}:void 0}}function z(e,t,n,r=`adult`,i,a){if(!t.eyes&&!t.mouth&&!t.eyebrows&&!t.bodyEffects&&!t.extras)return e;let o=S(e),s=We(e),c=s?Ge(s):null,l=[];if(t.extras?.tears?.enabled&&(e=e.includes(``)?e.replace(``,``+` `.replace(/<\/?defs>/g,``)):e.replace(/(]*>)/,`$1 `)),t.eyebrows?.config&&o.length>0&&l.push(pt(o,t.eyebrows.config,r,i)),t.mouth&&s&&(t.mouth.roundMouth?e=F(e,Qe(s.position,t.mouth.roundMouth)):t.mouth.sadMouth?e=F(e,$e(s.position)):t.mouth.smallSmile?e=F(e,et(s.position,t.mouth.smallSmile)):t.mouth.bigSmile?e=F(e,nt(s.position,t.mouth.bigSmile)):t.mouth.droopyMouth?e=F(e,tt(s.position,t.mouth.droopyMouth)):t.mouth.eatingMouth?e=F(e,ct(s.position)):t.mouth.chewingMouth&&(e=F(e,ut(s.position)))),t.eyes&&(t.eyes.wateryEyes&&o.length>0&&(e=Ne(e,{includeWaterFill:t.eyes.wateryEyes.includeWaterFill},o)),t.eyes.dizzySpirals&&o.length>0&&(e=Ve(e,{rotationDuration:t.eyes.dizzySpirals.rotationDuration},o)),t.eyes.starEyes&&o.length>0&&(e=Ie(e,{points:t.eyes.starEyes.points,color:t.eyes.starEyes.color,scale:t.eyes.starEyes.scale},o))),t.extras?.tears?.enabled&&o.length>0){let n=yt(e);l.push(bt(o,t.extras.tears,n))}if(t.eyes?.sleepyBlink&&(e=Tt(e,o,c,t.eyes.sleepyBlink.cycleDuration)),t.eyes?.sleepingClosed&&!t.eyes?.sleepyBlink&&(e=kt(e,o,c)),t.eyes?.happyArc&&!t.eyes?.sleepyBlink&&!t.eyes?.sleepingClosed&&(e=Ot(e,o)),t.eyebrows?.animated?.enabled&&(e=ht(e,t.eyebrows.animated)),t.extras?.drool?.enabled&&s){e=e.includes(``)?e.replace(``,` `):e.replace(/(]*>)/,`$1 `);let n=t.extras.drool.side||`right`,r=rt(s.position,t.mouth,n);l.push(it(r,t.extras.drool))}if(t.extras?.foodIcon?.enabled){let n=r===`adult`?M(e):null;l.push(at({...t.extras.foodIcon,variant:r,bodyPath:n??void 0}))}if(l.length>0){let t=` ${l.join(` `)} `;e=e.replace(``,t+` `)}if(t.bodyEffects){let n={variant:r};t.bodyEffects.dirtMarks?.enabled&&(n.dirtyMarks=t.bodyEffects.dirtMarks),t.bodyEffects.stinkClouds?.enabled&&(n.stinkClouds=t.bodyEffects.stinkClouds),t.bodyEffects.angerRise&&(n.angerRise=t.bodyEffects.angerRise),a&&(n.idPrefix=a),(n.dirtyMarks||n.stinkClouds||n.angerRise)&&(e=gt(e,n))}return e}var jt=0,Mt=0,Nt=!1;function Pt(){if(Nt)return;let e=e=>{jt=e.clientX,Mt=e.clientY},t=e=>{let t=e.touches[0];t&&(jt=t.clientX,Mt=t.clientY)};window.addEventListener(`mousemove`,e,{capture:!0,passive:!0}),window.addEventListener(`touchstart`,t,{capture:!0,passive:!0}),window.addEventListener(`touchmove`,t,{capture:!0,passive:!0}),Nt=!0}function Ft(){return p+Math.random()*(m-p)}function It(e,t){let n=t-e.phaseStartTime;switch(e.phase){case`open`:return 0;case`closing`:{let e=Math.min(n/80,1);return e*e*h}case`closed`:return h;case`opening`:{let e=Math.min(n/120,1);return h*(1-(1-(1-e)*(1-e)))}default:return 0}}function Lt(e,t){let n=t-e.phaseStartTime;switch(e.phase){case`open`:return t>=e.nextBlinkTime?{...e,phase:`closing`,phaseStartTime:t,pendingDoubleBlink:Math.random()=80?{...e,phase:`closed`,phaseStartTime:t}:e;case`closed`:return n>=100?{...e,phase:`opening`,phaseStartTime:t}:e;case`opening`:return n>=120?e.pendingDoubleBlink?{...e,phase:`closing`,phaseStartTime:t,pendingDoubleBlink:!1}:{...e,phase:`open`,phaseStartTime:t,nextBlinkTime:t+Ft()}:e;default:return e}}var Rt=400;function zt(e){let t=e.querySelectorAll(`.${u.blink}`);if(t.length===0)return()=>{};let n=[];if(t.forEach(t=>{let r=t.getAttribute(d.clipId),i=t.getAttribute(d.clipTop)??t.getAttribute(d.legacyEyeTop),a=t.getAttribute(d.clipHeight),o=t.getAttribute(d.side);if(!r||!i||!a)return;let s=e.querySelector(`#${r} rect`);if(!s)return;let c=parseFloat(i),l=parseFloat(a),f=parseFloat(s.getAttribute(`y`)??`0`),p=parseFloat(s.getAttribute(`height`)??`0`),m=o?e.querySelector(`.${u.closedEye}-${o}`):null;n.push({clipRect:s,openY:c,openHeight:l,closedY:f,closedHeight:p,closedEyeLine:m})}),n.length===0)return()=>{};n.forEach(({clipRect:e,openY:t,openHeight:n,closedEyeLine:r})=>{e.setAttribute(`y`,t.toString()),e.setAttribute(`height`,n.toString()),r&&r.setAttribute(`opacity`,`0`)});let r=null,i=null,a=e=>{i===null&&(i=e);let t=e-i,o=Math.min(t/Rt,1),s=o<.5?2*o*o:1-(-2*o+2)**2/2;n.forEach(({clipRect:e,openY:t,openHeight:n,closedY:r,closedHeight:i,closedEyeLine:a})=>{let c=t+(r-t)*s,l=n+(i-n)*s;if(e.setAttribute(`y`,c.toString()),e.setAttribute(`height`,Math.max(.1,l).toString()),a){let e=Math.max(0,(o-.6)/.4);a.setAttribute(`opacity`,e.toString())}}),o<1&&(r=requestAnimationFrame(a))};return r=requestAnimationFrame(a),()=>{r!==null&&cancelAnimationFrame(r)}}var Bt=400;function Vt(e,t){let n=e.querySelectorAll(`.${u.blink}`);if(n.length===0)return t(),()=>{};let r=[];if(n.forEach(t=>{let n=t.getAttribute(d.clipId),i=t.getAttribute(d.clipTop)??t.getAttribute(d.legacyEyeTop),a=t.getAttribute(d.clipHeight);if(!n||!i||!a)return;let o=e.querySelector(`#${n} rect`);if(!o)return;let s=parseFloat(i),c=parseFloat(a),l=c*h,u=s+l,f=c-l;r.push({clipRect:o,openY:s,openHeight:c,closedY:u,closedHeight:f})}),r.length===0)return t(),()=>{};r.forEach(({clipRect:e,closedY:t,closedHeight:n})=>{e.setAttribute(`y`,t.toString()),e.setAttribute(`height`,Math.max(.1,n).toString())});let i=null,a=null,o=!1,s=e=>{a===null&&(a=e);let n=e-a,c=Math.min(n/Bt,1),l=c<.5?2*c*c:1-(-2*c+2)**2/2;r.forEach(({clipRect:e,openY:t,openHeight:n,closedY:r,closedHeight:i})=>{let a=r+(t-r)*l,o=i+(n-i)*l;e.setAttribute(`y`,a.toString()),e.setAttribute(`height`,Math.max(.1,o).toString())}),c<1?i=requestAnimationFrame(s):(o=!0,t())};return i=requestAnimationFrame(s),()=>{i!==null&&cancelAnimationFrame(i),o||t()}}function Ht(e,t={}){let{isSleeping:n=!1,maxMovement:r=2,lookMode:i=`follow-pointer`,disableBlink:a=!1,disableTracking:o=!1}=t,s=(0,L.useRef)(null),c=(0,L.useRef)([]),l=(0,L.useRef)([]),p=(0,L.useRef)([]),m=(0,L.useRef)([]),h=(0,L.useRef)(``),g=(0,L.useRef)(null),_=(0,L.useRef)(n);(0,L.useEffect)(()=>{if(Pt(),n){c.current=[],l.current=[],p.current=[],m.current=[],h.current=``,g.current=null;let t=null,n=!_.current;return _.current=!0,n&&e.current&&(t=zt(e.current)),()=>{s.current&&cancelAnimationFrame(s.current),t?.()}}let t=_.current;_.current=!1;let v=()=>{if(!e.current)return!1;let t=e.current.innerHTML;if(t===h.current&&c.current.length>0)return!0;let n=e.current.querySelectorAll(`.${u.gazeLeft}`),r=e.current.querySelectorAll(`.${u.gazeRight}`),i=e.current.querySelectorAll(`.${u.blinkLeft}`),a=e.current.querySelectorAll(`.${u.blinkRight}`);return n.length===0&&r.length===0?!1:(c.current=Array.from(n),l.current=Array.from(r),p.current=Array.from(i),m.current=Array.from(a),h.current=t,[...c.current,...l.current,...p.current,...m.current].forEach(e=>{e.style.transition=`none`}),!0)},y=0,b=null,x=null,S=t=>{if((c.current.length===0||l.current.length===0)&&!v()){s.current=requestAnimationFrame(S);return}if(e.current&&t-y>=500&&(y=t,e.current.innerHTML!==h.current&&(v(),b=null,x=null)),!e.current){s.current=requestAnimationFrame(S);return}let n=0;if(a||(g.current||={phase:`open`,phaseStartTime:t,nextBlinkTime:t+Ft(),pendingDoubleBlink:!1,scaleY:1},g.current=Lt(g.current,t),n=It(g.current,t)),!o){let t=0,n=0;if(i===`follow-pointer`){let i=e.current.getBoundingClientRect(),a=i.left+i.width/2,o=i.top+i.height/2,s=jt-a,c=Mt-o,l=Math.atan2(c,s);t=Math.cos(l)*r,n=Math.sin(l)*r*f}let a=`translate(${t} ${n})`;a!==b&&(b=a,c.current.forEach(e=>{e.setAttribute(`transform`,a)}),l.current.forEach(e=>{e.setAttribute(`transform`,a)}))}let u=t=>{let r=t.getAttribute(d.clipId),i=t.getAttribute(d.clipTop)??t.getAttribute(d.legacyEyeTop),a=t.getAttribute(d.clipHeight);if(r&&i&&a&&e.current){let t=e.current.querySelector(`#${r} rect`);if(t){if(t.querySelector(`animate`)!==null)return;let e=parseFloat(i),r=parseFloat(a),o=r*n,s=e+o,c=r-o;t.setAttribute(`y`,s.toString()),t.setAttribute(`height`,Math.max(.1,c).toString())}}};n!==x&&(x=n,p.current.forEach(u),m.current.forEach(u)),s.current=requestAnimationFrame(S)},C=null,w=()=>{s.current=requestAnimationFrame(S)};return t&&e.current?C=Vt(e.current,w):w(),()=>{C?.(),s.current&&cancelAnimationFrame(s.current)}},[n,r,i,a,o,e])}function Ut({containerRef:e,externalEyeOffset:t,externalEyeOffsetRef:n,isSleeping:r,variant:i}){let a=(0,L.useRef)(t),o=(0,L.useRef)(null),s=n??a;(0,L.useEffect)(()=>{n||(a.current=t)},[t,n]);let c=!!(t||n);(0,L.useEffect)(()=>{if(!c||r){o.current&&=(cancelAnimationFrame(o.current),null);return}let t=i===`baby`?4:v,n=i===`baby`?4:y,a=i===`baby`?_:b,l=null,d=0,f=r=>{let i=s.current;if(!i||!e.current){o.current=requestAnimationFrame(f);return}let c=i.x*t,p=i.y<0?i.y*n:i.y*a,m=`translate(${Math.round(c*100)/100} ${Math.round(p*100)/100})`;(m!==l||r-d>=500)&&(l=m,d=r,e.current.querySelectorAll(`.${u.gazeLeft}, .${u.gazeRight}`).forEach(e=>{e.setAttribute(`transform`,m)})),o.current=requestAnimationFrame(f)};return o.current=requestAnimationFrame(f),()=>{o.current&&=(cancelAnimationFrame(o.current),null)}},[e,c,r,i])}function Wt(e){return e.state===`sleeping`||e.isSleeping===!0}var Gt=` `,Kt=` Z z z `;function qt(){return Gt}function Jt(){return Kt}function Yt(e,t={}){let{isSleeping:n=!1}=t;return e.lifeStage===`baby`?n?Jt():qt():(console.warn(`resolveBabySvg called with non-baby Blobbi`),Xt())}function Xt(){return` `}function B(e,t){if(!e.startsWith(`#`))return e;let n=parseInt(e.slice(1),16),r=Math.round(2.55*t),i=(n>>16)+r,a=(n>>8&255)+r,o=(n&255)+r;return`#`+(16777216+(i<255?i<1?0:i:255)*65536+(a<255?a<1?0:a:255)*256+(o<255?o<1?0:o:255)).toString(16).slice(1).toUpperCase()}function V(e,t){if(!e.startsWith(`#`))return e;let n=parseInt(e.slice(1),16),r=Math.round(2.55*t),i=Math.max(0,(n>>16)-r),a=Math.max(0,(n>>8&255)-r),o=Math.max(0,(n&255)-r);return`#`+(16777216+i*65536+a*256+o).toString(16).slice(1).toUpperCase()}function Zt(e,t){let n=`b_${t.replace(/[^a-zA-Z0-9_-]/g,`_`)}`,r=/\bid=["']([^"']+)["']/g,i=new Set,a;for(;(a=r.exec(e))!==null;)i.add(a[1]);let o=e;for(let e of i){let t=`${n}_${e}`;o=o.replace(RegExp(`\\bid=["']${H(e)}["']`,`g`),`id="${t}"`),o=o.replace(RegExp(`url\\(#${H(e)}\\)`,`g`),`url(#${t})`),o=o.replace(RegExp(`xlink:href=["']#${H(e)}["']`,`g`),`xlink:href="#${t}"`),o=o.replace(RegExp(`\\bhref=["']#${H(e)}["']`,`g`),`href="#${t}"`)}return o}function H(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function Qt(e){return/\swidth=/.test(e)&&/\sheight=/.test(e)?e:e.replace(/]*)>/,``)}function $t(e,t,n=!1,r){let i=e;return i=Qt(i),!t.baseColor&&!t.secondaryColor&&!t.eyeColor?(r&&(i=Zt(i,r)),i):(t.baseColor&&(i=en(i,t)),t.eyeColor&&!n&&(i=tn(i,t.eyeColor)),r&&(i=Zt(i,r)),i)}function en(e,t){let n=e.match(/]*id=["']blobbiBodyGradient["'][^>]*>([\s\S]*?)<\/radialGradient>/);if(!n||!t.baseColor)return e;let r=``;return r=t.secondaryColor?` `:` `,e.replace(n[0],r)}function tn(e,t){let n=e.match(/]*id=["']blobbiPupilGradient["'][^>]*>([\s\S]*?)<\/radialGradient>/);if(!n)return e;let r=` `;return e.replace(n[0],r)}function nn(e,t,n=!1){return $t(e,{baseColor:t.baseColor,secondaryColor:t.secondaryColor,eyeColor:t.eyeColor},n,t.id)}var rn=l();rn.addHook(`uponSanitizeAttribute`,(e,t)=>{t.attrName.startsWith(`data-`)&&(t.allowedAttributes[t.attrName]=!0)});var an=[`svg`,`g`,`defs`,`path`,`circle`,`ellipse`,`rect`,`line`,`polyline`,`polygon`,`radialGradient`,`linearGradient`,`stop`,`clipPath`,`mask`,`animate`,`animateTransform`,`animateMotion`,`text`,`tspan`,`style`],on=`xmlns.viewBox.preserveAspectRatio.width.height.id.class.fill.stroke.stroke-width.stroke-linecap.stroke-linejoin.stroke-dasharray.stroke-dashoffset.stroke-opacity.fill-opacity.fill-rule.opacity.transform.transform-origin.transform-box.style.clip-path.clip-rule.mask.cx.cy.r.rx.ry.x.y.x1.y1.x2.y2.d.points.offset.stop-color.stop-opacity.gradientUnits.gradientTransform.patternUnits.spreadMethod.fx.fy.attributeName.attributeType.values.keyTimes.keySplines.keyPoints.calcMode.dur.begin.end.repeatCount.repeatDur.fill.from.to.by.type.additive.accumulate.path.text-anchor.dominant-baseline.font-family.font-size.font-weight`.split(`.`),sn=[`script`,`foreignObject`,`iframe`,`embed`,`object`,`use`,`image`,`a`],cn=`onload.onerror.onclick.ondblclick.onmousedown.onmouseup.onmouseover.onmouseout.onmouseenter.onmouseleave.onmousemove.onfocus.onblur.onkeydown.onkeyup.onkeypress.onchange.oninput.onsubmit.onreset.onscroll.onwheel.oncopy.oncut.onpaste.ondrag.ondragend.ondragenter.ondragleave.ondragover.ondragstart.ondrop.onanimationend.onanimationstart.onanimationiteration.ontransitionend.ontransitionstart.ontransitioncancel.onbegin.onend.onrepeat.ontouchstart.ontouchend.ontouchmove.ontouchcancel.href.xlink:href`.split(`.`),ln=512*1024;function un(e){return e.length>ln?``:rn.sanitize(e,{ALLOWED_TAGS:an,ALLOWED_ATTR:on,FORBID_TAGS:sn,FORBID_ATTR:cn,RETURN_DOM:!1,RETURN_DOM_FRAGMENT:!1})}function dn(e,t){let n=e.match(/fill="url\(#([^"]+)\)"/);if(n){let e=n[1];if(/[Ee]ye[Bb]ase/i.test(e))return!1;if(/[Ee]ye[Ww]hite/i.test(e)||/[Ee]ye/i.test(e)&&!/[Bb]ase/i.test(e))return!0}return!!((e.includes(`fill="white"`)||e.includes(`fill='white'`)||e.includes(`fill="#fff"`)||e.includes(`fill="#ffffff"`)||e.includes(`fill="#FFF"`)||e.includes(`fill="#FFFFFF"`))&&t>=8)}function fn(e){if(e.includes(`data-blobbi-skip`))return!1;if(e.includes(`data-blobbi-pupil`)||/fill="url\(#[^"]*[Pp]upil[^"]*\)"/.test(e))return!0;for(let t of x)if(e.includes(`fill="${t}"`)||e.includes(`fill='${t}'`))return!0;return!1}function pn(e,t){return(e.includes(`fill="white"`)||e.includes(`fill='white'`)||e.includes(`fill="#fff"`)||e.includes(`fill="#ffffff"`)||e.includes(`fill="#FFF"`)||e.includes(`fill="#FFFFFF"`))&&t<8}function mn(e){let t=e.match(/cx="(-?\d+\.?\d*)"/),n=e.match(/cy="(-?\d+\.?\d*)"/);if(!t||!n)return null;let r=parseFloat(t[1]),i=parseFloat(n[1]),a=e.match(/\br="(\d+\.?\d*)"/);if(a)return{cx:r,cy:i,radius:parseFloat(a[1])};let o=e.match(/rx="(\d+\.?\d*)"/),s=e.match(/ry="(\d+\.?\d*)"/);return o&&s?{cx:r,cy:i,radius:(parseFloat(o[1])+parseFloat(s[1]))/2}:null}function hn(e,t,n,r){return Math.sqrt((n-e)**2+(r-t)**2)}function gn(e){let t=/<(circle|ellipse)[^>]*\/>/g,n=[],r;for(;(r=t.exec(e))!==null;){let e=mn(r[0]);if(!e)continue;let t=`other`;fn(r[0])?t=`pupil`:dn(r[0],e.radius)?t=`eye-white`:pn(r[0],e.radius)&&(t=`highlight`),n.push({match:r[0],index:r.index,endIndex:r.index+r[0].length,cx:e.cx,cy:e.cy,radius:e.radius,type:t})}return n}function _n(e){let t=e.filter(e=>e.type===`pupil`),n=e.filter(e=>e.type===`eye-white`),r=e.filter(e=>e.type===`highlight`);if(t.length===0)return[];let i=[...t].sort((e,t)=>e.cx-t.cx),a=i.length>1?(i[0].cx+i[i.length-1].cx)/2:i[0].cx,o=[],s=new Set,c=new Set;for(let e of t){let t=null,i=15;for(let r of n){if(s.has(r))continue;let n=hn(e.cx,e.cy,r.cx,r.cy);nc.has(t)?!1:hn(e.cx,e.cy,t.cx,t.cy)<15);l.forEach(e=>c.add(e));let u=t||e,d=null;if(t){let e=t.match.match(/rx="(\d+\.?\d*)"/),n=t.match.match(/ry="(\d+\.?\d*)"/),r=t.match.match(/\br="(\d+\.?\d*)"/);if(e&&n)d={rx:parseFloat(e[1]),ry:parseFloat(n[1])};else if(r){let e=parseFloat(r[1]);d={rx:e,ry:e}}}o.push({eyeWhite:t,pupil:e,highlights:l,side:e.cx`}function yn(e,t){let n=_n(gn(e));if(n.length===0)return e;let r=[],i=[],a=V(t?.baseColor||`#6d28d9`,8),o=(t?.instanceId||Math.random().toString(36).substring(2,8)).replace(/[^a-zA-Z0-9_-]/g,`_`);for(let e of n){let t=[e.pupil,...e.highlights];e.eyeWhite&&t.push(e.eyeWhite);let n=[...t].sort((e,t)=>e.index-t.index);if(n.length===0)continue;let s=n[0],c=[e.pupil,...e.highlights].sort((e,t)=>e.index-t.index).map(e=>e.match).join(` `),l=` ${c} `,d=` ${l} `,f;f=e.eyeWhite?`${e.eyeWhite.match} ${d}`:d;let p=e.eyeWhiteGeometry,m=p?e.blinkCenterY-p.ry:e.blinkCenterY-e.pupil.radius,h=p?e.blinkCenterY+p.ry:e.blinkCenterY+e.pupil.radius,g=p?e.blinkCenterX-p.rx:e.blinkCenterX-e.pupil.radius,_=p?e.blinkCenterX+p.rx:e.blinkCenterX+e.pupil.radius,v=h-m,y=_-g,b=m-2,x=g-2,S=y+4,C=v+4,w=`blobbi-blink-clip-${o}-${e.side}`,ee=e.eyeWhiteGeometry?` data-eye-rx="${e.eyeWhiteGeometry.rx}" data-eye-ry="${e.eyeWhiteGeometry.ry}"`:``,T=` ${f} `,E=T;e.eyeWhiteGeometry&&e.eyeWhite&&(E=vn(e.blinkCenterX,e.blinkCenterY,e.eyeWhiteGeometry.rx,e.eyeWhiteGeometry.ry,e.side,a)+` `+T);let D=` `;i.push(D),r.push({type:`replace`,index:s.index,endIndex:s.endIndex,replacement:E});for(let e=1;et.index-e.index);let s=e;for(let e of r)e.type===`replace`&&e.replacement?s=s.slice(0,e.index)+e.replacement+s.slice(e.endIndex):e.type===`remove`&&(s=s.slice(0,e.index)+s.slice(e.endIndex));if(i.length>0){let e=i.join(` `);s=s.includes(``)?s.replace(``,`\n ${e}`):s.replace(/(]*>)/,`$1\n \n ${e}\n `)}return s}var bn=.1;function xn(e){return(0,L.useMemo)(()=>{if(!e)return``;let{bodyEffects:t,...n}=e;if(!t)return JSON.stringify(n);let{angerRise:r,...i}=t;if(!r)return JSON.stringify({...n,bodyEffects:i});let{level:a,...o}=r;return JSON.stringify({...n,bodyEffects:{...i,angerRise:o}})},[e])}function Sn(e,t,n){let r=n?.bodyEffects?.angerRise?.level;(0,L.useEffect)(()=>{let n=e.current;if(!n||r===void 0)return;let i=`blobbi-anger-gradient-${t}`,a=n.querySelector(`#${CSS.escape(i)}`);if(!a)return;let o=a.querySelectorAll(`stop`);if(o.length<3)return;let s=Math.max(0,r-bn);o[1]?.setAttribute(`offset`,String(s)),o[2]?.setAttribute(`offset`,String(r))},[r,t,e])}function Cn(e){return`${e}-${(0,L.useId)().replace(/[^a-zA-Z0-9]/g,``)}`}function wn({blobbi:e,isSleeping:t,recipe:n,recipeLabel:r,emotion:i=`neutral`,bodyEffects:a,className:o}){let s=xn(n),c=Cn(e.id),l=(0,L.useMemo)(()=>{let t=yn(nn(Yt(e,{isSleeping:!1}),e,!1),{baseColor:e.baseColor,instanceId:c});if(n)t=z(t,n,r??`status`,`baby`,void 0,c);else if(i!==`neutral`){let e=vt(i);t=z(t,e,i,`baby`,void 0,c)}return a&&!n&&(t=gt(t,{...a,idPrefix:a.idPrefix??c})),t},[e.id,e.baseColor,e.secondaryColor,e.eyeColor,e.seed,c,s,r,i,a]);return(0,R.jsx)(`div`,{className:o,dangerouslySetInnerHTML:{__html:(0,L.useMemo)(()=>un(l),[l])}})}function Tn({blobbi:e,reaction:t=`idle`,lookMode:n=`follow-pointer`,disableBlink:i=!1,externalEyeOffset:a,externalEyeOffsetRef:o,renderMode:s=`page`,recipe:c,recipeLabel:l,emotion:u=`neutral`,bodyEffects:d,className:f}){let p=Wt(e),m=(0,L.useRef)(null),h=s===`companion`,g=p?`idle`:t;return Ht(m,{isSleeping:p,maxMovement:2,lookMode:n,disableBlink:i,disableTracking:h}),Ut({containerRef:m,externalEyeOffset:a,externalEyeOffsetRef:o,isSleeping:p,variant:`baby`}),(0,R.jsx)(`div`,{ref:m,className:r(`relative flex items-center justify-center`,!h&&(g===`listening`||g===`swaying`||g===`happy`)&&`animate-blobbi-sway`,!h&&g===`singing`&&`animate-blobbi-bounce`,f),children:(0,R.jsx)(wn,{blobbi:e,isSleeping:p,recipe:c,recipeLabel:l,emotion:u,bodyEffects:d,className:`size-full`})})}var En={bloomi:{base:``,sleeping:`Zzz`},breezy:{base:``,sleeping:`Zzz`},cacti:{base:``,sleeping:`Zzz`},catti:{base:``,sleeping:`Zzz`},cloudi:{base:``,sleeping:`Zzz`},crysti:{base:``,sleeping:`Zzz`},droppi:{base:``,sleeping:`Zzz`},flammi:{base:``,sleeping:`Zzz`},froggi:{base:``,sleeping:`Zzz`},leafy:{base:``,sleeping:`Zzz`},mushie:{base:``,sleeping:`Zzz`},owli:{base:``,sleeping:`Zzz`},pandi:{base:``,sleeping:`Zzz`},rocky:{base:``,sleeping:`Zzz`},rosey:{base:``,sleeping:`Zzz`},starri:{base:``,sleeping:`Zzz`}};function Dn(e){return En[e]?.base??An(e)}function On(e){return En[e]?.sleeping??An(e)}function kn(e,t={}){let{isSleeping:n=!1}=t,r=s(e);return{form:r,svg:n?On(r):Dn(r)}}function An(e){return` ${e} `}function U(e,t,n=`0.3`,r=`0.2`,i){return` `}function W(e,t,n=`0.3`,r=`0.3`){return` `}function G(e,t,n=`0.3`,r=`0.2`,i){return` `}function jn(e,t,n=`0.3`,r=`0.2`,i){return` `}function Mn(e,t){return` `}function K(e,t,n){let r=RegExp(`<(radial|linear)Gradient[^>]*id=["']${t}["'][^>]*>[\\s\\S]*?<\\/(radial|linear)Gradient>`,`i`),i=e.match(r);return i?e.replace(i[0],n):e}function Nn(e,t,n){let r=e;r=K(r,`cattiBody3D`,U(`cattiBody3D`,t,`0.3`,`0.2`,n)),r=K(r,`cattiEar3D`,W(`cattiEar3D`,t));let i=B(t,20);r=K(r,`cattiEarInner`,W(`cattiEarInner`,i,`0.4`,`0.3`));let a=B(t,40);return r=K(r,`cattiTail3D`,` `),r=K(r,`cattiTailHighlight`,W(`cattiTailHighlight`,a,`0.4`,`0.3`)),r}function Pn(e,t,n){let r=e;r=K(r,`droppiBody`,G(`droppiBody`,t,`0.3`,`0.2`,n));let i=B(t,45);return r=K(r,`droppiInner`,W(`droppiInner`,i,`0.4`,`0.3`)),r=K(r,`droppiArm`,W(`droppiArm`,B(t,15))),r=K(r,`droppiLeg`,W(`droppiLeg`,V(t,5),`0.3`,`0.2`)),r=K(r,`droppiDroplet`,W(`droppiDroplet`,B(t,30),`0.5`,`0.5`)),r}function Fn(e,t,n){let r=e;r=K(r,`flammiBody`,G(`flammiBody`,t,`0.3`,`0.2`,n));let i=B(t,25);r=K(r,`flammiInner`,` `);let a=B(t,50);return r=K(r,`flammiCore`,W(`flammiCore`,a,`0.5`,`0.4`)),r=K(r,`flammiArm`,W(`flammiArm`,B(t,10))),r=K(r,`flammiLeg`,W(`flammiLeg`,t,`0.3`,`0.2`)),r=K(r,`flammiEmber`,W(`flammiEmber`,B(t,35),`0.5`,`0.5`)),r}function In(e,t,n){let r=e;r=K(r,`froggiBody3D`,U(`froggiBody3D`,t,`0.3`,`0.2`,n)),r=K(r,`froggiEyeBase3D`,W(`froggiEyeBase3D`,B(t,15)));let i=B(t,20);return r=K(r,`froggiFeet3D`,W(`froggiFeet3D`,i,`0.3`,`0.2`)),r=K(r,`froggiFeetHighlight`,W(`froggiFeetHighlight`,B(i,20),`0.4`,`0.3`)),r=K(r,`froggiToe3D`,` `),r}function Ln(e,t,n){let r=e,i=n??B(t,15),a=n?B(n,20):B(t,25);return r=K(r,`leafyPetal`,` `),r}function Rn(e,t,n){let r=e;return r=K(r,`mushieCap`,G(`mushieCap`,t,`0.3`,`0.2`,n)),r=K(r,`mushieCapHighlight`,W(`mushieCapHighlight`,B(t,25),`0.4`,`0.3`)),r}function zn(e,t,n){let r=e;return r=K(r,`rockyBody`,G(`rockyBody`,t,`0.3`,`0.2`,n)),r=K(r,`rockyInner`,W(`rockyInner`,B(t,35),`0.4`,`0.3`)),r=K(r,`rockyArm`,W(`rockyArm`,t)),r=K(r,`rockyLeg`,W(`rockyLeg`,V(t,10),`0.3`,`0.2`)),r=K(r,`rockyPebble`,W(`rockyPebble`,B(t,15),`0.5`,`0.5`)),r}function Bn(e,t,n){let r=e;return r=K(r,`roseyPetal1`,jn(`roseyPetal1`,t,`0.3`,`0.2`,n)),r=K(r,`roseyPetal2`,W(`roseyPetal2`,B(t,15),`0.4`,`0.3`)),r=K(r,`roseyPetal3`,W(`roseyPetal3`,B(t,30),`0.5`,`0.4`)),r=K(r,`roseyCenter`,W(`roseyCenter`,B(t,10))),r=K(r,`roseyFloatingPetal`,W(`roseyFloatingPetal`,B(t,20),`0.5`,`0.5`)),r}function Vn(e,t,n){let r=e,i=n??B(t,35),a=n?B(n,20):B(t,15);return r=K(r,`starriInner`,` `),r}function Hn(e,t,n){let r=e;return r=K(r,`breezyBody`,G(`breezyBody`,t,`0.3`,`0.2`,n)),r=K(r,`breezyInner`,W(`breezyInner`,B(t,40),`0.4`,`0.3`)),r=K(r,`breezyVein`,` `),r=K(r,`breezyArm`,W(`breezyArm`,B(t,15))),r=K(r,`breezyLeg`,W(`breezyLeg`,t,`0.3`,`0.2`)),r=K(r,`breezyFloating`,W(`breezyFloating`,B(t,25),`0.5`,`0.5`)),r}function Un(e,t,n){let r=e;r=K(r,`bloomiPetal1`,W(`bloomiPetal1`,B(t,30))),r=K(r,`bloomiPetal2`,W(`bloomiPetal2`,B(t,20))),r=K(r,`bloomiPetal3`,W(`bloomiPetal3`,B(t,10))),r=K(r,`bloomiPetal4`,W(`bloomiPetal4`,t)),r=K(r,`bloomiPetal5`,W(`bloomiPetal5`,V(t,10))),r=K(r,`bloomiPetal6`,W(`bloomiPetal6`,V(t,5)));let i=n??B(t,45),a=n?B(n,20):B(t,35);return r=K(r,`bloomiCenter`,` `),r=K(r,`bloomiPollen`,W(`bloomiPollen`,B(t,40),`0.5`,`0.5`)),r}function Wn(e,t,n){let r=e;return r=K(r,`cactiBody`,G(`cactiBody`,t,`0.3`,`0.2`,n)),r=K(r,`cactiArm`,W(`cactiArm`,B(t,10))),r}function Gn(e,t,n){let r=e,i=n??B(t,45),a=n?B(n,20):B(t,30);return r=K(r,`cloudiBody`,` `),r=K(r,`cloudiHighlight`,` `),r=K(r,`cloudiRain`,W(`cloudiRain`,V(t,10),`0.5`,`0.3`)),r}function Kn(e,t,n){let r=e;return r=K(r,`crystiBody`,G(`crystiBody`,t,`0.3`,`0.2`,n)),r=K(r,`crystiInner`,` `),r}function qn(e,t,n){let r=e;return r=K(r,`owliBody3D`,U(`owliBody3D`,t,`0.3`,`0.2`,n)),r=K(r,`owliEar3D`,W(`owliEar3D`,V(t,10),`0.3`,`0.2`)),r=K(r,`owliWing3D`,W(`owliWing3D`,V(t,15),`0.3`,`0.2`)),r=K(r,`owliWingHighlight`,W(`owliWingHighlight`,B(t,10),`0.4`,`0.3`)),r}function Jn(e,t,n){let r=e,i=a(t),s=o(i.h,Math.min(i.s,30),95),c=o(i.h,Math.min(i.s,20),90),l=a(n??t),u=o(l.h,30,20),d=o(l.h,20,27);return r=r.replaceAll(`fill="#f8fafc"`,`fill="${s}"`),r=r.replaceAll(`stroke="#e2e8f0"`,`stroke="${c}"`),r=r.replaceAll(`fill="#1f2937" data-blobbi-skip="true"`,`fill="${u}" data-blobbi-skip="true"`),r=r.replaceAll(`fill="#374151" data-blobbi-skip="true"`,`fill="${d}" data-blobbi-skip="true"`),r=K(r,`pandiArm3D`,` `),r=K(r,`pandiLeg3D`,` `),r=K(r,`pandiNose3D`,` `),r=K(r,`pandiMouth3D`,` `),r=r.replaceAll(`stroke="#1e293b"`,`stroke="${u}"`),r=r.replaceAll(`fill="#1e293b"`,`fill="${u}"`),r}var Yn={bloomi:Un,breezy:Hn,cacti:Wn,catti:Nn,cloudi:Gn,crysti:Kn,droppi:Pn,flammi:Fn,froggi:In,leafy:Ln,mushie:Rn,owli:qn,pandi:Jn,rocky:zn,rosey:Bn,starri:Vn};function Xn(e,t,n,r=!1,i){let a=e;if(a=Qt(a),!n.baseColor&&!n.secondaryColor&&!n.eyeColor)return i&&(a=Zt(a,i)),a;if(n.baseColor){let e=Yn[t];a=e?e(a,n.baseColor,n.secondaryColor):Zn(a,t,n.baseColor)}return n.eyeColor&&!r&&(a=$n(a,t,n.eyeColor)),i&&(a=Zt(a,i)),a}function Zn(e,t,n){let r=e,i=[RegExp(`]*id=["'](${t}Body3D)["'][^>]*>[\\s\\S]*?<\\/radialGradient>`,`i`),RegExp(`]*id=["'](${t}Body)["'][^>]*>[\\s\\S]*?<\\/radialGradient>`,`i`)];for(let e of i){let t=r.match(e);if(t){let e=t[1],i=U(e,n);r=r.replace(t[0],i);break}}return r}var Qn={bloomi:`#1f2937`,breezy:`#1f2937`,cacti:`#1f2937`,cloudi:`#64748b`,crysti:`#1e1b4b`,droppi:`#0891b2`,flammi:`#1f2937`,leafy:`#1f2937`,mushie:`#1f2937`,rocky:`#1f2937`,rosey:`#1f2937`,starri:`#1e1b4b`};function $n(e,t,n){let r=e,i=[RegExp(`]*id=["'](${t}Pupil3D)["'][^>]*>[\\s\\S]*?<\\/radialGradient>`,`i`),RegExp(`]*id=["'](${t}Pupil)["'][^>]*>[\\s\\S]*?<\\/radialGradient>`,`i`)];for(let e of i){let t=r.match(e);if(t){let e=t[1],i=Mn(e,n);return r=r.replace(t[0],i),r}}let a=Qn[t];if(a){let e=r.match(/([\s\S]*?)(?=