masoneffect 2.0.2 → 2.0.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.
Files changed (212) hide show
  1. package/README.md +4 -4
  2. package/dist/core/index.d.ts +2 -0
  3. package/dist/core/index.d.ts.map +1 -1
  4. package/dist/core/typing/index.d.ts +52 -0
  5. package/dist/core/typing/index.d.ts.map +1 -0
  6. package/dist/count/core/index.d.ts +2 -0
  7. package/dist/count/core/index.d.ts.map +1 -1
  8. package/dist/count/core/typing/index.d.ts +52 -0
  9. package/dist/count/core/typing/index.d.ts.map +1 -0
  10. package/dist/count/index.d.ts +2 -0
  11. package/dist/count/index.d.ts.map +1 -1
  12. package/dist/count/react/index.d.ts +2 -0
  13. package/dist/count/react/index.d.ts.map +1 -1
  14. package/dist/count/react/typing/Typing.d.ts +18 -0
  15. package/dist/count/react/typing/Typing.d.ts.map +1 -0
  16. package/dist/count/react/typing/index.d.ts +4 -0
  17. package/dist/count/react/typing/index.d.ts.map +1 -0
  18. package/dist/count/svelte/index.d.ts +1 -0
  19. package/dist/count/svelte/index.d.ts.map +1 -1
  20. package/dist/count/svelte/typing/index.d.ts +3 -0
  21. package/dist/count/svelte/typing/index.d.ts.map +1 -0
  22. package/dist/count/vue/index.d.ts +1 -0
  23. package/dist/count/vue/index.d.ts.map +1 -1
  24. package/dist/count/vue/typing/index.d.ts +4 -0
  25. package/dist/count/vue/typing/index.d.ts.map +1 -0
  26. package/dist/index.cjs +1 -1
  27. package/dist/index.d.ts +2 -0
  28. package/dist/index.d.ts.map +1 -1
  29. package/dist/index.mjs +1 -1
  30. package/dist/react/core/index.d.ts +2 -0
  31. package/dist/react/core/typing/index.d.ts +51 -0
  32. package/dist/react/count/core/index.d.ts +2 -0
  33. package/dist/react/count/core/index.d.ts.map +1 -1
  34. package/dist/react/count/core/typing/index.d.ts +52 -0
  35. package/dist/react/count/core/typing/index.d.ts.map +1 -0
  36. package/dist/react/count/index.d.ts +2 -0
  37. package/dist/react/count/index.d.ts.map +1 -1
  38. package/dist/react/count/react/index.d.ts +2 -0
  39. package/dist/react/count/react/index.d.ts.map +1 -1
  40. package/dist/react/count/react/typing/Typing.d.ts +18 -0
  41. package/dist/react/count/react/typing/Typing.d.ts.map +1 -0
  42. package/dist/react/count/react/typing/index.d.ts +4 -0
  43. package/dist/react/count/react/typing/index.d.ts.map +1 -0
  44. package/dist/react/count/svelte/index.d.ts +1 -0
  45. package/dist/react/count/svelte/index.d.ts.map +1 -1
  46. package/dist/react/count/svelte/typing/index.d.ts +3 -0
  47. package/dist/react/count/svelte/typing/index.d.ts.map +1 -0
  48. package/dist/react/count/vue/index.d.ts +1 -0
  49. package/dist/react/count/vue/index.d.ts.map +1 -1
  50. package/dist/react/count/vue/typing/index.d.ts +4 -0
  51. package/dist/react/count/vue/typing/index.d.ts.map +1 -0
  52. package/dist/react/index.cjs +2 -0
  53. package/dist/react/index.d.ts.map +1 -1
  54. package/dist/react/index.mjs +1 -0
  55. package/dist/react/react/index.d.ts +2 -0
  56. package/dist/react/react/typing/Typing.d.ts +17 -0
  57. package/dist/react/react/typing/index.d.ts +3 -0
  58. package/dist/react/svelte/index.d.ts +1 -0
  59. package/dist/react/svelte/typing/index.d.ts +2 -0
  60. package/dist/react/textToParticle/core/index.d.ts +2 -0
  61. package/dist/react/textToParticle/core/index.d.ts.map +1 -1
  62. package/dist/react/textToParticle/core/typing/index.d.ts +52 -0
  63. package/dist/react/textToParticle/core/typing/index.d.ts.map +1 -0
  64. package/dist/react/textToParticle/index.d.ts +2 -0
  65. package/dist/react/textToParticle/index.d.ts.map +1 -1
  66. package/dist/react/textToParticle/react/index.d.ts +2 -0
  67. package/dist/react/textToParticle/react/index.d.ts.map +1 -1
  68. package/dist/react/textToParticle/react/typing/Typing.d.ts +18 -0
  69. package/dist/react/textToParticle/react/typing/Typing.d.ts.map +1 -0
  70. package/dist/react/textToParticle/react/typing/index.d.ts +4 -0
  71. package/dist/react/textToParticle/react/typing/index.d.ts.map +1 -0
  72. package/dist/react/textToParticle/svelte/index.d.ts +1 -0
  73. package/dist/react/textToParticle/svelte/index.d.ts.map +1 -1
  74. package/dist/react/textToParticle/svelte/typing/index.d.ts +3 -0
  75. package/dist/react/textToParticle/svelte/typing/index.d.ts.map +1 -0
  76. package/dist/react/textToParticle/vue/index.d.ts +1 -0
  77. package/dist/react/textToParticle/vue/index.d.ts.map +1 -1
  78. package/dist/react/textToParticle/vue/typing/index.d.ts +4 -0
  79. package/dist/react/textToParticle/vue/typing/index.d.ts.map +1 -0
  80. package/dist/react/typing/Typing.d.ts +18 -0
  81. package/dist/react/typing/Typing.d.ts.map +1 -0
  82. package/dist/react/typing/core/count/index.d.ts +52 -0
  83. package/dist/react/typing/core/count/index.d.ts.map +1 -0
  84. package/dist/react/typing/core/index.d.ts +20 -0
  85. package/dist/react/typing/core/index.d.ts.map +1 -0
  86. package/dist/react/typing/core/textToParticle/index.d.ts +103 -0
  87. package/dist/react/typing/core/textToParticle/index.d.ts.map +1 -0
  88. package/dist/react/typing/core/typing/index.d.ts +52 -0
  89. package/dist/react/typing/core/typing/index.d.ts.map +1 -0
  90. package/dist/react/typing/index.cjs +1 -0
  91. package/dist/react/typing/index.d.ts +18 -0
  92. package/dist/react/typing/index.d.ts.map +1 -0
  93. package/dist/react/typing/index.mjs +1 -0
  94. package/dist/react/typing/index.umd.d.ts +7 -0
  95. package/dist/react/typing/index.umd.d.ts.map +1 -0
  96. package/dist/react/typing/react/MasonEffect.d.ts +32 -0
  97. package/dist/react/typing/react/MasonEffect.d.ts.map +1 -0
  98. package/dist/react/typing/react/count/Count.d.ts +19 -0
  99. package/dist/react/typing/react/count/Count.d.ts.map +1 -0
  100. package/dist/react/typing/react/count/index.d.ts +5 -0
  101. package/dist/react/typing/react/count/index.d.ts.map +1 -0
  102. package/dist/react/typing/react/index.d.ts +14 -0
  103. package/dist/react/typing/react/index.d.ts.map +1 -0
  104. package/dist/react/typing/react/textToParticle/TextToParticle.d.ts +15 -0
  105. package/dist/react/typing/react/textToParticle/TextToParticle.d.ts.map +1 -0
  106. package/dist/react/typing/react/textToParticle/index.d.ts +4 -0
  107. package/dist/react/typing/react/textToParticle/index.d.ts.map +1 -0
  108. package/dist/react/typing/react/typing/Typing.d.ts +18 -0
  109. package/dist/react/typing/react/typing/Typing.d.ts.map +1 -0
  110. package/dist/react/typing/react/typing/index.d.ts +4 -0
  111. package/dist/react/typing/react/typing/index.d.ts.map +1 -0
  112. package/dist/react/typing/svelte/count/index.d.ts +2 -0
  113. package/dist/react/typing/svelte/count/index.d.ts.map +1 -0
  114. package/dist/react/typing/svelte/index.d.ts +9 -0
  115. package/dist/react/typing/svelte/index.d.ts.map +1 -0
  116. package/dist/react/typing/svelte/textToParticle/index.d.ts +2 -0
  117. package/dist/react/typing/svelte/textToParticle/index.d.ts.map +1 -0
  118. package/dist/react/typing/svelte/typing/index.d.ts +3 -0
  119. package/dist/react/typing/svelte/typing/index.d.ts.map +1 -0
  120. package/dist/react/typing/vue/count/index.d.ts +2 -0
  121. package/dist/react/typing/vue/count/index.d.ts.map +1 -0
  122. package/dist/react/typing/vue/index.d.ts +9 -0
  123. package/dist/react/typing/vue/index.d.ts.map +1 -0
  124. package/dist/react/typing/vue/textToParticle/index.d.ts +2 -0
  125. package/dist/react/typing/vue/textToParticle/index.d.ts.map +1 -0
  126. package/dist/react/typing/vue/typing/index.d.ts +4 -0
  127. package/dist/react/typing/vue/typing/index.d.ts.map +1 -0
  128. package/dist/react/vue/index.d.ts +1 -0
  129. package/dist/react/vue/typing/index.d.ts +3 -0
  130. package/dist/svelte/count/index.d.ts +52 -0
  131. package/dist/svelte/index.cjs +1 -1
  132. package/dist/svelte/index.d.ts +52 -0
  133. package/dist/svelte/index.mjs +415 -48
  134. package/dist/svelte/textToParticle/index.d.ts +52 -0
  135. package/dist/svelte/typing/index.cjs +1 -0
  136. package/dist/svelte/typing/index.d.ts +215 -0
  137. package/dist/svelte/typing/index.mjs +634 -0
  138. package/dist/textToParticle/core/index.d.ts +2 -0
  139. package/dist/textToParticle/core/index.d.ts.map +1 -1
  140. package/dist/textToParticle/core/typing/index.d.ts +52 -0
  141. package/dist/textToParticle/core/typing/index.d.ts.map +1 -0
  142. package/dist/textToParticle/index.d.ts +2 -0
  143. package/dist/textToParticle/index.d.ts.map +1 -1
  144. package/dist/textToParticle/react/index.d.ts +2 -0
  145. package/dist/textToParticle/react/index.d.ts.map +1 -1
  146. package/dist/textToParticle/react/typing/Typing.d.ts +18 -0
  147. package/dist/textToParticle/react/typing/Typing.d.ts.map +1 -0
  148. package/dist/textToParticle/react/typing/index.d.ts +4 -0
  149. package/dist/textToParticle/react/typing/index.d.ts.map +1 -0
  150. package/dist/textToParticle/svelte/index.d.ts +1 -0
  151. package/dist/textToParticle/svelte/index.d.ts.map +1 -1
  152. package/dist/textToParticle/svelte/typing/index.d.ts +3 -0
  153. package/dist/textToParticle/svelte/typing/index.d.ts.map +1 -0
  154. package/dist/textToParticle/vue/index.d.ts +1 -0
  155. package/dist/textToParticle/vue/index.d.ts.map +1 -1
  156. package/dist/textToParticle/vue/typing/index.d.ts +4 -0
  157. package/dist/textToParticle/vue/typing/index.d.ts.map +1 -0
  158. package/dist/typing/core/count/index.d.ts +52 -0
  159. package/dist/typing/core/count/index.d.ts.map +1 -0
  160. package/dist/typing/core/index.d.ts +20 -0
  161. package/dist/typing/core/index.d.ts.map +1 -0
  162. package/dist/typing/core/textToParticle/index.d.ts +103 -0
  163. package/dist/typing/core/textToParticle/index.d.ts.map +1 -0
  164. package/dist/typing/core/typing/index.d.ts +52 -0
  165. package/dist/typing/core/typing/index.d.ts.map +1 -0
  166. package/dist/typing/index.cjs +1 -0
  167. package/dist/typing/index.d.ts +18 -0
  168. package/dist/typing/index.d.ts.map +1 -0
  169. package/dist/typing/index.mjs +1 -0
  170. package/dist/typing/index.umd.d.ts +7 -0
  171. package/dist/typing/index.umd.d.ts.map +1 -0
  172. package/dist/typing/react/MasonEffect.d.ts +32 -0
  173. package/dist/typing/react/MasonEffect.d.ts.map +1 -0
  174. package/dist/typing/react/count/Count.d.ts +19 -0
  175. package/dist/typing/react/count/Count.d.ts.map +1 -0
  176. package/dist/typing/react/count/index.d.ts +5 -0
  177. package/dist/typing/react/count/index.d.ts.map +1 -0
  178. package/dist/typing/react/index.d.ts +14 -0
  179. package/dist/typing/react/index.d.ts.map +1 -0
  180. package/dist/typing/react/textToParticle/TextToParticle.d.ts +15 -0
  181. package/dist/typing/react/textToParticle/TextToParticle.d.ts.map +1 -0
  182. package/dist/typing/react/textToParticle/index.d.ts +4 -0
  183. package/dist/typing/react/textToParticle/index.d.ts.map +1 -0
  184. package/dist/typing/react/typing/Typing.d.ts +18 -0
  185. package/dist/typing/react/typing/Typing.d.ts.map +1 -0
  186. package/dist/typing/react/typing/index.d.ts +4 -0
  187. package/dist/typing/react/typing/index.d.ts.map +1 -0
  188. package/dist/typing/svelte/count/index.d.ts +2 -0
  189. package/dist/typing/svelte/count/index.d.ts.map +1 -0
  190. package/dist/typing/svelte/index.d.ts +9 -0
  191. package/dist/typing/svelte/index.d.ts.map +1 -0
  192. package/dist/typing/svelte/textToParticle/index.d.ts +2 -0
  193. package/dist/typing/svelte/textToParticle/index.d.ts.map +1 -0
  194. package/dist/typing/svelte/typing/index.d.ts +3 -0
  195. package/dist/typing/svelte/typing/index.d.ts.map +1 -0
  196. package/dist/typing/vue/count/index.d.ts +2 -0
  197. package/dist/typing/vue/count/index.d.ts.map +1 -0
  198. package/dist/typing/vue/index.d.ts +9 -0
  199. package/dist/typing/vue/index.d.ts.map +1 -0
  200. package/dist/typing/vue/textToParticle/index.d.ts +2 -0
  201. package/dist/typing/vue/textToParticle/index.d.ts.map +1 -0
  202. package/dist/typing/vue/typing/index.d.ts +4 -0
  203. package/dist/typing/vue/typing/index.d.ts.map +1 -0
  204. package/dist/vue/count/index.d.ts +52 -0
  205. package/dist/vue/index.cjs +1 -1
  206. package/dist/vue/index.d.ts +52 -0
  207. package/dist/vue/index.mjs +312 -7
  208. package/dist/vue/textToParticle/index.d.ts +52 -0
  209. package/dist/vue/typing/index.cjs +1 -0
  210. package/dist/vue/typing/index.d.ts +215 -0
  211. package/dist/vue/typing/index.mjs +308 -0
  212. package/package.json +25 -3
