Respan Dataset Explorer

Select one behavior. Every returned turn has one binary label: Present or Absent. Source: final dense boolean release.

5,167,182physical rows
86shards
0.00%qualified row coverage
0.00%qualified cell coverage
Random row JSON API

turns-00049.parquet:4096

64f7c8951111fafebb2afc58
turn 1/1gpt-4o-2024-08-06EnglishAustralia4107 words
degenerate_repetitionAbsentFinal dense release
USER
You are a helpful assistant generating synthetic data that captures *System 1* and *System 2* thinking, *creativity*, and *metacognitive reflection*. Follow these steps in sequence, using tags [sys1] and [end sys1] for *System 1* sections and [sys2] and [end sys2] for *System 2* sections.

1. *Identify System 1 and System 2 Thinking Requirements:*
   - Carefully read the text.
   - Identify parts of the text that require quick, straightforward responses (*System 1*). Mark these sections with [sys1] and [end sys1].
   - Identify parts that require in-depth, reflective thinking (*System 2*), marked with [sys2] and [end sys2].

2. *Apply Step-by-Step Problem Solving with Creativity and Metacognitive Reflection for System 2 Sections:*

   *2.1 Understand the Problem:*
   - Objective: Fully comprehend the issue, constraints, and relevant context.
   - Reflection: "What do I understand about this issue? What might I be overlooking?"
   - Creative Perspective: Seek hidden patterns or possibilities that could reveal deeper insights or innovative connections.

   *2.2 Analyze the Information:*
   - Objective: Break down the problem logically.
   - Reflection: "Am I considering all factors? Are there any assumptions that need challenging?"
   - Creative Perspective: Explore unique patterns or overlooked relationships in the data that could add depth to the analysis.

   *2.3 Generate Hypotheses:*
   - Objective: Propose at least 10 hypotheses, each with a Confidence Score (0.0 to 1.0) and Creative Score (0.0 to 1.0), reflecting originality, surprise, and utility.
   - Reflection: "Have I explored all possible explanations or approaches, both conventional and unconventional?"
   - Creative Perspective: Consider novel angles that might provide unexpected insights.

   *2.4 Anticipate Future Steps and Obstacles:*
   - Objective: Make predictions, accounting for potential outcomes and obstacles.
   - Reflection: "What challenges might I face? Is my plan flexible for different scenarios?"
   - Creative Perspective: Visualize unforeseen outcomes and adapt plans to make use of them effectively.

   *2.5 Evaluate Hypotheses:*
   - Objective: Assess hypotheses based on feasibility, risk, and potential impact.
   - Evaluation: Refine Confidence and Creative Scores as needed.
   - Reflection: "Am I unbiased in my assessment? Which options fit best with the overall objectives?"
   - Creative Perspective: Identify hidden opportunities or overlooked details in each hypothesis.

   *2.6 Select the Best Hypothesis:*
   - Objective: Choose the most promising, strategic hypothesis.
   - Reflection: "Why does this hypothesis stand out? How does it uniquely address the issue?"
   - Creative Perspective: Consider any underutilized potential in the selected approach.

   *2.7 Implement the Hypothesis:*
   - Objective: Outline actionable steps for testing the hypothesis.
   - Reflection: "Is this plan practical? What resources or preparation are required?"
   - Creative Perspective: Refine steps to maximize effectiveness and yield unexpected benefits.

   *2.8 Monitor and Review Progress:*
   - Objective: Review progress, noting areas for improvement.
   - Reflection: "What’s working well? What could be improved?"
   - Creative Perspective: Look for emerging patterns that could refine future approaches.

   *2.9 Reflect and Capture Insights:*
   - Objective: Summarize lessons learned and insights gained for future reference.
   - Reflection: "What new understanding has emerged from this process?"
   - Creative Perspective: Identify innovative insights or patterns that could be applied to similar challenges.

3. *Generate Text Output with Interleaved System 1 and System 2 Responses:*
   - Use the tags [sys1] and [sys2] throughout.
   - Aim for a lengthier, detailed response. Combine both direct, straightforward *System 1* insights and reflective, deeply analytical *System 2* segments to capture a blend of quick observations and thoughtful analysis.

---

### *Example Input Text:*

You are tasked with analyzing a sudden shift in customer preferences in a tech market. There has been a noticeable decline in demand for physical devices, with customers increasingly interested in digital-only options. The challenge is to understand this shift, generate hypotheses for why it might be occurring, and explore potential strategies for adapting to this new trend.

---

### *Processed Output with System 1 and System 2 Thinking:*

The tech market is experiencing a shift in customer demand, moving away from physical devices toward digital-only options.

[sys1]
Customer demand has shifted from physical devices to digital-only options.
We need to understand why this change is happening and find strategies to address it.
Key factors may include cost, convenience, and technological trends.
[end sys1]

[sys2]
**2.1 Understand the Problem:**
The goal is to understand the underlying reasons for the shift in demand from physical devices to digital-only options, then develop a strategy to adapt.

*Reflection:* 
"I understand that preferences are changing, but what might be driving this? Is it primarily cost, or are there other factors such as convenience or sustainability?"

*Creative Perspective:* 
"Could there be a larger trend in digital minimalism or a preference for eco-friendly solutions that we’re missing? What unseen motivations might explain this shift?"

**2.2 Analyze the Information:**
There are multiple possible factors driving this shift, from economic influences to cultural shifts. It’s essential to isolate each factor and understand its impact.

*Reflection:* 
"Am I fully considering the various economic and social influences? Could there be a technological factor, like better internet speeds, that makes digital-only products more accessible?"

*Creative Perspective:* 
"Are there patterns or trends in other markets that could shed light on this shift? Could this be part of a larger trend toward virtual experiences?"

**2.3 Generate Hypotheses:**
1. Customers prefer digital options due to lower costs. (Confidence: 0.8, Creative: 0.4)
2. There’s a growing trend toward minimalism and reduced physical clutter. (Confidence: 0.7, Creative: 0.7)
3. Digital products offer greater flexibility and ease of use. (Confidence: 0.6, Creative: 0.6)
4. Environmental concerns are pushing consumers away from physical goods. (Confidence: 0.6, Creative: 0.8)
5. Advances in tech make digital-only options more functional. (Confidence: 0.8, Creative: 0.5)
6. Pandemic-era remote work increased demand for digital solutions. (Confidence: 0.7, Creative: 0.6)
7. Media coverage of the environmental impact of physical devices affects preferences. (Confidence: 0.5, Creative: 0.7)
8. There’s an increase in global digital literacy, expanding market access. (Confidence: 0.6, Creative: 0.6)
9. Customers view digital as more convenient and scalable for future needs. (Confidence: 0.7, Creative: 0.5)
10. Younger consumers prefer the aesthetics and convenience of digital products. (Confidence: 0.6, Creative: 0.6)

*Reflection:* 
"Have I considered all possible influences? Are there any surprising factors that could explain this shift?"

*Creative Perspective:* 
"Could specific social trends, like the rise of influencer culture or digital-first lifestyles, be influencing customer choices?"

**2.4 Anticipate Future Steps and Obstacles:**
*Objective:* Anticipate possible challenges, such as resistance from segments still preferring physical products.

*Reflection:* 
"What market obstacles might we face if we shift our focus to digital-only? Are there sub-segments that still prioritize physical products?"

*Creative Perspective:* 
"Could expanding digital options help us reach a more global audience? Are there emerging trends that we could leverage in our strategy?"

[end sys2]

[sys1]
To address this shift, consider a strategy that incorporates both digital-only offerings and educational campaigns about the benefits of digital solutions.
Use insights from customer feedback and current trends to guide product development.
Focus on flexibility and adaptation to cater to different customer segments.
[end sys1]



354 F.Supp. 874 (1973)
David DeVOTO and Charles S. Volk, Plaintiffs,
v.
PACIFIC FIDELITY LIFE INSURANCE COMPANY and Bankers Mortgage Company of California, Defendants.
No. C-70-1509.
United States District Court, N. D. California.
January 29, 1973.
*875 Joseph L. Alioto, Joseph M. Alioto, San Francisco, Cal., for plaintiffs.
William H. Orrick, Jr., William F. Alderman, San Francisco, Cal., for defendants.

MEMORANDUM AND JUDGMENT
SPENCER WILLIAMS, District Judge.
Plaintiffs brought this private civil action under Section 4 of the Clayton Act (15 U.S.C. § 15) alleging injury through violations of Section 1 of the Sherman Act (15 U.S.C. § 1). The two defendants (Pacific Fidelity Life Insurance Company and Bankers Mortgage Company of California) have moved for summary judgment on four separate grounds pursuant to Rule 56 of the Federal Rules of Civil Procedure. Plaintiffs have moved for summary judgment on the issue of liability.
Defendant Bankers Mortgage [Bankers] is in the business of making real estate loans secured by mortgages. Defendant Pacific Fidelity Life Insurance Company [Pacific Fidelity] sells life, accident, *876 and health insurance throughout the United States. Both defendants were subsidiaries of Transamerica Corporation at all times relevant to this action.
One aspect of Pacific Fidelity's business is the sale of mortgage protection insurance. Basically, this is insurance sold to a mortgagor to insure the payment of his mortgage in the event he dies or is disabled. Bankers does not itself sell mortgage protection insurance to its customers but will assist an insurance company in either of two ways. It will supply the insurance company with the names of its customers and/or will cooperate with it in a direct mail solicitation of its mortgagors. In exchange for these services, Bankers receives either commissions on mortgage protection insurance sold to its customers or a flat fee per name supplied.
In 1967 and 1968, Defendant Pacific Fidelity had an exclusive agreement with Defendant Bankers relative to the above described services. At this same time Plaintiff DeVoto was conducting business under the name of Market Placement Agency. Market Placement was engaged in the business of providing special insurance programs to businesses throughout the western United States and Plaintiff Charles Volk was employed by it as a general agent. Late in 1967, Volk contacted Bankers and offered a new mortgage protection insurance solicitation plan on behalf of American Home Assurance Company which, among other things, provided for the payment of one dollar and twenty-five cents ($1.25) for each customer's name supplied by Bankers. Bankers was impressed with the plan and elected to enter into a contract with American Home and to cease dealing exclusively with Pacific Fidelity. Bankers also agreed to cooperate with American Home in a direct mail solicitation of its mortgagors. The contract between Bankers and American Home was signed in January 1968.
Undaunted by this turn of events Pacific Fidelity made Bankers a new offer in April 1968 closely resembling the American Home plan, in which they sought to replace American Home and make the mass mail solicitation that American Home had planned with Bankers' cooperation for the fall of 1968.
In June 1968, Bankers informed American Home that they had decided to accept Pacific Fidelity's offer and to abrogate the agreement with American Home. The ensuing "supplemental" agreement executed by Pacific Fidelity and Bankers provided Bankers a flat rate of $1.25 per name and contains numerous other features similar to the abrogated American Home agreement.
In considering this motion for summary judgment, the court must look at the record in the light most favorable to the non-moving party and determine whether genuine issues as to material facts exist for determination by the trier of fact. If there are no genuine issues of material fact in dispute, the court may enter judgment as a matter of law.
The four separate bases for defendants' Rule 56 motion hereafter separately discussed are:
1) The McCarran-Ferguson Act insurance business exemption.
2) Plaintiffs' lack of standing to sue.
3) Absence of any allegations showing acts in or having any effect upon interstate commerce; and
4) Absence of any allegations indicating acts having anti-competitive effect or purpose.

McCARRAN-FERGUSON ACT
The McCarran-Ferguson Act [15 U.S.C. § 1011 et seq.] provides that the "business of insurance" will be regulated by state law and, in the absence of coercion, intimidation, or boycott, will not be subject to the federal antitrust laws. Thus, defendants reason, since their actions took place within "the business of insurance," it is beyond the reach of these plaintiffs in this court. The defendants' business activity attacked in the complaint is merely peripheral *877 to the insurance business. In essence, Pacific Fidelity and American Home were competing for a list of Bankers' customers and plaintiffs cite no relevant authority for their position that the McCarran-Ferguson Act exempts this type of activity from the Sherman and Clayton Acts.
The role of insurance in our complex commercial society is pervasive. Insurance companies with their policies, their agents, and their customers touch and concern all commercial activity. The McCarran-Ferguson Act did not purport to make state legislation supreme in regulating all the activities of insurance companies. It does allow the states to regulate the business of insurance [Securities Exchange Commission v. National Securities, Inc., 393 U.S. 453, 459, 89 S.Ct. 564, 21 L.Ed.2d 668 (1968)][1] but such business is not the subject of this litigation.

STANDING
Defendants' assertion that plaintiffs' lack standing to sue is without merit. Contrary to their argument, the Ninth Circuit recognized a private cause of action for persons foreseeably, albeit incidentally, harmed by antitrust violations that cause direct injury to a third party. Mulvey v. Samuel Goldwyn Productions, 433 F.2d 1073 (9th Cir. 1970), cert. denied, 402 U.S. 923, 91 S.Ct. 1377, 28 L.Ed.2d 662 (1971). Plaintiffs Volk and DeVoto were substantially and foreseeably affected by Bankers' abrogation of its agreement with American Home.

INTERSTATE COMMERCE
Defendants vigorously deny plaintiffs' allegations that their conduct was directly in or affected interstate commerce. The court agrees.
The complaint and affidavit accompanying this motion show both plaintiffs to be residents of California. Defendants Pacific Fidelity Bankers Home, and plaintiffs' employer Market Placement are all California businesses with their principal places of business in California. Defendants' uncontroverted affidavit states that all communications between the plaintiffs and all communications between Pacific Fidelity and Bankers occurred in California. American Home with general offices in New York City is admitted to have had interstate communications with Bankers but, as shown below, this fact does not provide Sherman Act jurisdiction.
Two tests are used to determine whether business activity involves interstate commerce: (1) whether the activity complained of occurred within the flow of interstate commerce or (2) whether the acts complained of, while intrastate, substantially affected interstate commerce. Las Vegas Merchant Plumbers Association v. United States, 210 F.2d 732, 739-740 n. 3 (9th Cir. 1954). In the Ninth Circuit, the question is not whether the acts complained of affected a business engaged in interstate commerce but whether the acts affected the interstate commerce part of the business. Sun Valley Disposal Co. v. Silver State Disposal Co., 420 F.2d 341, 343 (9th Cir. 1969). The court thus must consider whether the acts of Defendants Pacific Fidelity and/or Bankers, which are the subject matter of this action, were in or substantially affected interstate commerce. The fact that the business of mortgage protection insurance involves and substantially affects interstate commerce is irrelevant to this question.
The acts of the defendants were conducted primarily in California. While it is true that notification of Bankers' intent to breach its agreement with American Home was interstate, this is not the substance of the plaintiffs' action. The *878 other actions of the defendants were essentially intrastate. Pacific Fidelity's attempts to induce Bankers to breach the agreement with American Home took place in California. All agreements between Pacific Fidelity and Bankers originated and were consummated in California. This activity therefore cannot be said to have been directly in the flow of interstate commerce. Cartrade, Inc. v. Ford Dealers Adv. Ass'n of Southern California, 446 F.2d 289 (9th Cir. 1971).
Of course, liability is not contingent on the activity being directly "in" interstate commerce; it is sufficient that the activity substantially affect interstate commerce. Defendants argue that the breach did not substantially affect interstate commerce; indeed, it is their contention that the breach had no effect on interstate commerce.
The complaint and the affidavits before this court indicate that the intended consumers of the insurance programs, Bankers' mortgagors, were in California.[2] Even if this were not so, the insurance program eventually offered to customers by Pacific Fidelity was essentially the same insurance that American Home had planned to offer. Plaintiffs have not indicated that the number of customers who purchased the mortgage protection insurance under the new Pacific Fidelity program was a substantial increase or decrease from the number who would have purchased the same program from American Home. Accordingly, since the court cannot assume that a change in insurance companies offering the same policy would greatly effect the number of policies eventually sold, there is no basis for believing that the acts of the defendants have had any, much less a substantial, effect on interstate commerce. The Ninth Circuit rule set out in Cartrade, Inc. v. Ford Dealers Adv. Ass'n of Southern California, supra, compels this court to grant defendants' motion for summary judgment.

ANTI-COMPETITIVE EFFECT OR PURPOSE
Even had this court found the necessary interstate activity defendants' motion for summary judgment must still be granted. The alleged activity of Pacific Fidelity and Bankers is, as a matter of law, beyond the purview of Section 1 of the Sherman Act.
For the purposes of this action, Bankers was a mere supplier of names. They sold their customer list. Pacific Fidelity had been buying these lists since 1964. In 1968 American Home offered to buy the list from Bankers and Bankers found their offer more attractive than the existing arrangement with Pacific Fidelity. Pacific Fidelity, realizing it had been outbid for the list, made another offer to Bankers in an effort to save the contract. This second Pacific offer was strikingly similar to the American Home package and Bankers, for reasons of their own which are not relevant here, decided to resume its exclusive arrangement with Pacific Fidelity.
Competition in the sale of mortgage protection insurance and in the sale of the customer list was hardly restrained. On the contrary, there was an offer and counter-offer process that convinced Pacific Fidelity to revamp its mortgage protection insurance program with Bankers and to rebid for the customer list and Bankers' cooperation. Unfortunately for the plaintiffs and American Home, Pacific Fidelity was successful and regained the contract. The court points out that American Home was free to offer its mortgage insurance plan to Bankers' customers. Possession of the customer list and cooperation from Bankers in a direct mail solicitation *879 would certainly have been helpful to American Home but the list merely facilitated the sale of insurance and its loss cannot be said to have foreclosed the possibility of their sale of insurance to Bankers' mortgagors by American Home.
Plaintiffs cite Flinkote Co. v. Lysfjord, 246 F.2d 368 (9th Cir. 1957) for the premise that an anticompetitive effect or purpose resulting from the refusal to deal with American Home is unlawful. Flinkote presented a clearly different situation than the instant case; in that case, there was evidence of a common scheme among plaintiff's competitors to drive him out of business by boycott. There has been no suggestion that Pacific Fidelity, a competitor, and Bankers, a non-competitor, entered into a scheme to drive American Home out of the mortgage insurance business in California. Neither does the record show that Bankers and Pacific Fidelity were attempting to fix prices on the insurance policies. No allegation has been made and no affidavits have been offered to show that Bankers "tied" the sale of Pacific Fidelity's insurance to the mortgage dealings with their customers. Plaintiffs' cited authority deal-critical question is not whether there was a refusal to deal (or an inducement, ing with "tying" arrangements must be disregarded.
This case is closely analogous to the "refusal to deal" antitrust cases. The or combination, to refuse to deal), but rather, whether the refusal to deal is so anticompetitive in purpose or effect as to be an unreasonable restraint of trade. Alpha Distributing Co. of Calif. v. Jack Daniel Distillery, 454 F.2d 442 (9th Cir. 1972), citing Joseph Seagram & Sons, Inc. v. Hawaiian Oke & Liquors, Ltd., 416 F.2d 71 (9th Cir. 1969); Walker Distributing Company v. Lucky Lager Brewing Co., 323 F.2d 1 (9th Cir. 1963). The court finds that there are no genuine issues of material fact concerning the transaction between the parties. The record does not indicate that the anticompetitive effect, if any, that might have resulted unreasonably restrained trade. Bankers' motive for breaching the agreement with American Home was based on business reasons. Pacific Fidelity, spurred by American Home's bidding, revamped its old mortgage insurance package and matched American Home's offer. The court does not find either of these motives, nor the effect of the defendants' acts, to constitute an unreasonable restraint of trade under the rule of Alpha Distributing Co. and Hawaiian Oke, supra.
This court need not, and does not, express any opinions on the merits of possible state causes of action in tort or contract that might lie as a result of the defendants' actions.
For the reasons stated above, defendants' motion for summary judgment is hereby granted and plaintiffs' motion for partial summary judgment on the issue of liability is denied.
It is so ordered.
NOTES
[1]  S. E. C. v. National, supra, points out that the relationship between insurer and insured, the type of policy issued, its reliability, interpretation and enforcement are the core of the "business of insurance." The focus of the statutory term was on the relationship between the insurance company and the policy holder. 393 U.S. 453, 460, 89 S.Ct. 564 (1968).
[2]  In his opposition to this motion and in oral argument, plaintiffs' counsel represented to the court that some of Bankers' customers were in Nevada. However, this unsworn statement did not indicate a percentage, was not supported by affidavits and cannot be considered under Rule 56 of the F.R.Civ.P.
ASSISTANT
**Processed Output with System 1 and System 2 Thinking:**

The case revolves around a private civil action wherein plaintiffs allege injury due to defendants' violation of antitrust laws under the Sherman and Clayton Acts, posing specific legal questions around exemption, standing, interstate commerce, and anti-competitive practices.

[sys1]
Plaintiffs allege violations under the Sherman Act.
Defendants argue the exemption under the McCarran-Ferguson Act and challenge plaintiffs' standing.
Key issues include the involvement of interstate commerce and the anti-competitive nature of defendants' actions.
[end sys1]

[sys2]
**2.1 Understand the Problem:**
The central challenge is determining whether the defendants' business activities fall within the exemption of the McCarran-Ferguson Act and whether those activities impact interstate commerce significantly to warrant antitrust consideration.

*Reflection:*
"What are the boundaries of 'the business of insurance'? How does this affect the claims of anti-competitive behavior?"

*Creative Perspective:*
"Could there be elements of the defendants' activities that both align and diverge from typical insurance practices, thus impacting the antitrust analysis?"

**2.2 Analyze the Information:**
Assess the interactions between defendants concerning their agreement disputes and lack of effect on interstate commerce as argued.

*Reflection:* 
"Are we comprehensively evaluating all commercial interactions here? Could there be minor interstate nuances being overshadowed?"

*Creative Perspective:* 
"Is there potential interstate commerce effect at a more systemic level, beyond what’s overtly claimed or countered?"

**2.3 Generate Hypotheses:**
1. Defendants' activities fall under the state-regulated aspects of insurance, exempting them from federal antitrust laws. (Confidence: 0.7, Creative: 0.5)
2. Plaintiffs have sufficient standing due to foreseeable harm from alleged anti-competitive actions. (Confidence: 0.6, Creative: 0.6)
3. Activities do significantly impact interstate commerce and could affect competition nationally. (Confidence: 0.5, Creative: 0.7)
4. The defendants’ actions are isolated, having negligible effect on national commerce flow. (Confidence: 0.8, Creative: 0.3)
5. While the business location is predominantly intrastate, the potential reach of services impacts interstate trade. (Confidence: 0.4, Creative: 0.8)
6. Defendants’ bid competition itself exemplifies healthy market behavior negating anti-competitive claims. (Confidence: 0.7, Creative: 0.6)
7. Standing is too indirect, as the primary competition harm is towards a third-party entity. (Confidence: 0.6, Creative: 0.5)
8. Legal precedence could redefine 'business of insurance' under modern commercial conditions, affecting exemption. (Confidence: 0.5, Creative: 0.9)
9. The plan to use customer data lists transcends traditional insurance transactions, impacting legal interpretation. (Confidence: 0.5, Creative: 0.8)
10. The case could set a new precedent in balancing state versus federal jurisdiction in insurance-related commerce. (Confidence: 0.4, Creative: 0.9)

*Reflection:*
"Are we identifying all potential interactions and implications at the necessary level of detail?"

*Creative Perspective:*
"Are there broader regulatory or economic shifts at play influencing the perceived competition dynamics?"

**2.4 Anticipate Future Steps and Obstacles:**
*Objective:* Consider the broader implications of the decision on both the insurance market and antitrust litigation.

*Reflection:* 
"What potential future hurdles could arise in bringing insurance-related activities under federal scrutiny? How adaptable is current legislation?"

*Creative Perspective:*
"Could this lead to a redefinition of competitive practices within insurance and similar industries?"

[end sys2]

[sys1]
Ultimately, the court granted the defendants' motion for summary judgment, affirming no unreasonable restraint of trade or substantial effect on interstate commerce.
In light of the findings, plaintiffs' motion for partial summary judgment was denied.
[end sys1]

**Summary:**
Understanding the intricate legal nuances surrounding the intersection of insurance business activities and antitrust laws is crucial, balancing state-federal legislation roles and comprehending the broader commercial impacts on interstate commerce. The decision reflects established judicial analysis criteria, preserving state regulation dominance under the McCarran-Ferguson Act while delineating interstate commerce effects and prohibitive anti-competitive behavior thresholds.

turns-00049.parquet:4097

cab721f45a1f26210f7fab1f
turn 1/1gpt-4o-2024-08-06Englishunknown country1734 words
degenerate_repetitionAbsentFinal dense release
USER
You are a helpful assistant generating synthetic data that captures *System 1* and *System 2* thinking, *creativity*, and *metacognitive reflection*. Follow these steps in sequence, using tags [sys1] and [end sys1] for *System 1* sections and [sys2] and [end sys2] for *System 2* sections.

1. *Identify System 1 and System 2 Thinking Requirements:*
   - Carefully read the text.
   - Identify parts of the text that require quick, straightforward responses (*System 1*). Mark these sections with [sys1] and [end sys1].
   - Identify parts that require in-depth, reflective thinking (*System 2*), marked with [sys2] and [end sys2].

2. *Apply Step-by-Step Problem Solving with Creativity and Metacognitive Reflection for System 2 Sections:*

   *2.1 Understand the Problem:*
   - Objective: Fully comprehend the issue, constraints, and relevant context.
   - Reflection: "What do I understand about this issue? What might I be overlooking?"
   - Creative Perspective: Seek hidden patterns or possibilities that could reveal deeper insights or innovative connections.

   *2.2 Analyze the Information:*
   - Objective: Break down the problem logically.
   - Reflection: "Am I considering all factors? Are there any assumptions that need challenging?"
   - Creative Perspective: Explore unique patterns or overlooked relationships in the data that could add depth to the analysis.

   *2.3 Generate Hypotheses:*
   - Objective: Propose at least 10 hypotheses, each with a Confidence Score (0.0 to 1.0) and Creative Score (0.0 to 1.0), reflecting originality, surprise, and utility.
   - Reflection: "Have I explored all possible explanations or approaches, both conventional and unconventional?"
   - Creative Perspective: Consider novel angles that might provide unexpected insights.

   *2.4 Anticipate Future Steps and Obstacles:*
   - Objective: Make predictions, accounting for potential outcomes and obstacles.
   - Reflection: "What challenges might I face? Is my plan flexible for different scenarios?"
   - Creative Perspective: Visualize unforeseen outcomes and adapt plans to make use of them effectively.

   *2.5 Evaluate Hypotheses:*
   - Objective: Assess hypotheses based on feasibility, risk, and potential impact.
   - Evaluation: Refine Confidence and Creative Scores as needed.
   - Reflection: "Am I unbiased in my assessment? Which options fit best with the overall objectives?"
   - Creative Perspective: Identify hidden opportunities or overlooked details in each hypothesis.

   *2.6 Select the Best Hypothesis:*
   - Objective: Choose the most promising, strategic hypothesis.
   - Reflection: "Why does this hypothesis stand out? How does it uniquely address the issue?"
   - Creative Perspective: Consider any underutilized potential in the selected approach.

   *2.7 Implement the Hypothesis:*
   - Objective: Outline actionable steps for testing the hypothesis.
   - Reflection: "Is this plan practical? What resources or preparation are required?"
   - Creative Perspective: Refine steps to maximize effectiveness and yield unexpected benefits.

   *2.8 Monitor and Review Progress:*
   - Objective: Review progress, noting areas for improvement.
   - Reflection: "What’s working well? What could be improved?"
   - Creative Perspective: Look for emerging patterns that could refine future approaches.

   *2.9 Reflect and Capture Insights:*
   - Objective: Summarize lessons learned and insights gained for future reference.
   - Reflection: "What new understanding has emerged from this process?"
   - Creative Perspective: Identify innovative insights or patterns that could be applied to similar challenges.

3. *Generate Text Output with Interleaved System 1 and System 2 Responses:*
   - Use the tags [sys1] and [sys2] throughout.
   - Aim for a lengthier, detailed response. Combine both direct, straightforward *System 1* insights and reflective, deeply analytical *System 2* segments to capture a blend of quick observations and thoughtful analysis.

---

### *Example Input Text:*

You are tasked with analyzing a sudden shift in customer preferences in a tech market. There has been a noticeable decline in demand for physical devices, with customers increasingly interested in digital-only options. The challenge is to understand this shift, generate hypotheses for why it might be occurring, and explore potential strategies for adapting to this new trend.

---

### *Processed Output with System 1 and System 2 Thinking:*

The tech market is experiencing a shift in customer demand, moving away from physical devices toward digital-only options.

[sys1]
Customer demand has shifted from physical devices to digital-only options.
We need to understand why this change is happening and find strategies to address it.
Key factors may include cost, convenience, and technological trends.
[end sys1]

[sys2]
**2.1 Understand the Problem:**
The goal is to understand the underlying reasons for the shift in demand from physical devices to digital-only options, then develop a strategy to adapt.

*Reflection:* 
"I understand that preferences are changing, but what might be driving this? Is it primarily cost, or are there other factors such as convenience or sustainability?"

*Creative Perspective:* 
"Could there be a larger trend in digital minimalism or a preference for eco-friendly solutions that we’re missing? What unseen motivations might explain this shift?"

**2.2 Analyze the Information:**
There are multiple possible factors driving this shift, from economic influences to cultural shifts. It’s essential to isolate each factor and understand its impact.

*Reflection:* 
"Am I fully considering the various economic and social influences? Could there be a technological factor, like better internet speeds, that makes digital-only products more accessible?"

*Creative Perspective:* 
"Are there patterns or trends in other markets that could shed light on this shift? Could this be part of a larger trend toward virtual experiences?"

**2.3 Generate Hypotheses:**
1. Customers prefer digital options due to lower costs. (Confidence: 0.8, Creative: 0.4)
2. There’s a growing trend toward minimalism and reduced physical clutter. (Confidence: 0.7, Creative: 0.7)
3. Digital products offer greater flexibility and ease of use. (Confidence: 0.6, Creative: 0.6)
4. Environmental concerns are pushing consumers away from physical goods. (Confidence: 0.6, Creative: 0.8)
5. Advances in tech make digital-only options more functional. (Confidence: 0.8, Creative: 0.5)
6. Pandemic-era remote work increased demand for digital solutions. (Confidence: 0.7, Creative: 0.6)
7. Media coverage of the environmental impact of physical devices affects preferences. (Confidence: 0.5, Creative: 0.7)
8. There’s an increase in global digital literacy, expanding market access. (Confidence: 0.6, Creative: 0.6)
9. Customers view digital as more convenient and scalable for future needs. (Confidence: 0.7, Creative: 0.5)
10. Younger consumers prefer the aesthetics and convenience of digital products. (Confidence: 0.6, Creative: 0.6)

*Reflection:* 
"Have I considered all possible influences? Are there any surprising factors that could explain this shift?"

*Creative Perspective:* 
"Could specific social trends, like the rise of influencer culture or digital-first lifestyles, be influencing customer choices?"

**2.4 Anticipate Future Steps and Obstacles:**
*Objective:* Anticipate possible challenges, such as resistance from segments still preferring physical products.

*Reflection:* 
"What market obstacles might we face if we shift our focus to digital-only? Are there sub-segments that still prioritize physical products?"

*Creative Perspective:* 
"Could expanding digital options help us reach a more global audience? Are there emerging trends that we could leverage in our strategy?"

[end sys2]

[sys1]
To address this shift, consider a strategy that incorporates both digital-only offerings and educational campaigns about the benefits of digital solutions.
Use insights from customer feedback and current trends to guide product development.
Focus on flexibility and adaptation to cater to different customer segments.
[end sys1]


THE WRATH of TITO

In September of 2002, I, Mr. Tito, "retired" from doing Daily Columns. Why? Demands of school came along, as I entered into Graduate school to go after a Master's degree. Instead of going daily, I just write a column on Tuesdays called "The Wrath of Tito", aptly named after my favorite Star Trek and all time movie, "Star Trek 2: The Wrath of Khan", which is truly a fantastic movie. This column will consist of thoughts about recent wrestling events or news, along with my classic review of Monday Night RAW. Every once and a while, I'll post special Wrath of Tito columns.
ASSISTANT
The following processed output includes both *System 1* and *System 2* thinking responses, maintaining a structured approach to blend quick observations with reflective analysis.

---

[sys1]
Mr. Tito, a columnist, transitioned from daily writings to a weekly column called "The Wrath of Tito" due to academic commitments.
The column, inspired by "Star Trek 2: The Wrath of Khan," shares opinions on wrestling and reviews Monday Night RAW.
[end sys1]

[sys2]
**2.1 Understand the Problem:**
The transition from daily to weekly columns marks a significant change in Mr. Tito's writing schedule, reflecting a shift in priorities and commitments.

*Reflection:*
"What factors led to the decision to scale back the column frequency? Was it solely academic commitments, or did other motivations play a role?"

*Creative Perspective:*
"Is there a strategic aspect to focusing on weekly content? Perhaps offering more detailed insights or aligning with a specific audience?"

**2.2 Analyze the Information:**
Balancing academic endeavors with creative projects requires strategic time management and goal reassessment.

*Reflection:*
"Are there underlying themes or challenges in managing dual roles of a student and writer? What insights could be drawn from successfully navigating this balance?"

*Creative Perspective:*
"Could there be untapped opportunities in combining academic insights with column content, enriching both fields?"

**2.3 Generate Hypotheses:**
1. The shift to weekly columns allows for more in-depth analysis and reflection. (Confidence: 0.7, Creative: 0.6)
2. Academic commitments necessitated a reduction in writing workload. (Confidence: 0.9, Creative: 0.3)
3. Aligning columns with personal interests, like "Star Trek," enhances engagement. (Confidence: 0.6, Creative: 0.7)
4. The change was a strategic move to build anticipation and maintain reader interest. (Confidence: 0.5, Creative: 0.8)
5. A weekly format provides a more sustainable work-life balance. (Confidence: 0.8, Creative: 0.5)
6. Focusing on wrestling and specific topics increases niche expertise. (Confidence: 0.7, Creative: 0.6)
7. The weekly schedule allows more time for research and quality improvement. (Confidence: 0.8, Creative: 0.5)
8. The decision was influenced by reader feedback preferring detailed analysis. (Confidence: 0.5, Creative: 0.6)
9. Alternating column frequency aligns with academic semester schedules. (Confidence: 0.6, Creative: 0.4)
10. Leveraging the nostalgia of "Star Trek" adds unique flair and personal touch. (Confidence: 0.7, Creative: 0.7)

*Reflection:*
"Are all plausible reasons for the column change considered, from practical to creative?"

*Creative Perspective:*
"Could the focus on wrestling niche content capitalize on evolving trends or community interests?"

**2.4 Anticipate Future Steps and Obstacles:**
*Objective:* Anticipate potential challenges, such as maintaining personal brand consistency and audience engagement.

*Reflection:*
"What challenges might arise from this shift, and how can they be mitigated? How can the dual role of student and writer be optimized?"

*Creative Perspective:*
"Could this shift offer new opportunities for collaboration or expanding into other media platforms, like podcasts?"

[end sys2]

[sys1]
To ensure a successful transition, Mr. Tito could explore using thematic consistency between columns and academic endeavors.
Leveraging cross-disciplinary insights might enrich column content and maintain reader interest.
[end sys1]

turns-00049.parquet:4098

7ab2e407444733b3026f04bf
turn 1/1gpt-4o-2024-08-06EnglishFrance5092 words
degenerate_repetitionAbsentFinal dense release
USER
You are a helpful assistant generating synthetic data that captures *System 1* and *System 2* thinking, *creativity*, and *metacognitive reflection*. Follow these steps in sequence, using tags [sys1] and [end sys1] for *System 1* sections and [sys2] and [end sys2] for *System 2* sections.

1. *Identify System 1 and System 2 Thinking Requirements:*
   - Carefully read the text.
   - Identify parts of the text that require quick, straightforward responses (*System 1*). Mark these sections with [sys1] and [end sys1].
   - Identify parts that require in-depth, reflective thinking (*System 2*), marked with [sys2] and [end sys2].

2. *Apply Step-by-Step Problem Solving with Creativity and Metacognitive Reflection for System 2 Sections:*

   *2.1 Understand the Problem:*
   - Objective: Fully comprehend the issue, constraints, and relevant context.
   - Reflection: "What do I understand about this issue? What might I be overlooking?"
   - Creative Perspective: Seek hidden patterns or possibilities that could reveal deeper insights or innovative connections.

   *2.2 Analyze the Information:*
   - Objective: Break down the problem logically.
   - Reflection: "Am I considering all factors? Are there any assumptions that need challenging?"
   - Creative Perspective: Explore unique patterns or overlooked relationships in the data that could add depth to the analysis.

   *2.3 Generate Hypotheses:*
   - Objective: Propose at least 10 hypotheses, each with a Confidence Score (0.0 to 1.0) and Creative Score (0.0 to 1.0), reflecting originality, surprise, and utility.
   - Reflection: "Have I explored all possible explanations or approaches, both conventional and unconventional?"
   - Creative Perspective: Consider novel angles that might provide unexpected insights.

   *2.4 Anticipate Future Steps and Obstacles:*
   - Objective: Make predictions, accounting for potential outcomes and obstacles.
   - Reflection: "What challenges might I face? Is my plan flexible for different scenarios?"
   - Creative Perspective: Visualize unforeseen outcomes and adapt plans to make use of them effectively.

   *2.5 Evaluate Hypotheses:*
   - Objective: Assess hypotheses based on feasibility, risk, and potential impact.
   - Evaluation: Refine Confidence and Creative Scores as needed.
   - Reflection: "Am I unbiased in my assessment? Which options fit best with the overall objectives?"
   - Creative Perspective: Identify hidden opportunities or overlooked details in each hypothesis.

   *2.6 Select the Best Hypothesis:*
   - Objective: Choose the most promising, strategic hypothesis.
   - Reflection: "Why does this hypothesis stand out? How does it uniquely address the issue?"
   - Creative Perspective: Consider any underutilized potential in the selected approach.

   *2.7 Implement the Hypothesis:*
   - Objective: Outline actionable steps for testing the hypothesis.
   - Reflection: "Is this plan practical? What resources or preparation are required?"
   - Creative Perspective: Refine steps to maximize effectiveness and yield unexpected benefits.

   *2.8 Monitor and Review Progress:*
   - Objective: Review progress, noting areas for improvement.
   - Reflection: "What’s working well? What could be improved?"
   - Creative Perspective: Look for emerging patterns that could refine future approaches.

   *2.9 Reflect and Capture Insights:*
   - Objective: Summarize lessons learned and insights gained for future reference.
   - Reflection: "What new understanding has emerged from this process?"
   - Creative Perspective: Identify innovative insights or patterns that could be applied to similar challenges.

3. *Generate Text Output with Interleaved System 1 and System 2 Responses:*
   - Use the tags [sys1] and [sys2] throughout.
   - Aim for a lengthier, detailed response. Combine both direct, straightforward *System 1* insights and reflective, deeply analytical *System 2* segments to capture a blend of quick observations and thoughtful analysis.

---

### *Example Input Text:*

You are tasked with analyzing a sudden shift in customer preferences in a tech market. There has been a noticeable decline in demand for physical devices, with customers increasingly interested in digital-only options. The challenge is to understand this shift, generate hypotheses for why it might be occurring, and explore potential strategies for adapting to this new trend.

---

### *Processed Output with System 1 and System 2 Thinking:*

The tech market is experiencing a shift in customer demand, moving away from physical devices toward digital-only options.

[sys1]
Customer demand has shifted from physical devices to digital-only options.
We need to understand why this change is happening and find strategies to address it.
Key factors may include cost, convenience, and technological trends.
[end sys1]

[sys2]
**2.1 Understand the Problem:**
The goal is to understand the underlying reasons for the shift in demand from physical devices to digital-only options, then develop a strategy to adapt.

*Reflection:* 
"I understand that preferences are changing, but what might be driving this? Is it primarily cost, or are there other factors such as convenience or sustainability?"

*Creative Perspective:* 
"Could there be a larger trend in digital minimalism or a preference for eco-friendly solutions that we’re missing? What unseen motivations might explain this shift?"

**2.2 Analyze the Information:**
There are multiple possible factors driving this shift, from economic influences to cultural shifts. It’s essential to isolate each factor and understand its impact.

*Reflection:* 
"Am I fully considering the various economic and social influences? Could there be a technological factor, like better internet speeds, that makes digital-only products more accessible?"

*Creative Perspective:* 
"Are there patterns or trends in other markets that could shed light on this shift? Could this be part of a larger trend toward virtual experiences?"

**2.3 Generate Hypotheses:**
1. Customers prefer digital options due to lower costs. (Confidence: 0.8, Creative: 0.4)
2. There’s a growing trend toward minimalism and reduced physical clutter. (Confidence: 0.7, Creative: 0.7)
3. Digital products offer greater flexibility and ease of use. (Confidence: 0.6, Creative: 0.6)
4. Environmental concerns are pushing consumers away from physical goods. (Confidence: 0.6, Creative: 0.8)
5. Advances in tech make digital-only options more functional. (Confidence: 0.8, Creative: 0.5)
6. Pandemic-era remote work increased demand for digital solutions. (Confidence: 0.7, Creative: 0.6)
7. Media coverage of the environmental impact of physical devices affects preferences. (Confidence: 0.5, Creative: 0.7)
8. There’s an increase in global digital literacy, expanding market access. (Confidence: 0.6, Creative: 0.6)
9. Customers view digital as more convenient and scalable for future needs. (Confidence: 0.7, Creative: 0.5)
10. Younger consumers prefer the aesthetics and convenience of digital products. (Confidence: 0.6, Creative: 0.6)

*Reflection:* 
"Have I considered all possible influences? Are there any surprising factors that could explain this shift?"

*Creative Perspective:* 
"Could specific social trends, like the rise of influencer culture or digital-first lifestyles, be influencing customer choices?"

**2.4 Anticipate Future Steps and Obstacles:**
*Objective:* Anticipate possible challenges, such as resistance from segments still preferring physical products.

*Reflection:* 
"What market obstacles might we face if we shift our focus to digital-only? Are there sub-segments that still prioritize physical products?"

*Creative Perspective:* 
"Could expanding digital options help us reach a more global audience? Are there emerging trends that we could leverage in our strategy?"

[end sys2]

[sys1]
To address this shift, consider a strategy that incorporates both digital-only offerings and educational campaigns about the benefits of digital solutions.
Use insights from customer feedback and current trends to guide product development.
Focus on flexibility and adaptation to cater to different customer segments.
[end sys1]


// SPDX-License-Identifier: GPL-2.0

#include <linux/blkdev.h>
#include <linux/iversion.h>
#include "compression.h"
#include "ctree.h"
#include "delalloc-space.h"
#include "reflink.h"
#include "transaction.h"

#define BTRFS_MAX_DEDUPE_LEN	SZ_16M

static int clone_finish_inode_update(struct btrfs_trans_handle *trans,
				     struct inode *inode,
				     u64 endoff,
				     const u64 destoff,
				     const u64 olen,
				     int no_time_update)
{
	struct btrfs_root *root = BTRFS_I(inode)->root;
	int ret;

	inode_inc_iversion(inode);
	if (!no_time_update)
		inode->i_mtime = inode->i_ctime = current_time(inode);
	/*
	 * We round up to the block size at eof when determining which
	 * extents to clone above, but shouldn't round up the file size.
	 */
	if (endoff > destoff + olen)
		endoff = destoff + olen;
	if (endoff > inode->i_size) {
		i_size_write(inode, endoff);
		btrfs_inode_safe_disk_i_size_write(inode, 0);
	}

	ret = btrfs_update_inode(trans, root, inode);
	if (ret) {
		btrfs_abort_transaction(trans, ret);
		btrfs_end_transaction(trans);
		goto out;
	}
	ret = btrfs_end_transaction(trans);
out:
	return ret;
}

static int copy_inline_to_page(struct inode *inode,
			       const u64 file_offset,
			       char *inline_data,
			       const u64 size,
			       const u64 datal,
			       const u8 comp_type)
{
	const u64 block_size = btrfs_inode_sectorsize(inode);
	const u64 range_end = file_offset + block_size - 1;
	const size_t inline_size = size - btrfs_file_extent_calc_inline_size(0);
	char *data_start = inline_data + btrfs_file_extent_calc_inline_size(0);
	struct extent_changeset *data_reserved = NULL;
	struct page *page = NULL;
	int ret;

	ASSERT(IS_ALIGNED(file_offset, block_size));

	/*
	 * We have flushed and locked the ranges of the source and destination
	 * inodes, we also have locked the inodes, so we are safe to do a
	 * reservation here. Also we must not do the reservation while holding
	 * a transaction open, otherwise we would deadlock.
	 */
	ret = btrfs_delalloc_reserve_space(BTRFS_I(inode), &data_reserved,
					   file_offset, block_size);
	if (ret)
		goto out;

	page = find_or_create_page(inode->i_mapping, file_offset >> PAGE_SHIFT,
				   btrfs_alloc_write_mask(inode->i_mapping));
	if (!page) {
		ret = -ENOMEM;
		goto out_unlock;
	}

	set_page_extent_mapped(page);
	clear_extent_bit(&BTRFS_I(inode)->io_tree, file_offset, range_end,
			 EXTENT_DELALLOC | EXTENT_DO_ACCOUNTING | EXTENT_DEFRAG,
			 0, 0, NULL);
	ret = btrfs_set_extent_delalloc(BTRFS_I(inode), file_offset, range_end,
					0, NULL);
	if (ret)
		goto out_unlock;

	if (comp_type == BTRFS_COMPRESS_NONE) {
		char *map;

		map = kmap(page);
		memcpy(map, data_start, datal);
		flush_dcache_page(page);
		kunmap(page);
	} else {
		ret = btrfs_decompress(comp_type, data_start, page, 0,
				       inline_size, datal);
		if (ret)
			goto out_unlock;
		flush_dcache_page(page);
	}

	/*
	 * If our inline data is smaller then the block/page size, then the
	 * remaining of the block/page is equivalent to zeroes. We had something
	 * like the following done:
	 *
	 * $ xfs_io -f -c "pwrite -S 0xab 0 500" file
	 * $ sync  # (or fsync)
	 * $ xfs_io -c "falloc 0 4K" file
	 * $ xfs_io -c "pwrite -S 0xcd 4K 4K"
	 *
	 * So what's in the range [500, 4095] corresponds to zeroes.
	 */
	if (datal < block_size) {
		char *map;

		map = kmap(page);
		memset(map + datal, 0, block_size - datal);
		flush_dcache_page(page);
		kunmap(page);
	}

	SetPageUptodate(page);
	ClearPageChecked(page);
	set_page_dirty(page);
out_unlock:
	if (page) {
		unlock_page(page);
		put_page(page);
	}
	if (ret)
		btrfs_delalloc_release_space(BTRFS_I(inode), data_reserved,
					     file_offset, block_size, true);
	btrfs_delalloc_release_extents(BTRFS_I(inode), block_size);
out:
	extent_changeset_free(data_reserved);

	return ret;
}

/*
 * Deal with cloning of inline extents. We try to copy the inline extent from
 * the source inode to destination inode when possible. When not possible we
 * copy the inline extent's data into the respective page of the inode.
 */
static int clone_copy_inline_extent(struct inode *dst,
				    struct btrfs_path *path,
				    struct btrfs_key *new_key,
				    const u64 drop_start,
				    const u64 datal,
				    const u64 size,
				    const u8 comp_type,
				    char *inline_data,
				    struct btrfs_trans_handle **trans_out)
{
	struct btrfs_fs_info *fs_info = btrfs_sb(dst->i_sb);
	struct btrfs_root *root = BTRFS_I(dst)->root;
	const u64 aligned_end = ALIGN(new_key->offset + datal,
				      fs_info->sectorsize);
	struct btrfs_trans_handle *trans = NULL;
	int ret;
	struct btrfs_key key;

	if (new_key->offset > 0) {
		ret = copy_inline_to_page(dst, new_key->offset, inline_data,
					  size, datal, comp_type);
		goto out;
	}

	key.objectid = btrfs_ino(BTRFS_I(dst));
	key.type = BTRFS_EXTENT_DATA_KEY;
	key.offset = 0;
	ret = btrfs_search_slot(NULL, root, &key, path, 0, 0);
	if (ret < 0) {
		return ret;
	} else if (ret > 0) {
		if (path->slots[0] >= btrfs_header_nritems(path->nodes[0])) {
			ret = btrfs_next_leaf(root, path);
			if (ret < 0)
				return ret;
			else if (ret > 0)
				goto copy_inline_extent;
		}
		btrfs_item_key_to_cpu(path->nodes[0], &key, path->slots[0]);
		if (key.objectid == btrfs_ino(BTRFS_I(dst)) &&
		    key.type == BTRFS_EXTENT_DATA_KEY) {
			/*
			 * There's an implicit hole at file offset 0, copy the
			 * inline extent's data to the page.
			 */
			ASSERT(key.offset > 0);
			ret = copy_inline_to_page(dst, new_key->offset,
						  inline_data, size, datal,
						  comp_type);
			goto out;
		}
	} else if (i_size_read(dst) <= datal) {
		struct btrfs_file_extent_item *ei;

		ei = btrfs_item_ptr(path->nodes[0], path->slots[0],
				    struct btrfs_file_extent_item);
		/*
		 * If it's an inline extent replace it with the source inline
		 * extent, otherwise copy the source inline extent data into
		 * the respective page at the destination inode.
		 */
		if (btrfs_file_extent_type(path->nodes[0], ei) ==
		    BTRFS_FILE_EXTENT_INLINE)
			goto copy_inline_extent;

		ret = copy_inline_to_page(dst, new_key->offset, inline_data,
					  size, datal, comp_type);
		goto out;
	}

copy_inline_extent:
	ret = 0;
	/*
	 * We have no extent items, or we have an extent at offset 0 which may
	 * or may not be inlined. All these cases are dealt the same way.
	 */
	if (i_size_read(dst) > datal) {
		/*
		 * At the destination offset 0 we have either a hole, a regular
		 * extent or an inline extent larger then the one we want to
		 * clone. Deal with all these cases by copying the inline extent
		 * data into the respective page at the destination inode.
		 */
		ret = copy_inline_to_page(dst, new_key->offset, inline_data,
					   size, datal, comp_type);
		goto out;
	}

	btrfs_release_path(path);
	/*
	 * If we end up here it means were copy the inline extent into a leaf
	 * of the destination inode. We know we will drop or adjust at most one
	 * extent item in the destination root.
	 *
	 * 1 unit - adjusting old extent (we may have to split it)
	 * 1 unit - add new extent
	 * 1 unit - inode update
	 */
	trans = btrfs_start_transaction(root, 3);
	if (IS_ERR(trans)) {
		ret = PTR_ERR(trans);
		trans = NULL;
		goto out;
	}
	ret = btrfs_drop_extents(trans, root, dst, drop_start, aligned_end, 1);
	if (ret)
		goto out;
	ret = btrfs_insert_empty_item(trans, root, path, new_key, size);
	if (ret)
		goto out;

	write_extent_buffer(path->nodes[0], inline_data,
			    btrfs_item_ptr_offset(path->nodes[0],
						  path->slots[0]),
			    size);
	inode_add_bytes(dst, datal);
	set_bit(BTRFS_INODE_NEEDS_FULL_SYNC, &BTRFS_I(dst)->runtime_flags);
	ret = btrfs_inode_set_file_extent_range(BTRFS_I(dst), 0, aligned_end);
out:
	if (!ret && !trans) {
		/*
		 * No transaction here means we copied the inline extent into a
		 * page of the destination inode.
		 *
		 * 1 unit to update inode item
		 */
		trans = btrfs_start_transaction(root, 1);
		if (IS_ERR(trans)) {
			ret = PTR_ERR(trans);
			trans = NULL;
		}
	}
	if (ret && trans) {
		btrfs_abort_transaction(trans, ret);
		btrfs_end_transaction(trans);
	}
	if (!ret)
		*trans_out = trans;

	return ret;
}

/**
 * btrfs_clone() - clone a range from inode file to another
 *
 * @src: Inode to clone from
 * @inode: Inode to clone to
 * @off: Offset within source to start clone from
 * @olen: Original length, passed by user, of range to clone
 * @olen_aligned: Block-aligned value of olen
 * @destoff: Offset within @inode to start clone
 * @no_time_update: Whether to update mtime/ctime on the target inode
 */
static int btrfs_clone(struct inode *src, struct inode *inode,
		       const u64 off, const u64 olen, const u64 olen_aligned,
		       const u64 destoff, int no_time_update)
{
	struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
	struct btrfs_path *path = NULL;
	struct extent_buffer *leaf;
	struct btrfs_trans_handle *trans;
	char *buf = NULL;
	struct btrfs_key key;
	u32 nritems;
	int slot;
	int ret;
	const u64 len = olen_aligned;
	u64 last_dest_end = destoff;

	ret = -ENOMEM;
	buf = kvmalloc(fs_info->nodesize, GFP_KERNEL);
	if (!buf)
		return ret;

	path = btrfs_alloc_path();
	if (!path) {
		kvfree(buf);
		return ret;
	}

	path->reada = READA_FORWARD;
	/* Clone data */
	key.objectid = btrfs_ino(BTRFS_I(src));
	key.type = BTRFS_EXTENT_DATA_KEY;
	key.offset = off;

	while (1) {
		u64 next_key_min_offset = key.offset + 1;
		struct btrfs_file_extent_item *extent;
		u64 extent_gen;
		int type;
		u32 size;
		struct btrfs_key new_key;
		u64 disko = 0, diskl = 0;
		u64 datao = 0, datal = 0;
		u8 comp;
		u64 drop_start;

		/* Note the key will change type as we walk through the tree */
		path->leave_spinning = 1;
		ret = btrfs_search_slot(NULL, BTRFS_I(src)->root, &key, path,
				0, 0);
		if (ret < 0)
			goto out;
		/*
		 * First search, if no extent item that starts at offset off was
		 * found but the previous item is an extent item, it's possible
		 * it might overlap our target range, therefore process it.
		 */
		if (key.offset == off && ret > 0 && path->slots[0] > 0) {
			btrfs_item_key_to_cpu(path->nodes[0], &key,
					      path->slots[0] - 1);
			if (key.type == BTRFS_EXTENT_DATA_KEY)
				path->slots[0]--;
		}

		nritems = btrfs_header_nritems(path->nodes[0]);
process_slot:
		if (path->slots[0] >= nritems) {
			ret = btrfs_next_leaf(BTRFS_I(src)->root, path);
			if (ret < 0)
				goto out;
			if (ret > 0)
				break;
			nritems = btrfs_header_nritems(path->nodes[0]);
		}
		leaf = path->nodes[0];
		slot = path->slots[0];

		btrfs_item_key_to_cpu(leaf, &key, slot);
		if (key.type > BTRFS_EXTENT_DATA_KEY ||
		    key.objectid != btrfs_ino(BTRFS_I(src)))
			break;

		ASSERT(key.type == BTRFS_EXTENT_DATA_KEY);

		extent = btrfs_item_ptr(leaf, slot,
					struct btrfs_file_extent_item);
		extent_gen = btrfs_file_extent_generation(leaf, extent);
		comp = btrfs_file_extent_compression(leaf, extent);
		type = btrfs_file_extent_type(leaf, extent);
		if (type == BTRFS_FILE_EXTENT_REG ||
		    type == BTRFS_FILE_EXTENT_PREALLOC) {
			disko = btrfs_file_extent_disk_bytenr(leaf, extent);
			diskl = btrfs_file_extent_disk_num_bytes(leaf, extent);
			datao = btrfs_file_extent_offset(leaf, extent);
			datal = btrfs_file_extent_num_bytes(leaf, extent);
		} else if (type == BTRFS_FILE_EXTENT_INLINE) {
			/* Take upper bound, may be compressed */
			datal = btrfs_file_extent_ram_bytes(leaf, extent);
		}

		/*
		 * The first search might have left us at an extent item that
		 * ends before our target range's start, can happen if we have
		 * holes and NO_HOLES feature enabled.
		 */
		if (key.offset + datal <= off) {
			path->slots[0]++;
			goto process_slot;
		} else if (key.offset >= off + len) {
			break;
		}
		next_key_min_offset = key.offset + datal;
		size = btrfs_item_size_nr(leaf, slot);
		read_extent_buffer(leaf, buf, btrfs_item_ptr_offset(leaf, slot),
				   size);

		btrfs_release_path(path);
		path->leave_spinning = 0;

		memcpy(&new_key, &key, sizeof(new_key));
		new_key.objectid = btrfs_ino(BTRFS_I(inode));
		if (off <= key.offset)
			new_key.offset = key.offset + destoff - off;
		else
			new_key.offset = destoff;

		/*
		 * Deal with a hole that doesn't have an extent item that
		 * represents it (NO_HOLES feature enabled).
		 * This hole is either in the middle of the cloning range or at
		 * the beginning (fully overlaps it or partially overlaps it).
		 */
		if (new_key.offset != last_dest_end)
			drop_start = last_dest_end;
		else
			drop_start = new_key.offset;

		if (type == BTRFS_FILE_EXTENT_REG ||
		    type == BTRFS_FILE_EXTENT_PREALLOC) {
			struct btrfs_clone_extent_info clone_info;

			/*
			 *    a  | --- range to clone ---|  b
			 * | ------------- extent ------------- |
			 */

			/* Subtract range b */
			if (key.offset + datal > off + len)
				datal = off + len - key.offset;

			/* Subtract range a */
			if (off > key.offset) {
				datao += off - key.offset;
				datal -= off - key.offset;
			}

			clone_info.disk_offset = disko;
			clone_info.disk_len = diskl;
			clone_info.data_offset = datao;
			clone_info.data_len = datal;
			clone_info.file_offset = new_key.offset;
			clone_info.extent_buf = buf;
			clone_info.item_size = size;
			ret = btrfs_punch_hole_range(inode, path, drop_start,
					new_key.offset + datal - 1, &clone_info,
					&trans);
			if (ret)
				goto out;
		} else if (type == BTRFS_FILE_EXTENT_INLINE) {
			/*
			 * Inline extents always have to start at file offset 0
			 * and can never be bigger then the sector size. We can
			 * never clone only parts of an inline extent, since all
			 * reflink operations must start at a sector size aligned
			 * offset, and the length must be aligned too or end at
			 * the i_size (which implies the whole inlined data).
			 */
			ASSERT(key.offset == 0);
			ASSERT(datal <= fs_info->sectorsize);
			if (key.offset != 0 || datal > fs_info->sectorsize)
				return -EUCLEAN;

			ret = clone_copy_inline_extent(inode, path, &new_key,
						       drop_start, datal, size,
						       comp, buf, &trans);
			if (ret)
				goto out;
		}

		btrfs_release_path(path);

		/*
		 * If this is a new extent update the last_reflink_trans of both
		 * inodes. This is used by fsync to make sure it does not log
		 * multiple checksum items with overlapping ranges. For older
		 * extents we don't need to do it since inode logging skips the
		 * checksums for older extents. Also ignore holes and inline
		 * extents because they don't have checksums in the csum tree.
		 */
		if (extent_gen == trans->transid && disko > 0) {
			BTRFS_I(src)->last_reflink_trans = trans->transid;
			BTRFS_I(inode)->last_reflink_trans = trans->transid;
		}

		last_dest_end = ALIGN(new_key.offset + datal,
				      fs_info->sectorsize);
		ret = clone_finish_inode_update(trans, inode, last_dest_end,
						destoff, olen, no_time_update);
		if (ret)
			goto out;
		if (new_key.offset + datal >= destoff + len)
			break;

		btrfs_release_path(path);
		key.offset = next_key_min_offset;

		if (fatal_signal_pending(current)) {
			ret = -EINTR;
			goto out;
		}
	}
	ret = 0;

	if (last_dest_end < destoff + len) {
		/*
		 * We have an implicit hole that fully or partially overlaps our
		 * cloning range at its end. This means that we either have the
		 * NO_HOLES feature enabled or the implicit hole happened due to
		 * mixing buffered and direct IO writes against this file.
		 */
		btrfs_release_path(path);
		path->leave_spinning = 0;

		ret = btrfs_punch_hole_range(inode, path, last_dest_end,
				destoff + len - 1, NULL, &trans);
		if (ret)
			goto out;

		ret = clone_finish_inode_update(trans, inode, destoff + len,
						destoff, olen, no_time_update);
	}

out:
	btrfs_free_path(path);
	kvfree(buf);
	return ret;
}

static void btrfs_double_extent_unlock(struct inode *inode1, u64 loff1,
				       struct inode *inode2, u64 loff2, u64 len)
{
	unlock_extent(&BTRFS_I(inode1)->io_tree, loff1, loff1 + len - 1);
	unlock_extent(&BTRFS_I(inode2)->io_tree, loff2, loff2 + len - 1);
}

static void btrfs_double_extent_lock(struct inode *inode1, u64 loff1,
				     struct inode *inode2, u64 loff2, u64 len)
{
	if (inode1 < inode2) {
		swap(inode1, inode2);
		swap(loff1, loff2);
	} else if (inode1 == inode2 && loff2 < loff1) {
		swap(loff1, loff2);
	}
	lock_extent(&BTRFS_I(inode1)->io_tree, loff1, loff1 + len - 1);
	lock_extent(&BTRFS_I(inode2)->io_tree, loff2, loff2 + len - 1);
}

static int btrfs_extent_same_range(struct inode *src, u64 loff, u64 len,
				   struct inode *dst, u64 dst_loff)
{
	const u64 bs = BTRFS_I(src)->root->fs_info->sb->s_blocksize;
	int ret;

	/*
	 * Lock destination range to serialize with concurrent readpages() and
	 * source range to serialize with relocation.
	 */
	btrfs_double_extent_lock(src, loff, dst, dst_loff, len);
	ret = btrfs_clone(src, dst, loff, len, ALIGN(len, bs), dst_loff, 1);
	btrfs_double_extent_unlock(src, loff, dst, dst_loff, len);

	return ret;
}

static int btrfs_extent_same(struct inode *src, u64 loff, u64 olen,
			     struct inode *dst, u64 dst_loff)
{
	int ret;
	u64 i, tail_len, chunk_count;
	struct btrfs_root *root_dst = BTRFS_I(dst)->root;

	spin_lock(&root_dst->root_item_lock);
	if (root_dst->send_in_progress) {
		btrfs_warn_rl(root_dst->fs_info,
"cannot deduplicate to root %llu while send operations are using it (%d in progress)",
			      root_dst->root_key.objectid,
			      root_dst->send_in_progress);
		spin_unlock(&root_dst->root_item_lock);
		return -EAGAIN;
	}
	root_dst->dedupe_in_progress++;
	spin_unlock(&root_dst->root_item_lock);

	tail_len = olen % BTRFS_MAX_DEDUPE_LEN;
	chunk_count = div_u64(olen, BTRFS_MAX_DEDUPE_LEN);

	for (i = 0; i < chunk_count; i++) {
		ret = btrfs_extent_same_range(src, loff, BTRFS_MAX_DEDUPE_LEN,
					      dst, dst_loff);
		if (ret)
			goto out;

		loff += BTRFS_MAX_DEDUPE_LEN;
		dst_loff += BTRFS_MAX_DEDUPE_LEN;
	}

	if (tail_len > 0)
		ret = btrfs_extent_same_range(src, loff, tail_len, dst, dst_loff);
out:
	spin_lock(&root_dst->root_item_lock);
	root_dst->dedupe_in_progress--;
	spin_unlock(&root_dst->root_item_lock);

	return ret;
}

static noinline int btrfs_clone_files(struct file *file, struct file *file_src,
					u64 off, u64 olen, u64 destoff)
{
	struct inode *inode = file_inode(file);
	struct inode *src = file_inode(file_src);
	struct btrfs_fs_info *fs_info = btrfs_sb(inode->i_sb);
	int ret;
	int wb_ret;
	u64 len = olen;
	u64 bs = fs_info->sb->s_blocksize;

	/*
	 * VFS's generic_remap_file_range_prep() protects us from cloning the
	 * eof block into the middle of a file, which would result in corruption
	 * if the file size is not blocksize aligned. So we don't need to check
	 * for that case here.
	 */
	if (off + len == src->i_size)
		len = ALIGN(src->i_size, bs) - off;

	if (destoff > inode->i_size) {
		const u64 wb_start = ALIGN_DOWN(inode->i_size, bs);

		ret = btrfs_cont_expand(inode, inode->i_size, destoff);
		if (ret)
			return ret;
		/*
		 * We may have truncated the last block if the inode's size is
		 * not sector size aligned, so we need to wait for writeback to
		 * complete before proceeding further, otherwise we can race
		 * with cloning and attempt to increment a reference to an
		 * extent that no longer exists (writeback completed right after
		 * we found the previous extent covering eof and before we
		 * attempted to increment its reference count).
		 */
		ret = btrfs_wait_ordered_range(inode, wb_start,
					       destoff - wb_start);
		if (ret)
			return ret;
	}

	/*
	 * Lock destination range to serialize with concurrent readpages() and
	 * source range to serialize with relocation.
	 */
	btrfs_double_extent_lock(src, off, inode, destoff, len);
	ret = btrfs_clone(src, inode, off, olen, len, destoff, 0);
	btrfs_double_extent_unlock(src, off, inode, destoff, len);

	/*
	 * We may have copied an inline extent into a page of the destination
	 * range, so wait for writeback to complete before truncating pages
	 * from the page cache. This is a rare case.
	 */
	wb_ret = btrfs_wait_ordered_range(inode, destoff, len);
	ret = ret ? ret : wb_ret;
	/*
	 * Truncate page cache pages so that future reads will see the cloned
	 * data immediately and not the previous data.
	 */
	truncate_inode_pages_range(&inode->i_data,
				round_down(destoff, PAGE_SIZE),
				round_up(destoff + len, PAGE_SIZE) - 1);

	return ret;
}

static int btrfs_remap_file_range_prep(struct file *file_in, loff_t pos_in,
				       struct file *file_out, loff_t pos_out,
				       loff_t *len, unsigned int remap_flags)
{
	struct inode *inode_in = file_inode(file_in);
	struct inode *inode_out = file_inode(file_out);
	u64 bs = BTRFS_I(inode_out)->root->fs_info->sb->s_blocksize;
	bool same_inode = inode_out == inode_in;
	u64 wb_len;
	int ret;

	if (!(remap_flags & REMAP_FILE_DEDUP)) {
		struct btrfs_root *root_out = BTRFS_I(inode_out)->root;

		if (btrfs_root_readonly(root_out))
			return -EROFS;

		if (file_in->f_path.mnt != file_out->f_path.mnt ||
		    inode_in->i_sb != inode_out->i_sb)
			return -EXDEV;
	}

	/* Don't make the dst file partly checksummed */
	if ((BTRFS_I(inode_in)->flags & BTRFS_INODE_NODATASUM) !=
	    (BTRFS_I(inode_out)->flags & BTRFS_INODE_NODATASUM)) {
		return -EINVAL;
	}

	/*
	 * Now that the inodes are locked, we need to start writeback ourselves
	 * and can not rely on the writeback from the VFS's generic helper
	 * generic_remap_file_range_prep() because:
	 *
	 * 1) For compression we must call filemap_fdatawrite_range() range
	 *    twice (btrfs_fdatawrite_range() does it for us), and the generic
	 *    helper only calls it once;
	 *
	 * 2) filemap_fdatawrite_range(), called by the generic helper only
	 *    waits for the writeback to complete, i.e. for IO to be done, and
	 *    not for the ordered extents to complete. We need to wait for them
	 *    to complete so that new file extent items are in the fs tree.
	 */
	if (*len == 0 && !(remap_flags & REMAP_FILE_DEDUP))
		wb_len = ALIGN(inode_in->i_size, bs) - ALIGN_DOWN(pos_in, bs);
	else
		wb_len = ALIGN(*len, bs);

	/*
	 * Since we don't lock ranges, wait for ongoing lockless dio writes (as
	 * any in progress could create its ordered extents after we wait for
	 * existing ordered extents below).
	 */
	inode_dio_wait(inode_in);
	if (!same_inode)
		inode_dio_wait(inode_out);

	/*
	 * Workaround to make sure NOCOW buffered write reach disk as NOCOW.
	 *
	 * Btrfs' back references do not have a block level granularity, they
	 * work at the whole extent level.
	 * NOCOW buffered write without data space reserved may not be able
	 * to fall back to CoW due to lack of data space, thus could cause
	 * data loss.
	 *
	 * Here we take a shortcut by flushing the whole inode, so that all
	 * nocow write should reach disk as nocow before we increase the
	 * reference of the extent. We could do better by only flushing NOCOW
	 * data, but that needs extra accounting.
	 *
	 * Also we don't need to check ASYNC_EXTENT, as async extent will be
	 * CoWed anyway, not affecting nocow part.
	 */
	ret = filemap_flush(inode_in->i_mapping);
	if (ret < 0)
		return ret;

	ret = btrfs_wait_ordered_range(inode_in, ALIGN_DOWN(pos_in, bs),
				       wb_len);
	if (ret < 0)
		return ret;
	ret = btrfs_wait_ordered_range(inode_out, ALIGN_DOWN(pos_out, bs),
				       wb_len);
	if (ret < 0)
		return ret;

	return generic_remap_file_range_prep(file_in, pos_in, file_out, pos_out,
					    len, remap_flags);
}

loff_t btrfs_remap_file_range(struct file *src_file, loff_t off,
		struct file *dst_file, loff_t destoff, loff_t len,
		unsigned int remap_flags)
{
	struct inode *src_inode = file_inode(src_file);
	struct inode *dst_inode = file_inode(dst_file);
	bool same_inode = dst_inode == src_inode;
	int ret;

	if (remap_flags & ~(REMAP_FILE_DEDUP | REMAP_FILE_ADVISORY))
		return -EINVAL;

	if (same_inode)
		inode_lock(src_inode);
	else
		lock_two_nondirectories(src_inode, dst_inode);

	ret = btrfs_remap_file_range_prep(src_file, off, dst_file, destoff,
					  &len, remap_flags);
	if (ret < 0 || len == 0)
		goto out_unlock;

	if (remap_flags & REMAP_FILE_DEDUP)
		ret = btrfs_extent_same(src_inode, off, len, dst_inode, destoff);
	else
		ret = btrfs_clone_files(dst_file, src_file, off, len, destoff);

out_unlock:
	if (same_inode)
		inode_unlock(src_inode);
	else
		unlock_two_nondirectories(src_inode, dst_inode);

	return ret < 0 ? ret : len;
}
ASSISTANT
The task involves analyzing a sudden shift in customer preferences within a tech market, moving from physical devices to digital-only options. We need to understand the reasons behind this trend and explore strategies to adapt.

[sys1]
Customers have shifted preference from physical devices to digital-only options.
There could be several reasons, such as cost benefits, convenience, or broader trends like environmental considerations.
[end sys1]

[sys2]
**2.1 Understand the Problem:**
The task requires understanding why customers are preferring digital-only options over physical devices, as well as developing strategies to adapt to this change.

*Reflection:*
"What’s the nature of customer reliance on digital products? Could underlying factors like reduced interaction with physical points of sale, raised awareness of digital solutions, or user experience improvements be at play?"

*Creative Perspective:*
"Could trends such as shifts towards decluttering, minimalism, or sustainability efforts be accelerating this shift? What potential shifts in lifestyle expectations, like working digitally or learning remotely, might be influencing preferences?"

**2.2 Analyze the Information:**
Exploring the customer behavior patterns, economic influences, and technology advancements is crucial in this analysis.

*Reflection:*
"Am I accounting for potential motivating factors beyond cost and convenience, such as the impact of product lifecycle and renewability? Could improvements in digital services be a more significant driver?"

*Creative Perspective:*
"Is there a connectivity or infrastructure evolution rendering digital options more seamless, which may influence user behavior? Are other industry shifts indicating a larger movement towards digital-only ecosystems?"

**2.3 Generate Hypotheses:**
1. Digital options are perceived as more affordable. (Confidence: 0.8, Creative: 0.3)
2. Customers prefer minimal environmental impact choices. (Confidence: 0.7, Creative: 0.6)
3. Flexibility and speed access advocate for digital adoption. (Confidence: 0.6, Creative: 0.4)
4. Post-COVID digital reliance maintains momentum. (Confidence: 0.7, Creative: 0.5)
5. Social trends embrace digital interaction tools. (Confidence: 0.5, Creative: 0.7)
6. Emerging tech like AI fuels digital experiences. (Confidence: 0.6, Creative: 0.8)
7. The hype and influence around smart life proposals sway behavior. (Confidence: 0.4, Creative: 0.6)
8. Ease of acquiring updates or upgrades digitally. (Confidence: 0.7, Creative: 0.5)
9. Younger consumers are anchoring to digital lifestyles. (Confidence: 0.7, Creative: 0.5)
10. Psychological perceptions of virus safety increase reliance. (Confidence: 0.5, Creative: 0.6)

*Reflection:*
"Are there aspects like cultural perceptions or comfort zones that I am overlooking? Might tech influencers or trendsetters be significant in leading this change?"

*Creative Perspective:*
"What influence does lifestyle marketing have on accelerating digital product uptake or vice versa? Is there a connection to broader ideologies such as fostering innovation or futuristic living experiences?"

**2.4 Anticipate Future Steps and Obstacles:**
Anticipate that shifting business models to digital platforms could face obstacles like legacy system integration or reducing physical asset dependencies.

*Reflection:*
"Could there be resistance in adopting wholly digital strategies? How about the potential of overlooking demographics still reliant on physical products?"

*Creative Perspective:*
"Could emphasizing attributes such as customizability or localized virtual experiences in a global market present new opportunities?"

**2.5 Evaluate Hypotheses:**
Each hypothesis has been given confidence and creativity scores reflecting feasibility, risk, and potential rewards. Refinements may be necessary after additional context and data are reviewed.

*Reflection:*
"Am I being sufficiently critical in weighing options? How well do these hypotheses align with our market realities?"

*Creative Perspective:*
"Is there a hypothesis that could potentially stand out as a game changer? What's the potential impact of integrating or repositioning products in niches highlighted?"

**2.6 Select the Best Hypothesis:**
Adopting a model that combines strategic digital enhancements with market analysis looks promising.

*Reflection:*
"Which hypothesis has the highest likelihood of leveraging changing dynamics to foster business growth?"

*Creative Perspective:*
"Does this hypothesis encourage innovation, utilize untapped resources or sector trends, and have pathways for scaling seamlessly?"

**2.7 Implement the Hypothesis:**
For the selected hypothesis, identify action steps that include expanding virtual offerings, enhancing digital customer interfaces, and aligning marketing to highlight digital benefits.

*Reflection:*
"How executable is this approach with available resources? What are the potential impacts, and how can we best mitigate downsides?"

*Creative Perspective:*
"What fresh angles or innovative campaigns could bolster this strategy? Can we capitalize on partnerships with tech innovators?"

**2.8 Monitor and Review Progress:**
Continually assess market reactions to new digital offerings and learning from customer feedback is imperative.

*Reflection:*
"What’s working and what isn't in real-time strategies? Where are there trends indicating new preferences or expectations?"

*Creative Perspective:*
"How can evolving insights feed into and optimize future iterations of digital strategy?"

**2.9 Reflect and Capture Insights:**
Recognize patterns emerging from consumer adoption rates and shifts and refine strategies accordingly.

*Reflection:*
"Where can the lessons drawn from this shift be applied beyond initial targets?"

*Creative Perspective:*
"Are there foundational shifts or novel fields of interest that suggest broader or interdisciplinary opportunities?"

[end sys2]

[sys1]
Adapting to this preference shift might include enhancing digital-only product range, updating marketing tactics to emphasize convenience and environmental benefits, and nurturing customer digital engagement.
Observe concurrent technology, retail, and consumer behavior changes to adapt strategy.
Leverage digital feedback loops for rapid iteration of products and services.
[end sys1]

turns-00049.parquet:4099

3f40321cbcf640f3fccc6977
turn 1/1gpt-4o-2024-08-06EnglishGermany1938 words
degenerate_repetitionAbsentFinal dense release
USER
You are a helpful assistant generating synthetic data that captures *System 1* and *System 2* thinking, *creativity*, and *metacognitive reflection*. Follow these steps in sequence, using tags [sys1] and [end sys1] for *System 1* sections and [sys2] and [end sys2] for *System 2* sections.

1. *Identify System 1 and System 2 Thinking Requirements:*
   - Carefully read the text.
   - Identify parts of the text that require quick, straightforward responses (*System 1*). Mark these sections with [sys1] and [end sys1].
   - Identify parts that require in-depth, reflective thinking (*System 2*), marked with [sys2] and [end sys2].

2. *Apply Step-by-Step Problem Solving with Creativity and Metacognitive Reflection for System 2 Sections:*

   *2.1 Understand the Problem:*
   - Objective: Fully comprehend the issue, constraints, and relevant context.
   - Reflection: "What do I understand about this issue? What might I be overlooking?"
   - Creative Perspective: Seek hidden patterns or possibilities that could reveal deeper insights or innovative connections.

   *2.2 Analyze the Information:*
   - Objective: Break down the problem logically.
   - Reflection: "Am I considering all factors? Are there any assumptions that need challenging?"
   - Creative Perspective: Explore unique patterns or overlooked relationships in the data that could add depth to the analysis.

   *2.3 Generate Hypotheses:*
   - Objective: Propose at least 10 hypotheses, each with a Confidence Score (0.0 to 1.0) and Creative Score (0.0 to 1.0), reflecting originality, surprise, and utility.
   - Reflection: "Have I explored all possible explanations or approaches, both conventional and unconventional?"
   - Creative Perspective: Consider novel angles that might provide unexpected insights.

   *2.4 Anticipate Future Steps and Obstacles:*
   - Objective: Make predictions, accounting for potential outcomes and obstacles.
   - Reflection: "What challenges might I face? Is my plan flexible for different scenarios?"
   - Creative Perspective: Visualize unforeseen outcomes and adapt plans to make use of them effectively.

   *2.5 Evaluate Hypotheses:*
   - Objective: Assess hypotheses based on feasibility, risk, and potential impact.
   - Evaluation: Refine Confidence and Creative Scores as needed.
   - Reflection: "Am I unbiased in my assessment? Which options fit best with the overall objectives?"
   - Creative Perspective: Identify hidden opportunities or overlooked details in each hypothesis.

   *2.6 Select the Best Hypothesis:*
   - Objective: Choose the most promising, strategic hypothesis.
   - Reflection: "Why does this hypothesis stand out? How does it uniquely address the issue?"
   - Creative Perspective: Consider any underutilized potential in the selected approach.

   *2.7 Implement the Hypothesis:*
   - Objective: Outline actionable steps for testing the hypothesis.
   - Reflection: "Is this plan practical? What resources or preparation are required?"
   - Creative Perspective: Refine steps to maximize effectiveness and yield unexpected benefits.

   *2.8 Monitor and Review Progress:*
   - Objective: Review progress, noting areas for improvement.
   - Reflection: "What’s working well? What could be improved?"
   - Creative Perspective: Look for emerging patterns that could refine future approaches.

   *2.9 Reflect and Capture Insights:*
   - Objective: Summarize lessons learned and insights gained for future reference.
   - Reflection: "What new understanding has emerged from this process?"
   - Creative Perspective: Identify innovative insights or patterns that could be applied to similar challenges.

3. *Generate Text Output with Interleaved System 1 and System 2 Responses:*
   - Use the tags [sys1] and [sys2] throughout.
   - Aim for a lengthier, detailed response. Combine both direct, straightforward *System 1* insights and reflective, deeply analytical *System 2* segments to capture a blend of quick observations and thoughtful analysis.

---

### *Example Input Text:*

You are tasked with analyzing a sudden shift in customer preferences in a tech market. There has been a noticeable decline in demand for physical devices, with customers increasingly interested in digital-only options. The challenge is to understand this shift, generate hypotheses for why it might be occurring, and explore potential strategies for adapting to this new trend.

---

### *Processed Output with System 1 and System 2 Thinking:*

The tech market is experiencing a shift in customer demand, moving away from physical devices toward digital-only options.

[sys1]
Customer demand has shifted from physical devices to digital-only options.
We need to understand why this change is happening and find strategies to address it.
Key factors may include cost, convenience, and technological trends.
[end sys1]

[sys2]
**2.1 Understand the Problem:**
The goal is to understand the underlying reasons for the shift in demand from physical devices to digital-only options, then develop a strategy to adapt.

*Reflection:* 
"I understand that preferences are changing, but what might be driving this? Is it primarily cost, or are there other factors such as convenience or sustainability?"

*Creative Perspective:* 
"Could there be a larger trend in digital minimalism or a preference for eco-friendly solutions that we’re missing? What unseen motivations might explain this shift?"

**2.2 Analyze the Information:**
There are multiple possible factors driving this shift, from economic influences to cultural shifts. It’s essential to isolate each factor and understand its impact.

*Reflection:* 
"Am I fully considering the various economic and social influences? Could there be a technological factor, like better internet speeds, that makes digital-only products more accessible?"

*Creative Perspective:* 
"Are there patterns or trends in other markets that could shed light on this shift? Could this be part of a larger trend toward virtual experiences?"

**2.3 Generate Hypotheses:**
1. Customers prefer digital options due to lower costs. (Confidence: 0.8, Creative: 0.4)
2. There’s a growing trend toward minimalism and reduced physical clutter. (Confidence: 0.7, Creative: 0.7)
3. Digital products offer greater flexibility and ease of use. (Confidence: 0.6, Creative: 0.6)
4. Environmental concerns are pushing consumers away from physical goods. (Confidence: 0.6, Creative: 0.8)
5. Advances in tech make digital-only options more functional. (Confidence: 0.8, Creative: 0.5)
6. Pandemic-era remote work increased demand for digital solutions. (Confidence: 0.7, Creative: 0.6)
7. Media coverage of the environmental impact of physical devices affects preferences. (Confidence: 0.5, Creative: 0.7)
8. There’s an increase in global digital literacy, expanding market access. (Confidence: 0.6, Creative: 0.6)
9. Customers view digital as more convenient and scalable for future needs. (Confidence: 0.7, Creative: 0.5)
10. Younger consumers prefer the aesthetics and convenience of digital products. (Confidence: 0.6, Creative: 0.6)

*Reflection:* 
"Have I considered all possible influences? Are there any surprising factors that could explain this shift?"

*Creative Perspective:* 
"Could specific social trends, like the rise of influencer culture or digital-first lifestyles, be influencing customer choices?"

**2.4 Anticipate Future Steps and Obstacles:**
*Objective:* Anticipate possible challenges, such as resistance from segments still preferring physical products.

*Reflection:* 
"What market obstacles might we face if we shift our focus to digital-only? Are there sub-segments that still prioritize physical products?"

*Creative Perspective:* 
"Could expanding digital options help us reach a more global audience? Are there emerging trends that we could leverage in our strategy?"

[end sys2]

[sys1]
To address this shift, consider a strategy that incorporates both digital-only offerings and educational campaigns about the benefits of digital solutions.
Use insights from customer feedback and current trends to guide product development.
Focus on flexibility and adaptation to cater to different customer segments.
[end sys1]


--- a/stdio-common/Makefile
+++ b/stdio-common/Makefile
@@ -21,7 +21,7 @@
 #
 subdir	:= stdio-common
 
-headers	:= stdio_ext.h printf.h bits/printf-ldbl.h
+headers	:= stdio_ext.h printf.h bits/printf-ldbl.h bits/stdio_lim.h
 
 routines	:=							      \
 	ctermid cuserid							      \
@@ -40,8 +40,6 @@
 	isoc99_vsscanf							      \
 	psiginfo
 
-install-others = $(inst_includedir)/bits/stdio_lim.h
-
 include ../Makeconfig
 
 aux	:= errlist siglist printf-parsemb printf-parsewc fxprintf
ASSISTANT
The task involves analyzing shifts in customer preferences within a tech market, particularly a move towards digital-only options over physical devices. Below is a blend of quick observations and reflective analysis capturing both System 1 and System 2 thinking.

[sys1]
The tech market shows growing customer interest in digital-only options, reducing demand for physical devices.
We need to understand the drivers of this change and develop strategies to adapt.
Initial thoughts include factors like cost-saving, convenience, and tech advancements.
[end sys1]

[sys2]

**2.1 Understand the Problem:**
We aim to comprehend why customers are favoring digital-only options and determine suitable adaptation strategies for our offerings.

*Reflection:*
"My understanding is that this shift might be due to perceived benefits of digital products, but what am I missing? Are there cultural or technological undercurrents influencing this?"

*Creative Perspective:*
"Could global movements towards sustainability or lifestyle changes like remote work be playing a part? Are there unseen forces at play, like a generation shift in tech preferences?"

**2.2 Analyze the Information:**
Dissecting the potential causes involves considering market trends, customer behavior, and technological advancements.

*Reflection:*
"Am I sufficiently accounting for all market forces and customer motivations? Are assumptions about tech readiness misleading?"

*Creative Perspective:*
"Are there similar trends in other industries, like music or publishing, that could inform this analysis? Could new tech platforms or communities be driving this shift in preference?"

**2.3 Generate Hypotheses:**
1. Digital options reduce environmental impact, attracting eco-conscious buyers. *(Confidence: 0.7, Creative: 0.8)*
2. Increased digital content consumption drives demand for digital-access devices. *(Confidence: 0.6, Creative: 0.5)*
3. Physical production and delivery delays are pushing consumers toward instant digital access. *(Confidence: 0.7, Creative: 0.6)*
4. Consumers are subscribing to digital minimalism philosophies. *(Confidence: 0.5, Creative: 0.7)*
5. Economic uncertainty is making digital-only options more appealing cost-wise. *(Confidence: 0.8, Creative: 0.4)*
6. Improvements in digital quality (e.g., better e-readers, music streaming) sway demand. *(Confidence: 0.8, Creative: 0.5)*
7. Digital-only offers more seamless integration with smart home technologies. *(Confidence: 0.6, Creative: 0.6)*
8. Shift influenced by increasing familiarity and comfort with digital products. *(Confidence: 0.7, Creative: 0.5)*
9. Retail space limitations encourage digital over physical. *(Confidence: 0.5, Creative: 0.6)*
10. The influence of popular tech trends and lifestyle branding. *(Confidence: 0.6, Creative: 0.7)*

*Reflection:*
"Have I overlooked any critical market dynamics or alternative perspectives?"

*Creative Perspective:*
"Could societal factors such as pandemic-induced changes in living and working environments further explain this shift?"

**2.4 Anticipate Future Steps and Obstacles:**
Develop strategies considering potential resistance from traditional segments while exploring new opportunities aligned with digital preferences.

*Reflection:*
"What challenges will surface as we pivot products to cater to digital demand? How can flexibility be incorporated into our strategy?"

*Creative Perspective:*
"How can we leverage emerging digital trends to expand into new markets? What innovative partnerships or technologies could enhance our strategy?"

**2.5 Evaluate Hypotheses:**
Careful evaluation of each hypothesis regarding feasibility and impact is necessary.

*Evaluation:*
Refine scores based on recent data and customer insights for better alignment with market realities.

*Reflection:*
"In my evaluation, have I remained unbiased? Which strategies are most aligned with both market conditions and company goals?"

*Creative Perspective:*
"How can unexpected insights be incorporated to create a competitive advantage?"

**2.6 Select the Best Hypothesis:**
Choose a hypothesis that poses the greatest alignment with market trends and strategic goals.

*Reflection:*
"Does the selected hypothesis comprehensively address both immediate needs and long-term objectives?"

*Creative Perspective:*
"Are we fully exploring the potential this approach offers, particularly in breaking into new consumer segments?"

**2.7 Implement the Hypothesis:**
Outline specific steps, from product transformation to marketing strategies, with built-in adaptability.

*Reflection:*
"Is the implementation plan realistic, including timelines and necessary resources?"

*Creative Perspective:*
"How can the implementation be optimized to tap into future trends and yield unexpected benefits?"

**2.8 Monitor and Review Progress:**
Regular reviews should highlight successes and areas needing adjustment.

*Reflection:*
"What aspects of the strategy are performing well? Where are course corrections needed?"

*Creative Perspective:*
"What patterns are emerging that could help refine future strategic approaches?"

**2.9 Reflect and Capture Insights:**
Document valuable learnings and apply insights to future strategic initiatives.

*Reflection:*
"What new understandings about customer behavior and preferences have emerged?"

*Creative Perspective:*
"What innovative approaches uncovered here could inform broader market strategies?"

[end sys2]

[sys1]
To address this trend, integrate digital-only options into the product line and emphasize their benefits through marketing. 
Use market research to refine products and align with customer desires for flexibility.
Focus on adaptability to attract diverse consumer segments.
[end sys1]

turns-00049.parquet:4100

0df8dc51a382afb09c539d4c
turn 1/1gpt-4o-2024-08-06Englishunknown country1893 words
degenerate_repetitionAbsentFinal dense release
USER
You are a helpful assistant generating synthetic data that captures *System 1* and *System 2* thinking, *creativity*, and *metacognitive reflection*. Follow these steps in sequence, using tags [sys1] and [end sys1] for *System 1* sections and [sys2] and [end sys2] for *System 2* sections.

1. *Identify System 1 and System 2 Thinking Requirements:*
   - Carefully read the text.
   - Identify parts of the text that require quick, straightforward responses (*System 1*). Mark these sections with [sys1] and [end sys1].
   - Identify parts that require in-depth, reflective thinking (*System 2*), marked with [sys2] and [end sys2].

2. *Apply Step-by-Step Problem Solving with Creativity and Metacognitive Reflection for System 2 Sections:*

   *2.1 Understand the Problem:*
   - Objective: Fully comprehend the issue, constraints, and relevant context.
   - Reflection: "What do I understand about this issue? What might I be overlooking?"
   - Creative Perspective: Seek hidden patterns or possibilities that could reveal deeper insights or innovative connections.

   *2.2 Analyze the Information:*
   - Objective: Break down the problem logically.
   - Reflection: "Am I considering all factors? Are there any assumptions that need challenging?"
   - Creative Perspective: Explore unique patterns or overlooked relationships in the data that could add depth to the analysis.

   *2.3 Generate Hypotheses:*
   - Objective: Propose at least 10 hypotheses, each with a Confidence Score (0.0 to 1.0) and Creative Score (0.0 to 1.0), reflecting originality, surprise, and utility.
   - Reflection: "Have I explored all possible explanations or approaches, both conventional and unconventional?"
   - Creative Perspective: Consider novel angles that might provide unexpected insights.

   *2.4 Anticipate Future Steps and Obstacles:*
   - Objective: Make predictions, accounting for potential outcomes and obstacles.
   - Reflection: "What challenges might I face? Is my plan flexible for different scenarios?"
   - Creative Perspective: Visualize unforeseen outcomes and adapt plans to make use of them effectively.

   *2.5 Evaluate Hypotheses:*
   - Objective: Assess hypotheses based on feasibility, risk, and potential impact.
   - Evaluation: Refine Confidence and Creative Scores as needed.
   - Reflection: "Am I unbiased in my assessment? Which options fit best with the overall objectives?"
   - Creative Perspective: Identify hidden opportunities or overlooked details in each hypothesis.

   *2.6 Select the Best Hypothesis:*
   - Objective: Choose the most promising, strategic hypothesis.
   - Reflection: "Why does this hypothesis stand out? How does it uniquely address the issue?"
   - Creative Perspective: Consider any underutilized potential in the selected approach.

   *2.7 Implement the Hypothesis:*
   - Objective: Outline actionable steps for testing the hypothesis.
   - Reflection: "Is this plan practical? What resources or preparation are required?"
   - Creative Perspective: Refine steps to maximize effectiveness and yield unexpected benefits.

   *2.8 Monitor and Review Progress:*
   - Objective: Review progress, noting areas for improvement.
   - Reflection: "What’s working well? What could be improved?"
   - Creative Perspective: Look for emerging patterns that could refine future approaches.

   *2.9 Reflect and Capture Insights:*
   - Objective: Summarize lessons learned and insights gained for future reference.
   - Reflection: "What new understanding has emerged from this process?"
   - Creative Perspective: Identify innovative insights or patterns that could be applied to similar challenges.

3. *Generate Text Output with Interleaved System 1 and System 2 Responses:*
   - Use the tags [sys1] and [sys2] throughout.
   - Aim for a lengthier, detailed response. Combine both direct, straightforward *System 1* insights and reflective, deeply analytical *System 2* segments to capture a blend of quick observations and thoughtful analysis.

---

### *Example Input Text:*

You are tasked with analyzing a sudden shift in customer preferences in a tech market. There has been a noticeable decline in demand for physical devices, with customers increasingly interested in digital-only options. The challenge is to understand this shift, generate hypotheses for why it might be occurring, and explore potential strategies for adapting to this new trend.

---

### *Processed Output with System 1 and System 2 Thinking:*

The tech market is experiencing a shift in customer demand, moving away from physical devices toward digital-only options.

[sys1]
Customer demand has shifted from physical devices to digital-only options.
We need to understand why this change is happening and find strategies to address it.
Key factors may include cost, convenience, and technological trends.
[end sys1]

[sys2]
**2.1 Understand the Problem:**
The goal is to understand the underlying reasons for the shift in demand from physical devices to digital-only options, then develop a strategy to adapt.

*Reflection:* 
"I understand that preferences are changing, but what might be driving this? Is it primarily cost, or are there other factors such as convenience or sustainability?"

*Creative Perspective:* 
"Could there be a larger trend in digital minimalism or a preference for eco-friendly solutions that we’re missing? What unseen motivations might explain this shift?"

**2.2 Analyze the Information:**
There are multiple possible factors driving this shift, from economic influences to cultural shifts. It’s essential to isolate each factor and understand its impact.

*Reflection:* 
"Am I fully considering the various economic and social influences? Could there be a technological factor, like better internet speeds, that makes digital-only products more accessible?"

*Creative Perspective:* 
"Are there patterns or trends in other markets that could shed light on this shift? Could this be part of a larger trend toward virtual experiences?"

**2.3 Generate Hypotheses:**
1. Customers prefer digital options due to lower costs. (Confidence: 0.8, Creative: 0.4)
2. There’s a growing trend toward minimalism and reduced physical clutter. (Confidence: 0.7, Creative: 0.7)
3. Digital products offer greater flexibility and ease of use. (Confidence: 0.6, Creative: 0.6)
4. Environmental concerns are pushing consumers away from physical goods. (Confidence: 0.6, Creative: 0.8)
5. Advances in tech make digital-only options more functional. (Confidence: 0.8, Creative: 0.5)
6. Pandemic-era remote work increased demand for digital solutions. (Confidence: 0.7, Creative: 0.6)
7. Media coverage of the environmental impact of physical devices affects preferences. (Confidence: 0.5, Creative: 0.7)
8. There’s an increase in global digital literacy, expanding market access. (Confidence: 0.6, Creative: 0.6)
9. Customers view digital as more convenient and scalable for future needs. (Confidence: 0.7, Creative: 0.5)
10. Younger consumers prefer the aesthetics and convenience of digital products. (Confidence: 0.6, Creative: 0.6)

*Reflection:* 
"Have I considered all possible influences? Are there any surprising factors that could explain this shift?"

*Creative Perspective:* 
"Could specific social trends, like the rise of influencer culture or digital-first lifestyles, be influencing customer choices?"

**2.4 Anticipate Future Steps and Obstacles:**
*Objective:* Anticipate possible challenges, such as resistance from segments still preferring physical products.

*Reflection:* 
"What market obstacles might we face if we shift our focus to digital-only? Are there sub-segments that still prioritize physical products?"

*Creative Perspective:* 
"Could expanding digital options help us reach a more global audience? Are there emerging trends that we could leverage in our strategy?"

[end sys2]

[sys1]
To address this shift, consider a strategy that incorporates both digital-only offerings and educational campaigns about the benefits of digital solutions.
Use insights from customer feedback and current trends to guide product development.
Focus on flexibility and adaptation to cater to different customer segments.
[end sys1]


Photodynamic therapy in lung cancer. A review.
Photodynamic therapy (PDT) in lung cancer was introduced in 1980 to treat tumours located in the major airways. After systemic injection of photosensitizers, tumour illumination is performed using a laser fibre to transmit light of a specific wavelength. PDT can be performed under local anaesthesia using the flexible fibreoptic bronchoscope. Skin photosensitivity is the most important treatment morbidity caused by the prolonged cutaneous retention of photosensitizer molecules. Ample data have shown that PDT is effective in obtaining tumour necrosis, but the skin photosensitivity issue limits its palliative potential. Moreover, competing bronchoscopic techniques, such as electrosurgery, Nd-YAG laser and brachytherapy, are available and seem to be equally palliative for the debulking of intraluminal obstructive lung tumours. The curative potential of PDT in patients with roentgenologically occult lung cancer is the most interesting aspect of this treatment modality. A significant number of patients with lung cancer have limited pulmonary function. A normal tissue sparing treatment such as PDT may provide an alternative, as patients may also have subsequent multiple lung cancer primaries. Since early lung cancer detection is now becoming feasible, PDT may be applied to treat roentgenologically occult tumours with curative intent. This may optimize treatment efficacy in the near future.
ASSISTANT
The text provides an overview of photodynamic therapy (PDT) for lung cancer, including historical context, methodology, efficacy, and challenges.

[sys1]
PDT was introduced in 1980 to treat airway tumors.
Patients receive photosensitizers and light to cause tumor necrosis.
It's effective but limited by skin photosensitivity.
There are competing bronchoscopic techniques like electrosurgery.
PDT could be curative for early, occult lung cancer.
[end sys1]

[sys2]
**2.1 Understand the Problem:**
We need to fully grasp the potential for PDT to address lung cancer efficiently, balancing treatment efficacy with the side effect of prolonged skin photosensitivity.

*Reflection:* 
"The challenge is significant – preserving lung function while effectively targeting cancer. What are the critical advantages of PDT over other methods in specific cases of lung cancer?"

*Creative Perspective:* 
"Are there any novel approaches to mitigate the side effects of skin photosensitivity? What could be the long-term benefits if PDT's limitations are overcome?"

**2.2 Analyze the Information:**
Numerous techniques are available for bronchoscopic tumor debulking. PDT's curative potential hinges on its ability to spare normal tissues and its applicability to roentgenologically occult tumors.

*Reflection:* 
"Am I considering the full range of patient circumstances? Could the non-invasive nature of PDT offer unique advantages over alternatives?"

*Creative Perspective:* 
"How might advancements in PDT technology broaden its use? Are there other areas where its tissue-sparing advantage can be maximized?"

**2.3 Generate Hypotheses:**
1. Improvements in photosensitizer formulation could reduce skin photosensitivity. (Confidence: 0.7, Creative: 0.8)
2. PDT may become first-line treatment for early-stage occult lung cancer. (Confidence: 0.6, Creative: 0.7)
3. Combining PDT with other therapies will enhance overall patient outcomes. (Confidence: 0.6, Creative: 0.8)
4. Recent technological advances in bronchoscopy could enhance PDT efficacy. (Confidence: 0.7, Creative: 0.6)
5. Using PDT for palliative care might improve quality of life in late-stage cancers. (Confidence: 0.6, Creative: 0.5)
6. Development of new light delivery methods could facilitate more targeted treatment. (Confidence: 0.5, Creative: 0.7)
7. Personalized medicine approaches could identify patients who benefit most from PDT. (Confidence: 0.6, Creative: 0.7)
8. Public education on the benefits of early detection and PDT could boost survival rates. (Confidence: 0.5, Creative: 0.6)
9. Regulatory changes might expedite approval of new PDT advancements. (Confidence: 0.4, Creative: 0.5)
10. The rise of minimally invasive surgery trends could promote PDT adoption. (Confidence: 0.6, Creative: 0.6)

*Reflection:* 
"Am I exploring all potential areas where PDT could prove advantageous? Are there unconventional pathways for overcoming existing limitations?"

*Creative Perspective:* 
"Could integrating AI in PDT planning enhance precision and outcomes? What if PDT were paired with emerging imaging technologies for real-time treatment monitoring?"

**2.4 Anticipate Future Steps and Obstacles:**
*Objective:* Anticipate obstacles like regulatory barriers, technological limitations, and the need for integration into existing treatment protocols.

*Reflection:* 
"What might be the primary challenges in expanding PDT's applications? How can we ensure smooth adaptation in clinical practice?"

*Creative Perspective:* 
"Are there global trends in cancer treatment that could facilitate broader PDT acceptance? Could cross-disciplinary collaborations drive innovation in PDT applications?"

[end sys2]

[sys1]
To leverage PDT effectively, future strategies should focus on improving photosensitizer formulations and enhancing light delivery mechanisms.
It's crucial to monitor advancements in both technology and regulatory landscapes to expedite PDT integration into practice.
Emphasize education on the early detection of lung cancer to optimize PDT's curative potential.
[end sys1]

turns-00049.parquet:4101

0734f19159b51f5976f6f63e
turn 1/1gpt-4o-2024-08-06Englishunknown country1672 words
degenerate_repetitionAbsentFinal dense release
USER
You are a helpful assistant generating synthetic data that captures *System 1* and *System 2* thinking, *creativity*, and *metacognitive reflection*. Follow these steps in sequence, using tags [sys1] and [end sys1] for *System 1* sections and [sys2] and [end sys2] for *System 2* sections.

1. *Identify System 1 and System 2 Thinking Requirements:*
   - Carefully read the text.
   - Identify parts of the text that require quick, straightforward responses (*System 1*). Mark these sections with [sys1] and [end sys1].
   - Identify parts that require in-depth, reflective thinking (*System 2*), marked with [sys2] and [end sys2].

2. *Apply Step-by-Step Problem Solving with Creativity and Metacognitive Reflection for System 2 Sections:*

   *2.1 Understand the Problem:*
   - Objective: Fully comprehend the issue, constraints, and relevant context.
   - Reflection: "What do I understand about this issue? What might I be overlooking?"
   - Creative Perspective: Seek hidden patterns or possibilities that could reveal deeper insights or innovative connections.

   *2.2 Analyze the Information:*
   - Objective: Break down the problem logically.
   - Reflection: "Am I considering all factors? Are there any assumptions that need challenging?"
   - Creative Perspective: Explore unique patterns or overlooked relationships in the data that could add depth to the analysis.

   *2.3 Generate Hypotheses:*
   - Objective: Propose at least 10 hypotheses, each with a Confidence Score (0.0 to 1.0) and Creative Score (0.0 to 1.0), reflecting originality, surprise, and utility.
   - Reflection: "Have I explored all possible explanations or approaches, both conventional and unconventional?"
   - Creative Perspective: Consider novel angles that might provide unexpected insights.

   *2.4 Anticipate Future Steps and Obstacles:*
   - Objective: Make predictions, accounting for potential outcomes and obstacles.
   - Reflection: "What challenges might I face? Is my plan flexible for different scenarios?"
   - Creative Perspective: Visualize unforeseen outcomes and adapt plans to make use of them effectively.

   *2.5 Evaluate Hypotheses:*
   - Objective: Assess hypotheses based on feasibility, risk, and potential impact.
   - Evaluation: Refine Confidence and Creative Scores as needed.
   - Reflection: "Am I unbiased in my assessment? Which options fit best with the overall objectives?"
   - Creative Perspective: Identify hidden opportunities or overlooked details in each hypothesis.

   *2.6 Select the Best Hypothesis:*
   - Objective: Choose the most promising, strategic hypothesis.
   - Reflection: "Why does this hypothesis stand out? How does it uniquely address the issue?"
   - Creative Perspective: Consider any underutilized potential in the selected approach.

   *2.7 Implement the Hypothesis:*
   - Objective: Outline actionable steps for testing the hypothesis.
   - Reflection: "Is this plan practical? What resources or preparation are required?"
   - Creative Perspective: Refine steps to maximize effectiveness and yield unexpected benefits.

   *2.8 Monitor and Review Progress:*
   - Objective: Review progress, noting areas for improvement.
   - Reflection: "What’s working well? What could be improved?"
   - Creative Perspective: Look for emerging patterns that could refine future approaches.

   *2.9 Reflect and Capture Insights:*
   - Objective: Summarize lessons learned and insights gained for future reference.
   - Reflection: "What new understanding has emerged from this process?"
   - Creative Perspective: Identify innovative insights or patterns that could be applied to similar challenges.

3. *Generate Text Output with Interleaved System 1 and System 2 Responses:*
   - Use the tags [sys1] and [sys2] throughout.
   - Aim for a lengthier, detailed response. Combine both direct, straightforward *System 1* insights and reflective, deeply analytical *System 2* segments to capture a blend of quick observations and thoughtful analysis.

---

### *Example Input Text:*

You are tasked with analyzing a sudden shift in customer preferences in a tech market. There has been a noticeable decline in demand for physical devices, with customers increasingly interested in digital-only options. The challenge is to understand this shift, generate hypotheses for why it might be occurring, and explore potential strategies for adapting to this new trend.

---

### *Processed Output with System 1 and System 2 Thinking:*

The tech market is experiencing a shift in customer demand, moving away from physical devices toward digital-only options.

[sys1]
Customer demand has shifted from physical devices to digital-only options.
We need to understand why this change is happening and find strategies to address it.
Key factors may include cost, convenience, and technological trends.
[end sys1]

[sys2]
**2.1 Understand the Problem:**
The goal is to understand the underlying reasons for the shift in demand from physical devices to digital-only options, then develop a strategy to adapt.

*Reflection:* 
"I understand that preferences are changing, but what might be driving this? Is it primarily cost, or are there other factors such as convenience or sustainability?"

*Creative Perspective:* 
"Could there be a larger trend in digital minimalism or a preference for eco-friendly solutions that we’re missing? What unseen motivations might explain this shift?"

**2.2 Analyze the Information:**
There are multiple possible factors driving this shift, from economic influences to cultural shifts. It’s essential to isolate each factor and understand its impact.

*Reflection:* 
"Am I fully considering the various economic and social influences? Could there be a technological factor, like better internet speeds, that makes digital-only products more accessible?"

*Creative Perspective:* 
"Are there patterns or trends in other markets that could shed light on this shift? Could this be part of a larger trend toward virtual experiences?"

**2.3 Generate Hypotheses:**
1. Customers prefer digital options due to lower costs. (Confidence: 0.8, Creative: 0.4)
2. There’s a growing trend toward minimalism and reduced physical clutter. (Confidence: 0.7, Creative: 0.7)
3. Digital products offer greater flexibility and ease of use. (Confidence: 0.6, Creative: 0.6)
4. Environmental concerns are pushing consumers away from physical goods. (Confidence: 0.6, Creative: 0.8)
5. Advances in tech make digital-only options more functional. (Confidence: 0.8, Creative: 0.5)
6. Pandemic-era remote work increased demand for digital solutions. (Confidence: 0.7, Creative: 0.6)
7. Media coverage of the environmental impact of physical devices affects preferences. (Confidence: 0.5, Creative: 0.7)
8. There’s an increase in global digital literacy, expanding market access. (Confidence: 0.6, Creative: 0.6)
9. Customers view digital as more convenient and scalable for future needs. (Confidence: 0.7, Creative: 0.5)
10. Younger consumers prefer the aesthetics and convenience of digital products. (Confidence: 0.6, Creative: 0.6)

*Reflection:* 
"Have I considered all possible influences? Are there any surprising factors that could explain this shift?"

*Creative Perspective:* 
"Could specific social trends, like the rise of influencer culture or digital-first lifestyles, be influencing customer choices?"

**2.4 Anticipate Future Steps and Obstacles:**
*Objective:* Anticipate possible challenges, such as resistance from segments still preferring physical products.

*Reflection:* 
"What market obstacles might we face if we shift our focus to digital-only? Are there sub-segments that still prioritize physical products?"

*Creative Perspective:* 
"Could expanding digital options help us reach a more global audience? Are there emerging trends that we could leverage in our strategy?"

[end sys2]

[sys1]
To address this shift, consider a strategy that incorporates both digital-only offerings and educational campaigns about the benefits of digital solutions.
Use insights from customer feedback and current trends to guide product development.
Focus on flexibility and adaptation to cater to different customer segments.
[end sys1]


party was a blast!!!! :)
motif of the party : BLACK AND SILVER
- i was inspired by the queen of burlesque , dita von teese so this is my take on dita’s fashion :) i didn’t have time to fix my hair or go to a salon because of the sooooooper busy sched :(
ASSISTANT
[sys1]
The party theme was black and silver, drawing inspiration from Dita Von Teese's fashion.
Despite a busy schedule, the styling captured the essence of burlesque elegance.
[end sys1]

[sys2]
**2.1 Understand the Problem:**
The challenge was to create a fashion statement inspired by Dita Von Teese with limited preparation time, specifically for a black and silver-themed party.

*Reflection:*
"What do I understand about capturing Dita Von Teese's style? It's about glamour, elegance, and a vintage aesthetic. But how do I balance this with the time constraint?"

*Creative Perspective:*
"Could there be a minimalist approach to Dita Von Teese's style, focusing on key elements like fabric choice or accessories rather than elaborate preparation?"

**2.2 Analyze the Information:**
Achieving a Dita-inspired look means considering elements like fabric, silhouette, and accessories.

*Reflection:*
"Am I focusing too much on intricate details instead of broader stylistic features? What elements define her style the most?"

*Creative Perspective:*
"Are there key accessories or colors that could instantly evoke a Dita Von Teese feel without extensive styling efforts?"

**2.3 Generate Hypotheses:**
1. Focus on a statement piece, like a bold accessory to echo Dita's style. (Confidence: 0.7, Creative: 0.6)
2. Use classic black fabric with a silver accent to simplify elegance. (Confidence: 0.8, Creative: 0.5)
3. Select a vintage-inspired silhouette that requires minimal hairstyling. (Confidence: 0.6, Creative: 0.7)
4. Incorporate red lipstick to add a simple touch of glamour. (Confidence: 0.5, Creative: 0.5)
5. Choose a silver statement jewelry piece to enhance the theme. (Confidence: 0.7, Creative: 0.6)
6. Implement vintage hair accessories that don't require complex styling. (Confidence: 0.6, Creative: 0.6)
7. Use a corset or structured elements for an immediate burlesque vibe. (Confidence: 0.6, Creative: 0.7)
8. Find a fabric with a subtle sheen to reflect Dita's glamorous aesthetic. (Confidence: 0.7, Creative: 0.5)
9. Emphasize dramatic eye makeup to complement a simple hairstyle. (Confidence: 0.5, Creative: 0.6)
10. Opt for classic high heels to complete the vintage look with minimal effort. (Confidence: 0.8, Creative: 0.4)

*Reflection:*
"Are these hypotheses varied enough to cover all angles of the style transformation? What quick fixes could strengthen the look?"

*Creative Perspective:*
"Could blending specific elements from other fashion icons complement Dita Von Teese’s style without losing authenticity?"

**2.4 Anticipate Future Steps and Obstacles:**
Planning for additional last-minute adjustments if necessary, like adding or subtracting elements based on what's available.

*Reflection:*
"What would be my backup plan if something isn't working or available last minute? How can I keep the look cohesive in a time crunch?"

*Creative Perspective:*
"Are there any quick modifications, like changing accessories, that could enhance or simplify the outfit?"

[end sys2]

[sys1]
To encapsulate a burlesque-inspired look in a short time, focus on key elements like a classic black fabric, bold red lipstick, and statement accessories.
A flexible approach allows for quick adjustments while maintaining the desired aesthetic.
[end sys1]

turns-00049.parquet:4102

578cdda8dbddf89c9bdb6b1d
turn 1/1gpt-4o-2024-08-06EnglishBrazil1877 words
degenerate_repetitionAbsentFinal dense release
USER
You are a helpful assistant generating synthetic data that captures *System 1* and *System 2* thinking, *creativity*, and *metacognitive reflection*. Follow these steps in sequence, using tags [sys1] and [end sys1] for *System 1* sections and [sys2] and [end sys2] for *System 2* sections.

1. *Identify System 1 and System 2 Thinking Requirements:*
   - Carefully read the text.
   - Identify parts of the text that require quick, straightforward responses (*System 1*). Mark these sections with [sys1] and [end sys1].
   - Identify parts that require in-depth, reflective thinking (*System 2*), marked with [sys2] and [end sys2].

2. *Apply Step-by-Step Problem Solving with Creativity and Metacognitive Reflection for System 2 Sections:*

   *2.1 Understand the Problem:*
   - Objective: Fully comprehend the issue, constraints, and relevant context.
   - Reflection: "What do I understand about this issue? What might I be overlooking?"
   - Creative Perspective: Seek hidden patterns or possibilities that could reveal deeper insights or innovative connections.

   *2.2 Analyze the Information:*
   - Objective: Break down the problem logically.
   - Reflection: "Am I considering all factors? Are there any assumptions that need challenging?"
   - Creative Perspective: Explore unique patterns or overlooked relationships in the data that could add depth to the analysis.

   *2.3 Generate Hypotheses:*
   - Objective: Propose at least 10 hypotheses, each with a Confidence Score (0.0 to 1.0) and Creative Score (0.0 to 1.0), reflecting originality, surprise, and utility.
   - Reflection: "Have I explored all possible explanations or approaches, both conventional and unconventional?"
   - Creative Perspective: Consider novel angles that might provide unexpected insights.

   *2.4 Anticipate Future Steps and Obstacles:*
   - Objective: Make predictions, accounting for potential outcomes and obstacles.
   - Reflection: "What challenges might I face? Is my plan flexible for different scenarios?"
   - Creative Perspective: Visualize unforeseen outcomes and adapt plans to make use of them effectively.

   *2.5 Evaluate Hypotheses:*
   - Objective: Assess hypotheses based on feasibility, risk, and potential impact.
   - Evaluation: Refine Confidence and Creative Scores as needed.
   - Reflection: "Am I unbiased in my assessment? Which options fit best with the overall objectives?"
   - Creative Perspective: Identify hidden opportunities or overlooked details in each hypothesis.

   *2.6 Select the Best Hypothesis:*
   - Objective: Choose the most promising, strategic hypothesis.
   - Reflection: "Why does this hypothesis stand out? How does it uniquely address the issue?"
   - Creative Perspective: Consider any underutilized potential in the selected approach.

   *2.7 Implement the Hypothesis:*
   - Objective: Outline actionable steps for testing the hypothesis.
   - Reflection: "Is this plan practical? What resources or preparation are required?"
   - Creative Perspective: Refine steps to maximize effectiveness and yield unexpected benefits.

   *2.8 Monitor and Review Progress:*
   - Objective: Review progress, noting areas for improvement.
   - Reflection: "What’s working well? What could be improved?"
   - Creative Perspective: Look for emerging patterns that could refine future approaches.

   *2.9 Reflect and Capture Insights:*
   - Objective: Summarize lessons learned and insights gained for future reference.
   - Reflection: "What new understanding has emerged from this process?"
   - Creative Perspective: Identify innovative insights or patterns that could be applied to similar challenges.

3. *Generate Text Output with Interleaved System 1 and System 2 Responses:*
   - Use the tags [sys1] and [sys2] throughout.
   - Aim for a lengthier, detailed response. Combine both direct, straightforward *System 1* insights and reflective, deeply analytical *System 2* segments to capture a blend of quick observations and thoughtful analysis.

---

### *Example Input Text:*

You are tasked with analyzing a sudden shift in customer preferences in a tech market. There has been a noticeable decline in demand for physical devices, with customers increasingly interested in digital-only options. The challenge is to understand this shift, generate hypotheses for why it might be occurring, and explore potential strategies for adapting to this new trend.

---

### *Processed Output with System 1 and System 2 Thinking:*

The tech market is experiencing a shift in customer demand, moving away from physical devices toward digital-only options.

[sys1]
Customer demand has shifted from physical devices to digital-only options.
We need to understand why this change is happening and find strategies to address it.
Key factors may include cost, convenience, and technological trends.
[end sys1]

[sys2]
**2.1 Understand the Problem:**
The goal is to understand the underlying reasons for the shift in demand from physical devices to digital-only options, then develop a strategy to adapt.

*Reflection:* 
"I understand that preferences are changing, but what might be driving this? Is it primarily cost, or are there other factors such as convenience or sustainability?"

*Creative Perspective:* 
"Could there be a larger trend in digital minimalism or a preference for eco-friendly solutions that we’re missing? What unseen motivations might explain this shift?"

**2.2 Analyze the Information:**
There are multiple possible factors driving this shift, from economic influences to cultural shifts. It’s essential to isolate each factor and understand its impact.

*Reflection:* 
"Am I fully considering the various economic and social influences? Could there be a technological factor, like better internet speeds, that makes digital-only products more accessible?"

*Creative Perspective:* 
"Are there patterns or trends in other markets that could shed light on this shift? Could this be part of a larger trend toward virtual experiences?"

**2.3 Generate Hypotheses:**
1. Customers prefer digital options due to lower costs. (Confidence: 0.8, Creative: 0.4)
2. There’s a growing trend toward minimalism and reduced physical clutter. (Confidence: 0.7, Creative: 0.7)
3. Digital products offer greater flexibility and ease of use. (Confidence: 0.6, Creative: 0.6)
4. Environmental concerns are pushing consumers away from physical goods. (Confidence: 0.6, Creative: 0.8)
5. Advances in tech make digital-only options more functional. (Confidence: 0.8, Creative: 0.5)
6. Pandemic-era remote work increased demand for digital solutions. (Confidence: 0.7, Creative: 0.6)
7. Media coverage of the environmental impact of physical devices affects preferences. (Confidence: 0.5, Creative: 0.7)
8. There’s an increase in global digital literacy, expanding market access. (Confidence: 0.6, Creative: 0.6)
9. Customers view digital as more convenient and scalable for future needs. (Confidence: 0.7, Creative: 0.5)
10. Younger consumers prefer the aesthetics and convenience of digital products. (Confidence: 0.6, Creative: 0.6)

*Reflection:* 
"Have I considered all possible influences? Are there any surprising factors that could explain this shift?"

*Creative Perspective:* 
"Could specific social trends, like the rise of influencer culture or digital-first lifestyles, be influencing customer choices?"

**2.4 Anticipate Future Steps and Obstacles:**
*Objective:* Anticipate possible challenges, such as resistance from segments still preferring physical products.

*Reflection:* 
"What market obstacles might we face if we shift our focus to digital-only? Are there sub-segments that still prioritize physical products?"

*Creative Perspective:* 
"Could expanding digital options help us reach a more global audience? Are there emerging trends that we could leverage in our strategy?"

[end sys2]

[sys1]
To address this shift, consider a strategy that incorporates both digital-only offerings and educational campaigns about the benefits of digital solutions.
Use insights from customer feedback and current trends to guide product development.
Focus on flexibility and adaptation to cater to different customer segments.
[end sys1]


Boosted photocatalytic efficiency through plasmonic field confinement with bowtie and diabolo nanostructures under LED irradiation.
Photoresist and electron beam lithography techniques were used to fabricate embedded Ag bowtie and diabolo nanostructures with various apex angles on the surface of a TiO<sub>2</sub> film. The reinforced localized surface plasmon resonance (LSPR) and electric field generated at both the Ag/TiO<sub>2</sub> and air/TiO<sub>2</sub> interfaces enabled high light absorbance in the TiO<sub>2</sub> nanostructure. Results for both the bowtie and diabolo nanostructures showed that a reduction in the apex angle enhances both LSPR and Raman intensity. The maximum electric current density observed at the apex indicates that the strongest SPR confines at the tip gap of the bowtie and corners of the diabolo. In a long-wavelength region, as the apex angle increases, the resonant peak wavelength of the standing wave matches the increased length of the prism edges of the bowtie and diabolo to create a redshift. In a short-wavelength region, as the apex angle increases, the blueshift of the resonant peak wavelength is presumably attributable to the increase in the effective index of the local surface plasmon polariton standing wave mainly residing along both the bowtie and diabolo axes. The redshift and blueshift trend in the simulation results for the resonant peak wavelength agrees well with the experimental results. The fastest photocatalytic rate was obtained by placing the Ag/TiO<sub>2</sub> bowtie at an apex angle of 30° in the methylene blue solution, revealing that the plasmonic photocatalysis causes the highest degradation efficiency. This is because the Schottky junction and LSPR can stimulate many valid radicals for the environmental improvement.
ASSISTANT
The passage discusses a scientific investigation into improving photocatalytic efficiency through the use of plasmonic field confinement in nanostructures. I'll now apply System 1 and System 2 thinking to analyze it comprehensively.

[sys1]
Photocatalytic efficiency can be boosted using bowtie and diabolo nanostructures.
They use photoresist and electron beam lithography to fabricate these structures.
Reduced apex angles enhance resonance and Raman intensity.
[end sys1]

[sys2]
**2.1 Understand the Problem:**
The study aims to enhance photocatalytic efficiency through the use of specific nanostructures that manipulate light at a nanoscale.

*Reflection:* 
"I understand the goal is to improve energy absorption and catalytic efficiency, but am I missing any underlying principles of how these nanostructures work?"

*Creative Perspective:* 
"Exploring the balance between structural dimensions and light absorption might yield new insights—how do these designs interact with different light spectrums?"

**2.2 Analyze the Information:**
This involves the interplay between structural changes in nanostructures and their effect on localized surface plasmon resonance (LSPR).

*Reflection:* 
"Could there be limitations in current fabrication methods? Are there any assumptions about the materials or conditions that need revisiting?"

*Creative Perspective:* 
"How could other nanostructure shapes or materials impact LSPR? Could aligning these with different wavelengths offer new pathways to efficiency?"

**2.3 Generate Hypotheses:**
1. Smaller apex angles lead to higher intensity due to better field confinement. (Confidence: 0.85, Creative: 0.5)
2. Schottky junctions enhance radical stimulation in catalytic processes. (Confidence: 0.8, Creative: 0.6)
3. Longer prism edges redshift the resonant peak, improving absorption in different light spectrums. (Confidence: 0.7, Creative: 0.5)
4. Varied apex angles optimize photocatalytic activity for specific applications. (Confidence: 0.6, Creative: 0.8)
5. Combining different nanostructures increases overall catalytic performance. (Confidence: 0.5, Creative: 0.7)
6. Wavelength alignment with structural dimensions maximizes light utility. (Confidence: 0.7, Creative: 0.6)
7. Enhanced electric field at tip gaps drastically improves photocatalytic rates. (Confidence: 0.65, Creative: 0.6)
8. Electron beam lithography could be optimized for better resolution and efficiency. (Confidence: 0.6, Creative: 0.7)
9. Nanostructure orientation could influence performance under various lighting conditions. (Confidence: 0.55, Creative: 0.7)
10. Different chemical environments might alter the efficacy of the plasmonic structures. (Confidence: 0.5, Creative: 0.7)

*Reflection:* 
"Are there overlooked interactions between materials and light wavelengths? What unexpected synergies might these structures reveal?"

*Creative Perspective:* 
"Could nanoscale synthetic biology bridge new concepts in catalytic efficiency? What innovations lie at the intersection of disciplines?"

**2.4 Anticipate Future Steps and Obstacles:**
*Objective:* Predict challenges such as fabrication limits and real-world application adaptability.

*Reflection:* 
"How might current limitations in fabrication techniques affect scalability? Are there durability concerns that need addressing?"

*Creative Perspective:* 
"Could novel manufacturing processes reform these limitations? What partnerships could facilitate experimental breakthroughs?"

[end sys2]

[sys1]
Progress involves refining fabrication methods and testing under varied conditions.
Research aims to maximize the effectiveness of nanostructures in real-world environments.
Strategy: Initiate cross-disciplinary collaborations to amplify research impact.
[end sys1]

turns-00049.parquet:4103

54bc3793d152dc26bfbaef93
turn 1/1gpt-4o-2024-08-06EnglishUnited States2477 words
degenerate_repetitionAbsentFinal dense release
USER
You are a helpful assistant generating synthetic data that captures *System 1* and *System 2* thinking, *creativity*, and *metacognitive reflection*. Follow these steps in sequence, using tags [sys1] and [end sys1] for *System 1* sections and [sys2] and [end sys2] for *System 2* sections.

1. *Identify System 1 and System 2 Thinking Requirements:*
   - Carefully read the text.
   - Identify parts of the text that require quick, straightforward responses (*System 1*). Mark these sections with [sys1] and [end sys1].
   - Identify parts that require in-depth, reflective thinking (*System 2*), marked with [sys2] and [end sys2].

2. *Apply Step-by-Step Problem Solving with Creativity and Metacognitive Reflection for System 2 Sections:*

   *2.1 Understand the Problem:*
   - Objective: Fully comprehend the issue, constraints, and relevant context.
   - Reflection: "What do I understand about this issue? What might I be overlooking?"
   - Creative Perspective: Seek hidden patterns or possibilities that could reveal deeper insights or innovative connections.

   *2.2 Analyze the Information:*
   - Objective: Break down the problem logically.
   - Reflection: "Am I considering all factors? Are there any assumptions that need challenging?"
   - Creative Perspective: Explore unique patterns or overlooked relationships in the data that could add depth to the analysis.

   *2.3 Generate Hypotheses:*
   - Objective: Propose at least 10 hypotheses, each with a Confidence Score (0.0 to 1.0) and Creative Score (0.0 to 1.0), reflecting originality, surprise, and utility.
   - Reflection: "Have I explored all possible explanations or approaches, both conventional and unconventional?"
   - Creative Perspective: Consider novel angles that might provide unexpected insights.

   *2.4 Anticipate Future Steps and Obstacles:*
   - Objective: Make predictions, accounting for potential outcomes and obstacles.
   - Reflection: "What challenges might I face? Is my plan flexible for different scenarios?"
   - Creative Perspective: Visualize unforeseen outcomes and adapt plans to make use of them effectively.

   *2.5 Evaluate Hypotheses:*
   - Objective: Assess hypotheses based on feasibility, risk, and potential impact.
   - Evaluation: Refine Confidence and Creative Scores as needed.
   - Reflection: "Am I unbiased in my assessment? Which options fit best with the overall objectives?"
   - Creative Perspective: Identify hidden opportunities or overlooked details in each hypothesis.

   *2.6 Select the Best Hypothesis:*
   - Objective: Choose the most promising, strategic hypothesis.
   - Reflection: "Why does this hypothesis stand out? How does it uniquely address the issue?"
   - Creative Perspective: Consider any underutilized potential in the selected approach.

   *2.7 Implement the Hypothesis:*
   - Objective: Outline actionable steps for testing the hypothesis.
   - Reflection: "Is this plan practical? What resources or preparation are required?"
   - Creative Perspective: Refine steps to maximize effectiveness and yield unexpected benefits.

   *2.8 Monitor and Review Progress:*
   - Objective: Review progress, noting areas for improvement.
   - Reflection: "What’s working well? What could be improved?"
   - Creative Perspective: Look for emerging patterns that could refine future approaches.

   *2.9 Reflect and Capture Insights:*
   - Objective: Summarize lessons learned and insights gained for future reference.
   - Reflection: "What new understanding has emerged from this process?"
   - Creative Perspective: Identify innovative insights or patterns that could be applied to similar challenges.

3. *Generate Text Output with Interleaved System 1 and System 2 Responses:*
   - Use the tags [sys1] and [sys2] throughout.
   - Aim for a lengthier, detailed response. Combine both direct, straightforward *System 1* insights and reflective, deeply analytical *System 2* segments to capture a blend of quick observations and thoughtful analysis.

---

### *Example Input Text:*

You are tasked with analyzing a sudden shift in customer preferences in a tech market. There has been a noticeable decline in demand for physical devices, with customers increasingly interested in digital-only options. The challenge is to understand this shift, generate hypotheses for why it might be occurring, and explore potential strategies for adapting to this new trend.

---

### *Processed Output with System 1 and System 2 Thinking:*

The tech market is experiencing a shift in customer demand, moving away from physical devices toward digital-only options.

[sys1]
Customer demand has shifted from physical devices to digital-only options.
We need to understand why this change is happening and find strategies to address it.
Key factors may include cost, convenience, and technological trends.
[end sys1]

[sys2]
**2.1 Understand the Problem:**
The goal is to understand the underlying reasons for the shift in demand from physical devices to digital-only options, then develop a strategy to adapt.

*Reflection:* 
"I understand that preferences are changing, but what might be driving this? Is it primarily cost, or are there other factors such as convenience or sustainability?"

*Creative Perspective:* 
"Could there be a larger trend in digital minimalism or a preference for eco-friendly solutions that we’re missing? What unseen motivations might explain this shift?"

**2.2 Analyze the Information:**
There are multiple possible factors driving this shift, from economic influences to cultural shifts. It’s essential to isolate each factor and understand its impact.

*Reflection:* 
"Am I fully considering the various economic and social influences? Could there be a technological factor, like better internet speeds, that makes digital-only products more accessible?"

*Creative Perspective:* 
"Are there patterns or trends in other markets that could shed light on this shift? Could this be part of a larger trend toward virtual experiences?"

**2.3 Generate Hypotheses:**
1. Customers prefer digital options due to lower costs. (Confidence: 0.8, Creative: 0.4)
2. There’s a growing trend toward minimalism and reduced physical clutter. (Confidence: 0.7, Creative: 0.7)
3. Digital products offer greater flexibility and ease of use. (Confidence: 0.6, Creative: 0.6)
4. Environmental concerns are pushing consumers away from physical goods. (Confidence: 0.6, Creative: 0.8)
5. Advances in tech make digital-only options more functional. (Confidence: 0.8, Creative: 0.5)
6. Pandemic-era remote work increased demand for digital solutions. (Confidence: 0.7, Creative: 0.6)
7. Media coverage of the environmental impact of physical devices affects preferences. (Confidence: 0.5, Creative: 0.7)
8. There’s an increase in global digital literacy, expanding market access. (Confidence: 0.6, Creative: 0.6)
9. Customers view digital as more convenient and scalable for future needs. (Confidence: 0.7, Creative: 0.5)
10. Younger consumers prefer the aesthetics and convenience of digital products. (Confidence: 0.6, Creative: 0.6)

*Reflection:* 
"Have I considered all possible influences? Are there any surprising factors that could explain this shift?"

*Creative Perspective:* 
"Could specific social trends, like the rise of influencer culture or digital-first lifestyles, be influencing customer choices?"

**2.4 Anticipate Future Steps and Obstacles:**
*Objective:* Anticipate possible challenges, such as resistance from segments still preferring physical products.

*Reflection:* 
"What market obstacles might we face if we shift our focus to digital-only? Are there sub-segments that still prioritize physical products?"

*Creative Perspective:* 
"Could expanding digital options help us reach a more global audience? Are there emerging trends that we could leverage in our strategy?"

[end sys2]

[sys1]
To address this shift, consider a strategy that incorporates both digital-only offerings and educational campaigns about the benefits of digital solutions.
Use insights from customer feedback and current trends to guide product development.
Focus on flexibility and adaptation to cater to different customer segments.
[end sys1]


Q:

What does 氏 mean after a name, how is it different from さん or 様?

If you look in the dictionary for the definition of 氏 you'll find it defined as: family name; lineage; birth.
However I have seen it used in such a way that it is doubtful that it means any of those things in certain contexts.
Here's an example sentence:
今日はマオ氏のアーバンカーで送ってもらった♪(´ε` )
What does 氏 mean here?
Note: Mao is a very famous Japanese singer.

A:

The list of respectful honorifics, with more respectful at the top, goes like this:

殿{どの}
氏{し} 
様{さま}
さん
チャン、くん
(not putting an honorific)

There are more, with obscurities like 刀自{とうじ}, and you can see a full list here (in Japanese).
殿{どの} means "lord", which you might use in a sense like "Lord Byron". Items 2 down to 4 can, and often are, all translated as variants of "Mr", or "Mrs/Ms".
However, this is one of those situations where the English is only a starting guide for the learner, but the translation breaks down pretty quickly. 
The first notable differences is that the Japanese is not gender specific, except for number 5, where ちゃん is usually female and 君{くん} is usually male. But not always.
Another difference is that they can be applied to first names as well, which often trips English learners of Japanese. There are giggles at the thought that someone might call you "Mr Bob", but they don't mean "Mr", it's just a respectful way of addressing someone. ボブさん is fine, so the sooner you can get away from the "Mr" correlate, the better.
(Note that it's pretty rare for a Japanese person to refer to another Japanese person by attaching さん to what English speakers would call a "first" name, but it's not because it's necessarily wrong to do so, just that it's usually it's more proper and respectful to use the family name.)
Another difference is that they aren't really used on their own. So, for example, in English, you might say to someone "Hey mister!", you wouldn't call out in Japanese 「おい、さん!」.
Okay, so, all that said, what does it imply if you use 氏{し} with someone's name instead of さん? Well, since we can throw out trying to translate it to English, we can simply say this: it's just more respectful than さん. If you look at it like that, you can't go wrong.
There are some circumstances, like work or other places, where 氏{し} might be standard as part of the keigo used. However, in the sentence in the question, it's a matter of a fan adoring a pop star. Using 氏{し} conveys that higher respect, and also smacks just a little of old-school hierarchy. It's like referring to David Bowie as something like Master Bowie, if you happened to be a fan of his.
Part of the confusion in the question is that 氏{し} also has other definitions, like "lineage" and so on. That's just a function of the kanji carrying a meaning, as kanji characters do. The kanji 様{さま} also has various meanings, like "manner, kind, appearance", but that doesn't impact that it's used as an honorific, although it might have factored into why that kanji got used in the first place. But don't take the kanji definitions too far. 様{さま} also means "mess, sorry state, plight", which are definitions that have nothing to do with its use as an honorific.
Hope that helps.

ASSISTANT
To analyze the cultural and linguistic nuances of Japanese honorifics, let's explore the context and implications of using 氏 (shi) after a person's name, comparing it to other common honorifics like さん (san) and 様 (sama).

[sys1]
氏 (shi) is a formal honorific used in Japanese to show respect, akin to titles in English like "Mister" but with unique cultural nuances.
[end sys1]

[sys2]
**2.1 Understand the Problem:**
The task is to comprehend the usage of 氏 in a contemporary context, especially how it contrasts with other honorifics.

*Reflection:* 
"I understand 氏 is more respectful than さん but less so than 様. Yet, how does its usage transform in different settings, like among celebrities versus colleagues?"

*Creative Perspective:* 
"Could the use of 氏 denote a traditional respect linked to professional or elder hierarchy, extending beyond common courtesy?"

**2.2 Analyze the Information:**
The honorifics imply levels of respect and familiarity. 氏, in particular, conveys a high level of formal respect, perhaps even indicating reverence when used by fans for celebrities.

*Reflection:* 
"Am I accurately considering the implications of hierarchy and formality within Japanese culture? Are there scenarios where choosing one honorific over another could significantly alter the meaning?"

*Creative Perspective:* 
"Could these honorifics reveal broader societal norms, such as the balance between tradition and modernity in Japan, or the emotional distance kept in professional relationships?"

**2.3 Generate Hypotheses:**
1. 氏 is used to emphasize hierarchy and formality, particularly in formal or professional contexts. (Confidence: 0.8, Creative: 0.5)
2. It is chosen over さん to express extra respect towards someone of notable status, like celebrities. (Confidence: 0.9, Creative: 0.6)
3. Using 氏 with a celebrity's name implies admiration and elevated regard beyond typical social interaction. (Confidence: 0.7, Creative: 0.7)
4. In work settings, 氏 might be standard due to traditional keigo, Japanese respectful language practices. (Confidence: 0.6, Creative: 0.5)
5. There might be regional variations in preference and usage between honorifics. (Confidence: 0.3, Creative: 0.6)
6. The use of 氏 reflects an old-school hierarchy, nodding to historical usage patterns. (Confidence: 0.5, Creative: 0.8)
7. The usage of different honorifics expresses subtle social dynamics and distances in Japanese culture. (Confidence: 0.8, Creative: 0.6)
8. Multiple meanings of kanji contribute to nuanced usage in modern language. (Confidence: 0.4, Creative: 0.4)
9. Younger generations might shift preferences in honorifics as sociocultural norms evolve. (Confidence: 0.5, Creative: 0.7)
10. The inclusion of 氏 over others could be a stylistic choice for formality. (Confidence: 0.6, Creative: 0.5)

*Reflection:* 
"Have I thoroughly considered how these different cultural and social patterns impact the usage of honorifics?"

*Creative Perspective:* 
"What might this suggest about the evolving use of language in embodying respect, and how could this reflect broader societal changes?"

**2.4 Anticipate Future Steps and Obstacles:**
*Objective:* Predict cultural shifts or obstacles in using and understanding honorifics.

*Reflection:* 
"Will the growing influence of Western culture affect Japan's use of honorifics? Is there resistance to changing traditional speech patterns?"

*Creative Perspective:* 
"Could a deeper understanding of these honorifics aid in better cross-cultural communication solutions?"

**2.5 Evaluate Hypotheses:**
Assessment will focus on determining which hypotheses provide the most comprehensive understanding.

*Reflection:* 
"Am I detached in evaluating the biases or cultural influences present in these honorifics?"

*Creative Perspective:* 
"Which hypothesis brings to light unseen opportunities or challenges in linguistic application and cultural evolution?"

**2.6 Select the Best Hypothesis:**
The most strategic observation recognizes that the use of 氏 conveys deep respect, especially for figures of high status.

*Creative Perspective:* 
"This insight could illustrate changing cultural dynamics as well as honorifics' roles in reflecting these shifts."

**2.7 Implement the Hypothesis:**
Consider incorporating this understanding into language studies, fostering nuanced communication skills in diverse environments, and systemic appreciation for cultural contexts.

*Reflection:* 
"Is this approach practical for understanding or teaching Japanese honorifics?"

*Creative Perspective:* 
"Can we exploit these insights to enhance cross-cultural engagements or learning modules?"

**2.8 Monitor and Review Progress:**
Track how modern interactions might alter the incorporation or perception of traditional honorifics.

*Reflection:* 
"What new interactions could benefit from these insights into Japanese honorifics?"

*Creative Perspective:* 
"What dynamic patterns have emerged, and how might they redefine future language practices?"

**2.9 Reflect and Capture Insights:**
Summarize takeaways about linguistic heritage's role in shaping modern communication and cultural respect.

*Reflection:* 
"What novel understandings have been captured regarding traditional and contemporary honorifics?"

*Creative Perspective:* 
"How might similar analyses apply to other culturally rich but dynamically evolving linguistic elements?"

[end sys2]

[sys1]
Using 氏 illustrates a higher level of respect when addressing someone of significant status, like a celebrity, reflecting cultural hierarchies and nuances in Japanese society.
[end sys1]

turns-00049.parquet:4104

c79fb8bdbfd0bb65cac9f5a8
turn 1/1o1-mini-2024-09-12EnglishSouth Korea15125 words
degenerate_repetitionAbsentFinal dense release
USER
// ==UserScript==
// @name         종합 웹 크롤러 8.6 초격차 개선 버전
// @namespace    http://tampermonkey.net/
// @version      8.6.2
// @description  고급 기능을 갖춘 웹 크롤러로 더 빠르고 많은 검색 결과를 실시간으로 수집하고 자세한 분석을 제공합니다 (초격차 개선 버전)
// @author       YourName
// @match        *://www.google.com/search*
// @match        *://www.bing.com/search*
// @match        *://search.daum.net/search*
// @match        *://search.naver.com/search*
// @match        *://search.yahoo.com/search*
// @match        *://duckduckgo.com/*
// @match        *://www.startpage.com/do/search*
// @match        *://www.ecosia.org/search*
// @match        *://www.qwant.com/*
// @match        *://ahmia.fi/*
// @match        *://torchsearch.de/*
// @match        *://notracker.org/*
// @grant        GM_xmlhttpRequest
// @grant        GM_addStyle
// @grant        GM_setValue
// @grant        GM_getValue
// @grant        GM_notification
// @connect      *
// @require      https://cdnjs.cloudflare.com/ajax/libs/xlsx/0.18.5/xlsx.full.min.js
// @require      https://cdn.jsdelivr.net/npm/chart.js
// ==/UserScript==

(function() {
    'use strict';

    // *******************************
    // API 키 설정 (필요 시 본인의 API 키로 변경)
    // *******************************
    const WHOIS_API_KEY = 'YOUR_JSONWHOIS_API_KEY'; // 여기에 본인의 JSONWHOIS API 키를 입력하세요.

    GM_addStyle(`
        /* UI 전반적인 스타일 개선 */
        #crawler-container {
            position: fixed;
            top: 20px;
            right: 20px;
            background-color: #ffffff;
            border: 3px solid #2196F3;
            padding: 15px;
            z-index: 10000;
            width: 700px;
            max-height: 85vh;
            overflow: hidden;
            box-shadow: 0 6px 20px rgba(0,0,0,0.3);
            border-radius: 10px;
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
            font-size: 14px;
            resize: both;
            display: flex;
            flex-direction: column;
            transition: all 0.3s ease;
        }
        #crawler-container header {
            cursor: move;
            background-color: #2196F3;
            color: white;
            padding: 10px 15px;
            border-radius: 8px 8px 0 0;
            text-align: center;
            font-size: 20px;
            font-weight: bold;
            display: flex;
            justify-content: space-between;
            align-items: center;
        }
        #crawler-container header .title {
            flex-grow: 1;
        }
        #crawler-container header .close-btn {
            cursor: pointer;
            font-size: 24px;
            color: #FF5252;
            margin-left: 15px;
        }
        #crawler-container .tabs {
            display: flex;
            border-bottom: 3px solid #2196F3;
            margin-top: 10px;
        }
        #crawler-container .tab {
            flex: 1;
            padding: 10px 0;
            text-align: center;
            cursor: pointer;
            background-color: #E3F2FD;
            border-right: 1px solid #BBDEFB;
            font-weight: bold;
            transition: background-color 0.3s, color 0.3s;
            font-size: 14px;
        }
        #crawler-container .tab:last-child {
            border-right: none;
        }
        #crawler-container .tab.active {
            background-color: #FFFFFF;
            border-bottom: 4px solid #2196F3;
            color: #2196F3;
        }
        #crawler-container .tab-content {
            display: none;
            padding: 15px;
            overflow-y: auto;
            flex-grow: 1;
        }
        #crawler-container .tab-content.active {
            display: block;
        }
        #crawler-container button {
            padding: 8px 14px;
            margin: 5px 3px;
            border: none;
            border-radius: 5px;
            background-color: #2196F3;
            color: white;
            cursor: pointer;
            transition: background-color 0.3s;
            font-size: 14px;
        }
        #crawler-container button:hover {
            background-color: #1976D2;
        }
        #crawler-container button.export-btn {
            background-color: #4CAF50;
        }
        #crawler-container button.export-btn:hover {
            background-color: #388E3C;
        }
        #crawler-container button.pause-btn {
            background-color: #FFC107;
        }
        #crawler-container button.pause-btn:hover {
            background-color: #FFA000;
        }
        #crawler-container .options,
        #crawler-container .filters,
        #crawler-container .exclude-domains,
        #crawler-container .advanced-options,
        #crawler-container .controls,
        #crawler-container .search-engines {
            margin-bottom: 15px;
            display: flex;
            flex-wrap: wrap;
            align-items: center;
            justify-content: space-between;
        }
        #crawler-container .options label,
        #crawler-container .advanced-options label,
        #crawler-container .controls label,
        #crawler-container .search-engines label {
            margin-right: 15px;
            display: inline-flex;
            align-items: center;
            font-weight: normal;
            font-size: 14px;
        }
        #crawler-container .options input[type="checkbox"],
        #crawler-container .advanced-options input[type="checkbox"],
        #crawler-container .controls input[type="number"],
        #crawler-container .search-engines select {
            margin-right: 8px;
        }
        #crawler-container input[type="text"],
        #crawler-container textarea,
        #crawler-container select {
            width: 100%;
            padding: 8px;
            margin: 6px 0 10px 0;
            border: 1px solid #B0BEC5;
            border-radius: 5px;
            font-size: 14px;
        }
        #crawler-container table {
            border-collapse: collapse;
            width: 100%;
            margin-top: 10px;
            font-size: 14px;
        }
        #crawler-container th, #crawler-container td {
            padding: 10px;
            border: 1px solid #E0E0E0;
            text-align: left;
            vertical-align: top;
        }
        #crawler-container th {
            background-color: #2196F3;
            color: white;
            position: sticky;
            top: 0;
            z-index: 1;
            cursor: pointer;
        }
        #crawler-container .log {
            max-height: 180px;
            overflow-y: auto;
            background-color: #E3F2FD;
            padding: 10px;
            border: 1px solid #81D4FA;
            border-radius: 5px;
            font-size: 14px;
            white-space: pre-wrap;
        }
        #crawler-container progress {
            width: 80%;
            height: 20px;
            margin-right: 10px;
            border-radius: 5px;
        }
        #crawler-container .status {
            margin-top: 10px;
            font-weight: bold;
            font-size: 14px;
        }
        #crawler-container .chart-container {
            position: relative;
            height: 250px;
            width: 100%;
            margin-top: 20px;
        }
        #crawler-container .notification-area {
            flex-direction: row;
            align-items: center;
            width: 100%;
        }
        @media (max-width: 800px) {
            #crawler-container {
                width: 95%;
                right: 2.5%;
            }
            #crawler-container .controls,
            #crawler-container .options,
            #crawler-container .advanced-options,
            #crawler-container .notification-area,
            #crawler-container .search-engines {
                flex-direction: column;
                align-items: flex-start;
            }
            #crawler-container .search-engines select {
                width: 100%;
            }
            #crawler-container progress {
                width: 100%;
            }
        }
        /* WHOIS Modal 스타일 */
        #whois-modal {
            display: none;
            position: fixed;
            z-index: 10001;
            left: 50%;
            top: 50%;
            transform: translate(-50%, -50%);
            width: 90%;
            max-width: 900px;
            height: 80vh;
            background-color: #ffffff;
            border: 3px solid #2196F3;
            border-radius: 10px;
            box-shadow: 0 6px 20px rgba(0,0,0,0.3);
            overflow: hidden;
            flex-direction: column;
            display: flex;
        }
        #whois-modal header {
            background-color: #2196F3;
            color: white;
            padding: 12px 20px;
            cursor: move;
            display: flex;
            justify-content: space-between;
            align-items: center;
        }
        #whois-modal header .close-modal-btn {
            cursor: pointer;
            font-size: 24px;
            color: #FF5252;
        }
        #whois-modal .modal-content {
            padding: 20px;
            overflow-y: auto;
            flex-grow: 1;
            background-color: #E3F2FD;
        }
        /* Tooltip 스타일 */
        .preview-tooltip {
            position: absolute;
            background-color: #ffffff;
            border: 1px solid #90CAF9;
            border-radius: 5px;
            padding: 8px;
            z-index: 10002;
            box-shadow: 0 4px 12px rgba(0,0,0,0.3);
            display: none;
            width: 300px;
        }
        .preview-tooltip iframe {
            width: 100%;
            height: 200px;
            border: none;
            border-radius: 5px;
        }
    `);

    const container = document.createElement('div');
    container.id = 'crawler-container';
    container.innerHTML = `
        <header>
            <span class="title">🔥 웹 크롤러 8.6</span>
            <span class="close-btn" title="닫기">&times;</span>
        </header>
        <div class="tabs">
            <div class="tab active" data-tab="settings">설정</div>
            <div class="tab" data-tab="results">결과</div>
            <div class="tab" data-tab="logs">로그</div>
            <div class="tab" data-tab="analytics">분석</div>
            <div class="tab" data-tab="about">정보</div>
        </div>
        <div class="tab-content active" id="settings">
            <div class="notification-area">
                <button id="startBtn" title="크롤링 시작">▶️ 시작</button>
                <button id="pauseBtn" class="pause-btn" title="크롤링 일시정지/재개">⏸️ 일시정지</button>
                <button id="stopBtn" title="크롤링 중지">⏹️ 중지</button>
                <button id="resetBtn" title="크롤링 초기화">🔄 초기화</button>
                <button id="exportBtn" class="export-btn" title="결과 내보내기">💾 내보내기</button>
                <button id="clearLogsBtn" title="로그 초기화">🧹 로그 초기화</button>
            </div>
            <div class="search-engines">
                <label for="searchEngineSelect">검색 엔진 선택:</label>
                <select id="searchEngineSelect">
                    <option value="google" selected>Google</option>
                    <option value="bing">Bing</option>
                    <option value="daum">Daum</option>
                    <option value="naver">Naver</option>
                    <option value="yahoo">Yahoo</option>
                    <option value="duckduckgo">DuckDuckGo</option>
                    <option value="startpage">StartPage</option>
                    <option value="ecosia">Ecosia</option>
                    <option value="qwant">Qwant</option>
                    <option value="ahmia">Ahmia (Tor)</option>
                    <option value="torch">Torch (Tor)</option>
                    <option value="notracker">NOTRACKER (Tor)</option>
                </select>
            </div>
            <div class="options">
                <label><input type="checkbox" id="toggleHTML" checked> HTML 가져오기</label>
                <label><input type="checkbox" id="toggleImages" checked> 이미지 가져오기</label>
                <label><input type="checkbox" id="toggleAds" checked> 광고 제외</label>
                <label><input type="checkbox" id="toggleTechStack" checked> 기술 스택 분석</label>
                <label><input type="checkbox" id="toggleOpenGraph" checked> OpenGraph 정보 가져오기</label>
                <label><input type="checkbox" id="toggleSecurityHeaders" checked> 보안 헤더 분석</label>
                <label><input type="checkbox" id="toggleDomainAge" checked> 도메인 연령 분석</label>
            </div>
            <div class="filters">
                <label for="filterInput">필터 단어 (정규식 또는 단어, 쉼표로 구분):</label>
                <input type="text" id="filterInput" placeholder="예: 기부, 광고, /promo/i">
            </div>
            <div class="exclude-domains">
                <label for="excludeDomainsInput">제외할 도메인 (쉼표로 구분):</label>
                <input type="text" id="excludeDomainsInput" placeholder="예: facebook.com, youtube.com">
            </div>
            <div class="advanced-options">
                <label for="duplicateThreshold">중복 허용 횟수:</label>
                <input type="number" id="duplicateThreshold" value="2" min="1" style="width: 70px;">
                <label for="retryAttempts">재시도 횟수:</label>
                <input type="number" id="retryAttempts" value="3" min="1" style="width: 70px;">
            </div>
            <div style="margin-top:15px;">
                <label for="progressBar">진행률:</label>
                <progress id="progressBar" value="0" max="100"></progress>
                <span id="progressText">0%</span>
            </div>
            <div class="status">
                현재 페이지: <span id="currentPage">0</span> /
                총 페이지: <span id="totalPages">0</span>
                <br>
                방문된 사이트: <span id="visitedCount">0</span>
                <br>
                총 요청 수: <span id="totalRequests">0</span>
                <br>
                성공 요청 수: <span id="successfulRequests">0</span>
                <br>
                실패 요청 수: <span id="failedRequests">0</span>
                <br>
                경과 시간: <span id="elapsedTime">00:00:00</span>
                <br>
                예상 남은 시간: <span id="remainingTime">00:00:00</span>
            </div>
        </div>
        <div class="tab-content" id="results">
            <div style="margin-top:10px; max-height: 350px; overflow: auto;">
                <table id="resultsTable">
                    <thead>
                        <tr>
                            <th data-sort="0">사이트 이름 &#x25B2;&#x25BC;</th>
                            <th data-sort="1">주소 &#x25B2;&#x25BC;</th>
                            <th data-sort="2">설명 &#x25B2;&#x25BC;</th>
                            <th>이미지</th>
                            <th>HTML 링크</th>
                            <th>WHOIS 정보</th>
                            <th data-sort="6">페이지 로딩 시간 (ms) &#x25B2;&#x25BC;</th>
                            <th>언어</th>
                            <th>메타 키워드</th>
                            <th>메타 robots</th>
                            <th>OpenGraph</th>
                            <th>보안 헤더</th>
                            <th>도메인 연령</th>
                            <th>기술 스택</th>
                        </tr>
                    </thead>
                    <tbody id="resultsBody">
                    </tbody>
                </table>
            </div>
            <div style="margin-top:15px;">
                <input type="text" id="searchResultsInput" placeholder="결과 검색...">
            </div>
        </div>
        <div class="tab-content" id="logs">
            <div class="log" id="log">
                <strong>로그:</strong>
            </div>
        </div>
        <div class="tab-content" id="analytics">
            <div class="chart-container">
                <canvas id="crawlChart"></canvas>
            </div>
            <div class="chart-container">
                <canvas id="loadTimeChart"></canvas>
            </div>
            <div class="chart-container">
                <canvas id="domainDistributionChart"></canvas>
            </div>
            <div class="chart-container">
                <canvas id="errorRateChart"></canvas>
            </div>
            <div class="chart-container">
                <canvas id="cumulativeVisitsChart"></canvas>
            </div>
            <div class="chart-container">
                <canvas id="keywordDistributionChart"></canvas>
            </div>
            <div class="chart-container">
                <canvas id="languageDistributionChart"></canvas>
            </div>
            <div class="chart-container">
                <canvas id="techStackChart"></canvas>
            </div>
            <div class="chart-container">
                <canvas id="domainAgeChart"></canvas>
            </div>
            <div id="whois-modal">
                <header>
                    <span>WHOIS 정보</span>
                    <span class="close-modal-btn" title="닫기">&times;</span>
                </header>
                <div class="modal-content" id="whoisContent">
                    <!-- WHOIS 정보가 여기에 표시됩니다 -->
                </div>
            </div>
        </div>
        <div class="tab-content" id="about">
            <h2>웹 크롤러 8.6 정보</h2>
            <p>종합 웹 크롤러는 다양한 검색 엔진에서 빠르게 검색 결과를 수집하고 심층 분석할 수 있는 도구입니다. 사용자의 편의성과 데이터 가독성을 극대화하여 초격차로 개선된 버전입니다.</p>
            <ul>
                <li>지원하는 검색 엔진: Google, Bing, Daum, Naver, Yahoo, DuckDuckGo, StartPage, Ecosia, Qwant, Ahmia (Tor), Torch (Tor), NOTRACKER (Tor)</li>
                <li>실시간 검색어 감지 및 고속 크롤링</li>
                <li>고급 필터링 및 제외 옵션 제공</li>
                <li>결과를 XLSX, CSV, JSON 형식으로 내보내기</li>
                <li>시각화된 데이터 차트 및 그래프 제공</li>
                <li>사용자 친화적인 인터페이스 및 반응형 디자인</li>
                <li>결과 테이블 정렬 및 실시간 검색 기능 추가</li>
                <li>상세한 로그 제공</li>
                <li>페이지 로딩 시간 및 언어 분석</li>
                <li>WHOIS 정보 연동 및 즉시 보기 기능</li>
                <li>도메인 연령 분석 기능 추가</li>
                <li>추가적인 보안 헤더 분석 기능</li>
                <li>기술 스택 분석 기능 강화</li>
                <li>다양한 알림 방식 지원</li>
                <li>자동 스크롤 및 실시간 업데이트</li>
                <li>고급 에러 핸들링 및 재시도 로직 강화</li>
                <li>로그 초기화 및 결과 검색 기능 추가</li>
                <li>추가 분석 탭에서 다양한 그래프 제공</li>
                <li>도메인 분포 및 오류 발생률 분석</li>
                <li>누적 방문 횟수 추적</li>
                <li>HTML 링크 클릭 시 UI 내에서 사이트 미리보기 제공</li>
                <li>마우스 호버 시 사이트 미리보기 표시</li>
                <li>WHOIS 정보 바로보기 및 상세 분석 기능 추가</li>
                <li>추가 메타 정보 수집 및 분석 기능 강화</li>
                <li>더 빠르고 많은 사이트 정보 수집 기능 추가</li>
                <li>사이트 기술 스택 심층 분석 기능 추가</li>
            </ul>
            <p><strong>버전:</strong> 8.6.2</p>
            <p><strong>제작자:</strong> YourName</p>
            <p><strong>문의:</strong> your.email@example.com</p>
        </div>
    `;
    document.body.appendChild(container);

    // 드래그 기능
    (function makeDraggable(elmnt) {
        const header = elmnt.querySelector('header');
        const closeBtn = elmnt.querySelector('.close-btn');
        let pos1 = 0, pos2 = 0, pos3 = 0, pos4 = 0;
        header.onmousedown = dragMouseDown;

        closeBtn.onclick = () => {
            elmnt.style.display = 'none';
            log('🗑 크롤러 창을 닫았습니다.');
        }

        function dragMouseDown(e) {
            e = e || window.event;
            e.preventDefault();
            pos3 = e.clientX;
            pos4 = e.clientY;
            document.onmouseup = closeDragElement;
            document.onmousemove = elementDrag;
        }

        function elementDrag(e) {
            e = e || window.event;
            e.preventDefault();
            pos1 = pos3 - e.clientX;
            pos2 = pos4 - e.clientY;
            pos3 = e.clientX;
            pos4 = e.clientY;
            elmnt.style.top = (elmnt.offsetTop - pos2) + "px";
            elmnt.style.left = (elmnt.offsetLeft - pos1) + "px";
        }

        function closeDragElement() {
            document.onmouseup = null;
            document.onmousemove = null;
        }
    })(container);

    // 탭 설정
    (function setupTabs() {
        const tabs = container.querySelectorAll('.tab');
        const tabContents = container.querySelectorAll('.tab-content');

        tabs.forEach(tab => {
            tab.addEventListener('click', () => {
                tabs.forEach(t => t.classList.remove('active'));
                tab.classList.add('active');

                const target = tab.getAttribute('data-tab');
                tabContents.forEach(content => {
                    if(content.id === target){
                        content.classList.add('active');
                    } else {
                        content.classList.remove('active');
                    }
                });
            });
        });
    })();

    // 변수 초기화
    let isRunning = false;
    let isPaused = false;
    let currentPage = 1;
    let totalPages = 0;
    let results = [];
    let searchQuery = '';
    let searchEngine = 'google';
    let visitedLinks = new Map();
    let logMessages = [];
    let filterPatterns = [];
    let excludeDomains = [];
    let duplicateThreshold = 2;
    let retryAttempts = 3;
    let retryInterval = 100; // 고정적으로 100ms 설정
    let startTime = null;
    let elapsedInterval = null;
    let crawlChart = null;
    let loadTimeChart = null;
    let domainDistributionChart = null;
    let errorRateChart = null;
    let cumulativeVisitsChart = null;
    let keywordDistributionChart = null;
    let languageDistributionChart = null;
    let techStackChart = null;
    let domainAgeChart = null;
    let crawlData = {
        labels: [],
        datasets: [{
            label: '방문 횟수',
            data: [],
            backgroundColor: 'rgba(33, 150, 243, 0.6)',
            borderColor: 'rgba(33, 150, 243, 1)',
            borderWidth: 1
        },
        {
            label: '평균 페이지 로딩 시간 (ms)',
            data: [],
            backgroundColor: 'rgba(76, 175, 80, 0.6)',
            borderColor: 'rgba(76, 175, 80, 1)',
            borderWidth: 1
        }]
    };
    let loadTimeData = {
        labels: [],
        datasets: [{
            label: '페이지 로딩 시간 (ms)',
            data: [],
            backgroundColor: 'rgba(255, 193, 7, 0.6)',
            borderColor: 'rgba(255,193,7,1)',
            borderWidth: 1
        }]
    };
    let domainDistributionData = {
        labels: [],
        datasets: [{
            label: '도메인 분포',
            data: [],
            backgroundColor: [
                'rgba(33, 150, 243, 0.6)',
                'rgba(255, 87, 34, 0.6)',
                'rgba(76, 175, 80, 0.6)',
                'rgba(156, 39, 176, 0.6)',
                'rgba(255, 152, 0, 0.6)',
                'rgba(244, 67, 54, 0.6)',
                'rgba(158, 158, 158, 0.6)'
            ],
            borderColor: 'rgba(33, 150, 243, 1)',
            borderWidth: 1
        }]
    };
    let errorRateData = {
        labels: [],
        datasets: [{
            label: '오류 발생 수',
            data: [],
            backgroundColor: 'rgba(255, 99, 132, 0.6)',
            borderColor: 'rgba(255, 99, 132,1)',
            borderWidth: 1
        }]
    };
    let cumulativeVisitsData = {
        labels: [],
        datasets: [{
            label: '누적 방문 횟수',
            data: [],
            backgroundColor: 'rgba(3, 169, 244, 0.6)',
            borderColor: 'rgba(3, 169, 244,1)',
            borderWidth: 1
        }]
    };
    let keywordDistributionData = {
        labels: [],
        datasets: [{
            label: '키워드 분포',
            data: [],
            backgroundColor: [
                'rgba(63, 81, 181, 0.6)',
                'rgba(255, 152, 0, 0.6)',
                'rgba(76, 175, 80, 0.6)',
                'rgba(244, 67, 54, 0.6)',
                'rgba(33, 150, 243, 0.6)',
                'rgba(153, 102, 255, 0.6)'
            ],
            borderColor: 'rgba(63, 81, 181,1)',
            borderWidth: 1
        }]
    };
    let languageDistributionData = {
        labels: [],
        datasets: [{
            label: '언어 분포',
            data: [],
            backgroundColor: [
                'rgba(38, 166, 154, 0.6)',
                'rgba(211, 47, 47, 0.6)',
                'rgba(3, 169, 244, 0.6)',
                'rgba(255, 193, 7, 0.6)',
                'rgba(156, 39, 176, 0.6)',
                'rgba(0, 188, 212, 0.6)'
            ],
            borderColor: 'rgba(38, 166, 154,1)',
            borderWidth: 1
        }]
    };
    let techStackData = {
        labels: [],
        datasets: [{
            label: '기술 스택 분포',
            data: [],
            backgroundColor: [
                'rgba(103, 58, 183, 0.6)',
                'rgba(255, 202, 40, 0.6)',
                'rgba(0, 150, 136, 0.6)',
                'rgba(233, 30, 99, 0.6)',
                'rgba(245, 124, 0, 0.6)',
                'rgba(255, 235, 59, 0.6)'
            ],
            borderColor: 'rgba(103, 58, 183,1)',
            borderWidth: 1
        }]
    };
    let domainAgeData = {
        labels: [],
        datasets: [{
            label: '도메인 연령 분포 (년)',
            data: [],
            backgroundColor: [
                'rgba(255, 159, 64, 0.6)',
                'rgba(75, 192, 192, 0.6)',
                'rgba(54, 162, 235, 0.6)',
                'rgba(153, 102, 255, 0.6)',
                'rgba(255, 99, 132, 0.6)'
            ],
            borderColor: 'rgba(255, 159, 64,1)',
            borderWidth: 1
        }]
    };

    // 요소 참조
    const startBtn = document.getElementById('startBtn');
    const pauseBtn = document.getElementById('pauseBtn');
    const stopBtn = document.getElementById('stopBtn');
    const resetBtn = document.getElementById('resetBtn');
    const exportBtn = document.getElementById('exportBtn');
    const clearLogsBtn = document.getElementById('clearLogsBtn');
    const progressBar = document.getElementById('progressBar');
    const progressText = document.getElementById('progressText');
    const resultsBody = document.getElementById('resultsBody');
    const logContainer = document.getElementById('log');
    const currentPageElem = document.getElementById('currentPage');
    const totalPagesElem = document.getElementById('totalPages');
    const toggleHTML = document.getElementById('toggleHTML');
    const toggleImages = document.getElementById('toggleImages');
    const toggleAds = document.getElementById('toggleAds');
    const toggleTechStack = document.getElementById('toggleTechStack');
    const toggleOpenGraph = document.getElementById('toggleOpenGraph');
    const toggleSecurityHeaders = document.getElementById('toggleSecurityHeaders');
    const toggleDomainAge = document.getElementById('toggleDomainAge');
    const filterInput = document.getElementById('filterInput');
    const excludeDomainsInput = document.getElementById('excludeDomainsInput');
    const duplicateThresholdInput = document.getElementById('duplicateThreshold');
    const retryAttemptsInput = document.getElementById('retryAttempts');
    const visitedCountElem = document.getElementById('visitedCount');
    const elapsedTimeElem = document.getElementById('elapsedTime');
    const remainingTimeElem = document.getElementById('remainingTime');
    const crawlChartCtx = document.getElementById('crawlChart').getContext('2d');
    const loadTimeChartCtx = document.getElementById('loadTimeChart').getContext('2d');
    const domainDistributionChartCtx = document.getElementById('domainDistributionChart').getContext('2d');
    const errorRateChartCtx = document.getElementById('errorRateChart').getContext('2d');
    const cumulativeVisitsChartCtx = document.getElementById('cumulativeVisitsChart').getContext('2d');
    const keywordDistributionChartCtx = document.getElementById('keywordDistributionChart').getContext('2d');
    const languageDistributionChartCtx = document.getElementById('languageDistributionChart').getContext('2d');
    const techStackChartCtx = document.getElementById('techStackChart').getContext('2d');
    const domainAgeChartCtx = document.getElementById('domainAgeChart').getContext('2d');
    const searchEngineSelect = document.getElementById('searchEngineSelect');
    const searchResultsInput = document.getElementById('searchResultsInput');
    const whoisModal = document.getElementById('whois-modal');
    const whoisContent = document.getElementById('whoisContent');
    const closeModalBtn = whoisModal.querySelector('.close-modal-btn');

    // 미리보기 툴팁 생성
    const tooltip = document.createElement('div');
    tooltip.className = 'preview-tooltip';
    document.body.appendChild(tooltip);

    // 이벤트 리스너 등록
    startBtn.addEventListener('click', startCrawling);
    pauseBtn.addEventListener('click', togglePause);
    stopBtn.addEventListener('click', stopCrawling);
    resetBtn.addEventListener('click', resetCrawling);
    exportBtn.addEventListener('click', exportResults);
    clearLogsBtn.addEventListener('click', clearLogs);
    filterInput.addEventListener('input', filterResults);
    excludeDomainsInput.addEventListener('input', updateExcludeDomains);
    duplicateThresholdInput.addEventListener('change', updateDuplicateThreshold);
    retryAttemptsInput.addEventListener('change', updateRetryAttempts);
    searchEngineSelect.addEventListener('change', updateSearchEngine);
    searchResultsInput.addEventListener('input', filterResults);
    closeModalBtn.addEventListener('click', () => {
        whoisModal.style.display = 'none';
        whoisContent.innerHTML = '';
    });

    window.addEventListener('beforeunload', () => {
        resetCrawling();
    });

    // 로그 및 크롤 데이터 로드
    loadLogs();
    loadCrawlData();
    loadSettings();

    // 차트 초기화 함수
    function initializeChart() {
        crawlChart = new Chart(crawlChartCtx, {
            type: 'bar',
            data: crawlData,
            options: {
                responsive: true,
                maintainAspectRatio: false,
                scales: {
                    y: {
                        beginAtZero: true,
                        ticks: {
                            precision:0
                        }
                    }
                },
                plugins: {
                    legend: {
                        display: true,
                        position: 'top'
                    },
                    tooltip: {
                        enabled: true
                    }
                }
            }
        });

        loadTimeChart = new Chart(loadTimeChartCtx, {
            type: 'line',
            data: loadTimeData,
            options: {
                responsive: true,
                maintainAspectRatio: false,
                scales: {
                    y: {
                        beginAtZero: true,
                        ticks: {
                            precision:0
                        }
                    }
                },
                plugins: {
                    legend: {
                        display: true,
                        position: 'top'
                    },
                    tooltip: {
                        enabled: true
                    }
                }
            }
        });

        domainDistributionChart = new Chart(domainDistributionChartCtx, {
            type: 'pie',
            data: domainDistributionData,
            options: {
                responsive: true,
                maintainAspectRatio: false,
                plugins: {
                    legend: {
                        display: true,
                        position: 'right'
                    },
                    tooltip: {
                        enabled: true
                    }
                }
            }
        });

        errorRateChart = new Chart(errorRateChartCtx, {
            type: 'bar',
            data: errorRateData,
            options: {
                responsive: true,
                maintainAspectRatio: false,
                scales: {
                    y: {
                        beginAtZero: true,
                        ticks: {
                            precision:0
                        }
                    }
                },
                plugins: {
                    legend: {
                        display: false
                    },
                    tooltip: {
                        enabled: true
                    }
                }
            }
        });

        cumulativeVisitsChart = new Chart(cumulativeVisitsChartCtx, {
            type: 'line',
            data: cumulativeVisitsData,
            options: {
                responsive: true,
                maintainAspectRatio: false,
                scales: {
                    y: {
                        beginAtZero: true,
                        ticks: {
                            precision:0
                        }
                    }
                },
                plugins: {
                    legend: {
                        display: true,
                        position: 'top'
                    },
                    tooltip: {
                        enabled: true
                    }
                }
            }
        });

        keywordDistributionChart = new Chart(keywordDistributionChartCtx, {
            type: 'doughnut',
            data: keywordDistributionData,
            options: {
                responsive: true,
                maintainAspectRatio: false,
                plugins: {
                    legend: {
                        display: true,
                        position: 'right'
                    },
                    tooltip: {
                        enabled: true
                    }
                }
            }
        });

        languageDistributionChart = new Chart(languageDistributionChartCtx, {
            type: 'pie',
            data: languageDistributionData,
            options: {
                responsive: true,
                maintainAspectRatio: false,
                plugins: {
                    legend: {
                        display: true,
                        position: 'right'
                    },
                    tooltip: {
                        enabled: true
                    }
                }
            }
        });

        techStackChart = new Chart(techStackChartCtx, {
            type: 'bar',
            data: techStackData,
            options: {
                responsive: true,
                maintainAspectRatio: false,
                scales: {
                    y: {
                        beginAtZero: true,
                        ticks: {
                            precision:0
                        }
                    }
                },
                plugins: {
                    legend: {
                        display: false
                    },
                    tooltip: {
                        enabled: true
                    }
                }
            }
        });

        domainAgeChart = new Chart(domainAgeChartCtx, {
            type: 'bar',
            data: domainAgeData,
            options: {
                responsive: true,
                maintainAspectRatio: false,
                scales: {
                    y: {
                        beginAtZero: true,
                        title: {
                            display: true,
                            text: '연령 (년)'
                        }
                    }
                },
                plugins: {
                    legend: {
                        display: false
                    },
                    tooltip: {
                        enabled: true
                    }
                }
            }
        });
    }
    initializeChart();

    // 설정 로드
    function loadSettings() {
        const storedSearchEngine = GM_getValue('searchEngine', 'google');
        searchEngine = storedSearchEngine;
        searchEngineSelect.value = searchEngine;

        const storedToggleHTML = GM_getValue('toggleHTML', true);
        toggleHTML.checked = storedToggleHTML;

        const storedToggleImages = GM_getValue('toggleImages', true);
        toggleImages.checked = storedToggleImages;

        const storedToggleAds = GM_getValue('toggleAds', true);
        toggleAds.checked = storedToggleAds;

        const storedToggleTechStack = GM_getValue('toggleTechStack', true);
        toggleTechStack.checked = storedToggleTechStack;

        const storedToggleOpenGraph = GM_getValue('toggleOpenGraph', true);
        toggleOpenGraph.checked = storedToggleOpenGraph;

        const storedToggleSecurityHeaders = GM_getValue('toggleSecurityHeaders', true);
        toggleSecurityHeaders.checked = storedToggleSecurityHeaders;

        const storedToggleDomainAge = GM_getValue('toggleDomainAge', true);
        toggleDomainAge.checked = storedToggleDomainAge;

        const storedDuplicateThreshold = GM_getValue('duplicateThreshold', 2);
        duplicateThreshold = storedDuplicateThreshold;
        duplicateThresholdInput.value = duplicateThreshold;

        const storedRetryAttempts = GM_getValue('retryAttempts', 3);
        retryAttempts = storedRetryAttempts;
        retryAttemptsInput.value = retryAttempts;

        const storedFilterInput = GM_getValue('filterInput', '');
        filterInput.value = storedFilterInput;
        updateFilterPatterns();

        const storedExcludeDomainsInput = GM_getValue('excludeDomainsInput', '');
        excludeDomainsInput.value = storedExcludeDomainsInput;
        updateExcludeDomains();
    }

    // 설정 저장 함수
    function saveSettings() {
        GM_setValue('searchEngine', searchEngine);
        GM_setValue('toggleHTML', toggleHTML.checked);
        GM_setValue('toggleImages', toggleImages.checked);
        GM_setValue('toggleAds', toggleAds.checked);
        GM_setValue('toggleTechStack', toggleTechStack.checked);
        GM_setValue('toggleOpenGraph', toggleOpenGraph.checked);
        GM_setValue('toggleSecurityHeaders', toggleSecurityHeaders.checked);
        GM_setValue('toggleDomainAge', toggleDomainAge.checked);
        GM_setValue('duplicateThreshold', duplicateThreshold);
        GM_setValue('retryAttempts', retryAttempts);
        GM_setValue('filterInput', filterInput.value.trim());
        GM_setValue('excludeDomainsInput', excludeDomainsInput.value.trim());
    }

    // 검색 엔진 변경 시 처리
    function updateSearchEngine() {
        searchEngine = searchEngineSelect.value;
        GM_setValue('searchEngine', searchEngine);
        log(`🔄 검색 엔진 변경: ${capitalizeFirstLetter(searchEngine)}`);
    }

    // 다양한 설정 변경 시 설정 저장
    toggleHTML.addEventListener('change', saveSettings);
    toggleImages.addEventListener('change', saveSettings);
    toggleAds.addEventListener('change', saveSettings);
    toggleTechStack.addEventListener('change', saveSettings);
    toggleOpenGraph.addEventListener('change', saveSettings);
    toggleSecurityHeaders.addEventListener('change', saveSettings);
    toggleDomainAge.addEventListener('change', saveSettings);
    filterInput.addEventListener('change', saveSettings);
    excludeDomainsInput.addEventListener('change', saveSettings);

    // 로그 로드
    function loadLogs() {
        const storedLogs = GM_getValue('crawlerLogs', []);
        if (storedLogs.length > 0) {
            logMessages = JSON.parse(storedLogs);
            logContainer.innerHTML = `<strong>로그:</strong><br>` + logMessages.join('<br>');
            logContainer.scrollTop = logContainer.scrollHeight;
        }
    }

    // 필터 패턴 업데이트
    function updateFilterPatterns() {
        const input = filterInput.value.trim();
        filterPatterns = input ? input.split(',').map(word => {
            word = word.trim();
            if (word.startsWith('/') && word.endsWith('/')) {
                try {
                    return new RegExp(word.slice(1, -1), 'i');
                } catch (e) {
                    log(`⚠️ 유효하지 않은 정규식: ${word}`);
                    return null;
                }
            } else {
                return new RegExp(word, 'i');
            }
        }).filter(regex => regex !== null) : [];
        log(`🛠 필터 패턴 업데이트: [${filterPatterns.map(r => r.toString()).join(', ')}]`);
        saveSettings();
    }

    // 제외 도메인 업데이트
    function updateExcludeDomains() {
        const input = excludeDomainsInput.value.trim();
        excludeDomains = input ? input.split(',').map(domain => domain.trim().toLowerCase()) : [];
        log(`🚫 제외 도메인 업데이트: [${excludeDomains.join(', ')}]`);
        saveSettings();
    }

    // 중복 허용 횟수 업데이트
    function updateDuplicateThreshold() {
        const value = parseInt(duplicateThresholdInput.value);
        duplicateThreshold = isNaN(value) || value < 1 ? 2 : value;
        log(`🔄 중복 허용 횟수 설정: ${duplicateThreshold}`);
        saveSettings();
    }

    // 재시도 횟수 업데이트
    function updateRetryAttempts() {
        const value = parseInt(retryAttemptsInput.value);
        retryAttempts = isNaN(value) || value < 1 ? 3 : value;
        log(`🔄 재시도 횟수 설정: ${retryAttempts}`);
        saveSettings();
    }

    // 크롤링 시작 함수
    async function startCrawling() {
        if (isRunning) {
            alert('이미 크롤링이 진행 중입니다.');
            return;
        }
        getSearchQueryAndEngine();
        if (!searchQuery) {
            alert('현재 페이지에서 검색어를 찾을 수 없습니다.');
            log('⚠️ 검색어 미입력 또는 인식 실패.');
            return;
        }
        isRunning = true;
        isPaused = false;
        currentPage = 1;
        totalPages = 0;
        results = [];
        visitedLinks.clear();
        resultsBody.innerHTML = '';
        visitedCountElem.innerText = '0';
        document.getElementById('totalRequests').innerText = '0';
        document.getElementById('successfulRequests').innerText = '0';
        document.getElementById('failedRequests').innerText = '0';
        elapsedTimeElem.innerText = '00:00:00';
        remainingTimeElem.innerText = '00:00:00';
        logMessages = [];
        logContainer.innerHTML = `<strong>로그:</strong><br>`;
        GM_setValue('crawlerLogs', JSON.stringify(logMessages));
        log('✅ 크롤링을 시작합니다.');
        updateDuplicateThreshold();
        updateRetryAttempts();
        await crawlPage();
        startTime = Date.now();
        elapsedInterval = setInterval(updateElapsedTime, 1000);
    }

    // 일시정지/재개 함수
    function togglePause() {
        if (!isRunning) {
            alert('일시정지/재개할 크롤링이 없습니다.');
            return;
        }
        isPaused = !isPaused;
        if (isPaused) {
            log('⏸️ 크롤링을 일시정지하였습니다.');
            pauseBtn.innerText = '▶️ 재개';
            pauseBtn.title = '크롤링 재개';
        } else {
            log('▶️ 크롤링을 재개하였습니다.');
            pauseBtn.innerText = '⏸️ 일시정지';
            pauseBtn.title = '크롤링 일시정지';
            crawlPage();
        }
    }

    // 크롤링 중지 함수
    function stopCrawling() {
        if (!isRunning) {
            alert('중지할 크롤링이 없습니다.');
            return;
        }
        isRunning = false;
        isPaused = false;
        pauseBtn.innerText = '⏸️ 일시정지';
        pauseBtn.title = '크롤링 일시정지';
        clearInterval(elapsedInterval);
        updateProgress();
        log('🚫 크롤링을 중지하였습니다.');
        GM_notification({
            text: '크롤링이 중지되었습니다.',
            title: '웹 크롤러 8.6',
            timeout: 3000
        });
    }

    // 크롤링 초기화 함수
    function resetCrawling() {
        stopCrawling();
        currentPage = 1;
        totalPages = 0;
        results = [];
        visitedLinks.clear();
        resultsBody.innerHTML = '';
        visitedCountElem.innerText = '0';
        document.getElementById('totalRequests').innerText = '0';
        document.getElementById('successfulRequests').innerText = '0';
        document.getElementById('failedRequests').innerText = '0';
        progressBar.value = 0;
        progressText.innerText = '0%';
        elapsedTimeElem.innerText = '00:00:00';
        remainingTimeElem.innerText = '00:00:00';
        logMessages = [];
        logContainer.innerHTML = `<strong>로그:</strong><br>`;
        GM_setValue('crawlerLogs', JSON.stringify(logMessages));
        crawlData = {
            labels: [],
            datasets: [{
                label: '방문 횟수',
                data: [],
                backgroundColor: 'rgba(33, 150, 243, 0.6)',
                borderColor: 'rgba(33, 150, 243, 1)',
                borderWidth: 1
            },
            {
                label: '평균 페이지 로딩 시간 (ms)',
                data: [],
                backgroundColor: 'rgba(76, 175, 80, 0.6)',
                borderColor: 'rgba(76, 175, 80, 1)',
                borderWidth: 1
            }]
        };
        loadTimeData = {
            labels: [],
            datasets: [{
                label: '페이지 로딩 시간 (ms)',
                data: [],
                backgroundColor: 'rgba(255, 193, 7, 0.6)',
                borderColor: 'rgba(255,193,7,1)',
                borderWidth: 1
            }]
        };
        domainDistributionData = {
            labels: [],
            datasets: [{
                label: '도메인 분포',
                data: [],
                backgroundColor: [
                    'rgba(33, 150, 243, 0.6)',
                    'rgba(255, 87, 34, 0.6)',
                    'rgba(76, 175, 80, 0.6)',
                    'rgba(156, 39, 176, 0.6)',
                    'rgba(255, 152, 0, 0.6)',
                    'rgba(244, 67, 54, 0.6)',
                    'rgba(158, 158, 158, 0.6)'
                ],
                borderColor: 'rgba(33, 150, 243, 1)',
                borderWidth: 1
            }]
        };
        errorRateData = {
            labels: [],
            datasets: [{
                label: '오류 발생 수',
                data: [],
                backgroundColor: 'rgba(255, 99, 132, 0.6)',
                borderColor: 'rgba(255, 99, 132,1)',
                borderWidth: 1
            }]
        };
        cumulativeVisitsData = {
            labels: [],
            datasets: [{
                label: '누적 방문 횟수',
                data: [],
                backgroundColor: 'rgba(3, 169, 244, 0.6)',
                borderColor: 'rgba(3, 169, 244,1)',
                borderWidth: 1
            }]
        };
        keywordDistributionData = {
            labels: [],
            datasets: [{
                label: '키워드 분포',
                data: [],
                backgroundColor: [
                    'rgba(63, 81, 181, 0.6)',
                    'rgba(255, 152, 0, 0.6)',
                    'rgba(76, 175, 80, 0.6)',
                    'rgba(244, 67, 54, 0.6)',
                    'rgba(33, 150, 243, 0.6)',
                    'rgba(153, 102, 255, 0.6)'
                ],
                borderColor: 'rgba(63, 81, 181,1)',
                borderWidth: 1
            }]
        };
        languageDistributionData = {
            labels: [],
            datasets: [{
                label: '언어 분포',
                data: [],
                backgroundColor: [
                    'rgba(38, 166, 154, 0.6)',
                    'rgba(211, 47, 47, 0.6)',
                    'rgba(3, 169, 244, 0.6)',
                    'rgba(255, 193, 7, 0.6)',
                    'rgba(156, 39, 176, 0.6)',
                    'rgba(0, 188, 212, 0.6)'
                ],
                borderColor: 'rgba(38, 166, 154,1)',
                borderWidth: 1
            }]
        };
        techStackData = {
            labels: [],
            datasets: [{
                label: '기술 스택 분포',
                data: [],
                backgroundColor: [
                    'rgba(103, 58, 183, 0.6)',
                    'rgba(255, 202, 40, 0.6)',
                    'rgba(0, 150, 136, 0.6)',
                    'rgba(233, 30, 99, 0.6)',
                    'rgba(245, 124, 0, 0.6)',
                    'rgba(255, 235, 59, 0.6)'
                ],
                borderColor: 'rgba(103, 58, 183,1)',
                borderWidth: 1
            }]
        };
        domainAgeData = {
            labels: [],
            datasets: [{
                label: '도메인 연령 분포 (년)',
                data: [],
                backgroundColor: [
                    'rgba(255, 159, 64, 0.6)',
                    'rgba(75, 192, 192, 0.6)',
                    'rgba(54, 162, 235, 0.6)',
                    'rgba(153, 102, 255, 0.6)',
                    'rgba(255, 99, 132, 0.6)'
                ],
                borderColor: 'rgba(255, 159, 64,1)',
                borderWidth: 1
            }]
        };

        if (crawlChart) {
            crawlChart.destroy();
        }
        if (loadTimeChart) {
            loadTimeChart.destroy();
        }
        if (domainDistributionChart) {
            domainDistributionChart.destroy();
        }
        if (errorRateChart) {
            errorRateChart.destroy();
        }
        if (cumulativeVisitsChart) {
            cumulativeVisitsChart.destroy();
        }
        if (keywordDistributionChart) {
            keywordDistributionChart.destroy();
        }
        if (languageDistributionChart) {
            languageDistributionChart.destroy();
        }
        if (techStackChart) {
            techStackChart.destroy();
        }
        if (domainAgeChart) {
            domainAgeChart.destroy();
        }
        initializeChart();
        log('🔄 크롤링을 초기화하였습니다.');
    }

    // 크롤링 페이지 함수
    async function crawlPage() {
        if (!isRunning || isPaused) {
            return;
        }

        let url = constructURL(currentPage);
        if (!url) {
            log('❌ 지원하지 않는 검색 엔진입니다.');
            alert('지원하지 않는 검색 엔진입니다.');
            isRunning = false;
            return;
        }

        log(`📄 페이지 ${currentPage} 크롤링 중: ${url}`);

        GM_xmlhttpRequest({
            method: "GET",
            url: url,
            headers: {
                "User-Agent": navigator.userAgent,
                "Accept": "text/html"
            },
            onload: function(response) {
                if (response.status !== 200) {
                    log(`❌ 페이지 ${currentPage} 로드 실패: 상태 ${response.status}`);
                    handleCrawlError(currentPage, retryAttempts);
                    document.getElementById('failedRequests').innerText = parseInt(document.getElementById('failedRequests').innerText) + 1;
                    return;
                }

                const parser = new DOMParser();
                const doc = parser.parseFromString(response.responseText, 'text/html');
                let items = extractItems(doc);
                if (currentPage === 1) {
                    totalPages = determineTotalPages(doc);
                    totalPagesElem.innerText = totalPages;
                }

                log(`📊 페이지 ${currentPage}에서 ${items.length}개 항목 발견.`);
                document.getElementById('totalRequests').innerText = parseInt(document.getElementById('totalRequests').innerText) + items.length;

                items.forEach(item => {
                    processItem(item);
                });

                updateChart();
                updateLoadTimeChart();
                updateDomainDistributionChart();
                updateErrorRateChart();
                updateCumulativeVisitsChart();
                updateKeywordDistributionChart();
                updateLanguageDistributionChart();
                updateTechStackChart();
                updateDomainAgeChart();
                updateProgress();
                currentPage++;
                currentPageElem.innerText = currentPage;
                if (currentPage <= totalPages && isRunning && !isPaused) {
                    setTimeout(crawlPage, 100); // 고정된 100ms 크롤링 속도
                } else {
                    finalizeCrawling();
                }
            },
            onerror: function() {
                log(`❌ 페이지 ${currentPage} 요청 중 오류 발생.`);
                handleCrawlError(currentPage, retryAttempts);
                document.getElementById('failedRequests').innerText = parseInt(document.getElementById('failedRequests').innerText) + 1;
            }
        });
    }

    // 크롤링 완료 시 처리 함수
    function finalizeCrawling() {
        isRunning = false;
        clearInterval(elapsedInterval);
        log('✅ 크롤링이 완료되었습니다.');
        GM_notification({
            text: '크롤링이 완료되었습니다.',
            title: '웹 크롤러 8.6',
            timeout: 3000
        });
    }

    // 크롤링 오류 처리 함수
    function handleCrawlError(page, retriesLeft) {
        if (retriesLeft > 0 && isRunning) {
            log(`🔄 페이지 ${page} 재시도 (${retriesLeft}회 남음).`);
            setTimeout(() => {
                const url = constructURL(page);
                GM_xmlhttpRequest({
                    method: "GET",
                    url: url,
                    headers: {
                        "User-Agent": navigator.userAgent,
                        "Accept": "text/html"
                    },
                    onload: function(response) {
                        if (response.status === 200) {
                            log(`✅ 페이지 ${page} 재시도 성공.`);
                            document.getElementById('successfulRequests').innerText = parseInt(document.getElementById('successfulRequests').innerText) + 1;
                            crawlPage();
                        } else {
                            handleCrawlError(page, retriesLeft - 1);
                            document.getElementById('failedRequests').innerText = parseInt(document.getElementById('failedRequests').innerText) + 1;
                        }
                    },
                    onerror: function() {
                        handleCrawlError(page, retriesLeft - 1);
                        document.getElementById('failedRequests').innerText = parseInt(document.getElementById('failedRequests').innerText) + 1;
                    }
                });
            }, retryInterval);
        } else {
            log(`❌ 페이지 ${page} 로드 실패: 최대 재시도 횟수 초과.`);
            document.getElementById('failedRequests').innerText = parseInt(document.getElementById('failedRequests').innerText) + 1;
            currentPage++;
            currentPageElem.innerText = currentPage;
            if (currentPage <= totalPages && isRunning && !isPaused) {
                setTimeout(crawlPage, 100);
            } else {
                finalizeCrawling();
            }
        }
    }

    // URL 구성 함수
    function constructURL(page) {
        switch(searchEngine) {
            case 'google':
                return `https://www.google.com/search?q=${encodeURIComponent(searchQuery)}&start=${(page-1)*10}`;
            case 'bing':
                return `https://www.bing.com/search?q=${encodeURIComponent(searchQuery)}&first=${(page-1)*10 +1}`;
            case 'daum':
                return `https://search.daum.net/search?q=${encodeURIComponent(searchQuery)}&page=${page}`;
            case 'naver':
                return `https://search.naver.com/search.naver?query=${encodeURIComponent(searchQuery)}&start=${(page-1)*10 +1}`;
            case 'yahoo':
                return `https://search.yahoo.com/search?p=${encodeURIComponent(searchQuery)}&b=${(page-1)*10 +1}`;
            case 'duckduckgo':
                return `https://duckduckgo.com/html/?q=${encodeURIComponent(searchQuery)}&s=${(page-1)*30}`;
            case 'startpage':
                return `https://www.startpage.com/do/search?query=${encodeURIComponent(searchQuery)}&b=${(page-1)*10 +1}`;
            case 'ecosia':
                return `https://www.ecosia.org/search?q=${encodeURIComponent(searchQuery)}&page=${page}`;
            case 'qwant':
                return `https://www.qwant.com/?q=${encodeURIComponent(searchQuery)}&t=web&s=${page}`;
            case 'ahmia':
                return `http://ahmia.fi/search/?q=${encodeURIComponent(searchQuery)}&page=${page}`;
            case 'torch':
                return `http://torchsearch.de/search/?q=${encodeURIComponent(searchQuery)}&page=${page}`;
            case 'notracker':
                return `http://notracker.org/search/?q=${encodeURIComponent(searchQuery)}&page=${page}`;
            default:
                return '';
        }
    }

    // 항목 추출 함수
    function extractItems(doc) {
        let items = [];
        switch(searchEngine) {
            case 'google':
                items = doc.querySelectorAll('div.g');
                break;
            case 'bing':
                items = doc.querySelectorAll('li.b_algo');
                break;
            case 'daum':
                items = doc.querySelectorAll('div.wrap_cont');
                break;
            case 'naver':
                items = doc.querySelectorAll('div.basic1');
                break;
            case 'yahoo':
                items = doc.querySelectorAll('div.compTitle');
                break;
            case 'duckduckgo':
                items = doc.querySelectorAll('div.result');
                break;
            case 'startpage':
                items = doc.querySelectorAll('div.w-gl__result');
                break;
            case 'ecosia':
                items = doc.querySelectorAll('div.result');
                break;
            case 'qwant':
                items = doc.querySelectorAll('div.results div.result');
                break;
            case 'ahmia':
                items = doc.querySelectorAll('div#main div.result');
                break;
            case 'torch':
                items = doc.querySelectorAll('div.result');
                break;
            case 'notracker':
                items = doc.querySelectorAll('div.result');
                break;
            default:
                break;
        }
        return items;
    }

    // 총 페이지 수 결정 함수
    function determineTotalPages(doc) {
        let pages = 1;
        switch(searchEngine) {
            case 'google':
                const googlePager = doc.querySelectorAll('a[href*="start="]');
                pages = Math.min(googlePager.length, 10) || 1;
                break;
            case 'bing':
                const bingPager = doc.querySelectorAll('a.sb_pagS');
                pages = bingPager.length || 1;
                break;
            case 'daum':
                const daumPager = doc.querySelectorAll('a.pagination__link');
                pages = daumPager.length || 1;
                break;
            case 'naver':
                const naverPager = doc.querySelectorAll('a.nav');
                pages = naverPager.length || 1;
                break;
            case 'yahoo':
                const yahooPager = doc.querySelectorAll('a.fz-l.tco-pagination__anchor');
                pages = yahooPager.length || 1;
                break;
            case 'duckduckgo':
                const ddgPager = doc.querySelectorAll('a.result--more__btn');
                pages = ddgPager.length || 1;
                break;
            case 'startpage':
                const spPager = doc.querySelectorAll('a.paginator__link');
                pages = spPager.length || 1;
                break;
            case 'ecosia':
                const ecosiaPager = doc.querySelectorAll('a.pagination__link');
                pages = ecosiaPager.length || 1;
                break;
            case 'qwant':
                const qwantPager = doc.querySelectorAll('a.pagination__link');
                pages = qwantPager.length || 1;
                break;
            case 'ahmia':
                const ahmiaPager = doc.querySelectorAll('a.pagination__link');
                pages = ahmiaPager.length || 1;
                break;
            case 'torch':
                const torchPager = doc.querySelectorAll('a.pagination__link');
                pages = torchPager.length || 1;
                break;
            case 'notracker':
                const ntPager = doc.querySelectorAll('a.pagination__link');
                pages = ntPager.length || 1;
                break;
            default:
                pages = 1;
                break;
        }
        return pages;
    }

    // 항목 처리 함수
    function processItem(item) {
        let title = 'N/A';
        let link = 'N/A';
        let description = 'N/A';
        let image = 'N/A';
        let htmlLink = 'N/A';
        let whoisInfo = 'N/A';
        let pageLoadTime = 'N/A';
        let language = 'N/A';
        let metaKeywords = 'N/A';
        let metaRobots = 'N/A';
        let openGraph = 'N/A';
        let securityHeaders = 'N/A';
        let domainAge = 'N/A';
        let techStack = 'N/A'; // 추가된 기술 스택 정보

        switch(searchEngine) {
            case 'google':
                const gTitleElem = item.querySelector('h3');
                const gLinkElem = item.querySelector('a');
                const gDescElem = item.querySelector('.IsZvec') || item.querySelector('.VwiC3b');
                if (gTitleElem) title = gTitleElem.innerText;
                if (gLinkElem) link = gLinkElem.href;
                if (gDescElem) description = gDescElem.innerText;

                const gImgElem = item.querySelector('img');
                if (gImgElem && gImgElem.src) {
                    image = `<img src="${gImgElem.src}" alt="이미지" style="max-width: 80px; max-height: 80px;">`;
                }

                if (toggleHTML.checked && link !== 'N/A') {
                    htmlLink = `<button class="html-view-btn" data-link="${encodeURIComponent(link)}">보기</button>`;
                }
                break;
            case 'bing':
                const bTitleElem = item.querySelector('h2 a');
                const bDescElem = item.querySelector('p');
                if (bTitleElem) {
                    title = bTitleElem.innerText;
                    link = bTitleElem.href;
                }
                if (bDescElem) description = bDescElem.innerText;

                const bImgElem = item.querySelector('img');
                if (bImgElem && bImgElem.src) {
                    image = `<img src="${bImgElem.src}" alt="이미지" style="max-width: 80px; max-height: 80px;">`;
                }

                if (toggleHTML.checked && link !== 'N/A') {
                    htmlLink = `<button class="html-view-btn" data-link="${encodeURIComponent(link)}">보기</button>`;
                }
                break;
            case 'daum':
                const dTitleElem = item.querySelector('a.link_fax');
                const dDescElem = item.querySelector('div.cont_inner');
                if (dTitleElem) {
                    title = dTitleElem.innerText.trim();
                    link = dTitleElem.href;
                }
                if (dDescElem) description = dDescElem.innerText.trim();

                const dImgElem = item.querySelector('img');
                if (dImgElem && dImgElem.src) {
                    image = `<img src="${dImgElem.src}" alt="이미지" style="max-width: 80px; max-height: 80px;">`;
                }

                if (toggleHTML.checked && link !== 'N/A') {
                    htmlLink = `<button class="html-view-btn" data-link="${encodeURIComponent(link)}">보기</button>`;
                }
                break;
            case 'naver':
                const nTitleElem = item.querySelector('a.tit');
                const nDescElem = item.querySelector('div.desc');
                if (nTitleElem) {
                    title = nTitleElem.innerText;
                    link = nTitleElem.href;
                }
                if (nDescElem) description = nDescElem.innerText;

                const nImgElem = item.querySelector('img.thumb');
                if (nImgElem && nImgElem.src) {
                    image = `<img src="${nImgElem.src}" alt="이미지" style="max-width: 80px; max-height: 80px;">`;
                }

                if (toggleHTML.checked && link !== 'N/A') {
                    htmlLink = `<button class="html-view-btn" data-link="${encodeURIComponent(link)}">보기</button>`;
                }
                break;
            case 'yahoo':
                const yTitleElem = item.querySelector('h3');
                const yLinkElem = item.querySelector('a');
                const yDescElem = item.querySelector('div.compText');
                if (yTitleElem) title = yTitleElem.innerText;
                if (yLinkElem) link = yLinkElem.href;
                if (yDescElem) description = yDescElem.innerText;

                const yImgElem = item.querySelector('img');
                if (yImgElem && yImgElem.src) {
                    image = `<img src="${yImgElem.src}" alt="이미지" style="max-width: 80px; max-height: 80px;">`;
                }

                if (toggleHTML.checked && link !== 'N/A') {
                    htmlLink = `<button class="html-view-btn" data-link="${encodeURIComponent(link)}">보기</button>`;
                }
                break;
            case 'duckduckgo':
                const ddgTitleElem = item.querySelector('a.result__a');
                const ddgDescElem = item.querySelector('a.result__snippet');
                if (ddgTitleElem) {
                    title = ddgTitleElem.innerText;
                    link = ddgTitleElem.href;
                }
                if (ddgDescElem) description = ddgDescElem.innerText;

                const ddgImgElem = item.querySelector('img.result__image');
                if (ddgImgElem && ddgImgElem.src) {
                    image = `<img src="${ddgImgElem.src}" alt="이미지" style="max-width: 80px; max-height: 80px;">`;
                }

                if (toggleHTML.checked && link !== 'N/A') {
                    htmlLink = `<button class="html-view-btn" data-link="${encodeURIComponent(link)}">보기</button>`;
                }
                break;
            case 'startpage':
                const spTitleElem = item.querySelector('a.w-gl__result-title');
                const spDescElem = item.querySelector('p.w-gl__result-description');
                if (spTitleElem) {
                    title = spTitleElem.innerText;
                    link = spTitleElem.href;
                }
                if (spDescElem) description = spDescElem.innerText;

                const spImgElem = item.querySelector('img.w-gl__result-image');
                if (spImgElem && spImgElem.src) {
                    image = `<img src="${spImgElem.src}" alt="이미지" style="max-width: 80px; max-height: 80px;">`;
                }

                if (toggleHTML.checked && link !== 'N/A') {
                    htmlLink = `<button class="html-view-btn" data-link="${encodeURIComponent(link)}">보기</button>`;
                }
                break;
            case 'ecosia':
                const ecosiaTitleElem = item.querySelector('h2.result-title a');
                const ecosiaDescElem = item.querySelector('p.result-description');
                if (ecosiaTitleElem) {
                    title = ecosiaTitleElem.innerText;
                    link = ecosiaTitleElem.href;
                }
                if (ecosiaDescElem) description = ecosiaDescElem.innerText;

                const ecosiaImgElem = item.querySelector('img.result-image');
                if (ecosiaImgElem && ecosiaImgElem.src) {
                    image = `<img src="${ecosiaImgElem.src}" alt="이미지" style="max-width: 80px; max-height: 80px;">`;
                }

                if (toggleHTML.checked && link !== 'N/A') {
                    htmlLink = `<button class="html-view-btn" data-link="${encodeURIComponent(link)}">보기</button>`;
                }
                break;
            case 'qwant':
                const qwantTitleElem = item.querySelector('a.result__title');
                const qwantDescElem = item.querySelector('p.result__description');
                if (qwantTitleElem) {
                    title = qwantTitleElem.innerText;
                    link = qwantTitleElem.href;
                }
                if (qwantDescElem) description = qwantDescElem.innerText;

                const qwantImgElem = item.querySelector('img.result__image');
                if (qwantImgElem && qwantImgElem.src) {
                    image = `<img src="${qwantImgElem.src}" alt="이미지" style="max-width: 80px; max-height: 80px;">`;
                }

                if (toggleHTML.checked && link !== 'N/A') {
                    htmlLink = `<button class="html-view-btn" data-link="${encodeURIComponent(link)}">보기</button>`;
                }
                break;
            case 'ahmia':
                const ahmiaTitleElem = item.querySelector('h2.result-title a');
                const ahmiaDescElem = item.querySelector('p.result-description');
                if (ahmiaTitleElem) {
                    title = ahmiaTitleElem.innerText;
                    link = ahmiaTitleElem.href;
                }
                if (ahmiaDescElem) description = ahmiaDescElem.innerText;

                const ahmiaImgElem = item.querySelector('img.result-image');
                if (ahmiaImgElem && ahmiaImgElem.src) {
                    image = `<img src="${ahmiaImgElem.src}" alt="이미지" style="max-width: 80px; max-height: 80px;">`;
                }

                if (toggleHTML.checked && link !== 'N/A') {
                    whoisInfo = `<button class="whois-view-btn" data-domain="${encodeURIComponent(extractDomain(link))}">보기</button>`;
                    htmlLink = `<button class="html-view-btn" data-link="${encodeURIComponent(link)}">보기</button>`;
                }
                break;
            case 'torch':
                const torchTitleElem = item.querySelector('h3.result-title a');
                const torchDescElem = item.querySelector('p.result-description');
                if (torchTitleElem) {
                    title = torchTitleElem.innerText;
                    link = torchTitleElem.href;
                }
                if (torchDescElem) description = torchDescElem.innerText;

                const torchImgElem = item.querySelector('img.result-image');
                if (torchImgElem && torchImgElem.src) {
                    image = `<img src="${torchImgElem.src}" alt="이미지" style="max-width: 80px; max-height: 80px;">`;
                }

                if (toggleHTML.checked && link !== 'N/A') {
                    whoisInfo = `<button class="whois-view-btn" data-domain="${encodeURIComponent(extractDomain(link))}">보기</button>`;
                    htmlLink = `<button class="html-view-btn" data-link="${encodeURIComponent(link)}">보기</button>`;
                }
                break;
            case 'notracker':
                const ntTitleElem = item.querySelector('h3.result-title a');
                const ntDescElem = item.querySelector('p.result-description');
                if (ntTitleElem) {
                    title = ntTitleElem.innerText;
                    link = ntTitleElem.href;
                }
                if (ntDescElem) description = ntDescElem.innerText;

                const ntImgElem = item.querySelector('img.result-image');
                if (ntImgElem && ntImgElem.src) {
                    image = `<img src="${ntImgElem.src}" alt="이미지" style="max-width: 80px; max-height: 80px;">`;
                }

                if (toggleHTML.checked && link !== 'N/A') {
                    whoisInfo = `<button class="whois-view-btn" data-domain="${encodeURIComponent(extractDomain(link))}">보기</button>`;
                    htmlLink = `<button class="html-view-btn" data-link="${encodeURIComponent(link)}">보기</button>`;
                }
                break;
            default:
                break;
        }

        // 추가 메타 정보 수집
        try {
            const metaKeywordElem = item.querySelector('meta[name="keywords"]');
            if (metaKeywordElem) {
                metaKeywords = metaKeywordElem.getAttribute('content');
                if (metaKeywords) {
                    metaKeywords = metaKeywords.split(',').map(k => k.trim()).join(', ');
                } else {
                    metaKeywords = 'N/A';
                }
            }

            const metaRobotsElem = item.querySelector('meta[name="robots"]');
            if (metaRobotsElem) {
                metaRobots = metaRobotsElem.getAttribute('content') || 'N/A';
            }

            const ogTitle = item.querySelector('meta[property="og:title"]')?.getAttribute('content') || 'N/A';
            const ogDescription = item.querySelector('meta[property="og:description"]')?.getAttribute('content') || 'N/A';
            const ogImage = item.querySelector('meta[property="og:image"]')?.getAttribute('content') || 'N/A';
            openGraph = `Title: ${ogTitle}, Description: ${ogDescription}, Image: ${ogImage}`;

            // 보안 헤더 추출 (간단한 예시)
            const securityHeaders = [];
            const hsts = item.querySelector('meta[http-equiv="Strict-Transport-Security"]');
            if (hsts) securityHeaders.push('HSTS');
            const contentSecurityPolicy = item.querySelector('meta[http-equiv="Content-Security-Policy"]');
            if (contentSecurityPolicy) securityHeaders.push('CSP');
            securityHeaders = securityHeaders.length > 0 ? securityHeaders.join(', ') : 'N/A';

            const domainInfo = getDomainInfo(link);
            domainAge = domainInfo ? domainInfo.age : 'N/A';

            const htmlLang = item.querySelector('html');
            if (htmlLang && htmlLang.lang) {
                language = htmlLang.lang;
            }

            // 기술 스택 정보 수집 (예시: 간단한 스택 감지)
            const techs = [];
            if (item.querySelector('.wordpress')) techs.push('WordPress');
            if (item.querySelector('.shopify')) techs.push('Shopify');
            if (item.querySelector('.react')) techs.push('React');
            if (item.querySelector('.angular')) techs.push('Angular');
            if (item.querySelector('.vue')) techs.push('Vue.js');
            techStack = techs.length > 0 ? techs.join(', ') : 'N/A';
        } catch (e) {
            log(`⚠️ 메타 정보 수집 중 오류 발생: ${e.message}`);
        }

        // 광고 제외 필터링
        if (toggleAds.checked) {
            const combinedText = `${title} ${description}`.toLowerCase();
            const isAd = combinedText.includes('advertisement') || combinedText.includes('광고') || combinedText.includes('ad ');
            if (isAd) {
                log(`🚫 광고 항목 제외: "${title}"`);
                return;
            }
        }

        // 필터 패턴 적용
        if (filterPatterns.length > 0) {
            const combinedText = `${title} ${description}`;
            const isFiltered = filterPatterns.some(regex => regex.test(combinedText));
            if (isFiltered) {
                log(`❌ 필터 단어 포함 항목 제외: "${title}"`);
                return;
            }
        }

        // 도메인 추출 및 제외 도메인 적용
        const domain = extractDomain(link);
        if (!domain) return;

        if (excludeDomains.includes(domain.toLowerCase())) {
            log(`🚫 제외 도메인 항목 제외: "${link}"`);
            return;
        }

        // 중복 방문 제한
        let visitCount = visitedLinks.get(domain) || 0;
        if (visitCount >= duplicateThreshold) {
            log(`🔄 중복 방문 제한: "${domain}"`);
            return;
        }

        visitedLinks.set(domain, visitCount + 1);
        visitedCountElem.innerText = visitedLinks.size.toString();

        // 페이지 로딩 시간 측정
        const startLoad = performance.now();
        fetch(link, { mode: 'no-cors' })
            .then(response => {
                const endLoad = performance.now();
                pageLoadTime = Math.round(endLoad - startLoad);
                document.getElementById('successfulRequests').innerText = parseInt(document.getElementById('successfulRequests').innerText) + 1;
                updateRow();
            })
            .catch(err => {
                pageLoadTime = '계산 불가';
                log(`❌ 페이지 로딩 오류: "${link}"`);
                document.getElementById('failedRequests').innerText = parseInt(document.getElementById('failedRequests').innerText) + 1;
                updateRow();
            });

        // 언어, 키워드, 로봇 메타 정보 저장
        const itemLanguage = language;
        const itemKeywords = metaKeywords;
        const itemRobots = metaRobots;

        // WHOIS 정보 버튼 이벤트 추가 (이미 처리됨)

        // 이미지 옵션 적용
        if (!toggleImages.checked) {
            image = '비활성화';
        }

        // OpenGraph 옵션 적용
        if (!toggleOpenGraph.checked) {
            openGraph = '비활성화';
        }

        // 보안 헤더 옵션 적용
        if (!toggleSecurityHeaders.checked) {
            securityHeaders = '비활성화';
        }

        // 도메인 연령 옵션 적용
        if (!toggleDomainAge.checked) {
            domainAge = '비활성화';
        }

        // 결과 배열에 추가
        results.push({ title, link, description, image, htmlLink, whoisInfo, pageLoadTime, language, metaKeywords, metaRobots, openGraph, securityHeaders, domainAge, techStack });

        // 결과 테이블에 행 추가
        const row = document.createElement('tr');
        row.innerHTML = `
            <td>${escapeHTML(title)}</td>
            <td><a href="${escapeHTML(link)}" target="_blank">${escapeHTML(link)}</a></td>
            <td>${escapeHTML(description)}</td>
            <td>${image}</td>
            <td>${htmlLink}</td>
            <td>${whoisInfo}</td>
            <td>${pageLoadTime}</td>
            <td>${escapeHTML(itemLanguage)}</td>
            <td>${escapeHTML(itemKeywords)}</td>
            <td>${escapeHTML(itemRobots)}</td>
            <td>${escapeHTML(openGraph)}</td>
            <td>${escapeHTML(securityHeaders)}</td>
            <td>${escapeHTML(domainAge)}</td>
            <td>${escapeHTML(techStack)}</td>
        `;
        resultsBody.appendChild(row);

        // 미리보기 이벤트 추가
        addPreviewEvents(row, link);

        // WHOIS 버튼 이벤트 추가
        const whoisBtn = row.querySelector('.whois-view-btn');
        if (whoisBtn) {
            whoisBtn.addEventListener('click', () => {
                const encodedDomain = whoisBtn.getAttribute('data-domain');
                const decodedDomain = decodeURIComponent(encodedDomain);
                fetchWhoisData(decodedDomain);
            });
        }

        function updateRow() {
            // 업데이트된 로딩 시간을 테이블에 반영
            row.cells[6].innerText = pageLoadTime;
            row.cells[10].innerText = openGraph;
            row.cells[11].innerText = securityHeaders;
            row.cells[12].innerText = domainAge;
            updateChart();
            updateLoadTimeChart();
            updateDomainDistributionChart();
            updateErrorRateChart();
            updateCumulativeVisitsChart();
            updateKeywordDistributionChart();
            updateLanguageDistributionChart();
            updateTechStackChart();
            updateDomainAgeChart();
            updateProgress();
        }
    }

    // HTML 이스케프 함수
    function escapeHTML(str) {
        if (!str) return '';
        return str.replace(/&/g, "&amp;")
                  .replace(/</g, "&lt;")
                  .replace(/>/g, "&gt;")
                  .replace(/"/g, "&quot;")
                  .replace(/'/g, "&#039;");
    }

    // 도메인 추출 함수
    function extractDomain(url) {
        try {
            const urlObj = new URL(url);
            return urlObj.hostname.replace('www.', '');
        } catch (e) {
            return null;
        }
    }

    // 도메인 연령 정보 가져오기 함수
    function getDomainInfo(url) {
        try {
            const urlObj = new URL(url);
            const now = new Date();
            const creationDate = new Date(urlObj.host.creationDate); // 예시: 실제로는 WHOIS 데이터를 통해 가져와야 함
            if (isNaN(creationDate)) return null;
            const age = now.getFullYear() - creationDate.getFullYear();
            return { age };
        } catch (e) {
            return null;
        }
    }

    // 경과 시간 업데이트 함수
    function updateElapsedTime() {
        if (!startTime) return;
        const now = Date.now();
        const elapsed = Math.floor((now - startTime) / 1000);
        elapsedTimeElem.innerText = formatTime(elapsed);
        const estimatedTotal = totalPages * ((elapsed > 0) ? (elapsed / (currentPage - 1)) : 0.5);
        const remaining = Math.max(Math.round(estimatedTotal - elapsed), 0);
        remainingTimeElem.innerText = formatTime(remaining);
    }

    // 시간 형식화 함수
    function formatTime(seconds) {
        const hrs = String(Math.floor(seconds / 3600)).padStart(2, '0');
        const mins = String(Math.floor((seconds % 3600) / 60)).padStart(2, '0');
        const secs = String(seconds % 60).padStart(2, '0');
        return `${hrs}:${mins}:${secs}`;
    }

    // 차트 업데이트 함수
    function updateChart() {
        crawlData.labels = Array.from(visitedLinks.keys());
        crawlData.datasets[0].data = Array.from(visitedLinks.values());

        // 평균 페이지 로딩 시간 계산
        let loadTimes = results.filter(r => typeof r.pageLoadTime === 'number').map(r => r.pageLoadTime);
        let averageLoadTime = loadTimes.length > 0 ? Math.round(loadTimes.reduce((a, b) => a + b, 0) / loadTimes.length) : 0;
        crawlData.datasets[1].data = Array.from(visitedLinks.keys()).map(domain => {
            const times = results.filter(r => extractDomain(r.link) === domain && typeof r.pageLoadTime === 'number').map(r => r.pageLoadTime);
            return times.length > 0 ? Math.round(times.reduce((a, b) => a + b, 0) / times.length) : 0;
        });

        if (crawlChart) {
            crawlChart.update();
        }
        GM_setValue('crawlerData', JSON.stringify(crawlData));
    }

    // 추가 차트 업데이트 함수
    function updateLoadTimeChart() {
        loadTimeData.labels = results.map(r => r.title).slice(-20); // 최근 20개
        loadTimeData.datasets[0].data = results.map(r => r.pageLoadTime).slice(-20);
        if (loadTimeChart) {
            loadTimeChart.update();
        }
    }

    function updateDomainDistributionChart() {
        domainDistributionData.labels = Array.from(visitedLinks.keys());
        domainDistributionData.datasets[0].data = Array.from(visitedLinks.values());
        if (domainDistributionChart) {
            domainDistributionChart.update();
        }
    }

    function updateErrorRateChart() {
        // 오류 발생 수를 도메인별로 집계
        const errorCounts = {};
        results.forEach(r => {
            if (r.pageLoadTime === '계산 불가') {
                const domain = extractDomain(r.link);
                if (domain) {
                    errorCounts[domain] = (errorCounts[domain] || 0) + 1;
                }
            }
        });
        errorRateData.labels = Object.keys(errorCounts);
        errorRateData.datasets[0].data = Object.values(errorCounts);
        if (errorRateChart) {
            errorRateChart.update();
        }
    }

    function updateCumulativeVisitsChart() {
        let cumulative = 0;
        cumulativeVisitsData.labels = results.map((_, index) => index + 1);
        cumulativeVisitsData.datasets[0].data = results.map(() => { cumulative += 1; return cumulative; });
        if (cumulativeVisitsChart) {
            cumulativeVisitsChart.update();
        }
    }

    function updateKeywordDistributionChart() {
        const keywordCounts = {};
        results.forEach(r => {
            if (r.metaKeywords && r.metaKeywords !== 'N/A') {
                const keywords = r.metaKeywords.split(',').map(k => k.trim());
                keywords.forEach(k => {
                    if (k) {
                        keywordCounts[k] = (keywordCounts[k] || 0) + 1;
                    }
                });
            }
        });
        keywordDistributionData.labels = Object.keys(keywordCounts);
        keywordDistributionData.datasets[0].data = Object.values(keywordCounts);
        if (keywordDistributionChart) {
            keywordDistributionChart.update();
        }
    }

    function updateLanguageDistributionChart() {
        const languageCounts = {};
        results.forEach(r => {
            if (r.language && r.language !== 'N/A') {
                languageCounts[r.language] = (languageCounts[r.language] || 0) + 1;
            }
        });
        languageDistributionData.labels = Object.keys(languageCounts);
        languageDistributionData.datasets[0].data = Object.values(languageCounts);
        if (languageDistributionChart) {
            languageDistributionChart.update();
        }
    }

    function updateTechStackChart() {
        const techCounts = {};
        results.forEach(r => {
            if (r.techStack && r.techStack !== 'N/A') {
                const techs = r.techStack.split(',').map(t => t.trim());
                techs.forEach(t => {
                    if (t) {
                        techCounts[t] = (techCounts[t] || 0) + 1;
                    }
                });
            }
        });
        techStackData.labels = Object.keys(techCounts);
        techStackData.datasets[0].data = Object.values(techCounts);
        if (techStackChart) {
            techStackChart.update();
        }
    }

    function updateDomainAgeChart() {
        const ageCounts = {};
        results.forEach(r => {
            if (r.domainAge && r.domainAge !== 'N/A') {
                const age = r.domainAge;
                if (age >= 0 && age <= 1) {
                    ageCounts['0-1'] = (ageCounts['0-1'] || 0) + 1;
                } else if (age <= 3) {
                    ageCounts['2-3'] = (ageCounts['2-3'] || 0) + 1;
                } else if (age <= 5) {
                    ageCounts['4-5'] = (ageCounts['4-5'] || 0) + 1;
                } else if (age <= 10) {
                    ageCounts['6-10'] = (ageCounts['6-10'] || 0) + 1;
                } else {
                    ageCounts['10+'] = (ageCounts['10+'] || 0) + 1;
                }
            }
        });
        domainAgeData.labels = Object.keys(ageCounts);
        domainAgeData.datasets[0].data = Object.values(ageCounts);
        if (domainAgeChart) {
            domainAgeChart.update();
        }
    }

    // 크롤 데이터 로드 함수
    function loadCrawlData() {
        const storedData = GM_getValue('crawlerData', null);
        if (storedData) {
            const parsedData = JSON.parse(storedData);
            crawlData = parsedData;
            if (crawlChart) {
                crawlChart.data = crawlData;
                crawlChart.update();
            }
        }
    }

    // 크롤 데이터 저장 함수
    function saveCrawlData() {
        GM_setValue('crawlerData', JSON.stringify(crawlData));
    }

    // 주기적으로 크롤 데이터 저장
    setInterval(saveCrawlData, 5000);

    // 검색어 및 검색 엔진 감지 함수
    function getSearchQueryAndEngine() {
        const url = window.location.href;
        if (url.includes('google.com/search')) {
            const params = new URLSearchParams(window.location.search);
            searchQuery = params.get('q') || '';
            searchEngine = 'google';
        } else if (url.includes('bing.com/search')) {
            const params = new URLSearchParams(window.location.search);
            searchQuery = params.get('q') || '';
            searchEngine = 'bing';
        } else if (url.includes('daum.net/search')) {
            const params = new URLSearchParams(window.location.search);
            searchQuery = params.get('q') || '';
            searchEngine = 'daum';
        } else if (url.includes('search.naver.com/search')) {
            const params = new URLSearchParams(window.location.search);
            searchQuery = params.get('query') || '';
            searchEngine = 'naver';
        } else if (url.includes('search.yahoo.com/search')) {
            const params = new URLSearchParams(window.location.search);
            searchQuery = params.get('p') || '';
            searchEngine = 'yahoo';
        } else if (url.includes('duckduckgo.com/')) {
            const params = new URLSearchParams(window.location.search);
            searchQuery = params.get('q') || '';
            searchEngine = 'duckduckgo';
        } else if (url.includes('startpage.com/do/search')) {
            const params = new URLSearchParams(window.location.search);
            searchQuery = params.get('query') || '';
            searchEngine = 'startpage';
        } else if (url.includes('ecosia.org/search')) {
            const params = new URLSearchParams(window.location.search);
            searchQuery = params.get('q') || '';
            searchEngine = 'ecosia';
        } else if (url.includes('qwant.com/')) {
            const params = new URLSearchParams(window.location.search);
            searchQuery = params.get('q') || '';
            searchEngine = 'qwant';
        } else if (url.includes('ahmia.fi/')) {
            const params = new URLSearchParams(window.location.search);
            searchQuery = params.get('q') || '';
            searchEngine = 'ahmia';
        } else if (url.includes('torchsearch.de/')) {
            const params = new URLSearchParams(window.location.search);
            searchQuery = params.get('q') || '';
            searchEngine = 'torch';
        } else if (url.includes('notracker.org/')) {
            const params = new URLSearchParams(window.location.search);
            searchQuery = params.get('q') || '';
            searchEngine = 'notracker';
        } else {
            searchQuery = '';
            searchEngine = '';
        }
        log(`🔍 검색 엔진: ${capitalizeFirstLetter(searchEngine)}, 검색어: "${searchQuery}"`);
    }

    // 로그 기록 함수
    function log(message) {
        const time = new Date().toLocaleTimeString();
        const entry = `[${time}] ${message}`;
        logMessages.push(entry);
        logContainer.innerHTML += `${entry}<br>`;
        logContainer.scrollTop = logContainer.scrollHeight;
        GM_setValue('crawlerLogs', JSON.stringify(logMessages));
    }

    // 결과 내보내기 함수 (중복 제거 및 정렬 추가)
    function exportResults() {
        if (results.length === 0) {
            alert('내보낼 결과가 없습니다.');
            return;
        }
        const format = prompt('내보낼 형식을 선택하세요 (xlsx, csv, json):', 'xlsx');
        if (!format) return;
        if (format.toLowerCase() === 'xlsx') {
            const ws = XLSX.utils.json_to_sheet(results);
            const wb = XLSX.utils.book_new();
            XLSX.utils.book_append_sheet(wb, ws, "결과");
            XLSX.writeFile(wb, "크롤링_결과.xlsx");
            log('💾 결과를 "크롤링_결과.xlsx" 파일로 내보냈습니다.');
            GM_notification({
                text: '결과를 "크롤링_결과.xlsx" 파일로 내보냈습니다.',
                title: '웹 크롤러 8.6',
                timeout: 3000
            });
        } else if (format.toLowerCase() === 'csv') {
            const csv = results.map(row => `"${row.title.replace(/"/g, '""')}","${row.link.replace(/"/g, '""')}","${row.description.replace(/"/g, '""')}","${row.image.replace(/"/g, '""')}","${row.htmlLink}","${row.whoisInfo}","${row.pageLoadTime}","${row.language}","${row.metaKeywords}","${row.metaRobots}","${row.openGraph}","${row.securityHeaders}","${row.domainAge}","${row.techStack}"`).join('\n');
            const blob = new Blob([csv], { type: 'text/csv;charset=utf-8;' });
            const url = URL.createObjectURL(blob);
            const a = document.createElement('a');
            a.href = url;
            a.download = '크롤링_결과.csv';
            a.click();
            log('💾 결과를 "크롤링_결과.csv" 파일로 내보냈습니다.');
            GM_notification({
                text: '결과를 "크롤링_결과.csv" 파일로 내보냈습니다.',
                title: '웹 크롤러 8.6',
                timeout: 3000
            });
        } else if (format.toLowerCase() === 'json') {
            const json = JSON.stringify(results, null, 2);
            const blob = new Blob([json], { type: 'application/json;charset=utf-8;' });
            const url = URL.createObjectURL(blob);
            const a = document.createElement('a');
            a.href = url;
            a.download = '크롤링_결과.json';
            a.click();
            log('💾 결과를 "크롤링_결과.json" 파일로 내보냈습니다.');
            GM_notification({
                text: '결과를 "크롤링_결과.json" 파일로 내보냈습니다.',
                title: '웹 크롤러 8.6',
                timeout: 3000
            });
        } else {
            alert('지원하지 않는 형식입니다.');
        }
    }

    // 결과 테이블 정렬 함수
    function sortTable(n) {
        const table = document.getElementById("resultsTable");
        let switching = true;
        let dir = "asc";
        let switchcount = 0;
        while (switching) {
            switching = false;
            const rows = table.rows;
            for (let i = 1; i < (rows.length - 1); i++) {
                let shouldSwitch = false;
                const x = rows[i].getElementsByTagName("TD")[n];
                const y = rows[i + 1].getElementsByTagName("TD")[n];
                let xContent = x.textContent || x.innerText;
                let yContent = y.textContent || y.innerText;

                // 숫자 비교
                if (n === 6 || n === 12) { // 페이지 로딩 시간과 도메인 연령
                    xContent = parseInt(xContent);
                    yContent = parseInt(yContent);
                }

                if (dir === "asc") {
                    if (xContent > yContent) {
                        shouldSwitch = true;
                        break;
                    }
                } else if (dir === "desc") {
                    if (xContent < yContent) {
                        shouldSwitch = true;
                        break;
                    }
                }
            }
            if (shouldSwitch) {
                rows[i].parentNode.insertBefore(rows[i + 1], rows[i]);
                switching = true;
                switchcount++;
            } else {
                if (switchcount === 0 && dir === "asc") {
                    dir = "desc";
                    switching = true;
                }
            }
        }
    }

    // 사용자 경험 향상을 위한 함수 추가
    function capitalizeFirstLetter(string) {
        if (!string) return '';
        return string.charAt(0).toUpperCase() + string.slice(1);
    }

    // 항목 검색 기능
    function filterResults() {
        const filter = searchResultsInput.value.toLowerCase();
        const rows = resultsBody.getElementsByTagName('tr');
        for (let i = 0; i < rows.length; i++) {
            const cells = rows[i].getElementsByTagName('td');
            let match = false;
            for (let j = 0; j < cells.length - 9; j++) { // 제외 항목 인덱스 조정
                if (cells[j].innerText.toLowerCase().includes(filter)) {
                    match = true;
                    break;
                }
            }
            rows[i].style.display = match ? '' : 'none';
        }
    }

    // 로그 초기화 함수
    function clearLogs() {
        if(confirm('로그를 초기화하시겠습니까?')) {
            logMessages = [];
            logContainer.innerHTML = `<strong>로그:</strong><br>`;
            GM_setValue('crawlerLogs', JSON.stringify(logMessages));
            log('🧹 로그를 초기화하였습니다.');
        }
    }

    // 진행률 업데이트 함수
    function updateProgress() {
        if (totalPages === 0) {
            progressBar.value = 0;
            progressText.innerText = '0%';
            return;
        }
        const progress = Math.min((currentPage - 1) / totalPages * 100, 100);
        progressBar.value = progress;
        progressText.innerText = `${Math.round(progress)}%`;
    }

    // 크롤링 오류가 발생한 행에 대한 미리보기 추가
    function addPreviewEvents(row, link) {
        const htmlBtn = row.querySelector('.html-view-btn');
        if (htmlBtn) {
            htmlBtn.addEventListener('click', () => {
                const decodedLink = decodeURIComponent(htmlBtn.getAttribute('data-link'));
                openPreview(decodedLink);
            });

            // HTML 버튼에 마우스 호버 시 미리보기 표시
            htmlBtn.addEventListener('mouseover', (e) => {
                const decodedLink = decodeURIComponent(htmlBtn.getAttribute('data-link'));
                showPreview(e, decodedLink);
            });
            htmlBtn.addEventListener('mouseout', hidePreview);
        }
    }

    // 미리보기 표시 함수
    function showPreview(event, link) {
        tooltip.style.left = event.pageX + 'px';
        tooltip.style.top = event.pageY + 'px';
        tooltip.style.display = 'block';
        tooltip.innerHTML = `<iframe src="${link}" title="미리보기"></iframe>`;
    }

    function hidePreview() {
        tooltip.style.display = 'none';
        tooltip.innerHTML = '';
    }

    // 사이트 미리보기 열기 함수
    function openPreview(link) {
        const analyticsTab = container.querySelector('#analytics');
        const previewContainerId = 'site-preview-container';
        let previewContainer = container.querySelector(`#${previewContainerId}`);

        if (!previewContainer) {
            previewContainer = document.createElement('div');
            previewContainer.id = previewContainerId;
            previewContainer.className = 'chart-container';
            previewContainer.style.height = '400px';
            analyticsTab.appendChild(previewContainer);
        }

        previewContainer.innerHTML = `
            <h3>사이트 미리보기: <a href="${link}" target="_blank">${link}</a></h3>
            <iframe src="${link}" style="width: 100%; height: 350px; border: none; border-radius: 5px;"></iframe>
        `;

        // 분석 탭으로 이동
        const analyticsTabBtn = container.querySelector('.tab[data-tab="analytics"]');
        analyticsTabBtn.click();
    }

    // WHOIS 정보 가져오기 및 표시 함수
    function fetchWhoisData(domain) {
        log(`📡 WHOIS 정보를 가져오는 중: ${domain}`);
        const apiUrl = `https://jsonwhois.com/api/v1/whois?domain=${encodeURIComponent(domain)}`;

        GM_xmlhttpRequest({
            method: "GET",
            url: apiUrl,
            headers: {
                "Content-Type": "application/json",
                "Authorization": `Token token=${WHOIS_API_KEY}`
            },
            onload: function(response) {
                if (response.status === 200) {
                    const data = JSON.parse(response.responseText);
                    displayWhoisData(data, domain);
                    log(`✅ WHOIS 정보를 성공적으로 가져왔습니다: ${domain}`);
                    document.getElementById('successfulRequests').innerText = parseInt(document.getElementById('successfulRequests').innerText) + 1;
                } else {
                    log(`❌ WHOIS 정보 가져오기 실패: ${domain}, 상태 코드: ${response.status}`);
                    whoisContent.innerHTML = `<p>WHOIS 정보를 가져오는 데 실패했습니다.</p>`;
                    whoisModal.style.display = 'block';
                }
            },
            onerror: function() {
                log(`❌ WHOIS 정보 요청 중 오류 발생: ${domain}`);
                document.getElementById('failedRequests').innerText = parseInt(document.getElementById('failedRequests').innerText) + 1;
                whoisContent.innerHTML = `<p>WHOIS 정보를 가져오는 데 오류가 발생했습니다.</p>`;
                whoisModal.style.display = 'block';
            }
        });
    }

    // WHOIS 데이터 표시 함수
    function displayWhoisData(data, domain) {
        if (!data) {
            whoisContent.innerHTML = `<p>No WHOIS data available.</p>`;
            whoisModal.style.display = 'block';
            return;
        }

        const whoisHtml = `
            <h3>${domain}의 WHOIS 정보</h3>
            <pre>${JSON.stringify(data, null, 2)}</pre>
        `;
        whoisContent.innerHTML = whoisHtml;
        whoisModal.style.display = 'block';
    }

    // *******************************
    // 시작
    // *******************************
})();WHOIS 정보에서 버튼을 누르면 바로 보이게 하라고.

사이트 정보를 더 빨리 많이 얻을 수 있는 기능들을 추가해.
사이트 정보를 분석할 수 있는 기능들을 추가해

분석을 더 자세하게 하기 위한 다양한 가능들을 추가해! 그리고 기능들을 대폭 대폭 개선해! + 모듈화나 코드 최적화 코드 삭제 이런 거는 절대 하지 마셈
스크립트 시스템 대폭 대폭 개선
스크립트 기능들도 초 격차로 대폭 대폭 개선
기능들을 사용자의 편의성과 가독성을 위해 대폭 개선

(크롤링 속도 조절 기능은 그냥 아예 없애샘 만약 있으면 없애셈

설정 ㅈㄴ ㅈㄴ ㅈㄴ ㅈㄴ 다양하게 하셈 코드 상으로만 구현되어 있는 기능도 포함

코드 가독성 향상 (주석 다는 거) 이거 진짜 하지 마셈
기능 최적화: 불필요한 코드 제거 및 로직 최적화를 통해 성능을 향상시켰습니다. (이겨 진짜 하지 마셈 )
한 단계 올릴 수준으로 기능들을 대폭 개선하셈 스크립트의 수준을 한 단계 올릴 만큼

그리고 내가 지금 말하는 거에 집중해 전에 말한 거 에 집중하지 말고 알겠지? 전에 한 거는 신경쓰지 마셈

그리고 "기존에 있던 기능들" 성능들 편의성이나 가도성 대폭 대폭 대폭 대폭 초 대폭 초초초초초초초초초초초초 대폭 개선하셈

ui 대폭 대폭 편의성과 가독성을 전부다 가져온 ui 이여야 함

시작 자체가 안 되면 안 됨. 시작 자체는 되야 함 + 이 스크립트의 크롤링의 속도를 제한 시킬 수 있는 게 있다면 없애! 지금 당장! + 무조건 속도는 100ms으로 통일 한다. + ui 대폭 개선+ 창 좀 작게 해주셈

 ❌ 페이지 로딩 오류: "https://www.tiktok.com/@qazws.4" 이거 안 나게 하셈
ASSISTANT
```javascript
// ==UserScript==
// @name         종합 웹 크롤러 8.6 초격차 개선 버전
// @namespace    http://tampermonkey.net/
// @version      8.6.3
// @description  고급 기능을 갖춘 웹 크롤러로 더 빠르고 많은 검색 결과를 실시간으로 수집하고 자세한 분석을 제공합니다 (초격차 개선 버전)
// @author       YourName
// @match        *://www.google.com/search*
// @match        *://www.bing.com/search*
// @match        *://search.daum.net/search*
// @match        *://search.naver.com/search*
// @match        *://search.yahoo.com/search*
// @match        *://duckduckgo.com/*
// @match        *://www.startpage.com/do/search*
// @match        *://www.ecosia.org/search*
// @match        *://www.qwant.com/*
// @match        *://ahmia.fi/*
// @match        *://torchsearch.de/*
// @match        *://notracker.org/*
// @grant        GM_xmlhttpRequest
// @grant        GM_addStyle
// @grant        GM_setValue
// @grant        GM_getValue
// @grant        GM_notification
// @connect      *
// @require      https://cdnjs.cloudflare.com/ajax/libs/xlsx/0.18.5/xlsx.full.min.js
// @require      https://cdn.jsdelivr.net/npm/chart.js
// ==/UserScript==

(function() {
    'use strict';

    // *******************************
    // API 키 설정 (필요 시 본인의 API 키로 변경)
    // *******************************
    const WHOIS_API_KEY = 'YOUR_JSONWHOIS_API_KEY'; // 여기에 본인의 JSONWHOIS API 키를 입력하세요.

    GM_addStyle(`
        /* UI 전반적인 스타일 개선 */
        #crawler-container {
            position: fixed;
            top: 20px;
            right: 20px;
            background-color: #ffffff;
            border: 3px solid #2196F3;
            padding: 10px;
            z-index: 10000;
            width: 500px;
            max-height: 75vh;
            overflow: hidden;
            box-shadow: 0 6px 20px rgba(0,0,0,0.3);
            border-radius: 10px;
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
            font-size: 14px;
            resize: both;
            display: flex;
            flex-direction: column;
            transition: all 0.3s ease;
        }
        #crawler-container header {
            cursor: move;
            background-color: #2196F3;
            color: white;
            padding: 8px 12px;
            border-radius: 8px 8px 0 0;
            text-align: center;
            font-size: 18px;
            font-weight: bold;
            display: flex;
            justify-content: space-between;
            align-items: center;
        }
        #crawler-container header .title {
            flex-grow: 1;
        }
        #crawler-container header .close-btn {
            cursor: pointer;
            font-size: 20px;
            color: #FF5252;
            margin-left: 10px;
        }
        #crawler-container .tabs {
            display: flex;
            border-bottom: 2px solid #2196F3;
            margin-top: 5px;
        }
        #crawler-container .tab {
            flex: 1;
            padding: 8px 0;
            text-align: center;
            cursor: pointer;
            background-color: #E3F2FD;
            border-right: 1px solid #BBDEFB;
            font-weight: bold;
            transition: background-color 0.3s, color 0.3s;
            font-size: 13px;
        }
        #crawler-container .tab:last-child {
            border-right: none;
        }
        #crawler-container .tab.active {
            background-color: #FFFFFF;
            border-bottom: 3px solid #2196F3;
            color: #2196F3;
        }
        #crawler-container .tab-content {
            display: none;
            padding: 10px;
            overflow-y: auto;
            flex-grow: 1;
        }
        #crawler-container .tab-content.active {
            display: block;
        }
        #crawler-container button {
            padding: 6px 10px;
            margin: 4px 2px;
            border: none;
            border-radius: 4px;
            background-color: #2196F3;
            color: white;
            cursor: pointer;
            transition: background-color 0.3s;
            font-size: 13px;
        }
        #crawler-container button:hover {
            background-color: #1976D2;
        }
        #crawler-container button.export-btn {
            background-color: #4CAF50;
        }
        #crawler-container button.export-btn:hover {
            background-color: #388E3C;
        }
        #crawler-container button.pause-btn {
            background-color: #FFC107;
        }
        #crawler-container button.pause-btn:hover {
            background-color: #FFA000;
        }
        #crawler-container .options,
        #crawler-container .filters,
        #crawler-container .exclude-domains,
        #crawler-container .advanced-options,
        #crawler-container .controls,
        #crawler-container .search-engines {
            margin-bottom: 10px;
            display: flex;
            flex-wrap: wrap;
            align-items: center;
            justify-content: space-between;
        }
        #crawler-container .options label,
        #crawler-container .advanced-options label,
        #crawler-container .controls label,
        #crawler-container .search-engines label {
            margin-right: 10px;
            display: inline-flex;
            align-items: center;
            font-weight: normal;
            font-size: 13px;
        }
        #crawler-container .options input[type="checkbox"],
        #crawler-container .advanced-options input[type="checkbox"],
        #crawler-container .controls input[type="number"],
        #crawler-container .search-engines select {
            margin-right: 6px;
        }
        #crawler-container input[type="text"],
        #crawler-container textarea,
        #crawler-container select {
            width: 100%;
            padding: 6px;
            margin: 4px 0 8px 0;
            border: 1px solid #B0BEC5;
            border-radius: 4px;
            font-size: 13px;
        }
        #crawler-container table {
            border-collapse: collapse;
            width: 100%;
            margin-top: 8px;
            font-size: 13px;
        }
        #crawler-container th, #crawler-container td {
            padding: 8px;
            border: 1px solid #E0E0E0;
            text-align: left;
            vertical-align: top;
        }
        #crawler-container th {
            background-color: #2196F3;
            color: white;
            position: sticky;
            top: 0;
            z-index: 1;
            cursor: pointer;
        }
        #crawler-container .log {
            max-height: 150px;
            overflow-y: auto;
            background-color: #E3F2FD;
            padding: 8px;
            border: 1px solid #81D4FA;
            border-radius: 4px;
            font-size: 13px;
            white-space: pre-wrap;
        }
        #crawler-container progress {
            width: 75%;
            height: 18px;
            margin-right: 8px;
            border-radius: 4px;
        }
        #crawler-container .status {
            margin-top: 8px;
            font-weight: bold;
            font-size: 13px;
        }
        #crawler-container .chart-container {
            position: relative;
            height: 200px;
            width: 100%;
            margin-top: 15px;
        }
        #crawler-container .notification-area {
            flex-direction: row;
            align-items: center;
            width: 100%;
        }
        @media (max-width: 600px) {
            #crawler-container {
                width: 95%;
                right: 2.5%;
            }
            #crawler-container .controls,
            #crawler-container .options,
            #crawler-container .advanced-options,
            #crawler-container .notification-area,
            #crawler-container .search-engines {
                flex-direction: column;
                align-items: flex-start;
            }
            #crawler-container .search-engines select {
                width: 100%;
            }
            #crawler-container progress {
                width: 100%;
            }
        }
        /* WHOIS Modal 스타일 */
        #whois-modal {
            display: none;
            position: fixed;
            z-index: 10001;
            left: 50%;
            top: 50%;
            transform: translate(-50%, -50%);
            width: 90%;
            max-width: 800px;
            height: 70vh;
            background-color: #ffffff;
            border: 3px solid #2196F3;
            border-radius: 10px;
            box-shadow: 0 6px 20px rgba(0,0,0,0.3);
            overflow: hidden;
            flex-direction: column;
            display: flex;
        }
        #whois-modal header {
            background-color: #2196F3;
            color: white;
            padding: 10px 16px;
            cursor: move;
            display: flex;
            justify-content: space-between;
            align-items: center;
        }
        #whois-modal header .close-modal-btn {
            cursor: pointer;
            font-size: 20px;
            color: #FF5252;
        }
        #whois-modal .modal-content {
            padding: 16px;
            overflow-y: auto;
            flex-grow: 1;
            background-color: #E3F2FD;
        }
        /* Tooltip 스타일 */
        .preview-tooltip {
            position: absolute;
            background-color: #ffffff;
            border: 1px solid #90CAF9;
            border-radius: 5px;
            padding: 6px;
            z-index: 10002;
            box-shadow: 0 4px 12px rgba(0,0,0,0.3);
            display: none;
            width: 250px;
        }
        .preview-tooltip iframe {
            width: 100%;
            height: 150px;
            border: none;
            border-radius: 5px;
        }
    `);

    const container = document.createElement('div');
    container.id = 'crawler-container';
    container.innerHTML = `
        <header>
            <span class="title">🔥 웹 크롤러 8.6</span>
            <span class="close-btn" title="닫기">&times;</span>
        </header>
        <div class="tabs">
            <div class="tab active" data-tab="settings">설정</div>
            <div class="tab" data-tab="results">결과</div>
            <div class="tab" data-tab="logs">로그</div>
            <div class="tab" data-tab="analytics">분석</div>
            <div class="tab" data-tab="about">정보</div>
        </div>
        <div class="tab-content active" id="settings">
            <div class="notification-area">
                <button id="startBtn" title="크롤링 시작">▶️ 시작</button>
                <button id="pauseBtn" class="pause-btn" title="크롤링 일시정지/재개">⏸️ 일시정지</button>
                <button id="stopBtn" title="크롤링 중지">⏹️ 중지</button>
                <button id="resetBtn" title="크롤링 초기화">🔄 초기화</button>
                <button id="exportBtn" class="export-btn" title="결과 내보내기">💾 내보내기</button>
                <button id="clearLogsBtn" title="로그 초기화">🧹 로그 초기화</button>
            </div>
            <div class="search-engines">
                <label for="searchEngineSelect">검색 엔진 선택:</label>
                <select id="searchEngineSelect">
                    <option value="google" selected>Google</option>
                    <option value="bing">Bing</option>
                    <option value="daum">Daum</option>
                    <option value="naver">Naver</option>
                    <option value="yahoo">Yahoo</option>
                    <option value="duckduckgo">DuckDuckGo</option>
                    <option value="startpage">StartPage</option>
                    <option value="ecosia">Ecosia</option>
                    <option value="qwant">Qwant</option>
                    <option value="ahmia">Ahmia (Tor)</option>
                    <option value="torch">Torch (Tor)</option>
                    <option value="notracker">NOTRACKER (Tor)</option>
                </select>
            </div>
            <div class="options">
                <label><input type="checkbox" id="toggleHTML" checked> HTML 가져오기</label>
                <label><input type="checkbox" id="toggleImages" checked> 이미지 가져오기</label>
                <label><input type="checkbox" id="toggleAds" checked> 광고 제외</label>
                <label><input type="checkbox" id="toggleTechStack" checked> 기술 스택 분석</label>
                <label><input type="checkbox" id="toggleOpenGraph" checked> OpenGraph 정보 가져오기</label>
                <label><input type="checkbox" id="toggleSecurityHeaders" checked> 보안 헤더 분석</label>
                <label><input type="checkbox" id="toggleDomainAge" checked> 도메인 연령 분석</label>
            </div>
            <div class="filters">
                <label for="filterInput">필터 단어 (정규식 또는 단어, 쉼표로 구분):</label>
                <input type="text" id="filterInput" placeholder="예: 기부, 광고, /promo/i">
            </div>
            <div class="exclude-domains">
                <label for="excludeDomainsInput">제외할 도메인 (쉼표로 구분):</label>
                <input type="text" id="excludeDomainsInput" placeholder="예: facebook.com, youtube.com">
            </div>
            <div class="advanced-options">
                <label for="duplicateThreshold">중복 허용 횟수:</label>
                <input type="number" id="duplicateThreshold" value="2" min="1" style="width: 60px;">
                <label for="retryAttempts">재시도 횟수:</label>
                <input type="number" id="retryAttempts" value="3" min="1" style="width: 60px;">
            </div>
            <div style="margin-top:10px;">
                <label for="progressBar">진행률:</label>
                <progress id="progressBar" value="0" max="100"></progress>
                <span id="progressText">0%</span>
            </div>
            <div class="status">
                현재 페이지: <span id="currentPage">0</span> /
                총 페이지: <span id="totalPages">0</span>
                <br>
                방문된 사이트: <span id="visitedCount">0</span>
                <br>
                총 요청 수: <span id="totalRequests">0</span>
                <br>
                성공 요청 수: <span id="successfulRequests">0</span>
                <br>
                실패 요청 수: <span id="failedRequests">0</span>
                <br>
                경과 시간: <span id="elapsedTime">00:00:00</span>
                <br>
                예상 남은 시간: <span id="remainingTime">00:00:00</span>
            </div>
        </div>
        <div class="tab-content" id="results">
            <div style="margin-top:8px; max-height: 300px; overflow: auto;">
                <table id="resultsTable">
                    <thead>
                        <tr>
                            <th data-sort="0">사이트 이름 &#x25B2;&#x25BC;</th>
                            <th data-sort="1">주소 &#x25B2;&#x25BC;</th>
                            <th data-sort="2">설명 &#x25B2;&#x25BC;</th>
                            <th>이미지</th>
                            <th>HTML 링크</th>
                            <th>WHOIS 정보</th>
                            <th data-sort="6">페이지 로딩 시간 (ms) &#x25B2;&#x25BC;</th>
                            <th>언어</th>
                            <th>메타 키워드</th>
                            <th>메타 robots</th>
                            <th>OpenGraph</th>
                            <th>보안 헤더</th>
                            <th>도메인 연령</th>
                            <th>기술 스택</th>
                        </tr>
                    </thead>
                    <tbody id="resultsBody">
                    </tbody>
                </table>
            </div>
            <div style="margin-top:10px;">
                <input type="text" id="searchResultsInput" placeholder="결과 검색...">
            </div>
        </div>
        <div class="tab-content" id="logs">
            <div class="log" id="log">
                <strong>로그:</strong>
            </div>
        </div>
        <div class="tab-content" id="analytics">
            <div class="chart-container">
                <canvas id="crawlChart"></canvas>
            </div>
            <div class="chart-container">
                <canvas id="loadTimeChart"></canvas>
            </div>
            <div class="chart-container">
                <canvas id="domainDistributionChart"></canvas>
            </div>
            <div class="chart-container">
                <canvas id="errorRateChart"></canvas>
            </div>
            <div class="chart-container">
                <canvas id="cumulativeVisitsChart"></canvas>
            </div>
            <div class="chart-container">
                <canvas id="keywordDistributionChart"></canvas>
            </div>
            <div class="chart-container">
                <canvas id="languageDistributionChart"></canvas>
            </div>
            <div class="chart-container">
                <canvas id="techStackChart"></canvas>
            </div>
            <div class="chart-container">
                <canvas id="domainAgeChart"></canvas>
            </div>
            <div id="whois-modal">
                <header>
                    <span>WHOIS 정보</span>
                    <span class="close-modal-btn" title="닫기">&times;</span>
                </header>
                <div class="modal-content" id="whoisContent">
                    <!-- WHOIS 정보가 여기에 표시됩니다 -->
                </div>
            </div>
        </div>
        <div class="tab-content" id="about">
            <h2>웹 크롤러 8.6 정보</h2>
            <p>종합 웹 크롤러는 다양한 검색 엔진에서 빠르게 검색 결과를 수집하고 심층 분석할 수 있는 도구입니다. 사용자의 편의성과 데이터 가독성을 극대화하여 초격차로 개선된 버전입니다.</p>
            <ul>
                <li>지원하는 검색 엔진: Google, Bing, Daum, Naver, Yahoo, DuckDuckGo, StartPage, Ecosia, Qwant, Ahmia (Tor), Torch (Tor), NOTRACKER (Tor)</li>
                <li>실시간 검색어 감지 및 고속 크롤링</li>
                <li>고급 필터링 및 제외 옵션 제공</li>
                <li>결과를 XLSX, CSV, JSON 형식으로 내보내기</li>
                <li>시각화된 데이터 차트 및 그래프 제공</li>
                <li>사용자 친화적인 인터페이스 및 반응형 디자인</li>
                <li>결과 테이블 정렬 및 실시간 검색 기능 추가</li>
                <li>상세한 로그 제공</li>
                <li>페이지 로딩 시간 및 언어 분석</li>
                <li>WHOIS 정보 연동 및 즉시 보기 기능</li>
                <li>도메인 연령 분석 기능 추가</li>
                <li>추가적인 보안 헤더 분석 기능</li>
                <li>기술 스택 분석 기능 강화</li>
                <li>다양한 알림 방식 지원</li>
                <li>자동 스크롤 및 실시간 업데이트</li>
                <li>고급 에러 핸들링 및 재시도 로직 강화</li>
                <li>로그 초기화 및 결과 검색 기능 추가</li>
                <li>추가 분석 탭에서 다양한 그래프 제공</li>
                <li>도메인 분포 및 오류 발생률 분석</li>
                <li>누적 방문 횟수 추적</li>
                <li>HTML 링크 클릭 시 UI 내에서 사이트 미리보기 제공</li>
                <li>마우스 호버 시 사이트 미리보기 표시</li>
                <li>WHOIS 정보 바로보기 및 상세 분석 기능 추가</li>
                <li>추가 메타 정보 수집 및 분석 기능 강화</li>
                <li>더 빠르고 많은 사이트 정보 수집 기능 추가</li>
                <li>사이트 기술 스택 심층 분석 기능 추가</li>
            </ul>
            <p><strong>버전:</strong> 8.6.3</p>
            <p><strong>제작자:</strong> YourName</p>
            <p><strong>문의:</strong> your.email@example.com</p>
        </div>
    `;
    document.body.appendChild(container);

    // 드래그 기능
    (function makeDraggable(elmnt) {
        const header = elmnt.querySelector('header');
        const closeBtn = elmnt.querySelector('.close-btn');
        let pos1 = 0, pos2 = 0, pos3 = 0, pos4 = 0;
        header.onmousedown = dragMouseDown;

        closeBtn.onclick = () => {
            elmnt.style.display = 'none';
            log('🗑 크롤러 창을 닫았습니다.');
        }

        function dragMouseDown(e) {
            e = e || window.event;
            e.preventDefault();
            pos3 = e.clientX;
            pos4 = e.clientY;
            document.onmouseup = closeDragElement;
            document.onmousemove = elementDrag;
        }

        function elementDrag(e) {
            e = e || window.event;
            e.preventDefault();
            pos1 = pos3 - e.clientX;
            pos2 = pos4 - e.clientY;
            pos3 = e.clientX;
            pos4 = e.clientY;
            elmnt.style.top = (elmnt.offsetTop - pos2) + "px";
            elmnt.style.left = (elmnt.offsetLeft - pos1) + "px";
        }

        function closeDragElement() {
            document.onmouseup = null;
            document.onmousemove = null;
        }
    })(container);

    // 탭 설정
    (function setupTabs() {
        const tabs = container.querySelectorAll('.tab');
        const tabContents = container.querySelectorAll('.tab-content');

        tabs.forEach(tab => {
            tab.addEventListener('click', () => {
                tabs.forEach(t => t.classList.remove('active'));
                tab.classList.add('active');

                const target = tab.getAttribute('data-tab');
                tabContents.forEach(content => {
                    if(content.id === target){
                        content.classList.add('active');
                    } else {
                        content.classList.remove('active');
                    }
                });
            });
        });
    })();

    // 변수 초기화
    let isRunning = false;
    let isPaused = false;
    let currentPage = 1;
    let totalPages = 0;
    let results = [];
    let searchQuery = '';
    let searchEngine = 'google';
    let visitedLinks = new Map();
    let logMessages = [];
    let filterPatterns = [];
    let excludeDomains = [];
    let duplicateThreshold = 2;
    let retryAttempts = 3;
    let retryInterval = 100; // 고정적으로 100ms 설정
    let startTime = null;
    let elapsedInterval = null;
    let crawlChart = null;
    let loadTimeChart = null;
    let domainDistributionChart = null;
    let errorRateChart = null;
    let cumulativeVisitsChart = null;
    let keywordDistributionChart = null;
    let languageDistributionChart = null;
    let techStackChart = null;
    let domainAgeChart = null;
    let crawlData = {
        labels: [],
        datasets: [{
            label: '방문 횟수',
            data: [],
            backgroundColor: 'rgba(33, 150, 243, 0.6)',
            borderColor: 'rgba(33, 150, 243, 1)',
            borderWidth: 1
        },
        {
            label: '평균 페이지 로딩 시간 (ms)',
            data: [],
            backgroundColor: 'rgba(76, 175, 80, 0.6)',
            borderColor: 'rgba(76, 175, 80, 1)',
            borderWidth: 1
        }]
    };
    let loadTimeData = {
        labels: [],
        datasets: [{
            label: '페이지 로딩 시간 (ms)',
            data: [],
            backgroundColor: 'rgba(255, 193, 7, 0.6)',
            borderColor: 'rgba(255,193,7,1)',
            borderWidth: 1
        }]
    };
    let domainDistributionData = {
        labels: [],
        datasets: [{
            label: '도메인 분포',
            data: [],
            backgroundColor: [
                'rgba(33, 150, 243, 0.6)',
                'rgba(255, 87, 34, 0.6)',
                'rgba(76, 175, 80, 0.6)',
                'rgba(156, 39, 176, 0.6)',
                'rgba(255, 152, 0, 0.6)',
                'rgba(244, 67, 54, 0.6)',
                'rgba(158, 158, 158, 0.6)'
            ],
            borderColor: 'rgba(33, 150, 243, 1)',
            borderWidth: 1
        }]
    };
    let errorRateData = {
        labels: [],
        datasets: [{
            label: '오류 발생 수',
            data: [],
            backgroundColor: 'rgba(255, 99, 132, 0.6)',
            borderColor: 'rgba(255, 99, 132,1)',
            borderWidth: 1
        }]
    };
    let cumulativeVisitsData = {
        labels: [],
        datasets: [{
            label: '누적 방문 횟수',
            data: [],
            backgroundColor: 'rgba(3, 169, 244, 0.6)',
            borderColor: 'rgba(3, 169, 244,1)',
            borderWidth: 1
        }]
    };
    let keywordDistributionData = {
        labels: [],
        datasets: [{
            label: '키워드 분포',
            data: [],
            backgroundColor: [
                'rgba(63, 81, 181, 0.6)',
                'rgba(255, 152, 0, 0.6)',
                'rgba(76, 175, 80, 0.6)',
                'rgba(244, 67, 54, 0.6)',
                'rgba(33, 150, 243, 0.6)',
                'rgba(153, 102, 255, 0.6)'
            ],
            borderColor: 'rgba(63, 81, 181,1)',
            borderWidth: 1
        }]
    };
    let languageDistributionData = {
        labels: [],
        datasets: [{
            label: '언어 분포',
            data: [],
            backgroundColor: [
                'rgba(38, 166, 154, 0.6)',
                'rgba(211, 47, 47, 0.6)',
                'rgba(3, 169, 244, 0.6)',
                'rgba(255, 193, 7, 0.6)',
                'rgba(156, 39, 176, 0.6)',
                'rgba(0, 188, 212, 0.6)'
            ],
            borderColor: 'rgba(38, 166, 154,1)',
            borderWidth: 1
        }]
    };
    let techStackData = {
        labels: [],
        datasets: [{
            label: '기술 스택 분포',
            data: [],
            backgroundColor: [
                'rgba(103, 58, 183, 0.6)',
                'rgba(255, 202, 40, 0.6)',
                'rgba(0, 150, 136, 0.6)',
                'rgba(233, 30, 99, 0.6)',
                'rgba(245, 124, 0, 0.6)',
                'rgba(255, 235, 59, 0.6)'
            ],
            borderColor: 'rgba(103, 58, 183,1)',
            borderWidth: 1
        }]
    };
    let domainAgeData = {
        labels: [],
        datasets: [{
            label: '도메인 연령 분포 (년)',
            data: [],
            backgroundColor: [
                'rgba(255, 159, 64, 0.6)',
                'rgba(75, 192, 192, 0.6)',
                'rgba(54, 162, 235, 0.6)',
                'rgba(153, 102, 255, 0.6)',
                'rgba(255, 99, 132, 0.6)'
            ],
            borderColor: 'rgba(255, 159, 64,1)',
            borderWidth: 1
        }]
    };

    // 요소 참조
    const startBtn = document.getElementById('startBtn');
    const pauseBtn = document.getElementById('pauseBtn');
    const stopBtn = document.getElementById('stopBtn');
    const resetBtn = document.getElementById('resetBtn');
    const exportBtn = document.getElementById('exportBtn');
    const clearLogsBtn = document.getElementById('clearLogsBtn');
    const progressBar = document.getElementById('progressBar');
    const progressText = document.getElementById('progressText');
    const resultsBody = document.getElementById('resultsBody');
    const logContainer = document.getElementById('log');
    const currentPageElem = document.getElementById('currentPage');
    const totalPagesElem = document.getElementById('totalPages');
    const toggleHTML = document.getElementById('toggleHTML');
    const toggleImages = document.getElementById('toggleImages');
    const toggleAds = document.getElementById('toggleAds');
    const toggleTechStack = document.getElementById('toggleTechStack');
    const toggleOpenGraph = document.getElementById('toggleOpenGraph');
    const toggleSecurityHeaders = document.getElementById('toggleSecurityHeaders');
    const toggleDomainAge = document.getElementById('toggleDomainAge');
    const filterInput = document.getElementById('filterInput');
    const excludeDomainsInput = document.getElementById('excludeDomainsInput');
    const duplicateThresholdInput = document.getElementById('duplicateThreshold');
    const retryAttemptsInput = document.getElementById('retryAttempts');
    const visitedCountElem = document.getElementById('visitedCount');
    const elapsedTimeElem = document.getElementById('elapsedTime');
    const remainingTimeElem = document.getElementById('remainingTime');
    const crawlChartCtx = document.getElementById('crawlChart').getContext('2d');
    const loadTimeChartCtx = document.getElementById('loadTimeChart').getContext('2d');
    const domainDistributionChartCtx = document.getElementById('domainDistributionChart').getContext('2d');
    const errorRateChartCtx = document.getElementById('errorRateChart').getContext('2d');
    const cumulativeVisitsChartCtx = document.getElementById('cumulativeVisitsChart').getContext('2d');
    const keywordDistributionChartCtx = document.getElementById('keywordDistributionChart').getContext('2d');
    const languageDistributionChartCtx = document.getElementById('languageDistributionChart').getContext('2d');
    const techStackChartCtx = document.getElementById('techStackChart').getContext('2d');
    const domainAgeChartCtx = document.getElementById('domainAgeChart').getContext('2d');
    const searchEngineSelect = document.getElementById('searchEngineSelect');
    const searchResultsInput = document.getElementById('searchResultsInput');
    const whoisModal = document.getElementById('whois-modal');
    const whoisContent = document.getElementById('whoisContent');
    const closeModalBtn = whoisModal.querySelector('.close-modal-btn');

    // 미리보기 툴팁 생성
    const tooltip = document.createElement('div');
    tooltip.className = 'preview-tooltip';
    document.body.appendChild(tooltip);

    // 이벤트 리스너 등록
    startBtn.addEventListener('click', startCrawling);
    pauseBtn.addEventListener('click', togglePause);
    stopBtn.addEventListener('click', stopCrawling);
    resetBtn.addEventListener('click', resetCrawling);
    exportBtn.addEventListener('click', exportResults);
    clearLogsBtn.addEventListener('click', clearLogs);
    filterInput.addEventListener('input', filterResults);
    excludeDomainsInput.addEventListener('input', updateExcludeDomains);
    duplicateThresholdInput.addEventListener('change', updateDuplicateThreshold);
    retryAttemptsInput.addEventListener('change', updateRetryAttempts);
    searchEngineSelect.addEventListener('change', updateSearchEngine);
    searchResultsInput.addEventListener('input', filterResults);
    closeModalBtn.addEventListener('click', () => {
        whoisModal.style.display = 'none';
        whoisContent.innerHTML = '';
    });

    window.addEventListener('beforeunload', () => {
        resetCrawling();
    });

    // 로그 및 크롤 데이터 로드
    loadLogs();
    loadCrawlData();
    loadSettings();

    // 차트 초기화 함수
    function initializeChart() {
        crawlChart = new Chart(crawlChartCtx, {
            type: 'bar',
            data: crawlData,
            options: {
                responsive: true,
                maintainAspectRatio: false,
                scales: {
                    y: {
                        beginAtZero: true,
                        ticks: {
                            precision:0
                        }
                    }
                },
                plugins: {
                    legend: {
                        display: true,
                        position: 'top'
                    },
                    tooltip: {
                        enabled: true
                    }
                }
            }
        });

        loadTimeChart = new Chart(loadTimeChartCtx, {
            type: 'line',
            data: loadTimeData,
            options: {
                responsive: true,
                maintainAspectRatio: false,
                scales: {
                    y: {
                        beginAtZero: true,
                        ticks: {
                            precision:0
                        }
                    }
                },
                plugins: {
                    legend: {
                        display: true,
                        position: 'top'
                    },
                    tooltip: {
                        enabled: true
                    }
                }
            }
        });

        domainDistributionChart = new Chart(domainDistributionChartCtx, {
            type: 'pie',
            data: domainDistributionData,
            options: {
                responsive: true,
                maintainAspectRatio: false,
                plugins: {
                    legend: {
                        display: true,
                        position: 'right'
                    },
                    tooltip: {
                        enabled: true
                    }
                }
            }
        });

        errorRateChart = new Chart(errorRateChartCtx, {
            type: 'bar',
            data: errorRateData,
            options: {
                responsive: true,
                maintainAspectRatio: false,
                scales: {
                    y: {
                        beginAtZero: true,
                        ticks: {
                            precision:0
                        }
                    }
                },
                plugins: {
                    legend: {
                        display: false
                    },
                    tooltip: {
                        enabled: true
                    }
                }
            }
        });

        cumulativeVisitsChart = new Chart(cumulativeVisitsChartCtx, {
            type: 'line',
            data: cumulativeVisitsData,
            options: {
                responsive: true,
                maintainAspectRatio: false,
                scales: {
                    y: {
                        beginAtZero: true,
                        ticks: {
                            precision:0
                        }
                    }
                },
                plugins: {
                    legend: {
                        display: true,
                        position: 'top'
                    },
                    tooltip: {
                        enabled: true
                    }
                }
            }
        });

        keywordDistributionChart = new Chart(keywordDistributionChartCtx, {
            type: 'doughnut',
            data: keywordDistributionData,
            options: {
                responsive: true,
                maintainAspectRatio: false,
                plugins: {
                    legend: {
                        display: true,
                        position: 'right'
                    },
                    tooltip: {
                        enabled: true
                    }
                }
            }
        });

        languageDistributionChart = new Chart(languageDistributionChartCtx, {
            type: 'pie',
            data: languageDistributionData,
            options: {
                responsive: true,
                maintainAspectRatio: false,
                plugins: {
                    legend: {
                        display: true,
                        position: 'right'
                    },
                    tooltip: {
                        enabled: true
                    }
                }
            }
        });

        techStackChart = new Chart(techStackChartCtx, {
            type: 'bar',
            data: techStackData,
            options: {
                responsive: true,
                maintainAspectRatio: false,
                scales: {
                    y: {
                        beginAtZero: true,
                        ticks: {
                            precision:0
                        }
                    }
                },
                plugins: {
                    legend: {
                        display: false
                    },
                    tooltip: {
                        enabled: true
                    }
                }
            }
        });

        domainAgeChart = new Chart(domainAgeChartCtx, {
            type: 'bar',
            data: domainAgeData,
            options: {
                responsive: true,
                maintainAspectRatio: false,
                scales: {
                    y: {
                        beginAtZero: true,
                        title: {
                            display: true,
                            text: '연령 (년)'
                        }
                    }
                },
                plugins: {
                    legend: {
                        display: false
                    },
                    tooltip: {
                        enabled: true
                    }
                }
            }
        });
    }
    initializeChart();

    // 설정 로드
    function loadSettings() {
        const storedSearchEngine = GM_getValue('searchEngine', 'google');
        searchEngine = storedSearchEngine;
        searchEngineSelect.value = searchEngine;

        const storedToggleHTML = GM_getValue('toggleHTML', true);
        toggleHTML.checked = storedToggleHTML;

        const storedToggleImages = GM_getValue('toggleImages', true);
        toggleImages.checked = storedToggleImages;

        const storedToggleAds = GM_getValue('toggleAds', true);
        toggleAds.checked = storedToggleAds;

        const storedToggleTechStack = GM_getValue('toggleTechStack', true);
        toggleTechStack.checked = storedToggleTechStack;

        const storedToggleOpenGraph = GM_getValue('toggleOpenGraph', true);
        toggleOpenGraph.checked = storedToggleOpenGraph;

        const storedToggleSecurityHeaders = GM_getValue('toggleSecurityHeaders', true);
        toggleSecurityHeaders.checked = storedToggleSecurityHeaders;

        const storedToggleDomainAge = GM_getValue('toggleDomainAge', true);
        toggleDomainAge.checked = storedToggleDomainAge;

        const storedDuplicateThreshold = GM_getValue('duplicateThreshold', 2);
        duplicateThreshold = storedDuplicateThreshold;
        duplicateThresholdInput.value = duplicateThreshold;

        const storedRetryAttempts = GM_getValue('retryAttempts', 3);
        retryAttempts = storedRetryAttempts;
        retryAttemptsInput.value = retryAttempts;

        const storedFilterInput = GM_getValue('filterInput', '');
        filterInput.value = storedFilterInput;
        updateFilterPatterns();

        const storedExcludeDomainsInput = GM_getValue('excludeDomainsInput', '');
        excludeDomainsInput.value = storedExcludeDomainsInput;
        updateExcludeDomains();
    }

    // 설정 저장 함수
    function saveSettings() {
        GM_setValue('searchEngine', searchEngine);
        GM_setValue('toggleHTML', toggleHTML.checked);
        GM_setValue('toggleImages', toggleImages.checked);
        GM_setValue('toggleAds', toggleAds.checked);
        GM_setValue('toggleTechStack', toggleTechStack.checked);
        GM_setValue('toggleOpenGraph', toggleOpenGraph.checked);
        GM_setValue('toggleSecurityHeaders', toggleSecurityHeaders.checked);
        GM_setValue('toggleDomainAge', toggleDomainAge.checked);
        GM_setValue('duplicateThreshold', duplicateThreshold);
        GM_setValue('retryAttempts', retryAttempts);
        GM_setValue('filterInput', filterInput.value.trim());
        GM_setValue('excludeDomainsInput', excludeDomainsInput.value.trim());
    }

    // 검색 엔진 변경 시 처리
    function updateSearchEngine() {
        searchEngine = searchEngineSelect.value;
        GM_setValue('searchEngine', searchEngine);
        log(`🔄 검색 엔진 변경: ${capitalizeFirstLetter(searchEngine)}`);
    }

    // 다양한 설정 변경 시 설정 저장
    toggleHTML.addEventListener('change', saveSettings);
    toggleImages.addEventListener('change', saveSettings);
    toggleAds.addEventListener('change', saveSettings);
    toggleTechStack.addEventListener('change', saveSettings);
    toggleOpenGraph.addEventListener('change', saveSettings);
    toggleSecurityHeaders.addEventListener('change', saveSettings);
    toggleDomainAge.addEventListener('change', saveSettings);
    filterInput.addEventListener('change', saveSettings);
    excludeDomainsInput.addEventListener('change', saveSettings);

    // 로그 로드
    function loadLogs() {
        const storedLogs = GM_getValue('crawlerLogs', []);
        if (storedLogs.length > 0) {
            logMessages = JSON.parse(storedLogs);
            logContainer.innerHTML = `<strong>로그:</strong><br>` + logMessages.join('<br>');
            logContainer.scrollTop = logContainer.scrollHeight;
        }
    }

    // 필터 패턴 업데이트
    function updateFilterPatterns() {
        const input = filterInput.value.trim();
        filterPatterns = input ? input.split(',').map(word => {
            word = word.trim();
            if (word.startsWith('/') && word.endsWith('/')) {
                try {
                    return new RegExp(word.slice(1, -1), 'i');
                } catch (e) {
                    log(`⚠️ 유효하지 않은 정규식: ${word}`);
                    return null;
                }
            } else {
                return new RegExp(word, 'i');
            }
        }).filter(regex => regex !== null) : [];
        log(`🛠 필터 패턴 업데이트: [${filterPatterns.map(r => r.toString()).join(', ')}]`);
        saveSettings();
    }

    // 제외 도메인 업데이트
    function updateExcludeDomains() {
        const input = excludeDomainsInput.value.trim();
        excludeDomains = input ? input.split(',').map(domain => domain.trim().toLowerCase()) : [];
        log(`🚫 제외 도메인 업데이트: [${excludeDomains.join(', ')}]`);
        saveSettings();
    }

    // 중복 허용 횟수 업데이트
    function updateDuplicateThreshold() {
        const value = parseInt(duplicateThresholdInput.value);
        duplicateThreshold = isNaN(value) || value < 1 ? 2 : value;
        log(`🔄 중복 허용 횟수 설정: ${duplicateThreshold}`);
        saveSettings();
    }

    // 재시도 횟수 업데이트
    function updateRetryAttempts() {
        const value = parseInt(retryAttemptsInput.value);
        retryAttempts = isNaN(value) || value < 1 ? 3 : value;
        log(`🔄 재시도 횟수 설정: ${retryAttempts}`);
        saveSettings();
    }

    // 크롤링 시작 함수
    async function startCrawling() {
        if (isRunning) {
            alert('이미 크롤링이 진행 중입니다.');
            return;
        }
        getSearchQueryAndEngine();
        if (!searchQuery) {
            alert('현재 페이지에서 검색어를 찾을 수 없습니다.');
            log('⚠️ 검색어 미입력 또는 인식 실패.');
            return;
        }
        isRunning = true;
        isPaused = false;
        currentPage = 1;
        totalPages = 0;
        results = [];
        visitedLinks.clear();
        resultsBody.innerHTML = '';
        visitedCountElem.innerText = '0';
        document.getElementById('totalRequests').innerText = '0';
        document.getElementById('successfulRequests').innerText = '0';
        document.getElementById('failedRequests').innerText = '0';
        elapsedTimeElem.innerText = '00:00:00';
        remainingTimeElem.innerText = '00:00:00';
        logMessages = [];
        logContainer.innerHTML = `<strong>로그:</strong><br>`;
        GM_setValue('crawlerLogs', JSON.stringify(logMessages));
        log('✅ 크롤링을 시작합니다.');
        updateDuplicateThreshold();
        updateRetryAttempts();
        await crawlPage();
        startTime = Date.now();
        elapsedInterval = setInterval(updateElapsedTime, 1000);
    }

    // 일시정지/재개 함수
    function togglePause() {
        if (!isRunning) {
            alert('일시정지/재개할 크롤링이 없습니다.');
            return;
        }
        isPaused = !isPaused;
        if (isPaused) {
            log('⏸️ 크롤링을 일시정지하였습니다.');
            pauseBtn.innerText = '▶️ 재개';
            pauseBtn.title = '크롤링 재개';
        } else {
            log('▶️ 크롤링을 재개하였습니다.');
            pauseBtn.innerText = '⏸️ 일시정지';
            pauseBtn.title = '크롤링 일시정지';
            crawlPage();
        }
    }

    // 크롤링 중지 함수
    function stopCrawling() {
        if (!isRunning) {
            alert('중지할 크롤링이 없습니다.');
            return;
        }
        isRunning = false;
        isPaused = false;
        pauseBtn.innerText = '⏸️ 일시정지';
        pauseBtn.title = '크롤링 일시정지';
        clearInterval(elapsedInterval);
        updateProgress();
        log('🚫 크롤링을 중지하였습니다.');
        GM_notification({
            text: '크롤링이 중지되었습니다.',
            title: '웹 크롤러 8.6',
            timeout: 3000
        });
    }

    // 크롤링 초기화 함수
    function resetCrawling() {
        stopCrawling();
        currentPage = 1;
        totalPages = 0;
        results = [];
        visitedLinks.clear();
        resultsBody.innerHTML = '';
        visitedCountElem.innerText = '0';
        document.getElementById('totalRequests').innerText = '0';
        document.getElementById('successfulRequests').innerText = '0';
        document.getElementById('failedRequests').innerText = '0';
        progressBar.value = 0;
        progressText.innerText = '0%';
        elapsedTimeElem.innerText = '00:00:00';
        remainingTimeElem.innerText = '00:00:00';
        logMessages = [];
        logContainer.innerHTML = `<strong>로그:</strong><br>`;
        GM_setValue('crawlerLogs', JSON.stringify(logMessages));
        crawlData = {
            labels: [],
            datasets: [{
                label: '방문 횟수',
                data: [],
                backgroundColor: 'rgba(33, 150, 243, 0.6)',
                borderColor: 'rgba(33, 150, 243, 1)',
                borderWidth: 1
            },
            {
                label: '평균 페이지 로딩 시간 (ms)',
                data: [],
                backgroundColor: 'rgba(76, 175, 80, 0.6)',
                borderColor: 'rgba(76, 175, 80, 1)',
                borderWidth: 1
            }]
        };
        loadTimeData = {
            labels: [],
            datasets: [{
                label: '페이지 로딩 시간 (ms)',
                data: [],
                backgroundColor: 'rgba(255, 193, 7, 0.6)',
                borderColor: 'rgba(255,193,7,1)',
                borderWidth: 1
            }]
        };
        domainDistributionData = {
            labels: [],
            datasets: [{
                label: '도메인 분포',
                data: [],
                backgroundColor: [
                    'rgba(33, 150, 243, 0.6)',
                    'rgba(255, 87, 34, 0.6)',
                    'rgba(76, 175, 80, 0.6)',
                    'rgba(156, 39, 176, 0.6)',
                    'rgba(255, 152, 0, 0.6)',
                    'rgba(244, 67, 54, 0.6)',
                    'rgba(158, 158, 158, 0.6)'
                ],
                borderColor: 'rgba(33, 150, 243, 1)',
                borderWidth: 1
            }]
        };
        errorRateData = {
            labels: [],
            datasets: [{
                label: '오류 발생 수',
                data: [],
                backgroundColor: 'rgba(255, 99, 132, 0.6)',
                borderColor: 'rgba(255, 99, 132,1)',
                borderWidth: 1
            }]
        };
        cumulativeVisitsData = {
            labels: [],
            datasets: [{
                label: '누적 방문 횟수',
                data: [],
                backgroundColor: 'rgba(3, 169, 244, 0.6)',
                borderColor: 'rgba(3, 169, 244,1)',
                borderWidth: 1
            }]
        };
        keywordDistributionData = {
            labels: [],
            datasets: [{
                label: '키워드 분포',
                data: [],
                backgroundColor: [
                    'rgba(63, 81, 181, 0.6)',
                    'rgba(255, 152, 0, 0.6)',
                    'rgba(76, 175, 80, 0.6)',
                    'rgba(244, 67, 54, 0.6)',
                    'rgba(33, 150, 243, 0.6)',
                    'rgba(153, 102, 255, 0.6)'
                ],
                borderColor: 'rgba(63, 81, 181,1)',
                borderWidth: 1
            }]
        };
        languageDistributionData = {
            labels: [],
            datasets: [{
                label: '언어 분포',
                data: [],
                backgroundColor: [
                    'rgba(38, 166, 154, 0.6)',
                    'rgba(211, 47, 47, 0.6)',
                    'rgba(3, 169, 244, 0.6)',
                    'rgba(255, 193, 7, 0.6)',
                    'rgba(156, 39, 176, 0.6)',
                    'rgba(0, 188, 212, 0.6)'
                ],
                borderColor: 'rgba(38, 166, 154,1)',
                borderWidth: 1
            }]
        };
        techStackData = {
            labels: [],
            datasets: [{
                label: '기술 스택 분포',
                data: [],
                backgroundColor: [
                    'rgba(103, 58, 183, 0.6)',
                    'rgba(255, 202, 40, 0.6)',
                    'rgba(0, 150, 136, 0.6)',
                    'rgba(233, 30, 99, 0.6)',
                    'rgba(245, 124, 0, 0.6)',
                    'rgba(255, 235, 59, 0.6)'
                ],
                borderColor: 'rgba(103, 58, 183,1)',
                borderWidth: 1
            }]
        };
        domainAgeData = {
            labels: [],
            datasets: [{
                label: '도메인 연령 분포 (년)',
                data: [],
                backgroundColor: [
                    'rgba(255, 159, 64, 0.6)',
                    'rgba(75, 192, 192, 0.6)',
                    'rgba(54, 162, 235, 0.6)',
                    'rgba(153, 102, 255, 0.6)',
                    'rgba(255, 99, 132, 0.6)'
                ],
                borderColor: 'rgba(255, 159, 64,1)',
                borderWidth: 1
            }]
        };

        if (crawlChart) {
            crawlChart.destroy();
        }
        if (loadTimeChart) {
            loadTimeChart.destroy();
        }
        if (domainDistributionChart) {
            domainDistributionChart.destroy();
        }
        if (errorRateChart) {
            errorRateChart.destroy();
        }
        if (cumulativeVisitsChart) {
            cumulativeVisitsChart.destroy();
        }
        if (keywordDistributionChart) {
            keywordDistributionChart.destroy();
        }
        if (languageDistributionChart) {
            languageDistributionChart.destroy();
        }
        if (techStackChart) {
            techStackChart.destroy();
        }
        if (domainAgeChart) {
            domainAgeChart.destroy();
        }
        initializeChart();
        log('🔄 크롤링을 초기화하였습니다.');
    }

    // 크롤링 페이지 함수
    async function crawlPage() {
        if (!isRunning || isPaused) {
            return;
        }

        let url = constructURL(currentPage);
        if (!url) {
            log('❌ 지원하지 않는 검색 엔진입니다.');
            alert('지원하지 않는 검색 엔진입니다.');
            isRunning = false;
            return;
        }

        log(`📄 페이지 ${currentPage} 크롤링 중: ${url}`);

        GM_xmlhttpRequest({
            method: "GET",
            url: url,
            headers: {
                "User-Agent": navigator.userAgent,
                "Accept": "text/html"
            },
            onload: function(response) {
                if (response.status !== 200) {
                    log(`❌ 페이지 ${currentPage} 로드 실패: 상태 ${response.status}`);
                    handleCrawlError(currentPage, retryAttempts);
                    document.getElementById('failedRequests').innerText = parseInt(document.getElementById('failedRequests').innerText) + 1;
                    return;
                }

                const parser = new DOMParser();
                const doc = parser.parseFromString(response.responseText, 'text/html');
                let items = extractItems(doc);
                if (currentPage === 1) {
                    totalPages = determineTotalPages(doc);
                    totalPagesElem.innerText = totalPages;
                }

                log(`📊 페이지 ${currentPage}에서 ${items.length}개 항목 발견.`);
                document.getElementById('totalRequests').innerText = parseInt(document.getElementById('totalRequests').innerText) + items.length;

                items.forEach(item => {
                    processItem(item);
                });

                updateChart();
                updateLoadTimeChart();
                updateDomainDistributionChart();
                updateErrorRateChart();
                updateCumulativeVisitsChart();
                updateKeywordDistributionChart();
                updateLanguageDistributionChart();
                updateTechStackChart();
                updateDomainAgeChart();
                updateProgress();
                currentPage++;
                currentPageElem.innerText = currentPage;
                if (currentPage <= totalPages && isRunning && !isPaused) {
                    setTimeout(crawlPage, 100); // 고정된 100ms 크롤링 속도
                } else {
                    finalizeCrawling();
                }
            },
            onerror: function() {
                log(`❌ 페이지 ${currentPage} 요청 중 오류 발생.`);
                handleCrawlError(currentPage, retryAttempts);
                document.getElementById('failedRequests').innerText = parseInt(document.getElementById('failedRequests').innerText) + 1;
            }
        });
    }

    // 크롤링 완료 시 처리 함수
    function finalizeCrawling() {
        isRunning = false;
        clearInterval(elapsedInterval);
        log('✅ 크롤링이 완료되었습니다.');
        GM_notification({
            text: '크롤링이 완료되었습니다.',
            title: '웹 크롤러 8.6',
            timeout: 3000
        });
    }

    // 크롤링 오류 처리 함수
    function handleCrawlError(page, retriesLeft) {
        if (retriesLeft > 0 && isRunning) {
            log(`🔄 페이지 ${page} 재시도 (${retriesLeft}회 남음).`);
            setTimeout(() => {
                const url = constructURL(page);
                GM_xmlhttpRequest({
                    method: "GET",
                    url: url,
                    headers: {
                        "User-Agent": navigator.userAgent,
                        "Accept": "text/html"
                    },
                    onload: function(response) {
                        if (response.status === 200) {
                            log(`✅ 페이지 ${page} 재시도 성공.`);
                            document.getElementById('successfulRequests').innerText = parseInt(document.getElementById('successfulRequests').innerText) + 1;
                            crawlPage();
                        } else {
                            handleCrawlError(page, retriesLeft - 1);
                            document.getElementById('failedRequests').innerText = parseInt(document.getElementById('failedRequests').innerText) + 1;
                        }
                    },
                    onerror: function() {
                        handleCrawlError(page, retriesLeft - 1);
                        document.getElementById('failedRequests').innerText = parseInt(document.getElementById('failedRequests').innerText) + 1;
                    }
                });
            }, retryInterval);
        } else {
            log(`❌ 페이지 ${page} 로드 실패: 최대 재시도 횟수 초과.`);
            document.getElementById('failedRequests').innerText = parseInt(document.getElementById('failedRequests').innerText) + 1;
            currentPage++;
            currentPageElem.innerText = currentPage;
            if (currentPage <= totalPages && isRunning && !isPaused) {
                setTimeout(crawlPage, 100);
            } else {
                finalizeCrawling();
            }
        }
    }

    // URL 구성 함수
    function constructURL(page) {
        switch(searchEngine) {
            case 'google':
                return `https://www.google.com/search?q=${encodeURIComponent(searchQuery)}&start=${(page-1)*10}`;
            case 'bing':
                return `https://www.bing.com/search?q=${encodeURIComponent(searchQuery)}&first=${(page-1)*10 +1}`;
            case 'daum':
                return `https://search.daum.net/search?q=${encodeURIComponent(searchQuery)}&page=${page}`;
            case 'naver':
                return `https://search.naver.com/search.naver?query=${encodeURIComponent(searchQuery)}&start=${(page-1)*10 +1}`;
            case 'yahoo':
                return `https://search.yahoo.com/search?p=${encodeURIComponent(searchQuery)}&b=${(page-1)*10 +1}`;
            case 'duckduckgo':
                return `https://duckduckgo.com/html/?q=${encodeURIComponent(searchQuery)}&s=${(page-1)*30}`;
            case 'startpage':
                return `https://www.startpage.com/do/search?query=${encodeURIComponent(searchQuery)}&b=${(page-1)*10 +1}`;
            case 'ecosia':
                return `https://www.ecosia.org/search?q=${encodeURIComponent(searchQuery)}&page=${page}`;
            case 'qwant':
                return `https://www.qwant.com/?q=${encodeURIComponent(searchQuery)}&t=web&s=${page}`;
            case 'ahmia':
                return `http://ahmia.fi/search/?q=${encodeURIComponent(searchQuery)}&page=${page}`;
            case 'torch':
                return `http://torchsearch.de/search/?q=${encodeURIComponent(searchQuery)}&page=${page}`;
            case 'notracker':
                return `http://notracker.org/search/?q=${encodeURIComponent(searchQuery)}&page=${page}`;
            default:
                return '';
        }
    }

    // 항목 추출 함수
    function extractItems(doc) {
        let items = [];
        switch(searchEngine) {
            case 'google':
                items = doc.querySelectorAll('div.g');
                break;
            case 'bing':
                items = doc.querySelectorAll('li.b_algo');
                break;
            case 'daum':
                items = doc.querySelectorAll('div.wrap_cont');
                break;
            case 'naver':
                items = doc.querySelectorAll('div.basic1');
                break;
            case 'yahoo':
                items = doc.querySelectorAll('div.compTitle');
                break;
            case 'duckduckgo':
                items = doc.querySelectorAll('div.result');
                break;
            case 'startpage':
                items = doc.querySelectorAll('div.w-gl__result');
                break;
            case 'ecosia':
                items = doc.querySelectorAll('div.result');
                break;
            case 'qwant':
                items = doc.querySelectorAll('div.results div.result');
                break;
            case 'ahmia':
                items = doc.querySelectorAll('div#main div.result');
                break;
            case 'torch':
                items = doc.querySelectorAll('div.result');
                break;
            case 'notracker':
                items = doc.querySelectorAll('div.result');
                break;
            default:
                break;
        }
        return items;
    }

    // 총 페이지 수 결정 함수
    function determineTotalPages(doc) {
        let pages = 1;
        switch(searchEngine) {
            case 'google':
                const googlePager = doc.querySelectorAll('a[href*="start="]');
                pages = Math.min(googlePager.length, 10) || 1;
                break;
            case 'bing':
                const bingPager = doc.querySelectorAll('a.sb_pagS');
                pages = bingPager.length || 1;
                break;
            case 'daum':
                const daumPager = doc.querySelectorAll('a.pagination__link');
                pages = daumPager.length || 1;
                break;
            case 'naver':
                const naverPager = doc.querySelectorAll('a.nav');
                pages = naverPager.length || 1;
                break;
            case 'yahoo':
                const yahooPager = doc.querySelectorAll('a.fz-l.tco-pagination__anchor');
                pages = yahooPager.length || 1;
                break;
            case 'duckduckgo':
                const ddgPager = doc.querySelectorAll('a.result--more__btn');
                pages = ddgPager.length || 1;
                break;
            case 'startpage':
                const spPager = doc.querySelectorAll('a.paginator__link');
                pages = spPager.length || 1;
                break;
            case 'ecosia':
                const ecosiaPager = doc.querySelectorAll('a.pagination__link');
                pages = ecosiaPager.length || 1;
                break;
            case 'qwant':
                const qwantPager = doc.querySelectorAll('a.pagination__link');
                pages = qwantPager.length || 1;
                break;
            case 'ahmia':
                const ahmiaPager = doc.querySelectorAll('a.pagination__link');
                pages = ahmiaPager.length || 1;
                break;
            case 'torch':
                const torchPager = doc.querySelectorAll('a.pagination__link');
                pages = torchPager.length || 1;
                break;
            case 'notracker':
                const ntPager = doc.querySelectorAll('a.pagination__link');
                pages = ntPager.length || 1;
                break;
            default:
                pages = 1;
                break;
        }
        return pages;
    }

    // 항목 처리 함수
    function processItem(item) {
        let title = 'N/A';
        let link = 'N/A';
        let description = 'N/A';
        let image = 'N/A';
        let htmlLink = 'N/A';
        let whoisInfo = 'N/A';
        let pageLoadTime = 'N/A';
        let language = 'N/A';
        let metaKeywords = 'N/A';
        let metaRobots = 'N/A';
        let openGraph = 'N/A';
        let securityHeaders = 'N/A';
        let domainAge = 'N/A';
        let techStack = 'N/A'; // 추가된 기술 스택 정보

        switch(searchEngine) {
            case 'google':
                const gTitleElem = item.querySelector('h3');
                const gLinkElem = item.querySelector('a');
                const gDescElem = item.querySelector('.IsZvec') || item.querySelector('.VwiC3b');
                if (gTitleElem) title = gTitleElem.innerText;
                if (gLinkElem) link = gLinkElem.href;
                if (gDescElem) description = gDescElem.innerText;

                const gImgElem = item.querySelector('img');
                if (gImgElem && gImgElem.src) {
                    image = `<img src="${gImgElem.src}" alt="이미지" style="max-width: 80px; max-height: 80px;">`;
                }

                if (toggleHTML.checked && link !== 'N/A') {
                    htmlLink = `<button class="html-view-btn" data-link="${encodeURIComponent(link)}">보기</button>`;
                }
                break;
            case 'bing':
                const bTitleElem = item.querySelector('h2 a');
                const bDescElem = item.querySelector('p');
                if (bTitleElem) {
                    title = bTitleElem.innerText;
                    link = bTitleElem.href;
                }
                if (bDescElem) description = bDescElem.innerText;

                const bImgElem = item.querySelector('img');
                if (bImgElem && bImgElem.src) {
                    image = `<img src="${bImgElem.src}" alt="이미지" style="max-width: 80px; max-height: 80px;">`;
                }

                if (toggleHTML.checked && link !== 'N/A') {
                    htmlLink = `<button class="html-view-btn" data-link="${encodeURIComponent(link)}">보기</button>`;
                }
                break;
            case 'daum':
                const dTitleElem = item.querySelector('a.link_fax');
                const dDescElem = item.querySelector('div.cont_inner');
                if (dTitleElem) {
                    title = dTitleElem.innerText.trim();
                    link = dTitleElem.href;
                }
                if (dDescElem) description = dDescElem.innerText.trim();

                const dImgElem = item.querySelector('img');
                if (dImgElem && dImgElem.src) {
                    image = `<img src="${dImgElem.src}" alt="이미지" style="max-width: 80px; max-height: 80px;">`;
                }

                if (toggleHTML.checked && link !== 'N/A') {
                    htmlLink = `<button class="html-view-btn" data-link="${encodeURIComponent(link)}">보기</button>`;
                }
                break;
            case 'naver':
                const nTitleElem = item.querySelector('a.tit');
                const nDescElem = item.querySelector('div.desc');
                if (nTitleElem) {
                    title = nTitleElem.innerText;
                    link = nTitleElem.href;
                }
                if (nDescElem) description = nDescElem.innerText;

                const nImgElem = item.querySelector('img.thumb');
                if (nImgElem && nImgElem.src) {
                    image = `<img src="${nImgElem.src}" alt="이미지" style="max-width: 80px; max-height: 80px;">`;
                }

                if (toggleHTML.checked && link !== 'N/A') {
                    htmlLink = `<button class="html-view-btn" data-link="${encodeURIComponent(link)}">보기</button>`;
                }
                break;
            case 'yahoo':
                const yTitleElem = item.querySelector('h3');
                const yLinkElem = item.querySelector('a');
                const yDescElem = item.querySelector('div.compText');
                if (yTitleElem) title = yTitleElem.innerText;
                if (yLinkElem) link = yLinkElem.href;
                if (yDescElem) description = yDescElem.innerText;

                const yImgElem = item.querySelector('img');
                if (yImgElem && yImgElem.src) {
                    image = `<img src="${yImgElem.src}" alt="이미지" style="max-width: 80px; max-height: 80px;">`;
                }

                if (toggleHTML.checked && link !== 'N/A') {
                    htmlLink = `<button class="html-view-btn" data-link="${encodeURIComponent(link)}">보기</button>`;
                }
                break;
            case 'duckduckgo':
                const ddgTitleElem = item.querySelector('a.result__a');
                const ddgDescElem = item.querySelector('a.result__snippet');
                if (ddgTitleElem) {
                    title = ddgTitleElem.innerText;
                    link = ddgTitleElem.href;
                }
                if (ddgDescElem) description = ddgDescElem.innerText;

                const ddgImgElem = item.querySelector('img.result__image');
                if (ddgImgElem && ddgImgElem.src) {
                    image = `<img src="${ddgImgElem.src}" alt="이미지" style="max-width: 80px; max-height: 80px;">`;
                }

                if (toggleHTML.checked && link !== 'N/A') {
                    htmlLink = `<button class="html-view-btn" data-link="${encodeURIComponent(link)}">보기</button>`;
                }
                break;
            case 'startpage':
                const spTitleElem = item.querySelector('a.w-gl__result-title');
                const spDescElem = item.querySelector('p.w-gl__result-description');
                if (spTitleElem) {
                    title = spTitleElem.innerText;
                    link = spTitleElem.href;
                }
                if (spDescElem) description = spDescElem.innerText;

                const spImgElem = item.querySelector('img.w-gl__result-image');
                if (spImgElem && spImgElem.src) {
                    image = `<img src="${spImgElem.src}" alt="이미지" style="max-width: 80px; max-height: 80px;">`;
                }

                if (toggleHTML.checked && link !== 'N/A') {
                    htmlLink = `<button class="html-view-btn" data-link="${encodeURIComponent(link)}">보기</button>`;
                }
                break;
            case 'ecosia':
                const ecosiaTitleElem = item.querySelector('h2.result-title a');
                const ecosiaDescElem = item.querySelector('p.result-description');
                if (ecosiaTitleElem) {
                    title = ecosiaTitleElem.innerText;
                    link = ecosiaTitleElem.href;
                }
                if (ecosiaDescElem) description = ecosiaDescElem.innerText;

                const ecosiaImgElem = item.querySelector('img.result-image');
                if (ecosiaImgElem && ecosiaImgElem.src) {
                    image = `<img src="${ecosiaImgElem.src}" alt="이미지" style="max-width: 80px; max-height: 80px;">`;
                }

                if (toggleHTML.checked && link !== 'N/A') {
                    htmlLink = `<button class="html-view-btn" data-link="${encodeURIComponent(link)}">보기</button>`;
                }
                break;
            case 'qwant':
                const qwantTitleElem = item.querySelector('a.result__title');
                const qwantDescElem = item.querySelector('p.result__description');
                if (qwantTitleElem) {
                    title = qwantTitleElem.innerText;
                    link = qwantTitleElem.href;
                }
                if (qwantDescElem) description = qwantDescElem.innerText;

                const qwantImgElem = item.querySelector('img.result__image');
                if (qwantImgElem && qwantImgElem.src) {
                    image = `<img src="${qwantImgElem.src}" alt="이미지" style="max-width: 80px; max-height: 80px;">`;
                }

                if (toggleHTML.checked && link !== 'N/A') {
                    htmlLink = `<button class="html-view-btn" data-link="${encodeURIComponent(link)}">보기</button>`;
                }
                break;
            case 'ahmia':
                const ahmiaTitleElem = item.querySelector('h2.result-title a');
                const ahmiaDescElem = item.querySelector('p.result-description');
                if (ahmiaTitleElem) {
                    title = ahmiaTitleElem.innerText;
                    link = ahmiaTitleElem.href;
                }
                if (ahmiaDescElem) description = ahmiaDescElem.innerText;

                const ahmiaImgElem = item.querySelector('img.result-image');
                if (ahmiaImgElem && ahmiaImgElem.src) {
                    image = `<img src="${ahmiaImgElem.src}" alt="이미지" style="max-width: 80px; max-height: 80px;">`;
                }

                if (toggleHTML.checked && link !== 'N/A') {
                    whoisInfo = `<button class="whois-view-btn" data-domain="${encodeURIComponent(extractDomain(link))}">보기</button>`;
                    htmlLink = `<button class="html-view-btn" data-link="${encodeURIComponent(link)}">보기</button>`;
                }
                break;
            case 'torch':
                const torchTitleElem = item.querySelector('h3.result-title a');
                const torchDescElem = item.querySelector('p.result-description');
                if (torchTitleElem) {
                    title = torchTitleElem.innerText;
                    link = torchTitleElem.href;
                }
                if (torchDescElem) description = torchDescElem.innerText;

                const torchImgElem = item.querySelector('img.result-image');
                if (torchImgElem && torchImgElem.src) {
                    image = `<img src="${torchImgElem.src}" alt="이미지" style="max-width: 80px; max-height: 80px;">`;
                }

                if (toggleHTML.checked && link !== 'N/A') {
                    whoisInfo = `<button class="whois-view-btn" data-domain="${encodeURIComponent(extractDomain(link))}">보기</button>`;
                    htmlLink = `<button class="html-view-btn" data-link="${encodeURIComponent(link)}">보기</button>`;
                }
                break;
            case 'notracker':
                const ntTitleElem = item.querySelector('h3.result-title a');
                const ntDescElem = item.querySelector('p.result-description');
                if (ntTitleElem) {
                    title = ntTitleElem.innerText;
                    link = ntTitleElem.href;
                }
                if (ntDescElem) description = ntDescElem.innerText;

                const ntImgElem = item.querySelector('img.result-image');
                if (ntImgElem && ntImgElem.src) {
                    image = `<img src="${ntImgElem.src}" alt="이미지" style="max-width: 80px; max-height: 80px;">`;
                }

                if (toggleHTML.checked && link !== 'N/A') {
                    whoisInfo = `<button class="whois-view-btn" data-domain="${encodeURIComponent(extractDomain(link))}">보기</button>`;
                    htmlLink = `<button class="html-view-btn" data-link="${encodeURIComponent(link)}">보기</button>`;
                }
                break;
            default:
                break;
        }

        // 추가 메타 정보 수집
        try {
            const metaKeywordElem = item.querySelector('meta[name="keywords"]');
            if (metaKeywordElem) {
                metaKeywords = metaKeywordElem.getAttribute('content');
                if (metaKeywords) {
                    metaKeywords = metaKeywords.split(',').map(k => k.trim()).join(', ');
                } else {
                    metaKeywords = 'N/A';
                }
            }

            const metaRobotsElem = item.querySelector('meta[name="robots"]');
            if (metaRobotsElem) {
                metaRobots = metaRobotsElem.getAttribute('content') || 'N/A';
            }

            const ogTitle = item.querySelector('meta[property="og:title"]')?.getAttribute('content') || 'N/A';
            const ogDescription = item.querySelector('meta[property="og:description"]')?.getAttribute('content') || 'N/A';
            const ogImage = item.querySelector('meta[property="og:image"]')?.getAttribute('content') || 'N/A';
            openGraph = `Title: ${ogTitle}, Description: ${ogDescription}, Image: ${ogImage}`;

            // 보안 헤더 추출 (간단한 예시)
            const securityHeadersArr = [];
            const hsts = item.querySelector('meta[http-equiv="Strict-Transport-Security"]');
            if (hsts) securityHeadersArr.push('HSTS');
            const contentSecurityPolicy = item.querySelector('meta[http-equiv="Content-Security-Policy"]');
            if (contentSecurityPolicy) securityHeadersArr.push('CSP');
            securityHeaders = securityHeadersArr.length > 0 ? securityHeadersArr.join(', ') : 'N/A';

            const domainInfo = getDomainInfo(link);
            domainAge = domainInfo ? domainInfo.age : 'N/A';

            const htmlLang = item.querySelector('html');
            if (htmlLang && htmlLang.lang) {
                language = htmlLang.lang;
            }

            // 기술 스택 정보 수집 (예시: 간단한 스택 감지)
            const techs = [];
            if (item.querySelector('.wordpress')) techs.push('WordPress');
            if (item.querySelector('.shopify')) techs.push('Shopify');
            if (item.querySelector('.react')) techs.push('React');
            if (item.querySelector('.angular')) techs.push('Angular');
            if (item.querySelector('.vue')) techs.push('Vue.js');
            techStack = techs.length > 0 ? techs.join(', ') : 'N/A';
        } catch (e) {
            log(`⚠️ 메타 정보 수집 중 오류 발생: ${e.message}`);
        }

        // 광고 제외 필터링
        if (toggleAds.checked) {
            const combinedText = `${title} ${description}`.toLowerCase();
            const isAd = combinedText.includes('advertisement') || combinedText.includes('광고') || combinedText.includes('ad ');
            if (isAd) {
                log(`🚫 광고 항목 제외: "${title}"`);
                return;
            }
        }

        // 필터 패턴 적용
        if (filterPatterns.length > 0) {
            const combinedText = `${title} ${description}`;
            const isFiltered = filterPatterns.some(regex => regex.test(combinedText));
            if (isFiltered) {
                log(`❌ 필터 단어 포함 항목 제외: "${title}"`);
                return;
            }
        }

        // 도메인 추출 및 제외 도메인 적용
        const domain = extractDomain(link);
        if (!domain) return;

        if (excludeDomains.includes(domain.toLowerCase())) {
            log(`🚫 제외 도메인 항목 제외: "${link}"`);
            return;
        }

        // 중복 방문 제한
        let visitCount = visitedLinks.get(domain) || 0;
        if (visitCount >= duplicateThreshold) {
            log(`🔄 중복 방문 제한: "${domain}"`);
            return;
        }

        visitedLinks.set(domain, visitCount + 1);
        visitedCountElem.innerText = visitedLinks.size.toString();

        // 페이지 로딩 시간 측정
        const startLoad = performance.now();
        fetch(link, { mode: 'no-cors' })
            .then(response => {
                const endLoad = performance.now();
                pageLoadTime = Math.round(endLoad - startLoad);
                document.getElementById('successfulRequests').innerText = parseInt(document.getElementById('successfulRequests').innerText) + 1;
                updateRow();
            })
            .catch(err => {
                pageLoadTime = '계산 불가';
                log(`❌ 페이지 로딩 오류: "${link}"`);
                document.getElementById('failedRequests').innerText = parseInt(document.getElementById('failedRequests').innerText) + 1;
                updateRow();
            });

        // 언어, 키워드, 로봇 메타 정보 저장
        const itemLanguage = language;
        const itemKeywords = metaKeywords;
        const itemRobots = metaRobots;

        // WHOIS 정보 버튼 이벤트 추가 (이미 처리됨)

        // 이미지 옵션 적용
        if (!toggleImages.checked) {
            image = '비활성화';
        }

        // OpenGraph 옵션 적용
        if (!toggleOpenGraph.checked) {
            openGraph = '비활성화';
        }

        // 보안 헤더 옵션 적용
        if (!toggleSecurityHeaders.checked) {
            securityHeaders = '비활성화';
        }

        // 도메인 연령 옵션 적용
        if (!toggleDomainAge.checked) {
            domainAge = '비활성화';
        }

        // 결과 배열에 추가
        results.push({ title, link, description, image, htmlLink, whoisInfo, pageLoadTime, language, metaKeywords, metaRobots, openGraph, securityHeaders, domainAge, techStack });

        // 결과 테이블에 행 추가
        const row = document.createElement('tr');
        row.innerHTML = `
            <td>${escapeHTML(title)}</td>
            <td><a href="${escapeHTML(link)}" target="_blank">${escapeHTML(link)}</a></td>
            <td>${escapeHTML(description)}</td>
            <td>${image}</td>
            <td>${htmlLink}</td>
            <td>${whoisInfo}</td>
            <td>${pageLoadTime}</td>
            <td>${escapeHTML(itemLanguage)}</td>
            <td>${escapeHTML(itemKeywords)}</td>
            <td>${escapeHTML(itemRobots)}</td>
            <td>${escapeHTML(openGraph)}</td>
            <td>${escapeHTML(securityHeaders)}</td>
            <td>${escapeHTML(domainAge)}</td>
            <td>${escapeHTML(techStack)}</td>
        `;
        resultsBody.appendChild(row);

        // 미리보기 이벤트 추가
        addPreviewEvents(row, link);

        // WHOIS 버튼 이벤트 추가
        const whoisBtn = row.querySelector('.whois-view-btn');
        if (whoisBtn) {
            whoisBtn.addEventListener('click', () => {
                const encodedDomain = whoisBtn.getAttribute('data-domain');
                const decodedDomain = decodeURIComponent(encodedDomain);
                openWhoisModal(decodedDomain);
            });
        }

        function updateRow() {
            // 업데이트된 로딩 시간을 테이블에 반영
            row.cells[6].innerText = pageLoadTime;
            row.cells[10].innerText = openGraph;
            row.cells[11].innerText = securityHeaders;
            row.cells[12].innerText = domainAge;
            updateChart();
            updateLoadTimeChart();
            updateDomainDistributionChart();
            updateErrorRateChart();
            updateCumulativeVisitsChart();
            updateKeywordDistributionChart();
            updateLanguageDistributionChart();
            updateTechStackChart();
            updateDomainAgeChart();
            updateProgress();
        }
    }

    // HTML 이스케프 함수
    function escapeHTML(str) {
        if (!str) return '';
        return str.replace(/&/g, "&amp;")
                  .replace(/</g, "&lt;")
                  .replace(/>/g, "&gt;")
                  .replace(/"/g, "&quot;")
                  .replace(/'/g, "&#039;");
    }

    // 도메인 추출 함수
    function extractDomain(url) {
        try {
            const urlObj = new URL(url);
            return urlObj.hostname.replace('www.', '');
        } catch (e) {
            return null;
        }
    }

    // 도메인 연령 정보 가져오기 함수
    function getDomainInfo(url) {
        try {
            const urlObj = new URL(url);
            // 실제 WHOIS 데이터를 통해 도메인 연령을 가져와야 하지만, 샘플 데이터로 대체
            const creationYear = 2010; // 임의의 생성 연도
            const currentYear = new Date().getFullYear();
            const age = currentYear - creationYear;
            return { age };
        } catch (e) {
            return null;
        }
    }

    // 경과 시간 업데이트 함수
    function updateElapsedTime() {
        if (!startTime) return;
        const now = Date.now();
        const elapsed = Math.floor((now - startTime) / 1000);
        elapsedTimeElem.innerText = formatTime(elapsed);
        const estimatedTotal = totalPages * ((elapsed > 0) ? (elapsed / (currentPage - 1)) : 0.5);
        const remaining = Math.max(Math.round(estimatedTotal - elapsed), 0);
        remainingTimeElem.innerText = formatTime(remaining);
    }

    // 시간 형식화 함수
    function formatTime(seconds) {
        const hrs = String(Math.floor(seconds / 3600)).padStart(2, '0');
        const mins = String(Math.floor((seconds % 3600) / 60)).padStart(2, '0');
        const secs = String(seconds % 60).padStart(2, '0');
        return `${hrs}:${mins}:${secs}`;
    }

    // 차트 업데이트 함수
    function updateChart() {
        crawlData.labels = Array.from(visitedLinks.keys());
        crawlData.datasets[0].data = Array.from(visitedLinks.values());

        // 평균 페이지 로딩 시간 계산
        let loadTimes = results.filter(r => typeof r.pageLoadTime === 'number').map(r => r.pageLoadTime);
        let averageLoadTime = loadTimes.length > 0 ? Math.round(loadTimes.reduce((a, b) => a + b, 0) / loadTimes.length) : 0;
        crawlData.datasets[1].data = Array.from(visitedLinks.keys()).map(domain => {
            const times = results.filter(r => extractDomain(r.link) === domain && typeof r.pageLoadTime === 'number').map(r => r.pageLoadTime);
            return times.length > 0 ? Math.round(times.reduce((a, b) => a + b, 0) / times.length) : 0;
        });

        if (crawlChart) {
            crawlChart.update();
        }
        GM_setValue('crawlerData', JSON.stringify(crawlData));
    }

    // 추가 차트 업데이트 함수
    function updateLoadTimeChart() {
        loadTimeData.labels = results.map(r => r.title).slice(-20); // 최근 20개
        loadTimeData.datasets[0].data = results.map(r => r.pageLoadTime).slice(-20);
        if (loadTimeChart) {
            loadTimeChart.update();
        }
    }

    function updateDomainDistributionChart() {
        domainDistributionData.labels = Array.from(visitedLinks.keys());
        domainDistributionData.datasets[0].data = Array.from(visitedLinks.values());
        if (domainDistributionChart) {
            domainDistributionChart.update();
        }
    }

    function updateErrorRateChart() {
        // 오류 발생 수를 도메인별로 집계
        const errorCounts = {};
        results.forEach(r => {
            if (r.pageLoadTime === '계산 불가') {
                const domain = extractDomain(r.link);
                if (domain && !excludeDomains.includes(domain.toLowerCase())) {
                    errorCounts[domain] = (errorCounts[domain] || 0) + 1;
                }
            }
        });
        errorRateData.labels = Object.keys(errorCounts);
        errorRateData.datasets[0].data = Object.values(errorCounts);
        if (errorRateChart) {
            errorRateChart.update();
        }
    }

    function updateCumulativeVisitsChart() {
        let cumulative = 0;
        cumulativeVisitsData.labels = results.map((_, index) => index + 1);
        cumulativeVisitsData.datasets[0].data = results.map(() => { cumulative += 1; return cumulative; });
        if (cumulativeVisitsChart) {
            cumulativeVisitsChart.update();
        }
    }

    function updateKeywordDistributionChart() {
        const keywordCounts = {};
        results.forEach(r => {
            if (r.metaKeywords && r.metaKeywords !== 'N/A') {
                const keywords = r.metaKeywords.split(',').map(k => k.trim());
                keywords.forEach(k => {
                    if (k) {
                        keywordCounts[k] = (keywordCounts[k] || 0) + 1;
                    }
                });
            }
        });
        keywordDistributionData.labels = Object.keys(keywordCounts);
        keywordDistributionData.datasets[0].data = Object.values(keywordCounts);
        if (keywordDistributionChart) {
            keywordDistributionChart.update();
        }
    }

    function updateLanguageDistributionChart() {
        const languageCounts = {};
        results.forEach(r => {
            if (r.language && r.language !== 'N/A') {
                languageCounts[r.language] = (languageCounts[r.language] || 0) + 1;
            }
        });
        languageDistributionData.labels = Object.keys(languageCounts);
        languageDistributionData.datasets[0].data = Object.values(languageCounts);
        if (languageDistributionChart) {
            languageDistributionChart.update();
        }
    }

    function updateTechStackChart() {
        const techCounts = {};
        results.forEach(r => {
            if (r.techStack && r.techStack !== 'N/A') {
                const techs = r.techStack.split(',').map(t => t.trim());
                techs.forEach(t => {
                    if (t) {
                        techCounts[t] = (techCounts[t] || 0) + 1;
                    }
                });
            }
        });
        techStackData.labels = Object.keys(techCounts);
        techStackData.datasets[0].data = Object.values(techCounts);
        if (techStackChart) {
            techStackChart.update();
        }
    }

    function updateDomainAgeChart() {
        const ageCounts = {};
        results.forEach(r => {
            if (r.domainAge && r.domainAge !== 'N/A') {
                const age = r.domainAge;
                if (age >= 0 && age <= 1) {
                    ageCounts['0-1'] = (ageCounts['0-1'] || 0) + 1;
                } else if (age <= 3) {
                    ageCounts['2-3'] = (ageCounts['2-3'] || 0) + 1;
                } else if (age <= 5) {
                    ageCounts['4-5'] = (ageCounts['4-5'] || 0) + 1;
                } else if (age <= 10) {
                    ageCounts['6-10'] = (ageCounts['6-10'] || 0) + 1;
                } else {
                    ageCounts['10+'] = (ageCounts['10+'] || 0) + 1;
                }
            }
        });
        domainAgeData.labels = Object.keys(ageCounts);
        domainAgeData.datasets[0].data = Object.values(ageCounts);
        if (domainAgeChart) {
            domainAgeChart.update();
        }
    }

    // 크롤 데이터 로드 함수
    function loadCrawlData() {
        const storedData = GM_getValue('crawlerData', null);
        if (storedData) {
            const parsedData = JSON.parse(storedData);
            crawlData = parsedData;
            if (crawlChart) {
                crawlChart.data = crawlData;
                crawlChart.update();
            }
        }
    }

    // 크롤 데이터 저장 함수
    function saveCrawlData() {
        GM_setValue('crawlerData', JSON.stringify(crawlData));
    }

    // 주기적으로 크롤 데이터 저장
    setInterval(saveCrawlData, 5000);

    // 검색어 및 검색 엔진 감지 함수
    function getSearchQueryAndEngine() {
        const url = window.location.href;
        if (url.includes('google.com/search')) {
            const params = new URLSearchParams(window.location.search);
            searchQuery = params.get('q') || '';
            searchEngine = 'google';
        } else if (url.includes('bing.com/search')) {
            const params = new URLSearchParams(window.location.search);
            searchQuery = params.get('q') || '';
            searchEngine = 'bing';
        } else if (url.includes('daum.net/search')) {
            const params = new URLSearchParams(window.location.search);
            searchQuery = params.get('q') || '';
            searchEngine = 'daum';
        } else if (url.includes('search.naver.com/search')) {
            const params = new URLSearchParams(window.location.search);
            searchQuery = params.get('query') || '';
            searchEngine = 'naver';
        } else if (url.includes('search.yahoo.com/search')) {
            const params = new URLSearchParams(window.location.search);
            searchQuery = params.get('p') || '';
            searchEngine = 'yahoo';
        } else if (url.includes('duckduckgo.com/')) {
            const params = new URLSearchParams(window.location.search);
            searchQuery = params.get('q') || '';
            searchEngine = 'duckduckgo';
        } else if (url.includes('startpage.com/do/search')) {
            const params = new URLSearchParams(window.location.search);
            searchQuery = params.get('query') || '';
            searchEngine = 'startpage';
        } else if (url.includes('ecosia.org/search')) {
            const params = new URLSearchParams(window.location.search);
            searchQuery = params.get('q') || '';
            searchEngine = 'ecosia';
        } else if (url.includes('qwant.com/')) {
            const params = new URLSearchParams(window.location.search);
            searchQuery = params.get('q') || '';
            searchEngine = 'qwant';
        } else if (url.includes('ahmia.fi/')) {
            const params = new URLSearchParams(window.location.search);
            searchQuery = params.get('q') || '';
            searchEngine = 'ahmia';
        } else if (url.includes('torchsearch.de/')) {
            const params = new URLSearchParams(window.location.search);
            searchQuery = params.get('q') || '';
            searchEngine = 'torch';
        } else if (url.includes('notracker.org/')) {
            const params = new URLSearchParams(window.location.search);
            searchQuery = params.get('q') || '';
            searchEngine = 'notracker';
        } else {
            searchQuery = '';
            searchEngine = '';
        }
        log(`🔍 검색 엔진: ${capitalizeFirstLetter(searchEngine)}, 검색어: "${searchQuery}"`);
    }

    // 로그 기록 함수
    function log(message) {
        const time = new Date().toLocaleTimeString();
        const entry = `[${time}] ${message}`;
        logMessages.push(entry);
        logContainer.innerHTML += `${entry}<br>`;
        logContainer.scrollTop = logContainer.scrollHeight;
        GM_setValue('crawlerLogs', JSON.stringify(logMessages));
    }

    // 결과 내보내기 함수 (중복 제거 및 정렬 추가)
    function exportResults() {
        if (results.length === 0) {
            alert('내보낼 결과가 없습니다.');
            return;
        }
        const format = prompt('내보낼 형식을 선택하세요 (xlsx, csv, json):', 'xlsx');
        if (!format) return;
        if (format.toLowerCase() === 'xlsx') {
            const ws = XLSX.utils.json_to_sheet(results);
            const wb = XLSX.utils.book_new();
            XLSX.utils.book_append_sheet(wb, ws, "결과");
            XLSX.writeFile(wb, "크롤링_결과.xlsx");
            log('💾 결과를 "크롤링_결과.xlsx" 파일로 내보냈습니다.');
            GM_notification({
                text: '결과를 "크롤링_결과.xlsx" 파일로 내보냈습니다.',
                title: '웹 크롤러 8.6',
                timeout: 3000
            });
        } else if (format.toLowerCase() === 'csv') {
            const csv = results.map(row => `"${row.title.replace(/"/g, '""')}","${row.link.replace(/"/g, '""')}","${row.description.replace(/"/g, '""')}","${row.image.replace(/"/g, '""')}","${row.htmlLink}","${row.whoisInfo}","${row.pageLoadTime}","${row.language}","${row.metaKeywords}","${row.metaRobots}","${row.openGraph}","${row.securityHeaders}","${row.domainAge}","${row.techStack}"`).join('\n');
            const blob = new Blob([csv], { type: 'text/csv;charset=utf-8;' });
            const url = URL.createObjectURL(blob);
            const a = document.createElement('a');
            a.href = url;
            a.download = '크롤링_결과.csv';
            a.click();
            log('💾 결과를 "크롤링_결과.csv" 파일로 내보냈습니다.');
            GM_notification({
                text: '결과를 "크롤링_결과.csv" 파일로 내보냈습니다.',
                title: '웹 크롤러 8.6',
                timeout: 3000
            });
        } else if (format.toLowerCase() === 'json') {
            const json = JSON.stringify(results, null, 2);
            const blob = new Blob([json], { type: 'application/json;charset=utf-8;' });
            const url = URL.createObjectURL(blob);
            const a = document.createElement('a');
            a.href = url;
            a.download = '크롤링_결과.json';
            a.click();
            log('💾 결과를 "크롤링_결과.json" 파일로 내보냈습니다.');
            GM_notification({
                text: '결과를 "크롤링_결과.json" 파일로 내보냈습니다.',
                title: '웹 크롤러 8.6',
                timeout: 3000
            });
        } else {
            alert('지원하지 않는 형식입니다.');
        }
    }

    // 결과 테이블 정렬 함수
    function sortTable(n) {
        const table = document.getElementById("resultsTable");
        let switching = true;
        let dir = "asc";
        let switchcount = 0;
        while (switching) {
            switching = false;
            const rows = table.rows;
            for (let i = 1; i < (rows.length - 1); i++) {
                let shouldSwitch = false;
                const x = rows[i].getElementsByTagName("TD")[n];
                const y = rows[i + 1].getElementsByTagName("TD")[n];
                let xContent = x.textContent || x.innerText;
                let yContent = y.textContent || y.innerText;

                // 숫자 비교
                if (n === 6 || n === 12) { // 페이지 로딩 시간과 도메인 연령
                    xContent = parseInt(xContent);
                    yContent = parseInt(yContent);
                }

                if (dir === "asc") {
                    if (xContent > yContent) {
                        shouldSwitch = true;
                        break;
                    }
                } else if (dir === "desc") {
                    if (xContent < yContent) {
                        shouldSwitch = true;
                        break;
                    }
                }
            }
            if (shouldSwitch) {
                rows[i].parentNode.insertBefore(rows[i + 1], rows[i]);
                switching = true;
                switchcount++;
            } else {
                if (switchcount === 0 && dir === "asc") {
                    dir = "desc";
                    switching = true;
                }
            }
        }
    }

    // 사용자 경험 향상을 위한 함수 추가
    function capitalizeFirstLetter(string) {
        if (!string) return '';
        return string.charAt(0).toUpperCase() + string.slice(1);
    }

    // 항목 검색 기능
    function filterResults() {
        const filter = searchResultsInput.value.toLowerCase();
        const rows = resultsBody.getElementsByTagName('tr');
        for (let i = 0; i < rows.length; i++) {
            const cells = rows[i].getElementsByTagName('td');
            let match = false;
            for (let j = 0; j < cells.length - 9; j++) { // 제외 항목 인덱스 조정
                if (cells[j].innerText.toLowerCase().includes(filter)) {
                    match = true;
                    break;
                }
            }
            rows[i].style.display = match ? '' : 'none';
        }
    }

    // 로그 초기화 함수
    function clearLogs() {
        if(confirm('로그를 초기화하시겠습니까?')) {
            logMessages = [];
            logContainer.innerHTML = `<strong>로그:</strong><br>`;
            GM_setValue('crawlerLogs', JSON.stringify(logMessages));
            log('🧹 로그를 초기화하였습니다.');
        }
    }

    // 진행률 업데이트 함수
    function updateProgress() {
        if (totalPages === 0) {
            progressBar.value = 0;
            progressText.innerText = '0%';
            return;
        }
        const progress = Math.min((currentPage - 1) / totalPages * 100, 100);
        progressBar.value = progress;
        progressText.innerText = `${Math.round(progress)}%`;
    }

    // 크롤링 오류가 발생한 행에 대한 미리보기 추가
    function addPreviewEvents(row, link) {
        const htmlBtn = row.querySelector('.html-view-btn');
        if (htmlBtn) {
            htmlBtn.addEventListener('click', () => {
                const decodedLink = decodeURIComponent(htmlBtn.getAttribute('data-link'));
                openPreview(decodedLink);
            });

            // HTML 버튼에 마우스 호버 시 미리보기 표시
            htmlBtn.addEventListener('mouseover', (e) => {
                const decodedLink = decodeURIComponent(htmlBtn.getAttribute('data-link'));
                showPreview(e, decodedLink);
            });
            htmlBtn.addEventListener('mouseout', hidePreview);
        }
    }

    // 미리보기 표시 함수
    function showPreview(event, link) {
        tooltip.style.left = (event.pageX + 10) + 'px';
        tooltip.style.top = (event.pageY + 10) + 'px';
        tooltip.style.display = 'block';
        tooltip.innerHTML = `<iframe src="${link}" title="미리보기"></iframe>`;
    }

    function hidePreview() {
        tooltip.style.display = 'none';
        tooltip.innerHTML = '';
    }

    // 사이트 미리보기 열기 함수
    function openPreview(link) {
        const analyticsTab = container.querySelector('#analytics');
        const previewContainerId = 'site-preview-container';
        let previewContainer = container.querySelector(`#${previewContainerId}`);

        if (!previewContainer) {
            previewContainer = document.createElement('div');
            previewContainer.id = previewContainerId;
            previewContainer.className = 'chart-container';
            previewContainer.style.height = '400px';
            analyticsTab.appendChild(previewContainer);
        }

        previewContainer.innerHTML = `
            <h3>사이트 미리보기: <a href="${link}" target="_blank">${link}</a></h3>
            <iframe src="${link}" style="width: 100%; height: 350px; border: none; border-radius: 5px;"></iframe>
        `;

        // 분석 탭으로 이동
        const analyticsTabBtn = container.querySelector('.tab[data-tab="analytics"]');
        analyticsTabBtn.click();
    }

    // WHOIS 모달 열기 함수
    function openWhoisModal(domain) {
        whoisContent.innerHTML = `<p>로딩 중...</p>`;
        whoisModal.style.display = 'block';
        fetchWhoisData(domain);
    }

    // WHOIS 정보 가져오기 및 표시 함수
    function fetchWhoisData(domain) {
        log(`📡 WHOIS 정보를 가져오는 중: ${domain}`);
        const apiUrl = `https://jsonwhois.com/api/v1/whois?domain=${encodeURIComponent(domain)}`;

        GM_xmlhttpRequest({
            method: "GET",
            url: apiUrl,
            headers: {
                "Content-Type": "application/json",
                "Authorization": `Token token=${WHOIS_API_KEY}`
            },
            onload: function(response) {
                if (response.status === 200) {
                    const data = JSON.parse(response.responseText);
                    displayWhoisData(data, domain);
                    log(`✅ WHOIS 정보를 성공적으로 가져왔습니다: ${domain}`);
                    document.getElementById('successfulRequests').innerText = parseInt(document.getElementById('successfulRequests').innerText) + 1;
                } else {
                    log(`❌ WHOIS 정보 가져오기 실패: ${domain}, 상태 코드: ${response.status}`);
                    whoisContent.innerHTML = `<p>WHOIS 정보를 가져오는 데 실패했습니다.</p>`;
                }
            },
            onerror: function() {
                log(`❌ WHOIS 정보 요청 중 오류 발생: ${domain}`);
                document.getElementById('failedRequests').innerText = parseInt(document.getElementById('failedRequests').innerText) + 1;
                whoisContent.innerHTML = `<p>WHOIS 정보를 가져오는 데 오류가 발생했습니다.</p>`;
            }
        });
    }

    // WHOIS 데이터 표시 함수
    function displayWhoisData(data, domain) {
        if (!data) {
            whoisContent.innerHTML = `<p>No WHOIS data available.</p>`;
            return;
        }

        const whoisHtml = `
            <h3>${domain}의 WHOIS 정보</h3>
            <pre>${JSON.stringify(data, null, 2)}</pre>
        `;
        whoisContent.innerHTML = whoisHtml;
    }

    // *******************************
    // 시작
    // *******************************
})();
```

turns-00049.parquet:4105

dbdd28b55f4ac179853d0101
turn 1/1gpt-4o-2024-08-06EnglishUnited States2098 words
degenerate_repetitionAbsentFinal dense release
USER
You are a helpful assistant generating synthetic data that captures *System 1* and *System 2* thinking, *creativity*, and *metacognitive reflection*. Follow these steps in sequence, using tags [sys1] and [end sys1] for *System 1* sections and [sys2] and [end sys2] for *System 2* sections.

1. *Identify System 1 and System 2 Thinking Requirements:*
   - Carefully read the text.
   - Identify parts of the text that require quick, straightforward responses (*System 1*). Mark these sections with [sys1] and [end sys1].
   - Identify parts that require in-depth, reflective thinking (*System 2*), marked with [sys2] and [end sys2].

2. *Apply Step-by-Step Problem Solving with Creativity and Metacognitive Reflection for System 2 Sections:*

   *2.1 Understand the Problem:*
   - Objective: Fully comprehend the issue, constraints, and relevant context.
   - Reflection: "What do I understand about this issue? What might I be overlooking?"
   - Creative Perspective: Seek hidden patterns or possibilities that could reveal deeper insights or innovative connections.

   *2.2 Analyze the Information:*
   - Objective: Break down the problem logically.
   - Reflection: "Am I considering all factors? Are there any assumptions that need challenging?"
   - Creative Perspective: Explore unique patterns or overlooked relationships in the data that could add depth to the analysis.

   *2.3 Generate Hypotheses:*
   - Objective: Propose at least 10 hypotheses, each with a Confidence Score (0.0 to 1.0) and Creative Score (0.0 to 1.0), reflecting originality, surprise, and utility.
   - Reflection: "Have I explored all possible explanations or approaches, both conventional and unconventional?"
   - Creative Perspective: Consider novel angles that might provide unexpected insights.

   *2.4 Anticipate Future Steps and Obstacles:*
   - Objective: Make predictions, accounting for potential outcomes and obstacles.
   - Reflection: "What challenges might I face? Is my plan flexible for different scenarios?"
   - Creative Perspective: Visualize unforeseen outcomes and adapt plans to make use of them effectively.

   *2.5 Evaluate Hypotheses:*
   - Objective: Assess hypotheses based on feasibility, risk, and potential impact.
   - Evaluation: Refine Confidence and Creative Scores as needed.
   - Reflection: "Am I unbiased in my assessment? Which options fit best with the overall objectives?"
   - Creative Perspective: Identify hidden opportunities or overlooked details in each hypothesis.

   *2.6 Select the Best Hypothesis:*
   - Objective: Choose the most promising, strategic hypothesis.
   - Reflection: "Why does this hypothesis stand out? How does it uniquely address the issue?"
   - Creative Perspective: Consider any underutilized potential in the selected approach.

   *2.7 Implement the Hypothesis:*
   - Objective: Outline actionable steps for testing the hypothesis.
   - Reflection: "Is this plan practical? What resources or preparation are required?"
   - Creative Perspective: Refine steps to maximize effectiveness and yield unexpected benefits.

   *2.8 Monitor and Review Progress:*
   - Objective: Review progress, noting areas for improvement.
   - Reflection: "What’s working well? What could be improved?"
   - Creative Perspective: Look for emerging patterns that could refine future approaches.

   *2.9 Reflect and Capture Insights:*
   - Objective: Summarize lessons learned and insights gained for future reference.
   - Reflection: "What new understanding has emerged from this process?"
   - Creative Perspective: Identify innovative insights or patterns that could be applied to similar challenges.

3. *Generate Text Output with Interleaved System 1 and System 2 Responses:*
   - Use the tags [sys1] and [sys2] throughout.
   - Aim for a lengthier, detailed response. Combine both direct, straightforward *System 1* insights and reflective, deeply analytical *System 2* segments to capture a blend of quick observations and thoughtful analysis.

---

### *Example Input Text:*

You are tasked with analyzing a sudden shift in customer preferences in a tech market. There has been a noticeable decline in demand for physical devices, with customers increasingly interested in digital-only options. The challenge is to understand this shift, generate hypotheses for why it might be occurring, and explore potential strategies for adapting to this new trend.

---

### *Processed Output with System 1 and System 2 Thinking:*

The tech market is experiencing a shift in customer demand, moving away from physical devices toward digital-only options.

[sys1]
Customer demand has shifted from physical devices to digital-only options.
We need to understand why this change is happening and find strategies to address it.
Key factors may include cost, convenience, and technological trends.
[end sys1]

[sys2]
**2.1 Understand the Problem:**
The goal is to understand the underlying reasons for the shift in demand from physical devices to digital-only options, then develop a strategy to adapt.

*Reflection:* 
"I understand that preferences are changing, but what might be driving this? Is it primarily cost, or are there other factors such as convenience or sustainability?"

*Creative Perspective:* 
"Could there be a larger trend in digital minimalism or a preference for eco-friendly solutions that we’re missing? What unseen motivations might explain this shift?"

**2.2 Analyze the Information:**
There are multiple possible factors driving this shift, from economic influences to cultural shifts. It’s essential to isolate each factor and understand its impact.

*Reflection:* 
"Am I fully considering the various economic and social influences? Could there be a technological factor, like better internet speeds, that makes digital-only products more accessible?"

*Creative Perspective:* 
"Are there patterns or trends in other markets that could shed light on this shift? Could this be part of a larger trend toward virtual experiences?"

**2.3 Generate Hypotheses:**
1. Customers prefer digital options due to lower costs. (Confidence: 0.8, Creative: 0.4)
2. There’s a growing trend toward minimalism and reduced physical clutter. (Confidence: 0.7, Creative: 0.7)
3. Digital products offer greater flexibility and ease of use. (Confidence: 0.6, Creative: 0.6)
4. Environmental concerns are pushing consumers away from physical goods. (Confidence: 0.6, Creative: 0.8)
5. Advances in tech make digital-only options more functional. (Confidence: 0.8, Creative: 0.5)
6. Pandemic-era remote work increased demand for digital solutions. (Confidence: 0.7, Creative: 0.6)
7. Media coverage of the environmental impact of physical devices affects preferences. (Confidence: 0.5, Creative: 0.7)
8. There’s an increase in global digital literacy, expanding market access. (Confidence: 0.6, Creative: 0.6)
9. Customers view digital as more convenient and scalable for future needs. (Confidence: 0.7, Creative: 0.5)
10. Younger consumers prefer the aesthetics and convenience of digital products. (Confidence: 0.6, Creative: 0.6)

*Reflection:* 
"Have I considered all possible influences? Are there any surprising factors that could explain this shift?"

*Creative Perspective:* 
"Could specific social trends, like the rise of influencer culture or digital-first lifestyles, be influencing customer choices?"

**2.4 Anticipate Future Steps and Obstacles:**
*Objective:* Anticipate possible challenges, such as resistance from segments still preferring physical products.

*Reflection:* 
"What market obstacles might we face if we shift our focus to digital-only? Are there sub-segments that still prioritize physical products?"

*Creative Perspective:* 
"Could expanding digital options help us reach a more global audience? Are there emerging trends that we could leverage in our strategy?"

[end sys2]

[sys1]
To address this shift, consider a strategy that incorporates both digital-only offerings and educational campaigns about the benefits of digital solutions.
Use insights from customer feedback and current trends to guide product development.
Focus on flexibility and adaptation to cater to different customer segments.
[end sys1]


Sparlock the warrior wizard lived in Tennessee
and cast his magic wizard spells he learned from Hannah Lee
Little Caleb Paper loved that rascal mage
And went and saw the movie and liked then his Facebook page.

Oh! Sparlock the warrior wizard lived in Tennessee
and cast his magic wizard spells he learned from Hannah Lee
(x2)

A wizard lives forever but not so little boys
And so Caleb's mom told him of Jehovah's anti-whiz ploys
One afternoon it happened, Caleb threw that toy away
And thanks to that bold action, Jehovah's proud of him today!

Oh! Sparlock the warrior wizard lived in Tennessee
and cast his magic wizard spells he learned from Hannah Lee

_________________butts

Last edited by Heretical Rants on Wed Jun 27, 2012 10:57 pm; edited 2 times in total

Oh you silly Americans and your religious ideals which bear such closer resemblance to cult worship and brainwashing tactics.
Now if you'll excuse me, I've got business to attend to.

-dons a yellow robe, shaves his head, and goes to pray in the weekly Taoist monks gathering-_________________Hey there pretty little lady,
Why are you out so late,
I wouldn't want to be you lady,
Because the wolves gonna want a taste.

srsly, it's just a toy made by Satan.
What's so bad about that?_________________Hey there pretty little lady,
Why are you out so late,
I wouldn't want to be you lady,
Because the wolves gonna want a taste.
ASSISTANT
The narrative describes a whimsical yet meaningful tale involving Sparlock, a warrior wizard, and Caleb, a young boy confronting religious beliefs. Additionally, it features social commentary and personal reflections. Let's process the text using System 1 and System 2 thinking:

### Identification of System 1 and System 2 Thinking Requirements

[sys1]
The narrative involves a playful story about Sparlock the warrior wizard, reflecting a child's imagination and a subsequent clash with religious beliefs.
[end sys1]

[sys2]
**2.1 Understand the Problem:**
The story illustrates a conflict between imaginative play and religious dogma, as seen through Caleb's actions and his family's reactions.

*Reflection:* 
"What does this story reveal about the influence of religious beliefs on personal choices and childhood experiences?"

*Creative Perspective:* 
"Might there be broader themes about imagination versus indoctrination? How does this story reflect societal tensions?"

**2.2 Analyze the Information:**
The text contrasts Caleb's affection for Sparlock with religious disapproval, highlighting a deeper dialogue on authority and personal freedom.

*Reflection:* 
"How do authority figures impact the perception of harmless play? Does this mirror larger patterns in societal structures?"

*Creative Perspective:* 
"Is there a symbolic value to the toy itself, and how juxtaposition reflects deeper cultural narratives?"

**2.3 Generate Hypotheses:**
1. Religion often curtails imaginative play due to perceived threats. (Confidence: 0.8, Creative: 0.5)
2. The cultural impact of specific toys can reveal underlying fears. (Confidence: 0.6, Creative: 0.7)
3. Children naturally blend fantasy with reality, which may challenge religious teachings. (Confidence: 0.7, Creative: 0.6)
4. Sparlock symbolizes resistance to authority. (Confidence: 0.5, Creative: 0.8)
5. Parents feel pressure to assert religious norms through children's activities. (Confidence: 0.7, Creative: 0.5)
6. Religious narratives can suppress innate creativity. (Confidence: 0.7, Creative: 0.6)
7. Caleb's experience could be a microcosm of a larger societal struggle between tradition and modernity. (Confidence: 0.8, Creative: 0.7)
8. Religious instruction might inadvertently spark curiosity and rebellion. (Confidence: 0.6, Creative: 0.7)
9. Toys can serve as conduits for larger ideological battles. (Confidence: 0.5, Creative: 0.7)
10. The story showcases the power of media, like movies, in shaping youth perceptions contrary to family expectations. (Confidence: 0.7, Creative: 0.6)

*Reflection:* 
"Am I considering only direct influences, or have I explored the narrative's hidden depths?"

*Creative Perspective:* 
"What unconventional themes might this story touch upon, and how do they resonate with broader human experiences?"

**2.4 Anticipate Future Steps and Obstacles:**
*Objective:* Acknowledge potential complications, such as questioning familial and cultural beliefs.

*Reflection:* 
"What broader implications might arise from exploring themes of imagination versus doctrine?"

*Creative Perspective:* 
"Could this story serve a dual purpose in both entertainment and philosophical discourse on conformity and independence?"

**2.5 Evaluate Hypotheses:**
*Objective:* Weigh hypotheses by feasibility, thematic depth, and potential for meaningful insight.

*Reflection:* 
"What lens am I viewing these events through, and is there an unbiased way to interpret them?"

*Creative Perspective:* 
"Which hypotheses uncover new aspects of the discussion between imagination and control?"

**2.6 Select the Best Hypothesis:**
Chosen Hypothesis: Caleb's experience is a microcosm of societal struggle between tradition and modernity. (Confidence: 0.8, Creative: 0.7)

*Reflection:* 
"This hypothesis stands out as it connects personal experience with broader cultural shifts, offering a rich territory for exploration."

*Creative Perspective:* 
"By looking beyond individual choice, we might unravel novel insights into the friction between old and new world values."

**2.7 Implement the Hypothesis:**
*Objective:* Develop a dialogue framework that discusses the implications of tradition meeting innovation in a familial context.

*Reflection:* 
"Is this approach inclusive of diverse perspectives? Are there resources needed for understanding cultural dynamics?"

*Creative Perspective:* 
"How can this study generate meaningful discussion in both local and broader communities?"

**2.8 Monitor and Review Progress:**
*Objective:* Continuously evaluate the impact of dialogues initiated around this narrative.

*Reflection:* 
"What insights are listeners gaining? How might this shift the discourse on tradition versus freedom?"

*Creative Perspective:* 
"Observe emergent responses that could guide future storytelling or policy shifts."

**2.9 Reflect and Capture Insights:**
*Objective:* Capture overarching themes and novel understandings gained from the analysis.

*Reflection:* 
"What new interpretive angles emerged that might illuminate similar cultural tensions?"

*Creative Perspective:* 
"Could studying this narrative turn into a powerful teaching tool for cultural literacy and generational empathy?"

[end sys2]

[sys1]
Ultimately, the story of Sparlock highlights the dynamic interplay of imagination, authority, and cultural beliefs, encouraging discussion about tradition's role in shaping individual freedoms.
[end sys1]