{"version":3,"file":"state.cjs","sources":["../../../../src/hooks/useScreen/state.ts"],"sourcesContent":["export interface ScreenState {\n    isSmallDevice: boolean;\n    isMediumDevice: boolean;\n    isLargeDevice: boolean;\n    isXlDevice: boolean;\n    isLandscape: boolean;\n    isPortrait: boolean;\n}\n\nexport const ActionType = {\n    orientation: \"ORIENTATION_CHANGED\",\n    deviceSize: \"DEVICE_SIZE_CHANGED\",\n} as const;\n\nexport interface ScreenAction {\n    type: (typeof ActionType)[keyof typeof ActionType];\n    property: keyof ScreenState;\n}\n\nfunction setDeviceSize(\n    deviceSize: keyof ScreenState,\n): Omit<ScreenState, \"isLandscape\" | \"isPortrait\"> {\n    return {\n        isSmallDevice: deviceSize === \"isSmallDevice\",\n        isMediumDevice: deviceSize === \"isMediumDevice\",\n        isLargeDevice: deviceSize === \"isLargeDevice\",\n        isXlDevice: deviceSize === \"isXlDevice\",\n    };\n}\n\nfunction setOrientation(\n    orientation: keyof ScreenState,\n): Pick<ScreenState, \"isLandscape\" | \"isPortrait\"> {\n    return {\n        isLandscape: orientation === \"isLandscape\",\n        isPortrait: orientation === \"isPortrait\",\n    };\n}\n\nexport const reducer = (\n    state: ScreenState,\n    action: ScreenAction,\n): ScreenState => {\n    switch (action.type) {\n        case ActionType.orientation:\n            return {\n                ...state,\n                ...setOrientation(action.property),\n            };\n        case ActionType.deviceSize:\n            return {\n                ...state,\n                ...setDeviceSize(action.property),\n            };\n        default:\n            return state;\n    }\n};\n"],"names":["ActionType","orientation","deviceSize","setDeviceSize","isSmallDevice","isMediumDevice","isLargeDevice","isXlDevice","setOrientation","isLandscape","isPortrait","state","action","type","property"],"mappings":"gFASO,MAAMA,EAAa,CACtBC,YAAa,sBACbC,WAAY,uBAQhB,SAASC,EACLD,GAEA,MAAO,CACHE,cAA8B,kBAAfF,EACfG,eAA+B,mBAAfH,EAChBI,cAA8B,kBAAfJ,EACfK,WAA2B,eAAfL,EAEpB,CAEA,SAASM,EACLP,GAEA,MAAO,CACHQ,YAA6B,gBAAhBR,EACbS,WAA4B,eAAhBT,EAEpB,sCAEuB,CACnBU,EACAC,KAEA,OAAQA,EAAOC,MACX,KAAKb,EAAWC,YACZ,MAAO,IACAU,KACAH,EAAeI,EAAOE,WAEjC,KAAKd,EAAWE,WACZ,MAAO,IACAS,KACAR,EAAcS,EAAOE,WAEhC,QACI,OAAOH"}