import * as endConf from 'amos-processor/lib/config/endconf';
import formatUrl from 'amos-processor/lib/utils/urlFormat';
import { Store } from 'amos-tool';
import SysConsts from 'amos-processor/lib/config/consts';
const lsTool = Store.lsTool;
const completePrefix = endConf.completePrefix;

const AmosConfig = endConf.AmosConfig;
const baseURI = AmosConfig.wsURI.baseURI;
const view3dURI = AmosConfig.wsURI.view3dURI;
const getToken = () => {
  return lsTool.read(SysConsts.token);
};


export default {
  rulews: completePrefix(view3dURI, 'rule.ws?token={token}'),
  view3dws: completePrefix(view3dURI, 'view3d.ws?token={token}'),
  viewIndexws: completePrefix(baseURI, '3dViewMessage')
};

export const completeToken = (url) => {
  const token = getToken();
  const result = formatUrl(url, { token });
  return result;
};
