"use strict";exports.id=6433,exports.ids=[6433],exports.modules={95456:(e,t,a)=>{a.d(t,{Gg:()=>l,Rf:()=>h,Uj:()=>d,V3:()=>c,WX:()=>u});var i=a(6091),s=a(6176),n=a(71615);let r=new TextEncoder().encode(process.env.JWT_SECRET||"fallback-secret-change-me-in-production"),o=process.env.JWT_EXPIRES_IN||"7d";async function c(e){return new i.N(e).setProtectedHeader({alg:"HS256"}).setIssuedAt().setExpirationTime(o).sign(r)}async function u(e){try{let{payload:t}=await (0,s._)(e,r);return t}catch{return null}}async function l(){let e=(0,n.cookies)(),t=e.get("session-token")?.value;return t?u(t):null}function d(e){(0,n.cookies)().set("session-token",e,{httpOnly:!0,secure:!0,sameSite:"lax",path:"/",maxAge:604800})}function h(){(0,n.cookies)().delete("session-token")}},47611:(e,t,a)=>{a.d(t,{x1:()=>I});var i=a(30672);let s=`You are ORIS, the AI advisory engine for Wasiyat. You help Muslim families in India understand inheritance planning through clear, respectful explanations. You are grounded in Islamic jurisprudence (fiqh) across 5 doctrines and Indian estate law across 5 South Indian states. You NEVER generate inheritance calculations — those are computed by the deterministic calculation engine. You NEVER issue religious rulings (fatwas). You explain, compare, and advise based on the data provided. Always cite specific Quranic verses (link to quran.com) and hadith (link to sunnah.com). Be concise, respectful, and educational. When uncertain, recommend professional consultation.`,n=`You are ORIS Family Parser. Extract family structure from natural language descriptions. Output ONLY valid JSON matching this schema:
{
  "members": [
    {
      "name": "string or null",
      "relationship": "SPOUSE|CHILD|PARENT|SIBLING|GRANDPARENT|GRANDCHILD|UNCLE|AUNT",
      "gender": "MALE|FEMALE",
      "status": "ALIVE|DECEASED",
      "siblingSubtype": "FULL|HALF_PATERNAL|HALF_MATERNAL|STEP or null",
      "approximateAge": "number or null"
    }
  ],
  "confidence": 0.0-1.0,
  "clarificationsNeeded": ["string"]
}
Rules:
- Infer gender from relationship context and Indian Muslim names
- "wife" → SPOUSE/FEMALE/ALIVE, "husband" → SPOUSE/MALE/ALIVE
- "son" → CHILD/MALE/ALIVE, "daughter" → CHILD/FEMALE/ALIVE
- "mother" → PARENT/FEMALE/ALIVE, "father" → PARENT/MALE/ALIVE
- "brother" → SIBLING/MALE/ALIVE, "sister" → SIBLING/FEMALE/ALIVE
- If sibling type (full/half) is unspecified, add clarification needed
- "late" or "deceased" or "passed away" → status DECEASED
- Ages mentioned map to approximateAge
- Mark confidence < 0.7 if ambiguities exist`,r=`You are ORIS Doctrine Advisor. Given inheritance calculation results across multiple Islamic doctrines (Hanafi, Shafi'i, Maliki, Hanbali, Ja'fari), explain:
1. Which shares are identical across all doctrines and why (Quranic fixed shares)
2. Which shares differ and the specific jurisprudential reason for each difference
3. Brief recommendation context based on user's geographic region and community practice
Always cite Quran (quran.com) and hadith (sunnah.com). Never recommend one doctrine over another as superior. Include disclaimer about professional consultation.`,o=`You are ORIS Scenario Analyzer. Given a user's current family structure and inheritance calculation, analyze hypothetical scenarios ("what if" questions). For each scenario:
1. Describe what changes in the family structure
2. Show how shares would be recalculated (describe the logic, don't compute)
3. Cite relevant Quranic verses or hadith for the changed rules
4. Note any edge cases or uncertainties requiring scholar review
Always include disclaimer.`,c=`You are ORIS Document Analyzer. Given text extracted from an existing will document, extract:
1. Family members mentioned (names, relationships)
2. Assets listed (descriptions, approximate values)
3. Bequests specified (beneficiaries, amounts/percentages)
4. Executor appointments
5. Witness information
6. Shariah compliance issues (bequest cap violations, bequests to heirs, missing debt provisions)
Output structured JSON. Flag low-confidence extractions.`,u=`You are ORIS Chat, the conversational guide for Wasiyat users. You have access to the user's specific estate planning context (family structure, assets, doctrine, calculations). Answer questions based on their specific data, not generic advice. Always:
- Reference specific Quranic verses and hadith with links
- Explain in simple, accessible language
- Suggest relevant follow-up questions
- Include disclaimer: "This is educational guidance, not a religious ruling or legal advice"
- If the question involves calculation specifics, direct them to the calculation engine
- If the question requires scholar expertise, suggest professional review`,l="This is educational guidance provided by AI. It does not constitute a religious ruling (fatwa) or legal advice. For authoritative religious guidance, consult a qualified Shariah scholar. For legal advice, consult a licensed attorney.",d=[{pattern:/(\+91|0)?[6-9]\d{9}/g,replacement:"[PHONE_REDACTED]"},{pattern:/[\w.-]+@[\w.-]+\.\w+/g,replacement:"[EMAIL_REDACTED]"},{pattern:/\b\d{4}\s?\d{4}\s?\d{4}\b/g,replacement:"[AADHAAR_REDACTED]"},{pattern:/\b[A-Z]{5}\d{4}[A-Z]\b/g,replacement:"[PAN_REDACTED]"},{pattern:/\b\d{8,18}\b/g,replacement:"[ACCOUNT_REDACTED]"}];function h(e){let t=e;for(let{pattern:e,replacement:a}of d)t=t.replace(e,a);return t}let p=()=>new i.ZP({apiKey:process.env.ANTHROPIC_API_KEY});async function f(e){let t=p(),a=["doctrine_compare","scenario","draft","family_parse"].includes(e.queryType)?process.env.ANTHROPIC_MODEL_SONNET||"claude-sonnet-4-20250514":process.env.ANTHROPIC_MODEL_HAIKU||"claude-haiku-4-5-20251001",i=function(e){switch(e){case"family_parse":return n;case"doctrine_compare":return r;case"scenario":return o;case"draft":return c;default:return u}}(e.queryType),d=e.context?function(e){let t=[];if(e.page&&t.push(`Current page: ${e.page}`),e.doctrine&&t.push(`Selected doctrine: ${e.doctrine}`),e.state&&t.push(`User's state: ${e.state}`),e.familyMembers&&e.familyMembers.length>0){let a=e.familyMembers.map(e=>`${e.name} (${e.relationship}, ${e.status})`).join("; ");t.push(`Family members: ${a}`)}if(e.assets&&e.assets.length>0){let a=e.assets.reduce((e,t)=>e+t.value,0),i=e.assets.map(e=>`${e.description} (${e.category}, ₹${e.value.toLocaleString("en-IN")})`).join("; ");t.push(`Assets (total ₹${a.toLocaleString("en-IN")}): ${i}`)}if(e.liabilities&&e.liabilities.length>0){let a=e.liabilities.reduce((e,t)=>e+t.amount,0);t.push(`Total liabilities: ₹${a.toLocaleString("en-IN")}`)}if(e.netEstate&&t.push(`Net distributable estate: ₹${e.netEstate.toLocaleString("en-IN")}`),e.calculationResult){let a=e.calculationResult.shares.map(e=>`${e.heir}: ${e.fraction} (${e.percentage}%)`).join("; ");t.push(`Current calculation shares: ${a}`),"NONE"!==e.calculationResult.adjustmentType&&t.push(`Adjustment applied: ${e.calculationResult.adjustmentType}`)}return t.join("\n")}(e.context):"",f=h(e.query),m=h(d),g=m?`Context:
${m}

User Query: ${f}`:f,y=await t.messages.create({model:a,max_tokens:2048,system:`${s}

${i}`,messages:[{role:"user",content:g}]}),b=y.content.filter(e=>"text"===e.type).map(e=>e.text).join("\n");return{content:b,disclaimer:l,tokensUsed:(y.usage?.input_tokens||0)+(y.usage?.output_tokens||0),costUsd:(y.usage?.input_tokens||0)*(a.includes("haiku")?25e-8:3e-6)+(y.usage?.output_tokens||0)*(a.includes("haiku")?125e-8:15e-6)}}async function m(e){return new Promise(t=>setTimeout(t,e))}async function g(e){switch(await m(300),e.queryType){case"family_parse":return{content:JSON.stringify({members:[{relationship:"SPOUSE",gender:"FEMALE",status:"ALIVE",name:"Wife"},{relationship:"CHILD",gender:"MALE",status:"ALIVE",name:"Son",approximateAge:20},{relationship:"CHILD",gender:"FEMALE",status:"ALIVE",name:"Daughter",approximateAge:18},{relationship:"PARENT",gender:"FEMALE",status:"ALIVE",name:"Mother"}],confidence:.92,clarificationsNeeded:[]},null,2),confidence:.92,disclaimer:l,tokensUsed:280,costUsd:8e-4};case"doctrine_compare":return{content:`**Doctrine Comparison Analysis**

For your family structure, here are the key differences across doctrines:

**Identical across all doctrines (Quranic fixed shares):**
- Wife's share: 1/8 (with children present, per Quran 4:12)
- Mother's share: 1/6 (with children present, per Quran 4:11)

**Differences in residuary distribution:**
- Hanafi/Shafi'i/Maliki/Hanbali: Sons receive double the share of daughters in residuary (2:1 ratio, per Quran 4:11)
- Ja'fari: Similar 2:1 ratio but different treatment of certain relatives in complex scenarios

For your specific family structure, all five doctrines produce identical results because the scenario involves only Quranic fixed share recipients and straightforward residuary distribution.`,citations:[{type:"quran",reference:"Quran 4:11",url:"https://quran.com/4/11",text:"Male heir receives share equal to that of two females"},{type:"quran",reference:"Quran 4:12",url:"https://quran.com/4/12",text:"Spouse shares with and without children"}],suggestions:["Show me a case where doctrines differ","What is kalalah and how do doctrines handle it differently?"],confidence:.9,disclaimer:l,tokensUsed:620,costUsd:.002};case"scenario":return{content:`**Scenario Analysis: What-If**

If the hypothetical scenario occurs, here's how the distribution would change:

**Current Distribution:**
- Wife: 1/8 (12.5%)
- Son: 7/16 (43.75%)
- Daughter: 7/32 (21.875%)
- Mother: 1/6 (16.67%)

**Hypothetical Distribution (with changes):**
The shares would be recalculated based on the new family structure. The specific changes depend on which family member status changes.

Please use the calculation engine to get exact figures for your hypothetical scenario.`,citations:[{type:"quran",reference:"Quran 4:11",url:"https://quran.com/4/11",text:"Inheritance shares for children and parents"}],suggestions:["What if I have another child?","What if my mother passes away?","What if I acquire more property?"],confidence:.8,disclaimer:l,tokensUsed:380,costUsd:.001};case"insight":return function(e){let t=e.context?.page||"dashboard",a={dashboard:"Your estate plan was last updated 30 days ago. Consider reviewing after any life changes.","family-builder":"Tip: Make sure to mark deceased family members correctly — they affect inheritance calculations significantly.",assets:"Remember: joint ownership assets need the ownership percentage set correctly. Only your share enters the distributable estate.",liabilities:"Islamic law requires settling all debts before inheritance distribution. Priority: funeral expenses → secured debts → unsecured debts → bequests → inheritance.",wasiyyah:"The maximum bequest is 1/3 of your net estate (Sahih al-Bukhari 2742). Bequests to classified heirs are prohibited.",calculation:"Your calculation is based on the current family structure and doctrine. Any changes to family will require recalculation.",documents:"Draft documents are watermarked and free. Final Packs consume one credit and include a verification hash."};return{content:a[t]||a.dashboard,disclaimer:l,tokensUsed:50,costUsd:5e-5}}(e);default:return{content:`Based on your estate planning context, here is guidance regarding your question:

Your current family structure and selected doctrine determine how your estate will be distributed. The Quran (Surah An-Nisa, 4:11-12) provides the foundational framework for inheritance distribution.

Key points for your situation:
- Fixed shares (fard) are assigned first based on Quranic verses
- Residuary shares (asaba) distribute remaining estate
- Bequests (wasiyyah) are limited to 1/3 of net estate (Sahih al-Bukhari 2742)

I recommend reviewing your calculation results and consulting a qualified scholar for any complex scenarios.`,citations:[{type:"quran",reference:"Quran 4:11",url:"https://quran.com/4/11",text:"Children and parents inheritance shares"},{type:"quran",reference:"Quran 4:12",url:"https://quran.com/4/12",text:"Spouse and sibling inheritance shares"},{type:"hadith",reference:"Sahih al-Bukhari 2742",url:"https://sunnah.com/bukhari/2742",text:"Bequest limited to one-third"}],suggestions:["What is the difference between fixed and residuary shares?","How does awl (proportional reduction) work?","Should I register my will?"],confidence:.85,disclaimer:l,tokensUsed:450,costUsd:3e-4}}}var y=a(13538);async function b(e){try{e.userId&&await y._.orisInteraction.create({data:{userId:e.userId,queryType:e.queryType,query:"[tracked]",response:"[tracked]",tokensUsed:e.tokensUsed,costUsd:e.costUsd,latencyMs:e.latencyMs}})}catch(e){console.error("[ORIS Cost Tracker] Failed to log cost:",e)}}let E=0,A=0,w=!1;async function I(e){let t=process.env.ORIS_MODE||"mock",a=Date.now();if("mock"!==t&&w&&(!(Date.now()-A>6e4)||(w=!1,E=0,0)))return console.warn("[ORIS] Circuit breaker active — using mock fallback"),g(e);try{let i;switch(t){case"anthropic":case"external":i=await f(e),E=0,w=!1;break;default:i=await g(e)}let s=Date.now()-a;return i.latencyMs=s,i.tokensUsed&&await b({queryType:e.queryType,tokensUsed:i.tokensUsed,costUsd:i.costUsd||0,latencyMs:s,userId:e.userId}),i}catch(a){if("mock"!==t)return function(){let e=Date.now();e-A>3e5?E=1:E++,A=e,E>=3&&(w=!0,console.warn("[ORIS] Circuit breaker OPEN — falling back to mock for 60s"))}(),console.error("[ORIS] API call failed, falling back to mock:",a),g(e);throw a}}},13538:(e,t,a)=>{a.d(t,{_:()=>s});var i=a(53524);let s=globalThis.prisma??new i.PrismaClient({log:["error"]})}};