import{r as t,j as e,_ as n}from"./vendor-react-Dp9pL_Wn.js";import{u as r}from"./cba0eac33-DiCKjNP1.js";import{g as s,b as i}from"./vendor-ant-cds-BLsR_p72.js";import{a$ as o,P as a,b0 as c,b1 as l}from"./c2ee0272b-DPDuX889.js";function u(t){return{r:parseInt(t.slice(1,3),16),g:parseInt(t.slice(3,5),16),b:parseInt(t.slice(5,7),16)}}const f=u("#141413"),d=u("#dedcd1");function g(t){return Array.isArray(t)&&t.length>=3&&"number"==typeof t[0]&&"number"==typeof t[1]&&"number"==typeof t[2]}function m(t,e){if(Array.isArray(t)){for(const n of t)m(n,e);return}if("object"!=typeof t||null===t)return;const n=t,r=n.ty;if(1===r&&"string"==typeof n.sc&&e({kind:"solid",get:()=>n.sc,set:t=>{n.sc=t}}),("fl"===r||"st"===r)&&"object"==typeof n.c&&null!==n.c){const t=n.c;if(0===t.a&&g(t.k))e({kind:"flat",rgb:t.k});else if(1===t.a&&Array.isArray(t.k))for(const n of t.k)null!==n&&"object"==typeof n&&(g(n.s)&&e({kind:"keyframe",rgb:n.s}),g(n.e)&&e({kind:"keyframe",rgb:n.e}))}for(const s of Object.values(n))m(s,e)}const b=f,p=d;function h(t){const e=t.trim(),n=e.match(/^#([0-9a-f]{3}|[0-9a-f]{6})$/i)?.[1];if(void 0!==n){const t=3===n.length?n.replace(/./g,t=>t+t):n;return{r:parseInt(t.slice(0,2),16),g:parseInt(t.slice(2,4),16),b:parseInt(t.slice(4,6),16)}}const r=e.match(/^rgba?\(\s*([^)]*)\)$/i)?.[1];if(void 0!==r){const t=r.split(/[\s,/]+/).filter(Boolean);if(t.length<3)return null;const e=t.slice(0,3).map(Number);if(e.some(t=>!Number.isFinite(t)||t<0||t>255))return null;const[n,s,i]=e.map(Math.round);return{r:n,g:s,b:i}}return null}function y(t,e){const n=t[0]>1.001||t[1]>1.001||t[2]>1.001?1:255;return Math.abs(t[0]*n-e.r)<=1&&Math.abs(t[1]*n-e.g)<=1&&Math.abs(t[2]*n-e.b)<=1}function v(t,e,n){m(t,t=>{if("solid"===t.kind){const r=h(t.get());if(!r)return;const s=[r.r,r.g,r.b],i=y(s,b)?e:y(s,p)?n:null;return void(i&&t.set(`#${[i.r,i.g,i.b].map(t=>t.toString(16).padStart(2,"0")).join("")}`))}!function(t,e,n){const r=y(t,b)?e:y(t,p)?n:null;r&&(t[0]=r.r/255,t[1]=r.g/255,t[2]=r.b/255)}(t.rgb,e,n)})}let k;async function j(t){const e=await t();return"default"in e?e.default:e}function A({asset:u,still:f,size:d="md",highlightFill:g="default",alt:m,className:b,style:p,...y}){const A="number"==typeof d?d:o[d],I=s(),[S,E]=t.useState(null),[$,w]=t.useState(null),x=l(g),M=r(`pictogram-highlight-${x}`),[O,_]=t.useState(!1),F=t.useRef(!1),P=t.useRef(null),R=t.useRef(void 0),[N,C]=t.useState(!1);t.useEffect(()=>{if(!S||I)return;const t=new IntersectionObserver(t=>{const e=t[t.length-1];F.current=e.isIntersecting,_(e.isIntersecting);const n=P.current;n&&(e.isIntersecting?n.play():n.pause())});return t.observe(S),()=>t.disconnect()},[S,I]);const[D,L]=t.useState(null),z=t.useCallback(t=>{const e=getComputedStyle(t),n=e.color,r=e.getPropertyValue(`--cds-pictogram-highlight-${x}`).trim()||M,s=`${n}|${r}`,i=h(n),o=h(r),a=i&&o?{key:s,line:i,highlight:o}:null;L(t=>t?.key===a?.key&&null===t==(null===a)?t:a)},[x,M]),T=t.useCallback(t=>{E(t),t&&!I&&O&&z(t)},[I,O,z]);t.useEffect(()=>{if(!S||I)return;const t=new MutationObserver(()=>{F.current&&z(S)});return t.observe(document.documentElement,{attributes:!0,attributeFilter:["data-mode"],subtree:!0}),()=>t.disconnect()},[S,I,z]);const V=t.useRef(u);t.useEffect(()=>{V.current=u},[u]),t.useEffect(()=>{if(!$||I||!D)return;let t=!1;return(async()=>{try{const[e,r]=await Promise.all([(k??=n(()=>import("./cf27cae7f-CJgVugjN.js"),[]).then(t=>t.default,t=>{throw k=void 0,t}),k),j(V.current)]);if(t)return;const s=r.parse();v(s,D.line,D.highlight);const i=e.loadAnimation({container:$,renderer:"svg",loop:!0,autoplay:!1,animationData:s});P.current=i,i.addEventListener("DOMLoaded",()=>{t||C(!0)});const o=R.current;void 0!==o&&i.goToAndStop(o,!0),F.current&&i.play()}catch(e){}})(),()=>{t=!0;const e=P.current;e&&(R.current=e.currentFrame,e.destroy(),P.current=null),C(!1)}},[$,I,D]);const B=I||!N;return e.jsxs("div",{"data-cds":"AnimatedPictogram",className:i("inline-flex",b),style:{position:"relative",width:A,height:A,flexShrink:0,...p},ref:T,...y,...c(m,y),children:[B?e.jsx(a,{asset:f,size:d,highlightFill:g,"aria-hidden":!0}):null,I?null:e.jsx("div",{ref:w,style:{position:"absolute",inset:0,transform:"scale(1.2)",transformOrigin:"center"},"aria-hidden":!0})]})}export{A};
