class DigitalTwinModel:
    def __init__(self):
        self.history = []

    def learn(self, demand, customers):
        self.history.append({
            "demand": demand,
            "customers": customers
        })

        if len(self.history) > 50:
            self.history.pop(0)

    # ----------------------------
    # ACTIVE TRENDS
    # ----------------------------
    def get_active_trends(self, industry, demand, customers):
        trends = []

        if industry == "fashion":
            if demand > 130:
                trends.append("Seasonal fashion demand rising")
            if customers > 600:
                trends.append("Online fashion shopping growth")
            if demand < 90:
                trends.append("Clearance sales trend")

        elif industry == "retail":
            if demand > 120:
                trends.append("High demand for essential goods")
            if customers > 500:
                trends.append("In-store footfall increasing")
            if demand < 80:
                trends.append("Shift towards online retail")

        elif industry == "tech":
            if demand > 140:
                trends.append("High adoption of new technologies")
            if customers > 800:
                trends.append("Rapid user base growth")
            if demand < 100:
                trends.append("Slowdown in technology upgrades")

        return trends or ["Stable market trend"]

    # ----------------------------
    # COMPETITORS
    # ----------------------------
    def get_competitors(self, industry):
        if industry == "fashion":
            return ["Zara", "H&M", "Myntra", "Shein"]

        elif industry == "retail":
            return ["Reliance Retail", "Amazon", "Flipkart", "Walmart"]

        elif industry == "tech":
            return ["Google", "Microsoft", "Apple", "Amazon"]

        return []

    # ----------------------------
    # MARKET ACTIVITY
    # ----------------------------
    def get_market_activity(self, demand, customers):
        if demand > 140 and customers > 700:
            return "Highly active market"
        elif demand > 100:
            return "Moderately active market"
        else:
            return "Low market activity"

    # ----------------------------
    # SENTIMENT
    # ----------------------------
    def get_sentiment(self, demand, customers):
        score = demand + customers / 10

        if score > 220:
            return "Positive"
        elif score > 150:
            return "Neutral"
        else:
            return "Negative"
