"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.useAsset = exports.useChain = exports.useSearchParam = void 0;
var react_router_dom_1 = require("react-router-dom");
var react_1 = require("react");
function useSearchParam() {
    var _search = (0, react_router_dom_1.useLocation)().search;
    var urlSearchParams = new URLSearchParams(_search);
    var get = (0, react_1.useMemo)(function () { return function (key, defaultValue) {
        var value = urlSearchParams === null || urlSearchParams === void 0 ? void 0 : urlSearchParams.get(key);
        if (!value && defaultValue)
            return defaultValue;
        return value;
    }; }, [urlSearchParams]);
    var editSearchParam = (0, react_1.useMemo)(function () { return function (name, value, defaultValue) {
        var newSearchParams = urlSearchParams;
        if (value === null || value === defaultValue)
            newSearchParams === null || newSearchParams === void 0 ? void 0 : newSearchParams.delete(name);
        else
            newSearchParams.set(name, value);
        return "?".concat(newSearchParams === null || newSearchParams === void 0 ? void 0 : newSearchParams.toString());
    }; }, [urlSearchParams]);
    return { get: get, editSearchParam: editSearchParam, search: _search };
}
exports.useSearchParam = useSearchParam;
function useChain() {
    return useSearchParam().get('chain');
}
exports.useChain = useChain;
function useAsset() {
    return useSearchParam().get('asset');
}
exports.useAsset = useAsset;
//# sourceMappingURL=router.js.map