// Module ID: 11918 // Function ID: 11919 // Name: useFocusHelper // Dependencies: [19, 38, 6170, 2] // Exports: default // Module 11918 (useFocusHelper) import _modDef38 from "module_38" /* 38 */; import react from "react" /* 19 */; import size from "module_2" /* 2 */; function FocusHelperState() { const merged = Object.assign({ refsByKey: null, keyOrder: null }); merged[0] = {}; merged[1] = []; return merged; } class FocusHelperImpl { constructor() { const obj = Object.create(new.target.prototype); if (typeof FocusHelperState === "function") { const merged = Object.assign({ refsByKey: null, keyOrder: null }); merged[0] = {}; merged[1] = []; obj.validState = merged; obj.focusNext = function focusNext() { let keyOrder; let refsByKey; ({ refsByKey, keyOrder } = obj.validState); let tmp2; const keys = Object.keys(); if (keys !== undefined) { while (keys[tmp] !== undefined) { let tmp12 = refsByKey[tmp4]; let isFocusedResult; if (tmp12 != null) { let current = tmp12.current; if (current != null) { isFocusedResult = current.isFocused(); } } tmp2 = tmp4; if (true === isFocusedResult) { break; } } } if (null != tmp2) { const index = keyOrder.indexOf(tmp2); if (-1 !== index) { if (index < keyOrder.length - 1) { if (refsByKey[obj.validState.keyOrder[index + 1]] != null) { const current2 = tmp8.current; if (current2 != null) { current2.focus(); } } } } onAddAnswer = obj.onAddAnswer; if (onAddAnswer != null) { onAddAnswer(); } } }; obj.focus = function focus(arg0) { if (obj.validState.refsByKey[arg0] != null) { const current = tmp.current; if (current != null) { current.focus(); } } }; return obj; } else { throw new TypeError("Trying to call a non-function"); } } restartState() { if (typeof FocusHelperState === "function") { const self = this; const merged = Object.assign({ refsByKey: null, keyOrder: null }); merged[0] = {}; merged[1] = []; this.pendingState = merged; } else { throw new TypeError("Trying to call a non-function"); } } commitState() { const self = this; const pendingState = this.pendingState; if (null != pendingState) { self.validState = pendingState; } self.pendingState = undefined; } refWithKey(question) { const pendingState = this.pendingState; _modDef38(null != pendingState, "Called refWithKey without a valid state"); const keyOrder = pendingState.keyOrder; keyOrder.push(question); if (null != pendingState.refsByKey[question]) { return pendingState.refsByKey[question]; } else { const ref = react.createRef(); pendingState.refsByKey[question] = ref; return ref; } } } const prototype = FocusHelperImpl.prototype; const result = size.fileFinishedImporting("modules/polls/native/useFocusHelper.tsx"); export default function useFocusHelper() { let obj = arg0; if (arg0 === undefined) { obj = {}; } let onAddAnswer = obj.onAddAnswer; let obj2; obj2 = onAddAnswer(obj2[2])(function() { if (typeof FocusHelperImpl === "function") { const obj = Object.create(FocusHelperImpl.prototype); const self = this; if (typeof FocusHelperState === "function") { const merged = Object.assign({ refsByKey: null, keyOrder: null }); merged[0] = {}; merged[1] = []; obj.validState = merged; obj.focusNext = function focusNext() { let keyOrder; let refsByKey; ({ refsByKey, keyOrder } = obj.validState); let tmp2; const keys = Object.keys(); if (keys !== undefined) { while (keys[tmp] !== undefined) { let tmp12 = refsByKey[tmp4]; let isFocusedResult; if (tmp12 != null) { let current = tmp12.current; if (current != null) { isFocusedResult = current.isFocused(); } } tmp2 = tmp4; if (true === isFocusedResult) { break; } } } if (null != tmp2) { const index = keyOrder.indexOf(tmp2); if (-1 !== index) { if (index < keyOrder.length - 1) { if (refsByKey[obj.validState.keyOrder[index + 1]] != null) { const current2 = tmp8.current; if (current2 != null) { current2.focus(); } } } } onAddAnswer = obj.onAddAnswer; if (onAddAnswer != null) { onAddAnswer(); } } }; obj.focus = function focus(arg0) { if (obj.validState.refsByKey[arg0] != null) { const current = tmp.current; if (current != null) { current.focus(); } } }; return obj; } else { throw new TypeError("Trying to call a non-function"); } } else { throw new TypeError("Trying to call a non-function"); } }); obj2.restartState(); const effect = react.useEffect(() => { obj2.onAddAnswer = onAddAnswer; obj2.commitState(); }); return obj2; };