#!/bin/bash

# Script to run the SDK locally without TypeScript errors

# Ensure we're in the SDK directory
cd "$(dirname "$0")"

# Clean up previous build
echo "Cleaning up previous build..."
rm -rf dist

# Install dependencies if needed
if [ ! -d "node_modules" ]; then
  echo "Installing dependencies..."
  npm install
fi

# Create dist directory
mkdir -p dist

# Copy files directly without TypeScript compilation
echo "Copying files to dist..."
cp -r src/* dist/

# Copy CSS file to dist
cp src/cursor.css dist/

# Create package.json in dist
node -e "
const fs = require('fs');
const packageJson = JSON.parse(fs.readFileSync('package.json', 'utf8'));
packageJson.main = 'index.js';
packageJson.types = 'index.d.ts';
delete packageJson.scripts;
delete packageJson.devDependencies;
fs.writeFileSync('dist/package.json', JSON.stringify(packageJson, null, 2), 'utf8');
"

echo "SDK is ready for local use!"
echo "You can now import from '../../sdk/dist' in your project"