import{a as e}from"./rolldown-runtime-COnpUsM8.js";import{At as t,Ct as n,D as r,Ht as i,O as a,Pt as o,St as s,Tt as c,mt as l,xt as u}from"./vendor-react-N_fu9J_Y.js";import{t as d}from"./classnames-BRexu-Ot.js";import{n as f}from"./AppContextProvider-fvnyxBmo.js";import{G as p,V as m,a as h,t as g}from"./drivers-wEwLhNmR.js";import{t as _}from"./Button-CfyTBrFT.js";import{g as v,x as y}from"./icons-BrNTWQns.js";import{t as b}from"./Icon-DMzXpf4m.js";var x=e(i());a();var S={};function C(e){return e===`jp`||e===`ja`?S.ja??null:e===`cn`||e===`zh`?S.zh??null:null}async function w(e){if(e===`jp`||e===`ja`){if(!S.ja){let{loadDefaultJapaneseParser:e}=await r(async()=>{let{loadDefaultJapaneseParser:e}=await import(`./module-dItaheZY.js`);return{loadDefaultJapaneseParser:e}},[]);S.ja=e()}return S.ja}if(e===`cn`||e===`zh`){if(!S.zh){let{loadDefaultSimplifiedChineseParser:e}=await r(async()=>{let{loadDefaultSimplifiedChineseParser:e}=await import(`./module-dItaheZY.js`);return{loadDefaultSimplifiedChineseParser:e}},[]);S.zh=e()}return S.zh}return null}function T(){let{i18n:e}=l(),t=e.language,[n,r]=(0,x.useState)(()=>C(t)),i=(0,x.useCallback)(e=>n?n.parse(e).join(`​`):e,[n]),a=(0,x.useCallback)(e=>n?e.replace(/([^<>]+)(?=<|$)/g,(e,t)=>n.parse(t).join(`​`)):e,[n]);return(0,x.useEffect)(()=>{w(t).then(e=>{e&&r(e)})},[t]),{parser:n,processText:i,processHTML:a}}var E=t(),D=e=>Array.isArray(e)?e.map(e=>{if(!e)return``;if(e.type===`text`)return e.text??``;let t=D(e.content??[]);return e.type===`paragraph`&&t?`${t}\n`:t}).join(``):``,O=e=>{let{blok:t,expandable:r,maxLength:i}=e,[a]=f(),{selectedLanguage:o}=a,{processText:l}=T(),[d,m]=(0,x.useState)(!1),_=(0,x.useRef)(null),v=(0,x.useCallback)(()=>{m(e=>!e)},[]),y=t.richText??t.content,b=(0,x.useMemo)(()=>y?typeof y==`string`?{type:`doc`,content:[{type:`paragraph`,content:[{type:`text`,text:y}]}]}:Array.isArray(y)?{type:`doc`,content:y}:typeof y==`object`&&y&&`type`in y?y:null:null,[y]),S=t.alignment?{display:`flex`,justifyContent:t.alignment}:{},C=(0,x.useMemo)(()=>{if(t.textAlign===`left`||t.textAlign===`center`||t.textAlign===`right`||t.textAlign===`justify`)return t.textAlign},[t.textAlign]),w=(0,x.useMemo)(()=>b?c(b,{markResolvers:{[s]:(e,t)=>{let{linktype:n,href:r,anchor:i,target:a}=t;return n===`story`?(0,E.jsx)(g,{to:i?`${r}#${i}`:r,target:a,children:e}):(0,E.jsx)(`a`,{href:r,target:a,children:e})},[u]:(e,t)=>(0,E.jsx)(`span`,{style:t?.color?{backgroundColor:t.color,padding:`2px 8px`,borderRadius:`2px`}:{},children:e})},nodeResolvers:{[n]:(e,t)=>{let{src:n,alt:r,title:i}=t,a=p(n)||n||``,o=h(a,`filters:quality(100)/`,!1);return(0,E.jsxs)(`picture`,{children:[(0,E.jsx)(`source`,{media:`(max-width: 480px)`,srcSet:`${o.mobile1x} 1x, ${o.mobile2x} 2x`}),(0,E.jsx)(`source`,{media:`(max-width: 768px)`,srcSet:`${o.tablet1x} 1x, ${o.tablet2x} 2x`}),(0,E.jsx)(`source`,{media:`(max-width: 1024px)`,srcSet:`${o.smallDesktop1x} 1x, ${o.smallDesktop2x} 2x`}),(0,E.jsx)(`source`,{media:`(max-width: 1280px)`,srcSet:`${o.largeDesktop1x} 1x, ${o.largeDesktop2x} 2x`}),(0,E.jsx)(`source`,{media:`(min-width: 1281px)`,srcSet:`${o.extraLarge1x} 1x, ${o.extraLarge2x} 2x`}),(0,E.jsx)(`img`,{src:o.default||a,alt:r||``,title:i||``,loading:`lazy`,className:`w-auto h-auto`})]})}},textResolver:l}):null,[b,o,l]),O=(0,x.useMemo)(()=>b?.content?D(b.content).trim():``,[b]),k=(0,x.useMemo)(()=>!r||!i||!O||O.length<=i?null:(0,E.jsx)(`div`,{children:O.substring(0,i)+`...`}),[r,i,O]);return{alignment:S,handleToggle:v,isExpanded:d,renderedRichText:w,shouldShowButton:r&&O.length>(i??0),textAlign:C,textRef:_,truncatedContent:k}},k={root:`_root_1aqv5_23`,trimLastMargin:`_trimLastMargin_1aqv5_154`,buttonIcon:`_buttonIcon_1aqv5_158`,expandContent:`_expandContent_1aqv5_164`,expandButton:`_expandButton_1aqv5_168`},A=e(d()),j=e=>{let{blok:t,classes:n}=e;if(!t)return null;let{alignment:r,handleToggle:i,isExpanded:a,renderedRichText:s,shouldShowButton:c,textAlign:l,textRef:u,truncatedContent:d}=O(e),f=m(k,n);if(!s&&!d)return null;let p=(0,A.default)(c?f.expandContent:(0,A.default)(f.root,f.richTextModifier),c&&[`overflow-hidden`,`transition-[max-height]`,`duration-500`,`ease-in-out`,a?`max-h-[2000px]`:`max-h-60`]),h={iconComponentModifier:f.buttonIcon},g=a?v:y;return(0,E.jsxs)(`div`,{className:(0,A.default)(f.root,{[f.trimLastMargin]:t.trimLastMargin}),style:{...r,fontWeight:t.fontWeight||`normal`},...o(t),children:[(0,E.jsx)(`div`,{ref:u,className:p,style:{textAlign:l},children:c&&!a?d:s}),c&&(0,E.jsx)(_,{onClick:i,color:`brand`,size:`small`,className:f.expandButton,"aria-label":a?`Collapse content`:`Expand content`,"aria-expanded":a,children:(0,E.jsx)(b,{src:g,size:22,classes:h})})]})};export{T as n,j as t};