Files
2026-07-28 01:06:53 +03:00

410 lines
24 KiB
TypeScript

/* Metro module 9221; source: design/components/SegmentedControl/native/SegmentedControl.native.tsx; dependencies: [31, 27, 33, 4501, 697, 3860, 4017, 4577, 9222, 5321, 477, 2] */
import Native from '../../../../external/discord_common/js/packages/tokens/native.tsx'; /* Metro dependency 697 */
import ReanimatedRexport from '../../../../modules/reanimated/ReanimatedRexport.tsx'; /* Metro dependency 4017 */
import * as FileImportTrackerModule from '../../../../by-id/module-00002-FileImportTracker.js'; /* Metro dependency 2 */
import * as ReactNativeModule from '../../../../by-id/module-00027-ReactNative.js'; /* Metro dependency 27 */
import * as ReactModule from '../../../../by-id/module-00031-React.js'; /* Metro dependency 31 */
import * as UseTokenModule from '../../../tokens/native/useToken.tsx'; /* Metro dependency 3860 */
import * as ReanimatedRexportModule from '../../../../modules/reanimated/ReanimatedRexport.tsx'; /* Metro dependency 4017 */
import * as CreateStylesModule from '../../Styles/native/createStyles.tsx'; /* Metro dependency 4501 */
import * as SegmentedControlItemNativeModule from './SegmentedControlItem.native.tsx'; /* Metro dependency 9222 */
function _fun72105(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#72105, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:9406:6, offset: 0x01d39d52, size: 361 bytes, params: 8, frame: 18
const env0_0 = require;
const Object = global.Object;
Object.defineProperty(exports, '__esModule', {value: true});
let value = ReactNativeModule;
const env0_4 = value.View;
const env0_5 = value.ScrollView;
value = require(33) /* metro dependency 33 */;
const env0_6 = value.jsx;
const env0_7 = value.jsxs;
const env0_8 = {'mass': 0.3, 'damping': 13, 'stiffness': 100, 'restDisplacementThreshold': 0.001,
'overshootClamping': true};
const env0_9 = (CreateStylesModule).createStyles(_fun72106);
object = {code: 'function SegmentedControlNativeTsx1(){const{indicatorWidth}=this.__closure;return indicatorWidth.get();}'};
object = {code: 'function SegmentedControlNativeTsx2(_,previous){const{previousIndicatorWidth}=this.__closure;if(previous!=null){previousIndicatorWidth.set(previous);}}'};
object = {code: 'function SegmentedControlNativeTsx3(){const{activeIndex,itemCount}=this.__closure;return Math.min(Math.max(activeIndex.get(),0),itemCount-1);}'};
object = {code: 'function SegmentedControlNativeTsx4(){const{clampedActiveIndex,defaultActiveIndex,indicatorWidth}=this.__closure;return(clampedActiveIndex.get()-defaultActiveIndex.get())*indicatorWidth.get();}'};
object = {code: "function SegmentedControlNativeTsx5(){const{indicatorTranslateX,pressedIndex,clampedActiveIndex,PRESSED_TRANSLATE_AMOUNT,indicatorWidth,scrollOverflow,interpolate,SCROLL_OVERFLOW_UPPER_BOUND,SCROLL_OVERFLOW_MAX_SCALE,segmentSpacing,itemCount,previousIndicatorWidth,withSpring,SELECTED_INDICATOR_SPRING}=this.__closure;let translateX=indicatorTranslateX.get();let scaleX=1;if(pressedIndex.get()>=0){if(pressedIndex.get()<clampedActiveIndex.get()){scaleX+=PRESSED_TRANSLATE_AMOUNT;translateX-=indicatorWidth.get()*(PRESSED_TRANSLATE_AMOUNT/2);}else if(pressedIndex.get()>clampedActiveIndex.get()){scaleX+=PRESSED_TRANSLATE_AMOUNT;translateX+=indicatorWidth.get()*(PRESSED_TRANSLATE_AMOUNT/2);}}if(scrollOverflow.get()<0){const scaleFactor=interpolate(scrollOverflow.get(),[-SCROLL_OVERFLOW_UPPER_BOUND,0],[SCROLL_OVERFLOW_MAX_SCALE,1],'clamp');const scaleAmount=indicatorWidth.get()*(1-scaleFactor);scaleX=scaleFactor;translateX+=-scaleAmount/2;}else if(scrollOverflow.get()>0){const scaleFactor=interpolate(scrollOverflow.get(),[SCROLL_OVERFLOW_UPPER_BOUND,0],[SCROLL_OVERFLOW_MAX_SCALE,1],'clamp');const scaleAmount=indicatorWidth.get()*(1-scaleFactor);scaleX=scaleFactor;translateX+=scaleAmount/2;}if(clampedActiveIndex.get()===0){translateX+=segmentSpacing;}else if(clampedActiveIndex.get()===itemCount-1){translateX-=segmentSpacing;}const animated=indicatorWidth.get()===previousIndicatorWidth.get();if(!animated){previousIndicatorWidth.set(indicatorWidth.get());}return{transform:[{translateX:animated?withSpring(translateX,SELECTED_INDICATOR_SPRING):translateX},{scaleX:withSpring(scaleX,SELECTED_INDICATOR_SPRING)}]};}"};
object = {code: 'function onPanGestureUpdate_SegmentedControlNativeTsx6(event){const{indicatorWidth,panIndex,activeIndex,itemCount}=this.__closure;const progess=event.translationX/indicatorWidth.get();const index=panIndex.get()+progess;activeIndex.set(Math.min(Math.max(index,0),itemCount-1));}'};
object = {code: 'function SegmentedControlNativeTsx7(){const{panIndex,activeIndex,runOnJS,setActiveIndex}=this.__closure;panIndex.set(-1);activeIndex.set(Math.round(activeIndex.get()));runOnJS(setActiveIndex)(activeIndex.get());}'};
object = {code: 'function SegmentedControlNativeTsx8(){const{panIndex,activeIndex}=this.__closure;panIndex.set(activeIndex.get());}'};
(FileImportTrackerModule).fileFinishedImporting('design/components/SegmentedControl/native/SegmentedControl.native.tsx');
exports.SegmentedControl = SegmentedControl;
function _fun72106(a0, a1) { // fn#72106, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:9406:286, offset: 0x01d39ebb, size: 166 bytes, params: 3, frame: 18
const object = {};
object.scrollContentContainer = {flexGrow: 1};
const MOBILE_SEGMENTED_CONTROL_BACKGROUND = (Native).colors.MOBILE_SEGMENTED_CONTROL_BACKGROUND;
object.controlsContainer = {'backgroundColor': null, 'borderRadius': null, 'paddingVertical': null,
'display': 'flex', 'flexDirection': 'row', 'alignItems': 'center',
backgroundColor: MOBILE_SEGMENTED_CONTROL_BACKGROUND, borderRadius: a0 + a1, paddingVertical: a1};
object.indicatorContainer = {'position': 'absolute', 'width': '100%', 'height': '100%', 'borderRadius': null,
'flexDirection': 'row', borderRadius: a0};
const MOBILE_SEGMENTED_CONTROL_INDICATOR_BACKGROUND = (Native).colors.MOBILE_SEGMENTED_CONTROL_INDICATOR_BACKGROUND;
object.indicator = {flex: 1, backgroundColor: MOBILE_SEGMENTED_CONTROL_INDICATOR_BACKGROUND, borderRadius: a0};
return object;
}
function SegmentedControl({state, variant, keyboardShouldPersistTaps}) { // fn#72107, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:9406:3762, offset: 0x01d39f61, size: 1403 bytes, params: 2, frame: 40
variant = variant === undefined ? 'default' : variant;
const activeIndex = state.activeIndex;
const scrollOverflow = state.scrollOverflow;
const scrollOverflow2 = scrollOverflow;
const items2 = state.items;
const pressedIndex = state.pressedIndex;
const setActiveIndex = state.setActiveIndex;
const value = variant === 'experimental_Large';
const r20 = value ? 8 : 4;
const env0_8 = r20;
const useToken = UseTokenModule.useToken;
const SEGMENTED_CONTROL_BORDER_RADIUS = (Native).modules.mobile.SEGMENTED_CONTROL_BORDER_RADIUS;
const styles = useStyles(Reflect.apply(useToken, UseTokenModule, [SEGMENTED_CONTROL_BORDER_RADIUS]), r20);
const length = items2.length;
const length2 = length;
let useSharedValue = ReanimatedRexportModule.useSharedValue;
const value6 = Reflect.apply(useSharedValue, ReanimatedRexportModule, [-1]);
const env0_11 = value6;
const value7 = ReanimatedRexportModule.useSharedValue(0);
const env0_12 = value7;
const value8 = ReanimatedRexportModule.useSharedValue(0);
const env0_13 = value8;
const useAnimatedReaction = ReanimatedRexportModule.useAnimatedReaction;
let closure = SegmentedControlT;
closure.__closure = {indicatorWidth: value7};
closure.__workletHash = 5223249035388;
closure.__initData = length2;
const SegmentedControlR2 = SegmentedControlR;
SegmentedControlR2.__closure = {previousIndicatorWidth: value8};
SegmentedControlR2.__workletHash = 14748619096684;
SegmentedControlR2.__initData = env0_11;
Reflect.apply(useAnimatedReaction, ReanimatedRexportModule, [closure, SegmentedControlR2]);
const binding = scrollOverflow2;
const value9 = binding.useCallback(_fun72110, [value7]);
const env0_14 = value9;
useSharedValue = ReanimatedRexportModule.useSharedValue;
const get = activeIndex.get;
const value10 = Reflect.apply(useSharedValue, ReanimatedRexportModule, [Reflect.apply(get, activeIndex, [])]);
let useDerivedValue = ReanimatedRexportModule.useDerivedValue;
closure = function() {
var Math = global.Math;
var Math2 = global.Math;
return Math.min(Math2.max(activeIndex.get(), 0), length - 1);
};
closure.__closure = {activeIndex: activeIndex, itemCount: length};
closure.__workletHash = 790542357728;
closure.__initData = env0_12;
const value11 = Reflect.apply(useDerivedValue, ReanimatedRexportModule, [closure]);
const env0_16 = value11;
useDerivedValue = ReanimatedRexportModule.useDerivedValue;
closure = SegmentedControlG;
closure.__closure = {clampedActiveIndex: value11, defaultActiveIndex: value10, indicatorWidth: value7};
closure.__workletHash = 10116271570175;
closure.__initData = env0_13;
const value12 = Reflect.apply(useDerivedValue, ReanimatedRexportModule, [closure]);
const env0_17 = value12;
const useAnimatedStyle = ReanimatedRexportModule.useAnimatedStyle;
closure = SegmentedControlB;
object = {indicatorTranslateX: value12, pressedIndex: pressedIndex, clampedActiveIndex: value11,
PRESSED_TRANSLATE_AMOUNT: 0.04, indicatorWidth: value7, scrollOverflow: scrollOverflow};
object.interpolate = ReanimatedRexportModule.interpolate;
object.SCROLL_OVERFLOW_UPPER_BOUND = 50;
object.SCROLL_OVERFLOW_MAX_SCALE = 0.9;
object.segmentSpacing = r20;
object.itemCount = length;
object.previousIndicatorWidth = value8;
object.withSpring = (require(4577) /* metro dependency 4577: spring */).withSpring;
object.SELECTED_INDICATOR_SPRING = env0_8;
closure.__closure = object;
closure.__workletHash = 5537358752627;
closure.__initData = env0_14;
const value14 = binding.useMemo(function() {
return items.map(_fun72115);
}, [items2, value10, value9, styles.indicator, Reflect.apply(useAnimatedStyle, ReanimatedRexportModule, [closure])]);
const value15 = binding.useMemo(function() {
return items.map(_fun72117);
}, [items2, length, r20, state, pressedIndex, value, variant, setActiveIndex]);
const value16 = _fun72121();
const Gesture = (require(5321) /* metro dependency 5321 */).Gesture;
const value17 = Gesture.Pan();
const onStart = value17.onStart;
closure = SegmentedControlJ;
closure.__closure = {panIndex: value6, activeIndex: activeIndex};
closure.__workletHash = 16822477236158;
closure.__initData = env0_17;
const value19 = Reflect.apply(onStart, value17, [closure]).onUpdate(value16);
const onEnd = value19.onEnd;
closure = SegmentedControlH;
object = {panIndex: value6, activeIndex: activeIndex};
object.runOnJS = ReanimatedRexportModule.runOnJS;
object.setActiveIndex = setActiveIndex;
closure.__closure = object;
closure.__workletHash = 4531135834116;
closure.__initData = env0_16;
const value20 = Reflect.apply(onEnd, value19, [closure]);
const view = (
<View
accessibilityRole={(require(477) /* metro dependency 477: PlatformUtils */).isAndroid() ? 'tablist' : 'tabbar'}
style={styles.controlsContainer}
key={items2.length}
>
<View accessible={false} style={styles.indicatorContainer}>
{value14}
</View>
{value15}
</View>
);
if (value) {
const GestureDetector = (require(5321) /* metro dependency 5321 */).GestureDetector;
return (
<GestureDetector gesture={value20}>
{view}
</GestureDetector>
);
} else {
return (
<ScrollView
horizontal
alwaysBounceHorizontal={false}
contentContainerStyle={styles.scrollContentContainer}
keyboardShouldPersistTaps={keyboardShouldPersistTaps}
>
{view}
</ScrollView>
);
}
function SegmentedControlT() { // fn#72108, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:9406:4183, owner: SegmentedControl.T, offset: 0x01d3a4dc, size: 18 bytes, params: 1, frame: 9
return env0_12.get();
}
function SegmentedControlR(a0, a1) { // fn#72109, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:9406:4277, owner: SegmentedControl.R, offset: 0x01d3a4ee, size: 30 bytes, params: 3, frame: 11
if (a1 != null) {
env0_13.set(a1);
}
}
function _fun72110({nativeEvent}) { // fn#72110, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:9406:4428, offset: 0x01d3a50c, size: 41 bytes, params: 2, frame: 11
const binding = env0_12;
binding.set(nativeEvent.layout.width);
}
function SegmentedControlG() { // fn#72112, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:9406:4707, owner: SegmentedControl.G, offset: 0x01d3a578, size: 52 bytes, params: 1, frame: 11
let binding = env0_16;
let get = binding.get;
const value2 = Reflect.apply(get, binding, []);
binding = env0_15;
get = binding.get;
const value3 = value2 - Reflect.apply(get, binding, []);
binding = env0_12;
get = binding.get;
return value3 * Reflect.apply(get, binding, []);
}
function SegmentedControlB() { // fn#72113, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:9406:4889, owner: SegmentedControl.B, offset: 0x01d3a5ac, size: 734 bytes, params: 1, frame: 23
var r1;
var r2;
var r6;
var r7;
var value5;
var value6;
var value8;
var value11;
var value13;
var moduleValue;
var value15;
var value18;
var moduleValue2;
var value20;
var set;
var binding2;
var value;
let binding = env0_17;
let get = binding.get;
const value2 = Reflect.apply(get, binding, []);
const value3 = pressedIndex.get();
const value4 = 1;
if (value3 >= 0) {
value5 = pressedIndex.get();
binding = env0_16;
if (value5 < binding.get()) {
value11 = value2 - 0.02 * env0_12.get();
r1 = 1.04;
r2 = value11;
} else {
value6 = pressedIndex.get();
binding = env0_16;
if (value6 > binding.get()) {
value8 = value2 + 0.02 * env0_12.get();
r1 = 1.04;
r2 = value8;
} else {
r1 = value4;
r2 = value2;
}
}
r6 = r1;
r7 = r2;
} else {
r6 = value4;
r7 = value2;
}
get = scrollOverflow.get;
if (Reflect.apply(get, scrollOverflowBinding, []) < 0) {
value18 = environment.__proto__;
moduleValue2 = require(4017) /* metro dependency 4017: ReanimatedRexport */;
value20 = moduleValue2.interpolate(scrollOverflow.get(), [-50, 0], [0.9, 1], 'clamp');
binding = env0_12;
r2 = r7 + -binding.get() * (value4 - value20) / 2;
r6 = value20;
} else {
scrollOverflowBinding = scrollOverflow;
if (scrollOverflowBinding.get() > 0) {
value13 = environment.__proto__;
moduleValue = require(4017) /* metro dependency 4017: ReanimatedRexport */;
value15 = moduleValue.interpolate(scrollOverflow.get(), [50, 0], [0.9, 1], 'clamp');
r2 = r7 + env0_12.get() * (value4 - value15) / 2;
r6 = value15;
} else {
r2 = r7;
}
}
binding = env0_16;
get = binding.get;
r7 = Reflect.apply(get, binding, []) === 0 ? r2 + env0_8 : env0_16.get() !== length - value4 ? r2 : r2 - env0_8;
const value26 = env0_12.get();
binding = env0_13;
get = binding.get;
const value27 = value26 === Reflect.apply(get, binding, []);
if (!value27) {
binding = env0_13;
set = binding.set;
binding2 = env0_12;
Reflect.apply(set, binding, [binding2.get()]);
}
if (value27) {
value = environment.__proto__;
value = (require(4577) /* metro dependency 4577: spring */).withSpring(r7, env1_8);
r1 = value;
} else {
r1 = r7;
}
const items2 = [{translateX: r1}];
const object2 = {};
value = environment.__proto__;
object2.scaleX = (require(4577) /* metro dependency 4577: spring */).withSpring(r6, env1_8);
items2[1] = object2;
return {transform: items2};
}
function _fun72114() { // fn#72114, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:9406:5779, offset: 0x01d3a88a, size: 28 bytes, params: 1, frame: 11
return items.map(_fun72115);
function _fun72115({id}, a1) { // fn#72115, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:9406:5790, offset: 0x01d3a8a6, size: 133 bytes, params: 3, frame: 19
const value3 = env1_15.get() === a1;
const View = (ReanimatedRexport).View;
return (
<View
onLayout={value3 ? env1_14 : undefined}
style={[styles.indicator, value3 ? env1_18 : {opacity: 0}]}
key={id}
/>
);
}
}
function _fun72116() { // fn#72116, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:9406:5944, offset: 0x01d3a92b, size: 28 bytes, params: 1, frame: 11
return items.map(_fun72117);
function _fun72117({label, id, icon}, a1) { // fn#72117, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:9406:5955, offset: 0x01d3a947, size: 288 bytes, params: 3, frame: 25
var environment;
const env0_0 = a1;
let value = a1 === 0;
const r12 = value ? env1_8 : a1 !== length - 1 ? undefined : -env1_8;
const r11 = value ? -env1_8 : a1 !== length - 1 ? undefined : env1_8;
value = environment.__proto__.__proto__;
const SegmentedControlItem = (SegmentedControlItemNativeModule).SegmentedControlItem;
return (
<SegmentedControlItem
style={{
minWidth: 1 / length * 100 + '%',
marginStart: r12,
marginEnd: r11,
}}
index={a1}
itemCount={length}
label={label}
state={state}
pressed={pressedIndex}
onPress={function() {
setActiveIndex(require);
}}
onPressIn={function() {
pressedIndex.set(require);
}}
onPressOut={function() {
pressedIndex.set(-1);
}}
icon={env1_7 ? icon : null}
variant={variant}
key={id}
/>
);
}
}
function _fun72121() { // fn#72121, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:9406:6325, offset: 0x01d3aab5, size: 87 bytes, params: 1, frame: 4
const onPanGestureUpdate2 = onPanGestureUpdate;
onPanGestureUpdate2.__closure = {indicatorWidth: env0_12, panIndex: env0_11, activeIndex: activeIndex,
itemCount: length};
onPanGestureUpdate2.__workletHash = 4853281820821;
onPanGestureUpdate2.__initData = env1_15;
return onPanGestureUpdate2;
function onPanGestureUpdate({translationX}) { // fn#72122, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:9406:6359, offset: 0x01d3ab0c, size: 113 bytes, params: 2, frame: 18
let binding = env1_12;
let get = binding.get;
const value2 = translationX / Reflect.apply(get, binding, []);
binding = env1_11;
get = binding.get;
const value3 = Reflect.apply(get, binding, []) + value2;
const activeIndexBinding = activeIndex;
const set = activeIndexBinding.set;
const Math = global.Math;
const min = Math.min;
const Math2 = global.Math;
Reflect.apply(set, activeIndexBinding, [Reflect.apply(min, Math, [Math2.max(value3, 0), length - 1])]);
}
}
function SegmentedControlJ() { // fn#72123, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:9406:6677, owner: SegmentedControl.J, offset: 0x01d3ab7d, size: 34 bytes, params: 1, frame: 12
const binding = env0_11;
const set = binding.set;
const activeIndexBinding = activeIndex;
const get = activeIndexBinding.get;
Reflect.apply(set, binding, [Reflect.apply(get, activeIndexBinding, [])]);
}
function SegmentedControlH() { // fn#72124, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:9406:6814, owner: SegmentedControl.H, offset: 0x01d3ab9f, size: 127 bytes, params: 1, frame: 15
const binding = env0_11;
let set = binding.set;
Reflect.apply(set, binding, [-1]);
let activeIndexBinding = activeIndex;
set = activeIndexBinding.set;
const Math = global.Math;
const round = Math.round;
const activeIndexBinding2 = activeIndex;
let get = activeIndexBinding2.get;
Reflect.apply(set, activeIndexBinding, [Reflect.apply(round, Math, [Reflect.apply(get, activeIndexBinding2, [])])]);
const value3 = ReanimatedRexportModule.runOnJS(setActiveIndex);
activeIndexBinding = activeIndex;
get = activeIndexBinding.get;
value3(Reflect.apply(get, activeIndexBinding, []));
}
}
}
global.__d(_fun72105, 9221, [31, 27, 33, 4501, 697, 3860, 4017, 4577, 9222, 5321, 477,
2]) /* metro module 9221, dependencies: [31, 27, 33, 4501, 697, 3860, 4017, 4577, 9222, 5321, 477, 2] */;