@@ -22,6 +22,19 @@ function safe_not_equal(a, b) {
22
22
  function is_empty(obj) {
23
23
  return Object.keys(obj).length === 0;
24
24
  }
25
+ function subscribe(store, ...callbacks) {
26
+ if (store == null) {
27
+ for (const callback of callbacks) {
28
+ callback(void 0);
29
+ }
30
+ return noop;
31
+ }
32
+ const unsub = store.subscribe(...callbacks);
33
+ return unsub.unsubscribe ? () => unsub.unsubscribe() : unsub;
34
+ }
35
+ function component_subscribe(component, store, callback) {
36
+ component.$$.on_destroy.push(subscribe(store, callback));
37
+ }
25
38
  function insert(target, node, anchor) {
26
39
  target.insertBefore(node, anchor || null);
27
40
  }
@@ -155,14 +168,14 @@ function make_dirty(component, i) {
155
168
  }
156
169
  component.$$.dirty[i / 31 | 0] |= 1 << i % 31;
157
170
  }
158
- function init(component, options, instance, create_fragment2, not_equal, props, append_styles = null, dirty = [-1]) {
171
+ function init(component, options, instance2, create_fragment2, not_equal, props2, append_styles = null, dirty = [-1]) {
159
172
  const parent_component = current_component;
160
173
  set_current_component(component);
161
174
  const $$ = component.$$ = {
162
175
  fragment: null,
163
176
  ctx: [],
164
177
  // state
165
- props,
178
+ props: props2,
166
179
  update: noop,
167
180
  not_equal,
168
181
  bound: blank_object(),
@@ -181,7 +194,7 @@ function init(component, options, instance, create_fragment2, not_equal, props,
181
194
  };
182
195
  append_styles && append_styles($$.root);
183
196
  let ready = false;
184
- $$.ctx = instance ? instance(component, options.props || {}, (i, ret, ...rest) => {
197
+ $$.ctx = instance2 ? instance2(component, options.props || {}, (i, ret, ...rest) => {
185
198
  const value = rest.length ? rest[0] : ret;
186
199
  if ($$.ctx && not_equal($$.ctx[i], $$.ctx[i] = value)) {
187
200
  if (!$$.skip_bound && $$.bound[i]) $$.bound[i](value);
@@ -252,10 +265,10 @@ class SvelteComponent {
252
265
  * @param {Partial<Props>} props
253
266
  * @returns {void}
254
267
  */
255
- $set(props) {
256
- if (this.$$set && !is_empty(props)) {
268
+ $set(props2) {
269
+ if (this.$$set && !is_empty(props2)) {
257
270
  this.$$.skip_bound = true;
258
- this.$$set(props);
271
+ this.$$set(props2);
259
272
  this.$$.skip_bound = false;
260
273
  }
261
274
  }
@@ -847,7 +860,228 @@ class Count {
847
860
  }
848
861
  }
849
862
  }
850
- function create_fragment$1(ctx) {
863
+ function decomposeHangul(char) {
864
+ const code = char.charCodeAt(0);
865
+ if (code < 44032 || code > 55203) {
866
+ return [char];
867
+ }
868
+ const base = code - 44032;
869
+ const initial = Math.floor(base / (21 * 28));
870
+ const medial = Math.floor(base % (21 * 28) / 28);
871
+ const final = base % 28;
872
+ const initialChars = ["ㄱ", "ㄲ", "ㄴ", "ㄷ", "ㄸ", "ㄹ", "ㅁ", "ㅂ", "ㅃ", "ㅅ", "ㅆ", "ㅇ", "ㅈ", "ㅉ", "ㅊ", "ㅋ", "ㅌ", "ㅍ", "ㅎ"];
873
+ const medialChars = ["ㅏ", "ㅐ", "ㅑ", "ㅒ", "ㅓ", "ㅔ", "ㅕ", "ㅖ", "ㅗ", "ㅘ", "ㅙ", "ㅚ", "ㅛ", "ㅜ", "ㅝ", "ㅞ", "ㅟ", "ㅠ", "ㅡ", "ㅢ", "ㅣ"];
874
+ const finalChars = ["", "ㄱ", "ㄲ", "ㄳ", "ㄴ", "ㄵ", "ㄶ", "ㄷ", "ㄹ", "ㄺ", "ㄻ", "ㄼ", "ㄽ", "ㄾ", "ㄿ", "ㅀ", "ㅁ", "ㅂ", "ㅄ", "ㅅ", "ㅆ", "ㅇ", "ㅈ", "ㅊ", "ㅋ", "ㅌ", "ㅍ", "ㅎ"];
875
+ const result = [];
876
+ result.push(initialChars[initial]);
877
+ result.push(medialChars[medial]);
878
+ if (final > 0) {
879
+ result.push(finalChars[final]);
880
+ }
881
+ return result;
882
+ }
883
+ function decomposeText(text) {
884
+ const units = [];
885
+ for (let i = 0; i < text.length; i++) {
886
+ const char = text[i];
887
+ const code = char.charCodeAt(0);
888
+ if (code >= 44032 && code <= 55203) {
889
+ const decomposed = decomposeHangul(char);
890
+ units.push(...decomposed);
891
+ } else {
892
+ units.push(char);
893
+ }
894
+ }
895
+ return units;
896
+ }
897
+ class Typing {
898
+ // 원본 텍스트
899
+ constructor(container, options) {
900
+ this.originalChars = [];
901
+ this.charUnitMap = [];
902
+ this.container = typeof container === "string" ? document.querySelector(container) : container;
903
+ if (!this.container) {
904
+ throw new Error("Container element not found");
905
+ }
906
+ this.originalText = options.text;
907
+ this.config = {
908
+ text: options.text,
909
+ speed: options.speed ?? 50,
910
+ delay: options.delay ?? 0,
911
+ enabled: options.enabled ?? true,
912
+ threshold: options.threshold ?? 0.2,
913
+ rootMargin: options.rootMargin ?? "0px 0px -100px 0px",
914
+ triggerOnce: options.triggerOnce ?? false,
915
+ showCursor: options.showCursor ?? true,
916
+ cursorChar: options.cursorChar ?? "|",
917
+ onUpdate: options.onUpdate || null,
918
+ onComplete: options.onComplete || null
919
+ };
920
+ this.textUnits = decomposeText(this.config.text);
921
+ this.originalChars = [];
922
+ this.charUnitMap = [];
923
+ this.initializeTextStructure();
924
+ this.currentIndex = 0;
925
+ this.displayedText = "";
926
+ this.timeoutId = null;
927
+ this.intersectionObserver = null;
928
+ this.isRunning = false;
929
+ this.hasTriggered = false;
930
+ this.init();
931
+ }
932
+ init() {
933
+ this.updateDisplay("");
934
+ this.setupIntersectionObserver();
935
+ }
936
+ setupIntersectionObserver() {
937
+ if (typeof window === "undefined" || typeof window.IntersectionObserver === "undefined") {
938
+ if (this.config.enabled) {
939
+ setTimeout(() => this.start(), this.config.delay);
940
+ }
941
+ return;
942
+ }
943
+ this.intersectionObserver = new IntersectionObserver(
944
+ (entries) => {
945
+ var _a;
946
+ for (const entry of entries) {
947
+ if (entry.target !== this.container) continue;
948
+ if (entry.isIntersecting && !this.hasTriggered) {
949
+ if (this.config.enabled) {
950
+ setTimeout(() => this.start(), this.config.delay);
951
+ }
952
+ this.hasTriggered = true;
953
+ if (this.config.triggerOnce) {
954
+ (_a = this.intersectionObserver) == null ? void 0 : _a.disconnect();
955
+ }
956
+ }
957
+ }
958
+ },
959
+ {
960
+ threshold: this.config.threshold,
961
+ rootMargin: this.config.rootMargin
962
+ }
963
+ );
964
+ this.intersectionObserver.observe(this.container);
965
+ }
966
+ // 각 글자에 해당하는 단위 개수
967
+ initializeTextStructure() {
968
+ this.originalChars = [];
969
+ this.charUnitMap = [];
970
+ for (let i = 0; i < this.originalText.length; i++) {
971
+ const char = this.originalText[i];
972
+ const code = char.charCodeAt(0);
973
+ this.originalChars.push(char);
974
+ if (code >= 44032 && code <= 55203) {
975
+ const decomposed = decomposeHangul(char);
976
+ this.charUnitMap.push(decomposed.length);
977
+ } else {
978
+ this.charUnitMap.push(1);
979
+ }
980
+ }
981
+ }
982
+ // 단위 인덱스를 원본 텍스트의 글자 인덱스로 변환
983
+ // unitIndex: 현재까지 입력된 단위 개수 (0부터 시작)
984
+ // 반환: 표시할 글자 개수 (0부터 시작, exclusive)
985
+ getCharIndexFromUnitIndex(unitIndex) {
986
+ if (unitIndex === 0) return 0;
987
+ let charIndex = 0;
988
+ let currentUnits = 0;
989
+ for (let i = 0; i < this.charUnitMap.length; i++) {
990
+ const unitsForChar = this.charUnitMap[i];
991
+ currentUnits += unitsForChar;
992
+ if (unitIndex >= currentUnits) {
993
+ charIndex = i + 1;
994
+ } else {
995
+ const unitsEntered = unitIndex - (currentUnits - unitsForChar);
996
+ if (unitsEntered > 0) {
997
+ const isHangul = this.originalChars[i] && this.originalChars[i].charCodeAt(0) >= 44032 && this.originalChars[i].charCodeAt(0) <= 55203;
998
+ if (isHangul && unitsEntered >= 2) {
999
+ charIndex = i + 1;
1000
+ } else if (!isHangul && unitsEntered >= 1) {
1001
+ charIndex = i + 1;
1002
+ }
1003
+ }
1004
+ break;
1005
+ }
1006
+ }
1007
+ return charIndex;
1008
+ }
1009
+ // 단위들을 다시 합쳐서 실제 표시할 텍스트 생성
1010
+ buildTextFromUnits(units) {
1011
+ if (units.length === 0) return "";
1012
+ const charIndex = this.getCharIndexFromUnitIndex(units.length);
1013
+ return this.originalText.substring(0, charIndex);
1014
+ }
1015
+ start() {
1016
+ if (this.isRunning) return;
1017
+ this.isRunning = true;
1018
+ this.currentIndex = 0;
1019
+ this.displayedText = "";
1020
+ this.typeNext();
1021
+ }
1022
+ typeNext() {
1023
+ if (this.currentIndex >= this.textUnits.length) {
1024
+ this.isRunning = false;
1025
+ if (this.config.showCursor) {
1026
+ this.updateDisplay(this.originalText);
1027
+ }
1028
+ if (this.config.onComplete) {
1029
+ this.config.onComplete();
1030
+ }
1031
+ return;
1032
+ }
1033
+ const unitsToShow = this.textUnits.slice(0, this.currentIndex + 1);
1034
+ this.displayedText = this.buildTextFromUnits(unitsToShow);
1035
+ let displayText = this.displayedText;
1036
+ if (this.config.showCursor) {
1037
+ displayText += this.config.cursorChar;
1038
+ }
1039
+ this.updateDisplay(displayText);
1040
+ if (this.config.onUpdate) {
1041
+ this.config.onUpdate(this.displayedText);
1042
+ }
1043
+ this.currentIndex++;
1044
+ this.timeoutId = setTimeout(() => {
1045
+ this.typeNext();
1046
+ }, this.config.speed);
1047
+ }
1048
+ stop() {
1049
+ this.isRunning = false;
1050
+ if (this.timeoutId) {
1051
+ clearTimeout(this.timeoutId);
1052
+ this.timeoutId = null;
1053
+ }
1054
+ }
1055
+ reset() {
1056
+ this.stop();
1057
+ this.currentIndex = 0;
1058
+ this.displayedText = "";
1059
+ this.hasTriggered = false;
1060
+ this.updateDisplay("");
1061
+ }
1062
+ updateDisplay(text) {
1063
+ this.container.textContent = text;
1064
+ }
1065
+ // 텍스트 변경
1066
+ setText(newText) {
1067
+ this.originalText = newText;
1068
+ this.config.text = newText;
1069
+ this.textUnits = decomposeText(newText);
1070
+ this.initializeTextStructure();
1071
+ this.reset();
1072
+ if (this.config.enabled) {
1073
+ setTimeout(() => this.start(), this.config.delay);
1074
+ }
1075
+ }
1076
+ destroy() {
1077
+ this.stop();
1078
+ if (this.intersectionObserver) {
1079
+ this.intersectionObserver.disconnect();
1080
+ this.intersectionObserver = null;
1081
+ }
1082
+ }
1083
+ }
1084
+ function create_fragment$2(ctx) {
851
1085
  let div;
852
1086
  return {
853
1087
  c() {
@@ -917,7 +1151,7 @@ function instance_1$1($$self, $$props, $$invalidate) {
917
1151
  let { style = {} } = $$props;
918
1152
  const dispatch = createEventDispatcher();
919
1153
  let container;
920
- let instance = null;
1154
+ let instance2 = null;
921
1155
  onMount(() => {
922
1156
  if (!container) return;
923
1157
  const options = {
@@ -941,33 +1175,33 @@ function instance_1$1($$self, $$props, $$invalidate) {
941
1175
  dispatch("update", inst);
942
1176
  }
943
1177
  };
944
- $$invalidate(20, instance = new TextToParticle(container, options));
1178
+ $$invalidate(20, instance2 = new TextToParticle(container, options));
945
1179
  });
946
1180
  onDestroy(() => {
947
- if (instance) {
948
- instance.destroy();
949
- $$invalidate(20, instance = null);
1181
+ if (instance2) {
1182
+ instance2.destroy();
1183
+ $$invalidate(20, instance2 = null);
950
1184
  }
951
1185
  });
952
1186
  function morph(textOrOptions) {
953
- if (instance) {
954
- instance.morph(textOrOptions);
1187
+ if (instance2) {
1188
+ instance2.morph(textOrOptions);
955
1189
  }
956
1190
  }
957
1191
  function scatter() {
958
- if (instance) {
959
- instance.scatter();
1192
+ if (instance2) {
1193
+ instance2.scatter();
960
1194
  }
961
1195
  }
962
1196
  function updateConfig(config) {
963
- if (instance) {
964
- instance.updateConfig(config);
1197
+ if (instance2) {
1198
+ instance2.updateConfig(config);
965
1199
  }
966
1200
  }
967
1201
  function destroy() {
968
- if (instance) {
969
- instance.destroy();
970
- $$invalidate(20, instance = null);
1202
+ if (instance2) {
1203
+ instance2.destroy();
1204
+ $$invalidate(20, instance2 = null);
971
1205
  }
972
1206
  }
973
1207
  function div_binding($$value) {
@@ -997,8 +1231,8 @@ function instance_1$1($$self, $$props, $$invalidate) {
997
1231
  if ($$self.$$.dirty & /*instance, text, densityStep, maxParticles, pointSize, ease, repelRadius, repelStrength, particleColor, fontFamily, fontSize, width, height, devicePixelRatio*/
998
1232
  1114104) {
999
1233
  {
1000
- if (instance) {
1001
- instance.updateConfig({
1234
+ if (instance2) {
1235
+ instance2.updateConfig({
1002
1236
  text,
1003
1237
  densityStep,
1004
1238
  maxParticles,
@@ -1038,14 +1272,14 @@ function instance_1$1($$self, $$props, $$invalidate) {
1038
1272
  scatter,
1039
1273
  updateConfig,
1040
1274
  destroy,
1041
- instance,
1275
+ instance2,
1042
1276
  div_binding
1043
1277
  ];
1044
1278
  }
1045
1279
  class TextToParticle_1 extends SvelteComponent {
1046
1280
  constructor(options) {
1047
1281
  super();
1048
- init(this, options, instance_1$1, create_fragment$1, safe_not_equal, {
1282
+ init(this, options, instance_1$1, create_fragment$2, safe_not_equal, {
1049
1283
  text: 3,
1050
1284
  densityStep: 4,
1051
1285
  maxParticles: 5,
@@ -1080,7 +1314,7 @@ class TextToParticle_1 extends SvelteComponent {
1080
1314
  return this.$$.ctx[19];
1081
1315
  }
1082
1316
  }
1083
- function create_fragment(ctx) {
1317
+ function create_fragment$1(ctx) {
1084
1318
  let div;
1085
1319
  return {
1086
1320
  c() {
@@ -1145,7 +1379,7 @@ function instance_1($$self, $$props, $$invalidate) {
1145
1379
  let { style = {} } = $$props;
1146
1380
  const dispatch = createEventDispatcher();
1147
1381
  let container;
1148
- let instance = null;
1382
+ let instance2 = null;
1149
1383
  onMount(() => {
1150
1384
  if (!container) return;
1151
1385
  const options = {
@@ -1164,44 +1398,44 @@ function instance_1($$self, $$props, $$invalidate) {
1164
1398
  dispatch("complete");
1165
1399
  }
1166
1400
  };
1167
- $$invalidate(17, instance = new Count(container, options));
1401
+ $$invalidate(17, instance2 = new Count(container, options));
1168
1402
  });
1169
1403
  onDestroy(() => {
1170
- if (instance) {
1171
- instance.destroy();
1172
- $$invalidate(17, instance = null);
1404
+ if (instance2) {
1405
+ instance2.destroy();
1406
+ $$invalidate(17, instance2 = null);
1173
1407
  }
1174
1408
  });
1175
1409
  function start() {
1176
- if (instance) {
1177
- instance.start();
1410
+ if (instance2) {
1411
+ instance2.start();
1178
1412
  }
1179
1413
  }
1180
1414
  function stop() {
1181
- if (instance) {
1182
- instance.stop();
1415
+ if (instance2) {
1416
+ instance2.stop();
1183
1417
  }
1184
1418
  }
1185
1419
  function reset() {
1186
- if (instance) {
1187
- instance.reset();
1420
+ if (instance2) {
1421
+ instance2.reset();
1188
1422
  }
1189
1423
  }
1190
1424
  function getValue() {
1191
- if (instance) {
1192
- return instance.getValue();
1425
+ if (instance2) {
1426
+ return instance2.getValue();
1193
1427
  }
1194
1428
  return 0;
1195
1429
  }
1196
1430
  function updateConfig(config) {
1197
- if (instance) {
1198
- instance.updateConfig(config);
1431
+ if (instance2) {
1432
+ instance2.updateConfig(config);
1199
1433
  }
1200
1434
  }
1201
1435
  function destroy() {
1202
- if (instance) {
1203
- instance.destroy();
1204
- $$invalidate(17, instance = null);
1436
+ if (instance2) {
1437
+ instance2.destroy();
1438
+ $$invalidate(17, instance2 = null);
1205
1439
  }
1206
1440
  }
1207
1441
  function div_binding($$value) {
@@ -1226,8 +1460,8 @@ function instance_1($$self, $$props, $$invalidate) {
1226
1460
  if ($$self.$$.dirty & /*instance, targetValue, duration, startValue, enabled, easing, threshold, rootMargin, triggerOnce*/
1227
1461
  133112) {
1228
1462
  {
1229
- if (instance) {
1230
- instance.updateConfig({
1463
+ if (instance2) {
1464
+ instance2.updateConfig({
1231
1465
  targetValue,
1232
1466
  duration,
1233
1467
  startValue,
@@ -1265,14 +1499,14 @@ function instance_1($$self, $$props, $$invalidate) {
1265
1499
  getValue,
1266
1500
  updateConfig,
1267
1501
  destroy,
1268
- instance,
1502
+ instance2,
1269
1503
  div_binding
1270
1504
  ];
1271
1505
  }
1272
1506
  class Count_1 extends SvelteComponent {
1273
1507
  constructor(options) {
1274
1508
  super();
1275
- init(this, options, instance_1, create_fragment, safe_not_equal, {
1509
+ init(this, options, instance_1, create_fragment$1, safe_not_equal, {
1276
1510
  targetValue: 3,
1277
1511
  duration: 4,
1278
1512
  startValue: 5,
@@ -1310,9 +1544,142 @@ class Count_1 extends SvelteComponent {
1310
1544
  return this.$$.ctx[16];
1311
1545
  }
1312
1546
  }
1547
+ function create_fragment(ctx) {
1548
+ let div;
1549
+ return {
1550
+ c() {
1551
+ div = element("div");
1552
+ attr(
1553
+ div,
1554
+ "class",
1555
+ /*className*/
1556
+ ctx[1]
1557
+ );
1558
+ attr(
1559
+ div,
1560
+ "style",
1561
+ /*style*/
1562
+ ctx[2]
1563
+ );
1564
+ },
1565
+ m(target, anchor) {
1566
+ insert(target, div, anchor);
1567
+ ctx[8](div);
1568
+ },
1569
+ p: noop,
1570
+ i: noop,
1571
+ o: noop,
1572
+ d(detaching) {
1573
+ if (detaching) {
1574
+ detach(div);
1575
+ }
1576
+ ctx[8](null);
1577
+ }
1578
+ };
1579
+ }
1580
+ function instance($$self, $$props, $$invalidate) {
1581
+ let $effect;
1582
+ let $props;
1583
+ component_subscribe($$self, effect, ($$value) => $$invalidate(10, $effect = $$value));
1584
+ component_subscribe($$self, props, ($$value) => $$invalidate(11, $props = $$value));
1585
+ let { text, speed = 50, delay = 0, enabled = true, threshold = 0.2, rootMargin = "0px 0px -100px 0px", triggerOnce = false, showCursor = true, cursorChar = "|", className = "", style = "", onUpdate, onComplete } = $props();
1586
+ let containerRef = null;
1587
+ let instanceRef = null;
1588
+ onMount(() => {
1589
+ if (!containerRef) return;
1590
+ const options = {
1591
+ text,
1592
+ speed,
1593
+ delay,
1594
+ enabled,
1595
+ threshold,
1596
+ rootMargin,
1597
+ triggerOnce,
1598
+ showCursor,
1599
+ cursorChar,
1600
+ onUpdate,
1601
+ onComplete
1602
+ };
1603
+ instanceRef = new Typing(containerRef, options);
1604
+ });
1605
+ onDestroy(() => {
1606
+ if (instanceRef) {
1607
+ instanceRef.destroy();
1608
+ instanceRef = null;
1609
+ }
1610
+ });
1611
+ $effect(() => {
1612
+ if (instanceRef && text !== instanceRef["originalText"]) {
1613
+ instanceRef.setText(text);
1614
+ }
1615
+ });
1616
+ function start() {
1617
+ instanceRef == null ? void 0 : instanceRef.start();
1618
+ }
1619
+ function stop() {
1620
+ instanceRef == null ? void 0 : instanceRef.stop();
1621
+ }
1622
+ function reset() {
1623
+ instanceRef == null ? void 0 : instanceRef.reset();
1624
+ }
1625
+ function setText(newText) {
1626
+ instanceRef == null ? void 0 : instanceRef.setText(newText);
1627
+ }
1628
+ function destroy() {
1629
+ if (instanceRef) {
1630
+ instanceRef.destroy();
1631
+ instanceRef = null;
1632
+ }
1633
+ }
1634
+ function div_binding($$value) {
1635
+ binding_callbacks[$$value ? "unshift" : "push"](() => {
1636
+ containerRef = $$value;
1637
+ $$invalidate(0, containerRef);
1638
+ });
1639
+ }
1640
+ return [
1641
+ containerRef,
1642
+ className,
1643
+ style,
1644
+ start,
1645
+ stop,
1646
+ reset,
1647
+ setText,
1648
+ destroy,
1649
+ div_binding
1650
+ ];
1651
+ }
1652
+ class Typing_1 extends SvelteComponent {
1653
+ constructor(options) {
1654
+ super();
1655
+ init(this, options, instance, create_fragment, safe_not_equal, {
1656
+ start: 3,
1657
+ stop: 4,
1658
+ reset: 5,
1659
+ setText: 6,
1660
+ destroy: 7
1661
+ });
1662
+ }
1663
+ get start() {
1664
+ return this.$$.ctx[3];
1665
+ }
1666
+ get stop() {
1667
+ return this.$$.ctx[4];
1668
+ }
1669
+ get reset() {
1670
+ return this.$$.ctx[5];
1671
+ }
1672
+ get setText() {
1673
+ return this.$$.ctx[6];
1674
+ }
1675
+ get destroy() {
1676
+ return this.$$.ctx[7];
1677
+ }
1678
+ }
1313
1679
  export {
1314
1680
  Count_1 as Count,
1315
1681
  TextToParticle_1 as MasonEffect,
1316
1682
  TextToParticle_1 as TextToParticle,
1683
+ Typing_1 as Typing,
1317
1684
  TextToParticle_1 as default
1318
1685
  };
@@ -160,4 +160,56 @@ declare class TextToParticle {
160
160
  export { TextToParticleOptions as MasonEffectOptions }
161
161
  export { TextToParticleOptions }
162
162
 
163
+ export declare class Typing {
164
+ container: HTMLElement;
165
+ config: Required<Omit<TypingOptions, 'onUpdate' | 'onComplete'>> & {
166
+ onUpdate: TypingOptions['onUpdate'];
167
+ onComplete: TypingOptions['onComplete'];
168
+ };
169
+ textUnits: string[];
170
+ currentIndex: number;
171
+ displayedText: string;
172
+ timeoutId: ReturnType<typeof setTimeout> | null;
173
+ intersectionObserver: IntersectionObserver | null;
174
+ isRunning: boolean;
175
+ hasTriggered: boolean;
176
+ originalText: string;
177
+ constructor(container: HTMLElement | string, options: TypingOptions);
178
+ init(): void;
179
+ setupIntersectionObserver(): void;
180
+ private originalChars;
181
+ private charUnitMap;
182
+ private initializeTextStructure;
183
+ private getCharIndexFromUnitIndex;
184
+ private buildTextFromUnits;
185
+ start(): void;
186
+ typeNext(): void;
187
+ stop(): void;
188
+ reset(): void;
189
+ updateDisplay(text: string): void;
190
+ setText(newText: string): void;
191
+ destroy(): void;
192
+ }
193
+
194
+ /**
195
+ * Typing - 타이핑 애니메이션 효과
196
+ * 바닐라 JS 코어 클래스
197
+ *
198
+ * 사용법:
199
+ * import { Typing } from 'masoneffect/typing';
200
+ */
201
+ export declare interface TypingOptions {
202
+ text: string;
203
+ speed?: number;
204
+ delay?: number;
205
+ enabled?: boolean;
206
+ threshold?: number;
207
+ rootMargin?: string;
208
+ triggerOnce?: boolean;
209
+ showCursor?: boolean;
210
+ cursorChar?: string;
211
+ onUpdate?: (text: string) => void;
212
+ onComplete?: () => void;
213
+ }
214
+
163
215
  export { }
@@ -0,0 +1 @@
1
+ "use strict";var t=Object.defineProperty,e=(e,n,i)=>((e,n,i)=>n in e?t(e,n,{enumerable:!0,configurable:!0,writable:!0,value:i}):e[n]=i)(e,"symbol"!=typeof n?n+"":n,i);const n=require("svelte");function i(){}function s(t){return t()}function r(){return Object.create(null)}function o(t){t.forEach(s)}function h(t){return"function"==typeof t}function c(t,e){return t!=t?e==e:t!==e||t&&"object"==typeof t||"function"==typeof t}function u(t,e,n){t.$$.on_destroy.push(function(t,...e){if(null==t){for(const t of e)t(void 0);return i}const n=t.subscribe(...e);return n.unsubscribe?()=>n.unsubscribe():n}(e,n))}function a(t){t.parentNode&&t.parentNode.removeChild(t)}function l(t,e,n){null==n?t.removeAttribute(e):t.getAttribute(e)!==n&&t.setAttribute(e,n)}let d;function f(t){d=t}const p=[],g=[];let x=[];const $=[],y=Promise.resolve();let b=!1;function m(t){x.push(t)}const C=new Set;let T=0;function v(){if(0!==T)return;const t=d;do{try{for(;T<p.length;){const t=p[T];T++,f(t),w(t.$$)}}catch(e){throw p.length=0,T=0,e}for(f(null),p.length=0,T=0;g.length;)g.pop()();for(let t=0;t<x.length;t+=1){const e=x[t];C.has(e)||(C.add(e),e())}x.length=0}while(p.length);for(;$.length;)$.pop()();b=!1,C.clear(),f(t)}function w(t){if(null!==t.fragment){t.update(),o(t.before_update);const e=t.dirty;t.dirty=[-1],t.fragment&&t.fragment.p(t.ctx,e),t.after_update.forEach(m)}}const _=new Set;function O(t,e){const n=t.$$;null!==n.fragment&&(!function(t){const e=[],n=[];x.forEach(i=>-1===t.indexOf(i)?e.push(i):n.push(i)),n.forEach(t=>t()),x=e}(n.after_update),o(n.on_destroy),n.fragment&&n.fragment.d(e),n.on_destroy=n.fragment=null,n.ctx=[])}function U(t,e){-1===t.$$.dirty[0]&&(p.push(t),b||(b=!0,y.then(v)),t.$$.dirty.fill(0)),t.$$.dirty[e/31|0]|=1<<e%31}function I(t,e,n,c,u,l,p=null,g=[-1]){const x=d;f(t);const $=t.$$={fragment:null,ctx:[],props:l,update:i,not_equal:u,bound:r(),on_mount:[],on_destroy:[],on_disconnect:[],before_update:[],after_update:[],context:new Map(e.context||(x?x.$$.context:[])),callbacks:r(),dirty:g,skip_bound:!1,root:e.target||x.$$.root};p&&p($.root);let y=!1;if($.ctx=n?n(t,e.props||{},(e,n,...i)=>{const s=i.length?i[0]:n;return $.ctx&&u($.ctx[e],$.ctx[e]=s)&&(!$.skip_bound&&$.bound[e]&&$.bound[e](s),y&&U(t,e)),n}):[],$.update(),y=!0,o($.before_update),$.fragment=!!c&&c($.ctx),e.target){if(e.hydrate){const t=(T=e.target,Array.from(T.childNodes));$.fragment&&$.fragment.l(t),t.forEach(a)}else $.fragment&&$.fragment.c();e.intro&&((b=t.$$.fragment)&&b.i&&(_.delete(b),b.i(C))),function(t,e,n){const{fragment:i,after_update:r}=t.$$;i&&i.m(e,n),m(()=>{const e=t.$$.on_mount.map(s).filter(h);t.$$.on_destroy?t.$$.on_destroy.push(...e):o(e),t.$$.on_mount=[]}),r.forEach(m)}(t,e.target,e.anchor),v()}var b,C,T;f(x)}class M{constructor(){e(this,"$$"),e(this,"$$set")}$destroy(){O(this,1),this.$destroy=i}$on(t,e){if(!h(e))return i;const n=this.$$.callbacks[t]||(this.$$.callbacks[t]=[]);return n.push(e),()=>{const t=n.indexOf(e);-1!==t&&n.splice(t,1)}}$set(t){var e;this.$$set&&(e=t,0!==Object.keys(e).length)&&(this.$$.skip_bound=!0,this.$$set(t),this.$$.skip_bound=!1)}}function k(t){const e=t.charCodeAt(0);if(e<44032||e>55203)return[t];const n=e-44032,i=Math.floor(n/588),s=Math.floor(n%588/28),r=n%28,o=["","ㄱ","ㄲ","ㄳ","ㄴ","ㄵ","ㄶ","ㄷ","ㄹ","ㄺ","ㄻ","ㄼ","ㄽ","ㄾ","ㄿ","ㅀ","ㅁ","ㅂ","ㅄ","ㅅ","ㅆ","ㅇ","ㅈ","ㅊ","ㅋ","ㅌ","ㅍ","ㅎ"],h=[];return h.push(["ㄱ","ㄲ","ㄴ","ㄷ","ㄸ","ㄹ","ㅁ","ㅂ","ㅃ","ㅅ","ㅆ","ㅇ","ㅈ","ㅉ","ㅊ","ㅋ","ㅌ","ㅍ","ㅎ"][i]),h.push(["ㅏ","ㅐ","ㅑ","ㅒ","ㅓ","ㅔ","ㅕ","ㅖ","ㅗ","ㅘ","ㅙ","ㅚ","ㅛ","ㅜ","ㅝ","ㅞ","ㅟ","ㅠ","ㅡ","ㅢ","ㅣ"][s]),r>0&&h.push(o[r]),h}function A(t){const e=[];for(let n=0;n<t.length;n++){const i=t[n],s=i.charCodeAt(0);if(s>=44032&&s<=55203){const t=k(i);e.push(...t)}else e.push(i)}return e}"undefined"!=typeof window&&(window.__svelte||(window.__svelte={v:new Set})).v.add("4");class E{constructor(t,e){if(this.originalChars=[],this.charUnitMap=[],this.container="string"==typeof t?document.querySelector(t):t,!this.container)throw new Error("Container element not found");this.originalText=e.text,this.config={text:e.text,speed:e.speed??50,delay:e.delay??0,enabled:e.enabled??!0,threshold:e.threshold??.2,rootMargin:e.rootMargin??"0px 0px -100px 0px",triggerOnce:e.triggerOnce??!1,showCursor:e.showCursor??!0,cursorChar:e.cursorChar??"|",onUpdate:e.onUpdate||null,onComplete:e.onComplete||null},this.textUnits=A(this.config.text),this.originalChars=[],this.charUnitMap=[],this.initializeTextStructure(),this.currentIndex=0,this.displayedText="",this.timeoutId=null,this.intersectionObserver=null,this.isRunning=!1,this.hasTriggered=!1,this.init()}init(){this.updateDisplay(""),this.setupIntersectionObserver()}setupIntersectionObserver(){"undefined"!=typeof window&&void 0!==window.IntersectionObserver?(this.intersectionObserver=new IntersectionObserver(t=>{var e;for(const n of t)n.target===this.container&&n.isIntersecting&&!this.hasTriggered&&(this.config.enabled&&setTimeout(()=>this.start(),this.config.delay),this.hasTriggered=!0,this.config.triggerOnce&&(null==(e=this.intersectionObserver)||e.disconnect()))},{threshold:this.config.threshold,rootMargin:this.config.rootMargin}),this.intersectionObserver.observe(this.container)):this.config.enabled&&setTimeout(()=>this.start(),this.config.delay)}initializeTextStructure(){this.originalChars=[],this.charUnitMap=[];for(let t=0;t<this.originalText.length;t++){const e=this.originalText[t],n=e.charCodeAt(0);if(this.originalChars.push(e),n>=44032&&n<=55203){const t=k(e);this.charUnitMap.push(t.length)}else this.charUnitMap.push(1)}}getCharIndexFromUnitIndex(t){if(0===t)return 0;let e=0,n=0;for(let i=0;i<this.charUnitMap.length;i++){const s=this.charUnitMap[i];if(n+=s,!(t>=n)){const r=t-(n-s);if(r>0){const t=this.originalChars[i]&&this.originalChars[i].charCodeAt(0)>=44032&&this.originalChars[i].charCodeAt(0)<=55203;(t&&r>=2||!t&&r>=1)&&(e=i+1)}break}e=i+1}return e}buildTextFromUnits(t){if(0===t.length)return"";const e=this.getCharIndexFromUnitIndex(t.length);return this.originalText.substring(0,e)}start(){this.isRunning||(this.isRunning=!0,this.currentIndex=0,this.displayedText="",this.typeNext())}typeNext(){if(this.currentIndex>=this.textUnits.length)return this.isRunning=!1,this.config.showCursor&&this.updateDisplay(this.originalText),void(this.config.onComplete&&this.config.onComplete());const t=this.textUnits.slice(0,this.currentIndex+1);this.displayedText=this.buildTextFromUnits(t);let e=this.displayedText;this.config.showCursor&&(e+=this.config.cursorChar),this.updateDisplay(e),this.config.onUpdate&&this.config.onUpdate(this.displayedText),this.currentIndex++,this.timeoutId=setTimeout(()=>{this.typeNext()},this.config.speed)}stop(){this.isRunning=!1,this.timeoutId&&(clearTimeout(this.timeoutId),this.timeoutId=null)}reset(){this.stop(),this.currentIndex=0,this.displayedText="",this.hasTriggered=!1,this.updateDisplay("")}updateDisplay(t){this.container.textContent=t}setText(t){this.originalText=t,this.config.text=t,this.textUnits=A(t),this.initializeTextStructure(),this.reset(),this.config.enabled&&setTimeout(()=>this.start(),this.config.delay)}destroy(){this.stop(),this.intersectionObserver&&(this.intersectionObserver.disconnect(),this.intersectionObserver=null)}}function N(t){let e;return{c(){var n;n="div",e=document.createElement(n),l(e,"class",t[1]),l(e,"style",t[2])},m(n,i){!function(t,e,n){t.insertBefore(e,n||null)}(n,e,i),t[8](e)},p:i,i:i,o:i,d(n){n&&a(e),t[8](null)}}}function S(t,e,i){let s,r;u(t,effect,t=>i(10,s=t)),u(t,props,t=>i(11,r=t));let{text:o,speed:h=50,delay:c=0,enabled:a=!0,threshold:l=.2,rootMargin:d="0px 0px -100px 0px",triggerOnce:f=!1,showCursor:p=!0,cursorChar:x="|",className:$="",style:y="",onUpdate:b,onComplete:m}=r(),C=null,T=null;return n.onMount(()=>{if(!C)return;T=new E(C,{text:o,speed:h,delay:c,enabled:a,threshold:l,rootMargin:d,triggerOnce:f,showCursor:p,cursorChar:x,onUpdate:b,onComplete:m})}),n.onDestroy(()=>{T&&(T.destroy(),T=null)}),s(()=>{T&&o!==T.originalText&&T.setText(o)}),[C,$,y,function(){null==T||T.start()},function(){null==T||T.stop()},function(){null==T||T.reset()},function(t){null==T||T.setText(t)},function(){T&&(T.destroy(),T=null)},function(t){g[t?"unshift":"push"](()=>{C=t,i(0,C)})}]}module.exports=class extends M{constructor(t){super(),I(this,t,S,N,c,{start:3,stop:4,reset:5,setText:6,destroy:7})}get start(){return this.$$.ctx[3]}get stop(){return this.$$.ctx[4]}get reset(){return this.$$.ctx[5]}get setText(){return this.$$.ctx[6]}get destroy(){return this.$$.ctx[7]}};