import{s as e}from"./chunk-Bj-mKKzh.js";import{n as t}from"./jsx-runtime-CiQ1k8xo.js";import{lt as n}from"./vscode-api-DjORcpSo.js";import{n as r}from"./use-resize-observer-pZWTsQ9C.js";var i=n(),a=e(t(),1),o=1.5,s=1;function c(e){let t=(0,i.c)(9),{text:n,collapsedLineCount:r,fallbackFontSizePx:o}=e,[c,u]=(0,a.useState)(null),d;t[0]!==r||t[1]!==o?(d={collapsedLineCount:r,fallbackFontSizePx:o},t[0]=r,t[1]=o,t[2]=d):d=t[2];let{setTextMeasurementRef:f,textMeasurement:p}=l(d),m=p==null||p.collapsedHeightPx==null||p.contentHeightPx<=p.collapsedHeightPx+s?`uncollapsible`:c===n?`expanded`:`collapsed`,h;t[3]===n?h=t[4]:(h=()=>{u(e=>e===n?null:n)},t[3]=n,t[4]=h);let g=h,_;return t[5]!==m||t[6]!==g||t[7]!==f?(_={setTextContentMeasurementRef:f,collapseState:m,handleToggleExpansion:g},t[5]=m,t[6]=g,t[7]=f,t[8]=_):_=t[8],_}function l(e){let t=(0,i.c)(10),{collapsedLineCount:n,fallbackFontSizePx:o}=e,[s,c]=(0,a.useState)(null),l;t[0]!==n||t[1]!==o?(l=(e,t)=>{c(r=>{let i=u(t,e.contentRect.width,n,o);return r?.collapsedHeightPx===i?.collapsedHeightPx&&r?.contentHeightPx===i?.contentHeightPx&&r?.font===i?.font&&r?.lineHeightPx===i?.lineHeightPx&&r?.maxWidthPx===i?.maxWidthPx&&r?.element===i?.element&&r?.fallbackFontSizePx===i?.fallbackFontSizePx?r:i})},t[0]=n,t[1]=o,t[2]=l):l=t[2];let d=l,f;t[3]===d?f=t[4]:(f=(e,t)=>{d(e,t)},t[3]=d,t[4]=f);let p=r(f),m;t[5]===p?m=t[6]:(m=e=>{p(e)},t[5]=p,t[6]=m);let h=m,g;return t[7]!==h||t[8]!==s?(g={setTextMeasurementRef:h,textMeasurement:s},t[7]=h,t[8]=s,t[9]=g):g=t[9],g}function u(e,t,n,r){let i=Math.floor(t);if(i<=0)return null;let a=window.getComputedStyle(e),o=f(a,r),s=p(a,o);return{collapsedHeightPx:n==null?null:Math.ceil(s*n),contentHeightPx:Math.ceil(e.scrollHeight),element:e,fallbackFontSizePx:r,font:d(a,o),lineHeightPx:s,maxWidthPx:i}}function d(e,t){return[e.fontStyle||`normal`,e.fontVariant||`normal`,e.fontWeight||`400`,`${t}px`,e.fontFamily||`sans-serif`].join(` `)}function f(e,t){let n=Number.parseFloat(e.fontSize);return Number.isFinite(n)?n:t}function p(e,t){let n=Number.parseFloat(e.lineHeight);return Number.isFinite(n)?n:t*o}export{l as n,c as t};
//# sourceMappingURL=use-measured-text-collapse-Bs82JrPM.js.map