@bigtablet/design-system 4.10.1 → 4.10.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -18,17 +18,32 @@ Crafted for clarity. Built on tokens. Ships with dark mode.
18
18
  <a href="https://github.com/Bigtablet/bigtablet-design-system/actions/workflows/ci.yml"><img src="https://img.shields.io/github/actions/workflow/status/Bigtablet/bigtablet-design-system/ci.yml?style=for-the-badge&color=10b981&labelColor=000" alt="ci" /></a>
19
19
  </p>
20
20
 
21
- [**Documentation**](./docs/COMPONENTS.md)&nbsp;&nbsp;·&nbsp;&nbsp;[Docs site](https://bigtablet.github.io/bigtablet-design-system/)&nbsp;&nbsp;·&nbsp;&nbsp;[NPM](https://www.npmjs.com/package/@bigtablet/design-system)&nbsp;&nbsp;·&nbsp;&nbsp;[🇰🇷 한국어](./README_KR.md)
21
+ [**Docs site**](https://bigtablet.github.io/bigtablet-design-system/)&nbsp;&nbsp;·&nbsp;&nbsp;[NPM](https://www.npmjs.com/package/@bigtablet/design-system)&nbsp;&nbsp;·&nbsp;&nbsp;[Changelog](./CHANGELOG.md)&nbsp;&nbsp;·&nbsp;&nbsp;[🇰🇷 한국어](./README_KR.md)
22
+
23
+ <br />
24
+
25
+ <a href="https://bigtablet.github.io/bigtablet-design-system/">
26
+ <picture>
27
+ <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/Bigtablet/bigtablet-design-system/main/.github/assets/home-dark.png" />
28
+ <img alt="Docs site home" src="https://raw.githubusercontent.com/Bigtablet/bigtablet-design-system/main/.github/assets/home-light.png" />
29
+ </picture>
30
+ </a>
22
31
 
23
32
  </div>
24
33
 
25
34
  <br />
26
35
 
36
+ ## Install
37
+
38
+ ```bash
39
+ pnpm add @bigtablet/design-system react@^19 react-dom@^19 lucide-react
40
+ ```
41
+
27
42
  ```tsx
43
+ "use client"; // useToast · onClick need a client component in the Next.js App Router
44
+
28
45
  import { ThemeProvider, ToastProvider, Button, useToast } from "@bigtablet/design-system";
29
- // No CSS import needed - each component brings its own CSS plus the shared theme variables,
30
- // so a page that uses only Button ships about 3 kB of DS CSS (gzip) instead of 20 kB.
31
- // Next.js with webpack: add the package to `experimental.optimizePackageImports` (Turbopack needs nothing).
46
+ // No CSS import needed - each component brings its own CSS.
32
47
 
33
48
  export default function App() {
34
49
  return (
@@ -40,196 +55,49 @@ export default function App() {
40
55
  );
41
56
  }
42
57
 
43
- // useToast() needs a ToastProvider above it - call it in a child, not where the provider is rendered.
44
58
  function SaveButton() {
45
59
  const toast = useToast();
46
60
  return <Button onClick={() => toast.success("Saved")}>Save</Button>;
47
61
  }
48
62
  ```
49
63
 
50
- A complete React + TypeScript design system maintained by Bigtablet for internal product work. Open-sourced for reference - external use welcome, but minor versions may include breaking changes - check [MIGRATION](./docs/MIGRATION.md#업그레이드-체크리스트) before upgrading.
64
+ Components ship with `"use client"`, so they import straight into the App Router. Setup details and SCSS tokens are on the [install page](https://bigtablet.github.io/bigtablet-design-system/#/install), Tailwind v4 in [THEMING](./docs/THEMING.md#tailwind-css-v4).
51
65
 
52
66
  <br />
53
67
 
54
68
  ## What's inside
55
69
 
56
- - **60+ components** across forms, display, feedback, navigation, overlay, and layout<br />
57
- - **13 token domains** - colors, typography, spacing, motion, radius, elevation, and more - exposed as SCSS variables and CSS custom properties (plus a SCSS-only `layout` domain)<br />
58
- - **Light + dark mode** out of the box. `[data-theme="dark"]` or `prefers-color-scheme`, no theme provider required (but available via `ThemeProvider` for runtime toggling)<br />
59
- - **Vanilla JS bundle** for non-React backends - Thymeleaf, JSP, PHP, Django<br />
60
- - **Korean line breaking** at `@bigtablet/design-system/text` - `BalancedText` measures the real width and breaks at sentence ends and commas, `BalancedTextScript` applies the same lines to server HTML before hydration. No runtime dependencies<br />
61
- - **Docs for AI agents** in the package (`dist/llms`) and on the docs site (`llms.txt` · `llms-full.txt`) - components, every token, screen recipes and names to avoid<br />
62
- - **Accessibility tested** with axe-core in CI · keyboard nav · ARIA throughout
63
-
64
- <br />
65
-
66
- ## Install
67
-
68
- ```bash
69
- pnpm add @bigtablet/design-system react@^19 react-dom@^19 lucide-react
70
- ```
71
-
72
- Requires React 19 + lucide-react ≥ 0.552. Next.js is an optional peer dependency at `>=15`.
73
-
74
- <details>
75
- <summary><b>One-line setup</b> - auto-detect package manager + framework</summary>
76
-
77
- <br />
78
-
79
- ```bash
80
- curl -fsSL https://raw.githubusercontent.com/Bigtablet/bigtablet-design-system/main/scripts/setup.sh | sh
81
- ```
82
-
83
- Detects npm / yarn / pnpm / bun and React / Next.js, installs the package and its peer dependencies, and prints the provider setup. No CSS import is needed - importing a component brings its CSS.
84
-
85
- </details>
86
-
87
- <br />
88
-
89
- ## Providers
90
-
91
- ```tsx
92
- import { ThemeProvider, AlertProvider, ToastProvider } from "@bigtablet/design-system";
93
-
94
- <ThemeProvider>
95
- <AlertProvider>
96
- <ToastProvider>{children}</ToastProvider>
97
- </AlertProvider>
98
- </ThemeProvider>
99
- ```
100
-
101
- Use the hooks anywhere:
102
-
103
- ```tsx
104
- const toast = useToast();
105
- const { showAlert } = useAlert();
106
-
107
- toast.success("Saved");
108
- showAlert({ title: "Delete?", showCancel: true, onConfirm: ... });
109
- ```
110
-
111
- <br />
112
-
113
- ## Components
114
-
115
- <table>
116
- <tr><td><b>General</b></td><td>Button · CopyButton · IconButton</td></tr>
117
- <tr><td><b>Forms</b></td><td>Checkbox · Combobox · DateCalendar · DatePicker · DateRangePicker · Dropdown · Field · FileInput · FilterBar · Form · ImageCropper · OtpInput · Radio · RadioGroup · SegmentedControl · TagInput · Textarea · TextField · TimePicker · Toggle</td></tr>
118
- <tr><td><b>Display</b></td><td>Accordion · Avatar · Badge · Card · Chip · DataView · DescriptionList · Divider · Hero · Icon · ListItem · MediaCard · Prose · Stat · Table · Timeline</td></tr>
119
- <tr><td><b>Feedback</b></td><td>Alert (<code>useAlert</code> · <code>useConfirm</code>) · EmptyState · ErrorState · InlineAlert · LinearProgress · Skeleton · Spinner · Toast (<code>useToast</code>) · TopLoading</td></tr>
120
- <tr><td><b>Navigation</b></td><td>BottomNav · Breadcrumb · Menu · NavBar · Pagination · Sidebar · Stepper · Tabs</td></tr>
121
- <tr><td><b>Overlay</b></td><td>Drawer · Modal · Popover · Tooltip</td></tr>
122
- <tr><td><b>Layout</b></td><td>AppShell · Container · Grid · PageHeader · Section · Stack</td></tr>
123
- <tr><td><b>System</b></td><td>LocaleProvider · ThemeProvider</td></tr>
124
- </table>
70
+ <a href="https://bigtablet.github.io/bigtablet-design-system/#/data-view">
71
+ <picture>
72
+ <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/Bigtablet/bigtablet-design-system/main/.github/assets/data-view-dark.png" />
73
+ <img alt="DataView docs page" src="https://raw.githubusercontent.com/Bigtablet/bigtablet-design-system/main/.github/assets/data-view-light.png" />
74
+ </picture>
75
+ </a>
125
76
 
126
- →&nbsp;Full API · [`docs/COMPONENTS.md`](./docs/COMPONENTS.md)
77
+ - **60+ components** - forms, display, feedback, navigation, overlay, layout, plus screen-level pieces like `DataView`
78
+ - **Design tokens** - colors, typography, spacing, motion and more as SCSS variables and CSS custom properties
79
+ - **Light + dark mode** - `[data-theme="dark"]` or `prefers-color-scheme`, runtime toggling via `ThemeProvider`
80
+ - **Vanilla JS bundle** - the same look in Thymeleaf, JSP, PHP, Django ([guide](https://bigtablet.github.io/bigtablet-design-system/#/vanilla))
81
+ - **Korean line breaking** - `BalancedText` at `@bigtablet/design-system/text`
82
+ - **Docs for AI agents** - [`llms.txt`](https://bigtablet.github.io/bigtablet-design-system/llms.txt) and `dist/llms` in the package ([guide](https://bigtablet.github.io/bigtablet-design-system/#/ai))
83
+ - **Accessibility tested** - axe-core on every docs example in CI
127
84
 
128
- <br />
129
-
130
- ## Design tokens
131
-
132
- ```scss
133
- @use "@bigtablet/design-system/scss/token" as token;
134
-
135
- .card {
136
- background: token.$color_bg_solid;
137
- color: token.$color_text_heading;
138
- padding: token.$spacing_16;
139
- border-radius: token.$radius_md;
140
- box-shadow: token.$elevation_level1;
141
- }
142
- ```
143
-
144
- ```css
145
- /* from @bigtablet/design-system/style.css */
146
- .card {
147
- background: var(--bt-color-bg-solid);
148
- color: var(--bt-color-text-heading);
149
- border: 1px solid var(--bt-color-border-default);
150
- box-shadow: var(--bt-elevation-level1);
151
- }
152
- ```
153
-
154
- <!-- css-var-claim: 아래 한 줄이 React entry 의 변수 계열 전부를 주장한다. scripts/check-css-vars.sh 가 이 줄만 검사한다. -->
155
- > The React entry's `style.css` only emits `--bt-color-*`, `--bt-elevation-*`, `--bt-focus-*`, `--bt-sidebar-*`, `--bt-bottom-nav-*`, `--bt-bottom-inset*`, `--bt-scrollbar-width`, `--bt-z-*`, `--bt-radius-*`, `--bt-spacing-*`, `--bt-font-family`. Font size and line height are **SCSS-only** on this entry - use the `scss/token` typography mixins (`--bt-font-size-*` exists only in the [Vanilla bundle](./docs/VANILLA.md)).
156
-
157
- `colors`&nbsp;·&nbsp;`spacing`&nbsp;·&nbsp;`typography`&nbsp;·&nbsp;`radius`&nbsp;·&nbsp;`elevation`&nbsp;·&nbsp;`motion`&nbsp;·&nbsp;`z-index`&nbsp;·&nbsp;`breakpoints`&nbsp;·&nbsp;`border-width`&nbsp;·&nbsp;`opacity`&nbsp;·&nbsp;`skeleton`&nbsp;·&nbsp;`icon`&nbsp;·&nbsp;`a11y`&nbsp;·&nbsp;`layout`<sup>SCSS only</sup>
85
+ Maintained for Bigtablet's own products and open for reference. Minor versions may include breaking changes - check [MIGRATION](./docs/MIGRATION.md#업그레이드-체크리스트) before upgrading.
158
86
 
159
87
  <br />
160
88
 
161
- ### Tailwind CSS (v4)
162
-
163
- ```css
164
- /* app/globals.css - import before tailwindcss so the layer order is fixed first */
165
- @import "@bigtablet/design-system/tailwind.css";
166
- @import "tailwindcss";
167
- ```
168
-
169
- ```tsx
170
- import "@bigtablet/design-system/style.css"; // defines the --bt-* values
171
- <p className="text-bt-text-heading shadow-bt-level2 dark:bg-bt-bg-solid" />
172
- ```
173
-
174
- `tailwind.css` maps every `--bt-color-*` to `--color-bt-*`, `--bt-elevation-*` / `--bt-focus-ring*` to `--shadow-bt-*`, `--bt-radius-*` to `--radius-bt-*` (`rounded-bt-md`), `--bt-spacing-*` to `--spacing-bt-*` (`p-bt-16`) and `--bt-font-family` to `--font-bt` (`font-bt`) (values stay `var()`, so dark mode and your overrides follow), and makes `dark:` match ThemeProvider (`data-theme="dark"`, or OS dark when `data-theme` is unset). Component CSS lives in the `bigtablet` cascade layer (`theme, base, reset, bigtablet, components, utilities`), so utilities and your own unlayered CSS override it without specificity fights: `<Button className="bg-bt-text-brand" />`. Element-selector resets of your own (`* { padding: 0 }`, `button { background: none }`) and global focus styles (`:focus-visible { outline: 2px solid ... }`) must go in `@layer reset { ... }` - unlayered, they beat every DS component, and a global `:focus-visible` outline is drawn on top of the DS focus ring (a double ring).
175
-
176
- <br />
177
-
178
- ## Vanilla JS
179
-
180
- For server-rendered apps (Thymeleaf, JSP, PHP, Django):
181
-
182
- ```html
183
- <!-- @4 tracks the latest 4.x. Pin an exact version like @4.9.1 to freeze rendering -->
184
- <link rel="stylesheet" href="https://unpkg.com/@bigtablet/design-system@4/dist/vanilla/bigtablet.min.css">
185
- <script src="https://unpkg.com/@bigtablet/design-system@4/dist/vanilla/bigtablet.min.js"></script>
186
-
187
- <button class="bt-button bt-button--md bt-button--filled">Filled</button>
188
- ```
189
-
190
- →&nbsp;Full guide · [`docs/VANILLA.md`](./docs/VANILLA.md)
191
-
192
- <br />
193
-
194
- ## Development
195
-
196
- ```bash
197
- pnpm install
198
- pnpm site # docs site, localhost:6007
199
- pnpm test # Vitest unit
200
- pnpm test:browser # a11y (axe on docs examples) + layout, Playwright
201
- pnpm build # tsup + SCSS copy + Vanilla + tailwind.css + dist/llms
202
- ```
203
-
204
- The docs site lives at **[bigtablet.github.io/bigtablet-design-system](https://bigtablet.github.io/bigtablet-design-system/)** and redeploys from `main`.
205
-
206
- <br />
207
-
208
- ## Documentation
89
+ ## More docs
209
90
 
210
91
  | | |
211
92
  |---|---|
212
- | 📚 [Components](./docs/COMPONENTS.md) | When to use, examples, and props per component |
213
93
  | 🔄 [Migration](./docs/MIGRATION.md) | Upgrade checklist + what to change per version |
214
- | 🎨 [Theming](./docs/THEMING.md) | Light/dark theme system guide |
94
+ | 🎨 [Theming](./docs/THEMING.md) | Light/dark theme system |
215
95
  | 🏗️ [Architecture](./docs/ARCHITECTURE.md) | Project structure + design principles |
216
- | 🤝 [Contributing](./docs/CONTRIBUTING.md) | Dev setup + workflow |
96
+ | 🤝 [Contributing](./docs/CONTRIBUTING.md) | Dev setup (`pnpm install` · `pnpm site` on :6007) + workflow |
217
97
  | 🧪 [Testing](./docs/TESTING.md) | Test patterns + a11y testing |
218
- | 🌐 [Vanilla JS](./docs/VANILLA.md) | HTML/CSS/JS integration |
219
- | 🤖 [Agent Guide](./docs/AGENT_GUIDE.md) | Rules for AI agents. Generated docs: `node_modules/@bigtablet/design-system/dist/llms/index.md` · [llms.txt](https://bigtablet.github.io/bigtablet-design-system/llms.txt) |
220
98
 
221
99
  <br />
222
100
 
223
101
  ## License
224
102
 
225
103
  Licensed under the [Bigtablet License](https://github.com/Bigtablet/.github/blob/main/BIGTABLET_LICENSE.md).
226
-
227
- <br />
228
-
229
- <div align="center">
230
-
231
- <sub>Made with care by the Bigtablet team.</sub>
232
-
233
- <sub>[GitHub](https://github.com/Bigtablet/bigtablet-design-system) · [Issues](https://github.com/Bigtablet/bigtablet-design-system/issues) · [NPM](https://www.npmjs.com/package/@bigtablet/design-system)</sub>
234
-
235
- </div>
@@ -1 +1 @@
1
- import{jsx,jsxs}from"react/jsx-runtime";import*as React from"react";import{chooseDomBreaks,contentWidth,fontPending,ID_ATTR,releasePrehydrate,WORD_CLASS,wordSpans}from"./dom.js";import{toWords}from"./layout.js";import{createCanvasMeasurer,fontOf}from"./measure.js";import{balancedTextScript}from"./prehydrate-script.js";import"./text.css";const useSafeLayoutEffect=typeof window!=="undefined"?React.useLayoutEffect:React.useEffect;const textOf=node=>{if(typeof node==="string"||typeof node==="number")return String(node);if(React.isValidElement(node))return React.Children.toArray(node.props.children).map(textOf).join("");return""};const flatten=children=>React.Children.toArray(children).flatMap(child=>React.isValidElement(child)&&child.type===React.Fragment?flatten(child.props.children):[child]);const shapeOf=node=>{if(!React.isValidElement(node))return String(node);const{type}=node;const name=typeof type==="string"?type:type.displayName??type.name??"?";return`<${name}>${textOf(node)}`};const tokenize=children=>{const tokens=[];let gap="";let lead="";let joined=false;let pos=0;const add=(text,node,spaceBefore)=>{const last=tokens.at(-1);if(joined&&last&&!spaceBefore){last.text+=text;last.end+=text.length;last.nodes.push(node)}else{if(tokens.length===0)lead=gap;tokens.push({text,start:pos,end:pos+text.length,spaceBefore:tokens.length>0&&spaceBefore,nodes:[node],gap:tokens.length>0?gap:""})}pos+=text.length;gap="";joined=true};for(const child of flatten(children)){if(typeof child!=="string"&&typeof child!=="number"){add(textOf(child),child,gap!=="");continue}for(const chunk of String(child).split(/(\s+)/)){if(!chunk)continue;if(/^\s/.test(chunk)){gap+=chunk;joined=false;continue}toWords(chunk).forEach((word,index)=>{if(index>0)joined=false;add(word.text,word.text,index===0&&gap!=="")})}}return{tokens,lead,tail:gap}};const measurers=new Map;const measurerFor=(font,letterSpacing)=>{const key=`${font}|${letterSpacing}`;if(!measurers.has(key))measurers.set(key,createCanvasMeasurer(font,letterSpacing));return measurers.get(key)??null};const SETTLE_MS=100;const MAX_CHURN=6;const BalancedText=({children,as:Tag="span",className,...props})=>{const ref=React.useRef(null);const id=React.useId();const{tokens,lead,tail}=tokenize(children);const key=tokens.map(t=>t.nodes.map(shapeOf).join("")).join("");const[chosen,setChosen]=React.useState(null);const breaks=chosen?.key===key?chosen.breaks:null;const boxed=chosen?.boxed??false;const latest=React.useRef(tokens);const drawnFor=React.useRef(0);const contentSized=React.useRef(false);latest.current=tokens;useSafeLayoutEffect(()=>{const el=ref.current;if(!el)return;let timer;let cancelled=false;let width=contentWidth(el);let churn=0;let churnReset;let gaveUp=false;const apply=breaks2=>{if(++churn>MAX_CHURN){gaveUp=true;setChosen(null);return}clearTimeout(churnReset);churnReset=setTimeout(()=>{churn=0},1e3);drawnFor.current=width;setChosen({key,breaks:breaks2,boxed:contentSized.current})};const compute=()=>{if(gaveUp)return;const pending=fontPending(el);if(pending){pending.then(()=>{if(cancelled)return;for(const m of measurers.values())m?.clear();compute()},()=>{});return}if(el.querySelector(":scope > .text_balanced_line"))return;releasePrehydrate(el);if(wordSpans(el).length!==latest.current.length)return;width=contentWidth(el);const{font,letterSpacing}=fontOf(el);const measure=measurerFor(font,letterSpacing);const breaks2=measure&&chooseDomBreaks(el,measure);if(breaks2)apply(breaks2)};const recompute=()=>{setChosen(null);clearTimeout(timer);timer=setTimeout(()=>{if(!cancelled)compute()},SETTLE_MS)};compute();const observer=typeof ResizeObserver==="undefined"?null:new ResizeObserver(()=>{const next=contentWidth(el);if(next===width)return;width=next;recompute()});observer?.observe(el);return()=>{cancelled=true;clearTimeout(timer);clearTimeout(churnReset);observer?.disconnect()}},[key]);useSafeLayoutEffect(()=>{const el=ref.current;if(!el||!breaks||boxed)return;const style=getComputedStyle(el);const inner=el.clientWidth-Number.parseFloat(style.paddingLeft)-Number.parseFloat(style.paddingRight);let grew=false;if(inner>drawnFor.current+.5){const before=el.clientWidth;el.classList.add("text_balanced_probe");grew=el.clientWidth<before-.5;el.classList.remove("text_balanced_probe")}const right=el.getBoundingClientRect().right-Number.parseFloat(style.paddingRight);const lines=el.querySelectorAll(":scope > .text_balanced_line");const overflow=[...lines].some(line=>line.getBoundingClientRect().right>right+.5);if(grew)contentSized.current=true;if(grew||overflow)setChosen(c=>c?{...c,boxed:true}:c)},[chosen]);const word=i=>{const t=tokens[i];return jsx("span",{className:WORD_CLASS,children:t.nodes.map((node,j)=>jsx(React.Fragment,{children:node},j))},i)};const run=(from,to)=>{const out=[];for(let i=from;i<=to;i++){if(i>from)out.push(tokens[i]?.gap);out.push(word(i))}return out};const body=[];if(breaks){let from=0;for(const end of[...breaks,tokens.length-1]){if(from>0)body.push(tokens[from]?.gap||jsx("wbr",{},`wbr${from}`));body.push(jsx("span",{className:boxed?"text_balanced_line text_balanced_line_boxed":"text_balanced_line",children:run(from,end)},`line${from}`));from=end+1}}else{body.push(run(0,tokens.length-1))}return jsxs(Tag,{ref,...props,className:className?`text_balanced ${className}`:"text_balanced",...{[ID_ATTR]:id},children:[lead,body,tail]})};const BalancedTextScript=({nonce})=>jsx("script",{nonce,dangerouslySetInnerHTML:{__html:balancedTextScript}});export{BalancedText,BalancedTextScript};
1
+ "use client";import{jsx,jsxs}from"react/jsx-runtime";import*as React from"react";import{chooseDomBreaks,contentWidth,fontPending,ID_ATTR,releasePrehydrate,WORD_CLASS,wordSpans}from"./dom.js";import{toWords}from"./layout.js";import{createCanvasMeasurer,fontOf}from"./measure.js";import{balancedTextScript}from"./prehydrate-script.js";import"./text.css";const useSafeLayoutEffect=typeof window!=="undefined"?React.useLayoutEffect:React.useEffect;const textOf=node=>{if(typeof node==="string"||typeof node==="number")return String(node);if(React.isValidElement(node))return React.Children.toArray(node.props.children).map(textOf).join("");return""};const flatten=children=>React.Children.toArray(children).flatMap(child=>React.isValidElement(child)&&child.type===React.Fragment?flatten(child.props.children):[child]);const shapeOf=node=>{if(!React.isValidElement(node))return String(node);const{type}=node;const name=typeof type==="string"?type:type.displayName??type.name??"?";return`<${name}>${textOf(node)}`};const tokenize=children=>{const tokens=[];let gap="";let lead="";let joined=false;let pos=0;const add=(text,node,spaceBefore)=>{const last=tokens.at(-1);if(joined&&last&&!spaceBefore){last.text+=text;last.end+=text.length;last.nodes.push(node)}else{if(tokens.length===0)lead=gap;tokens.push({text,start:pos,end:pos+text.length,spaceBefore:tokens.length>0&&spaceBefore,nodes:[node],gap:tokens.length>0?gap:""})}pos+=text.length;gap="";joined=true};for(const child of flatten(children)){if(typeof child!=="string"&&typeof child!=="number"){add(textOf(child),child,gap!=="");continue}for(const chunk of String(child).split(/(\s+)/)){if(!chunk)continue;if(/^\s/.test(chunk)){gap+=chunk;joined=false;continue}toWords(chunk).forEach((word,index)=>{if(index>0)joined=false;add(word.text,word.text,index===0&&gap!=="")})}}return{tokens,lead,tail:gap}};const measurers=new Map;const measurerFor=(font,letterSpacing)=>{const key=`${font}|${letterSpacing}`;if(!measurers.has(key))measurers.set(key,createCanvasMeasurer(font,letterSpacing));return measurers.get(key)??null};const SETTLE_MS=100;const MAX_CHURN=6;const BalancedText=({children,as:Tag="span",className,...props})=>{const ref=React.useRef(null);const id=React.useId();const{tokens,lead,tail}=tokenize(children);const key=`${className??""}${tokens.map(t=>t.nodes.map(shapeOf).join("")).join("")}`;const[chosen,setChosen]=React.useState(null);const breaks=chosen?.key===key?chosen.breaks:null;const boxed=chosen?.boxed??false;const latest=React.useRef(tokens);const drawnFor=React.useRef(0);const contentSized=React.useRef(false);latest.current=tokens;useSafeLayoutEffect(()=>{const el=ref.current;if(!el)return;setChosen(c=>c&&c.key!==key?null:c);let timer;let cancelled=false;let width=contentWidth(el);let churn=0;let churnReset;let gaveUp=false;const apply=breaks2=>{if(++churn>MAX_CHURN){gaveUp=true;setChosen(null);return}clearTimeout(churnReset);churnReset=setTimeout(()=>{churn=0},1e3);drawnFor.current=width;setChosen({key,breaks:breaks2,boxed:contentSized.current})};const compute=(fontWaited=false)=>{if(gaveUp)return;const pending=fontWaited?null:fontPending(el);if(pending){pending.then(()=>{if(cancelled)return;for(const m of measurers.values())m?.clear();compute(true)},()=>{});return}if(el.querySelector(":scope > .text_balanced_line"))return;releasePrehydrate(el);if(wordSpans(el).length!==latest.current.length)return;width=contentWidth(el);const{font,letterSpacing}=fontOf(el);const measure=measurerFor(font,letterSpacing);const breaks2=measure&&chooseDomBreaks(el,measure);if(breaks2)apply(breaks2)};const recompute=()=>{setChosen(null);clearTimeout(timer);timer=setTimeout(()=>{if(!cancelled)compute()},SETTLE_MS)};compute();const observer=typeof ResizeObserver==="undefined"?null:new ResizeObserver(()=>{const next=contentWidth(el);if(next===width)return;width=next;recompute()});observer?.observe(el);return()=>{cancelled=true;clearTimeout(timer);clearTimeout(churnReset);observer?.disconnect()}},[key]);useSafeLayoutEffect(()=>{const el=ref.current;if(!el||!breaks||boxed)return;const style=getComputedStyle(el);const inner=el.clientWidth-Number.parseFloat(style.paddingLeft)-Number.parseFloat(style.paddingRight);let grew=false;if(inner>drawnFor.current+.5){const before=el.clientWidth;el.classList.add("text_balanced_probe");grew=el.clientWidth<before-.5;el.classList.remove("text_balanced_probe")}const right=el.getBoundingClientRect().right-Number.parseFloat(style.paddingRight);const lines=el.querySelectorAll(":scope > .text_balanced_line");const overflow=[...lines].some(line=>line.getBoundingClientRect().right>right+.5);if(grew)contentSized.current=true;if(grew||overflow)setChosen(c=>c?{...c,boxed:true}:c)},[chosen]);const word=i=>{const t=tokens[i];return jsx("span",{className:WORD_CLASS,children:t.nodes.map((node,j)=>jsx(React.Fragment,{children:node},j))},i)};const run=(from,to)=>{const out=[];for(let i=from;i<=to;i++){if(i>from)out.push(tokens[i]?.gap);out.push(word(i))}return out};const body=[];if(breaks){let from=0;for(const end of[...breaks,tokens.length-1]){if(from>0)body.push(tokens[from]?.gap||jsx("wbr",{},`wbr${from}`));body.push(jsx("span",{className:boxed?"text_balanced_line text_balanced_line_boxed":"text_balanced_line",children:run(from,end)},`line${from}`));from=end+1}}else{body.push(run(0,tokens.length-1))}return jsxs(Tag,{ref,...props,className:className?`text_balanced ${className}`:"text_balanced",...{[ID_ATTR]:id},children:[lead,body,tail]})};const BalancedTextScript=({nonce})=>jsx("script",{nonce,dangerouslySetInnerHTML:{__html:balancedTextScript}});export{BalancedText,BalancedTextScript};
@@ -1 +1 @@
1
- const SENTENCE_END=/(?:[^\d]\.|[!?])["')\]”’」』]*$/;const splitSentences=text=>{const sentences=[];let start=-1;let end=0;for(const match of text.matchAll(/\S+/g)){const index=match.index??0;if(start<0)start=index;end=index+match[0].length;if(SENTENCE_END.test(match[0])){sentences.push({text:text.slice(start,end),start,end});start=-1}}if(start>=0)sentences.push({text:text.slice(start,end),start,end});return sentences};const DETERMINERS=new Set(["\uC774","\uADF8","\uC800","\uD55C","\uB450","\uC138","\uB124","\uAC01","\uBAA8\uB4E0","\uCCAB","\uC0C8","\uBA87","\uC628\uAC16","\uC5EC\uB7EC","\uC5B4\uB290","\uBB34\uC2A8","\uC774\uB7F0","\uADF8\uB7F0","\uC800\uB7F0"]);const MAX_PHRASE=3;const NOUNS_ENDING_IN_UI=new Set(["\uD68C\uC758","\uB3D9\uC758","\uC8FC\uC758","\uD611\uC758","\uB17C\uC758","\uAC74\uC758","\uD569\uC758","\uBB38\uC758","\uAC15\uC758","\uC815\uC758","\uC758\uC758","\uD3B8\uC758","\uC608\uC758","\uC131\uC758","\uACB0\uC758","\uBAA8\uC758","\uC2EC\uC758","\uD1A0\uC758","\uC9C8\uC758","\uD56D\uC758"]);const bindsNext=word=>/[가-힣]의$/.test(word)&&!NOUNS_ENDING_IN_UI.has(word)&&!/[가-힣]주의$/.test(word)||DETERMINERS.has(word);const ATTACHES_PREV=/^(?:입니다|입니까|이다|이에요|예요|이죠|이고|이며|이면|(?:수|것|때|줄|뿐|듯|만큼|중)(?:가|도|는|은|을|를|이|에|에서|에는|만|이다|입니다|이에요|예요|이죠)?)[.,!?"')\]”’]*$/;const bindsPrev=word=>ATTACHES_PREV.test(word);const phraseRanges=text=>{const words=[...text.matchAll(/\S+/g)].map(m=>({word:m[0],start:m.index??0,end:(m.index??0)+m[0].length}));const ranges=[];for(let i=0;i<words.length;){let j=i;while(j<words.length-1&&j-i+1<MAX_PHRASE&&(bindsNext(words[j]?.word??"")||bindsPrev(words[j+1]?.word??"")))j++;const first=words[i];const last=words[j];if(j>i&&first&&last)ranges.push({start:first.start,end:last.end});i=j+1}return ranges};const hasFinal=ch=>(ch.charCodeAt(0)-44032)%28!==0;const isModifier=word=>{if(!/^[가-힣]{2,}$/.test(word))return false;const last=word.at(-1)??"";const stem=word.at(-2)??"";if(last==="\uB294")return hasFinal(stem)||/[하되이리오가주보지치키우두쓰뜨나내대르드]/.test(stem);if(last==="\uC740")return/[같작높낮좋많넓좁짧얇붙묶받읽남닫찾놓넣않깊밝]/.test(stem);return/[운된던]/.test(last)};const BARE_END=/[이가은는을를에의와과도만로서고며면게지요다나든야라니죠께해여어아듯]$/;const isBare=word=>/^[가-힣]+$/.test(word)&&!BARE_END.test(word)||/^[A-Za-z0-9][\w.+#-]*$/.test(word);const SPACED_PARTICLE=/^(?:이|가|은|는|을|를|의|와|과|도|만|로|으로|에|에서|에게|부터|까지|처럼|보다|마다|만큼|이나|나|라고|이라고|하고)(?:는|도|만|의)?[.,!?]*$/;const leansNext=(before,after)=>{if(!/^[가-힣\d]/.test(after))return false;return isBare(before)||isModifier(before)};const gapPenalty=(before,after)=>{if(SENTENCE_END.test(before))return 0;if(bindsNext(before)||bindsPrev(after)||after==="\xB7")return 100;if(/[A-Za-z0-9"')\]”’>]$/.test(before)&&SPACED_PARTICLE.test(after))return 100;if(/[,:;]["')\]”’]*$/.test(before))return 1;if(SENTENCE_END.test(after))return 12;if(/·$/.test(before))return 8;if(leansNext(before,after))return 6;return 4};export{gapPenalty,phraseRanges,splitSentences};
1
+ const SENTENCE_END=/(?:[^\d]\.|[!?])["')\]”’」』]*$/;const ABBREVIATION=/(?:^|[^A-Za-z])(?:[A-Za-z]\.){2,}["')\]”’」』]*$/;const endsSentence=word=>SENTENCE_END.test(word)&&!ABBREVIATION.test(word);const splitSentences=text=>{const sentences=[];let start=-1;let end=0;for(const match of text.matchAll(/\S+/g)){const index=match.index??0;if(start<0)start=index;end=index+match[0].length;if(endsSentence(match[0])){sentences.push({text:text.slice(start,end),start,end});start=-1}}if(start>=0)sentences.push({text:text.slice(start,end),start,end});return sentences};const DETERMINERS=new Set(["\uC774","\uADF8","\uC800","\uD55C","\uB450","\uC138","\uB124","\uAC01","\uBAA8\uB4E0","\uCCAB","\uC0C8","\uBA87","\uC628\uAC16","\uC5EC\uB7EC","\uC5B4\uB290","\uBB34\uC2A8","\uC774\uB7F0","\uADF8\uB7F0","\uC800\uB7F0"]);const MAX_PHRASE=3;const NOUNS_ENDING_IN_UI=new Set(["\uD68C\uC758","\uB3D9\uC758","\uC8FC\uC758","\uD611\uC758","\uB17C\uC758","\uAC74\uC758","\uD569\uC758","\uBB38\uC758","\uAC15\uC758","\uC815\uC758","\uC758\uC758","\uD3B8\uC758","\uC608\uC758","\uC131\uC758","\uACB0\uC758","\uBAA8\uC758","\uC2EC\uC758","\uD1A0\uC758","\uC9C8\uC758","\uD56D\uC758"]);const bindsNext=word=>/[가-힣]의$/.test(word)&&!NOUNS_ENDING_IN_UI.has(word)&&!/[가-힣]주의$/.test(word)||DETERMINERS.has(word);const ATTACHES_PREV=/^(?:입니다|입니까|이다|이에요|예요|이죠|이고|이며|이면|(?:수|것|때|줄|뿐|듯|만큼|중)(?:가|도|는|은|을|를|이|에|에서|에는|만|이다|입니다|이에요|예요|이죠)?)[.,!?"')\]”’]*$/;const bindsPrev=word=>ATTACHES_PREV.test(word);const phraseRanges=text=>{const words=[...text.matchAll(/\S+/g)].map(m=>({word:m[0],start:m.index??0,end:(m.index??0)+m[0].length}));const ranges=[];for(let i=0;i<words.length;){let j=i;while(j<words.length-1&&j-i+1<MAX_PHRASE&&(bindsNext(words[j]?.word??"")||bindsPrev(words[j+1]?.word??"")))j++;const first=words[i];const last=words[j];if(j>i&&first&&last)ranges.push({start:first.start,end:last.end});i=j+1}return ranges};const hasFinal=ch=>(ch.charCodeAt(0)-44032)%28!==0;const isModifier=word=>{if(!/^[가-힣]{2,}$/.test(word))return false;const last=word.at(-1)??"";const stem=word.at(-2)??"";if(last==="\uB294")return hasFinal(stem)||/[하되이리오가주보지치키우두쓰뜨나내대르드]/.test(stem);if(last==="\uC740")return/[같작높낮좋많넓좁짧얇붙묶받읽남닫찾놓넣않깊밝]/.test(stem);return/[운된던]/.test(last)};const BARE_END=/[이가은는을를에의와과도만로서고며면게지요다나든야라니죠께해여어아듯]$/;const isBare=word=>/^[가-힣]+$/.test(word)&&!BARE_END.test(word)||/^[A-Za-z0-9][\w.+#-]*$/.test(word);const SPACED_PARTICLE=/^(?:이|가|은|는|을|를|의|와|과|도|만|로|으로|에|에서|에게|부터|까지|처럼|보다|마다|만큼|이나|나|라고|이라고|하고)(?:는|도|만|의)?[.,!?]*$/;const leansNext=(before,after)=>{if(!/^[가-힣\d]/.test(after))return false;return isBare(before)||isModifier(before)};const gapPenalty=(before,after)=>{if(endsSentence(before))return 0;if(bindsNext(before)||bindsPrev(after)||after==="\xB7")return 100;if(/[A-Za-z0-9"')\]”’>]$/.test(before)&&SPACED_PARTICLE.test(after))return 100;if(/[,:;]["')\]”’]*$/.test(before))return 1;if(endsSentence(after))return 12;if(/·$/.test(before))return 8;if(leansNext(before,after))return 6;return 4};export{endsSentence,gapPenalty,phraseRanges,splitSentences};
@@ -1 +1 @@
1
- import{gapPenalty}from"./core.js";const toWords=text=>{const words=[];for(const m of text.matchAll(/\S+/g)){const start=m.index??0;let from=0;for(let i=1;i<m[0].length;i++){const prev=m[0][i-1]??"";const cur=m[0][i]??"";if(cur==="("&&/[가-힣]/.test(prev)||prev===")"&&/[가-힣]/.test(cur)){words.push({text:m[0].slice(from,i),start:start+from,end:start+i,spaceBefore:from===0});from=i}}words.push({text:m[0].slice(from),start:start+from,end:start+m[0].length,spaceBefore:from===0})}if(words[0])words[0].spaceBefore=false;return words};const lineWidths=(words,widths,space)=>{const sum=[0];words.forEach((w,i)=>{sum.push((sum[i]??0)+(widths[i]??0)+(i>0&&w.spaceBefore?space:0))});return(from,to)=>(sum[to+1]??0)-(sum[from]??0)-(from>0&&words[from]?.spaceBefore?space:0)};const layoutNative=(words,measure,maxWidth)=>{const widths=words.map(w=>w.width??measure(w.text));const space=measure(" ");const breaks=[];let width=0;for(let i=0;i<words.length;i++){const w=widths[i]??0;const gap=words[i]?.spaceBefore?space:0;if(i>0&&width+gap+w>maxWidth&&width>0){breaks.push(i-1);width=w}else width=i===0||width===0?w:width+gap+w}return breaks};const scoreBreaks=(words,measure,maxWidth,breaks)=>{const widths=words.map(w=>w.width??measure(w.text));const space=measure(" ");const costs=breakCosts(words);const lineWidth=lineWidths(words,widths,space);let penalty=0;let ragged=0;let from=0;for(const end of breaks){penalty+=costs[end]??0;const slack=(maxWidth-lineWidth(from,end))/maxWidth;ragged+=slack*slack;from=end+1}return{penalty,ragged}};const breakCosts=words=>{const closesAfter=[];let closes=0;for(let i=words.length-1;i>=0;i--){closesAfter[i]=closes;closes+=[...words[i]?.text??""].filter(ch=>ch===")").length}let depth=0;return words.map((word,i)=>{for(const ch of word.text)depth=Math.max(0,depth+(ch==="("?1:ch===")"?-1:0));const open=Math.min(depth,closesAfter[i]??0);const next=words[i+1];let penalty=gapPenalty(word.text,next?.text??"");if(penalty===6&&(words[i-1]?.text==="\xB7"||words[i+2]?.text==="\xB7"))penalty=10;if(open>0)return Math.max(60,penalty);return next?.spaceBefore===false?Math.max(50,penalty):penalty})};const RAGGED_WEIGHT=2;const layoutBest=(words,measure,maxWidth,lines)=>{const n=words.length;if(n===0||lines<1||lines>n)return null;const widths=words.map(w=>w.width??measure(w.text));const space=measure(" ");const costs=breakCosts(words);const cost=Array.from({length:lines},()=>new Array(n).fill(Number.POSITIVE_INFINITY));const from=Array.from({length:lines},()=>new Array(n).fill(-1));const lineWidth=lineWidths(words,widths,space);const fits=(a,b)=>lineWidth(a,b)<=maxWidth;const slack=(a,b)=>{const s=(maxWidth-lineWidth(a,b))/maxWidth;return s*s*RAGGED_WEIGHT};for(let j2=0;j2<n;j2++)if(fits(0,j2))cost[0][j2]=0;for(let k=1;k<lines;k++){const prev=cost[k-1];const cur=cost[k];const at=from[k];for(let j2=k;j2<n;j2++){for(let i=k;i<=j2;i++){if(!fits(i,j2))continue;const before=prev[i-1]??Number.POSITIVE_INFINITY;if(before===Number.POSITIVE_INFINITY)continue;const startOfPrev=k-1===0?0:from[k-1][i-1]??0;const c=before+(costs[i-1]??0)+slack(startOfPrev,i-1);if(c<(cur[j2]??Number.POSITIVE_INFINITY)){cur[j2]=c;at[j2]=i}}}}if(cost[lines-1][n-1]===Number.POSITIVE_INFINITY)return null;const breaks=[];let j=n-1;for(let k=lines-1;k>0;k--){const i=from[k][j]??0;breaks.unshift(i-1);j=i-1}return breaks};const chooseBreaks=(text,measure,maxWidth)=>chooseWordBreaks(toWords(text),measure,maxWidth);const chooseWordBreaks=(words,measure,maxWidth,native=layoutNative(words,measure,maxWidth))=>{const keep={breaks:native,native,changed:false};if(native.length===0||words.some(w=>(w.width??measure(w.text))>maxWidth))return keep;const best=layoutBest(words,measure,maxWidth,native.length+1);if(!best)return keep;const a=scoreBreaks(words,measure,maxWidth,native);const b=scoreBreaks(words,measure,maxWidth,best);return b.penalty<a.penalty?{breaks:best,native,changed:true}:keep};export{chooseBreaks,chooseWordBreaks,layoutBest,layoutNative,scoreBreaks,toWords};
1
+ import{endsSentence,gapPenalty}from"./core.js";const toWords=text=>{const words=[];for(const m of text.matchAll(/\S+/g)){const start=m.index??0;let from=0;for(let i=1;i<m[0].length;i++){const prev=m[0][i-1]??"";const cur=m[0][i]??"";if(cur==="("&&/[가-힣]/.test(prev)||prev===")"&&/[가-힣]/.test(cur)){words.push({text:m[0].slice(from,i),start:start+from,end:start+i,spaceBefore:from===0});from=i}}words.push({text:m[0].slice(from),start:start+from,end:start+m[0].length,spaceBefore:from===0})}if(words[0])words[0].spaceBefore=false;return words};const lineWidths=(words,widths,space)=>{const sum=[0];words.forEach((w,i)=>{sum.push((sum[i]??0)+(widths[i]??0)+(i>0&&w.spaceBefore?space:0))});return(from,to)=>(sum[to+1]??0)-(sum[from]??0)-(from>0&&words[from]?.spaceBefore?space:0)};const layoutNative=(words,measure,maxWidth)=>{const widths=words.map(w=>w.width??measure(w.text));const space=measure(" ");const breaks=[];let width=0;for(let i=0;i<words.length;i++){const w=widths[i]??0;const gap=words[i]?.spaceBefore?space:0;if(i>0&&width+gap+w>maxWidth&&width>0){breaks.push(i-1);width=w}else width=i===0||width===0?w:width+gap+w}return breaks};const scoreBreaks=(words,measure,maxWidth,breaks)=>{const widths=words.map(w=>w.width??measure(w.text));const space=measure(" ");const costs=breakCosts(words);const lineWidth=lineWidths(words,widths,space);let penalty=0;let ragged=0;let from=0;for(const end of breaks){const slack=(maxWidth-lineWidth(from,end))/maxWidth;penalty+=(costs[end]??0)+(from>0?shortLine(slack):0);ragged+=slack*slack;from=end+1}return{penalty,ragged}};const SHORT_LINE=8;const shortLine=slack=>slack>.5?SHORT_LINE:0;const breakCosts=words=>{const closesAfter=[];let closes=0;for(let i=words.length-1;i>=0;i--){closesAfter[i]=closes;closes+=[...words[i]?.text??""].filter(ch=>ch===")").length}let depth=0;return words.map((word,i)=>{for(const ch of word.text)depth=Math.max(0,depth+(ch==="("?1:ch===")"?-1:0));const open=Math.min(depth,closesAfter[i]??0);const next=words[i+1];let penalty=gapPenalty(word.text,next?.text??"");if(next&&i>0&&endsSentence(words[i-1]?.text??"")&&!endsSentence(word.text))penalty=Math.max(100,penalty);if(penalty===6&&(words[i-1]?.text==="\xB7"||words[i+2]?.text==="\xB7"))penalty=10;if(open>0)return Math.max(60,penalty);return next?.spaceBefore===false?Math.max(50,penalty):penalty})};const RAGGED_WEIGHT=2;const layoutBest=(words,measure,maxWidth,lines)=>{const n=words.length;if(n===0||lines<1||lines>n)return null;const widths=words.map(w=>w.width??measure(w.text));const space=measure(" ");const costs=breakCosts(words);const cost=Array.from({length:lines},()=>new Array(n).fill(Number.POSITIVE_INFINITY));const from=Array.from({length:lines},()=>new Array(n).fill(-1));const lineWidth=lineWidths(words,widths,space);const fits=(a,b)=>lineWidth(a,b)<=maxWidth;const lineCost=(a,b,last)=>{if(last)return 0;const s=(maxWidth-lineWidth(a,b))/maxWidth;return s*s*RAGGED_WEIGHT+(a>0?shortLine(s):0)};for(let j2=0;j2<n;j2++)if(fits(0,j2))cost[0][j2]=lineCost(0,j2,lines===1&&j2===n-1);for(let k=1;k<lines;k++){const prev=cost[k-1];const cur=cost[k];const at=from[k];for(let j2=k;j2<n;j2++){for(let i=k;i<=j2;i++){if(!fits(i,j2))continue;const before=prev[i-1]??Number.POSITIVE_INFINITY;if(before===Number.POSITIVE_INFINITY)continue;const c=before+(costs[i-1]??0)+lineCost(i,j2,k===lines-1&&j2===n-1);if(c<(cur[j2]??Number.POSITIVE_INFINITY)){cur[j2]=c;at[j2]=i}}}}if(cost[lines-1][n-1]===Number.POSITIVE_INFINITY)return null;const breaks=[];let j=n-1;for(let k=lines-1;k>0;k--){const i=from[k][j]??0;breaks.unshift(i-1);j=i-1}return breaks};const chooseBreaks=(text,measure,maxWidth)=>chooseWordBreaks(toWords(text),measure,maxWidth);const chooseWordBreaks=(words,measure,maxWidth,native=layoutNative(words,measure,maxWidth))=>{const keep={breaks:native,native,changed:false};if(native.length===0||words.some(w=>(w.width??measure(w.text))>maxWidth))return keep;const best=layoutBest(words,measure,maxWidth,native.length+1);if(!best)return keep;const a=scoreBreaks(words,measure,maxWidth,native);const b=scoreBreaks(words,measure,maxWidth,best);return b.penalty<a.penalty?{breaks:best,native,changed:true}:keep};export{chooseBreaks,chooseWordBreaks,layoutBest,layoutNative,scoreBreaks,toWords};
@@ -1 +1 @@
1
- const balancedTextScript='(function(){var e=/(?:[^\\d]\\.|[!?])["\')\\]\u201D\u2019\u300D\u300F]*$/,t=new Set([`\uC774`,`\uADF8`,`\uC800`,`\uD55C`,`\uB450`,`\uC138`,`\uB124`,`\uAC01`,`\uBAA8\uB4E0`,`\uCCAB`,`\uC0C8`,`\uBA87`,`\uC628\uAC16`,`\uC5EC\uB7EC`,`\uC5B4\uB290`,`\uBB34\uC2A8`,`\uC774\uB7F0`,`\uADF8\uB7F0`,`\uC800\uB7F0`]),n=new Set([`\uD68C\uC758`,`\uB3D9\uC758`,`\uC8FC\uC758`,`\uD611\uC758`,`\uB17C\uC758`,`\uAC74\uC758`,`\uD569\uC758`,`\uBB38\uC758`,`\uAC15\uC758`,`\uC815\uC758`,`\uC758\uC758`,`\uD3B8\uC758`,`\uC608\uC758`,`\uC131\uC758`,`\uACB0\uC758`,`\uBAA8\uC758`,`\uC2EC\uC758`,`\uD1A0\uC758`,`\uC9C8\uC758`,`\uD56D\uC758`]),r=e=>/[\uAC00-\uD7A3]\uC758$/.test(e)&&!n.has(e)&&!/[\uAC00-\uD7A3]\uC8FC\uC758$/.test(e)||t.has(e),i=/^(?:\uC785\uB2C8\uB2E4|\uC785\uB2C8\uAE4C|\uC774\uB2E4|\uC774\uC5D0\uC694|\uC608\uC694|\uC774\uC8E0|\uC774\uACE0|\uC774\uBA70|\uC774\uBA74|(?:\uC218|\uAC83|\uB54C|\uC904|\uBFD0|\uB4EF|\uB9CC\uD07C|\uC911)(?:\uAC00|\uB3C4|\uB294|\uC740|\uC744|\uB97C|\uC774|\uC5D0|\uC5D0\uC11C|\uC5D0\uB294|\uB9CC|\uC774\uB2E4|\uC785\uB2C8\uB2E4|\uC774\uC5D0\uC694|\uC608\uC694|\uC774\uC8E0)?)[.,!?"\')\\]\u201D\u2019]*$/,a=e=>i.test(e),o=e=>(e.charCodeAt(0)-44032)%28!=0,s=e=>{if(!/^[\uAC00-\uD7A3]{2,}$/.test(e))return!1;let t=e.at(-1)??``,n=e.at(-2)??``;return t===`\uB294`?o(n)||/[\uD558\uB418\uC774\uB9AC\uC624\uAC00\uC8FC\uBCF4\uC9C0\uCE58\uD0A4\uC6B0\uB450\uC4F0\uB728\uB098\uB0B4\uB300\uB974\uB4DC]/.test(n):t===`\uC740`?/[\uAC19\uC791\uB192\uB0AE\uC88B\uB9CE\uB113\uC881\uC9E7\uC587\uBD99\uBB36\uBC1B\uC77D\uB0A8\uB2EB\uCC3E\uB193\uB123\uC54A\uAE4A\uBC1D]/.test(n):/[\uC6B4\uB41C\uB358]/.test(t)},c=/[\uC774\uAC00\uC740\uB294\uC744\uB97C\uC5D0\uC758\uC640\uACFC\uB3C4\uB9CC\uB85C\uC11C\uACE0\uBA70\uBA74\uAC8C\uC9C0\uC694\uB2E4\uB098\uB4E0\uC57C\uB77C\uB2C8\uC8E0\uAED8\uD574\uC5EC\uC5B4\uC544\uB4EF]$/,l=e=>/^[\uAC00-\uD7A3]+$/.test(e)&&!c.test(e)||/^[A-Za-z0-9][\\w.+#-]*$/.test(e),u=/^(?:\uC774|\uAC00|\uC740|\uB294|\uC744|\uB97C|\uC758|\uC640|\uACFC|\uB3C4|\uB9CC|\uB85C|\uC73C\uB85C|\uC5D0|\uC5D0\uC11C|\uC5D0\uAC8C|\uBD80\uD130|\uAE4C\uC9C0|\uCC98\uB7FC|\uBCF4\uB2E4|\uB9C8\uB2E4|\uB9CC\uD07C|\uC774\uB098|\uB098|\uB77C\uACE0|\uC774\uB77C\uACE0|\uD558\uACE0)(?:\uB294|\uB3C4|\uB9CC|\uC758)?[.,!?]*$/,d=(e,t)=>/^[\uAC00-\uD7A3\\d]/.test(t)?l(e)||s(e):!1,f=(t,n)=>e.test(t)?0:r(t)||a(n)||n===`\xB7`||/[A-Za-z0-9"\')\\]\u201D\u2019>]$/.test(t)&&u.test(n)?100:/[,:;]["\')\\]\u201D\u2019]*$/.test(t)?1:e.test(n)?12:/\xB7$/.test(t)?8:d(t,n)?6:4,p=(e,t,n)=>{let r=[0];return e.forEach((e,i)=>{r.push((r[i]??0)+(t[i]??0)+(i>0&&e.spaceBefore?n:0))}),(t,i)=>(r[i+1]??0)-(r[t]??0)-(t>0&&e[t]?.spaceBefore?n:0)},m=(e,t,n)=>{let r=e.map(e=>e.width??t(e.text)),i=t(` `),a=[],o=0;for(let t=0;t<e.length;t++){let s=r[t]??0,c=e[t]?.spaceBefore?i:0;t>0&&o+c+s>n&&o>0?(a.push(t-1),o=s):o=t===0||o===0?s:o+c+s}return a},h=(e,t,n,r)=>{let i=e.map(e=>e.width??t(e.text)),a=t(` `),o=g(e),s=p(e,i,a),c=0,l=0,u=0;for(let e of r){c+=o[e]??0;let t=(n-s(u,e))/n;l+=t*t,u=e+1}return{penalty:c,ragged:l}},g=e=>{let t=[],n=0;for(let r=e.length-1;r>=0;r--)t[r]=n,n+=[...e[r]?.text??``].filter(e=>e===`)`).length;let r=0;return e.map((n,i)=>{for(let e of n.text)r=Math.max(0,r+(e===`(`?1:e===`)`?-1:0));let a=Math.min(r,t[i]??0),o=e[i+1],s=f(n.text,o?.text??``);return s===6&&(e[i-1]?.text===`\xB7`||e[i+2]?.text===`\xB7`)&&(s=10),a>0?Math.max(60,s):o?.spaceBefore===!1?Math.max(50,s):s})},_=2,v=(e,t,n,r)=>{let i=e.length;if(i===0||r<1||r>i)return null;let a=e.map(e=>e.width??t(e.text)),o=t(` `),s=g(e),c=Array.from({length:r},()=>Array(i).fill(1/0)),l=Array.from({length:r},()=>Array(i).fill(-1)),u=p(e,a,o),d=(e,t)=>u(e,t)<=n,f=(e,t)=>{let r=(n-u(e,t))/n;return r*r*_};for(let e=0;e<i;e++)d(0,e)&&(c[0][e]=0);for(let e=1;e<r;e++){let t=c[e-1],n=c[e],r=l[e];for(let a=e;a<i;a++)for(let i=e;i<=a;i++){if(!d(i,a))continue;let o=t[i-1]??1/0;if(o===1/0)continue;let c=e-1==0?0:l[e-1][i-1]??0,u=o+(s[i-1]??0)+f(c,i-1);u<(n[a]??1/0)&&(n[a]=u,r[a]=i)}}if(c[r-1][i-1]===1/0)return null;let m=[],h=i-1;for(let e=r-1;e>0;e--){let t=l[e][h]??0;m.unshift(t-1),h=t-1}return m},y=(e,t,n,r=m(e,t,n))=>{let i={breaks:r,native:r,changed:!1};if(r.length===0||e.some(e=>(e.width??t(e.text))>n))return i;let a=v(e,t,n,r.length+1);if(!a)return i;let o=h(e,t,n,r);return h(e,t,n,a).penalty<o.penalty?{breaks:a,native:r,changed:!0}:i},b=(e,t=0)=>{if(typeof document>`u`)return null;let n=document.createElement(`canvas`).getContext(`2d`);if(!n)return null;n.font=e;let r=new Map,i=(e=>{let i=r.get(e);if(i!==void 0)return i;let a=n.measureText(e).width+t*[...e].length;return r.set(e,a),a});return i.clear=()=>r.clear(),i},x=e=>{let t=getComputedStyle(e),n=Number.parseFloat(t.letterSpacing);return{font:`${t.fontStyle} ${t.fontWeight} ${t.fontSize} ${t.fontFamily}`,letterSpacing:Number.isFinite(n)?n:0}},S=`text_balanced_word`,C=`data-balanced`,w=`bt-balanced-prehydrate`,T=e=>`[${C}="${e.replace(/["\\\\]/g,`\\\\$&`)}"]`,E=e=>{let t=getComputedStyle(e);return e.clientWidth-Number.parseFloat(t.paddingLeft)-Number.parseFloat(t.paddingRight)},D=e=>[...e.querySelectorAll(`.${S}`)].filter(t=>!e.contains(t.parentElement?.closest(`.text_balanced_word`)??null)),O=e=>{let t=``;for(let n=e.previousSibling;n&&!(n instanceof Element&&n.classList.contains(`text_balanced_word`));n=n.previousSibling)t+=n.textContent??``;return/\\s/.test(t)},k=e=>{let t=[...e.getClientRects()];if(new Set(t.map(e=>Math.round(e.top))).size<2)return t.reduce((e,t)=>e+t.width,0);e.classList.add(`text_balanced_word_measure`);let n=e.getBoundingClientRect().width;return e.classList.remove(`text_balanced_word_measure`),n},A=(e,t)=>{let n=E(e),r=D(e);if(n<=0||r.length===0)return null;let i=n-1,a=r.map((e,t)=>({text:e.textContent??``,start:0,end:0,spaceBefore:t>0&&O(e),width:k(e)}));if(a.some(e=>(e.width??0)>i))return null;let o=0,s=r.map(e=>{let t=[...e.getClientRects()].map(e=>Math.round(e.top));return t.length===0?[o]:(o=t.at(-1)??o,t)}),c=new Set(s.flat()).size,l=s.some(e=>new Set(e).size>1),u=m(a,t,i).length+1,d=e=>{let n=v(a,t,i,e);return n&&h(a,t,i,n).penalty<100?n:null};if(l||u<c){let e=d(Math.min(u,c));if(e)return e;if(l)return d(c)??d(c+1)}let f=s.flatMap((e,t)=>t>0&&e[0]!==s[t-1]?.[0]?[t-1]:[]),p=y(a,t,i,f).breaks;return h(a,t,i,p).penalty>=100?d(f.length+2)??p:p},j=e=>{let t=typeof document>`u`?void 0:document.fonts;if(!t?.check)return null;let{font:n}=x(e),r=(e.textContent??``).slice(0,64);try{return t.check(n,r)?null:t.load(n,r)}catch{return null}},M=e=>{let t=e.getAttribute(C),n=document.getElementById(w)?.sheet;if(!t||!n)return;let r=T(t);for(let e=n.cssRules.length-1;e>=0;e--)n.cssRules[e].selectorText?.startsWith(r)&&n.deleteRule(e)};(()=>{let e=document,t=e.getElementById(w);t||(t=e.createElement(`style`),t.id=w,e.head.appendChild(t));let n=t.sheet;if(!n)return;let r=e=>{let t=e.getAttribute(C);if(!t||e.querySelector(`:scope > .text_balanced_line`))return;let r=j(e);if(r){r.catch(()=>{});return}let{font:i,letterSpacing:a}=x(e),o=b(i,a),s=o&&A(e,o);if(!s?.length)return;let c=T(t),l=e.clientWidth;try{n.insertRule(`${c}{white-space:nowrap}`,n.cssRules.length),n.insertRule(`${c} wbr{display:none}`,n.cssRules.length);for(let e of s)n.insertRule(`${c}>.${S}:nth-child(${e+1} of .${S})::after{content:"\\\\A";white-space:pre}`,n.cssRules.length)}catch{M(e);return}let u=e.getBoundingClientRect().right-Number.parseFloat(getComputedStyle(e).paddingRight),d=e.querySelectorAll(`:scope > .${S}`);(e.clientWidth>l+.5||[...d].some(e=>e.getBoundingClientRect().right>u+.5))&&M(e)};for(let t of e.querySelectorAll(`[${C}]`))r(t);addEventListener(`resize`,()=>t?.remove(),{once:!0})})()})();';export{balancedTextScript};
1
+ const balancedTextScript='(function(){var e=/(?:[^\\d]\\.|[!?])["\')\\]\u201D\u2019\u300D\u300F]*$/,t=/(?:^|[^A-Za-z])(?:[A-Za-z]\\.){2,}["\')\\]\u201D\u2019\u300D\u300F]*$/,n=n=>e.test(n)&&!t.test(n),r=new Set([`\uC774`,`\uADF8`,`\uC800`,`\uD55C`,`\uB450`,`\uC138`,`\uB124`,`\uAC01`,`\uBAA8\uB4E0`,`\uCCAB`,`\uC0C8`,`\uBA87`,`\uC628\uAC16`,`\uC5EC\uB7EC`,`\uC5B4\uB290`,`\uBB34\uC2A8`,`\uC774\uB7F0`,`\uADF8\uB7F0`,`\uC800\uB7F0`]),i=new Set([`\uD68C\uC758`,`\uB3D9\uC758`,`\uC8FC\uC758`,`\uD611\uC758`,`\uB17C\uC758`,`\uAC74\uC758`,`\uD569\uC758`,`\uBB38\uC758`,`\uAC15\uC758`,`\uC815\uC758`,`\uC758\uC758`,`\uD3B8\uC758`,`\uC608\uC758`,`\uC131\uC758`,`\uACB0\uC758`,`\uBAA8\uC758`,`\uC2EC\uC758`,`\uD1A0\uC758`,`\uC9C8\uC758`,`\uD56D\uC758`]),a=e=>/[\uAC00-\uD7A3]\uC758$/.test(e)&&!i.has(e)&&!/[\uAC00-\uD7A3]\uC8FC\uC758$/.test(e)||r.has(e),o=/^(?:\uC785\uB2C8\uB2E4|\uC785\uB2C8\uAE4C|\uC774\uB2E4|\uC774\uC5D0\uC694|\uC608\uC694|\uC774\uC8E0|\uC774\uACE0|\uC774\uBA70|\uC774\uBA74|(?:\uC218|\uAC83|\uB54C|\uC904|\uBFD0|\uB4EF|\uB9CC\uD07C|\uC911)(?:\uAC00|\uB3C4|\uB294|\uC740|\uC744|\uB97C|\uC774|\uC5D0|\uC5D0\uC11C|\uC5D0\uB294|\uB9CC|\uC774\uB2E4|\uC785\uB2C8\uB2E4|\uC774\uC5D0\uC694|\uC608\uC694|\uC774\uC8E0)?)[.,!?"\')\\]\u201D\u2019]*$/,s=e=>o.test(e),c=e=>(e.charCodeAt(0)-44032)%28!=0,l=e=>{if(!/^[\uAC00-\uD7A3]{2,}$/.test(e))return!1;let t=e.at(-1)??``,n=e.at(-2)??``;return t===`\uB294`?c(n)||/[\uD558\uB418\uC774\uB9AC\uC624\uAC00\uC8FC\uBCF4\uC9C0\uCE58\uD0A4\uC6B0\uB450\uC4F0\uB728\uB098\uB0B4\uB300\uB974\uB4DC]/.test(n):t===`\uC740`?/[\uAC19\uC791\uB192\uB0AE\uC88B\uB9CE\uB113\uC881\uC9E7\uC587\uBD99\uBB36\uBC1B\uC77D\uB0A8\uB2EB\uCC3E\uB193\uB123\uC54A\uAE4A\uBC1D]/.test(n):/[\uC6B4\uB41C\uB358]/.test(t)},u=/[\uC774\uAC00\uC740\uB294\uC744\uB97C\uC5D0\uC758\uC640\uACFC\uB3C4\uB9CC\uB85C\uC11C\uACE0\uBA70\uBA74\uAC8C\uC9C0\uC694\uB2E4\uB098\uB4E0\uC57C\uB77C\uB2C8\uC8E0\uAED8\uD574\uC5EC\uC5B4\uC544\uB4EF]$/,d=e=>/^[\uAC00-\uD7A3]+$/.test(e)&&!u.test(e)||/^[A-Za-z0-9][\\w.+#-]*$/.test(e),f=/^(?:\uC774|\uAC00|\uC740|\uB294|\uC744|\uB97C|\uC758|\uC640|\uACFC|\uB3C4|\uB9CC|\uB85C|\uC73C\uB85C|\uC5D0|\uC5D0\uC11C|\uC5D0\uAC8C|\uBD80\uD130|\uAE4C\uC9C0|\uCC98\uB7FC|\uBCF4\uB2E4|\uB9C8\uB2E4|\uB9CC\uD07C|\uC774\uB098|\uB098|\uB77C\uACE0|\uC774\uB77C\uACE0|\uD558\uACE0)(?:\uB294|\uB3C4|\uB9CC|\uC758)?[.,!?]*$/,p=(e,t)=>/^[\uAC00-\uD7A3\\d]/.test(t)?d(e)||l(e):!1,m=(e,t)=>n(e)?0:a(e)||s(t)||t===`\xB7`||/[A-Za-z0-9"\')\\]\u201D\u2019>]$/.test(e)&&f.test(t)?100:/[,:;]["\')\\]\u201D\u2019]*$/.test(e)?1:n(t)?12:/\xB7$/.test(e)?8:p(e,t)?6:4,h=(e,t,n)=>{let r=[0];return e.forEach((e,i)=>{r.push((r[i]??0)+(t[i]??0)+(i>0&&e.spaceBefore?n:0))}),(t,i)=>(r[i+1]??0)-(r[t]??0)-(t>0&&e[t]?.spaceBefore?n:0)},g=(e,t,n)=>{let r=e.map(e=>e.width??t(e.text)),i=t(` `),a=[],o=0;for(let t=0;t<e.length;t++){let s=r[t]??0,c=e[t]?.spaceBefore?i:0;t>0&&o+c+s>n&&o>0?(a.push(t-1),o=s):o=t===0||o===0?s:o+c+s}return a},_=(e,t,n,r)=>{let i=e.map(e=>e.width??t(e.text)),a=t(` `),o=b(e),s=h(e,i,a),c=0,l=0,u=0;for(let e of r){let t=(n-s(u,e))/n;c+=(o[e]??0)+(u>0?y(t):0),l+=t*t,u=e+1}return{penalty:c,ragged:l}},v=8,y=e=>e>.5?v:0,b=e=>{let t=[],r=0;for(let n=e.length-1;n>=0;n--)t[n]=r,r+=[...e[n]?.text??``].filter(e=>e===`)`).length;let i=0;return e.map((r,a)=>{for(let e of r.text)i=Math.max(0,i+(e===`(`?1:e===`)`?-1:0));let o=Math.min(i,t[a]??0),s=e[a+1],c=m(r.text,s?.text??``);return s&&a>0&&n(e[a-1]?.text??``)&&!n(r.text)&&(c=Math.max(100,c)),c===6&&(e[a-1]?.text===`\xB7`||e[a+2]?.text===`\xB7`)&&(c=10),o>0?Math.max(60,c):s?.spaceBefore===!1?Math.max(50,c):c})},x=2,S=(e,t,n,r)=>{let i=e.length;if(i===0||r<1||r>i)return null;let a=e.map(e=>e.width??t(e.text)),o=t(` `),s=b(e),c=Array.from({length:r},()=>Array(i).fill(1/0)),l=Array.from({length:r},()=>Array(i).fill(-1)),u=h(e,a,o),d=(e,t)=>u(e,t)<=n,f=(e,t,r)=>{if(r)return 0;let i=(n-u(e,t))/n;return i*i*x+(e>0?y(i):0)};for(let e=0;e<i;e++)d(0,e)&&(c[0][e]=f(0,e,r===1&&e===i-1));for(let e=1;e<r;e++){let t=c[e-1],n=c[e],a=l[e];for(let o=e;o<i;o++)for(let c=e;c<=o;c++){if(!d(c,o))continue;let l=t[c-1]??1/0;if(l===1/0)continue;let u=l+(s[c-1]??0)+f(c,o,e===r-1&&o===i-1);u<(n[o]??1/0)&&(n[o]=u,a[o]=c)}}if(c[r-1][i-1]===1/0)return null;let p=[],m=i-1;for(let e=r-1;e>0;e--){let t=l[e][m]??0;p.unshift(t-1),m=t-1}return p},C=(e,t,n,r=g(e,t,n))=>{let i={breaks:r,native:r,changed:!1};if(r.length===0||e.some(e=>(e.width??t(e.text))>n))return i;let a=S(e,t,n,r.length+1);if(!a)return i;let o=_(e,t,n,r);return _(e,t,n,a).penalty<o.penalty?{breaks:a,native:r,changed:!0}:i},w=(e,t=0)=>{if(typeof document>`u`)return null;let n=document.createElement(`canvas`).getContext(`2d`);if(!n)return null;n.font=e;let r=new Map,i=(e=>{let i=r.get(e);if(i!==void 0)return i;let a=n.measureText(e).width+t*[...e].length;return r.set(e,a),a});return i.clear=()=>r.clear(),i},T=e=>{let t=getComputedStyle(e),n=Number.parseFloat(t.letterSpacing);return{font:`${t.fontStyle} ${t.fontWeight} ${t.fontSize} ${t.fontFamily}`,letterSpacing:Number.isFinite(n)?n:0}},E=`text_balanced_word`,D=`data-balanced`,O=`bt-balanced-prehydrate`,k=e=>`[${D}="${e.replace(/["\\\\]/g,`\\\\$&`)}"]`,A=e=>{let t=getComputedStyle(e);return e.clientWidth-Number.parseFloat(t.paddingLeft)-Number.parseFloat(t.paddingRight)},j=e=>[...e.querySelectorAll(`.${E}`)].filter(t=>!e.contains(t.parentElement?.closest(`.text_balanced_word`)??null)),M=e=>{let t=``;for(let n=e.previousSibling;n&&!(n instanceof Element&&n.classList.contains(`text_balanced_word`));n=n.previousSibling)t+=n.textContent??``;return/\\s/.test(t)},N=e=>{let t=[...e.getClientRects()];if(new Set(t.map(e=>Math.round(e.top))).size<2)return t.reduce((e,t)=>e+t.width,0);e.classList.add(`text_balanced_word_measure`);let n=e.getBoundingClientRect().width;return e.classList.remove(`text_balanced_word_measure`),n},P=(e,t)=>{let n=A(e),r=j(e);if(n<=0||r.length===0)return null;let i=n-1,a=r.map((e,t)=>({text:e.textContent??``,start:0,end:0,spaceBefore:t>0&&M(e),width:N(e)}));if(a.some(e=>(e.width??0)>i))return null;let o=0,s=r.map(e=>{let t=[...e.getClientRects()].map(e=>Math.round(e.top));return t.length===0?[o]:(o=t.at(-1)??o,t)}),c=new Set(s.flat()).size,l=s.some(e=>new Set(e).size>1),u=g(a,t,i).length+1,d=e=>{let n=S(a,t,i,e);return n&&_(a,t,i,n).penalty<100?n:null};if(l||u<c){let e=d(Math.min(u,c));if(e)return e;if(l)return d(c)??d(c+1)}let f=s.flatMap((e,t)=>t>0&&e[0]!==s[t-1]?.[0]?[t-1]:[]),p=C(a,t,i,f).breaks;return _(a,t,i,p).penalty>=100?d(f.length+2)??p:p},F=e=>{let t=typeof document>`u`?void 0:document.fonts;if(!t?.check)return null;let{font:n}=T(e),r=(e.textContent??``).slice(0,64);try{return t.check(n,r)?null:t.load(n,r)}catch{return null}},I=e=>{let t=e.getAttribute(D),n=document.getElementById(O)?.sheet;if(!t||!n)return;let r=k(t);for(let e=n.cssRules.length-1;e>=0;e--)n.cssRules[e].selectorText?.startsWith(r)&&n.deleteRule(e)};(()=>{let e=document,t=e.getElementById(O);t||(t=e.createElement(`style`),t.id=O,e.head.appendChild(t));let n=t.sheet;if(!n)return;let r=e=>{let t=e.getAttribute(D);if(!t||e.querySelector(`:scope > .text_balanced_line`))return;let r=F(e);if(r){r.catch(()=>{});return}let{font:i,letterSpacing:a}=T(e),o=w(i,a),s=o&&P(e,o);if(!s?.length)return;let c=k(t),l=e.clientWidth;try{n.insertRule(`${c}{white-space:nowrap}`,n.cssRules.length),n.insertRule(`${c} wbr{display:none}`,n.cssRules.length);for(let e of s)n.insertRule(`${c}>.${E}:nth-child(${e+1} of .${E})::after{content:"\\\\A";white-space:pre}`,n.cssRules.length)}catch{I(e);return}let u=e.getBoundingClientRect().right-Number.parseFloat(getComputedStyle(e).paddingRight),d=e.querySelectorAll(`:scope > .${E}`);(e.clientWidth>l+.5||[...d].some(e=>e.getBoundingClientRect().right>u+.5))&&I(e)};for(let t of e.querySelectorAll(`[${D}]`))r(t);addEventListener(`resize`,()=>t?.remove(),{once:!0})})()})();';export{balancedTextScript};
@@ -1,4 +1,4 @@
1
1
  @charset "UTF-8";
2
2
  @layer theme, base, reset, bigtablet, components, utilities;
3
3
  @layer bigtablet {
4
- .sentences_item{display:inline-block}.sentences_phrase{display:inline-block}.text_balanced{text-wrap:pretty}.text_balanced_line{white-space:nowrap}.text_balanced_line wbr,.text_balanced_word_measure wbr{display:none}.text_balanced_word_measure{white-space:nowrap}.text_balanced_line_boxed,.text_balanced_probe>.text_balanced_line{display:inline-block;white-space:normal}}
4
+ .sentences_item{display:inline-block}.sentences_phrase{display:inline-block}.text_balanced{text-wrap:pretty}:where(span).text_balanced{display:block}.text_balanced_line{white-space:nowrap}.text_balanced_line wbr,.text_balanced_word_measure wbr{display:none}.text_balanced_word_measure{white-space:nowrap}.text_balanced_line_boxed,.text_balanced_probe>.text_balanced_line{display:inline-block;white-space:normal}}