import{r as t,j as e,_ as n}from"./vendor-react-DcxrbCFs.js";import{u as r}from"./c8748971a-CqajCpTp.js";import{i as s,u as i,f as o}from"./vendor-ant-cds-BOj-tX6j.js";import{aL as a,P as c,aM as l,aN as u}from"./c4b350ac1-BTR_0NaM.js";function f(t){return{r:parseInt(t.slice(1,3),16),g:parseInt(t.slice(3,5),16),b:parseInt(t.slice(5,7),16)}}const d=f("#141413"),g=f("#dedcd1");function m(t){return Array.isArray(t)&&t.length>=3&&"number"==typeof t[0]&&"number"==typeof t[1]&&"number"==typeof t[2]}function h(t,e){if(Array.isArray(t)){for(const n of t)h(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&&m(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&&(m(n.s)&&e({kind:"keyframe",rgb:n.s}),m(n.e)&&e({kind:"keyframe",rgb:n.e}))}for(const s of Object.values(n))h(s,e)}const p=d,b=g;function y(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 v(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 k(t,e,n){h(t,t=>{if("solid"===t.kind){const r=y(t.get());if(!r)return;const s=[r.r,r.g,r.b],i=v(s,p)?e:v(s,b)?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=v(t,p)?e:v(t,b)?n:null;r&&(t[0]=r.r/255,t[1]=r.g/255,t[2]=r.b/255)}(t.rgb,e,n)})}let j;async function A(t){const e=await t();return"default"in e?e.default:e}function I({asset:f,still:d,size:g="md",highlightFill:m="default",alt:h,className:p,style:b,...v}){const I="number"==typeof g?g:a[g],S=s(),E=i(),[M,$]=t.useState(null),[w,x]=t.useState(null),O=u(m),_=r(`pictogram-highlight-${O}`),[F,N]=t.useState(!1),P=t.useRef(!1),R=t.useRef(null),L=t.useRef(void 0),[D,V]=t.useState(!1),[z,T]=t.useState(0);t.useEffect(()=>{if(!M||S)return;const t=new MutationObserver(()=>T(t=>t+1));return t.observe(document.documentElement,{attributes:!0,attributeFilter:["data-mode"],subtree:!0}),()=>t.disconnect()},[M,S]),t.useEffect(()=>{if(!M||S)return;const t=new IntersectionObserver(t=>{const e=t[t.length-1];P.current=e.isIntersecting,N(e.isIntersecting);const n=R.current;n&&(e.isIntersecting?n.play():n.pause())});return t.observe(M),()=>t.disconnect()},[M,S]);const[B,C]=t.useState(null);t.useEffect(()=>{if(!M||S)return;if(!F)return;const t=getComputedStyle(M),e=t.color,n=t.getPropertyValue(`--cds-pictogram-highlight-${O}`).trim()||_,r=`${e}|${n}`,s=y(e),i=y(n),o=s&&i?{key:r,line:s,highlight:i}:null;C(t=>t?.key===o?.key&&null===t==(null===o)?t:o)},[M,S,F,O,_,E,z]);const q=t.useRef(f);q.current=f,t.useEffect(()=>{if(!w||S||!B)return;let t=!1;return(async()=>{try{const[e,r]=await Promise.all([(j??=n(()=>import("./cf27cae7f-CJgVugjN.js"),[]).then(t=>t.default,t=>{throw j=void 0,t}),j),A(q.current)]);if(t)return;const s=r.parse();k(s,B.line,B.highlight);const i=e.loadAnimation({container:w,renderer:"svg",loop:!0,autoplay:!1,animationData:s});R.current=i,i.addEventListener("DOMLoaded",()=>{t||V(!0)});const o=L.current;void 0!==o&&i.goToAndStop(o,!0),P.current&&i.play()}catch(e){}})(),()=>{t=!0;const e=R.current;e&&(L.current=e.currentFrame,e.destroy(),R.current=null),V(!1)}},[w,S,B]);const G=S||!D;return e.jsxs("div",{"data-cds":"AnimatedPictogram",className:o("inline-flex",p),style:{position:"relative",width:I,height:I,flexShrink:0,...b},ref:$,...v,...l(h,v),children:[G?e.jsx(c,{asset:d,size:g,highlightFill:m,"aria-hidden":!0}):null,S?null:e.jsx("div",{ref:x,style:{position:"absolute",inset:0,transform:"scale(1.2)",transformOrigin:"center"},"aria-hidden":!0})]})}export{I as A};
