diff --git a/bun.lockb b/bun.lockb index a2dd2af..f5c5689 100644 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/package.json b/package.json index 84141a8..236c93d 100644 --- a/package.json +++ b/package.json @@ -56,6 +56,7 @@ "rehype-mathjax": "4.0.3", "remark-gfm": "3.0.1", "remark-math": "5.1.1", + "tesseract.js": "^5.1.1", "turndown": "^7.1.3", "yt-transcript": "^0.0.2", "zustand": "^4.5.0" diff --git a/src/assets/locale/ar/chrome.json b/src/assets/locale/ar/chrome.json new file mode 100644 index 0000000..2e75af6 --- /dev/null +++ b/src/assets/locale/ar/chrome.json @@ -0,0 +1,13 @@ +{ + "heading": "إعداد Chrome AI", + "status": { + "label": "تمكين أو تعطيل دعم Chrome AI في مساعد الصفحة" + }, + "error": { + "browser_not_supported": "هذا الإصدار من Chrome غير مدعوم من نموذج Gemini Nano. يرجى التحديث إلى الإصدار 127 أو أحدث", + "ai_not_supported": "الإعداد chrome://flags/#prompt-api-for-gemini-nano غير مفعل. يرجى تفعيله.", + "ai_not_ready": "Gemini Nano غير جاهز بعد؛ تحتاج إلى التحقق مرة أخرى من إعدادات Chrome.", + "internal_error": "حدث خطأ داخلي. يرجى المحاولة مرة أخرى لاحقاً." + }, + "errorDescription": "لاستخدام Chrome AI، تحتاج إلى إصدار متصفح أعلى من 127، وهو متوفر حالياً في قنوات Dev و Canary. بعد تنزيل الإصدار المدعوم، اتبع هذه الخطوات:\n\n1. انتقل إلى `chrome://flags/#prompt-api-for-gemini-nano` واختر \"تمكين\".\n2. انتقل إلى `chrome://flags/#optimization-guide-on-device-model` واختر \"EnabledBypassPrefRequirement\".\n3. انتقل إلى `chrome://components`، ابحث عن \"Optimization Guide On Device Model\"، وانقر على \"التحقق من التحديثات\". سيؤدي هذا إلى تنزيل النموذج. إذا لم تر الإعدادات، كرر الخطوتين 1 و 2 وأعد تشغيل المتصفح." +} \ No newline at end of file diff --git a/src/assets/locale/ar/common.json b/src/assets/locale/ar/common.json new file mode 100644 index 0000000..2f8e349 --- /dev/null +++ b/src/assets/locale/ar/common.json @@ -0,0 +1,128 @@ +{ + "pageAssist": "مساعد الصفحة", + "selectAModel": "اختر نموذجًا", + "save": "حفظ", + "saved": "تم الحفظ", + "cancel": "إلغاء", + "retry": "إعادة المحاولة", + "share": { + "tooltip": { + "share": "مشاركة" + }, + "modal": { + "title": "مشاركة رابط المحادثة" + }, + "form": { + "defaultValue": { + "name": "مجهول", + "title": "محادثة بدون عنوان" + }, + "title": { + "label": "عنوان المحادثة", + "placeholder": "أدخل عنوان المحادثة", + "required": "عنوان المحادثة مطلوب" + }, + "name": { + "label": "اسمك", + "placeholder": "أدخل اسمك", + "required": "اسمك مطلوب" + }, + "btn": { + "save": "إنشاء رابط", + "saving": "جاري إنشاء الرابط..." + } + }, + "notification": { + "successGenerate": "تم نسخ الرابط إلى الحافظة", + "failGenerate": "فشل في إنشاء الرابط" + } + }, + "copyToClipboard": "نسخ إلى الحافظة", + "webSearch": "البحث في الويب", + "regenerate": "إعادة التوليد", + "edit": "تعديل", + "delete": "حذف", + "saveAndSubmit": "حفظ وإرسال", + "editMessage": { + "placeholder": "اكتب رسالة..." + }, + "submit": "إرسال", + "noData": "لا توجد بيانات", + "noHistory": "لا يوجد سجل محادثات", + "chatWithCurrentPage": "الدردشة مع الصفحة الحالية", + "beta": "تجريبي", + "tts": "قراءة بصوت عالٍ", + "currentChatModelSettings": "إعدادات نموذج المحادثة الحالي", + "modelSettings": { + "label": "إعدادات النموذج", + "description": "تعيين خيارات النموذج عالمياً لجميع المحادثات", + "form": { + "keepAlive": { + "label": "الإبقاء نشطاً", + "help": "يتحكم في المدة التي سيظل فيها النموذج محملاً في الذاكرة بعد الطلب (الافتراضي: 5 دقائق)", + "placeholder": "أدخل مدة البقاء نشطاً (مثال: 5م، 10م، 1س)" + }, + "temperature": { + "label": "درجة الحرارة", + "placeholder": "أدخل قيمة درجة الحرارة (مثال: 0.7، 1.0)" + }, + "numCtx": { + "label": "عدد السياقات", + "placeholder": "أدخل قيمة عدد السياقات (الافتراضي: 2048)" + }, + "numPredict": { + "label": "الحد الأقصى للرموز", + "placeholder": "أدخل قيمة الحد الأقصى للرموز (مثال: 2048، 4096)" + }, + "seed": { + "label": "البذرة", + "placeholder": "أدخل قيمة البذرة (مثال: 1234)", + "help": "إمكانية تكرار مخرجات النموذج" + }, + "topK": { + "label": "أعلى K", + "placeholder": "أدخل قيمة أعلى K (مثال: 40، 100)" + }, + "topP": { + "label": "أعلى P", + "placeholder": "أدخل قيمة أعلى P (مثال: 0.9، 0.95)" + }, + "useMMap": { + "label": "استخدام MMap" + }, + "numGpu": { + "label": "عدد وحدات معالجة الرسومات", + "placeholder": "أدخل عدد الطبقات لإرسالها إلى وحدة/وحدات معالجة الرسومات" + }, + "systemPrompt": { + "label": "موجه النظام المؤقت", + "placeholder": "أدخل موجه النظام", + "help": "هذه طريقة سريعة لتعيين موجه النظام في المحادثة الحالية، والذي سيتجاوز موجه النظام المحدد إذا كان موجوداً." + } + }, + "advanced": "المزيد من إعدادات النموذج" + }, + "copilot": { + "summary": "تلخيص", + "explain": "شرح", + "rephrase": "إعادة صياغة", + "translate": "ترجمة", + "custom": "مخصص" + }, + "citations": "الاقتباسات", + "segmented": { + "ollama": "نماذج Ollama", + "custom": "نماذج مخصصة" + }, + "downloadCode": "تنزيل الكود", + "date": { + "pinned": "مثبت", + "today": "اليوم", + "yesterday": "الأمس", + "last7Days": "آخر 7 أيام", + "older": "أقدم" + }, + "pin": "تثبيت", + "unpin": "إلغاء التثبيت", + "generationInfo": "معلومات التوليد" +} diff --git a/src/assets/locale/ar/knowledge.json b/src/assets/locale/ar/knowledge.json new file mode 100644 index 0000000..ae9f6cd --- /dev/null +++ b/src/assets/locale/ar/knowledge.json @@ -0,0 +1,40 @@ +{ + "addBtn": "إضافة معرفة جديدة", + "columns": { + "title": "العنوان", + "status": "الحالة", + "embeddings": "نموذج التضمين", + "createdAt": "تاريخ الإنشاء", + "action": "الإجراءات" + }, + "expandedColumns": { + "name": "الاسم" + }, + "confirm": { + "delete": "هل أنت متأكد أنك تريد حذف هذه المعرفة؟" + }, + "deleteSuccess": "تم حذف المعرفة بنجاح", + "status": { + "pending": "قيد الانتظار", + "finished": "مكتمل", + "processing": "قيد المعالجة", + "failed": "فشل" + }, + "addKnowledge": "إضافة معرفة", + "form": { + "title": { + "label": "عنوان المعرفة", + "placeholder": "أدخل عنوان المعرفة", + "required": "عنوان المعرفة مطلوب" + }, + "uploadFile": { + "label": "رفع ملف", + "uploadText": "اسحب وأفلت ملفًا هنا أو انقر للرفع", + "uploadHint": "أنواع الملفات المدعومة: .pdf, .csv, .txt, .md, .docx", + "required": "الملف مطلوب" + }, + "submit": "إرسال", + "success": "تمت إضافة المعرفة بنجاح" + }, + "noEmbeddingModel": "يرجى إضافة نموذج تضمين من صفحة إعدادات RAG أولاً" +} \ No newline at end of file diff --git a/src/assets/locale/ar/openai.json b/src/assets/locale/ar/openai.json new file mode 100644 index 0000000..58207fd --- /dev/null +++ b/src/assets/locale/ar/openai.json @@ -0,0 +1,90 @@ +{ + "settings": "واجهة برمجة التطبيقات المتوافقة مع OpenAI", + "heading": "واجهة برمجة التطبيقات المتوافقة مع OpenAI", + "subheading": "إدارة وتكوين مزودي واجهة برمجة التطبيقات المتوافقة مع OpenAI هنا.", + "addBtn": "إضافة مزود", + "table": { + "name": "اسم المزود", + "baseUrl": "عنوان URL الأساسي", + "actions": "إجراء" + }, + "modal": { + "titleAdd": "إضافة مزود جديد", + "name": { + "label": "اسم المزود", + "required": "اسم المزود مطلوب.", + "placeholder": "أدخل اسم المزود" + }, + "baseUrl": { + "label": "عنوان URL الأساسي", + "help": "عنوان URL الأساسي لمزود واجهة برمجة التطبيقات OpenAI. مثال (http://localhost:1234/v1)", + "required": "عنوان URL الأساسي مطلوب.", + "placeholder": "أدخل عنوان URL الأساسي" + }, + "apiKey": { + "label": "مفتاح API", + "required": "مفتاح API مطلوب.", + "placeholder": "أدخل مفتاح API" + }, + "submit": "حفظ", + "update": "تحديث", + "deleteConfirm": "هل أنت متأكد أنك تريد حذف هذا المزود؟", + "model": { + "title": "قائمة النماذج", + "subheading": "يرجى تحديد نماذج المحادثة التي تريد استخدامها مع هذا المزود.", + "success": "تمت إضافة نماذج جديدة بنجاح." + }, + "tipLMStudio": "سيقوم Page Assist تلقائيًا بجلب النماذج التي قمت بتحميلها على LM Studio. لست بحاجة إلى إضافتها يدويًا." + }, + "addSuccess": "تمت إضافة المزود بنجاح.", + "deleteSuccess": "تم حذف المزود بنجاح.", + "updateSuccess": "تم تحديث المزود بنجاح.", + "delete": "حذف", + "edit": "تعديل", + "newModel": "إضافة نماذج للمزود", + "noNewModel": "بالنسبة لـ LMStudio و Ollama و Llamafile، نقوم بالجلب ديناميكيًا. لا حاجة للإضافة اليدوية.", + "searchModel": "بحث عن نموذج", + "selectAll": "تحديد الكل", + "save": "حفظ", + "saving": "جاري الحفظ...", + "manageModels": { + "columns": { + "name": "اسم النموذج", + "model_type": "نوع النموذج", + "model_id": "معرف النموذج", + "provider": "اسم المزود", + "actions": "إجراء" + }, + "tooltip": { + "delete": "حذف" + }, + "confirm": { + "delete": "هل أنت متأكد أنك تريد حذف هذا النموذج؟" + }, + "modal": { + "title": "إضافة نموذج مخصص", + "form": { + "name": { + "label": "معرف النموذج", + "placeholder": "llama3.2", + "required": "معرف النموذج مطلوب." + }, + "provider": { + "label": "المزود", + "placeholder": "اختر المزود", + "required": "المزود مطلوب." + }, + "type": { + "label": "نوع النموذج" + } + } + } + }, + "noModelFound": "لم يتم العثور على نموذج. تأكد من إضافة المزود الصحيح مع عنوان URL الأساسي ومفتاح API.", + "radio": { + "chat": "نموذج المحادثة", + "embedding": "نموذج التضمين", + "chatInfo": "يستخدم لإكمال المحادثة وتوليد المحادثات", + "embeddingInfo": "يستخدم لـ RAG ومهام البحث الدلالي الأخرى ذات الصلة." + } +} \ No newline at end of file diff --git a/src/assets/locale/ar/option.json b/src/assets/locale/ar/option.json new file mode 100644 index 0000000..5886434 --- /dev/null +++ b/src/assets/locale/ar/option.json @@ -0,0 +1,28 @@ +{ + "newChat": "محادثة جديدة", + "selectAPrompt": "اختر موجهاً", + "githubRepository": "مستودع GitHub", + "settings": "الإعدادات", + "sidebarTitle": "سجل المحادثات", + "error": "خطأ", + "somethingWentWrong": "حدث خطأ ما", + "validationSelectModel": "الرجاء اختيار نموذج للمتابعة", + "deleteHistoryConfirmation": "هل أنت متأكد أنك تريد حذف هذا السجل؟", + "editHistoryTitle": "أدخل عنواناً جديداً", + "temporaryChat": "محادثة مؤقتة", + "more": { + "copy": { + "group": "نسخ", + "asText": "نسخ كنص", + "asMarkdown": "نسخ كماركداون", + "success": "تم النسخ إلى الحافظة!" + }, + "download": { + "group": "تنزيل", + "text": "ملف نصي (.txt)", + "markdown": "ماركداون (.md)", + "json": "ملف JSON (.json)" + }, + "share": "مشاركة" + } +} \ No newline at end of file diff --git a/src/assets/locale/ar/playground.json b/src/assets/locale/ar/playground.json new file mode 100644 index 0000000..a5dc623 --- /dev/null +++ b/src/assets/locale/ar/playground.json @@ -0,0 +1,32 @@ +{ + "ollamaState": { + "searching": "جارٍ البحث عن Ollama الخاص بك 🦙", + "running": "Ollama يعمل 🦙", + "notRunning": "تعذر الاتصال بـ Ollama 🦙", + "connectionError": "يبدو أنك تواجه خطأ في الاتصال. يرجى الرجوع إلى هذا الدليل لاستكشاف الأخطاء وإصلاحها." + }, + "formError": { + "noModel": "الرجاء اختيار نموذج", + "noEmbeddingModel": "الرجاء تعيين نموذج التضمين في صفحة الإعدادات > RAG" + }, + "form": { + "textarea": { + "placeholder": "اكتب رسالة..." + }, + "webSearch": { + "on": "تشغيل", + "off": "إيقاف" + } + }, + "tooltip": { + "searchInternet": "البحث في الإنترنت", + "speechToText": "تحويل الكلام إلى نص", + "uploadImage": "تحميل صورة", + "stopStreaming": "إيقاف البث", + "knowledge": "المعرفة", + "vision": "[تجريبي] محادثة الرؤية" + }, + "sendWhenEnter": "إرسال عند الضغط على Enter", + "welcome": "مرحباً! كيف يمكنني مساعدتك اليوم؟", + "useOCR": "استخراج النص من الصورة (OCR)" +} \ No newline at end of file diff --git a/src/assets/locale/ar/settings.json b/src/assets/locale/ar/settings.json new file mode 100644 index 0000000..6de45fd --- /dev/null +++ b/src/assets/locale/ar/settings.json @@ -0,0 +1,358 @@ +{ + "generalSettings": { + "title": "الإعدادات العامة", + "settings": { + "heading": "إعدادات واجهة المستخدم", + "speechRecognitionLang": { + "label": "لغة التعرف على الكلام", + "placeholder": "اختر لغة" + }, + "language": { + "label": "اللغة", + "placeholder": "اختر لغة" + }, + "darkMode": { + "label": "تغيير المظهر", + "options": { + "light": "فاتح", + "dark": "داكن" + } + }, + "copilotResumeLastChat": { + "label": "استئناف آخر محادثة عند فتح اللوحة الجانبية (كوبيلوت)" + }, + "webUIResumeLastChat": { + "label": "استئناف آخر محادثة عند فتح واجهة المستخدم" + }, + "hideCurrentChatModelSettings": { + "label": "إخفاء إعدادات نموذج المحادثة الحالي" + }, + "restoreLastChatModel": { + "label": "استعادة آخر نموذج مستخدم للمحادثات السابقة" + }, + "sendNotificationAfterIndexing": { + "label": "إرسال إشعار بعد الانتهاء من معالجة قاعدة المعرفة" + }, + "generateTitle": { + "label": "توليد العنوان باستخدام الذكاء الاصطناعي" + }, + "ollamaStatus": { + "label": "تمكين أو تعطيل فحص حالة اتصال أولاما" + } + }, + "sidepanelRag": { + "heading": "إعدادات الدردشة مع الموقع", + "ragEnabled": { + "label": "الدردشة مع الموقع باستخدام التضمينات المتجهة" + }, + "maxWebsiteContext": { + "label": "حجم محتوى الموقع في الوضع العادي", + "placeholder": "حجم المحتوى (الافتراضي 4028)" + } + }, + "webSearch": { + "heading": "إدارة البحث على الإنترنت", + "searchMode": { + "label": "إجراء بحث بسيط على الإنترنت" + }, + "provider": { + "label": "محرك البحث", + "placeholder": "اختر محرك بحث" + }, + "totalSearchResults": { + "label": "إجمالي نتائج البحث", + "placeholder": "أدخل إجمالي نتائج البحث" + }, + "visitSpecificWebsite": { + "label": "زيارة الموقع المذكور في الرسالة" + }, + "searxng": { + "url": { + "label": "رابط SearXNG" + } + }, + "braveApi": { + "label": "مفتاح واجهة برنامج Brave", + "placeholder": "أدخل مفتاح واجهة برنامج Brave" + }, + "googleDomain": { + "label": "نطاق جوجل" + } + }, + "system": { + "heading": "إعدادات النظام", + "deleteChatHistory": { + "label": "إعادة تعيين النظام", + "button": "إعادة تعيين الكل", + "confirm": "هل أنت متأكد أنك تريد إجراء إعادة تعيين النظام؟ سيؤدي هذا إلى مسح جميع البيانات ولا يمكن التراجع عنه." + }, + "export": { + "label": "تصدير سجل المحادثات وقاعدة المعرفة والإرشادات", + "button": "تصدير البيانات", + "success": "تم التصدير بنجاح" + }, + "import": { + "label": "استيراد سجل المحادثات وقاعدة المعرفة والإرشادات", + "button": "استيراد البيانات", + "success": "تم الاستيراد بنجاح", + "error": "خطأ في الاستيراد" + } + }, + "tts": { + "heading": "إعدادات تحويل النص إلى كلام", + "ttsEnabled": { + "label": "تمكين تحويل النص إلى كلام" + }, + "ttsProvider": { + "label": "مزود خدمة تحويل النص إلى كلام", + "placeholder": "اختر مزود خدمة" + }, + "ttsVoice": { + "label": "صوت تحويل النص إلى كلام", + "placeholder": "اختر صوتاً" + }, + "ssmlEnabled": { + "label": "تمكين SSML (لغة ترميز توليف الكلام)" + } + } + }, + "manageModels": { + "title": "إدارة النماذج", + "addBtn": "إضافة نموذج جديد", + "columns": { + "name": "الاسم", + "digest": "الملخص", + "modifiedAt": "تم التعديل في", + "size": "الحجم", + "actions": "الإجراءات" + }, + "expandedColumns": { + "parentModel": "النموذج الأصلي", + "format": "التنسيق", + "family": "العائلة", + "parameterSize": "حجم المعلمة", + "quantizationLevel": "مستوى التكميم" + }, + "tooltip": { + "delete": "حذف النموذج", + "repull": "إعادة سحب النموذج" + }, + "confirm": { + "delete": "هل أنت متأكد أنك تريد حذف هذا النموذج؟", + "repull": "هل أنت متأكد أنك تريد إعادة سحب هذا النموذج؟" + }, + "modal": { + "title": "إضافة نموذج جديد", + "placeholder": "أدخل اسم النموذج", + "pull": "سحب النموذج" + }, + "notification": { + "pullModel": "جاري سحب النموذج", + "pullModelDescription": "جاري سحب نموذج {{modelName}}. لمزيد من التفاصيل، تحقق من أيقونة الإضافة.", + "success": "نجاح", + "error": "خطأ", + "successDescription": "تم سحب النموذج بنجاح", + "successDeleteDescription": "تم حذف النموذج بنجاح", + "someError": "حدث خطأ ما. يرجى المحاولة مرة أخرى لاحقاً" + } + }, + "managePrompts": { + "title": "إدارة الإرشادات", + "addBtn": "إضافة إرشاد جديد", + "option1": "عادي", + "option2": "RAG", + "questionPrompt": "إرشاد السؤال", + "segmented": { + "custom": "إرشادات مخصصة", + "copilot": "إرشادات كوبيلوت" + }, + "columns": { + "title": "العنوان", + "prompt": "الإرشاد", + "type": "نوع الإرشاد", + "actions": "الإجراءات" + }, + "systemPrompt": "إرشاد النظام", + "quickPrompt": "إرشاد سريع", + "tooltip": { + "delete": "حذف الإرشاد", + "edit": "تعديل الإرشاد" + }, + "confirm": { + "delete": "هل أنت متأكد أنك تريد حذف هذا الإرشاد؟ لا يمكن التراجع عن هذا الإجراء." + }, + "modal": { + "addTitle": "إضافة إرشاد جديد", + "editTitle": "تعديل الإرشاد" + }, + "form": { + "title": { + "label": "العنوان", + "placeholder": "إرشادي الرائع", + "required": "الرجاء إدخال عنوان" + }, + "prompt": { + "label": "الإرشاد", + "placeholder": "أدخل الإرشاد", + "required": "الرجاء إدخال إرشاد", + "help": "يمكنك استخدام {key} كمتغير في إرشادك.", + "missingTextPlaceholder": "المتغير {text} مفقود في الإرشاد. الرجاء إضافته." + }, + "isSystem": { + "label": "إرشاد نظام" + }, + "btnSave": { + "saving": "جاري إضافة الإرشاد...", + "save": "إضافة الإرشاد" + }, + "btnEdit": { + "saving": "جاري تحديث الإرشاد...", + "save": "تحديث الإرشاد" + } + }, + "notification": { + "addSuccess": "تمت إضافة الإرشاد", + "addSuccessDesc": "تمت إضافة الإرشاد بنجاح", + "error": "خطأ", + "someError": "حدث خطأ ما. يرجى المحاولة مرة أخرى لاحقاً", + "updatedSuccess": "تم تحديث الإرشاد", + "updatedSuccessDesc": "تم تحديث الإرشاد بنجاح", + "deletedSuccess": "تم حذف الإرشاد", + "deletedSuccessDesc": "تم حذف الإرشاد بنجاح" + } + }, + "manageShare": { + "title": "إدارة المشاركة", + "heading": "تكوين رابط مشاركة الصفحة", + "form": { + "url": { + "label": "رابط مشاركة الصفحة", + "placeholder": "أدخل رابط مشاركة الصفحة", + "required": "الرجاء إدخال رابط مشاركة الصفحة!", + "help": "لأسباب تتعلق بالخصوصية، يمكنك استضافة مشاركة الصفحة ذاتياً وتوفير الرابط هنا. تعلم المزيد." + } + }, + "webshare": { + "heading": "مشاركة الويب", + "columns": { + "title": "العنوان", + "url": "الرابط", + "actions": "الإجراءات" + }, + "tooltip": { + "delete": "حذف المشاركة" + }, + "confirm": { + "delete": "هل أنت متأكد أنك تريد حذف هذه المشاركة؟ لا يمكن التراجع عن هذا الإجراء." + }, + "label": "إدارة مشاركة الصفحة", + "description": "تمكين أو تعطيل ميزة مشاركة الصفحة" + }, + "notification": { + "pageShareSuccess": "تم تحديث رابط مشاركة الصفحة بنجاح", + "someError": "حدث خطأ ما. يرجى المحاولة مرة أخرى لاحقاً", + "webShareDeleteSuccess": "تم حذف مشاركة الويب بنجاح" + } + }, + "ollamaSettings": { + "title": "إعدادات Ollama", + "heading": "تكوين Ollama", + "settings": { + "ollamaUrl": { + "label": "رابط Ollama", + "placeholder": "أدخل رابط Ollama" + }, + "advanced": { + "label": "تكوين رابط Ollama المتقدم", + "urlRewriteEnabled": { + "label": "تمكين أو تعطيل رابط المصدر المخصص" + }, + "rewriteUrl": { + "label": "رابط المصدر المخصص", + "placeholder": "أدخل رابط المصدر المخصص" + }, + "headers": { + "label": "الترويسات المخصصة", + "add": "إضافة ترويسة", + "key": { + "label": "مفتاح الترويسة", + "placeholder": "التفويض" + }, + "value": { + "label": "قيمة الترويسة", + "placeholder": "رمز Bearer" + } + }, + "help": "إذا كنت تواجه مشاكل في الاتصال مع Ollama في مساعد الصفحة، يمكنك تكوين رابط مصدر مخصص. لمعرفة المزيد حول التكوين، انقر هنا." + } + } + }, + "manageSearch": { + "title": "إدارة البحث في الويب", + "heading": "تكوين البحث في الويب" + }, + "about": { + "title": "حول", + "heading": "حول", + "chromeVersion": "إصدار مساعد الصفحة", + "ollamaVersion": "إصدار Ollama", + "support": "يمكنك دعم مشروع مساعد الصفحة من خلال التبرع أو الرعاية عبر المنصات التالية:", + "koFi": "ادعم على Ko-fi", + "githubSponsor": "كن راعياً على GitHub", + "githubRepo": "مستودع GitHub" + }, + "manageKnowledge": { + "title": "إدارة المعرفة", + "heading": "تكوين قاعدة المعرفة" + }, + "rag": { + "title": "إعدادات RAG", + "ragSettings": { + "label": "إعدادات RAG", + "model": { + "label": "نموذج التضمين", + "required": "الرجاء اختيار نموذج", + "help": "يوصى بشدة باستخدام نماذج التضمين مثل `nomic-embed-text`.", + "placeholder": "اختر نموذجاً" + }, + "chunkSize": { + "label": "حجم القطعة", + "placeholder": "أدخل حجم القطعة", + "required": "الرجاء إدخال حجم القطعة" + }, + "chunkOverlap": { + "label": "تداخل القطع", + "placeholder": "أدخل تداخل القطع", + "required": "الرجاء إدخال تداخل القطع" + }, + "totalFilePerKB": { + "label": "حد رفع الملفات الافتراضي لقاعدة المعرفة", + "placeholder": "أدخل حد رفع الملفات الافتراضي (مثال: 10)", + "required": "الرجاء إدخال حد رفع الملفات الافتراضي" + }, + "noOfRetrievedDocs": { + "label": "عدد المستندات المسترجعة", + "placeholder": "أدخل عدد المستندات المسترجعة", + "required": "الرجاء إدخال عدد المستندات المسترجعة" + } + }, + "prompt": { + "label": "تكوين إرشاد RAG", + "option1": "عادي", + "option2": "ويب", + "alert": "تكوين إرشاد النظام هنا مهمل. يرجى استخدام قسم إدارة الإرشادات لإضافة أو تعديل الإرشادات. سيتم إزالة هذا القسم في إصدار مستقبلي", + "systemPrompt": "إرشاد النظام", + "systemPromptPlaceholder": "أدخل إرشاد النظام", + "webSearchPrompt": "إرشاد بحث الويب", + "webSearchPromptHelp": "لا تقم بإزالة `{search_results}` من الإرشاد.", + "webSearchPromptError": "الرجاء إدخال إرشاد بحث الويب", + "webSearchPromptPlaceholder": "أدخل إرشاد بحث الويب", + "webSearchFollowUpPrompt": "إرشاد متابعة بحث الويب", + "webSearchFollowUpPromptHelp": "لا تقم بإزالة `{chat_history}` و `{question}` من الإرشاد.", + "webSearchFollowUpPromptError": "الرجاء إدخال إرشاد متابعة بحث الويب!", + "webSearchFollowUpPromptPlaceholder": "إرشاد متابعة بحث الويب الخاص بك" + } + }, + "chromeAiSettings": { + "title": "إعدادات Chrome AI" + }} diff --git a/src/assets/locale/ar/sidepanel.json b/src/assets/locale/ar/sidepanel.json new file mode 100644 index 0000000..2db6314 --- /dev/null +++ b/src/assets/locale/ar/sidepanel.json @@ -0,0 +1,7 @@ +{ + "tooltip": { + "embed": "قد يستغرق تضمين الصفحة بضع دقائق. يرجى الانتظار...", + "clear": "مسح سجل المحادثة", + "history": "سجل المحادثة" + } +} \ No newline at end of file diff --git a/src/assets/locale/da/playground.json b/src/assets/locale/da/playground.json index 8fdcd54..875a654 100644 --- a/src/assets/locale/da/playground.json +++ b/src/assets/locale/da/playground.json @@ -26,5 +26,6 @@ "knowledge": "Viden" }, "sendWhenEnter": "Søg, når Indtast trykkes", - "welcome": "Hej! Hvordan kan jeg hjælpe dig i dag?" + "welcome": "Hej! Hvordan kan jeg hjælpe dig i dag?", + "useOCR": "Udtræk tekst fra billede (OCR)" } \ No newline at end of file diff --git a/src/assets/locale/de/playground.json b/src/assets/locale/de/playground.json index 43eafb9..251c299 100644 --- a/src/assets/locale/de/playground.json +++ b/src/assets/locale/de/playground.json @@ -26,5 +26,6 @@ "knowledge": "Wissen" }, "sendWhenEnter": "Senden bei Drücken der Eingabetaste", - "welcome": "Hallo! Wie kann ich Ihnen heute helfen?" + "welcome": "Hallo! Wie kann ich Ihnen heute helfen?", + "useOCR": "Text aus Bild extrahieren (OCR)" } \ No newline at end of file diff --git a/src/assets/locale/en/common.json b/src/assets/locale/en/common.json index 88c1be5..b00e03e 100644 --- a/src/assets/locale/en/common.json +++ b/src/assets/locale/en/common.json @@ -60,11 +60,11 @@ "keepAlive": { "label": "Keep Alive", "help": "controls how long the model will stay loaded into memory following the request (default: 5m)", - "placeholder": "Enter Keep Alive duration (e.g. 5m, 10m, 1h)" + "placeholder": "e.g. 5m, 10m, 1h" }, "temperature": { "label": "Temperature", - "placeholder": "Enter Temperature value (e.g. 0.7, 1.0)" + "placeholder": "e.g. 0.7, 1.0" }, "numCtx": { "label": "Number of Contexts", @@ -72,24 +72,36 @@ }, "numPredict": { "label": "Max Tokens (num_predict)", - "placeholder": "Enter Max Tokens value (e.g. 2048, 4096)" + "placeholder": "e.g. 2048, 4096" }, "seed": { "label": "Seed", - "placeholder": "Enter Seed value (e.g. 1234)", + "placeholder": "e.g. 1234", "help": "Reproducibility of the model output" }, "topK": { "label": "Top K", - "placeholder": "Enter Top K value (e.g. 40, 100)" + "placeholder": "e.g. 40, 100" }, "topP": { "label": "Top P", - "placeholder": "Enter Top P value (e.g. 0.9, 0.95)" + "placeholder": "e.g. 0.9, 0.95" }, "useMMap": { "label": "useMmap" }, + "minP": { + "label": "Min P", + "placeholder": "e.g. 0.05" + }, + "repeatPenalty": { + "label": "Repeat Penalty", + "placeholder": "e.g. 1.1, 1.2" + }, + "repeatLastN": { + "label": "Repeat Last N", + "placeholder": "e.g. 64, 128" + }, "numGpu": { "label": "Num GPU", "placeholder": "Enter number of layers to send to GPU(s)" @@ -125,4 +137,4 @@ "pin": "Pin", "unpin": "Unpin", "generationInfo": "Generation Info" -} +} \ No newline at end of file diff --git a/src/assets/locale/en/playground.json b/src/assets/locale/en/playground.json index c4f5f5c..d673f04 100644 --- a/src/assets/locale/en/playground.json +++ b/src/assets/locale/en/playground.json @@ -27,5 +27,6 @@ "vision": "[Experimental] Vision Chat" }, "sendWhenEnter": "Send when Enter pressed", - "welcome": "Hello! How can I help you today?" + "welcome": "Hello! How can I help you today?", + "useOCR": "Extract text from image (OCR)" } \ No newline at end of file diff --git a/src/assets/locale/en/settings.json b/src/assets/locale/en/settings.json index 20eb45c..3f6af27 100644 --- a/src/assets/locale/en/settings.json +++ b/src/assets/locale/en/settings.json @@ -113,6 +113,9 @@ }, "ssmlEnabled": { "label": "Enable SSML (Speech Synthesis Markup Language)" + }, + "responseSplitting": { + "label": "Response Splitting" } } }, diff --git a/src/assets/locale/es/playground.json b/src/assets/locale/es/playground.json index 2e16639..3c11c27 100644 --- a/src/assets/locale/es/playground.json +++ b/src/assets/locale/es/playground.json @@ -26,5 +26,6 @@ "knowledge": "Conocimiento" }, "sendWhenEnter": "Enviar cuando presione Enter", - "welcome": "¡Hola! ¿Cómo puedo ayudarte hoy?" + "welcome": "¡Hola! ¿Cómo puedo ayudarte hoy?", + "useOCR": "Extraer texto de imagen (OCR)" } diff --git a/src/assets/locale/fa/playground.json b/src/assets/locale/fa/playground.json index 3732e7f..91c0366 100644 --- a/src/assets/locale/fa/playground.json +++ b/src/assets/locale/fa/playground.json @@ -26,5 +26,6 @@ "knowledge": "دانش" }, "sendWhenEnter": "با فشار دادن Enter ارسال شود", - "welcome": "سلام! امروز چطور می‌توانم به شما کمک کنم؟" + "welcome": "سلام! امروز چطور می‌توانم به شما کمک کنم؟", + "useOCR": "استخراج متن از تصویر (OCR)" } diff --git a/src/assets/locale/fr/playground.json b/src/assets/locale/fr/playground.json index e81c542..c2f7d83 100644 --- a/src/assets/locale/fr/playground.json +++ b/src/assets/locale/fr/playground.json @@ -26,5 +26,6 @@ "knowledge": "Connaissance" }, "sendWhenEnter": "Envoyer en appuyant sur Entrée", - "welcome": "Bonjour ! Comment puis-je vous aider aujourd'hui ?" + "welcome": "Bonjour ! Comment puis-je vous aider aujourd'hui ?", + "useOCR": "Extraire le texte de l'image (OCR)" } \ No newline at end of file diff --git a/src/assets/locale/it/playground.json b/src/assets/locale/it/playground.json index c43cf87..2c902f0 100644 --- a/src/assets/locale/it/playground.json +++ b/src/assets/locale/it/playground.json @@ -26,5 +26,6 @@ "knowledge": "Conoscenza" }, "sendWhenEnter": "Invia subito dopo Enter", - "welcome": "Ciao! Come posso aiutarti oggi?" + "welcome": "Ciao! Come posso aiutarti oggi?", + "useOCR": "Estrai testo dall'immagine (OCR)" } \ No newline at end of file diff --git a/src/assets/locale/ja-JP/playground.json b/src/assets/locale/ja-JP/playground.json index f89911c..49ba31b 100644 --- a/src/assets/locale/ja-JP/playground.json +++ b/src/assets/locale/ja-JP/playground.json @@ -26,5 +26,6 @@ "knowledge": "知識" }, "sendWhenEnter": "Enterキーを押すと送信", - "welcome": "こんにちは!本日はどのようなお手伝いができますか?" + "welcome": "こんにちは!本日はどのようなお手伝いができますか?", + "useOCR": "画像からテキストを抽出(OCR)" } \ No newline at end of file diff --git a/src/assets/locale/ko/playground.json b/src/assets/locale/ko/playground.json index d60b102..caa29f9 100644 --- a/src/assets/locale/ko/playground.json +++ b/src/assets/locale/ko/playground.json @@ -26,5 +26,6 @@ "knowledge": "지식" }, "sendWhenEnter": "Enter 키를 누르면 전송", - "welcome": "안녕하세요! 오늘 어떻게 도와드릴까요?" + "welcome": "안녕하세요! 오늘 어떻게 도와드릴까요?", + "useOCR": "이미지에서 텍스트 추출 (OCR)" } diff --git a/src/assets/locale/ml/playground.json b/src/assets/locale/ml/playground.json index e789350..a6a216c 100644 --- a/src/assets/locale/ml/playground.json +++ b/src/assets/locale/ml/playground.json @@ -26,5 +26,6 @@ "knowledge": "അറിവ്" }, "sendWhenEnter": "എന്റര്‍ അമര്‍ത്തുമ്പോള്‍ അയയ്ക്കുക", - "welcome": "നമസ്കാരം! ഇന്ന് എനിക്ക് നിങ്ങളെ എങ്ങനെ സഹായിക്കാൻ കഴിയും?" + "welcome": "നമസ്കാരം! ഇന്ന് എനിക്ക് നിങ്ങളെ എങ്ങനെ സഹായിക്കാൻ കഴിയും?", + "useOCR": "ചിത്രത്തിൽ നിന്ന് ടെക്സ്റ്റ് എടുക്കുക (OCR)" } \ No newline at end of file diff --git a/src/assets/locale/no/playground.json b/src/assets/locale/no/playground.json index 43e2fa3..0814c3f 100644 --- a/src/assets/locale/no/playground.json +++ b/src/assets/locale/no/playground.json @@ -26,5 +26,6 @@ "knowledge": "Kunnskap" }, "sendWhenEnter": "Søk når Enter trykkes", - "welcome": "Hei! Hvordan kan jeg hjelpe deg i dag?" + "welcome": "Hei! Hvordan kan jeg hjelpe deg i dag?", + "useOCR": "Trekk ut tekst fra bilde (OCR)" } diff --git a/src/assets/locale/pt-BR/playground.json b/src/assets/locale/pt-BR/playground.json index ea11ffa..efad16f 100644 --- a/src/assets/locale/pt-BR/playground.json +++ b/src/assets/locale/pt-BR/playground.json @@ -26,5 +26,6 @@ "knowledge": "Conhecimento" }, "sendWhenEnter": "Enviar ao pressionar Enter", - "welcome": "Olá! Como posso ajudar você hoje?" + "welcome": "Olá! Como posso ajudar você hoje?", + "useOCR": "Extrair texto da imagem (OCR)" } \ No newline at end of file diff --git a/src/assets/locale/ru/playground.json b/src/assets/locale/ru/playground.json index 39ba724..5cda9a7 100644 --- a/src/assets/locale/ru/playground.json +++ b/src/assets/locale/ru/playground.json @@ -26,5 +26,6 @@ "knowledge": "Знание" }, "sendWhenEnter": "Отправить при нажатии клавиши Enter", - "welcome": "Здравствуйте! Как я могу помочь вам сегодня?" + "welcome": "Здравствуйте! Как я могу помочь вам сегодня?", + "useOCR": "Извлечь текст из изображения (OCR)" } diff --git a/src/assets/locale/sv/playground.json b/src/assets/locale/sv/playground.json index 16c8e80..a88def8 100644 --- a/src/assets/locale/sv/playground.json +++ b/src/assets/locale/sv/playground.json @@ -26,5 +26,6 @@ "knowledge": "Kunskap" }, "sendWhenEnter": "Skicka när Enter trycks", - "welcome": "Hej! Hur kan jag hjälpa dig idag?" + "welcome": "Hej! Hur kan jag hjälpa dig idag?", + "useOCR": "Extrahera text från bild (OCR)" } diff --git a/src/assets/locale/uk/playground.json b/src/assets/locale/uk/playground.json index 29e244d..0d88ac0 100644 --- a/src/assets/locale/uk/playground.json +++ b/src/assets/locale/uk/playground.json @@ -26,5 +26,6 @@ "knowledge": "Знання" }, "sendWhenEnter": "Надсилати при натисканні Enter", - "welcome": "Вітаю! Як я можу допомогти вам сьогодні?" + "welcome": "Вітаю! Як я можу допомогти вам сьогодні?", + "useOCR": "Витягти текст із зображення (OCR)" } \ No newline at end of file diff --git a/src/assets/locale/zh/playground.json b/src/assets/locale/zh/playground.json index 2b99e39..08c0863 100644 --- a/src/assets/locale/zh/playground.json +++ b/src/assets/locale/zh/playground.json @@ -26,5 +26,6 @@ "knowledge": "知识" }, "sendWhenEnter": "按Enter发送", - "welcome": "你好!今天我能帮你什么?" + "welcome": "你好!今天我能帮你什么?", + "useOCR": "从图片中提取文字(OCR)" } \ No newline at end of file diff --git a/src/components/Common/Settings/CurrentChatModelSettings.tsx b/src/components/Common/Settings/CurrentChatModelSettings.tsx index b1218b4..57a6926 100644 --- a/src/components/Common/Settings/CurrentChatModelSettings.tsx +++ b/src/components/Common/Settings/CurrentChatModelSettings.tsx @@ -76,7 +76,10 @@ export const CurrentChatModelSettings = ({ numGpu: cUserSettings.numGpu ?? data.numGpu, numPredict: cUserSettings.numPredict ?? data.numPredict, systemPrompt: cUserSettings.systemPrompt ?? tempSystemPrompt, - useMMap: cUserSettings.useMMap ?? data.useMMap + useMMap: cUserSettings.useMMap ?? data.useMMap, + minP: cUserSettings.minP ?? data.minP, + repeatLastN: cUserSettings.repeatLastN ?? data.repeatLastN, + repeatPenalty: cUserSettings.repeatPenalty ?? data.repeatPenalty }) return data }, @@ -199,6 +202,34 @@ export const CurrentChatModelSettings = ({ /> + + + + + + + + + @@ -209,7 +240,10 @@ export const CurrentChatModelSettings = ({ } ]} /> - + ) : ( diff --git a/src/components/Layouts/Header.tsx b/src/components/Layouts/Header.tsx index 0001ab7..4f4da36 100644 --- a/src/components/Layouts/Header.tsx +++ b/src/components/Layouts/Header.tsx @@ -2,11 +2,11 @@ import { useStorage } from "@plasmohq/storage/hook" import { BrainCog, ChevronLeft, + ChevronRight, CogIcon, ComputerIcon, GithubIcon, PanelLeftIcon, - SquarePen, ZapIcon } from "lucide-react" import { useTranslation } from "react-i18next" @@ -32,7 +32,9 @@ export const Header: React.FC = ({ setOpenModelSettings, setSidebarOpen }) => { - const { t } = useTranslation(["option", "common"]) + const { t, i18n } = useTranslation(["option", "common"]) + const isRTL = i18n?.dir() === "rtl" + const [shareModeEnabled] = useStorage("shareMode", false) const [hideCurrentChatModelSettings] = useStorage( "hideCurrentChatModelSettings", @@ -98,7 +100,11 @@ export const Header: React.FC = ({ - + {isRTL ? ( + + ) : ( + + )} )} diff --git a/src/components/Option/Playground/PlaygroundForm.tsx b/src/components/Option/Playground/PlaygroundForm.tsx index 00eef04..c6e2b40 100644 --- a/src/components/Option/Playground/PlaygroundForm.tsx +++ b/src/components/Option/Playground/PlaygroundForm.tsx @@ -37,7 +37,9 @@ export const PlaygroundForm = ({ dropedFile }: Props) => { textareaRef, setSelectedQuickPrompt, selectedKnowledge, - temporaryChat + temporaryChat, + useOCR, + setUseOCR } = useMessageOption() const isMobile = () => { @@ -375,6 +377,16 @@ export const PlaygroundForm = ({ dropedFile }: Props) => { {t("sendWhenEnter")} ) + }, + { + key: 2, + label: ( + setUseOCR(e.target.checked)}> + {t("useOCR")} + + ) } ] }}> diff --git a/src/components/Option/Settings/model-settings.tsx b/src/components/Option/Settings/model-settings.tsx index 18015ba..43753eb 100644 --- a/src/components/Option/Settings/model-settings.tsx +++ b/src/components/Option/Settings/model-settings.tsx @@ -122,6 +122,34 @@ export const ModelSettings = () => { placeholder={t("modelSettings.form.numGpu.placeholder")} /> + + + + + + + + + diff --git a/src/components/Option/Settings/tts-mode.tsx b/src/components/Option/Settings/tts-mode.tsx index 7360419..2de6be3 100644 --- a/src/components/Option/Settings/tts-mode.tsx +++ b/src/components/Option/Settings/tts-mode.tsx @@ -1,9 +1,10 @@ import { SaveButton } from "@/components/Common/SaveButton" +import { getModels, getVoices } from "@/services/elevenlabs" import { getTTSSettings, setTTSSettings } from "@/services/tts" import { useWebUI } from "@/store/webui" import { useForm } from "@mantine/form" import { useQuery } from "@tanstack/react-query" -import { Select, Skeleton, Switch } from "antd" +import { Input, message, Select, Skeleton, Switch } from "antd" import { useTranslation } from "react-i18next" export const TTSModeSettings = ({ hideBorder }: { hideBorder?: boolean }) => { @@ -15,7 +16,11 @@ export const TTSModeSettings = ({ hideBorder }: { hideBorder?: boolean }) => { ttsEnabled: false, ttsProvider: "", voice: "", - ssmlEnabled: false + ssmlEnabled: false, + elevenLabsApiKey: "", + elevenLabsVoiceId: "", + elevenLabsModel: "", + responseSplitting: "" } }) @@ -28,6 +33,27 @@ export const TTSModeSettings = ({ hideBorder }: { hideBorder?: boolean }) => { } }) + const { data: elevenLabsData } = useQuery({ + queryKey: ["fetchElevenLabsData", form.values.elevenLabsApiKey], + queryFn: async () => { + try { + if ( + form.values.ttsProvider === "elevenlabs" && + form.values.elevenLabsApiKey + ) { + const voices = await getVoices(form.values.elevenLabsApiKey) + const models = await getModels(form.values.elevenLabsApiKey) + return { voices, models } + } + } catch (e) { + console.log(e) + message.error("Error fetching ElevenLabs data") + } + return null + }, + enabled: + form.values.ttsProvider === "elevenlabs" && !!form.values.elevenLabsApiKey + }) if (status === "pending" || status === "error") { return } @@ -72,29 +98,103 @@ export const TTSModeSettings = ({ hideBorder }: { hideBorder?: boolean }) => { ({ + {form.values.ttsProvider === "browser" && ( +
+ + {t("generalSettings.tts.ttsVoice.label")} + +
+ ({ + label: v.name, + value: v.voice_id + }))} + className="w-full mt-4 sm:mt-0 sm:w-[200px]" + placeholder="Select a voice" + {...form.getInputProps("elevenLabsVoiceId")} + /> +
+ +
+ + TTS Model + + +
+
+ + )} + + )}
{t("generalSettings.tts.ssmlEnabled.label")} diff --git a/src/components/Select/index.tsx b/src/components/Select/index.tsx index 34d205f..01a7c5e 100644 --- a/src/components/Select/index.tsx +++ b/src/components/Select/index.tsx @@ -73,6 +73,7 @@ export const PageAssistSelect: React.FC = ({ } catch (error) { console.error("Error scrolling to selected option:", error) } + }, [isOpen, value]) useEffect(() => { diff --git a/src/components/Sidepanel/Chat/form.tsx b/src/components/Sidepanel/Chat/form.tsx index a402680..3b39164 100644 --- a/src/components/Sidepanel/Chat/form.tsx +++ b/src/components/Sidepanel/Chat/form.tsx @@ -131,7 +131,9 @@ export const SidepanelForm = ({ dropedFile }: Props) => { setWebSearch, selectedQuickPrompt, setSelectedQuickPrompt, - speechToTextLanguage + speechToTextLanguage, + useOCR, + setUseOCR } = useMessage() React.useEffect(() => { @@ -414,6 +416,16 @@ export const SidepanelForm = ({ dropedFile }: Props) => { {t("common:chatWithCurrentPage")} ) + }, + { + key: 3, + label: ( + setUseOCR(e.target.checked)}> + {t("useOCR")} + + ) } ] }}> diff --git a/src/components/Sidepanel/Settings/header.tsx b/src/components/Sidepanel/Settings/header.tsx index 9f714d8..0919926 100644 --- a/src/components/Sidepanel/Settings/header.tsx +++ b/src/components/Sidepanel/Settings/header.tsx @@ -1,14 +1,22 @@ -import { ChevronLeft } from "lucide-react" +import { ChevronLeft, ChevronRight } from "lucide-react" import { useTranslation } from "react-i18next" import { Link } from "react-router-dom" import logoImage from "~/assets/icon.png" export const SidepanelSettingsHeader = () => { - const { t } = useTranslation("common") + const { t , i18n} = useTranslation("common") + const isRTL = i18n?.dir() === "rtl" + return (
- + { + isRTL ? ( + + ) : ( + + ) + }
{t("pageAssist")} diff --git a/src/entries-firefox/background.ts b/src/entries-firefox/background.ts new file mode 100644 index 0000000..9a9bcd5 --- /dev/null +++ b/src/entries-firefox/background.ts @@ -0,0 +1,267 @@ +import { getOllamaURL, isOllamaRunning } from "../services/ollama" +import { browser } from "wxt/browser" +import { clearBadge, streamDownload } from "@/utils/pull-ollama" + +export default defineBackground({ + main() { + let isCopilotRunning: boolean = false + browser.runtime.onMessage.addListener(async (message) => { + if (message.type === "sidepanel") { + await browser.sidebarAction.open() + } else if (message.type === "pull_model") { + const ollamaURL = await getOllamaURL() + + const isRunning = await isOllamaRunning() + + if (!isRunning) { + setBadgeText({ text: "E" }) + setBadgeBackgroundColor({ color: "#FF0000" }) + setTitle({ title: "Ollama is not running" }) + setTimeout(() => { + clearBadge() + }, 5000) + } + + await streamDownload(ollamaURL, message.modelName) + } + }) + + browser.runtime.onConnect.addListener((port) => { + if (port.name === "pgCopilot") { + isCopilotRunning = true + port.onDisconnect.addListener(() => { + isCopilotRunning = false + }) + } + }) + + if (import.meta.env.BROWSER === "chrome") { + chrome.action.onClicked.addListener((tab) => { + chrome.tabs.create({ url: chrome.runtime.getURL("/options.html") }) + }) + } else { + browser.browserAction.onClicked.addListener((tab) => { + console.log("browser.browserAction.onClicked.addListener") + browser.tabs.create({ url: browser.runtime.getURL("/options.html") }) + }) + } + + const contextMenuTitle = { + webUi: browser.i18n.getMessage("openOptionToChat"), + sidePanel: browser.i18n.getMessage("openSidePanelToChat") + } + + const contextMenuId = { + webUi: "open-web-ui-pa", + sidePanel: "open-side-panel-pa" + } + + browser.contextMenus.create({ + id: contextMenuId["sidePanel"], + title: contextMenuTitle["sidePanel"], + contexts: ["page", "selection"] + }) + + browser.contextMenus.create({ + id: "summarize-pa", + title: browser.i18n.getMessage("contextSummarize"), + contexts: ["selection"] + }) + + browser.contextMenus.create({ + id: "explain-pa", + title: browser.i18n.getMessage("contextExplain"), + contexts: ["selection"] + }) + + browser.contextMenus.create({ + id: "rephrase-pa", + title: browser.i18n.getMessage("contextRephrase"), + contexts: ["selection"] + }) + + browser.contextMenus.create({ + id: "translate-pg", + title: browser.i18n.getMessage("contextTranslate"), + contexts: ["selection"] + }) + + browser.contextMenus.create({ + id: "custom-pg", + title: browser.i18n.getMessage("contextCustom"), + contexts: ["selection"] + }) + + if (import.meta.env.BROWSER === "chrome") { + browser.contextMenus.onClicked.addListener(async (info, tab) => { + if (info.menuItemId === "open-side-panel-pa") { + chrome.sidePanel.open({ + tabId: tab.id! + }) + } else if (info.menuItemId === "open-web-ui-pa") { + browser.tabs.create({ + url: browser.runtime.getURL("/options.html") + }) + } else if (info.menuItemId === "summarize-pa") { + chrome.sidePanel.open({ + tabId: tab.id! + }) + // this is a bad method hope somone can fix it :) + setTimeout(async () => { + await browser.runtime.sendMessage({ + from: "background", + type: "summary", + text: info.selectionText + }) + }, isCopilotRunning ? 0 : 5000) + + } else if (info.menuItemId === "rephrase-pa") { + chrome.sidePanel.open({ + tabId: tab.id! + }) + setTimeout(async () => { + + await browser.runtime.sendMessage({ + type: "rephrase", + from: "background", + text: info.selectionText + }) + }, isCopilotRunning ? 0 : 5000) + + } else if (info.menuItemId === "translate-pg") { + chrome.sidePanel.open({ + tabId: tab.id! + }) + + setTimeout(async () => { + await browser.runtime.sendMessage({ + type: "translate", + from: "background", + text: info.selectionText + }) + }, isCopilotRunning ? 0 : 5000) + } else if (info.menuItemId === "explain-pa") { + chrome.sidePanel.open({ + tabId: tab.id! + }) + + setTimeout(async () => { + await browser.runtime.sendMessage({ + type: "explain", + from: "background", + text: info.selectionText + }) + }, isCopilotRunning ? 0 : 5000) + } else if (info.menuItemId === "custom-pg") { + chrome.sidePanel.open({ + tabId: tab.id! + }) + + setTimeout(async () => { + await browser.runtime.sendMessage({ + type: "custom", + from: "background", + text: info.selectionText + }) + }, isCopilotRunning ? 0 : 5000) + } + }) + + browser.commands.onCommand.addListener((command) => { + switch (command) { + case "execute_side_panel": + chrome.tabs.query( + { active: true, currentWindow: true }, + async (tabs) => { + const tab = tabs[0] + chrome.sidePanel.open({ + tabId: tab.id! + }) + } + ) + break + default: + break + } + }) + } + + if (import.meta.env.BROWSER === "firefox") { + browser.contextMenus.onClicked.addListener((info, tab) => { + if (info.menuItemId === "open-side-panel-pa") { + browser.sidebarAction.toggle() + } else if (info.menuItemId === "open-web-ui-pa") { + browser.tabs.create({ + url: browser.runtime.getURL("/options.html") + }) + } else if (info.menuItemId === "summarize-pa") { + if (!isCopilotRunning) { + browser.sidebarAction.toggle() + } + setTimeout(async () => { + await browser.runtime.sendMessage({ + from: "background", + type: "summary", + text: info.selectionText + }) + }, isCopilotRunning ? 0 : 5000) + } else if (info.menuItemId === "rephrase-pa") { + if (!isCopilotRunning) { + browser.sidebarAction.toggle() + } + setTimeout(async () => { + await browser.runtime.sendMessage({ + type: "rephrase", + from: "background", + text: info.selectionText + }) + }, isCopilotRunning ? 0 : 5000) + } else if (info.menuItemId === "translate-pg") { + if (!isCopilotRunning) { + browser.sidebarAction.toggle() + } + setTimeout(async () => { + await browser.runtime.sendMessage({ + type: "translate", + from: "background", + text: info.selectionText + }) + }, isCopilotRunning ? 0 : 5000) + } else if (info.menuItemId === "explain-pa") { + if (!isCopilotRunning) { + browser.sidebarAction.toggle() + } + setTimeout(async () => { + await browser.runtime.sendMessage({ + type: "explain", + from: "background", + text: info.selectionText + }) + }, isCopilotRunning ? 0 : 5000) + } else if (info.menuItemId === "custom-pg") { + if (!isCopilotRunning) { + browser.sidebarAction.toggle() + } + setTimeout(async () => { + await browser.runtime.sendMessage({ + type: "custom", + from: "background", + text: info.selectionText + }) + }, isCopilotRunning ? 0 : 5000) + } + }) + + browser.commands.onCommand.addListener((command) => { + switch (command) { + case "execute_side_panel": + browser.sidebarAction.toggle() + break + default: + break + } + }) + } + }, + persistent: true +}) diff --git a/src/entries-firefox/hf-pull.content.ts b/src/entries-firefox/hf-pull.content.ts new file mode 100644 index 0000000..ac44737 --- /dev/null +++ b/src/entries-firefox/hf-pull.content.ts @@ -0,0 +1,95 @@ +export default defineContentScript({ + main(ctx) { + const downloadModel = async (modelName: string) => { + const ok = confirm( + `[Page Assist Extension] Do you want to pull the ${modelName} model? This has nothing to do with the huggingface.co website. The model will be pulled locally once you confirm. Make sure Ollama is running.` + ) + if (ok) { + alert( + `[Page Assist Extension] Pulling ${modelName} model. For more details, check the extension icon.` + ) + + await browser.runtime.sendMessage({ + type: "pull_model", + modelName + }) + return true + } + return false + } + + const downloadSVG = ` + + + + + ` + + const injectDownloadButton = (modal: HTMLElement) => { + const copyButton = modal.querySelector( + 'button[title="Copy snippet to clipboard"]' + ) + if (copyButton && !modal.querySelector(".pageassist-download-button")) { + const downloadButton = copyButton.cloneNode(true) as HTMLElement + downloadButton.classList.add("pageassist-download-button") + downloadButton.querySelector("svg")!.outerHTML = downloadSVG + downloadButton.querySelector("span")!.textContent = + "Pull from Page Assist" + downloadButton.addEventListener("click", async () => { + const preElement = modal.querySelector("pre") + if (preElement) { + let modelCommand = "" + preElement.childNodes.forEach((node) => { + if (node.nodeType === Node.TEXT_NODE) { + modelCommand += node.textContent + } else if (node instanceof HTMLSelectElement) { + modelCommand += node.value + } else if (node instanceof HTMLElement) { + const selectElement = node.querySelector( + "select" + ) as HTMLSelectElement + if (selectElement) { + modelCommand += selectElement.value + } else { + modelCommand += node.textContent + } + } + }) + + modelCommand = modelCommand.trim() + + await downloadModel( + modelCommand + ?.replaceAll("ollama run", "") + ?.replaceAll("ollama pull", "") + ?.trim() + ) + } + }) + const buttonContainer = document.createElement('div') + buttonContainer.classList.add("mb-3") + buttonContainer.style.display = 'flex' + buttonContainer.style.justifyContent = 'flex-end' + buttonContainer.appendChild(downloadButton) + modal.querySelector("pre")!.insertAdjacentElement("afterend", buttonContainer) + } + } + + const observer = new MutationObserver((mutations) => { + for (const mutation of mutations) { + mutation.addedNodes.forEach((node) => { + if (node instanceof HTMLElement) { + const modal = node.querySelector(".shadow-alternate") as HTMLElement + if (modal) { + injectDownloadButton(modal) + } + } + }) + } + }) + + observer.observe(document.body, { childList: true, subtree: true }) + }, + allFrames: true, + matches: ["*://huggingface.co/*"] +}) diff --git a/src/entries-firefox/ollama-pull.content.ts b/src/entries-firefox/ollama-pull.content.ts new file mode 100644 index 0000000..89250e3 --- /dev/null +++ b/src/entries-firefox/ollama-pull.content.ts @@ -0,0 +1,57 @@ +export default defineContentScript({ + main(ctx) { + const downloadModel = async (modelName: string) => { + const ok = confirm( + `[Page Assist Extension] Do you want to pull ${modelName} model? This has nothing to do with Ollama.com website. The model will be pulled locally once you confirm.` + ) + if (ok) { + alert( + `[Page Assist Extension] Pulling ${modelName} model. For more details, check the extension icon.` + ) + + await browser.runtime.sendMessage({ + type: "pull_model", + modelName + }) + return true + } + return false + } + + const downloadSVG = ` + + + ` + const codeDiv = document.querySelectorAll("div.language-none") + + for (let i = 0; i < codeDiv.length; i++) { + const button = codeDiv[i].querySelector("button") + const command = codeDiv[i].querySelector("input") + if (button && command) { + const newButton = document.createElement("button") + newButton.innerHTML = downloadSVG + newButton.className = `border-l ${button.className}` + newButton.id = `download-${i}-pageassist` + const modelName = command?.value + .replace("ollama run", "") + .replace("ollama pull", "") + .trim() + newButton.addEventListener("click", () => { + downloadModel(modelName) + }) + + const span = document.createElement("span") + span.title = "Download model via Page Assist" + span.appendChild(newButton) + + if (button.parentNode) { + button.parentNode.appendChild(span) + } + + } + } + }, + allFrames: true, + matches: ["*://ollama.com/*"], + +}) \ No newline at end of file diff --git a/src/entries-firefox/options/App.tsx b/src/entries-firefox/options/App.tsx new file mode 100644 index 0000000..fceed88 --- /dev/null +++ b/src/entries-firefox/options/App.tsx @@ -0,0 +1,57 @@ +import { QueryClient, QueryClientProvider } from "@tanstack/react-query" +import { MemoryRouter } from "react-router-dom" +import { useEffect, useState } from "react" +const queryClient = new QueryClient() +import { ConfigProvider, Empty, theme } from "antd" +import { StyleProvider } from "@ant-design/cssinjs" +import { useDarkMode } from "~/hooks/useDarkmode" +import { OptionRouting } from "@/routes/firefox-route" +import "~/i18n" +import { useTranslation } from "react-i18next" +import { PageAssistProvider } from "@/components/Common/PageAssistProvider" + +function IndexOption() { + const { mode } = useDarkMode() + const { t, i18n } = useTranslation() + const [direction, setDirection] = useState<"ltr" | "rtl">("ltr") + + useEffect(() => { + if (i18n.resolvedLanguage) { + document.documentElement.lang = i18n.resolvedLanguage + document.documentElement.dir = i18n.dir(i18n.resolvedLanguage) + setDirection(i18n.dir(i18n.resolvedLanguage)) + } + }, [i18n, i18n.resolvedLanguage]) + + return ( + + ( + + )} + direction={direction}> + + + + + + + + + + ) +} + +export default IndexOption diff --git a/src/entries-firefox/options/index.html b/src/entries-firefox/options/index.html new file mode 100644 index 0000000..c30dfad --- /dev/null +++ b/src/entries-firefox/options/index.html @@ -0,0 +1,15 @@ + + + + Page Assist - A Web UI for Local AI Models + + + + + + + +
+ + + diff --git a/src/entries-firefox/options/main.tsx b/src/entries-firefox/options/main.tsx new file mode 100644 index 0000000..9e68814 --- /dev/null +++ b/src/entries-firefox/options/main.tsx @@ -0,0 +1,10 @@ +import React from 'react'; +import ReactDOM from 'react-dom/client'; +import IndexOption from './App'; + + +ReactDOM.createRoot(document.getElementById('root')!).render( + + + , +); diff --git a/src/entries-firefox/sidepanel/App.tsx b/src/entries-firefox/sidepanel/App.tsx new file mode 100644 index 0000000..e1cfafe --- /dev/null +++ b/src/entries-firefox/sidepanel/App.tsx @@ -0,0 +1,54 @@ +import { QueryClient, QueryClientProvider } from "@tanstack/react-query" +import { MemoryRouter } from "react-router-dom" +import { useEffect } from "react" +import { SidepanelRouting } from "@/routes/firefox-route" +const queryClient = new QueryClient() +import { ConfigProvider, Empty, theme } from "antd" +import { StyleProvider } from "@ant-design/cssinjs" +import { useDarkMode } from "~/hooks/useDarkmode" +import "~/i18n" +import { useTranslation } from "react-i18next" +import { PageAssistProvider } from "@/components/Common/PageAssistProvider" + +function IndexSidepanel() { + const { mode } = useDarkMode() + const { t, i18n } = useTranslation() + + useEffect(() => { + if (i18n.resolvedLanguage) { + document.documentElement.lang = i18n.resolvedLanguage; + document.documentElement.dir = i18n.dir(i18n.resolvedLanguage); + } + }, [i18n, i18n.resolvedLanguage]); + + return ( + + ( + + )}> + + + + + + + + + + ) +} + +export default IndexSidepanel diff --git a/src/entries-firefox/sidepanel/index.html b/src/entries-firefox/sidepanel/index.html new file mode 100644 index 0000000..1e7c405 --- /dev/null +++ b/src/entries-firefox/sidepanel/index.html @@ -0,0 +1,16 @@ + + + + Page Assist - A Web UI for Local AI Models + + + + + + + + +
+ + + diff --git a/src/entries-firefox/sidepanel/main.tsx b/src/entries-firefox/sidepanel/main.tsx new file mode 100644 index 0000000..16cfcf7 --- /dev/null +++ b/src/entries-firefox/sidepanel/main.tsx @@ -0,0 +1,9 @@ +import React from "react" +import ReactDOM from "react-dom/client" +import IndexSidepanel from "./App" + +ReactDOM.createRoot(document.getElementById("root")!).render( + + + +) diff --git a/src/entries/options/App.tsx b/src/entries/options/App.tsx index 997e1de..a0cb324 100644 --- a/src/entries/options/App.tsx +++ b/src/entries/options/App.tsx @@ -5,7 +5,7 @@ const queryClient = new QueryClient() import { ConfigProvider, Empty, theme } from "antd" import { StyleProvider } from "@ant-design/cssinjs" import { useDarkMode } from "~/hooks/useDarkmode" -import { OptionRouting } from "~/routes" +import { OptionRouting } from "@/routes/chrome-route" import "~/i18n" import { useTranslation } from "react-i18next" import { PageAssistProvider } from "@/components/Common/PageAssistProvider" diff --git a/src/entries/sidepanel/App.tsx b/src/entries/sidepanel/App.tsx index 3abbf33..26aa58a 100644 --- a/src/entries/sidepanel/App.tsx +++ b/src/entries/sidepanel/App.tsx @@ -1,7 +1,7 @@ import { QueryClient, QueryClientProvider } from "@tanstack/react-query" import { MemoryRouter } from "react-router-dom" import { useEffect } from "react" -import { SidepanelRouting } from "~/routes" +import { SidepanelRouting } from "@/routes/chrome-route" const queryClient = new QueryClient() import { ConfigProvider, Empty, theme } from "antd" import { StyleProvider } from "@ant-design/cssinjs" diff --git a/src/hooks/useMessage.tsx b/src/hooks/useMessage.tsx index c95554d..1cdca63 100644 --- a/src/hooks/useMessage.tsx +++ b/src/hooks/useMessage.tsx @@ -84,7 +84,9 @@ export const useMessage = () => { selectedQuickPrompt, setSelectedQuickPrompt, selectedSystemPrompt, - setSelectedSystemPrompt + setSelectedSystemPrompt, + useOCR, + setUseOCR } = useStoreMessage() const [speechToTextLanguage, setSpeechToTextLanguage] = useStorage( @@ -141,7 +143,14 @@ export const useMessage = () => { currentChatModelSettings?.numPredict ?? userDefaultModelSettings?.numPredict, useMMap: - currentChatModelSettings?.useMMap ?? userDefaultModelSettings?.useMMap + currentChatModelSettings?.useMMap ?? userDefaultModelSettings?.useMMap, + minP: currentChatModelSettings?.minP ?? userDefaultModelSettings?.minP, + repeatLastN: + currentChatModelSettings?.repeatLastN ?? + userDefaultModelSettings?.repeatLastN, + repeatPenalty: + currentChatModelSettings?.repeatPenalty ?? + userDefaultModelSettings?.repeatPenalty }) let newMessage: Message[] = [] @@ -276,7 +285,15 @@ export const useMessage = () => { userDefaultModelSettings?.numPredict, useMMap: currentChatModelSettings?.useMMap ?? - userDefaultModelSettings?.useMMap + userDefaultModelSettings?.useMMap, + minP: + currentChatModelSettings?.minP ?? userDefaultModelSettings?.minP, + repeatLastN: + currentChatModelSettings?.repeatLastN ?? + userDefaultModelSettings?.repeatLastN, + repeatPenalty: + currentChatModelSettings?.repeatPenalty ?? + userDefaultModelSettings?.repeatPenalty }) const response = await questionOllama.invoke(promptForQuestion) query = response.content.toString() @@ -329,7 +346,7 @@ export const useMessage = () => { ] } - let humanMessage = humanMessageFormatter({ + let humanMessage = await humanMessageFormatter({ content: [ { text: systemPrompt @@ -338,7 +355,8 @@ export const useMessage = () => { type: "text" } ], - model: selectedModel + model: selectedModel, + useOCR }) const applicationChatHistory = generateHistory(history, selectedModel) @@ -489,7 +507,14 @@ export const useMessage = () => { currentChatModelSettings?.numPredict ?? userDefaultModelSettings?.numPredict, useMMap: - currentChatModelSettings?.useMMap ?? userDefaultModelSettings?.useMMap + currentChatModelSettings?.useMMap ?? userDefaultModelSettings?.useMMap, + minP: currentChatModelSettings?.minP ?? userDefaultModelSettings?.minP, + repeatLastN: + currentChatModelSettings?.repeatLastN ?? + userDefaultModelSettings?.repeatLastN, + repeatPenalty: + currentChatModelSettings?.repeatPenalty ?? + userDefaultModelSettings?.repeatPenalty }) let newMessage: Message[] = [] @@ -564,7 +589,7 @@ export const useMessage = () => { ) } - let humanMessage = humanMessageFormatter({ + let humanMessage = await humanMessageFormatter({ content: [ { text: message, @@ -575,7 +600,8 @@ export const useMessage = () => { type: "image_url" } ], - model: selectedModel + model: selectedModel, + useOCR }) let generationInfo: any | undefined = undefined @@ -725,7 +751,14 @@ export const useMessage = () => { currentChatModelSettings?.numPredict ?? userDefaultModelSettings?.numPredict, useMMap: - currentChatModelSettings?.useMMap ?? userDefaultModelSettings?.useMMap + currentChatModelSettings?.useMMap ?? userDefaultModelSettings?.useMMap, + minP: currentChatModelSettings?.minP ?? userDefaultModelSettings?.minP, + repeatLastN: + currentChatModelSettings?.repeatLastN ?? + userDefaultModelSettings?.repeatLastN, + repeatPenalty: + currentChatModelSettings?.repeatPenalty ?? + userDefaultModelSettings?.repeatPenalty }) let newMessage: Message[] = [] @@ -769,17 +802,18 @@ export const useMessage = () => { const prompt = await systemPromptForNonRag() const selectedPrompt = await getPromptById(selectedSystemPrompt) - let humanMessage = humanMessageFormatter({ + let humanMessage = await humanMessageFormatter({ content: [ { text: message, type: "text" } ], - model: selectedModel + model: selectedModel, + useOCR }) if (image.length > 0) { - humanMessage = humanMessageFormatter({ + humanMessage = await humanMessageFormatter({ content: [ { text: message, @@ -790,7 +824,8 @@ export const useMessage = () => { type: "image_url" } ], - model: selectedModel + model: selectedModel, + useOCR }) } @@ -955,7 +990,14 @@ export const useMessage = () => { currentChatModelSettings?.numPredict ?? userDefaultModelSettings?.numPredict, useMMap: - currentChatModelSettings?.useMMap ?? userDefaultModelSettings?.useMMap + currentChatModelSettings?.useMMap ?? userDefaultModelSettings?.useMMap, + minP: currentChatModelSettings?.minP ?? userDefaultModelSettings?.minP, + repeatLastN: + currentChatModelSettings?.repeatLastN ?? + userDefaultModelSettings?.repeatLastN, + repeatPenalty: + currentChatModelSettings?.repeatPenalty ?? + userDefaultModelSettings?.repeatPenalty }) let newMessage: Message[] = [] @@ -1037,7 +1079,15 @@ export const useMessage = () => { userDefaultModelSettings?.numPredict, useMMap: currentChatModelSettings?.useMMap ?? - userDefaultModelSettings?.useMMap + userDefaultModelSettings?.useMMap, + minP: + currentChatModelSettings?.minP ?? userDefaultModelSettings?.minP, + repeatLastN: + currentChatModelSettings?.repeatLastN ?? + userDefaultModelSettings?.repeatLastN, + repeatPenalty: + currentChatModelSettings?.repeatPenalty ?? + userDefaultModelSettings?.repeatPenalty }) const response = await questionOllama.invoke(promptForQuestion) query = response.content.toString() @@ -1048,17 +1098,18 @@ export const useMessage = () => { // message = message.trim().replaceAll("\n", " ") - let humanMessage = humanMessageFormatter({ + let humanMessage = await humanMessageFormatter({ content: [ { text: message, type: "text" } ], - model: selectedModel + model: selectedModel, + useOCR }) if (image.length > 0) { - humanMessage = humanMessageFormatter({ + humanMessage = await humanMessageFormatter({ content: [ { text: message, @@ -1069,7 +1120,8 @@ export const useMessage = () => { type: "image_url" } ], - model: selectedModel + model: selectedModel, + useOCR }) } @@ -1227,7 +1279,14 @@ export const useMessage = () => { currentChatModelSettings?.numPredict ?? userDefaultModelSettings?.numPredict, useMMap: - currentChatModelSettings?.useMMap ?? userDefaultModelSettings?.useMMap + currentChatModelSettings?.useMMap ?? userDefaultModelSettings?.useMMap, + minP: currentChatModelSettings?.minP ?? userDefaultModelSettings?.minP, + repeatLastN: + currentChatModelSettings?.repeatLastN ?? + userDefaultModelSettings?.repeatLastN, + repeatPenalty: + currentChatModelSettings?.repeatPenalty ?? + userDefaultModelSettings?.repeatPenalty }) let newMessage: Message[] = [] @@ -1270,17 +1329,18 @@ export const useMessage = () => { try { const prompt = await getPrompt(messageType) - let humanMessage = humanMessageFormatter({ + let humanMessage = await humanMessageFormatter({ content: [ { text: prompt.replace("{text}", message), type: "text" } ], - model: selectedModel + model: selectedModel, + useOCR }) if (image.length > 0) { - humanMessage = humanMessageFormatter({ + humanMessage = await humanMessageFormatter({ content: [ { text: prompt.replace("{text}", message), @@ -1291,7 +1351,8 @@ export const useMessage = () => { type: "image_url" } ], - model: selectedModel + model: selectedModel, + useOCR }) } @@ -1590,6 +1651,8 @@ export const useMessage = () => { selectedSystemPrompt, setSelectedSystemPrompt, speechToTextLanguage, - setSpeechToTextLanguage + setSpeechToTextLanguage, + useOCR, + setUseOCR } } diff --git a/src/hooks/useMessageOption.tsx b/src/hooks/useMessageOption.tsx index 0de14c5..56100be 100644 --- a/src/hooks/useMessageOption.tsx +++ b/src/hooks/useMessageOption.tsx @@ -70,7 +70,9 @@ export const useMessageOption = () => { selectedKnowledge, setSelectedKnowledge, temporaryChat, - setTemporaryChat + setTemporaryChat, + useOCR, + setUseOCR } = useStoreMessageOption() const currentChatModelSettings = useStoreChatModelSettings() const [selectedModel, setSelectedModel] = useStorage("selectedModel") @@ -132,7 +134,14 @@ export const useMessageOption = () => { currentChatModelSettings?.numPredict ?? userDefaultModelSettings?.numPredict, useMMap: - currentChatModelSettings?.useMMap ?? userDefaultModelSettings?.useMMap + currentChatModelSettings?.useMMap ?? userDefaultModelSettings?.useMMap, + minP: currentChatModelSettings?.minP ?? userDefaultModelSettings?.minP, + repeatLastN: + currentChatModelSettings?.repeatLastN ?? + userDefaultModelSettings?.repeatLastN, + repeatPenalty: + currentChatModelSettings?.repeatPenalty ?? + userDefaultModelSettings?.repeatPenalty }) let newMessage: Message[] = [] @@ -214,7 +223,15 @@ export const useMessageOption = () => { userDefaultModelSettings?.numPredict, useMMap: currentChatModelSettings?.useMMap ?? - userDefaultModelSettings?.useMMap + userDefaultModelSettings?.useMMap, + minP: + currentChatModelSettings?.minP ?? userDefaultModelSettings?.minP, + repeatLastN: + currentChatModelSettings?.repeatLastN ?? + userDefaultModelSettings?.repeatLastN, + repeatPenalty: + currentChatModelSettings?.repeatPenalty ?? + userDefaultModelSettings?.repeatPenalty }) const response = await questionOllama.invoke(promptForQuestion) query = response.content.toString() @@ -225,17 +242,18 @@ export const useMessageOption = () => { // message = message.trim().replaceAll("\n", " ") - let humanMessage = humanMessageFormatter({ + let humanMessage = await humanMessageFormatter({ content: [ { text: message, type: "text" } ], - model: selectedModel + model: selectedModel, + useOCR: useOCR }) if (image.length > 0) { - humanMessage = humanMessageFormatter({ + humanMessage = await humanMessageFormatter({ content: [ { text: message, @@ -246,7 +264,8 @@ export const useMessageOption = () => { type: "image_url" } ], - model: selectedModel + model: selectedModel, + useOCR: useOCR }) } @@ -438,7 +457,14 @@ export const useMessageOption = () => { currentChatModelSettings?.numPredict ?? userDefaultModelSettings?.numPredict, useMMap: - currentChatModelSettings?.useMMap ?? userDefaultModelSettings?.useMMap + currentChatModelSettings?.useMMap ?? userDefaultModelSettings?.useMMap, + minP: currentChatModelSettings?.minP ?? userDefaultModelSettings?.minP, + repeatLastN: + currentChatModelSettings?.repeatLastN ?? + userDefaultModelSettings?.repeatLastN, + repeatPenalty: + currentChatModelSettings?.repeatPenalty ?? + userDefaultModelSettings?.repeatPenalty }) let newMessage: Message[] = [] @@ -482,17 +508,18 @@ export const useMessageOption = () => { const prompt = await systemPromptForNonRagOption() const selectedPrompt = await getPromptById(selectedSystemPrompt) - let humanMessage = humanMessageFormatter({ + let humanMessage = await humanMessageFormatter({ content: [ { text: message, type: "text" } ], - model: selectedModel + model: selectedModel, + useOCR: useOCR }) if (image.length > 0) { - humanMessage = humanMessageFormatter({ + humanMessage = await humanMessageFormatter({ content: [ { text: message, @@ -503,7 +530,8 @@ export const useMessageOption = () => { type: "image_url" } ], - model: selectedModel + model: selectedModel, + useOCR: useOCR }) } @@ -684,7 +712,14 @@ export const useMessageOption = () => { currentChatModelSettings?.numPredict ?? userDefaultModelSettings?.numPredict, useMMap: - currentChatModelSettings?.useMMap ?? userDefaultModelSettings?.useMMap + currentChatModelSettings?.useMMap ?? userDefaultModelSettings?.useMMap, + minP: currentChatModelSettings?.minP ?? userDefaultModelSettings?.minP, + repeatLastN: + currentChatModelSettings?.repeatLastN ?? + userDefaultModelSettings?.repeatLastN, + repeatPenalty: + currentChatModelSettings?.repeatPenalty ?? + userDefaultModelSettings?.repeatPenalty }) let newMessage: Message[] = [] @@ -782,7 +817,15 @@ export const useMessageOption = () => { userDefaultModelSettings?.numPredict, useMMap: currentChatModelSettings?.useMMap ?? - userDefaultModelSettings?.useMMap + userDefaultModelSettings?.useMMap, + minP: + currentChatModelSettings?.minP ?? userDefaultModelSettings?.minP, + repeatLastN: + currentChatModelSettings?.repeatLastN ?? + userDefaultModelSettings?.repeatLastN, + repeatPenalty: + currentChatModelSettings?.repeatPenalty ?? + userDefaultModelSettings?.repeatPenalty }) const response = await questionOllama.invoke(promptForQuestion) query = response.content.toString() @@ -802,7 +845,7 @@ export const useMessageOption = () => { }) // message = message.trim().replaceAll("\n", " ") - let humanMessage = humanMessageFormatter({ + let humanMessage = await humanMessageFormatter({ content: [ { text: systemPrompt @@ -811,7 +854,8 @@ export const useMessageOption = () => { type: "text" } ], - model: selectedModel + model: selectedModel, + useOCR: useOCR }) const applicationChatHistory = generateHistory(history, selectedModel) @@ -1106,6 +1150,8 @@ export const useMessageOption = () => { setSelectedKnowledge, ttsEnabled, temporaryChat, - setTemporaryChat + setTemporaryChat, + useOCR, + setUseOCR } } diff --git a/src/hooks/useTTS.tsx b/src/hooks/useTTS.tsx index 5274956..6573ec4 100644 --- a/src/hooks/useTTS.tsx +++ b/src/hooks/useTTS.tsx @@ -1,44 +1,101 @@ import { useEffect, useState } from "react" import { notification } from "antd" -import { getVoice, isSSMLEnabled } from "@/services/tts" +import { + getElevenLabsApiKey, + getElevenLabsModel, + getElevenLabsVoiceId, + getTTSProvider, + getVoice, + isSSMLEnabled +} from "@/services/tts" import { markdownToSSML } from "@/utils/markdown-to-ssml" -type VoiceOptions = { +import { generateSpeech } from "@/services/elevenlabs" +import { splitMessageContent } from "@/utils/tts" + +export interface VoiceOptions { utterance: string } export const useTTS = () => { const [isSpeaking, setIsSpeaking] = useState(false) + const [audioElement, setAudioElement] = useState( + null + ) const speak = async ({ utterance }: VoiceOptions) => { try { const voice = await getVoice() - const isSSML = await isSSMLEnabled() - if (isSSML) { - utterance = markdownToSSML(utterance) - } - if (import.meta.env.BROWSER === "chrome") { - chrome.tts.speak(utterance, { - voiceName: voice, - onEvent(event) { - if (event.type === "start") { - setIsSpeaking(true) - } else if (event.type === "end") { - setIsSpeaking(false) - } - } - }) - } else { - // browser tts - window.speechSynthesis.speak(new SpeechSynthesisUtterance(utterance)) - window.speechSynthesis.onvoiceschanged = () => { - const voices = window.speechSynthesis.getVoices() - const voice = voices.find((v) => v.name === voice) - const utter = new SpeechSynthesisUtterance(utterance) - utter.voice = voice - window.speechSynthesis.speak(utter) + const provider = await getTTSProvider() + + if (provider === "browser") { + const isSSML = await isSSMLEnabled() + if (isSSML) { + utterance = markdownToSSML(utterance) } + if (import.meta.env.BROWSER === "chrome") { + chrome.tts.speak(utterance, { + voiceName: voice, + onEvent(event) { + if (event.type === "start") { + setIsSpeaking(true) + } else if (event.type === "end") { + setIsSpeaking(false) + } + } + }) + } else { + window.speechSynthesis.speak(new SpeechSynthesisUtterance(utterance)) + window.speechSynthesis.onvoiceschanged = () => { + const voices = window.speechSynthesis.getVoices() + const voice = voices.find((v) => v.name === voice) + const utter = new SpeechSynthesisUtterance(utterance) + utter.voice = voice + window.speechSynthesis.speak(utter) + } + } + } else if (provider === "elevenlabs") { + const apiKey = await getElevenLabsApiKey() + const modelId = await getElevenLabsModel() + const voiceId = await getElevenLabsVoiceId() + const sentences = splitMessageContent(utterance) + let nextAudioData: ArrayBuffer | null = null + if (!apiKey || !modelId || !voiceId) { + throw new Error("Missing ElevenLabs configuration") + } + for (let i = 0; i < sentences.length; i++) { + setIsSpeaking(true) + + let currentAudioData = + nextAudioData || + (await generateSpeech(apiKey, sentences[i], voiceId, modelId)) + + if (i < sentences.length - 1) { + generateSpeech(apiKey, sentences[i + 1], voiceId, modelId) + .then((nextAudioData) => { + nextAudioData = nextAudioData + }) + .catch(console.error) + } + + const blob = new Blob([currentAudioData], { type: "audio/mpeg" }) + const url = URL.createObjectURL(blob) + const audio = new Audio(url) + setAudioElement(audio) + + await new Promise((resolve) => { + audio.onended = resolve + audio.play() + }) + + URL.revokeObjectURL(url) + } + + setIsSpeaking(false) + setAudioElement(null) } } catch (error) { + setIsSpeaking(false) + setAudioElement(null) notification.error({ message: "Error", description: "Something went wrong while trying to play the audio" @@ -47,6 +104,14 @@ export const useTTS = () => { } const cancel = () => { + if (audioElement) { + audioElement.pause() + audioElement.currentTime = 0 + setAudioElement(null) + setIsSpeaking(false) + return + } + if (import.meta.env.BROWSER === "chrome") { chrome.tts.stop() } else { diff --git a/src/i18n/index.ts b/src/i18n/index.ts index 5897a1e..72b7a93 100644 --- a/src/i18n/index.ts +++ b/src/i18n/index.ts @@ -16,6 +16,7 @@ import { da } from "./lang/da"; import { no } from "./lang/no"; import { sv } from "./lang/sv"; import { ko } from "./lang/ko"; +import { ar } from "./lang/ar" i18n @@ -43,6 +44,7 @@ i18n de: de, sv: sv, ko: ko, + ar: ar }, fallbackLng: "en", lng: localStorage.getItem("i18nextLng") || "en", diff --git a/src/i18n/lang/ar.ts b/src/i18n/lang/ar.ts new file mode 100644 index 0000000..87d94c1 --- /dev/null +++ b/src/i18n/lang/ar.ts @@ -0,0 +1,19 @@ +import option from "@/assets/locale/ar/option.json"; +import playground from "@/assets/locale/ar/playground.json"; +import common from "@/assets/locale/ar/common.json"; +import sidepanel from "@/assets/locale/ar/sidepanel.json"; +import settings from "@/assets/locale/ar/settings.json"; +import knowledge from "@/assets/locale/ar/knowledge.json"; +import chrome from "@/assets/locale/ar/chrome.json"; +import openai from "@/assets/locale/ar/openai.json"; + +export const ar = { + option, + playground, + common, + sidepanel, + settings, + knowledge, + chrome, + openai +} \ No newline at end of file diff --git a/src/i18n/support-language.ts b/src/i18n/support-language.ts index 4787ab6..9a88674 100644 --- a/src/i18n/support-language.ts +++ b/src/i18n/support-language.ts @@ -63,5 +63,9 @@ export const supportLanguage = [ { value: "ko", label: "한국어" + }, + { + value: "ar", + label: "العربية" } ] diff --git a/src/models/ChatOllama.ts b/src/models/ChatOllama.ts index 1bc7ddb..e046f68 100644 --- a/src/models/ChatOllama.ts +++ b/src/models/ChatOllama.ts @@ -95,6 +95,8 @@ export class ChatOllama topP?: number; + minP?: number; + typicalP?: number; useMLock?: boolean; @@ -142,6 +144,7 @@ export class ChatOllama this.tfsZ = fields.tfsZ; this.topK = fields.topK; this.topP = fields.topP; + this.minP = fields.minP; this.typicalP = fields.typicalP; this.useMLock = fields.useMLock; this.useMMap = fields.useMMap; @@ -205,6 +208,7 @@ export class ChatOllama tfs_z: this.tfsZ, top_k: this.topK, top_p: this.topP, + min_p: this.minP, typical_p: this.typicalP, use_mlock: this.useMLock, use_mmap: this.useMMap, diff --git a/src/models/index.ts b/src/models/index.ts index 953c968..b50baf2 100644 --- a/src/models/index.ts +++ b/src/models/index.ts @@ -17,7 +17,10 @@ export const pageAssistModel = async ({ seed, numGpu, numPredict, - useMMap + useMMap, + minP, + repeatLastN, + repeatPenalty }: { model: string baseUrl: string @@ -30,6 +33,9 @@ export const pageAssistModel = async ({ numGpu?: number numPredict?: number useMMap?: boolean + minP?: number + repeatPenalty?: number + repeatLastN?: number }) => { if (model === "chrome::gemini-nano::page-assist") { return new ChatChromeAI({ @@ -86,6 +92,9 @@ export const pageAssistModel = async ({ model, numGpu, numPredict, - useMMap + useMMap, + minP: minP, + repeatPenalty: repeatPenalty, + repeatLastN: repeatLastN, }) } diff --git a/src/models/utils/ollama.ts b/src/models/utils/ollama.ts index 57b98f0..a311ca9 100644 --- a/src/models/utils/ollama.ts +++ b/src/models/utils/ollama.ts @@ -35,6 +35,7 @@ export interface OllamaInput { tfsZ?: number topK?: number topP?: number + minP?: number typicalP?: number useMLock?: boolean useMMap?: boolean diff --git a/src/public/ocr/lang/eng-fast.traineddata.gz b/src/public/ocr/lang/eng-fast.traineddata.gz new file mode 100644 index 0000000..1760dd1 Binary files /dev/null and b/src/public/ocr/lang/eng-fast.traineddata.gz differ diff --git a/src/public/ocr/tesseract-core-simd.js b/src/public/ocr/tesseract-core-simd.js new file mode 100644 index 0000000..58fa1ae --- /dev/null +++ b/src/public/ocr/tesseract-core-simd.js @@ -0,0 +1,281 @@ + +var TesseractCore = (() => { + var _scriptDir = typeof document !== 'undefined' && document.currentScript ? document.currentScript.src : undefined; + if (typeof __filename !== 'undefined') _scriptDir = _scriptDir || __filename; + return ( +function(TesseractCore) { + TesseractCore = TesseractCore || {}; + + +var b;b||(b=typeof TesseractCore !== 'undefined' ? TesseractCore : {});var aa,ba;b.ready=new Promise(function(a,c){aa=a;ba=c});var ca=Object.assign({},b),da="./this.program",ea=(a,c)=>{throw c;},fa="object"==typeof window,ha="function"==typeof importScripts,ia="object"==typeof process&&"object"==typeof process.versions&&"string"==typeof process.versions.node,f="",ja,ka,la,fs,ma,na; +if(ia)f=ha?require("path").dirname(f)+"/":__dirname+"/",na=()=>{ma||(fs=require("fs"),ma=require("path"))},ja=function(a,c){na();a=ma.normalize(a);return fs.readFileSync(a,c?void 0:"utf8")},la=a=>{a=ja(a,!0);a.buffer||(a=new Uint8Array(a));return a},ka=(a,c,d)=>{na();a=ma.normalize(a);fs.readFile(a,function(e,g){e?d(e):c(g.buffer)})},1{if(noExitRuntime)throw process.exitCode=a,c;c instanceof oa||pa("exiting due to exception: "+c);process.exit(a)},b.inspect=function(){return"[Emscripten Module object]"};else if(fa||ha)ha?f=self.location.href:"undefined"!=typeof document&&document.currentScript&&(f=document.currentScript.src),_scriptDir&&(f=_scriptDir),0!==f.indexOf("blob:")?f=f.substr(0,f.replace(/[?#].*/,"").lastIndexOf("/")+1):f="",ja=a=>{var c=new XMLHttpRequest;c.open("GET",a,!1);c.send(null); +return c.responseText},ha&&(la=a=>{var c=new XMLHttpRequest;c.open("GET",a,!1);c.responseType="arraybuffer";c.send(null);return new Uint8Array(c.response)}),ka=(a,c,d)=>{var e=new XMLHttpRequest;e.open("GET",a,!0);e.responseType="arraybuffer";e.onload=()=>{200==e.status||0==e.status&&e.response?c(e.response):d()};e.onerror=d;e.send(null)};var qa=b.print||console.log.bind(console),pa=b.printErr||console.warn.bind(console);Object.assign(b,ca);ca=null;b.thisProgram&&(da=b.thisProgram);b.quit&&(ea=b.quit); +var ra=0,sa;b.wasmBinary&&(sa=b.wasmBinary);var noExitRuntime=b.noExitRuntime||!0;"object"!=typeof WebAssembly&&n("no native wasm support detected");var ta,ua=!1,wa="undefined"!=typeof TextDecoder?new TextDecoder("utf8"):void 0; +function xa(a,c){for(var d=c+NaN,e=c;a[e]&&!(e>=d);)++e;if(16g?d+=String.fromCharCode(g):(g-=65536,d+=String.fromCharCode(55296|g>>10,56320|g&1023))}}else d+=String.fromCharCode(g)}return d}function q(a){return a?xa(ya,a):""} +function za(a,c,d,e){if(!(0=k){var m=a.charCodeAt(++h);k=65536+((k&1023)<<10)|m&1023}if(127>=k){if(d>=e)break;c[d++]=k}else{if(2047>=k){if(d+1>=e)break;c[d++]=192|k>>6}else{if(65535>=k){if(d+2>=e)break;c[d++]=224|k>>12}else{if(d+3>=e)break;c[d++]=240|k>>18;c[d++]=128|k>>12&63}c[d++]=128|k>>6&63}c[d++]=128|k&63}}c[d]=0;return d-g} +function Aa(a){for(var c=0,d=0;d=e?c++:2047>=e?c+=2:55296<=e&&57343>=e?(c+=4,++d):c+=3}return c}var Ba,r,ya,Ca,v,y,Da,Ea;function Fa(){var a=ta.buffer;Ba=a;b.HEAP8=r=new Int8Array(a);b.HEAP16=Ca=new Int16Array(a);b.HEAP32=v=new Int32Array(a);b.HEAPU8=ya=new Uint8Array(a);b.HEAPU16=new Uint16Array(a);b.HEAPU32=y=new Uint32Array(a);b.HEAPF32=Da=new Float32Array(a);b.HEAPF64=Ea=new Float64Array(a)}var Ga,Ha=[],Ia=[],Ka=[],La=!1; +function Ma(){var a=b.preRun.shift();Ha.unshift(a)}var Na=0,Oa=null,Pa=null;function Qa(){Na++;b.monitorRunDependencies&&b.monitorRunDependencies(Na)}function Ra(){Na--;b.monitorRunDependencies&&b.monitorRunDependencies(Na);if(0==Na&&(null!==Oa&&(clearInterval(Oa),Oa=null),Pa)){var a=Pa;Pa=null;a()}}function n(a){if(b.onAbort)b.onAbort(a);a="Aborted("+a+")";pa(a);ua=!0;a=new WebAssembly.RuntimeError(a+". Build with -sASSERTIONS for more info.");ba(a);throw a;} +function Sa(){return z.startsWith("data:application/octet-stream;base64,")}var z;z="tesseract-core-simd.wasm";if(!Sa()){var Ta=z;z=b.locateFile?b.locateFile(Ta,f):f+Ta}function Ua(){var a=z;try{if(a==z&&sa)return new Uint8Array(sa);if(la)return la(a);throw"both async and sync fetching of the wasm failed";}catch(c){n(c)}} +function Va(){if(!sa&&(fa||ha)){if("function"==typeof fetch&&!z.startsWith("file://"))return fetch(z,{credentials:"same-origin"}).then(function(a){if(!a.ok)throw"failed to load wasm binary file at '"+z+"'";return a.arrayBuffer()}).catch(function(){return Ua()});if(ka)return new Promise(function(a,c){ka(z,function(d){a(new Uint8Array(d))},c)})}return Promise.resolve().then(function(){return Ua()})} +var A,C,Wa={627260:a=>{b.TesseractProgress&&b.TesseractProgress(a)},627329:a=>{b.TesseractProgress&&b.TesseractProgress(a)},627398:a=>{b.TesseractProgress&&b.TesseractProgress(a)}};function oa(a){this.name="ExitStatus";this.message="Program terminated with exit("+a+")";this.status=a}function Xa(a){for(;0>0];case "i8":return r[a>>0];case "i16":return Ca[a>>1];case "i32":return v[a>>2];case "i64":return v[a>>2];case "float":return Da[a>>2];case "double":return Ea[a>>3];case "*":return y[a>>2];default:n("invalid type for getValue: "+c)}return null} +function Za(a,c,d="i8"){d.endsWith("*")&&(d="*");switch(d){case "i1":r[a>>0]=c;break;case "i8":r[a>>0]=c;break;case "i16":Ca[a>>1]=c;break;case "i32":v[a>>2]=c;break;case "i64":C=[c>>>0,(A=c,1<=+Math.abs(A)?0>>0:~~+Math.ceil((A-+(~~A>>>0))/4294967296)>>>0:0)];v[a>>2]=C[0];v[a+4>>2]=C[1];break;case "float":Da[a>>2]=c;break;case "double":Ea[a>>3]=c;break;case "*":y[a>>2]=c;break;default:n("invalid type for setValue: "+d)}} +function $a(a){this.If=a-24;this.Ih=function(c){y[this.If+4>>2]=c};this.Eh=function(c){y[this.If+8>>2]=c};this.Fh=function(){v[this.If>>2]=0};this.Jg=function(){r[this.If+12>>0]=0};this.Hh=function(){r[this.If+13>>0]=0};this.rg=function(c,d){this.Vf();this.Ih(c);this.Eh(d);this.Fh();this.Jg();this.Hh()};this.Vf=function(){y[this.If+16>>2]=0}} +var ab=0,bb=(a,c)=>{for(var d=0,e=a.length-1;0<=e;e--){var g=a[e];"."===g?a.splice(e,1):".."===g?(a.splice(e,1),d++):d&&(a.splice(e,1),d--)}if(c)for(;d;d--)a.unshift("..");return a},cb=a=>{var c="/"===a.charAt(0),d="/"===a.substr(-1);(a=bb(a.split("/").filter(e=>!!e),!c).join("/"))||c||(a=".");a&&d&&(a+="/");return(c?"/":"")+a},db=a=>{var c=/^(\/?|)([\s\S]*?)((?:\.{1,2}|[^\/]+?|)(\.[^.\/]*|))(?:[\/]*)$/.exec(a).slice(1);a=c[0];c=c[1];if(!a&&!c)return".";c&&(c=c.substr(0,c.length-1));return a+c},eb= +a=>{if("/"===a)return"/";a=cb(a);a=a.replace(/\/$/,"");var c=a.lastIndexOf("/");return-1===c?a:a.substr(c+1)},fb=(a,c)=>cb(a+"/"+c);function gb(){if("object"==typeof crypto&&"function"==typeof crypto.getRandomValues){var a=new Uint8Array(1);return()=>{crypto.getRandomValues(a);return a[0]}}if(ia)try{var c=require("crypto");return()=>c.randomBytes(1)[0]}catch(d){}return()=>n("randomDevice")} +function hb(){for(var a="",c=!1,d=arguments.length-1;-1<=d&&!c;d--){c=0<=d?arguments[d]:D.cwd();if("string"!=typeof c)throw new TypeError("Arguments to path.resolve must be strings");if(!c)return"";a=c+"/"+a;c="/"===c.charAt(0)}a=bb(a.split("/").filter(e=>!!e),!c).join("/");return(c?"/":"")+a||"."} +var ib=(a,c)=>{function d(k){for(var m=0;mt?[]:k.slice(m,t-m+1)}a=hb(a).substr(1);c=hb(c).substr(1);a=d(a.split("/"));c=d(c.split("/"));for(var e=Math.min(a.length,c.length),g=e,h=0;h=c||(c=Math.max(c,d*(1048576>d?2:1.125)>>>0),0!=d&&(c=Math.max(c,256)),d=a.Lf,a.Lf=new Uint8Array(c),0=a.node.Qf)return 0;a=Math.min(a.node.Qf-g,e);if(8c)throw new D.Jf(28);return c},vg:function(a,c,d){E.th(a.node,c+d);a.node.Qf=Math.max(a.node.Qf,c+d)},lg:function(a,c,d,e,g){if(!D.isFile(a.node.mode))throw new D.Jf(43);a=a.node.Lf;if(g&2||a.buffer!==Ba){if(0{g||n('Loading data file "'+a+'" failed (no arrayBuffer).');c(new Uint8Array(g));e&&Ra(e)},()=>{if(d)d();else throw'Loading data file "'+a+'" failed.';});e&&Qa(e)} +var D={root:null,Ag:[],rh:{},streams:[],zi:1,$f:null,qh:"/",Xg:!1,Ah:!0,Jf:null,Pg:{},Wh:null,Gg:0,Pf:(a,c={})=>{a=hb(D.cwd(),a);if(!a)return{path:"",node:null};c=Object.assign({Ng:!0,fh:0},c);if(8!!k),!1);for(var d=D.root,e="/",g=0;g{for(var c;;){if(D.Dg(a))return a=a.Sf.Bh,c?"/"!==a[a.length-1]?a+"/"+c:a+c:a;c=c?a.name+"/"+c:a.name;a=a.parent}},Wg:(a,c)=>{for(var d=0,e=0;e>>0)%D.$f.length},yh:a=>{var c=D.Wg(a.parent.id,a.name);a.mg=D.$f[c];D.$f[c]=a},zh:a=>{var c=D.Wg(a.parent.id,a.name);if(D.$f[c]===a)D.$f[c]=a.mg;else for(c=D.$f[c];c;){if(c.mg===a){c.mg=a.mg;break}c=c.mg}},dg:(a,c)=>{var d=D.wi(a);if(d)throw new D.Jf(d, +a);for(d=D.$f[D.Wg(a.id,c)];d;d=d.mg){var e=d.name;if(d.parent.id===a.id&&e===c)return d}return D.lookup(a,c)},createNode:(a,c,d,e)=>{a=new D.Dh(a,c,d,e);D.yh(a);return a},Mg:a=>{D.zh(a)},Dg:a=>a===a.parent,jg:a=>!!a.zg,isFile:a=>32768===(a&61440),Tf:a=>16384===(a&61440),yg:a=>40960===(a&61440),Cg:a=>8192===(a&61440),ui:a=>24576===(a&61440),isFIFO:a=>4096===(a&61440),isSocket:a=>49152===(a&49152),Xh:{r:0,"r+":2,w:577,"w+":578,a:1089,"a+":1090},yi:a=>{var c=D.Xh[a];if("undefined"==typeof c)throw Error("Unknown file open mode: "+ +a);return c},uh:a=>{var c=["r","w","rw"][a&3];a&512&&(c+="w");return c},ng:(a,c)=>{if(D.Ah)return 0;if(!c.includes("r")||a.mode&292){if(c.includes("w")&&!(a.mode&146)||c.includes("x")&&!(a.mode&73))return 2}else return 2;return 0},wi:a=>{var c=D.ng(a,"x");return c?c:a.Kf.lookup?0:2},bh:(a,c)=>{try{return D.dg(a,c),20}catch(d){}return D.ng(a,"wx")},Eg:(a,c,d)=>{try{var e=D.dg(a,c)}catch(g){return g.Rf}if(a=D.ng(a,"wx"))return a;if(d){if(!D.Tf(e.mode))return 54;if(D.Dg(e)||D.fg(e)===D.cwd())return 10}else if(D.Tf(e.mode))return 31; +return 0},xi:(a,c)=>a?D.yg(a.mode)?32:D.Tf(a.mode)&&("r"!==D.uh(c)||c&512)?31:D.ng(a,D.uh(c)):44,Gh:4096,Ai:(a=0,c=D.Gh)=>{for(;a<=c;a++)if(!D.streams[a])return a;throw new D.Jf(33);},gg:a=>D.streams[a],ph:(a,c,d)=>{D.Bg||(D.Bg=function(){this.Vf={}},D.Bg.prototype={},Object.defineProperties(D.Bg.prototype,{object:{get:function(){return this.node},set:function(e){this.node=e}},flags:{get:function(){return this.Vf.flags},set:function(e){this.Vf.flags=e}},position:{get:function(){return this.Vf.position}, +set:function(e){this.Vf.position=e}}}));a=Object.assign(new D.Bg,a);c=D.Ai(c,d);a.fd=c;return D.streams[c]=a},Ph:a=>{D.streams[a]=null},Oh:{open:a=>{a.Mf=D.Yh(a.node.rdev).Mf;a.Mf.open&&a.Mf.open(a)},Zf:()=>{throw new D.Jf(70);}},ah:a=>a>>8,Ri:a=>a&255,kg:(a,c)=>a<<8|c,gh:(a,c)=>{D.rh[a]={Mf:c}},Yh:a=>D.rh[a],vh:a=>{var c=[];for(a=[a];a.length;){var d=a.pop();c.push(d);a.push.apply(a,d.Ag)}return c},Ch:(a,c)=>{function d(k){D.Gg--;return c(k)}function e(k){if(k){if(!e.Vh)return e.Vh=!0,d(k)}else++h>= +g.length&&d(null)}"function"==typeof a&&(c=a,a=!1);D.Gg++;1{if(!k.type.Ch)return e(null);k.type.Ch(k,a,e)})},Sf:(a,c,d)=>{var e="/"===d,g=!d;if(e&&D.root)throw new D.Jf(10);if(!e&&!g){var h=D.Pf(d,{Ng:!1});d=h.path;h=h.node;if(D.jg(h))throw new D.Jf(10);if(!D.Tf(h.mode))throw new D.Jf(54);}c={type:a,Ui:c,Bh:d,Ag:[]};a=a.Sf(c);a.Sf=c;c.root=a;e?D.root=a:h&&(h.zg= +c,h.Sf&&h.Sf.Ag.push(c));return a},Yi:a=>{a=D.Pf(a,{Ng:!1});if(!D.jg(a.node))throw new D.Jf(28);a=a.node;var c=a.zg,d=D.vh(c);Object.keys(D.$f).forEach(e=>{for(e=D.$f[e];e;){var g=e.mg;d.includes(e.Sf)&&D.Mg(e);e=g}});a.zg=null;a.Sf.Ag.splice(a.Sf.Ag.indexOf(c),1)},lookup:(a,c)=>a.Kf.lookup(a,c),eg:(a,c,d)=>{var e=D.Pf(a,{parent:!0}).node;a=eb(a);if(!a||"."===a||".."===a)throw new D.Jf(28);var g=D.bh(e,a);if(g)throw new D.Jf(g);if(!e.Kf.eg)throw new D.Jf(63);return e.Kf.eg(e,a,c,d)},create:(a,c)=> +D.eg(a,(void 0!==c?c:438)&4095|32768,0),mkdir:(a,c)=>D.eg(a,(void 0!==c?c:511)&1023|16384,0),Si:(a,c)=>{a=a.split("/");for(var d="",e=0;e{"undefined"==typeof d&&(d=c,c=438);return D.eg(a,c|8192,d)},symlink:(a,c)=>{if(!hb(a))throw new D.Jf(44);var d=D.Pf(c,{parent:!0}).node;if(!d)throw new D.Jf(44);c=eb(c);var e=D.bh(d,c);if(e)throw new D.Jf(e);if(!d.Kf.symlink)throw new D.Jf(63);return d.Kf.symlink(d, +c,a)},rename:(a,c)=>{var d=db(a),e=db(c),g=eb(a),h=eb(c);var k=D.Pf(a,{parent:!0});var m=k.node;k=D.Pf(c,{parent:!0});k=k.node;if(!m||!k)throw new D.Jf(44);if(m.Sf!==k.Sf)throw new D.Jf(75);var t=D.dg(m,g);a=ib(a,e);if("."!==a.charAt(0))throw new D.Jf(28);a=ib(c,d);if("."!==a.charAt(0))throw new D.Jf(55);try{var u=D.dg(k,h)}catch(p){}if(t!==u){c=D.Tf(t.mode);if(g=D.Eg(m,g,c))throw new D.Jf(g);if(g=u?D.Eg(k,h,c):D.bh(k,h))throw new D.Jf(g);if(!m.Kf.rename)throw new D.Jf(63);if(D.jg(t)||u&&D.jg(u))throw new D.Jf(10); +if(k!==m&&(g=D.ng(m,"w")))throw new D.Jf(g);D.zh(t);try{m.Kf.rename(t,k,h)}catch(p){throw p;}finally{D.yh(t)}}},rmdir:a=>{var c=D.Pf(a,{parent:!0}).node;a=eb(a);var d=D.dg(c,a),e=D.Eg(c,a,!0);if(e)throw new D.Jf(e);if(!c.Kf.rmdir)throw new D.Jf(63);if(D.jg(d))throw new D.Jf(10);c.Kf.rmdir(c,a);D.Mg(d)},readdir:a=>{a=D.Pf(a,{Xf:!0}).node;if(!a.Kf.readdir)throw new D.Jf(54);return a.Kf.readdir(a)},unlink:a=>{var c=D.Pf(a,{parent:!0}).node;if(!c)throw new D.Jf(44);a=eb(a);var d=D.dg(c,a),e=D.Eg(c,a, +!1);if(e)throw new D.Jf(e);if(!c.Kf.unlink)throw new D.Jf(63);if(D.jg(d))throw new D.Jf(10);c.Kf.unlink(c,a);D.Mg(d)},readlink:a=>{a=D.Pf(a).node;if(!a)throw new D.Jf(44);if(!a.Kf.readlink)throw new D.Jf(28);return hb(D.fg(a.parent),a.Kf.readlink(a))},stat:(a,c)=>{a=D.Pf(a,{Xf:!c}).node;if(!a)throw new D.Jf(44);if(!a.Kf.Yf)throw new D.Jf(63);return a.Kf.Yf(a)},lstat:a=>D.stat(a,!0),chmod:(a,c,d)=>{a="string"==typeof a?D.Pf(a,{Xf:!d}).node:a;if(!a.Kf.Uf)throw new D.Jf(63);a.Kf.Uf(a,{mode:c&4095|a.mode& +-4096,timestamp:Date.now()})},lchmod:(a,c)=>{D.chmod(a,c,!0)},fchmod:(a,c)=>{a=D.gg(a);if(!a)throw new D.Jf(8);D.chmod(a.node,c)},chown:(a,c,d,e)=>{a="string"==typeof a?D.Pf(a,{Xf:!e}).node:a;if(!a.Kf.Uf)throw new D.Jf(63);a.Kf.Uf(a,{timestamp:Date.now()})},lchown:(a,c,d)=>{D.chown(a,c,d,!0)},fchown:(a,c,d)=>{a=D.gg(a);if(!a)throw new D.Jf(8);D.chown(a.node,c,d)},truncate:(a,c)=>{if(0>c)throw new D.Jf(28);a="string"==typeof a?D.Pf(a,{Xf:!0}).node:a;if(!a.Kf.Uf)throw new D.Jf(63);if(D.Tf(a.mode))throw new D.Jf(31); +if(!D.isFile(a.mode))throw new D.Jf(28);var d=D.ng(a,"w");if(d)throw new D.Jf(d);a.Kf.Uf(a,{size:c,timestamp:Date.now()})},Ni:(a,c)=>{a=D.gg(a);if(!a)throw new D.Jf(8);if(0===(a.flags&2097155))throw new D.Jf(28);D.truncate(a.node,c)},Zi:(a,c,d)=>{a=D.Pf(a,{Xf:!0}).node;a.Kf.Uf(a,{timestamp:Math.max(c,d)})},open:(a,c,d)=>{if(""===a)throw new D.Jf(44);c="string"==typeof c?D.yi(c):c;d=c&64?("undefined"==typeof d?438:d)&4095|32768:0;if("object"==typeof a)var e=a;else{a=cb(a);try{e=D.Pf(a,{Xf:!(c&131072)}).node}catch(h){}}var g= +!1;if(c&64)if(e){if(c&128)throw new D.Jf(20);}else e=D.eg(a,d,0),g=!0;if(!e)throw new D.Jf(44);D.Cg(e.mode)&&(c&=-513);if(c&65536&&!D.Tf(e.mode))throw new D.Jf(54);if(!g&&(d=D.xi(e,c)))throw new D.Jf(d);c&512&&!g&&D.truncate(e,0);c&=-131713;e=D.ph({node:e,path:D.fg(e),flags:c,seekable:!0,position:0,Mf:e.Mf,Li:[],error:!1});e.Mf.open&&e.Mf.open(e);!b.logReadFiles||c&1||(D.eh||(D.eh={}),a in D.eh||(D.eh[a]=1));return e},close:a=>{if(D.xg(a))throw new D.Jf(8);a.Vg&&(a.Vg=null);try{a.Mf.close&&a.Mf.close(a)}catch(c){throw c; +}finally{D.Ph(a.fd)}a.fd=null},xg:a=>null===a.fd,Zf:(a,c,d)=>{if(D.xg(a))throw new D.Jf(8);if(!a.seekable||!a.Mf.Zf)throw new D.Jf(70);if(0!=d&&1!=d&&2!=d)throw new D.Jf(28);a.position=a.Mf.Zf(a,c,d);a.Li=[];return a.position},read:(a,c,d,e,g)=>{if(0>e||0>g)throw new D.Jf(28);if(D.xg(a))throw new D.Jf(8);if(1===(a.flags&2097155))throw new D.Jf(8);if(D.Tf(a.node.mode))throw new D.Jf(31);if(!a.Mf.read)throw new D.Jf(28);var h="undefined"!=typeof g;if(!h)g=a.position;else if(!a.seekable)throw new D.Jf(70); +c=a.Mf.read(a,c,d,e,g);h||(a.position+=c);return c},write:(a,c,d,e,g,h)=>{if(0>e||0>g)throw new D.Jf(28);if(D.xg(a))throw new D.Jf(8);if(0===(a.flags&2097155))throw new D.Jf(8);if(D.Tf(a.node.mode))throw new D.Jf(31);if(!a.Mf.write)throw new D.Jf(28);a.seekable&&a.flags&1024&&D.Zf(a,0,2);var k="undefined"!=typeof g;if(!k)g=a.position;else if(!a.seekable)throw new D.Jf(70);c=a.Mf.write(a,c,d,e,g,h);k||(a.position+=c);return c},vg:(a,c,d)=>{if(D.xg(a))throw new D.Jf(8);if(0>c||0>=d)throw new D.Jf(28); +if(0===(a.flags&2097155))throw new D.Jf(8);if(!D.isFile(a.node.mode)&&!D.Tf(a.node.mode))throw new D.Jf(43);if(!a.Mf.vg)throw new D.Jf(138);a.Mf.vg(a,c,d)},lg:(a,c,d,e,g)=>{if(0!==(e&2)&&0===(g&2)&&2!==(a.flags&2097155))throw new D.Jf(2);if(1===(a.flags&2097155))throw new D.Jf(2);if(!a.Mf.lg)throw new D.Jf(43);return a.Mf.lg(a,c,d,e,g)},sg:(a,c,d,e,g)=>a&&a.Mf.sg?a.Mf.sg(a,c,d,e,g):0,Ti:()=>0,Yg:(a,c,d)=>{if(!a.Mf.Yg)throw new D.Jf(59);return a.Mf.Yg(a,c,d)},readFile:(a,c={})=>{c.flags=c.flags||0; +c.encoding=c.encoding||"binary";if("utf8"!==c.encoding&&"binary"!==c.encoding)throw Error('Invalid encoding type "'+c.encoding+'"');var d,e=D.open(a,c.flags);a=D.stat(a).size;var g=new Uint8Array(a);D.read(e,g,0,a,0);"utf8"===c.encoding?d=xa(g,0):"binary"===c.encoding&&(d=g);D.close(e);return d},writeFile:(a,c,d={})=>{d.flags=d.flags||577;a=D.open(a,d.flags,d.mode);if("string"==typeof c){var e=new Uint8Array(Aa(c)+1);c=za(c,e,0,e.length);D.write(a,e,0,c,void 0,d.Nh)}else if(ArrayBuffer.isView(c))D.write(a, +c,0,c.byteLength,void 0,d.Nh);else throw Error("Unsupported data type");D.close(a)},cwd:()=>D.qh,chdir:a=>{a=D.Pf(a,{Xf:!0});if(null===a.node)throw new D.Jf(44);if(!D.Tf(a.node.mode))throw new D.Jf(54);var c=D.ng(a.node,"x");if(c)throw new D.Jf(c);D.qh=a.path},Rh:()=>{D.mkdir("/tmp");D.mkdir("/home");D.mkdir("/home/web_user")},Qh:()=>{D.mkdir("/dev");D.gh(D.kg(1,3),{read:()=>0,write:(c,d,e,g)=>g});D.Fg("/dev/null",D.kg(1,3));lb(D.kg(5,0),nb);lb(D.kg(6,0),ob);D.Fg("/dev/tty",D.kg(5,0));D.Fg("/dev/tty1", +D.kg(6,0));var a=gb();D.Wf("/dev","random",a);D.Wf("/dev","urandom",a);D.mkdir("/dev/shm");D.mkdir("/dev/shm/tmp")},Th:()=>{D.mkdir("/proc");var a=D.mkdir("/proc/self");D.mkdir("/proc/self/fd");D.Sf({Sf:()=>{var c=D.createNode(a,"fd",16895,73);c.Kf={lookup:(d,e)=>{var g=D.gg(+e);if(!g)throw new D.Jf(8);d={parent:null,Sf:{Bh:"fake"},Kf:{readlink:()=>g.path}};return d.parent=d}};return c}},{},"/proc/self/fd")},Uh:()=>{b.stdin?D.Wf("/dev","stdin",b.stdin):D.symlink("/dev/tty","/dev/stdin");b.stdout? +D.Wf("/dev","stdout",null,b.stdout):D.symlink("/dev/tty","/dev/stdout");b.stderr?D.Wf("/dev","stderr",null,b.stderr):D.symlink("/dev/tty1","/dev/stderr");D.open("/dev/stdin",0);D.open("/dev/stdout",1);D.open("/dev/stderr",1)},sh:()=>{D.Jf||(D.Jf=function(a,c){this.node=c;this.Fi=function(d){this.Rf=d};this.Fi(a);this.message="FS error"},D.Jf.prototype=Error(),D.Jf.prototype.constructor=D.Jf,[44].forEach(a=>{D.Pg[a]=new D.Jf(a);D.Pg[a].stack=""}))},Gi:()=>{D.sh();D.$f=Array(4096); +D.Sf(E,{},"/");D.Rh();D.Qh();D.Th();D.Wh={MEMFS:E}},rg:(a,c,d)=>{D.rg.Xg=!0;D.sh();b.stdin=a||b.stdin;b.stdout=c||b.stdout;b.stderr=d||b.stderr;D.Uh()},Vi:()=>{D.rg.Xg=!1;for(var a=0;a{var d=0;a&&(d|=365);c&&(d|=146);return d},Mi:(a,c)=>{a=D.Kg(a,c);return a.exists?a.object:null},Kg:(a,c)=>{try{var d=D.Pf(a,{Xf:!c});a=d.path}catch(g){}var e={Dg:!1,exists:!1,error:0,name:null,path:null,object:null,Bi:!1,Di:null,Ci:null};try{d=D.Pf(a, +{parent:!0}),e.Bi=!0,e.Di=d.path,e.Ci=d.node,e.name=eb(a),d=D.Pf(a,{Xf:!c}),e.exists=!0,e.path=d.path,e.object=d.node,e.name=d.node.name,e.Dg="/"===d.path}catch(g){e.error=g.Rf}return e},Lg:(a,c)=>{a="string"==typeof a?a:D.fg(a);for(c=c.split("/").reverse();c.length;){var d=c.pop();if(d){var e=cb(a+"/"+d);try{D.mkdir(e)}catch(g){}a=e}}return e},Sh:(a,c,d,e,g)=>{a="string"==typeof a?a:D.fg(a);c=cb(a+"/"+c);return D.create(c,D.Qg(e,g))},wg:(a,c,d,e,g,h)=>{var k=c;a&&(a="string"==typeof a?a:D.fg(a), +k=c?cb(a+"/"+c):a);a=D.Qg(e,g);k=D.create(k,a);if(d){if("string"==typeof d){c=Array(d.length);e=0;for(g=d.length;e{a=fb("string"==typeof a?a:D.fg(a),c);c=D.Qg(!!d,!!e);D.Wf.ah||(D.Wf.ah=64);var g=D.kg(D.Wf.ah++,0);D.gh(g,{open:h=>{h.seekable=!1},close:()=>{e&&e.buffer&&e.buffer.length&&e(10)},read:(h,k,m,t)=>{for(var u=0,p=0;p{for(var u=0;u{if(a.Zg||a.vi||a.link||a.Lf)return!0;if("undefined"!=typeof XMLHttpRequest)throw Error("Lazy loading should have been performed (contents set) in createLazyFile, but it was not. Lazy loading only works in web workers. Use --embed-file or --preload-file in emcc on the main thread."); +if(ja)try{a.Lf=jb(ja(a.url),!0),a.Qf=a.Lf.length}catch(c){throw new D.Jf(29);}else throw Error("Cannot load without read() or XMLHttpRequest.");},nh:(a,c,d,e,g)=>{function h(){this.$g=!1;this.Vf=[]}function k(p,x,N,l,w){p=p.node.Lf;if(w>=p.length)return 0;l=Math.min(p.length-w,l);if(p.slice)for(var B=0;Bthis.length-1||0>p)){var x=p%this.chunkSize;return this.xh(p/this.chunkSize|0)[x]}};h.prototype.Jg= +function(p){this.xh=p};h.prototype.lh=function(){var p=new XMLHttpRequest;p.open("HEAD",d,!1);p.send(null);if(!(200<=p.status&&300>p.status||304===p.status))throw Error("Couldn't load "+d+". Status: "+p.status);var x=Number(p.getResponseHeader("Content-length")),N,l=(N=p.getResponseHeader("Accept-Ranges"))&&"bytes"===N;p=(N=p.getResponseHeader("Content-Encoding"))&&"gzip"===N;var w=1048576;l||(w=x);var B=this;B.Jg(U=>{var va=U*w,Ja=(U+1)*w-1;Ja=Math.min(Ja,x-1);if("undefined"==typeof B.Vf[U]){var Sh= +B.Vf;if(va>Ja)throw Error("invalid range ("+va+", "+Ja+") or no bytes requested!");if(Ja>x-1)throw Error("only "+x+" bytes available! programmer error!");var W=new XMLHttpRequest;W.open("GET",d,!1);x!==w&&W.setRequestHeader("Range","bytes="+va+"-"+Ja);W.responseType="arraybuffer";W.overrideMimeType&&W.overrideMimeType("text/plain; charset=x-user-defined");W.send(null);if(!(200<=W.status&&300>W.status||304===W.status))throw Error("Couldn't load "+d+". Status: "+W.status);va=void 0!==W.response?new Uint8Array(W.response|| +[]):jb(W.responseText||"",!0);Sh[U]=va}if("undefined"==typeof B.Vf[U])throw Error("doXHR failed!");return B.Vf[U]});if(p||!x)w=x=1,w=x=this.xh(0).length,qa("LazyFiles on gzip forces download of the whole file when length is accessed");this.Kh=x;this.Jh=w;this.$g=!0};if("undefined"!=typeof XMLHttpRequest){if(!ha)throw"Cannot do synchronous binary XHRs outside webworkers in modern browsers. Use --embed-file or --preload-file in emcc";var m=new h;Object.defineProperties(m,{length:{get:function(){this.$g|| +this.lh();return this.Kh}},chunkSize:{get:function(){this.$g||this.lh();return this.Jh}}});m={Zg:!1,Lf:m}}else m={Zg:!1,url:d};var t=D.Sh(a,c,m,e,g);m.Lf?t.Lf=m.Lf:m.url&&(t.Lf=null,t.url=m.url);Object.defineProperties(t,{Qf:{get:function(){return this.Lf.length}}});var u={};Object.keys(t.Mf).forEach(p=>{var x=t.Mf[p];u[p]=function(){D.Og(t);return x.apply(null,arguments)}});u.read=(p,x,N,l,w)=>{D.Og(t);return k(p,x,N,l,w)};u.lg=(p,x,N)=>{D.Og(t);var l=pb(x);if(!l)throw new D.Jf(48);k(p,r,l,x,N); +return{If:l,kh:!0}};t.Mf=u;return t},oh:(a,c,d,e,g,h,k,m,t,u)=>{function p(l){function w(B){u&&u();m||D.wg(a,c,B,e,g,t);h&&h();Ra(N)}sb.Pi(l,x,w,()=>{k&&k();Ra(N)})||w(l)}var x=c?hb(cb(a+"/"+c)):a,N="cp "+x;Qa(N);"string"==typeof d?rb(d,l=>p(l),k):p(d)},indexedDB:()=>window.indexedDB||window.mozIndexedDB||window.webkitIndexedDB||window.msIndexedDB,ih:()=>"EM_FS_"+window.location.pathname,jh:20,ug:"FILE_DATA",Wi:(a,c,d)=>{c=c||(()=>{});d=d||(()=>{});var e=D.indexedDB();try{var g=e.open(D.ih(),D.jh)}catch(h){return d(h)}g.onupgradeneeded= +()=>{qa("creating db");g.result.createObjectStore(D.ug)};g.onsuccess=()=>{var h=g.result.transaction([D.ug],"readwrite"),k=h.objectStore(D.ug),m=0,t=0,u=a.length;a.forEach(p=>{p=k.put(D.Kg(p).object.Lf,p);p.onsuccess=()=>{m++;m+t==u&&(0==t?c():d())};p.onerror=()=>{t++;m+t==u&&(0==t?c():d())}});h.onerror=d};g.onerror=d},Qi:(a,c,d)=>{c=c||(()=>{});d=d||(()=>{});var e=D.indexedDB();try{var g=e.open(D.ih(),D.jh)}catch(h){return d(h)}g.onupgradeneeded=d;g.onsuccess=()=>{var h=g.result;try{var k=h.transaction([D.ug], +"readonly")}catch(x){d(x);return}var m=k.objectStore(D.ug),t=0,u=0,p=a.length;a.forEach(x=>{var N=m.get(x);N.onsuccess=()=>{D.Kg(x).exists&&D.unlink(x);D.wg(db(x),eb(x),N.result,!0,!0,!0);t++;t+u==p&&(0==u?c():d())};N.onerror=()=>{u++;t+u==p&&(0==u?c():d())}});k.onerror=d};g.onerror=d}};function tb(a,c,d){if("/"===c.charAt(0))return c;if(-100===a)a=D.cwd();else{a=D.gg(a);if(!a)throw new D.Jf(8);a=a.path}if(0==c.length){if(!d)throw new D.Jf(44);return a}return cb(a+"/"+c)} +function ub(a,c,d){try{var e=a(c)}catch(g){if(g&&g.node&&cb(c)!==cb(D.fg(g.node)))return-54;throw g;}v[d>>2]=e.dev;v[d+8>>2]=e.ino;v[d+12>>2]=e.mode;v[d+16>>2]=e.nlink;v[d+20>>2]=e.uid;v[d+24>>2]=e.gid;v[d+28>>2]=e.rdev;C=[e.size>>>0,(A=e.size,1<=+Math.abs(A)?0>>0:~~+Math.ceil((A-+(~~A>>>0))/4294967296)>>>0:0)];v[d+40>>2]=C[0];v[d+44>>2]=C[1];v[d+48>>2]=4096;v[d+52>>2]=e.blocks;C=[Math.floor(e.atime.getTime()/1E3)>>>0,(A=Math.floor(e.atime.getTime()/ +1E3),1<=+Math.abs(A)?0>>0:~~+Math.ceil((A-+(~~A>>>0))/4294967296)>>>0:0)];v[d+56>>2]=C[0];v[d+60>>2]=C[1];v[d+64>>2]=0;C=[Math.floor(e.mtime.getTime()/1E3)>>>0,(A=Math.floor(e.mtime.getTime()/1E3),1<=+Math.abs(A)?0>>0:~~+Math.ceil((A-+(~~A>>>0))/4294967296)>>>0:0)];v[d+72>>2]=C[0];v[d+76>>2]=C[1];v[d+80>>2]=0;C=[Math.floor(e.ctime.getTime()/1E3)>>>0,(A=Math.floor(e.ctime.getTime()/1E3),1<=+Math.abs(A)? +0>>0:~~+Math.ceil((A-+(~~A>>>0))/4294967296)>>>0:0)];v[d+88>>2]=C[0];v[d+92>>2]=C[1];v[d+96>>2]=0;C=[e.ino>>>0,(A=e.ino,1<=+Math.abs(A)?0>>0:~~+Math.ceil((A-+(~~A>>>0))/4294967296)>>>0:0)];v[d+104>>2]=C[0];v[d+108>>2]=C[1];return 0}var vb=void 0;function wb(){vb+=4;return v[vb-4>>2]}function xb(a){a=D.gg(a);if(!a)throw new D.Jf(8);return a} +function yb(a){var c=Aa(a)+1,d=zb(c);d&&za(a,r,d,c);return d}function Ab(a,c,d){function e(t){return(t=t.toTimeString().match(/\(([A-Za-z ]+)\)$/))?t[1]:"GMT"}var g=(new Date).getFullYear(),h=new Date(g,0,1),k=new Date(g,6,1);g=h.getTimezoneOffset();var m=k.getTimezoneOffset();v[a>>2]=60*Math.max(g,m);v[c>>2]=Number(g!=m);a=e(h);c=e(k);a=yb(a);c=yb(c);m>2]=a,y[d+4>>2]=c):(y[d>>2]=c,y[d+4>>2]=a)}function Bb(a,c,d){Bb.Mh||(Bb.Mh=!0,Ab(a,c,d))}var Cb=[],Db; +Db=ia?()=>{var a=process.hrtime();return 1E3*a[0]+a[1]/1E6}:()=>performance.now();var Eb={};function Fb(){if(!Gb){var a={USER:"web_user",LOGNAME:"web_user",PATH:"/",PWD:"/",HOME:"/home/web_user",LANG:("object"==typeof navigator&&navigator.languages&&navigator.languages[0]||"C").replace("-","_")+".UTF-8",_:da||"./this.program"},c;for(c in Eb)void 0===Eb[c]?delete a[c]:a[c]=Eb[c];var d=[];for(c in a)d.push(c+"="+a[c]);Gb=d}return Gb}var Gb;function Hb(a){return 0===a%4&&(0!==a%100||0===a%400)} +var Ib=[31,29,31,30,31,30,31,31,30,31,30,31],Jb=[31,28,31,30,31,30,31,31,30,31,30,31]; +function Kb(a,c,d,e){function g(l,w,B){for(l="number"==typeof l?l.toString():l||"";l.lengthva?-1:0U-l.getDate())w-=U-l.getDate()+1,l.setDate(1),11>B?l.setMonth(B+1):(l.setMonth(0),l.setFullYear(l.getFullYear()+1));else{l.setDate(l.getDate()+w);break}}B=new Date(l.getFullYear()+1,0,4);w=m(new Date(l.getFullYear(), +0,4));B=m(B);return 0>=k(w,l)?0>=k(B,l)?l.getFullYear()+1:l.getFullYear():l.getFullYear()-1}var u=v[e+40>>2];e={Ji:v[e>>2],Ii:v[e+4>>2],Hg:v[e+8>>2],hh:v[e+12>>2],Ig:v[e+16>>2],qg:v[e+20>>2],bg:v[e+24>>2],pg:v[e+28>>2],Xi:v[e+32>>2],Hi:v[e+36>>2],Ki:u?q(u):""};d=q(d);u={"%c":"%a %b %d %H:%M:%S %Y","%D":"%m/%d/%y","%F":"%Y-%m-%d","%h":"%b","%r":"%I:%M:%S %p","%R":"%H:%M","%T":"%H:%M:%S","%x":"%m/%d/%y","%X":"%H:%M:%S","%Ec":"%c","%EC":"%C","%Ex":"%m/%d/%y","%EX":"%H:%M:%S","%Ey":"%y","%EY":"%Y","%Od":"%d", +"%Oe":"%e","%OH":"%H","%OI":"%I","%Om":"%m","%OM":"%M","%OS":"%S","%Ou":"%u","%OU":"%U","%OV":"%V","%Ow":"%w","%OW":"%W","%Oy":"%y"};for(var p in u)d=d.replace(new RegExp(p,"g"),u[p]);var x="Sunday Monday Tuesday Wednesday Thursday Friday Saturday".split(" "),N="January February March April May June July August September October November December".split(" ");u={"%a":function(l){return x[l.bg].substring(0,3)},"%A":function(l){return x[l.bg]},"%b":function(l){return N[l.Ig].substring(0,3)},"%B":function(l){return N[l.Ig]}, +"%C":function(l){return h((l.qg+1900)/100|0,2)},"%d":function(l){return h(l.hh,2)},"%e":function(l){return g(l.hh,2," ")},"%g":function(l){return t(l).toString().substring(2)},"%G":function(l){return t(l)},"%H":function(l){return h(l.Hg,2)},"%I":function(l){l=l.Hg;0==l?l=12:12l.Hg?"AM":"PM"},"%S":function(l){return h(l.Ji,2)},"%t":function(){return"\t"},"%u":function(l){return l.bg||7},"%U":function(l){return h(Math.floor((l.pg+7-l.bg)/7),2)},"%V":function(l){var w=Math.floor((l.pg+7-(l.bg+6)%7)/7);2>=(l.bg+371-l.pg-2)%7&&w++;if(w)53==w&&(B=(l.bg+371-l.pg)%7,4==B||3==B&&Hb(l.qg)||(w=1));else{w=52;var B=(l.bg+7-l.pg-1)%7;(4==B||5==B&&Hb(l.qg%400-1))&&w++}return h(w,2)},"%w":function(l){return l.bg},"%W":function(l){return h(Math.floor((l.pg+7-(l.bg+6)%7)/7),2)}, +"%y":function(l){return(l.qg+1900).toString().substring(2)},"%Y":function(l){return l.qg+1900},"%z":function(l){l=l.Hi;var w=0<=l;l=Math.abs(l)/60;return(w?"+":"-")+String("0000"+(l/60*100+l%60)).slice(-4)},"%Z":function(l){return l.Ki},"%%":function(){return"%"}};d=d.replace(/%%/g,"\x00\x00");for(p in u)d.includes(p)&&(d=d.replace(new RegExp(p,"g"),u[p](e)));d=d.replace(/\0\0/g,"%");p=jb(d,!1);if(p.length>c)return 0;r.set(p,a);return p.length-1}var Lb=[]; +function Mb(a){var c=Lb[a];c||(a>=Lb.length&&(Lb.length=a+1),Lb[a]=c=Ga.get(a));return c}function Nb(a,c,d,e){a||(a=this);this.parent=a;this.Sf=a.Sf;this.zg=null;this.id=D.zi++;this.name=c;this.mode=d;this.Kf={};this.Mf={};this.rdev=e} +Object.defineProperties(Nb.prototype,{read:{get:function(){return 365===(this.mode&365)},set:function(a){a?this.mode|=365:this.mode&=-366}},write:{get:function(){return 146===(this.mode&146)},set:function(a){a?this.mode|=146:this.mode&=-147}},vi:{get:function(){return D.Tf(this.mode)}},Zg:{get:function(){return D.Cg(this.mode)}}});D.Dh=Nb;D.Gi();var sb;b.FS_createPath=D.Lg;b.FS_createDataFile=D.wg;b.FS_createPreloadedFile=D.oh;b.FS_unlink=D.unlink;b.FS_createLazyFile=D.nh;b.FS_createDevice=D.Wf; +var $b={c:function(a,c,d,e){n("Assertion failed: "+q(a)+", at: "+[c?q(c):"unknown filename",d,e?q(e):"unknown function"])},q:function(a){return zb(a+24)+24},p:function(a,c,d){(new $a(a)).rg(c,d);ab++;throw a;},w:function(a,c,d){vb=d;try{var e=xb(a);switch(c){case 0:var g=wb();return 0>g?-28:D.ph(e,g).fd;case 1:case 2:return 0;case 3:return e.flags;case 4:return g=wb(),e.flags|=g,0;case 5:return g=wb(),Ca[g+0>>1]=2,0;case 6:case 7:return 0;case 16:case 8:return-28;case 9:return v[Ob()>>2]=28,-1;default:return-28}}catch(h){if("undefined"== +typeof D||!(h instanceof D.Jf))throw h;return-h.Rf}},M:function(a,c){try{var d=xb(a);return ub(D.stat,d.path,c)}catch(e){if("undefined"==typeof D||!(e instanceof D.Jf))throw e;return-e.Rf}},J:function(a,c){try{if(0===c)return-28;var d=D.cwd(),e=Aa(d)+1;if(c>2]=0;case 21520:return e.tty?-28:-59;case 21531:return g=wb(),D.Yg(e,c,g);case 21523:return e.tty?0:-59;case 21524:return e.tty?0:-59;default:return-28}}catch(h){if("undefined"==typeof D||!(h instanceof D.Jf))throw h;return-h.Rf}},K:function(a,c,d,e){try{c=q(c);var g=e&256;c=tb(a,c,e&4096);return ub(g?D.lstat:D.stat,c,d)}catch(h){if("undefined"==typeof D||!(h instanceof D.Jf))throw h;return-h.Rf}},u:function(a,c,d,e){vb=e;try{c=q(c);c=tb(a, +c);var g=e?wb():0;return D.open(c,d,g).fd}catch(h){if("undefined"==typeof D||!(h instanceof D.Jf))throw h;return-h.Rf}},D:function(a){try{return a=q(a),D.rmdir(a),0}catch(c){if("undefined"==typeof D||!(c instanceof D.Jf))throw c;return-c.Rf}},L:function(a,c){try{return a=q(a),ub(D.stat,a,c)}catch(d){if("undefined"==typeof D||!(d instanceof D.Jf))throw d;return-d.Rf}},E:function(a,c,d){try{return c=q(c),c=tb(a,c),0===d?D.unlink(c):512===d?D.rmdir(c):n("Invalid flags passed to unlinkat"),0}catch(e){if("undefined"== +typeof D||!(e instanceof D.Jf))throw e;return-e.Rf}},o:function(){return Date.now()},V:function(a){do{var c=y[a>>2];a+=4;var d=y[a>>2];a+=4;var e=y[a>>2];a+=4;c=q(c);D.Lg("/",db(c),!0,!0);D.wg(c,null,r.subarray(e,e+d),!0,!0,!0)}while(y[a>>2])},O:function(){return!0},B:function(){throw Infinity;},P:function(a,c){a=new Date(1E3*(y[a>>2]+4294967296*v[a+4>>2]));v[c>>2]=a.getUTCSeconds();v[c+4>>2]=a.getUTCMinutes();v[c+8>>2]=a.getUTCHours();v[c+12>>2]=a.getUTCDate();v[c+16>>2]=a.getUTCMonth();v[c+20>> +2]=a.getUTCFullYear()-1900;v[c+24>>2]=a.getUTCDay();v[c+28>>2]=(a.getTime()-Date.UTC(a.getUTCFullYear(),0,1,0,0,0,0))/864E5|0},Q:function(a,c){a=new Date(1E3*(y[a>>2]+4294967296*v[a+4>>2]));v[c>>2]=a.getSeconds();v[c+4>>2]=a.getMinutes();v[c+8>>2]=a.getHours();v[c+12>>2]=a.getDate();v[c+16>>2]=a.getMonth();v[c+20>>2]=a.getFullYear()-1900;v[c+24>>2]=a.getDay();var d=new Date(a.getFullYear(),0,1);v[c+28>>2]=(a.getTime()-d.getTime())/864E5|0;v[c+36>>2]=-(60*a.getTimezoneOffset());var e=(new Date(a.getFullYear(), +6,1)).getTimezoneOffset();d=d.getTimezoneOffset();v[c+32>>2]=(e!=d&&a.getTimezoneOffset()==Math.min(d,e))|0},R:function(a){var c=new Date(v[a+20>>2]+1900,v[a+16>>2],v[a+12>>2],v[a+8>>2],v[a+4>>2],v[a>>2],0),d=v[a+32>>2],e=c.getTimezoneOffset(),g=new Date(c.getFullYear(),0,1),h=(new Date(c.getFullYear(),6,1)).getTimezoneOffset(),k=g.getTimezoneOffset(),m=Math.min(k,h);0>d?v[a+32>>2]=Number(h!=k&&m==e):0>2]=c.getDay();v[a+ +28>>2]=(c.getTime()-g.getTime())/864E5|0;v[a>>2]=c.getSeconds();v[a+4>>2]=c.getMinutes();v[a+8>>2]=c.getHours();v[a+12>>2]=c.getDate();v[a+16>>2]=c.getMonth();return c.getTime()/1E3|0},F:function(a,c,d,e,g,h){try{var k=D.gg(e);if(!k)return-8;var m=D.lg(k,a,g,c,d),t=m.If;v[h>>2]=m.kh;return t}catch(u){if("undefined"==typeof D||!(u instanceof D.Jf))throw u;return-u.Rf}},G:function(a,c,d,e,g,h){try{var k=D.gg(g);if(k&&d&2){var m=ya.slice(a,a+c);D.sg(k,m,h,c,e)}}catch(t){if("undefined"==typeof D||!(t instanceof +D.Jf))throw t;return-t.Rf}},S:Bb,n:function(){n("")},t:function(a,c,d){Cb.length=0;var e;for(d>>=2;e=ya[c++];)d+=105!=e&d,Cb.push(105==e?v[d]:Ea[d++>>1]),++d;return Wa[a].apply(null,Cb)},N:Db,T:function(a,c,d){ya.copyWithin(a,c,c+d)},C:function(a){var c=ya.length;a>>>=0;if(2147483648=d;d*=2){var e=c*(1+.2/d);e=Math.min(e,a+100663296);var g=Math;e=Math.max(a,e);g=g.min.call(g,2147483648,e+(65536-e%65536)%65536);a:{try{ta.grow(g-Ba.byteLength+65535>>>16);Fa();var h=1;break a}catch(k){}h= +void 0}if(h)return!0}return!1},H:function(a,c){var d=0;Fb().forEach(function(e,g){var h=c+d;g=y[a+4*g>>2]=h;for(h=0;h>0]=e.charCodeAt(h);r[g>>0]=0;d+=e.length+1});return 0},I:function(a,c){var d=Fb();y[a>>2]=d.length;var e=0;d.forEach(function(g){e+=g.length+1});y[c>>2]=e;return 0},m:function(a){if(!noExitRuntime){if(b.onExit)b.onExit(a);ua=!0}ea(a,new oa(a))},s:function(a){try{var c=xb(a);D.close(c);return 0}catch(d){if("undefined"==typeof D||!(d instanceof D.Jf))throw d;return d.Rf}}, +v:function(a,c,d,e){try{a:{var g=xb(a);a=c;for(var h=c=0;h>2],m=y[a+4>>2];a+=8;var t=D.read(g,r,k,m,void 0);if(0>t){var u=-1;break a}c+=t;if(t>2]=u;return 0}catch(p){if("undefined"==typeof D||!(p instanceof D.Jf))throw p;return p.Rf}},z:function(a,c,d,e,g){try{c=d+2097152>>>0<4194305-!!c?(c>>>0)+4294967296*d:NaN;if(isNaN(c))return 61;var h=xb(a);D.Zf(h,c,e);C=[h.position>>>0,(A=h.position,1<=+Math.abs(A)?0>>0: +~~+Math.ceil((A-+(~~A>>>0))/4294967296)>>>0:0)];v[g>>2]=C[0];v[g+4>>2]=C[1];h.Vg&&0===c&&0===e&&(h.Vg=null);return 0}catch(k){if("undefined"==typeof D||!(k instanceof D.Jf))throw k;return k.Rf}},r:function(a,c,d,e){try{a:{var g=xb(a);a=c;for(var h=c=0;h>2],m=y[a+4>>2];a+=8;var t=D.write(g,r,k,m,void 0);if(0>t){var u=-1;break a}c+=t}u=c}y[e>>2]=u;return 0}catch(p){if("undefined"==typeof D||!(p instanceof D.Jf))throw p;return p.Rf}},a:function(){return ra},e:Pb,h:Qb,d:Rb,j:Sb,k:Tb, +g:Ub,f:Vb,i:Wb,l:Xb,x:Yb,y:Zb,b:function(a){ra=a},W:Kb,A:function(a,c,d,e){return Kb(a,c,d,e)}}; +(function(){function a(g){b.asm=g.exports;ta=b.asm.X;Fa();Ga=b.asm.tf;Ia.unshift(b.asm.Y);Ra("wasm-instantiate")}function c(g){a(g.instance)}function d(g){return Va().then(function(h){return WebAssembly.instantiate(h,e)}).then(function(h){return h}).then(g,function(h){pa("failed to asynchronously prepare wasm: "+h);n(h)})}var e={a:$b};Qa("wasm-instantiate");if(b.instantiateWasm)try{return b.instantiateWasm(e,a)}catch(g){return pa("Module.instantiateWasm callback failed with error: "+g),!1}(function(){return sa|| +"function"!=typeof WebAssembly.instantiateStreaming||Sa()||z.startsWith("file://")||ia||"function"!=typeof fetch?d(c):fetch(z,{credentials:"same-origin"}).then(function(g){return WebAssembly.instantiateStreaming(g,e).then(c,function(h){pa("wasm streaming compile failed: "+h);pa("falling back to ArrayBuffer instantiation");return d(c)})})})().catch(ba);return{}})();b.___wasm_call_ctors=function(){return(b.___wasm_call_ctors=b.asm.Y).apply(null,arguments)}; +var ac=b._emscripten_bind_ParagraphJustification___destroy___0=function(){return(ac=b._emscripten_bind_ParagraphJustification___destroy___0=b.asm.Z).apply(null,arguments)},bc=b._emscripten_bind_BoolPtr___destroy___0=function(){return(bc=b._emscripten_bind_BoolPtr___destroy___0=b.asm._).apply(null,arguments)},cc=b._emscripten_bind_TessResultRenderer_BeginDocument_1=function(){return(cc=b._emscripten_bind_TessResultRenderer_BeginDocument_1=b.asm.$).apply(null,arguments)},dc=b._emscripten_bind_TessResultRenderer_AddImage_1= +function(){return(dc=b._emscripten_bind_TessResultRenderer_AddImage_1=b.asm.aa).apply(null,arguments)},ec=b._emscripten_bind_TessResultRenderer_EndDocument_0=function(){return(ec=b._emscripten_bind_TessResultRenderer_EndDocument_0=b.asm.ba).apply(null,arguments)},fc=b._emscripten_bind_TessResultRenderer_happy_0=function(){return(fc=b._emscripten_bind_TessResultRenderer_happy_0=b.asm.ca).apply(null,arguments)},gc=b._emscripten_bind_TessResultRenderer_file_extension_0=function(){return(gc=b._emscripten_bind_TessResultRenderer_file_extension_0= +b.asm.da).apply(null,arguments)},hc=b._emscripten_bind_TessResultRenderer_title_0=function(){return(hc=b._emscripten_bind_TessResultRenderer_title_0=b.asm.ea).apply(null,arguments)},ic=b._emscripten_bind_TessResultRenderer_imagenum_0=function(){return(ic=b._emscripten_bind_TessResultRenderer_imagenum_0=b.asm.fa).apply(null,arguments)},jc=b._emscripten_bind_TessResultRenderer___destroy___0=function(){return(jc=b._emscripten_bind_TessResultRenderer___destroy___0=b.asm.ga).apply(null,arguments)},kc= +b._emscripten_bind_LongStarPtr___destroy___0=function(){return(kc=b._emscripten_bind_LongStarPtr___destroy___0=b.asm.ha).apply(null,arguments)},lc=b._emscripten_bind_VoidPtr___destroy___0=function(){return(lc=b._emscripten_bind_VoidPtr___destroy___0=b.asm.ia).apply(null,arguments)},mc=b._emscripten_bind_ResultIterator_ResultIterator_1=function(){return(mc=b._emscripten_bind_ResultIterator_ResultIterator_1=b.asm.ja).apply(null,arguments)},nc=b._emscripten_bind_ResultIterator_Begin_0=function(){return(nc= +b._emscripten_bind_ResultIterator_Begin_0=b.asm.ka).apply(null,arguments)},oc=b._emscripten_bind_ResultIterator_RestartParagraph_0=function(){return(oc=b._emscripten_bind_ResultIterator_RestartParagraph_0=b.asm.la).apply(null,arguments)},pc=b._emscripten_bind_ResultIterator_IsWithinFirstTextlineOfParagraph_0=function(){return(pc=b._emscripten_bind_ResultIterator_IsWithinFirstTextlineOfParagraph_0=b.asm.ma).apply(null,arguments)},qc=b._emscripten_bind_ResultIterator_RestartRow_0=function(){return(qc= +b._emscripten_bind_ResultIterator_RestartRow_0=b.asm.na).apply(null,arguments)},rc=b._emscripten_bind_ResultIterator_Next_1=function(){return(rc=b._emscripten_bind_ResultIterator_Next_1=b.asm.oa).apply(null,arguments)},sc=b._emscripten_bind_ResultIterator_IsAtBeginningOf_1=function(){return(sc=b._emscripten_bind_ResultIterator_IsAtBeginningOf_1=b.asm.pa).apply(null,arguments)},tc=b._emscripten_bind_ResultIterator_IsAtFinalElement_2=function(){return(tc=b._emscripten_bind_ResultIterator_IsAtFinalElement_2= +b.asm.qa).apply(null,arguments)},uc=b._emscripten_bind_ResultIterator_Cmp_1=function(){return(uc=b._emscripten_bind_ResultIterator_Cmp_1=b.asm.ra).apply(null,arguments)},vc=b._emscripten_bind_ResultIterator_SetBoundingBoxComponents_2=function(){return(vc=b._emscripten_bind_ResultIterator_SetBoundingBoxComponents_2=b.asm.sa).apply(null,arguments)},wc=b._emscripten_bind_ResultIterator_BoundingBox_5=function(){return(wc=b._emscripten_bind_ResultIterator_BoundingBox_5=b.asm.ta).apply(null,arguments)}, +xc=b._emscripten_bind_ResultIterator_BoundingBox_6=function(){return(xc=b._emscripten_bind_ResultIterator_BoundingBox_6=b.asm.ua).apply(null,arguments)},yc=b._emscripten_bind_ResultIterator_BoundingBoxInternal_5=function(){return(yc=b._emscripten_bind_ResultIterator_BoundingBoxInternal_5=b.asm.va).apply(null,arguments)},zc=b._emscripten_bind_ResultIterator_Empty_1=function(){return(zc=b._emscripten_bind_ResultIterator_Empty_1=b.asm.wa).apply(null,arguments)},Ac=b._emscripten_bind_ResultIterator_BlockType_0= +function(){return(Ac=b._emscripten_bind_ResultIterator_BlockType_0=b.asm.xa).apply(null,arguments)},Bc=b._emscripten_bind_ResultIterator_BlockPolygon_0=function(){return(Bc=b._emscripten_bind_ResultIterator_BlockPolygon_0=b.asm.ya).apply(null,arguments)},Cc=b._emscripten_bind_ResultIterator_GetBinaryImage_1=function(){return(Cc=b._emscripten_bind_ResultIterator_GetBinaryImage_1=b.asm.za).apply(null,arguments)},Dc=b._emscripten_bind_ResultIterator_GetImage_5=function(){return(Dc=b._emscripten_bind_ResultIterator_GetImage_5= +b.asm.Aa).apply(null,arguments)},Ec=b._emscripten_bind_ResultIterator_Baseline_5=function(){return(Ec=b._emscripten_bind_ResultIterator_Baseline_5=b.asm.Ba).apply(null,arguments)},Fc=b._emscripten_bind_ResultIterator_Orientation_4=function(){return(Fc=b._emscripten_bind_ResultIterator_Orientation_4=b.asm.Ca).apply(null,arguments)},Gc=b._emscripten_bind_ResultIterator_ParagraphInfo_4=function(){return(Gc=b._emscripten_bind_ResultIterator_ParagraphInfo_4=b.asm.Da).apply(null,arguments)},Hc=b._emscripten_bind_ResultIterator_ParagraphIsLtr_0= +function(){return(Hc=b._emscripten_bind_ResultIterator_ParagraphIsLtr_0=b.asm.Ea).apply(null,arguments)},Ic=b._emscripten_bind_ResultIterator_GetUTF8Text_1=function(){return(Ic=b._emscripten_bind_ResultIterator_GetUTF8Text_1=b.asm.Fa).apply(null,arguments)},Jc=b._emscripten_bind_ResultIterator_SetLineSeparator_1=function(){return(Jc=b._emscripten_bind_ResultIterator_SetLineSeparator_1=b.asm.Ga).apply(null,arguments)},Kc=b._emscripten_bind_ResultIterator_SetParagraphSeparator_1=function(){return(Kc= +b._emscripten_bind_ResultIterator_SetParagraphSeparator_1=b.asm.Ha).apply(null,arguments)},Lc=b._emscripten_bind_ResultIterator_Confidence_1=function(){return(Lc=b._emscripten_bind_ResultIterator_Confidence_1=b.asm.Ia).apply(null,arguments)},Mc=b._emscripten_bind_ResultIterator_WordFontAttributes_8=function(){return(Mc=b._emscripten_bind_ResultIterator_WordFontAttributes_8=b.asm.Ja).apply(null,arguments)},Nc=b._emscripten_bind_ResultIterator_WordRecognitionLanguage_0=function(){return(Nc=b._emscripten_bind_ResultIterator_WordRecognitionLanguage_0= +b.asm.Ka).apply(null,arguments)},Oc=b._emscripten_bind_ResultIterator_WordDirection_0=function(){return(Oc=b._emscripten_bind_ResultIterator_WordDirection_0=b.asm.La).apply(null,arguments)},Pc=b._emscripten_bind_ResultIterator_WordIsFromDictionary_0=function(){return(Pc=b._emscripten_bind_ResultIterator_WordIsFromDictionary_0=b.asm.Ma).apply(null,arguments)},Qc=b._emscripten_bind_ResultIterator_WordIsNumeric_0=function(){return(Qc=b._emscripten_bind_ResultIterator_WordIsNumeric_0=b.asm.Na).apply(null, +arguments)},Rc=b._emscripten_bind_ResultIterator_HasBlamerInfo_0=function(){return(Rc=b._emscripten_bind_ResultIterator_HasBlamerInfo_0=b.asm.Oa).apply(null,arguments)},Sc=b._emscripten_bind_ResultIterator_HasTruthString_0=function(){return(Sc=b._emscripten_bind_ResultIterator_HasTruthString_0=b.asm.Pa).apply(null,arguments)},Tc=b._emscripten_bind_ResultIterator_EquivalentToTruth_1=function(){return(Tc=b._emscripten_bind_ResultIterator_EquivalentToTruth_1=b.asm.Qa).apply(null,arguments)},Uc=b._emscripten_bind_ResultIterator_WordTruthUTF8Text_0= +function(){return(Uc=b._emscripten_bind_ResultIterator_WordTruthUTF8Text_0=b.asm.Ra).apply(null,arguments)},Vc=b._emscripten_bind_ResultIterator_WordNormedUTF8Text_0=function(){return(Vc=b._emscripten_bind_ResultIterator_WordNormedUTF8Text_0=b.asm.Sa).apply(null,arguments)},Wc=b._emscripten_bind_ResultIterator_WordLattice_1=function(){return(Wc=b._emscripten_bind_ResultIterator_WordLattice_1=b.asm.Ta).apply(null,arguments)},Xc=b._emscripten_bind_ResultIterator_SymbolIsSuperscript_0=function(){return(Xc= +b._emscripten_bind_ResultIterator_SymbolIsSuperscript_0=b.asm.Ua).apply(null,arguments)},Yc=b._emscripten_bind_ResultIterator_SymbolIsSubscript_0=function(){return(Yc=b._emscripten_bind_ResultIterator_SymbolIsSubscript_0=b.asm.Va).apply(null,arguments)},Zc=b._emscripten_bind_ResultIterator_SymbolIsDropcap_0=function(){return(Zc=b._emscripten_bind_ResultIterator_SymbolIsDropcap_0=b.asm.Wa).apply(null,arguments)},$c=b._emscripten_bind_ResultIterator___destroy___0=function(){return($c=b._emscripten_bind_ResultIterator___destroy___0= +b.asm.Xa).apply(null,arguments)},ad=b._emscripten_bind_TextlineOrder___destroy___0=function(){return(ad=b._emscripten_bind_TextlineOrder___destroy___0=b.asm.Ya).apply(null,arguments)},bd=b._emscripten_bind_ETEXT_DESC___destroy___0=function(){return(bd=b._emscripten_bind_ETEXT_DESC___destroy___0=b.asm.Za).apply(null,arguments)},cd=b._emscripten_bind_PageIterator_Begin_0=function(){return(cd=b._emscripten_bind_PageIterator_Begin_0=b.asm._a).apply(null,arguments)},dd=b._emscripten_bind_PageIterator_RestartParagraph_0= +function(){return(dd=b._emscripten_bind_PageIterator_RestartParagraph_0=b.asm.$a).apply(null,arguments)},ed=b._emscripten_bind_PageIterator_IsWithinFirstTextlineOfParagraph_0=function(){return(ed=b._emscripten_bind_PageIterator_IsWithinFirstTextlineOfParagraph_0=b.asm.ab).apply(null,arguments)},fd=b._emscripten_bind_PageIterator_RestartRow_0=function(){return(fd=b._emscripten_bind_PageIterator_RestartRow_0=b.asm.bb).apply(null,arguments)},gd=b._emscripten_bind_PageIterator_Next_1=function(){return(gd= +b._emscripten_bind_PageIterator_Next_1=b.asm.cb).apply(null,arguments)},hd=b._emscripten_bind_PageIterator_IsAtBeginningOf_1=function(){return(hd=b._emscripten_bind_PageIterator_IsAtBeginningOf_1=b.asm.db).apply(null,arguments)},jd=b._emscripten_bind_PageIterator_IsAtFinalElement_2=function(){return(jd=b._emscripten_bind_PageIterator_IsAtFinalElement_2=b.asm.eb).apply(null,arguments)},kd=b._emscripten_bind_PageIterator_Cmp_1=function(){return(kd=b._emscripten_bind_PageIterator_Cmp_1=b.asm.fb).apply(null, +arguments)},ld=b._emscripten_bind_PageIterator_SetBoundingBoxComponents_2=function(){return(ld=b._emscripten_bind_PageIterator_SetBoundingBoxComponents_2=b.asm.gb).apply(null,arguments)},md=b._emscripten_bind_PageIterator_BoundingBox_5=function(){return(md=b._emscripten_bind_PageIterator_BoundingBox_5=b.asm.hb).apply(null,arguments)},nd=b._emscripten_bind_PageIterator_BoundingBox_6=function(){return(nd=b._emscripten_bind_PageIterator_BoundingBox_6=b.asm.ib).apply(null,arguments)},od=b._emscripten_bind_PageIterator_BoundingBoxInternal_5= +function(){return(od=b._emscripten_bind_PageIterator_BoundingBoxInternal_5=b.asm.jb).apply(null,arguments)},pd=b._emscripten_bind_PageIterator_Empty_1=function(){return(pd=b._emscripten_bind_PageIterator_Empty_1=b.asm.kb).apply(null,arguments)},qd=b._emscripten_bind_PageIterator_BlockType_0=function(){return(qd=b._emscripten_bind_PageIterator_BlockType_0=b.asm.lb).apply(null,arguments)},rd=b._emscripten_bind_PageIterator_BlockPolygon_0=function(){return(rd=b._emscripten_bind_PageIterator_BlockPolygon_0= +b.asm.mb).apply(null,arguments)},sd=b._emscripten_bind_PageIterator_GetBinaryImage_1=function(){return(sd=b._emscripten_bind_PageIterator_GetBinaryImage_1=b.asm.nb).apply(null,arguments)},td=b._emscripten_bind_PageIterator_GetImage_5=function(){return(td=b._emscripten_bind_PageIterator_GetImage_5=b.asm.ob).apply(null,arguments)},ud=b._emscripten_bind_PageIterator_Baseline_5=function(){return(ud=b._emscripten_bind_PageIterator_Baseline_5=b.asm.pb).apply(null,arguments)},vd=b._emscripten_bind_PageIterator_Orientation_4= +function(){return(vd=b._emscripten_bind_PageIterator_Orientation_4=b.asm.qb).apply(null,arguments)},wd=b._emscripten_bind_PageIterator_ParagraphInfo_4=function(){return(wd=b._emscripten_bind_PageIterator_ParagraphInfo_4=b.asm.rb).apply(null,arguments)},xd=b._emscripten_bind_PageIterator___destroy___0=function(){return(xd=b._emscripten_bind_PageIterator___destroy___0=b.asm.sb).apply(null,arguments)},yd=b._emscripten_bind_WritingDirection___destroy___0=function(){return(yd=b._emscripten_bind_WritingDirection___destroy___0= +b.asm.tb).apply(null,arguments)},zd=b._emscripten_bind_WordChoiceIterator_WordChoiceIterator_1=function(){return(zd=b._emscripten_bind_WordChoiceIterator_WordChoiceIterator_1=b.asm.ub).apply(null,arguments)},Ad=b._emscripten_bind_WordChoiceIterator_Next_0=function(){return(Ad=b._emscripten_bind_WordChoiceIterator_Next_0=b.asm.vb).apply(null,arguments)},Bd=b._emscripten_bind_WordChoiceIterator_GetUTF8Text_0=function(){return(Bd=b._emscripten_bind_WordChoiceIterator_GetUTF8Text_0=b.asm.wb).apply(null, +arguments)},Cd=b._emscripten_bind_WordChoiceIterator_Confidence_0=function(){return(Cd=b._emscripten_bind_WordChoiceIterator_Confidence_0=b.asm.xb).apply(null,arguments)},Dd=b._emscripten_bind_WordChoiceIterator___destroy___0=function(){return(Dd=b._emscripten_bind_WordChoiceIterator___destroy___0=b.asm.yb).apply(null,arguments)},Ed=b._emscripten_bind_Box_get_x_0=function(){return(Ed=b._emscripten_bind_Box_get_x_0=b.asm.zb).apply(null,arguments)},Fd=b._emscripten_bind_Box_get_y_0=function(){return(Fd= +b._emscripten_bind_Box_get_y_0=b.asm.Ab).apply(null,arguments)},Gd=b._emscripten_bind_Box_get_w_0=function(){return(Gd=b._emscripten_bind_Box_get_w_0=b.asm.Bb).apply(null,arguments)},Hd=b._emscripten_bind_Box_get_h_0=function(){return(Hd=b._emscripten_bind_Box_get_h_0=b.asm.Cb).apply(null,arguments)},Id=b._emscripten_bind_Box_get_refcount_0=function(){return(Id=b._emscripten_bind_Box_get_refcount_0=b.asm.Db).apply(null,arguments)},Jd=b._emscripten_bind_Box___destroy___0=function(){return(Jd=b._emscripten_bind_Box___destroy___0= +b.asm.Eb).apply(null,arguments)},Kd=b._emscripten_bind_TessPDFRenderer_TessPDFRenderer_3=function(){return(Kd=b._emscripten_bind_TessPDFRenderer_TessPDFRenderer_3=b.asm.Fb).apply(null,arguments)},Ld=b._emscripten_bind_TessPDFRenderer_BeginDocument_1=function(){return(Ld=b._emscripten_bind_TessPDFRenderer_BeginDocument_1=b.asm.Gb).apply(null,arguments)},Md=b._emscripten_bind_TessPDFRenderer_AddImage_1=function(){return(Md=b._emscripten_bind_TessPDFRenderer_AddImage_1=b.asm.Hb).apply(null,arguments)}, +Nd=b._emscripten_bind_TessPDFRenderer_EndDocument_0=function(){return(Nd=b._emscripten_bind_TessPDFRenderer_EndDocument_0=b.asm.Ib).apply(null,arguments)},Od=b._emscripten_bind_TessPDFRenderer_happy_0=function(){return(Od=b._emscripten_bind_TessPDFRenderer_happy_0=b.asm.Jb).apply(null,arguments)},Pd=b._emscripten_bind_TessPDFRenderer_file_extension_0=function(){return(Pd=b._emscripten_bind_TessPDFRenderer_file_extension_0=b.asm.Kb).apply(null,arguments)},Qd=b._emscripten_bind_TessPDFRenderer_title_0= +function(){return(Qd=b._emscripten_bind_TessPDFRenderer_title_0=b.asm.Lb).apply(null,arguments)},Rd=b._emscripten_bind_TessPDFRenderer_imagenum_0=function(){return(Rd=b._emscripten_bind_TessPDFRenderer_imagenum_0=b.asm.Mb).apply(null,arguments)},Sd=b._emscripten_bind_TessPDFRenderer___destroy___0=function(){return(Sd=b._emscripten_bind_TessPDFRenderer___destroy___0=b.asm.Nb).apply(null,arguments)},Td=b._emscripten_bind_PixaPtr___destroy___0=function(){return(Td=b._emscripten_bind_PixaPtr___destroy___0= +b.asm.Ob).apply(null,arguments)},Ud=b._emscripten_bind_FloatPtr___destroy___0=function(){return(Ud=b._emscripten_bind_FloatPtr___destroy___0=b.asm.Pb).apply(null,arguments)},Vd=b._emscripten_bind_ChoiceIterator_ChoiceIterator_1=function(){return(Vd=b._emscripten_bind_ChoiceIterator_ChoiceIterator_1=b.asm.Qb).apply(null,arguments)},Wd=b._emscripten_bind_ChoiceIterator_Next_0=function(){return(Wd=b._emscripten_bind_ChoiceIterator_Next_0=b.asm.Rb).apply(null,arguments)},Xd=b._emscripten_bind_ChoiceIterator_GetUTF8Text_0= +function(){return(Xd=b._emscripten_bind_ChoiceIterator_GetUTF8Text_0=b.asm.Sb).apply(null,arguments)},Yd=b._emscripten_bind_ChoiceIterator_Confidence_0=function(){return(Yd=b._emscripten_bind_ChoiceIterator_Confidence_0=b.asm.Tb).apply(null,arguments)},Zd=b._emscripten_bind_ChoiceIterator___destroy___0=function(){return(Zd=b._emscripten_bind_ChoiceIterator___destroy___0=b.asm.Ub).apply(null,arguments)},$d=b._emscripten_bind_PixPtr___destroy___0=function(){return($d=b._emscripten_bind_PixPtr___destroy___0= +b.asm.Vb).apply(null,arguments)},ae=b._emscripten_bind_UNICHARSET_get_script_from_script_id_1=function(){return(ae=b._emscripten_bind_UNICHARSET_get_script_from_script_id_1=b.asm.Wb).apply(null,arguments)},be=b._emscripten_bind_UNICHARSET_get_script_id_from_name_1=function(){return(be=b._emscripten_bind_UNICHARSET_get_script_id_from_name_1=b.asm.Xb).apply(null,arguments)},ce=b._emscripten_bind_UNICHARSET_get_script_table_size_0=function(){return(ce=b._emscripten_bind_UNICHARSET_get_script_table_size_0= +b.asm.Yb).apply(null,arguments)},de=b._emscripten_bind_UNICHARSET___destroy___0=function(){return(de=b._emscripten_bind_UNICHARSET___destroy___0=b.asm.Zb).apply(null,arguments)},ee=b._emscripten_bind_IntPtr___destroy___0=function(){return(ee=b._emscripten_bind_IntPtr___destroy___0=b.asm._b).apply(null,arguments)},fe=b._emscripten_bind_Orientation___destroy___0=function(){return(fe=b._emscripten_bind_Orientation___destroy___0=b.asm.$b).apply(null,arguments)},ge=b._emscripten_bind_OSBestResult_get_orientation_id_0= +function(){return(ge=b._emscripten_bind_OSBestResult_get_orientation_id_0=b.asm.ac).apply(null,arguments)},he=b._emscripten_bind_OSBestResult_get_script_id_0=function(){return(he=b._emscripten_bind_OSBestResult_get_script_id_0=b.asm.bc).apply(null,arguments)},ie=b._emscripten_bind_OSBestResult_get_sconfidence_0=function(){return(ie=b._emscripten_bind_OSBestResult_get_sconfidence_0=b.asm.cc).apply(null,arguments)},je=b._emscripten_bind_OSBestResult_get_oconfidence_0=function(){return(je=b._emscripten_bind_OSBestResult_get_oconfidence_0= +b.asm.dc).apply(null,arguments)},ke=b._emscripten_bind_OSBestResult___destroy___0=function(){return(ke=b._emscripten_bind_OSBestResult___destroy___0=b.asm.ec).apply(null,arguments)},le=b._emscripten_bind_Boxa_get_n_0=function(){return(le=b._emscripten_bind_Boxa_get_n_0=b.asm.fc).apply(null,arguments)},me=b._emscripten_bind_Boxa_get_nalloc_0=function(){return(me=b._emscripten_bind_Boxa_get_nalloc_0=b.asm.gc).apply(null,arguments)},ne=b._emscripten_bind_Boxa_get_refcount_0=function(){return(ne=b._emscripten_bind_Boxa_get_refcount_0= +b.asm.hc).apply(null,arguments)},oe=b._emscripten_bind_Boxa_get_box_0=function(){return(oe=b._emscripten_bind_Boxa_get_box_0=b.asm.ic).apply(null,arguments)},pe=b._emscripten_bind_Boxa___destroy___0=function(){return(pe=b._emscripten_bind_Boxa___destroy___0=b.asm.jc).apply(null,arguments)},qe=b._emscripten_bind_PixColormap_get_array_0=function(){return(qe=b._emscripten_bind_PixColormap_get_array_0=b.asm.kc).apply(null,arguments)},re=b._emscripten_bind_PixColormap_get_depth_0=function(){return(re= +b._emscripten_bind_PixColormap_get_depth_0=b.asm.lc).apply(null,arguments)},se=b._emscripten_bind_PixColormap_get_nalloc_0=function(){return(se=b._emscripten_bind_PixColormap_get_nalloc_0=b.asm.mc).apply(null,arguments)},te=b._emscripten_bind_PixColormap_get_n_0=function(){return(te=b._emscripten_bind_PixColormap_get_n_0=b.asm.nc).apply(null,arguments)},ue=b._emscripten_bind_PixColormap___destroy___0=function(){return(ue=b._emscripten_bind_PixColormap___destroy___0=b.asm.oc).apply(null,arguments)}, +ve=b._emscripten_bind_Pta_get_n_0=function(){return(ve=b._emscripten_bind_Pta_get_n_0=b.asm.pc).apply(null,arguments)},we=b._emscripten_bind_Pta_get_nalloc_0=function(){return(we=b._emscripten_bind_Pta_get_nalloc_0=b.asm.qc).apply(null,arguments)},xe=b._emscripten_bind_Pta_get_refcount_0=function(){return(xe=b._emscripten_bind_Pta_get_refcount_0=b.asm.rc).apply(null,arguments)},ye=b._emscripten_bind_Pta_get_x_0=function(){return(ye=b._emscripten_bind_Pta_get_x_0=b.asm.sc).apply(null,arguments)},ze= +b._emscripten_bind_Pta_get_y_0=function(){return(ze=b._emscripten_bind_Pta_get_y_0=b.asm.tc).apply(null,arguments)},Ae=b._emscripten_bind_Pta___destroy___0=function(){return(Ae=b._emscripten_bind_Pta___destroy___0=b.asm.uc).apply(null,arguments)},Be=b._emscripten_bind_Pix_get_w_0=function(){return(Be=b._emscripten_bind_Pix_get_w_0=b.asm.vc).apply(null,arguments)},Ce=b._emscripten_bind_Pix_get_h_0=function(){return(Ce=b._emscripten_bind_Pix_get_h_0=b.asm.wc).apply(null,arguments)},De=b._emscripten_bind_Pix_get_d_0= +function(){return(De=b._emscripten_bind_Pix_get_d_0=b.asm.xc).apply(null,arguments)},Ee=b._emscripten_bind_Pix_get_spp_0=function(){return(Ee=b._emscripten_bind_Pix_get_spp_0=b.asm.yc).apply(null,arguments)},Fe=b._emscripten_bind_Pix_get_wpl_0=function(){return(Fe=b._emscripten_bind_Pix_get_wpl_0=b.asm.zc).apply(null,arguments)},Ge=b._emscripten_bind_Pix_get_refcount_0=function(){return(Ge=b._emscripten_bind_Pix_get_refcount_0=b.asm.Ac).apply(null,arguments)},He=b._emscripten_bind_Pix_get_xres_0= +function(){return(He=b._emscripten_bind_Pix_get_xres_0=b.asm.Bc).apply(null,arguments)},Ie=b._emscripten_bind_Pix_get_yres_0=function(){return(Ie=b._emscripten_bind_Pix_get_yres_0=b.asm.Cc).apply(null,arguments)},Je=b._emscripten_bind_Pix_get_informat_0=function(){return(Je=b._emscripten_bind_Pix_get_informat_0=b.asm.Dc).apply(null,arguments)},Ke=b._emscripten_bind_Pix_get_special_0=function(){return(Ke=b._emscripten_bind_Pix_get_special_0=b.asm.Ec).apply(null,arguments)},Le=b._emscripten_bind_Pix_get_text_0= +function(){return(Le=b._emscripten_bind_Pix_get_text_0=b.asm.Fc).apply(null,arguments)},Me=b._emscripten_bind_Pix_get_colormap_0=function(){return(Me=b._emscripten_bind_Pix_get_colormap_0=b.asm.Gc).apply(null,arguments)},Ne=b._emscripten_bind_Pix_get_data_0=function(){return(Ne=b._emscripten_bind_Pix_get_data_0=b.asm.Hc).apply(null,arguments)},Oe=b._emscripten_bind_Pix___destroy___0=function(){return(Oe=b._emscripten_bind_Pix___destroy___0=b.asm.Ic).apply(null,arguments)},Pe=b._emscripten_bind_DoublePtr___destroy___0= +function(){return(Pe=b._emscripten_bind_DoublePtr___destroy___0=b.asm.Jc).apply(null,arguments)},Qe=b._emscripten_bind_Dawg___destroy___0=function(){return(Qe=b._emscripten_bind_Dawg___destroy___0=b.asm.Kc).apply(null,arguments)},Re=b._emscripten_bind_BoxPtr___destroy___0=function(){return(Re=b._emscripten_bind_BoxPtr___destroy___0=b.asm.Lc).apply(null,arguments)},Se=b._emscripten_bind_TessBaseAPI_TessBaseAPI_0=function(){return(Se=b._emscripten_bind_TessBaseAPI_TessBaseAPI_0=b.asm.Mc).apply(null, +arguments)},Te=b._emscripten_bind_TessBaseAPI_Version_0=function(){return(Te=b._emscripten_bind_TessBaseAPI_Version_0=b.asm.Nc).apply(null,arguments)},Ue=b._emscripten_bind_TessBaseAPI_SetInputName_1=function(){return(Ue=b._emscripten_bind_TessBaseAPI_SetInputName_1=b.asm.Oc).apply(null,arguments)},Ve=b._emscripten_bind_TessBaseAPI_GetInputName_0=function(){return(Ve=b._emscripten_bind_TessBaseAPI_GetInputName_0=b.asm.Pc).apply(null,arguments)},We=b._emscripten_bind_TessBaseAPI_SetInputImage_1=function(){return(We= +b._emscripten_bind_TessBaseAPI_SetInputImage_1=b.asm.Qc).apply(null,arguments)},Xe=b._emscripten_bind_TessBaseAPI_GetInputImage_0=function(){return(Xe=b._emscripten_bind_TessBaseAPI_GetInputImage_0=b.asm.Rc).apply(null,arguments)},Ye=b._emscripten_bind_TessBaseAPI_GetSourceYResolution_0=function(){return(Ye=b._emscripten_bind_TessBaseAPI_GetSourceYResolution_0=b.asm.Sc).apply(null,arguments)},Ze=b._emscripten_bind_TessBaseAPI_GetDatapath_0=function(){return(Ze=b._emscripten_bind_TessBaseAPI_GetDatapath_0= +b.asm.Tc).apply(null,arguments)},$e=b._emscripten_bind_TessBaseAPI_SetOutputName_1=function(){return($e=b._emscripten_bind_TessBaseAPI_SetOutputName_1=b.asm.Uc).apply(null,arguments)},af=b._emscripten_bind_TessBaseAPI_SetVariable_2=function(){return(af=b._emscripten_bind_TessBaseAPI_SetVariable_2=b.asm.Vc).apply(null,arguments)},bf=b._emscripten_bind_TessBaseAPI_SetDebugVariable_2=function(){return(bf=b._emscripten_bind_TessBaseAPI_SetDebugVariable_2=b.asm.Wc).apply(null,arguments)},cf=b._emscripten_bind_TessBaseAPI_GetIntVariable_2= +function(){return(cf=b._emscripten_bind_TessBaseAPI_GetIntVariable_2=b.asm.Xc).apply(null,arguments)},df=b._emscripten_bind_TessBaseAPI_GetBoolVariable_2=function(){return(df=b._emscripten_bind_TessBaseAPI_GetBoolVariable_2=b.asm.Yc).apply(null,arguments)},ef=b._emscripten_bind_TessBaseAPI_GetDoubleVariable_2=function(){return(ef=b._emscripten_bind_TessBaseAPI_GetDoubleVariable_2=b.asm.Zc).apply(null,arguments)},ff=b._emscripten_bind_TessBaseAPI_GetStringVariable_1=function(){return(ff=b._emscripten_bind_TessBaseAPI_GetStringVariable_1= +b.asm._c).apply(null,arguments)},gf=b._emscripten_bind_TessBaseAPI_SaveParameters_1=function(){return(gf=b._emscripten_bind_TessBaseAPI_SaveParameters_1=b.asm.$c).apply(null,arguments)},hf=b._emscripten_bind_TessBaseAPI_RestoreParameters_1=function(){return(hf=b._emscripten_bind_TessBaseAPI_RestoreParameters_1=b.asm.ad).apply(null,arguments)},jf=b._emscripten_bind_TessBaseAPI_Init_2=function(){return(jf=b._emscripten_bind_TessBaseAPI_Init_2=b.asm.bd).apply(null,arguments)},kf=b._emscripten_bind_TessBaseAPI_Init_3= +function(){return(kf=b._emscripten_bind_TessBaseAPI_Init_3=b.asm.cd).apply(null,arguments)},lf=b._emscripten_bind_TessBaseAPI_Init_4=function(){return(lf=b._emscripten_bind_TessBaseAPI_Init_4=b.asm.dd).apply(null,arguments)},mf=b._emscripten_bind_TessBaseAPI_GetInitLanguagesAsString_0=function(){return(mf=b._emscripten_bind_TessBaseAPI_GetInitLanguagesAsString_0=b.asm.ed).apply(null,arguments)},nf=b._emscripten_bind_TessBaseAPI_InitForAnalysePage_0=function(){return(nf=b._emscripten_bind_TessBaseAPI_InitForAnalysePage_0= +b.asm.fd).apply(null,arguments)},of=b._emscripten_bind_TessBaseAPI_ReadConfigFile_1=function(){return(of=b._emscripten_bind_TessBaseAPI_ReadConfigFile_1=b.asm.gd).apply(null,arguments)},pf=b._emscripten_bind_TessBaseAPI_ReadDebugConfigFile_1=function(){return(pf=b._emscripten_bind_TessBaseAPI_ReadDebugConfigFile_1=b.asm.hd).apply(null,arguments)},qf=b._emscripten_bind_TessBaseAPI_SetPageSegMode_1=function(){return(qf=b._emscripten_bind_TessBaseAPI_SetPageSegMode_1=b.asm.id).apply(null,arguments)}, +rf=b._emscripten_bind_TessBaseAPI_GetPageSegMode_0=function(){return(rf=b._emscripten_bind_TessBaseAPI_GetPageSegMode_0=b.asm.jd).apply(null,arguments)},sf=b._emscripten_bind_TessBaseAPI_TesseractRect_7=function(){return(sf=b._emscripten_bind_TessBaseAPI_TesseractRect_7=b.asm.kd).apply(null,arguments)},tf=b._emscripten_bind_TessBaseAPI_ClearAdaptiveClassifier_0=function(){return(tf=b._emscripten_bind_TessBaseAPI_ClearAdaptiveClassifier_0=b.asm.ld).apply(null,arguments)},uf=b._emscripten_bind_TessBaseAPI_SetImage_1= +function(){return(uf=b._emscripten_bind_TessBaseAPI_SetImage_1=b.asm.md).apply(null,arguments)},vf=b._emscripten_bind_TessBaseAPI_SetImage_5=function(){return(vf=b._emscripten_bind_TessBaseAPI_SetImage_5=b.asm.nd).apply(null,arguments)},wf=b._emscripten_bind_TessBaseAPI_SetImageFile_1=function(){return(wf=b._emscripten_bind_TessBaseAPI_SetImageFile_1=b.asm.od).apply(null,arguments)},xf=b._emscripten_bind_TessBaseAPI_SetSourceResolution_1=function(){return(xf=b._emscripten_bind_TessBaseAPI_SetSourceResolution_1= +b.asm.pd).apply(null,arguments)},yf=b._emscripten_bind_TessBaseAPI_SetRectangle_4=function(){return(yf=b._emscripten_bind_TessBaseAPI_SetRectangle_4=b.asm.qd).apply(null,arguments)},zf=b._emscripten_bind_TessBaseAPI_GetThresholdedImage_0=function(){return(zf=b._emscripten_bind_TessBaseAPI_GetThresholdedImage_0=b.asm.rd).apply(null,arguments)},Af=b._emscripten_bind_TessBaseAPI_WriteImage_0=function(){return(Af=b._emscripten_bind_TessBaseAPI_WriteImage_0=b.asm.sd).apply(null,arguments)},Bf=b._emscripten_bind_TessBaseAPI_FindLines_0= +function(){return(Bf=b._emscripten_bind_TessBaseAPI_FindLines_0=b.asm.td).apply(null,arguments)},Cf=b._emscripten_bind_TessBaseAPI_GetGradient_0=function(){return(Cf=b._emscripten_bind_TessBaseAPI_GetGradient_0=b.asm.ud).apply(null,arguments)},Df=b._emscripten_bind_TessBaseAPI_GetRegions_1=function(){return(Df=b._emscripten_bind_TessBaseAPI_GetRegions_1=b.asm.vd).apply(null,arguments)},Ef=b._emscripten_bind_TessBaseAPI_GetTextlines_2=function(){return(Ef=b._emscripten_bind_TessBaseAPI_GetTextlines_2= +b.asm.wd).apply(null,arguments)},Ff=b._emscripten_bind_TessBaseAPI_GetTextlines_5=function(){return(Ff=b._emscripten_bind_TessBaseAPI_GetTextlines_5=b.asm.xd).apply(null,arguments)},Gf=b._emscripten_bind_TessBaseAPI_GetStrips_2=function(){return(Gf=b._emscripten_bind_TessBaseAPI_GetStrips_2=b.asm.yd).apply(null,arguments)},Hf=b._emscripten_bind_TessBaseAPI_GetWords_1=function(){return(Hf=b._emscripten_bind_TessBaseAPI_GetWords_1=b.asm.zd).apply(null,arguments)},If=b._emscripten_bind_TessBaseAPI_GetConnectedComponents_1= +function(){return(If=b._emscripten_bind_TessBaseAPI_GetConnectedComponents_1=b.asm.Ad).apply(null,arguments)},Jf=b._emscripten_bind_TessBaseAPI_GetComponentImages_4=function(){return(Jf=b._emscripten_bind_TessBaseAPI_GetComponentImages_4=b.asm.Bd).apply(null,arguments)},Kf=b._emscripten_bind_TessBaseAPI_GetComponentImages_7=function(){return(Kf=b._emscripten_bind_TessBaseAPI_GetComponentImages_7=b.asm.Cd).apply(null,arguments)},Lf=b._emscripten_bind_TessBaseAPI_GetThresholdedImageScaleFactor_0=function(){return(Lf= +b._emscripten_bind_TessBaseAPI_GetThresholdedImageScaleFactor_0=b.asm.Dd).apply(null,arguments)},Mf=b._emscripten_bind_TessBaseAPI_AnalyseLayout_0=function(){return(Mf=b._emscripten_bind_TessBaseAPI_AnalyseLayout_0=b.asm.Ed).apply(null,arguments)},Nf=b._emscripten_bind_TessBaseAPI_AnalyseLayout_1=function(){return(Nf=b._emscripten_bind_TessBaseAPI_AnalyseLayout_1=b.asm.Fd).apply(null,arguments)},Of=b._emscripten_bind_TessBaseAPI_Recognize_1=function(){return(Of=b._emscripten_bind_TessBaseAPI_Recognize_1= +b.asm.Gd).apply(null,arguments)},Pf=b._emscripten_bind_TessBaseAPI_ProcessPages_4=function(){return(Pf=b._emscripten_bind_TessBaseAPI_ProcessPages_4=b.asm.Hd).apply(null,arguments)},Qf=b._emscripten_bind_TessBaseAPI_ProcessPage_6=function(){return(Qf=b._emscripten_bind_TessBaseAPI_ProcessPage_6=b.asm.Id).apply(null,arguments)},Rf=b._emscripten_bind_TessBaseAPI_GetIterator_0=function(){return(Rf=b._emscripten_bind_TessBaseAPI_GetIterator_0=b.asm.Jd).apply(null,arguments)},Sf=b._emscripten_bind_TessBaseAPI_GetUTF8Text_0= +function(){return(Sf=b._emscripten_bind_TessBaseAPI_GetUTF8Text_0=b.asm.Kd).apply(null,arguments)},Tf=b._emscripten_bind_TessBaseAPI_GetHOCRText_1=function(){return(Tf=b._emscripten_bind_TessBaseAPI_GetHOCRText_1=b.asm.Ld).apply(null,arguments)},Uf=b._emscripten_bind_TessBaseAPI_GetTSVText_1=function(){return(Uf=b._emscripten_bind_TessBaseAPI_GetTSVText_1=b.asm.Md).apply(null,arguments)},Vf=b._emscripten_bind_TessBaseAPI_GetBoxText_1=function(){return(Vf=b._emscripten_bind_TessBaseAPI_GetBoxText_1= +b.asm.Nd).apply(null,arguments)},Wf=b._emscripten_bind_TessBaseAPI_GetUNLVText_0=function(){return(Wf=b._emscripten_bind_TessBaseAPI_GetUNLVText_0=b.asm.Od).apply(null,arguments)},Xf=b._emscripten_bind_TessBaseAPI_GetOsdText_1=function(){return(Xf=b._emscripten_bind_TessBaseAPI_GetOsdText_1=b.asm.Pd).apply(null,arguments)},Yf=b._emscripten_bind_TessBaseAPI_MeanTextConf_0=function(){return(Yf=b._emscripten_bind_TessBaseAPI_MeanTextConf_0=b.asm.Qd).apply(null,arguments)},Zf=b._emscripten_bind_TessBaseAPI_AllWordConfidences_0= +function(){return(Zf=b._emscripten_bind_TessBaseAPI_AllWordConfidences_0=b.asm.Rd).apply(null,arguments)},$f=b._emscripten_bind_TessBaseAPI_AdaptToWordStr_2=function(){return($f=b._emscripten_bind_TessBaseAPI_AdaptToWordStr_2=b.asm.Sd).apply(null,arguments)},ag=b._emscripten_bind_TessBaseAPI_Clear_0=function(){return(ag=b._emscripten_bind_TessBaseAPI_Clear_0=b.asm.Td).apply(null,arguments)},bg=b._emscripten_bind_TessBaseAPI_End_0=function(){return(bg=b._emscripten_bind_TessBaseAPI_End_0=b.asm.Ud).apply(null, +arguments)},cg=b._emscripten_bind_TessBaseAPI_ClearPersistentCache_0=function(){return(cg=b._emscripten_bind_TessBaseAPI_ClearPersistentCache_0=b.asm.Vd).apply(null,arguments)},dg=b._emscripten_bind_TessBaseAPI_IsValidWord_1=function(){return(dg=b._emscripten_bind_TessBaseAPI_IsValidWord_1=b.asm.Wd).apply(null,arguments)},eg=b._emscripten_bind_TessBaseAPI_IsValidCharacter_1=function(){return(eg=b._emscripten_bind_TessBaseAPI_IsValidCharacter_1=b.asm.Xd).apply(null,arguments)},fg=b._emscripten_bind_TessBaseAPI_DetectOS_1= +function(){return(fg=b._emscripten_bind_TessBaseAPI_DetectOS_1=b.asm.Yd).apply(null,arguments)},gg=b._emscripten_bind_TessBaseAPI_GetUnichar_1=function(){return(gg=b._emscripten_bind_TessBaseAPI_GetUnichar_1=b.asm.Zd).apply(null,arguments)},hg=b._emscripten_bind_TessBaseAPI_GetDawg_1=function(){return(hg=b._emscripten_bind_TessBaseAPI_GetDawg_1=b.asm._d).apply(null,arguments)},ig=b._emscripten_bind_TessBaseAPI_NumDawgs_0=function(){return(ig=b._emscripten_bind_TessBaseAPI_NumDawgs_0=b.asm.$d).apply(null, +arguments)},jg=b._emscripten_bind_TessBaseAPI_oem_0=function(){return(jg=b._emscripten_bind_TessBaseAPI_oem_0=b.asm.ae).apply(null,arguments)},kg=b._emscripten_bind_TessBaseAPI___destroy___0=function(){return(kg=b._emscripten_bind_TessBaseAPI___destroy___0=b.asm.be).apply(null,arguments)},lg=b._emscripten_bind_OSResults_OSResults_0=function(){return(lg=b._emscripten_bind_OSResults_OSResults_0=b.asm.ce).apply(null,arguments)},mg=b._emscripten_bind_OSResults_print_scores_0=function(){return(mg=b._emscripten_bind_OSResults_print_scores_0= +b.asm.de).apply(null,arguments)},ng=b._emscripten_bind_OSResults_get_best_result_0=function(){return(ng=b._emscripten_bind_OSResults_get_best_result_0=b.asm.ee).apply(null,arguments)},og=b._emscripten_bind_OSResults_get_unicharset_0=function(){return(og=b._emscripten_bind_OSResults_get_unicharset_0=b.asm.fe).apply(null,arguments)},pg=b._emscripten_bind_OSResults___destroy___0=function(){return(pg=b._emscripten_bind_OSResults___destroy___0=b.asm.ge).apply(null,arguments)},qg=b._emscripten_bind_Pixa_get_n_0= +function(){return(qg=b._emscripten_bind_Pixa_get_n_0=b.asm.he).apply(null,arguments)},rg=b._emscripten_bind_Pixa_get_nalloc_0=function(){return(rg=b._emscripten_bind_Pixa_get_nalloc_0=b.asm.ie).apply(null,arguments)},sg=b._emscripten_bind_Pixa_get_refcount_0=function(){return(sg=b._emscripten_bind_Pixa_get_refcount_0=b.asm.je).apply(null,arguments)},tg=b._emscripten_bind_Pixa_get_pix_0=function(){return(tg=b._emscripten_bind_Pixa_get_pix_0=b.asm.ke).apply(null,arguments)},ug=b._emscripten_bind_Pixa_get_boxa_0= +function(){return(ug=b._emscripten_bind_Pixa_get_boxa_0=b.asm.le).apply(null,arguments)},vg=b._emscripten_bind_Pixa___destroy___0=function(){return(vg=b._emscripten_bind_Pixa___destroy___0=b.asm.me).apply(null,arguments)},wg=b._emscripten_enum_PageIteratorLevel_RIL_BLOCK=function(){return(wg=b._emscripten_enum_PageIteratorLevel_RIL_BLOCK=b.asm.ne).apply(null,arguments)},xg=b._emscripten_enum_PageIteratorLevel_RIL_PARA=function(){return(xg=b._emscripten_enum_PageIteratorLevel_RIL_PARA=b.asm.oe).apply(null, +arguments)},yg=b._emscripten_enum_PageIteratorLevel_RIL_TEXTLINE=function(){return(yg=b._emscripten_enum_PageIteratorLevel_RIL_TEXTLINE=b.asm.pe).apply(null,arguments)},zg=b._emscripten_enum_PageIteratorLevel_RIL_WORD=function(){return(zg=b._emscripten_enum_PageIteratorLevel_RIL_WORD=b.asm.qe).apply(null,arguments)},Ag=b._emscripten_enum_PageIteratorLevel_RIL_SYMBOL=function(){return(Ag=b._emscripten_enum_PageIteratorLevel_RIL_SYMBOL=b.asm.re).apply(null,arguments)},Bg=b._emscripten_enum_OcrEngineMode_OEM_TESSERACT_ONLY= +function(){return(Bg=b._emscripten_enum_OcrEngineMode_OEM_TESSERACT_ONLY=b.asm.se).apply(null,arguments)},Cg=b._emscripten_enum_OcrEngineMode_OEM_LSTM_ONLY=function(){return(Cg=b._emscripten_enum_OcrEngineMode_OEM_LSTM_ONLY=b.asm.te).apply(null,arguments)},Dg=b._emscripten_enum_OcrEngineMode_OEM_TESSERACT_LSTM_COMBINED=function(){return(Dg=b._emscripten_enum_OcrEngineMode_OEM_TESSERACT_LSTM_COMBINED=b.asm.ue).apply(null,arguments)},Eg=b._emscripten_enum_OcrEngineMode_OEM_DEFAULT=function(){return(Eg= +b._emscripten_enum_OcrEngineMode_OEM_DEFAULT=b.asm.ve).apply(null,arguments)},Fg=b._emscripten_enum_OcrEngineMode_OEM_COUNT=function(){return(Fg=b._emscripten_enum_OcrEngineMode_OEM_COUNT=b.asm.we).apply(null,arguments)},Gg=b._emscripten_enum_WritingDirection__WRITING_DIRECTION_LEFT_TO_RIGHT=function(){return(Gg=b._emscripten_enum_WritingDirection__WRITING_DIRECTION_LEFT_TO_RIGHT=b.asm.xe).apply(null,arguments)},Hg=b._emscripten_enum_WritingDirection__WRITING_DIRECTION_RIGHT_TO_LEFT=function(){return(Hg= +b._emscripten_enum_WritingDirection__WRITING_DIRECTION_RIGHT_TO_LEFT=b.asm.ye).apply(null,arguments)},Ig=b._emscripten_enum_WritingDirection__WRITING_DIRECTION_TOP_TO_BOTTOM=function(){return(Ig=b._emscripten_enum_WritingDirection__WRITING_DIRECTION_TOP_TO_BOTTOM=b.asm.ze).apply(null,arguments)},Jg=b._emscripten_enum_PolyBlockType_PT_UNKNOWN=function(){return(Jg=b._emscripten_enum_PolyBlockType_PT_UNKNOWN=b.asm.Ae).apply(null,arguments)},Kg=b._emscripten_enum_PolyBlockType_PT_FLOWING_TEXT=function(){return(Kg= +b._emscripten_enum_PolyBlockType_PT_FLOWING_TEXT=b.asm.Be).apply(null,arguments)},Lg=b._emscripten_enum_PolyBlockType_PT_HEADING_TEXT=function(){return(Lg=b._emscripten_enum_PolyBlockType_PT_HEADING_TEXT=b.asm.Ce).apply(null,arguments)},Mg=b._emscripten_enum_PolyBlockType_PT_PULLOUT_TEXT=function(){return(Mg=b._emscripten_enum_PolyBlockType_PT_PULLOUT_TEXT=b.asm.De).apply(null,arguments)},Ng=b._emscripten_enum_PolyBlockType_PT_EQUATION=function(){return(Ng=b._emscripten_enum_PolyBlockType_PT_EQUATION= +b.asm.Ee).apply(null,arguments)},Og=b._emscripten_enum_PolyBlockType_PT_INLINE_EQUATION=function(){return(Og=b._emscripten_enum_PolyBlockType_PT_INLINE_EQUATION=b.asm.Fe).apply(null,arguments)},Pg=b._emscripten_enum_PolyBlockType_PT_TABLE=function(){return(Pg=b._emscripten_enum_PolyBlockType_PT_TABLE=b.asm.Ge).apply(null,arguments)},Qg=b._emscripten_enum_PolyBlockType_PT_VERTICAL_TEXT=function(){return(Qg=b._emscripten_enum_PolyBlockType_PT_VERTICAL_TEXT=b.asm.He).apply(null,arguments)},Rg=b._emscripten_enum_PolyBlockType_PT_CAPTION_TEXT= +function(){return(Rg=b._emscripten_enum_PolyBlockType_PT_CAPTION_TEXT=b.asm.Ie).apply(null,arguments)},Sg=b._emscripten_enum_PolyBlockType_PT_FLOWING_IMAGE=function(){return(Sg=b._emscripten_enum_PolyBlockType_PT_FLOWING_IMAGE=b.asm.Je).apply(null,arguments)},Tg=b._emscripten_enum_PolyBlockType_PT_HEADING_IMAGE=function(){return(Tg=b._emscripten_enum_PolyBlockType_PT_HEADING_IMAGE=b.asm.Ke).apply(null,arguments)},Ug=b._emscripten_enum_PolyBlockType_PT_PULLOUT_IMAGE=function(){return(Ug=b._emscripten_enum_PolyBlockType_PT_PULLOUT_IMAGE= +b.asm.Le).apply(null,arguments)},Vg=b._emscripten_enum_PolyBlockType_PT_HORZ_LINE=function(){return(Vg=b._emscripten_enum_PolyBlockType_PT_HORZ_LINE=b.asm.Me).apply(null,arguments)},Wg=b._emscripten_enum_PolyBlockType_PT_VERT_LINE=function(){return(Wg=b._emscripten_enum_PolyBlockType_PT_VERT_LINE=b.asm.Ne).apply(null,arguments)},Xg=b._emscripten_enum_PolyBlockType_PT_NOISE=function(){return(Xg=b._emscripten_enum_PolyBlockType_PT_NOISE=b.asm.Oe).apply(null,arguments)},Yg=b._emscripten_enum_PolyBlockType_PT_COUNT= +function(){return(Yg=b._emscripten_enum_PolyBlockType_PT_COUNT=b.asm.Pe).apply(null,arguments)},Zg=b._emscripten_enum_StrongScriptDirection_DIR_NEUTRAL=function(){return(Zg=b._emscripten_enum_StrongScriptDirection_DIR_NEUTRAL=b.asm.Qe).apply(null,arguments)},$g=b._emscripten_enum_StrongScriptDirection_DIR_LEFT_TO_RIGHT=function(){return($g=b._emscripten_enum_StrongScriptDirection_DIR_LEFT_TO_RIGHT=b.asm.Re).apply(null,arguments)},ah=b._emscripten_enum_StrongScriptDirection_DIR_RIGHT_TO_LEFT=function(){return(ah= +b._emscripten_enum_StrongScriptDirection_DIR_RIGHT_TO_LEFT=b.asm.Se).apply(null,arguments)},bh=b._emscripten_enum_StrongScriptDirection_DIR_MIX=function(){return(bh=b._emscripten_enum_StrongScriptDirection_DIR_MIX=b.asm.Te).apply(null,arguments)},ch=b._emscripten_enum_ParagraphJustification__JUSTIFICATION_UNKNOWN=function(){return(ch=b._emscripten_enum_ParagraphJustification__JUSTIFICATION_UNKNOWN=b.asm.Ue).apply(null,arguments)},dh=b._emscripten_enum_ParagraphJustification__JUSTIFICATION_LEFT=function(){return(dh= +b._emscripten_enum_ParagraphJustification__JUSTIFICATION_LEFT=b.asm.Ve).apply(null,arguments)},eh=b._emscripten_enum_ParagraphJustification__JUSTIFICATION_CENTER=function(){return(eh=b._emscripten_enum_ParagraphJustification__JUSTIFICATION_CENTER=b.asm.We).apply(null,arguments)},fh=b._emscripten_enum_ParagraphJustification__JUSTIFICATION_RIGHT=function(){return(fh=b._emscripten_enum_ParagraphJustification__JUSTIFICATION_RIGHT=b.asm.Xe).apply(null,arguments)},gh=b._emscripten_enum_TextlineOrder__TEXTLINE_ORDER_LEFT_TO_RIGHT= +function(){return(gh=b._emscripten_enum_TextlineOrder__TEXTLINE_ORDER_LEFT_TO_RIGHT=b.asm.Ye).apply(null,arguments)},hh=b._emscripten_enum_TextlineOrder__TEXTLINE_ORDER_RIGHT_TO_LEFT=function(){return(hh=b._emscripten_enum_TextlineOrder__TEXTLINE_ORDER_RIGHT_TO_LEFT=b.asm.Ze).apply(null,arguments)},ih=b._emscripten_enum_TextlineOrder__TEXTLINE_ORDER_TOP_TO_BOTTOM=function(){return(ih=b._emscripten_enum_TextlineOrder__TEXTLINE_ORDER_TOP_TO_BOTTOM=b.asm._e).apply(null,arguments)},jh=b._emscripten_enum_Orientation__ORIENTATION_PAGE_UP= +function(){return(jh=b._emscripten_enum_Orientation__ORIENTATION_PAGE_UP=b.asm.$e).apply(null,arguments)},kh=b._emscripten_enum_Orientation__ORIENTATION_PAGE_RIGHT=function(){return(kh=b._emscripten_enum_Orientation__ORIENTATION_PAGE_RIGHT=b.asm.af).apply(null,arguments)},lh=b._emscripten_enum_Orientation__ORIENTATION_PAGE_DOWN=function(){return(lh=b._emscripten_enum_Orientation__ORIENTATION_PAGE_DOWN=b.asm.bf).apply(null,arguments)},mh=b._emscripten_enum_Orientation__ORIENTATION_PAGE_LEFT=function(){return(mh= +b._emscripten_enum_Orientation__ORIENTATION_PAGE_LEFT=b.asm.cf).apply(null,arguments)},nh=b._emscripten_enum_PageSegMode_PSM_OSD_ONLY=function(){return(nh=b._emscripten_enum_PageSegMode_PSM_OSD_ONLY=b.asm.df).apply(null,arguments)},oh=b._emscripten_enum_PageSegMode_PSM_AUTO_OSD=function(){return(oh=b._emscripten_enum_PageSegMode_PSM_AUTO_OSD=b.asm.ef).apply(null,arguments)},ph=b._emscripten_enum_PageSegMode_PSM_AUTO_ONLY=function(){return(ph=b._emscripten_enum_PageSegMode_PSM_AUTO_ONLY=b.asm.ff).apply(null, +arguments)},qh=b._emscripten_enum_PageSegMode_PSM_AUTO=function(){return(qh=b._emscripten_enum_PageSegMode_PSM_AUTO=b.asm.gf).apply(null,arguments)},rh=b._emscripten_enum_PageSegMode_PSM_SINGLE_COLUMN=function(){return(rh=b._emscripten_enum_PageSegMode_PSM_SINGLE_COLUMN=b.asm.hf).apply(null,arguments)},sh=b._emscripten_enum_PageSegMode_PSM_SINGLE_BLOCK_VERT_TEXT=function(){return(sh=b._emscripten_enum_PageSegMode_PSM_SINGLE_BLOCK_VERT_TEXT=b.asm.jf).apply(null,arguments)},th=b._emscripten_enum_PageSegMode_PSM_SINGLE_BLOCK= +function(){return(th=b._emscripten_enum_PageSegMode_PSM_SINGLE_BLOCK=b.asm.kf).apply(null,arguments)},uh=b._emscripten_enum_PageSegMode_PSM_SINGLE_LINE=function(){return(uh=b._emscripten_enum_PageSegMode_PSM_SINGLE_LINE=b.asm.lf).apply(null,arguments)},vh=b._emscripten_enum_PageSegMode_PSM_SINGLE_WORD=function(){return(vh=b._emscripten_enum_PageSegMode_PSM_SINGLE_WORD=b.asm.mf).apply(null,arguments)},wh=b._emscripten_enum_PageSegMode_PSM_CIRCLE_WORD=function(){return(wh=b._emscripten_enum_PageSegMode_PSM_CIRCLE_WORD= +b.asm.nf).apply(null,arguments)},xh=b._emscripten_enum_PageSegMode_PSM_SINGLE_CHAR=function(){return(xh=b._emscripten_enum_PageSegMode_PSM_SINGLE_CHAR=b.asm.of).apply(null,arguments)},yh=b._emscripten_enum_PageSegMode_PSM_SPARSE_TEXT=function(){return(yh=b._emscripten_enum_PageSegMode_PSM_SPARSE_TEXT=b.asm.pf).apply(null,arguments)},zh=b._emscripten_enum_PageSegMode_PSM_SPARSE_TEXT_OSD=function(){return(zh=b._emscripten_enum_PageSegMode_PSM_SPARSE_TEXT_OSD=b.asm.qf).apply(null,arguments)},Ah=b._emscripten_enum_PageSegMode_PSM_RAW_LINE= +function(){return(Ah=b._emscripten_enum_PageSegMode_PSM_RAW_LINE=b.asm.rf).apply(null,arguments)},Bh=b._emscripten_enum_PageSegMode_PSM_COUNT=function(){return(Bh=b._emscripten_enum_PageSegMode_PSM_COUNT=b.asm.sf).apply(null,arguments)};b._pixDestroy=function(){return(b._pixDestroy=b.asm.uf).apply(null,arguments)};b._ptaDestroy=function(){return(b._ptaDestroy=b.asm.vf).apply(null,arguments)};b._pixaDestroy=function(){return(b._pixaDestroy=b.asm.wf).apply(null,arguments)}; +b._boxaDestroy=function(){return(b._boxaDestroy=b.asm.xf).apply(null,arguments)};b._pixReadMem=function(){return(b._pixReadMem=b.asm.yf).apply(null,arguments)};var Ob=b.___errno_location=function(){return(Ob=b.___errno_location=b.asm.zf).apply(null,arguments)},Ch=b._free=function(){return(Ch=b._free=b.asm.Af).apply(null,arguments)},zb=b._malloc=function(){return(zb=b._malloc=b.asm.Bf).apply(null,arguments)};b._pixReadHeaderMem=function(){return(b._pixReadHeaderMem=b.asm.Cf).apply(null,arguments)}; +var qb=b._emscripten_builtin_memalign=function(){return(qb=b._emscripten_builtin_memalign=b.asm.Df).apply(null,arguments)},F=b._setThrew=function(){return(F=b._setThrew=b.asm.Ef).apply(null,arguments)},Dh=b.stackSave=function(){return(Dh=b.stackSave=b.asm.Ff).apply(null,arguments)},Eh=b.stackRestore=function(){return(Eh=b.stackRestore=b.asm.Gf).apply(null,arguments)};b.___cxa_is_pointer_type=function(){return(b.___cxa_is_pointer_type=b.asm.Hf).apply(null,arguments)}; +b.___emscripten_embedded_file_data=600112;function Rb(a,c,d,e){var g=Dh();try{return Mb(a)(c,d,e)}catch(h){Eh(g);if(h!==h+0)throw h;F(1,0)}}function Ub(a,c){var d=Dh();try{Mb(a)(c)}catch(e){Eh(d);if(e!==e+0)throw e;F(1,0)}}function Pb(a,c){var d=Dh();try{return Mb(a)(c)}catch(e){Eh(d);if(e!==e+0)throw e;F(1,0)}}function Wb(a,c,d,e){var g=Dh();try{Mb(a)(c,d,e)}catch(h){Eh(g);if(h!==h+0)throw h;F(1,0)}}function Vb(a,c,d){var e=Dh();try{Mb(a)(c,d)}catch(g){Eh(e);if(g!==g+0)throw g;F(1,0)}} +function Qb(a,c,d){var e=Dh();try{return Mb(a)(c,d)}catch(g){Eh(e);if(g!==g+0)throw g;F(1,0)}}function Sb(a,c,d,e,g){var h=Dh();try{return Mb(a)(c,d,e,g)}catch(k){Eh(h);if(k!==k+0)throw k;F(1,0)}}function Xb(a,c,d,e,g){var h=Dh();try{Mb(a)(c,d,e,g)}catch(k){Eh(h);if(k!==k+0)throw k;F(1,0)}}function Tb(a,c,d,e,g,h){var k=Dh();try{return Mb(a)(c,d,e,g,h)}catch(m){Eh(k);if(m!==m+0)throw m;F(1,0)}} +function Zb(a,c,d,e,g,h,k,m,t,u){var p=Dh();try{Mb(a)(c,d,e,g,h,k,m,t,u)}catch(x){Eh(p);if(x!==x+0)throw x;F(1,0)}}function Yb(a,c,d,e,g,h){var k=Dh();try{Mb(a)(c,d,e,g,h)}catch(m){Eh(k);if(m!==m+0)throw m;F(1,0)}}b.addRunDependency=Qa;b.removeRunDependency=Ra;b.FS_createPath=D.Lg;b.FS_createDataFile=D.wg;b.FS_createPreloadedFile=D.oh;b.FS_createLazyFile=D.nh;b.FS_createDevice=D.Wf;b.FS_unlink=D.unlink;b.setValue=Za;b.getValue=Ya;b.FS=D;var Fh;Pa=function Gh(){Fh||Hh();Fh||(Pa=Gh)}; +function Hh(){function a(){if(!Fh&&(Fh=!0,b.calledRun=!0,!ua)){La=!0;b.noFSInit||D.rg.Xg||D.rg();D.Ah=!1;Xa(Ia);aa(b);if(b.onRuntimeInitialized)b.onRuntimeInitialized();if(b.postRun)for("function"==typeof b.postRun&&(b.postRun=[b.postRun]);b.postRun.length;){var c=b.postRun.shift();Ka.unshift(c)}Xa(Ka)}}if(!(0=Kh){0>=1;break;case 4:e>>=2;break;case 8:e>>=3}for(var g=0;g{var t={919:(t,e)=>{"use strict";e.byteLength=function(t){var e=u(t),r=e[0],n=e[1];return 3*(r+n)/4-n},e.toByteArray=function(t){var e,r,o=u(t),a=o[0],s=o[1],c=new i(function(t,e,r){return 3*(e+r)/4-r}(0,a,s)),f=0,h=s>0?a-4:a;for(r=0;r>16&255,c[f++]=e>>8&255,c[f++]=255&e;return 2===s&&(e=n[t.charCodeAt(r)]<<2|n[t.charCodeAt(r+1)]>>4,c[f++]=255&e),1===s&&(e=n[t.charCodeAt(r)]<<10|n[t.charCodeAt(r+1)]<<4|n[t.charCodeAt(r+2)]>>2,c[f++]=e>>8&255,c[f++]=255&e),c},e.fromByteArray=function(t){for(var e,n=t.length,i=n%3,o=[],a=16383,s=0,u=n-i;su?u:s+a));return 1===i?(e=t[n-1],o.push(r[e>>2]+r[e<<4&63]+"==")):2===i&&(e=(t[n-2]<<8)+t[n-1],o.push(r[e>>10]+r[e>>4&63]+r[e<<2&63]+"=")),o.join("")};for(var r=[],n=[],i="undefined"!=typeof Uint8Array?Uint8Array:Array,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",a=0,s=o.length;a0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");return-1===r&&(r=e),[r,r===e?0:4-r%4]}function c(t,e,n){for(var i,o,a=[],s=e;s>18&63]+r[o>>12&63]+r[o>>6&63]+r[63&o]);return a.join("")}n["-".charCodeAt(0)]=62,n["_".charCodeAt(0)]=63},86:(t,e,r)=>{var n=r(752),i=r(773);t.exports={encode:n,decode:i}},773:(t,e,r)=>{var n=r(33).lW;function i(t,e){if(this.pos=0,this.buffer=t,this.is_with_alpha=!!e,this.bottom_up=!0,this.flag=this.buffer.toString("utf-8",0,this.pos+=2),"BM"!=this.flag)throw new Error("Invalid BMP File");this.parseHeader(),this.parseRGBA()}i.prototype.parseHeader=function(){if(this.fileSize=this.buffer.readUInt32LE(this.pos),this.pos+=4,this.reserved=this.buffer.readUInt32LE(this.pos),this.pos+=4,this.offset=this.buffer.readUInt32LE(this.pos),this.pos+=4,this.headerSize=this.buffer.readUInt32LE(this.pos),this.pos+=4,this.width=this.buffer.readUInt32LE(this.pos),this.pos+=4,this.height=this.buffer.readInt32LE(this.pos),this.pos+=4,this.planes=this.buffer.readUInt16LE(this.pos),this.pos+=2,this.bitPP=this.buffer.readUInt16LE(this.pos),this.pos+=2,this.compress=this.buffer.readUInt32LE(this.pos),this.pos+=4,this.rawSize=this.buffer.readUInt32LE(this.pos),this.pos+=4,this.hr=this.buffer.readUInt32LE(this.pos),this.pos+=4,this.vr=this.buffer.readUInt32LE(this.pos),this.pos+=4,this.colors=this.buffer.readUInt32LE(this.pos),this.pos+=4,this.importantColors=this.buffer.readUInt32LE(this.pos),this.pos+=4,16===this.bitPP&&this.is_with_alpha&&(this.bitPP=15),this.bitPP<15){var t=0===this.colors?1<=0?this.height-1:-this.height;for(r=this.height-1;r>=0;r--){for(var n=this.bottom_up?r:this.height-1-r,i=0;i>7-s&1];this.data[a+4*s]=0,this.data[a+4*s+1]=u.blue,this.data[a+4*s+2]=u.green,this.data[a+4*s+3]=u.red}0!=e&&(this.pos+=4-e)}},i.prototype.bit4=function(){if(2==this.compress){var t=function(t){var r=this.palette[t];this.data[e]=0,this.data[e+1]=r.blue,this.data[e+2]=r.green,this.data[e+3]=r.red,e+=4};this.data.fill(255);for(var e=0,r=this.bottom_up?this.height-1:0,n=!1;e>4),1&c&&c+1>1&1)&&this.pos++}}else for(c=0;c>4),n=!n}}else{var f=Math.ceil(this.width/2),h=f%4;for(s=this.height-1;s>=0;s--){var l=this.bottom_up?s:this.height-1-s;for(a=0;a>4,d=15&o,y=this.palette[p];if(this.data[e]=0,this.data[e+1]=y.blue,this.data[e+2]=y.green,this.data[e+3]=y.red,2*a+1>=this.width)break;y=this.palette[d],this.data[e+4]=0,this.data[e+4+1]=y.blue,this.data[e+4+2]=y.green,this.data[e+4+3]=y.red}0!=h&&(this.pos+=4-h)}}},i.prototype.bit8=function(){if(1==this.compress){var t=function(t){var r=this.palette[t];this.data[e]=0,this.data[e+1]=r.blue,this.data[e+2]=r.green,this.data[e+3]=r.red,e+=4};this.data.fill(255);for(var e=0,r=this.bottom_up?this.height-1:0;e=0;a--){var f=this.bottom_up?a:this.height-1-a;for(o=0;o=0;r--){for(var n=this.bottom_up?r:this.height-1-r,i=0;i>5&e)/e*255|0,u=(o>>10&e)/e*255|0,c=o>>15?255:0,f=n*this.width*4+4*i;this.data[f]=c,this.data[f+1]=a,this.data[f+2]=s,this.data[f+3]=u}this.pos+=t}},i.prototype.bit16=function(){var t=this.width%2*2;this.maskRed=31744,this.maskGreen=992,this.maskBlue=31,this.mask0=0,3==this.compress&&(this.maskRed=this.buffer.readUInt32LE(this.pos),this.pos+=4,this.maskGreen=this.buffer.readUInt32LE(this.pos),this.pos+=4,this.maskBlue=this.buffer.readUInt32LE(this.pos),this.pos+=4,this.mask0=this.buffer.readUInt32LE(this.pos),this.pos+=4);for(var e=[0,0,0],r=0;r<16;r++)this.maskRed>>r&1&&e[0]++,this.maskGreen>>r&1&&e[1]++,this.maskBlue>>r&1&&e[2]++;e[1]+=e[0],e[2]+=e[1],e[0]=8-e[0],e[1]-=8,e[2]-=8;for(var n=this.height-1;n>=0;n--){for(var i=this.bottom_up?n:this.height-1-n,o=0;o>e[1],c=(a&this.maskRed)>>e[2],f=i*this.width*4+4*o;this.data[f]=0,this.data[f+1]=s,this.data[f+2]=u,this.data[f+3]=c}this.pos+=t}},i.prototype.bit24=function(){for(var t=this.height-1;t>=0;t--){for(var e=this.bottom_up?t:this.height-1-t,r=0;r=0;t--)for(var e=this.bottom_up?t:this.height-1-t,r=0;r=0;t--)for(e=this.bottom_up?t:this.height-1-t,r=0;r{var n=r(33).lW;function i(t){this.buffer=t.data,this.width=t.width,this.height=t.height,this.extraBytes=this.width%4,this.rgbSize=this.height*(3*this.width+this.extraBytes),this.headerInfoSize=40,this.data=[],this.flag="BM",this.reserved=0,this.offset=54,this.fileSize=this.rgbSize+this.offset,this.planes=1,this.bitPP=24,this.compress=0,this.hr=0,this.vr=0,this.colors=0,this.importantColors=0}i.prototype.encode=function(){var t=new n(this.offset+this.rgbSize);this.pos=0,t.write(this.flag,this.pos,2),this.pos+=2,t.writeUInt32LE(this.fileSize,this.pos),this.pos+=4,t.writeUInt32LE(this.reserved,this.pos),this.pos+=4,t.writeUInt32LE(this.offset,this.pos),this.pos+=4,t.writeUInt32LE(this.headerInfoSize,this.pos),this.pos+=4,t.writeUInt32LE(this.width,this.pos),this.pos+=4,t.writeInt32LE(-this.height,this.pos),this.pos+=4,t.writeUInt16LE(this.planes,this.pos),this.pos+=2,t.writeUInt16LE(this.bitPP,this.pos),this.pos+=2,t.writeUInt32LE(this.compress,this.pos),this.pos+=4,t.writeUInt32LE(this.rgbSize,this.pos),this.pos+=4,t.writeUInt32LE(this.hr,this.pos),this.pos+=4,t.writeUInt32LE(this.vr,this.pos),this.pos+=4,t.writeUInt32LE(this.colors,this.pos),this.pos+=4,t.writeUInt32LE(this.importantColors,this.pos),this.pos+=4;for(var e=0,r=3*this.width+this.extraBytes,i=0;i0){var s=this.pos+i*r+3*this.width;t.fill(0,s,s+this.extraBytes)}}return t},t.exports=function(t,e){return void 0===e&&(e=100),{data:new i(t).encode(),width:t.width,height:t.height}}},33:(t,e,r)=>{"use strict";function n(t,e){for(var r=0;rh)throw new RangeError('The value "'+t+'" is invalid for option "size"');var e=new Uint8Array(t);return Object.setPrototypeOf(e,p.prototype),e}function p(t,e,r){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return g(t)}return d(t,e,r)}function d(t,e,r){if("string"==typeof t)return function(t,e){if("string"==typeof e&&""!==e||(e="utf8"),!p.isEncoding(e))throw new TypeError("Unknown encoding: "+e);var r=0|m(t,e),n=l(r),i=n.write(t,e);return i!==r&&(n=n.slice(0,i)),n}(t,e);if(ArrayBuffer.isView(t))return function(t){if(tt(t,Uint8Array)){var e=new Uint8Array(t);return b(e.buffer,e.byteOffset,e.byteLength)}return v(t)}(t);if(null==t)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+s(t));if(tt(t,ArrayBuffer)||t&&tt(t.buffer,ArrayBuffer))return b(t,e,r);if("undefined"!=typeof SharedArrayBuffer&&(tt(t,SharedArrayBuffer)||t&&tt(t.buffer,SharedArrayBuffer)))return b(t,e,r);if("number"==typeof t)throw new TypeError('The "value" argument must not be of type number. Received type number');var n=t.valueOf&&t.valueOf();if(null!=n&&n!==t)return p.from(n,e,r);var i=function(t){if(p.isBuffer(t)){var e=0|w(t.length),r=l(e);return 0===r.length||t.copy(r,0,0,e),r}return void 0!==t.length?"number"!=typeof t.length||et(t.length)?l(0):v(t):"Buffer"===t.type&&Array.isArray(t.data)?v(t.data):void 0}(t);if(i)return i;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof t[Symbol.toPrimitive])return p.from(t[Symbol.toPrimitive]("string"),e,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+s(t))}function y(t){if("number"!=typeof t)throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function g(t){return y(t),l(t<0?0:0|w(t))}function v(t){for(var e=t.length<0?0:0|w(t.length),r=l(e),n=0;n=h)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+h.toString(16)+" bytes");return 0|t}function m(t,e){if(p.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||tt(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+s(t));var r=t.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;for(var i=!1;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return $(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return Q(t).length;default:if(i)return n?-1:$(t).length;e=(""+e).toLowerCase(),i=!0}}function E(t,e,r){var n=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return R(this,e,r);case"utf8":case"utf-8":return j(this,e,r);case"ascii":return T(this,e,r);case"latin1":case"binary":return P(this,e,r);case"base64":return U(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return C(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function x(t,e,r){var n=t[e];t[e]=t[r],t[r]=n}function A(t,e,r,n,i){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),et(r=+r)&&(r=i?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(i)return-1;r=t.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof e&&(e=p.from(e,n)),p.isBuffer(e))return 0===e.length?-1:k(t,e,r,n,i);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):k(t,[e],r,n,i);throw new TypeError("val must be string, number or Buffer")}function k(t,e,r,n,i){var o,a=1,s=t.length,u=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;a=2,s/=2,u/=2,r/=2}function c(t,e){return 1===a?t[e]:t.readUInt16BE(e*a)}if(i){var f=-1;for(o=r;os&&(r=s-u),o=r;o>=0;o--){for(var h=!0,l=0;li&&(n=i):n=i;var o,a=e.length;for(n>a/2&&(n=a/2),o=0;o>8,i=r%256,o.push(i),o.push(n);return o}(e,t.length-r),t,r,n)}function U(t,e,r){return 0===e&&r===t.length?u.fromByteArray(t):u.fromByteArray(t.slice(e,r))}function j(t,e,r){r=Math.min(t.length,r);for(var n=[],i=e;i239?4:o>223?3:o>191?2:1;if(i+s<=r){var u=void 0,c=void 0,f=void 0,h=void 0;switch(s){case 1:o<128&&(a=o);break;case 2:128==(192&(u=t[i+1]))&&(h=(31&o)<<6|63&u)>127&&(a=h);break;case 3:u=t[i+1],c=t[i+2],128==(192&u)&&128==(192&c)&&(h=(15&o)<<12|(63&u)<<6|63&c)>2047&&(h<55296||h>57343)&&(a=h);break;case 4:u=t[i+1],c=t[i+2],f=t[i+3],128==(192&u)&&128==(192&c)&&128==(192&f)&&(h=(15&o)<<18|(63&u)<<12|(63&c)<<6|63&f)>65535&&h<1114112&&(a=h)}}null===a?(a=65533,s=1):a>65535&&(a-=65536,n.push(a>>>10&1023|55296),a=56320|1023&a),n.push(a),i+=s}return function(t){var e=t.length;if(e<=B)return String.fromCharCode.apply(String,t);for(var r="",n=0;nn.length?(p.isBuffer(o)||(o=p.from(o)),o.copy(n,i)):Uint8Array.prototype.set.call(n,o,i);else{if(!p.isBuffer(o))throw new TypeError('"list" argument must be an Array of Buffers');o.copy(n,i)}i+=o.length}return n},p.byteLength=m,p.prototype._isBuffer=!0,p.prototype.swap16=function(){var t=this.length;if(t%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var e=0;er&&(t+=" ... "),""},f&&(p.prototype[f]=p.prototype.inspect),p.prototype.compare=function(t,e,r,n,i){if(tt(t,Uint8Array)&&(t=p.from(t,t.offset,t.byteLength)),!p.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+s(t));if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),e<0||r>t.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&e>=r)return 0;if(n>=i)return-1;if(e>=r)return 1;if(this===t)return 0;for(var o=(i>>>=0)-(n>>>=0),a=(r>>>=0)-(e>>>=0),u=Math.min(o,a),c=this.slice(n,i),f=t.slice(e,r),h=0;h>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}var i=this.length-e;if((void 0===r||r>i)&&(r=i),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");for(var o=!1;;)switch(n){case"hex":return _(this,t,e,r);case"utf8":case"utf-8":return O(this,t,e,r);case"ascii":case"latin1":case"binary":return I(this,t,e,r);case"base64":return S(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return L(this,t,e,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},p.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};var B=4096;function T(t,e,r){var n="";r=Math.min(t.length,r);for(var i=e;in)&&(r=n);for(var i="",o=e;or)throw new RangeError("Trying to access beyond buffer length")}function M(t,e,r,n,i,o){if(!p.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||et.length)throw new RangeError("Index out of range")}function F(t,e,r,n,i){H(e,n,i,t,r,7);var o=Number(e&BigInt(4294967295));t[r++]=o,o>>=8,t[r++]=o,o>>=8,t[r++]=o,o>>=8,t[r++]=o;var a=Number(e>>BigInt(32)&BigInt(4294967295));return t[r++]=a,a>>=8,t[r++]=a,a>>=8,t[r++]=a,a>>=8,t[r++]=a,r}function G(t,e,r,n,i){H(e,n,i,t,r,7);var o=Number(e&BigInt(4294967295));t[r+7]=o,o>>=8,t[r+6]=o,o>>=8,t[r+5]=o,o>>=8,t[r+4]=o;var a=Number(e>>BigInt(32)&BigInt(4294967295));return t[r+3]=a,a>>=8,t[r+2]=a,a>>=8,t[r+1]=a,a>>=8,t[r]=a,r+8}function z(t,e,r,n,i,o){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function D(t,e,r,n,i){return e=+e,r>>>=0,i||z(t,0,r,4),c.write(t,e,r,n,23,4),r+4}function W(t,e,r,n,i){return e=+e,r>>>=0,i||z(t,0,r,8),c.write(t,e,r,n,52,8),r+8}p.prototype.slice=function(t,e){var r=this.length;(t=~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),(e=void 0===e?r:~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),e>>=0,e>>>=0,r||N(t,e,this.length);for(var n=this[t],i=1,o=0;++o>>=0,e>>>=0,r||N(t,e,this.length);for(var n=this[t+--e],i=1;e>0&&(i*=256);)n+=this[t+--e]*i;return n},p.prototype.readUint8=p.prototype.readUInt8=function(t,e){return t>>>=0,e||N(t,1,this.length),this[t]},p.prototype.readUint16LE=p.prototype.readUInt16LE=function(t,e){return t>>>=0,e||N(t,2,this.length),this[t]|this[t+1]<<8},p.prototype.readUint16BE=p.prototype.readUInt16BE=function(t,e){return t>>>=0,e||N(t,2,this.length),this[t]<<8|this[t+1]},p.prototype.readUint32LE=p.prototype.readUInt32LE=function(t,e){return t>>>=0,e||N(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},p.prototype.readUint32BE=p.prototype.readUInt32BE=function(t,e){return t>>>=0,e||N(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},p.prototype.readBigUInt64LE=nt((function(t){K(t>>>=0,"offset");var e=this[t],r=this[t+7];void 0!==e&&void 0!==r||J(t,this.length-8);var n=e+this[++t]*Math.pow(2,8)+this[++t]*Math.pow(2,16)+this[++t]*Math.pow(2,24),i=this[++t]+this[++t]*Math.pow(2,8)+this[++t]*Math.pow(2,16)+r*Math.pow(2,24);return BigInt(n)+(BigInt(i)<>>=0,"offset");var e=this[t],r=this[t+7];void 0!==e&&void 0!==r||J(t,this.length-8);var n=e*Math.pow(2,24)+this[++t]*Math.pow(2,16)+this[++t]*Math.pow(2,8)+this[++t],i=this[++t]*Math.pow(2,24)+this[++t]*Math.pow(2,16)+this[++t]*Math.pow(2,8)+r;return(BigInt(n)<>>=0,e>>>=0,r||N(t,e,this.length);for(var n=this[t],i=1,o=0;++o=(i*=128)&&(n-=Math.pow(2,8*e)),n},p.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||N(t,e,this.length);for(var n=e,i=1,o=this[t+--n];n>0&&(i*=256);)o+=this[t+--n]*i;return o>=(i*=128)&&(o-=Math.pow(2,8*e)),o},p.prototype.readInt8=function(t,e){return t>>>=0,e||N(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},p.prototype.readInt16LE=function(t,e){t>>>=0,e||N(t,2,this.length);var r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},p.prototype.readInt16BE=function(t,e){t>>>=0,e||N(t,2,this.length);var r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},p.prototype.readInt32LE=function(t,e){return t>>>=0,e||N(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},p.prototype.readInt32BE=function(t,e){return t>>>=0,e||N(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},p.prototype.readBigInt64LE=nt((function(t){K(t>>>=0,"offset");var e=this[t],r=this[t+7];void 0!==e&&void 0!==r||J(t,this.length-8);var n=this[t+4]+this[t+5]*Math.pow(2,8)+this[t+6]*Math.pow(2,16)+(r<<24);return(BigInt(n)<>>=0,"offset");var e=this[t],r=this[t+7];void 0!==e&&void 0!==r||J(t,this.length-8);var n=(e<<24)+this[++t]*Math.pow(2,16)+this[++t]*Math.pow(2,8)+this[++t];return(BigInt(n)<>>=0,e||N(t,4,this.length),c.read(this,t,!0,23,4)},p.prototype.readFloatBE=function(t,e){return t>>>=0,e||N(t,4,this.length),c.read(this,t,!1,23,4)},p.prototype.readDoubleLE=function(t,e){return t>>>=0,e||N(t,8,this.length),c.read(this,t,!0,52,8)},p.prototype.readDoubleBE=function(t,e){return t>>>=0,e||N(t,8,this.length),c.read(this,t,!1,52,8)},p.prototype.writeUintLE=p.prototype.writeUIntLE=function(t,e,r,n){t=+t,e>>>=0,r>>>=0,n||M(this,t,e,r,Math.pow(2,8*r)-1,0);var i=1,o=0;for(this[e]=255&t;++o>>=0,r>>>=0,n||M(this,t,e,r,Math.pow(2,8*r)-1,0);var i=r-1,o=1;for(this[e+i]=255&t;--i>=0&&(o*=256);)this[e+i]=t/o&255;return e+r},p.prototype.writeUint8=p.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||M(this,t,e,1,255,0),this[e]=255&t,e+1},p.prototype.writeUint16LE=p.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||M(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},p.prototype.writeUint16BE=p.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||M(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},p.prototype.writeUint32LE=p.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||M(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},p.prototype.writeUint32BE=p.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||M(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},p.prototype.writeBigUInt64LE=nt((function(t){return F(this,t,arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,BigInt(0),BigInt("0xffffffffffffffff"))})),p.prototype.writeBigUInt64BE=nt((function(t){return G(this,t,arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,BigInt(0),BigInt("0xffffffffffffffff"))})),p.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var i=Math.pow(2,8*r-1);M(this,t,e,r,i-1,-i)}var o=0,a=1,s=0;for(this[e]=255&t;++o>0)-s&255;return e+r},p.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){var i=Math.pow(2,8*r-1);M(this,t,e,r,i-1,-i)}var o=r-1,a=1,s=0;for(this[e+o]=255&t;--o>=0&&(a*=256);)t<0&&0===s&&0!==this[e+o+1]&&(s=1),this[e+o]=(t/a>>0)-s&255;return e+r},p.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||M(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},p.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||M(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},p.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||M(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},p.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||M(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},p.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||M(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},p.prototype.writeBigInt64LE=nt((function(t){return F(this,t,arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),p.prototype.writeBigInt64BE=nt((function(t){return G(this,t,arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),p.prototype.writeFloatLE=function(t,e,r){return D(this,t,e,!0,r)},p.prototype.writeFloatBE=function(t,e,r){return D(this,t,e,!1,r)},p.prototype.writeDoubleLE=function(t,e,r){return W(this,t,e,!0,r)},p.prototype.writeDoubleBE=function(t,e,r){return W(this,t,e,!1,r)},p.prototype.copy=function(t,e,r,n){if(!p.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(o=e;o=n+4;r-=3)e="_".concat(t.slice(r-3,r)).concat(e);return"".concat(t.slice(0,r)).concat(e)}function H(t,e,r,n,i,o){if(t>r||t3?0===e||e===BigInt(0)?">= 0".concat(s," and < 2").concat(s," ** ").concat(8*(o+1)).concat(s):">= -(2".concat(s," ** ").concat(8*(o+1)-1).concat(s,") and < 2 ** ")+"".concat(8*(o+1)-1).concat(s):">= ".concat(e).concat(s," and <= ").concat(r).concat(s),new Y.ERR_OUT_OF_RANGE("value",a,t)}!function(t,e,r){K(e,"offset"),void 0!==t[e]&&void 0!==t[e+r]||J(e,t.length-(r+1))}(n,i,o)}function K(t,e){if("number"!=typeof t)throw new Y.ERR_INVALID_ARG_TYPE(e,"number",t)}function J(t,e,r){if(Math.floor(t)!==t)throw K(t,r),new Y.ERR_OUT_OF_RANGE(r||"offset","an integer",t);if(e<0)throw new Y.ERR_BUFFER_OUT_OF_BOUNDS;throw new Y.ERR_OUT_OF_RANGE(r||"offset",">= ".concat(r?1:0," and <= ").concat(e),t)}V("ERR_BUFFER_OUT_OF_BOUNDS",(function(t){return t?"".concat(t," is outside of buffer bounds"):"Attempt to access memory outside buffer bounds"}),RangeError),V("ERR_INVALID_ARG_TYPE",(function(t,e){return'The "'.concat(t,'" argument must be of type number. Received type ').concat(s(e))}),TypeError),V("ERR_OUT_OF_RANGE",(function(t,e,r){var n='The value of "'.concat(t,'" is out of range.'),i=r;return Number.isInteger(r)&&Math.abs(r)>Math.pow(2,32)?i=q(String(r)):"bigint"==typeof r&&(i=String(r),(r>Math.pow(BigInt(2),BigInt(32))||r<-Math.pow(BigInt(2),BigInt(32)))&&(i=q(i)),i+="n"),n+" It must be ".concat(e,". Received ").concat(i)}),RangeError);var X=/[^+/0-9A-Za-z-_]/g;function $(t,e){var r;e=e||1/0;for(var n=t.length,i=null,o=[],a=0;a55295&&r<57344){if(!i){if(r>56319){(e-=3)>-1&&o.push(239,191,189);continue}if(a+1===n){(e-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(e-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(e-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((e-=1)<0)break;o.push(r)}else if(r<2048){if((e-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function Q(t){return u.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(X,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function Z(t,e,r,n){var i;for(i=0;i=e.length||i>=t.length);++i)e[i+r]=t[i];return i}function tt(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function et(t){return t!=t}var rt=function(){for(var t="0123456789abcdef",e=new Array(256),r=0;r<16;++r)for(var n=16*r,i=0;i<16;++i)e[n+i]=t[r]+t[i];return e}();function nt(t){return"undefined"==typeof BigInt?it:t}function it(){throw new Error("BigInt not supported")}},226:(t,e)=>{e.read=function(t,e,r,n,i){var o,a,s=8*i-n-1,u=(1<>1,f=-7,h=r?i-1:0,l=r?-1:1,p=t[e+h];for(h+=l,o=p&(1<<-f)-1,p>>=-f,f+=s;f>0;o=256*o+t[e+h],h+=l,f-=8);for(a=o&(1<<-f)-1,o>>=-f,f+=n;f>0;a=256*a+t[e+h],h+=l,f-=8);if(0===o)o=1-c;else{if(o===u)return a?NaN:1/0*(p?-1:1);a+=Math.pow(2,n),o-=c}return(p?-1:1)*a*Math.pow(2,o-n)},e.write=function(t,e,r,n,i,o){var a,s,u,c=8*o-i-1,f=(1<>1,l=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:o-1,d=n?1:-1,y=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(s=isNaN(e)?1:0,a=f):(a=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-a))<1&&(a--,u*=2),(e+=a+h>=1?l/u:l*Math.pow(2,1-h))*u>=2&&(a++,u/=2),a+h>=f?(s=0,a=f):a+h>=1?(s=(e*u-1)*Math.pow(2,i),a+=h):(s=e*Math.pow(2,h-1)*Math.pow(2,i),a=0));i>=8;t[r+p]=255&s,p+=d,s/=256,i-=8);for(a=a<0;t[r+p]=255&a,p+=d,a/=256,c-=8);t[r+p-d]|=128*y}},670:t=>{function e(t){return e="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},e(t)}t.exports=function(){return"undefined"!=typeof window&&"object"===e(window.process)&&"renderer"===window.process.type||!("undefined"==typeof process||"object"!==e(process.versions)||!process.versions.electron)||"object"===("undefined"==typeof navigator?"undefined":e(navigator))&&"string"==typeof navigator.userAgent&&navigator.userAgent.indexOf("Electron")>=0}},975:t=>{t.exports=function(t){if("string"!=typeof t)return!1;var i=t.match(e);if(!i)return!1;var o=i[1];return!!o&&!(!r.test(o)&&!n.test(o))};var e=/^(?:\w+:)?\/\/(\S+)$/,r=/^localhost[\:?\d]*(?:[^\:?\d]\S*)?$/,n=/^[^\s\.]+\.\S{2,}$/},760:(t,e,r)=>{function n(t){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},n(t)}var i=function(t){"use strict";var e,r=Object.prototype,i=r.hasOwnProperty,o=Object.defineProperty||function(t,e,r){t[e]=r.value},a="function"==typeof Symbol?Symbol:{},s=a.iterator||"@@iterator",u=a.asyncIterator||"@@asyncIterator",c=a.toStringTag||"@@toStringTag";function f(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{f({},"")}catch(t){f=function(t,e,r){return t[e]=r}}function h(t,e,r,n){var i=e&&e.prototype instanceof b?e:b,a=Object.create(i.prototype),s=new j(n||[]);return o(a,"_invoke",{value:I(t,r,s)}),a}function l(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=h;var p="suspendedStart",d="suspendedYield",y="executing",g="completed",v={};function b(){}function w(){}function m(){}var E={};f(E,s,(function(){return this}));var x=Object.getPrototypeOf,A=x&&x(x(B([])));A&&A!==r&&i.call(A,s)&&(E=A);var k=m.prototype=b.prototype=Object.create(E);function _(t){["next","throw","return"].forEach((function(e){f(t,e,(function(t){return this._invoke(e,t)}))}))}function O(t,e){function r(o,a,s,u){var c=l(t[o],t,a);if("throw"!==c.type){var f=c.arg,h=f.value;return h&&"object"===n(h)&&i.call(h,"__await")?e.resolve(h.__await).then((function(t){r("next",t,s,u)}),(function(t){r("throw",t,s,u)})):e.resolve(h).then((function(t){f.value=t,s(f)}),(function(t){return r("throw",t,s,u)}))}u(c.arg)}var a;o(this,"_invoke",{value:function(t,n){function i(){return new e((function(e,i){r(t,n,e,i)}))}return a=a?a.then(i,i):i()}})}function I(t,e,r){var n=p;return function(i,o){if(n===y)throw new Error("Generator is already running");if(n===g){if("throw"===i)throw o;return T()}for(r.method=i,r.arg=o;;){var a=r.delegate;if(a){var s=S(a,r);if(s){if(s===v)continue;return s}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if(n===p)throw n=g,r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n=y;var u=l(t,e,r);if("normal"===u.type){if(n=r.done?g:d,u.arg===v)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n=g,r.method="throw",r.arg=u.arg)}}}function S(t,r){var n=r.method,i=t.iterator[n];if(i===e)return r.delegate=null,"throw"===n&&t.iterator.return&&(r.method="return",r.arg=e,S(t,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),v;var o=l(i,t.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,v;var a=o.arg;return a?a.done?(r[t.resultName]=a.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=e),r.delegate=null,v):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,v)}function L(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function U(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function j(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(L,this),this.reset(!0)}function B(t){if(t){var r=t[s];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,o=function r(){for(;++n=0;--o){var a=this.tryEntries[o],s=a.completion;if("root"===a.tryLoc)return n("end");if(a.tryLoc<=this.prev){var u=i.call(a,"catchLoc"),c=i.call(a,"finallyLoc");if(u&&c){if(this.prev=0;--r){var n=this.tryEntries[r];if(n.tryLoc<=this.prev&&i.call(n,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),U(r),v}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var i=n.arg;U(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(t,r,n){return this.delegate={iterator:B(t),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=e),v}},t}("object"===n(t=r.nmd(t))?t.exports:{});try{regeneratorRuntime=i}catch(t){"object"===("undefined"==typeof globalThis?"undefined":n(globalThis))?globalThis.regeneratorRuntime=i:Function("r","regeneratorRuntime = r")(i)}},506:(t,e,r)=>{"use strict";function n(t){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},n(t)}function i(){i=function(){return t};var t={},e=Object.prototype,r=e.hasOwnProperty,o=Object.defineProperty||function(t,e,r){t[e]=r.value},a="function"==typeof Symbol?Symbol:{},s=a.iterator||"@@iterator",u=a.asyncIterator||"@@asyncIterator",c=a.toStringTag||"@@toStringTag";function f(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{f({},"")}catch(t){f=function(t,e,r){return t[e]=r}}function h(t,e,r,n){var i=e&&e.prototype instanceof d?e:d,a=Object.create(i.prototype),s=new I(n||[]);return o(a,"_invoke",{value:A(t,r,s)}),a}function l(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=h;var p={};function d(){}function y(){}function g(){}var v={};f(v,s,(function(){return this}));var b=Object.getPrototypeOf,w=b&&b(b(S([])));w&&w!==e&&r.call(w,s)&&(v=w);var m=g.prototype=d.prototype=Object.create(v);function E(t){["next","throw","return"].forEach((function(e){f(t,e,(function(t){return this._invoke(e,t)}))}))}function x(t,e){function i(o,a,s,u){var c=l(t[o],t,a);if("throw"!==c.type){var f=c.arg,h=f.value;return h&&"object"==n(h)&&r.call(h,"__await")?e.resolve(h.__await).then((function(t){i("next",t,s,u)}),(function(t){i("throw",t,s,u)})):e.resolve(h).then((function(t){f.value=t,s(f)}),(function(t){return i("throw",t,s,u)}))}u(c.arg)}var a;o(this,"_invoke",{value:function(t,r){function n(){return new e((function(e,n){i(t,r,e,n)}))}return a=a?a.then(n,n):n()}})}function A(t,e,r){var n="suspendedStart";return function(i,o){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===i)throw o;return{value:void 0,done:!0}}for(r.method=i,r.arg=o;;){var a=r.delegate;if(a){var s=k(a,r);if(s){if(s===p)continue;return s}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var u=l(t,e,r);if("normal"===u.type){if(n=r.done?"completed":"suspendedYield",u.arg===p)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n="completed",r.method="throw",r.arg=u.arg)}}}function k(t,e){var r=e.method,n=t.iterator[r];if(void 0===n)return e.delegate=null,"throw"===r&&t.iterator.return&&(e.method="return",e.arg=void 0,k(t,e),"throw"===e.method)||"return"!==r&&(e.method="throw",e.arg=new TypeError("The iterator does not provide a '"+r+"' method")),p;var i=l(n,t.iterator,e.arg);if("throw"===i.type)return e.method="throw",e.arg=i.arg,e.delegate=null,p;var o=i.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,p):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,p)}function _(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function O(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function I(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(_,this),this.reset(!0)}function S(t){if(t){var e=t[s];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,i=function e(){for(;++n=0;--i){var o=this.tryEntries[i],a=o.completion;if("root"===o.tryLoc)return n("end");if(o.tryLoc<=this.prev){var s=r.call(o,"catchLoc"),u=r.call(o,"finallyLoc");if(s&&u){if(this.prev=0;--n){var i=this.tryEntries[n];if(i.tryLoc<=this.prev&&r.call(i,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),O(r),p}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var i=n.arg;O(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:S(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),p}},t}function o(t,e,r,n,i,o,a){try{var s=t[o](a),u=s.value}catch(t){return void r(t)}s.done?e(u):Promise.resolve(u).then(n,i)}function a(t){return function(){var e=this,r=arguments;return new Promise((function(n,i){var a=t.apply(e,r);function s(t){o(a,n,i,s,u,"next",t)}function u(t){o(a,n,i,s,u,"throw",t)}s(void 0)}))}}r.r(e),r.d(e,{bigInt:()=>s,bulkMemory:()=>u,exceptions:()=>c,multiValue:()=>f,mutableGlobals:()=>h,referenceTypes:()=>l,saturatedFloatToInt:()=>p,signExtensions:()=>d,simd:()=>y,tailCall:()=>g,threads:()=>v});var s=function(){return(t=a(i().mark((function t(e){return i().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,WebAssembly.instantiate(e);case 3:return t.t0=t.sent.instance.exports.b(BigInt(0)),t.t1=BigInt(0),t.abrupt("return",t.t0===t.t1);case 8:return t.prev=8,t.t2=t.catch(0),t.abrupt("return",!1);case 11:case"end":return t.stop()}}),t,null,[[0,8]])}))),function(e){return t.apply(this,arguments)})(new Uint8Array([0,97,115,109,1,0,0,0,1,6,1,96,1,126,1,126,3,2,1,0,7,5,1,1,98,0,0,10,6,1,4,0,32,0,11]));var t},u=function(){var t=a(i().mark((function t(){return i().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,5,3,1,0,1,10,14,1,12,0,65,0,65,0,65,0,252,10,0,0,11])));case 1:case"end":return t.stop()}}),t)})));return function(){return t.apply(this,arguments)}}(),c=function(){var t=a(i().mark((function t(){return i().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,10,8,1,6,0,6,64,25,11,11])));case 1:case"end":return t.stop()}}),t)})));return function(){return t.apply(this,arguments)}}(),f=function(){var t=a(i().mark((function t(){return i().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,6,1,96,0,2,127,127,3,2,1,0,10,8,1,6,0,65,0,65,0,11])));case 1:case"end":return t.stop()}}),t)})));return function(){return t.apply(this,arguments)}}(),h=function(){var t=a(i().mark((function t(){return i().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,2,8,1,1,97,1,98,3,127,1,6,6,1,127,1,65,0,11,7,5,1,1,97,3,1])));case 1:case"end":return t.stop()}}),t)})));return function(){return t.apply(this,arguments)}}(),l=function(){var t=a(i().mark((function t(){return i().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,10,7,1,5,0,208,112,26,11])));case 1:case"end":return t.stop()}}),t)})));return function(){return t.apply(this,arguments)}}(),p=function(){var t=a(i().mark((function t(){return i().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,10,12,1,10,0,67,0,0,0,0,252,0,26,11])));case 1:case"end":return t.stop()}}),t)})));return function(){return t.apply(this,arguments)}}(),d=function(){var t=a(i().mark((function t(){return i().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,10,8,1,6,0,65,0,192,26,11])));case 1:case"end":return t.stop()}}),t)})));return function(){return t.apply(this,arguments)}}(),y=function(){var t=a(i().mark((function t(){return i().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,5,1,96,0,1,123,3,2,1,0,10,10,1,8,0,65,0,253,15,253,98,11])));case 1:case"end":return t.stop()}}),t)})));return function(){return t.apply(this,arguments)}}(),g=function(){var t=a(i().mark((function t(){return i().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,10,6,1,4,0,18,0,11])));case 1:case"end":return t.stop()}}),t)})));return function(){return t.apply(this,arguments)}}(),v=function(){return(t=a(i().mark((function t(e){return i().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.abrupt("return",("undefined"!=typeof MessageChannel&&(new MessageChannel).port1.postMessage(new SharedArrayBuffer(1)),WebAssembly.validate(e)));case 4:return t.prev=4,t.t0=t.catch(0),t.abrupt("return",!1);case 7:case"end":return t.stop()}}),t,null,[[0,4]])}))),function(e){return t.apply(this,arguments)})(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,5,4,1,3,1,1,10,11,1,9,0,65,0,254,16,2,0,26,11]));var t}},645:function(t,e,r){var n=r(33).lW;(function(){"use strict";function t(t){throw t}var r=void 0,i=!0,o="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Uint32Array&&"undefined"!=typeof DataView;function a(e,r){this.index="number"==typeof r?r:0,this.m=0,this.buffer=e instanceof(o?Uint8Array:Array)?e:new(o?Uint8Array:Array)(32768),2*this.buffer.length<=this.index&&t(Error("invalid index")),this.buffer.length<=this.index&&this.f()}a.prototype.f=function(){var t,e=this.buffer,r=e.length,n=new(o?Uint8Array:Array)(r<<1);if(o)n.set(e);else for(t=0;t>>8&255]<<16|l[t>>>16&255]<<8|l[t>>>24&255])>>32-e:l[t]>>8-e),8>e+a)s=s<>e-n-1&1,8==++a&&(a=0,i[o++]=l[s],s=0,o===i.length&&(i=this.f()));i[o]=s,this.buffer=i,this.m=a,this.index=o},a.prototype.finish=function(){var t,e=this.buffer,r=this.index;return 0s;++s){for(var c=h=s,f=7,h=h>>>1;h;h>>>=1)c<<=1,c|=1&h,--f;u[s]=(c<>>0}var l=u;function p(t,e,r){var n,i="number"==typeof e?e:e=0,o="number"==typeof r?r:t.length;for(n=-1,i=7&o;i--;++e)n=n>>>8^y[255&(n^t[e])];for(i=o>>3;i--;e+=8)n=(n=(n=(n=(n=(n=(n=(n=n>>>8^y[255&(n^t[e])])>>>8^y[255&(n^t[e+1])])>>>8^y[255&(n^t[e+2])])>>>8^y[255&(n^t[e+3])])>>>8^y[255&(n^t[e+4])])>>>8^y[255&(n^t[e+5])])>>>8^y[255&(n^t[e+6])])>>>8^y[255&(n^t[e+7])];return(4294967295^n)>>>0}var d=[0,1996959894,3993919788,2567524794,124634137,1886057615,3915621685,2657392035,249268274,2044508324,3772115230,2547177864,162941995,2125561021,3887607047,2428444049,498536548,1789927666,4089016648,2227061214,450548861,1843258603,4107580753,2211677639,325883990,1684777152,4251122042,2321926636,335633487,1661365465,4195302755,2366115317,997073096,1281953886,3579855332,2724688242,1006888145,1258607687,3524101629,2768942443,901097722,1119000684,3686517206,2898065728,853044451,1172266101,3705015759,2882616665,651767980,1373503546,3369554304,3218104598,565507253,1454621731,3485111705,3099436303,671266974,1594198024,3322730930,2970347812,795835527,1483230225,3244367275,3060149565,1994146192,31158534,2563907772,4023717930,1907459465,112637215,2680153253,3904427059,2013776290,251722036,2517215374,3775830040,2137656763,141376813,2439277719,3865271297,1802195444,476864866,2238001368,4066508878,1812370925,453092731,2181625025,4111451223,1706088902,314042704,2344532202,4240017532,1658658271,366619977,2362670323,4224994405,1303535960,984961486,2747007092,3569037538,1256170817,1037604311,2765210733,3554079995,1131014506,879679996,2909243462,3663771856,1141124467,855842277,2852801631,3708648649,1342533948,654459306,3188396048,3373015174,1466479909,544179635,3110523913,3462522015,1591671054,702138776,2966460450,3352799412,1504918807,783551873,3082640443,3233442989,3988292384,2596254646,62317068,1957810842,3939845945,2647816111,81470997,1943803523,3814918930,2489596804,225274430,2053790376,3826175755,2466906013,167816743,2097651377,4027552580,2265490386,503444072,1762050814,4150417245,2154129355,426522225,1852507879,4275313526,2312317920,282753626,1742555852,4189708143,2394877945,397917763,1622183637,3604390888,2714866558,953729732,1340076626,3518719985,2797360999,1068828381,1219638859,3624741850,2936675148,906185462,1090812512,3747672003,2825379669,829329135,1181335161,3412177804,3160834842,628085408,1382605366,3423369109,3138078467,570562233,1426400815,3317316542,2998733608,733239954,1555261956,3268935591,3050360625,752459403,1541320221,2607071920,3965973030,1969922972,40735498,2617837225,3943577151,1913087877,83908371,2512341634,3803740692,2075208622,213261112,2463272603,3855990285,2094854071,198958881,2262029012,4057260610,1759359992,534414190,2176718541,4139329115,1873836001,414664567,2282248934,4279200368,1711684554,285281116,2405801727,4167216745,1634467795,376229701,2685067896,3608007406,1308918612,956543938,2808555105,3495958263,1231636301,1047427035,2932959818,3654703836,1088359270,936918e3,2847714899,3736837829,1202900863,817233897,3183342108,3401237130,1404277552,615818150,3134207493,3453421203,1423857449,601450431,3009837614,3294710456,1567103746,711928724,3020668471,3272380065,1510334235,755167117],y=o?new Uint32Array(d):d;function g(){}function v(t){this.buffer=new(o?Uint16Array:Array)(2*t),this.length=0}function b(t){var e,r,n,i,a,s,u,c,f,h,l=t.length,p=0,d=Number.POSITIVE_INFINITY;for(c=0;cp&&(p=t[c]),t[c]>=1;for(h=n<<16|c,f=s;fo[n]);)i=o[r],o[r]=o[n],o[n]=i,i=o[r+1],o[r+1]=o[n+1],o[n+1]=i,r=n;return this.length},v.prototype.pop=function(){var t,e,r,n,i,o=this.buffer;for(e=o[0],t=o[1],this.length-=2,o[0]=o[this.length],o[1]=o[this.length+1],i=0;!((n=2*i+2)>=this.length)&&(n+2o[n]&&(n+=2),o[n]>o[i]);)r=o[i],o[i]=o[n],o[n]=r,r=o[i+1],o[i+1]=o[n+1],o[n+1]=r,i=n;return{index:t,value:e,length:this.length}};var m,E=2,x={NONE:0,L:1,t:E,X:3},A=[];for(m=0;288>m;m++)switch(i){case 143>=m:A.push([m+48,8]);break;case 255>=m:A.push([m-144+400,9]);break;case 279>=m:A.push([m-256+0,7]);break;case 287>=m:A.push([m-280+192,8]);break;default:t("invalid literal: "+m)}function k(t,e){this.length=t,this.N=e}w.prototype.h=function(){var e,n,s,u,c=this.input;switch(this.k){case 0:for(s=0,u=c.length;s>>8&255,v[b++]=255&l,v[b++]=l>>>8&255,o)v.set(p,b),b+=p.length,v=v.subarray(0,b);else{for(y=0,g=p.length;yJ)for(;0J?J:138)>J-3&&Q=Q?(rt[$++]=17,rt[$++]=Q-3,nt[17]++):(rt[$++]=18,rt[$++]=Q-11,nt[18]++),J-=Q;else if(rt[$++]=et[H],nt[et[H]]++,3>--J)for(;0J?J:6)>J-3&&QD;D++)q[D]=M[V[D]];for(T=19;4=e:return[265,e-11,1];case 14>=e:return[266,e-13,1];case 16>=e:return[267,e-15,1];case 18>=e:return[268,e-17,1];case 22>=e:return[269,e-19,2];case 26>=e:return[270,e-23,2];case 30>=e:return[271,e-27,2];case 34>=e:return[272,e-31,2];case 42>=e:return[273,e-35,3];case 50>=e:return[274,e-43,3];case 58>=e:return[275,e-51,3];case 66>=e:return[276,e-59,3];case 82>=e:return[277,e-67,4];case 98>=e:return[278,e-83,4];case 114>=e:return[279,e-99,4];case 130>=e:return[280,e-115,4];case 162>=e:return[281,e-131,5];case 194>=e:return[282,e-163,5];case 226>=e:return[283,e-195,5];case 257>=e:return[284,e-227,5];case 258===e:return[285,e-258,0];default:t("invalid length: "+e)}}var r,n,o=[];for(r=3;258>=r;r++)n=e(r),o[r]=n[2]<<24|n[1]<<16|n[0];return o}(),O=o?new Uint32Array(_):_;function I(e,n){function a(e,r){var n,o,a,s,u=e.N,c=[],f=0;switch(n=O[e.length],c[f++]=65535&n,c[f++]=n>>16&255,c[f++]=n>>24,i){case 1===u:o=[0,u-1,0];break;case 2===u:o=[1,u-2,0];break;case 3===u:o=[2,u-3,0];break;case 4===u:o=[3,u-4,0];break;case 6>=u:o=[4,u-5,1];break;case 8>=u:o=[5,u-7,1];break;case 12>=u:o=[6,u-9,2];break;case 16>=u:o=[7,u-13,2];break;case 24>=u:o=[8,u-17,3];break;case 32>=u:o=[9,u-25,3];break;case 48>=u:o=[10,u-33,4];break;case 64>=u:o=[11,u-49,4];break;case 96>=u:o=[12,u-65,5];break;case 128>=u:o=[13,u-97,5];break;case 192>=u:o=[14,u-129,6];break;case 256>=u:o=[15,u-193,6];break;case 384>=u:o=[16,u-257,7];break;case 512>=u:o=[17,u-385,7];break;case 768>=u:o=[18,u-513,8];break;case 1024>=u:o=[19,u-769,8];break;case 1536>=u:o=[20,u-1025,9];break;case 2048>=u:o=[21,u-1537,9];break;case 3072>=u:o=[22,u-2049,10];break;case 4096>=u:o=[23,u-3073,10];break;case 6144>=u:o=[24,u-4097,11];break;case 8192>=u:o=[25,u-6145,11];break;case 12288>=u:o=[26,u-8193,12];break;case 16384>=u:o=[27,u-12289,12];break;case 24576>=u:o=[28,u-16385,13];break;case 32768>=u:o=[29,u-24577,13];break;default:t("invalid distance")}for(n=o,c[f++]=n[0],c[f++]=n[1],c[f++]=n[2],a=0,s=c.length;a=c;)m[c++]=0;for(c=0;29>=c;)E[c++]=0}for(m[256]=1,s=0,u=n.length;s=u){for(d&&a(d,-1),c=0,f=u-s;co&&e+oc&&(i=n,c=o),258===o)break}return new k(c,e-i)}function L(t,e){var r,n,i,a,s,u=t.length,c=new v(572),f=new(o?Uint8Array:Array)(u);if(!o)for(a=0;a2*f[a-1]+h[a]&&(f[a]=2*f[a-1]+h[a]),p[a]=Array(f[a]),d[a]=Array(f[a]);for(i=0;it[i]?(p[a][s]=u,d[a][s]=e,c+=2):(p[a][s]=t[i],d[a][s]=i,++i);y[a]=0,1===h[a]&&n(a)}return l}(n,n.length,e),a=0,s=r.length;a>>=1;return a}function j(t,e){this.input=t,this.b=this.c=0,this.g={},e&&(e.flags&&(this.g=e.flags),"string"==typeof e.filename&&(this.filename=e.filename),"string"==typeof e.comment&&(this.w=e.comment),e.deflateOptions&&(this.l=e.deflateOptions)),this.l||(this.l={})}j.prototype.h=function(){var t,e,n,i,a,s,u,c,f=new(o?Uint8Array:Array)(32768),h=0,l=this.input,d=this.c,y=this.filename,g=this.w;if(f[h++]=31,f[h++]=139,f[h++]=8,t=0,this.g.fname&&(t|=P),this.g.fcomment&&(t|=R),this.g.fhcrc&&(t|=T),f[h++]=t,e=(Date.now?Date.now():+new Date)/1e3|0,f[h++]=255&e,f[h++]=e>>>8&255,f[h++]=e>>>16&255,f[h++]=e>>>24&255,f[h++]=0,f[h++]=B,this.g.fname!==r){for(u=0,c=y.length;u>>8&255),f[h++]=255&s;f[h++]=0}if(this.g.comment){for(u=0,c=g.length;u>>8&255),f[h++]=255&s;f[h++]=0}return this.g.fhcrc&&(n=65535&p(f,0,h),f[h++]=255&n,f[h++]=n>>>8&255),this.l.outputBuffer=f,this.l.outputIndex=h,f=(a=new w(l,this.l)).h(),h=a.b,o&&(h+8>f.buffer.byteLength?(this.a=new Uint8Array(h+8),this.a.set(new Uint8Array(f.buffer)),f=this.a):f=new Uint8Array(f.buffer)),i=p(l,r,r),f[h++]=255&i,f[h++]=i>>>8&255,f[h++]=i>>>16&255,f[h++]=i>>>24&255,c=l.length,f[h++]=255&c,f[h++]=c>>>8&255,f[h++]=c>>>16&255,f[h++]=c>>>24&255,this.c=d,o&&h>>=1){case 0:var n=this.input,a=this.c,s=this.a,u=this.b,c=n.length,f=r,h=s.length,l=r;switch(this.e=this.j=0,a+1>=c&&t(Error("invalid uncompressed block header: LEN")),f=n[a++]|n[a++]<<8,a+1>=c&&t(Error("invalid uncompressed block header: NLEN")),f===~(n[a++]|n[a++]<<8)&&t(Error("invalid uncompressed block header: length verify")),a+f>n.length&&t(Error("input buffer is broken")),this.q){case N:for(;u+f>s.length;){if(f-=l=h-u,o)s.set(n.subarray(a,a+l),u),u+=l,a+=l;else for(;l--;)s[u++]=n[a++];this.b=u,s=this.f(),u=this.b}break;case M:for(;u+f>s.length;)s=this.f({B:2});break;default:t(Error("invalid inflate mode"))}if(o)s.set(n.subarray(a,a+f),u),u+=f,a+=f;else for(;f--;)s[u++]=n[a++];this.c=a,this.b=u,this.a=s;break;case 1:this.r(tt,rt);break;case 2:var p,d,y,g,v=nt(this,5)+257,w=nt(this,5)+1,m=nt(this,4)+4,E=new(o?Uint8Array:Array)(D.length),x=r,A=r,k=r,_=r,O=r;for(O=0;O=F?8:255>=F?9:279>=F?7:8;var Q,Z,tt=b($),et=new(o?Uint8Array:Array)(30);for(Q=0,Z=et.length;Q=u&&t(Error("input buffer is broken")),i|=a[s++]<>>r,e.e=o-r,e.c=s,n}function it(e,r){for(var n,i,o=e.j,a=e.e,s=e.input,u=e.c,c=s.length,f=r[0],h=r[1];a=c);)o|=s[u++]<>>16)>a&&t(Error("invalid code length: "+i)),e.j=o>>i,e.e=a-i,e.c=u,65535&n}function ot(t){this.input=t,this.c=0,this.G=[],this.R=!1}function at(t){if("string"==typeof t){var e,r,n=t.split("");for(e=0,r=n.length;e>>0;t=n}for(var i,o=1,a=0,s=t.length,u=0;0>>0}function st(e,r){var n,i;this.input=e,this.c=0,!r&&(r={})||(r.index&&(this.c=r.index),r.verify&&(this.V=r.verify)),n=e[this.c++],i=e[this.c++],(15&n)===ut?this.method=ut:t(Error("unsupported compression method")),0!=((n<<8)+i)%31&&t(Error("invalid fcheck flag:"+((n<<8)+i)%31)),32&i&&t(Error("fdict flag is not supported")),this.J=new C(e,{index:this.c,bufferSize:r.bufferSize,bufferType:r.bufferType,resize:r.resize})}C.prototype.r=function(t,e){var r=this.a,n=this.b;this.A=t;for(var i,o,a,s,u=r.length-258;256!==(i=it(this,t));)if(256>i)n>=u&&(this.b=n,r=this.f(),n=this.b),r[n++]=i;else for(s=Y[o=i-257],0=u&&(this.b=n,r=this.f(),n=this.b);s--;)r[n]=r[n++-a];for(;8<=this.e;)this.e-=8,this.c--;this.b=n},C.prototype.Q=function(t,e){var r=this.a,n=this.b;this.A=t;for(var i,o,a,s,u=r.length;256!==(i=it(this,t));)if(256>i)n>=u&&(u=(r=this.f()).length),r[n++]=i;else for(s=Y[o=i-257],0u&&(u=(r=this.f()).length);s--;)r[n]=r[n++-a];for(;8<=this.e;)this.e-=8,this.c--;this.b=n},C.prototype.f=function(){var t,e,r=new(o?Uint8Array:Array)(this.b-32768),n=this.b-32768,i=this.a;if(o)r.set(i.subarray(32768,r.length));else for(t=0,e=r.length;tt;++t)i[t]=i[n+t];return this.b=32768,i},C.prototype.S=function(t){var e,r,n,i=this.input.length/this.c+1|0,a=this.input,s=this.a;return t&&("number"==typeof t.B&&(i=t.B),"number"==typeof t.M&&(i+=t.M)),r=2>i?(n=(a.length-this.c)/this.A[2]/2*258|0)e&&(this.a.length=e),t=this.a),this.buffer=t},ot.prototype.i=function(){for(var e=this.input.length;this.c>>0,p(n,r,r)!==y&&t(Error("invalid CRC-32 checksum: 0x"+p(n,r,r).toString(16)+" / 0x"+y.toString(16))),s.Z=u=(v[b++]|v[b++]<<8|v[b++]<<16|v[b++]<<24)>>>0,(4294967295&n.length)!==u&&t(Error("invalid input size: "+(4294967295&n.length)+" / "+u)),this.G.push(s),this.c=b}this.R=i;var w,m,E,x=this.G,A=0,k=0;for(w=0,m=x.length;w>>0!==at(e)&&t(Error("invalid adler-32 checksum")),e};var ut=8;function ct(t,e){this.input=t,this.a=new(o?Uint8Array:Array)(32768),this.k=ft.t;var r,n={};for(r in!e&&(e={})||"number"!=typeof e.compressionType||(this.k=e.compressionType),e)n[r]=e[r];n.outputBuffer=this.a,this.I=new w(this.input,n)}var ft=x;function ht(t,e){var r;return r=new ct(t).h(),e||(e={}),e.H?r:yt(r)}function lt(t,e){var r;return t.subarray=t.slice,r=new st(t).i(),e||(e={}),e.noBuffer?r:yt(r)}function pt(t,e){var r;return t.subarray=t.slice,r=new j(t).h(),e||(e={}),e.H?r:yt(r)}function dt(t,e){var r;return t.subarray=t.slice,r=new ot(t).i(),e||(e={}),e.H?r:yt(r)}function yt(t){var e,r,i=new n(t.length);for(e=0,r=t.length;e>24&255,u[c++]=s>>16&255,u[c++]=s>>8&255,u[c++]=255&s,u},e.deflate=function(t,e,r){process.nextTick((function(){var n,i;try{i=ht(t,r)}catch(t){n=t}e(n,i)}))},e.deflateSync=ht,e.inflate=function(t,e,r){process.nextTick((function(){var n,i;try{i=lt(t,r)}catch(t){n=t}e(n,i)}))},e.inflateSync=lt,e.gzip=function(t,e,r){process.nextTick((function(){var n,i;try{i=pt(t,r)}catch(t){n=t}e(n,i)}))},e.gzipSync=pt,e.gunzip=function(t,e,r){process.nextTick((function(){var n,i;try{i=dt(t,r)}catch(t){n=t}e(n,i)}))},e.gunzipSync=dt}).call(this)},711:t=>{t.exports={OSD_ONLY:"0",AUTO_OSD:"1",AUTO_ONLY:"2",AUTO:"3",SINGLE_COLUMN:"4",SINGLE_BLOCK_VERT_TEXT:"5",SINGLE_BLOCK:"6",SINGLE_LINE:"7",SINGLE_WORD:"8",CIRCLE_WORD:"9",SINGLE_CHAR:"10",SPARSE_TEXT:"11",SPARSE_TEXT_OSD:"12",RAW_LINE:"13"}},862:t=>{t.exports={COLOR:0,GREY:1,BINARY:2}},129:(t,e,r)=>{function n(t){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},n(t)}var i=r(670);t.exports=function(t){var e={};return"undefined"!=typeof WorkerGlobalScope?e.type="webworker":i()?e.type="electron":"object"===("undefined"==typeof document?"undefined":n(document))?e.type="browser":"object"===("undefined"==typeof process?"undefined":n(process))&&(e.type="node"),void 0===t?e:e[t]}},185:function(t,e){var r=this,n=!1;e.logging=n,e.setLogging=function(t){n=t},e.log=function(){for(var t=arguments.length,e=new Array(t),i=0;i{var n=r(160),i=n.set,o=n.get,a=n.del;t.exports={readCache:o,writeCache:i,deleteCache:a,checkCache:function(t){return o(t).then((function(t){return void 0!==t}))}}},485:(t,e,r)=>{function n(){"use strict";n=function(){return t};var t={},e=Object.prototype,r=e.hasOwnProperty,o=Object.defineProperty||function(t,e,r){t[e]=r.value},a="function"==typeof Symbol?Symbol:{},s=a.iterator||"@@iterator",u=a.asyncIterator||"@@asyncIterator",c=a.toStringTag||"@@toStringTag";function f(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{f({},"")}catch(t){f=function(t,e,r){return t[e]=r}}function h(t,e,r,n){var i=e&&e.prototype instanceof d?e:d,a=Object.create(i.prototype),s=new I(n||[]);return o(a,"_invoke",{value:A(t,r,s)}),a}function l(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=h;var p={};function d(){}function y(){}function g(){}var v={};f(v,s,(function(){return this}));var b=Object.getPrototypeOf,w=b&&b(b(S([])));w&&w!==e&&r.call(w,s)&&(v=w);var m=g.prototype=d.prototype=Object.create(v);function E(t){["next","throw","return"].forEach((function(e){f(t,e,(function(t){return this._invoke(e,t)}))}))}function x(t,e){function n(o,a,s,u){var c=l(t[o],t,a);if("throw"!==c.type){var f=c.arg,h=f.value;return h&&"object"==i(h)&&r.call(h,"__await")?e.resolve(h.__await).then((function(t){n("next",t,s,u)}),(function(t){n("throw",t,s,u)})):e.resolve(h).then((function(t){f.value=t,s(f)}),(function(t){return n("throw",t,s,u)}))}u(c.arg)}var a;o(this,"_invoke",{value:function(t,r){function i(){return new e((function(e,i){n(t,r,e,i)}))}return a=a?a.then(i,i):i()}})}function A(t,e,r){var n="suspendedStart";return function(i,o){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===i)throw o;return{value:void 0,done:!0}}for(r.method=i,r.arg=o;;){var a=r.delegate;if(a){var s=k(a,r);if(s){if(s===p)continue;return s}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var u=l(t,e,r);if("normal"===u.type){if(n=r.done?"completed":"suspendedYield",u.arg===p)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n="completed",r.method="throw",r.arg=u.arg)}}}function k(t,e){var r=e.method,n=t.iterator[r];if(void 0===n)return e.delegate=null,"throw"===r&&t.iterator.return&&(e.method="return",e.arg=void 0,k(t,e),"throw"===e.method)||"return"!==r&&(e.method="throw",e.arg=new TypeError("The iterator does not provide a '"+r+"' method")),p;var i=l(n,t.iterator,e.arg);if("throw"===i.type)return e.method="throw",e.arg=i.arg,e.delegate=null,p;var o=i.arg;return o?o.done?(e[t.resultName]=o.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,p):o:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,p)}function _(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function O(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function I(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(_,this),this.reset(!0)}function S(t){if(t){var e=t[s];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,i=function e(){for(;++n=0;--i){var o=this.tryEntries[i],a=o.completion;if("root"===o.tryLoc)return n("end");if(o.tryLoc<=this.prev){var s=r.call(o,"catchLoc"),u=r.call(o,"finallyLoc");if(s&&u){if(this.prev=0;--n){var i=this.tryEntries[n];if(i.tryLoc<=this.prev&&r.call(i,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),O(r),p}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var i=n.arg;O(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:S(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),p}},t}function i(t){return i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},i(t)}function o(t,e,r,n,i,o,a){try{var s=t[o](a),u=s.value}catch(t){return void r(t)}s.done?e(u):Promise.resolve(u).then(n,i)}var a=r(506).simd,s=r(147).HO._X;t.exports=function(){var t,e=(t=n().mark((function t(e,o,u){var c,f,h,l;return n().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(void 0!==r.g.TesseractCore){t.next=20;break}if(c="loading tesseract core",u.progress({status:c,progress:0}),"js"!==(f=o||"https://cdn.jsdelivr.net/npm/tesseract.js-core@v".concat(s.substring(1))).slice(-2)){t.next=8;break}h=f,t.next=12;break;case 8:return t.next=10,a();case 10:l=t.sent,h="".concat(f.replace(/\/$/,""),l?e?"/tesseract-core-simd-lstm.wasm.js":"/tesseract-core-simd.wasm.js":e?"/tesseract-core-lstm.wasm.js":"/tesseract-core.wasm.js");case 12:if(r.g.importScripts(h),void 0!==r.g.TesseractCore||void 0===r.g.TesseractCoreWASM||"object"!==("undefined"==typeof WebAssembly?"undefined":i(WebAssembly))){t.next=17;break}r.g.TesseractCore=r.g.TesseractCoreWASM,t.next=19;break;case 17:if(void 0!==r.g.TesseractCore){t.next=19;break}throw Error("Failed to load TesseractCore");case 19:u.progress({status:c,progress:1});case 20:return t.abrupt("return",r.g.TesseractCore);case 21:case"end":return t.stop()}}),t)})),function(){var e=this,r=arguments;return new Promise((function(n,i){var a=t.apply(e,r);function s(t){o(a,n,i,s,u,"next",t)}function u(t){o(a,n,i,s,u,"throw",t)}s(void 0)}))});return function(t,r,n){return e.apply(this,arguments)}}()},687:(t,e,r)=>{t.exports=r(645).gunzipSync},730:t=>{t.exports={text:!0,blocks:!0,layoutBlocks:!1,hocr:!0,tsv:!0,box:!1,unlv:!1,osd:!1,pdf:!1,imageColor:!1,imageGrey:!1,imageBinary:!1,debug:!1}},688:(t,e,r)=>{var n=r(711);t.exports={tessedit_pageseg_mode:n.SINGLE_BLOCK,tessedit_char_whitelist:"",tessjs_create_hocr:"1",tessjs_create_tsv:"1",tessjs_create_box:"0",tessjs_create_unlv:"0",tessjs_create_osd:"0"}},217:function(t,e,r){var n=this;function i(t){return i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},i(t)}function o(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function a(t){for(var e=1;et.length)&&(e=t.length);for(var r=0,n=new Array(e);r=0;--i){var o=this.tryEntries[i],a=o.completion;if("root"===o.tryLoc)return n("end");if(o.tryLoc<=this.prev){var s=r.call(o,"catchLoc"),u=r.call(o,"finallyLoc");if(s&&u){if(this.prev=0;--n){var i=this.tryEntries[n];if(i.tryLoc<=this.prev&&r.call(i,"finallyLoc")&&this.prev=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),O(r),p}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var i=n.arg;O(r)}return i}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:S(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),p}},t}function f(t,e,r,n,i,o,a){try{var s=t[o](a),u=s.value}catch(t){return void r(t)}s.done?e(u):Promise.resolve(u).then(n,i)}function h(t){return function(){var e=this,r=arguments;return new Promise((function(n,i){var o=t.apply(e,r);function a(t){f(o,n,i,a,s,"next",t)}function s(t){f(o,n,i,a,s,"throw",t)}a(void 0)}))}}r(760);var l,p,d,y,g=r(975),v=r(333),b=r(129)("type"),w=r(472),m=r(688),E=r(730),x=r(185),A=x.log,k=x.setLogging,_=r(711),O=null,I={},S=m,L=!1,U=function(){var t=h(c().mark((function t(e,r){var n,i,o,a,s,u,f,h;return c().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=e.workerId,i=e.jobId,o=e.payload.options,a=o.lstmOnly,s=o.corePath,u=o.logging,k(u),f="initializing tesseract",l){t.next=11;break}return t.next=6,I.getCore(a,s,r);case 6:h=t.sent,r.progress({workerId:n,status:f,progress:0}),h({TesseractProgress:function(t){p.progress({workerId:n,jobId:i,status:"recognizing text",progress:Math.max(0,(t-30)/70)})}}).then((function(t){l=t,r.progress({workerId:n,status:f,progress:1}),r.resolve({loaded:!0})})),t.next=12;break;case 11:r.resolve({loaded:!0});case 12:case"end":return t.stop()}}),t)})));return function(e,r){return t.apply(this,arguments)}}(),j=function(){var t=h(c().mark((function t(e,r){var n,i,o,a,s;return c().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:i=e.workerId,o=e.payload,a=o.method,s=o.args,A("[".concat(i,"]: FS.").concat(a)),r.resolve((n=l.FS)[a].apply(n,function(t){if(Array.isArray(t))return u(t)}(c=s)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(c)||function(t,e){if(t){if("string"==typeof t)return u(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?u(t,e):void 0}}(c)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()));case 3:case"end":return t.stop()}var c}),t)})));return function(e,r){return t.apply(this,arguments)}}(),B=function(){var t=h(c().mark((function t(e,r){var n,i,o,a,s,u,f,p,v,w,m,E,x,k,_;return c().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=e.workerId,i=e.payload,o=i.langs,a=i.options,s=a.langPath,u=a.dataPath,f=a.cachePath,p=a.cacheMethod,v=a.gzip,w=void 0===v||v,m=a.lstmOnly,d=o,y={langPath:s,dataPath:u,cachePath:f,cacheMethod:p,gzip:w,lstmOnly:m},E="loading language traineddata",x="string"==typeof o?o.split("+"):o,k=0,_=function(){var t=h(c().mark((function t(e){var i,o,a,h,d,y,v,_,O;return c().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return i="string"==typeof e?e:e.code,o=["refresh","none"].includes(p)?function(){return Promise.resolve()}:I.readCache,a=null,h=!1,t.prev=4,t.next=7,o("".concat(f||".","/").concat(i,".traineddata"));case 7:if(void 0===(d=t.sent)){t.next=14;break}A("[".concat(n,"]: Load ").concat(i,".traineddata from cache")),a=d,L=!0,t.next=15;break;case 14:throw Error("Not found in cache");case 15:t.next=45;break;case 17:if(t.prev=17,t.t0=t.catch(4),h=!0,A("[".concat(n,"]: Load ").concat(i,".traineddata from ").concat(s)),"string"!=typeof e){t.next=44;break}if(y=null,v=s||"https://cdn.jsdelivr.net/npm/@tesseract.js-data/".concat(i,m?"/4.0.0_best_int":"/4.0.0"),("node"!==b||g(v)||v.startsWith("moz-extension://")||v.startsWith("chrome-extension://")||v.startsWith("file://"))&&(y=v.replace(/\/$/,"")),null===y){t.next=39;break}return _="".concat(y,"/").concat(i,".traineddata").concat(w?".gz":""),t.next=29,("webworker"===b?fetch:I.fetch)(_);case 29:if((O=t.sent).ok){t.next=32;break}throw Error("Network error while fetching ".concat(_,". Response code: ").concat(O.status));case 32:return t.t1=Uint8Array,t.next=35,O.arrayBuffer();case 35:t.t2=t.sent,a=new t.t1(t.t2),t.next=42;break;case 39:return t.next=41,I.readCache("".concat(v,"/").concat(i,".traineddata").concat(w?".gz":""));case 41:a=t.sent;case 42:t.next=45;break;case 44:a=e.data;case 45:if(k+=.5/x.length,r&&r.progress({workerId:n,status:E,progress:k}),(31===a[0]&&139===a[1]||31===a[1]&&139===a[0])&&(a=I.gunzip(a)),l){if(u)try{l.FS.mkdir(u)}catch(t){r&&r.reject(t.toString())}l.FS.writeFile("".concat(u||".","/").concat(i,".traineddata"),a)}if(!h||!["write","refresh",void 0].includes(p)){t.next=60;break}return t.prev=51,t.next=54,I.writeCache("".concat(f||".","/").concat(i,".traineddata"),a);case 54:t.next=60;break;case 56:t.prev=56,t.t3=t.catch(51),A("[".concat(n,"]: Failed to write ").concat(i,".traineddata to cache due to error:")),A(t.t3.toString());case 60:k+=.5/x.length,100===Math.round(100*k)&&(k=1),r&&r.progress({workerId:n,status:E,progress:k});case 63:case"end":return t.stop()}}),t,null,[[4,17],[51,56]])})));return function(e){return t.apply(this,arguments)}}(),r&&r.progress({workerId:n,status:E,progress:0}),t.prev=8,t.next=11,Promise.all(x.map(_));case 11:r&&r.resolve(o),t.next=17;break;case 14:t.prev=14,t.t0=t.catch(8),r&&r.reject(t.t0.toString());case 17:case"end":return t.stop()}}),t,null,[[8,14]])})));return function(e,r){return t.apply(this,arguments)}}(),T=function(){var t=h(c().mark((function t(e,r){var n,i,o;return c().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:n=e.payload.params,i=["ambigs_debug_level","user_words_suffix","user_patterns_suffix","user_patterns_suffix","load_system_dawg","load_freq_dawg","load_unambig_dawg","load_punc_dawg","load_number_dawg","load_bigram_dawg","tessedit_ocr_engine_mode","tessedit_init_config_only","language_model_ngram_on","language_model_use_sigmoidal_certainty"],(o=Object.keys(n).filter((function(t){return i.includes(t)})).join(", ")).length>0&&console.log("Attempted to set parameters that can only be set during initialization: ".concat(o)),Object.keys(n).filter((function(t){return!t.startsWith("tessjs_")})).forEach((function(t){O.SetVariable(t,n[t])})),S=a(a({},S),n),void 0!==r&&r.resolve(S);case 7:case"end":return t.stop()}}),t)})));return function(e,r){return t.apply(this,arguments)}}(),P=function(){var t=h(c().mark((function t(e,r){var n,o,a,s,u,f,h,p,g,v,b,w,E,x;return c().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=e.workerId,o=e.payload,a=o.langs,s=o.oem,u=o.config,f="string"==typeof a?a:a.map((function(t){return"string"==typeof t?t:t.data})).join("+"),h="initializing api",t.prev=3,r.progress({workerId:n,status:h,progress:0}),null!==O&&O.End(),u&&"object"===i(u)&&Object.keys(u).length>0?g=JSON.stringify(u).replace(/,/g,"\n").replace(/:/g," ").replace(/["'{}]/g,""):u&&"string"==typeof u&&(g=u),"string"==typeof g&&(p="/config",l.FS.writeFile(p,g)),O=new l.TessBaseAPI,-1!==(v=O.Init(null,f,s,p))){t.next=30;break}if(!["write","refresh",void 0].includes(y.cacheMethod)){t.next=30;break}return b=f.split("+"),w=b.map((function(t){return I.deleteCache("".concat(y.cachePath||".","/").concat(t,".traineddata"))})),t.next=16,Promise.all(w);case 16:if(E=l.FS.readFile("/debugDev.txt",{encoding:"utf8",flags:"a+"}),!L||!/components are not present/.test(E)){t.next=30;break}return A("Data from cache missing requested OEM model. Attempting to refresh cache with new language data."),t.next=21,B({workerId:n,payload:{langs:d,options:y}});case 21:if(-1!==(v=O.Init(null,f,s,p))){t.next=29;break}return A("Language data refresh failed."),x=b.map((function(t){return I.deleteCache("".concat(y.cachePath||".","/").concat(t,".traineddata"))})),t.next=27,Promise.all(x);case 27:t.next=30;break;case 29:A("Language data refresh successful.");case 30:return-1===v&&r.reject("initialization failed"),S=m,t.next=34,T({payload:{params:S}});case 34:r.progress({workerId:n,status:h,progress:1}),r.resolve(),t.next=41;break;case 38:t.prev=38,t.t0=t.catch(3),r.reject(t.t0.toString());case 41:case"end":return t.stop()}}),t,null,[[3,38]])})));return function(e,r){return t.apply(this,arguments)}}(),R=function(t,e){var r=new l.TessPDFRenderer("tesseract-ocr","/",e);return r.BeginDocument(t),r.AddImage(O),r.EndDocument(),l._free(r),l.FS.readFile("/tesseract-ocr.pdf")},C=function(){var t=h(c().mark((function t(e,r){var n,i,o;return c().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:n=e.payload,i=n.title,o=n.textonly,r.resolve(R(i,o));case 2:case"end":return t.stop()}}),t)})));return function(e,r){return t.apply(this,arguments)}}(),N=function(t){var e=JSON.parse(JSON.stringify(E));"1"===S.tessjs_create_box&&(e.box=!0),"1"===S.tessjs_create_hocr&&(e.hocr=!0),"1"===S.tessjs_create_osd&&(e.osd=!0),"1"===S.tessjs_create_tsv&&(e.tsv=!0),"1"===S.tessjs_create_unlv&&(e.unlv=!0);for(var r=["imageColor","imageGrey","imageBinary","layoutBlocks","debug"],n=0,i=0,o=Object.keys(t);i0)for(f=0,h=Object.keys(a);f0)for(O.SaveParameters(),d=0,y=Object.keys(u);d=.005?w(l,O,o,x=S):(I&&w(l,O,o),x=0)):(x=a.rotateRadians||0,w(l,O,o,x)),"object"===i(L=a.rectangle)&&O.SetRectangle(L.left,L.top,L.width,L.height),E?(s.layoutBlocks&&O.AnalyseLayout(),A("Skipping recognition: all output options requiring recognition are disabled.")):O.Recognize(null),U=a.pdfTitle,j=a.pdfTextOnly,(B=v(l,O,m,{pdfTitle:U,pdfTextOnly:j,skipRecognition:E})).rotateRadians=x,s.debug&&l.FS.unlink("/debugInternal.txt"),Object.keys(u).length>0&&O.RestoreParameters(),r.resolve(B)}catch(t){r.reject(t.toString())}case 2:case"end":return t.stop()}}),t)})));return function(e,r){return t.apply(this,arguments)}}(),G=function(){var t=h(c().mark((function t(e,r){var n,i,o,a,s;return c().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:n=e.payload.image;try{w(l,O,n),i=new l.OSResults,O.DetectOS(i)?(o=i.best_result,a=o.orientation_id,s=o.script_id,r.resolve({tesseract_script_id:s,script:i.unicharset.get_script_from_script_id(s),script_confidence:o.sconfidence,orientation_degrees:[0,270,180,90][a],orientation_confidence:o.oconfidence})):r.resolve({tesseract_script_id:null,script:null,script_confidence:null,orientation_degrees:null,orientation_confidence:null})}catch(t){r.reject(t.toString())}case 2:case"end":return t.stop()}}),t)})));return function(e,r){return t.apply(this,arguments)}}(),z=function(){var t=h(c().mark((function t(e,r){return c().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:try{null!==O&&O.End(),r.resolve({terminated:!0})}catch(t){r.reject(t.toString())}case 1:case"end":return t.stop()}}),t)})));return function(e,r){return t.apply(this,arguments)}}();e.dispatchHandlers=function(t,e){var r=function(r,n){var i={jobId:t.jobId,workerId:t.workerId,action:t.action};e(a(a({},i),{},{status:r,data:n}))};r.resolve=r.bind(n,"resolve"),r.reject=r.bind(n,"reject"),r.progress=r.bind(n,"progress"),p=r,{load:U,FS:j,loadLanguage:B,initialize:P,setParameters:T,recognize:F,getPDF:C,detect:G,terminate:z}[t.action](t,r).catch((function(t){return r.reject(t.toString())}))},e.setAdapter=function(t){I=t}},629:t=>{t.exports=function(t){for(var e,r="",n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",i=new Uint8Array(t),o=i.byteLength,a=o%3,s=o-a,u=0;u>18]+n[(258048&e)>>12]+n[(4032&e)>>6]+n[63&e];return 1===a?(e=i[s],r+="".concat(n[(252&e)>>2]+n[(3&e)<<4],"==")):2===a&&(e=i[s]<<8|i[s+1],r+="".concat(n[(64512&e)>>10]+n[(1008&e)>>4]+n[(15&e)<<2],"=")),r}},333:(t,e,r)=>{var n=r(629),i=r(862),o=function(t){var e=t.split("\n");if(" "===e[0].substring(0,2))for(var r=0;r0){var S=O.get_n(),L=O.get_x(),U=O.get_y();I=[];for(var j=0;j{var n=r(33).lW;function i(t){return i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},i(t)}function o(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function a(t){for(var e=1;e3&&void 0!==arguments[3]?arguments[3]:0,s=66===r[0]&&77===r[1]||66===r[1]&&77===r[0],c=parseInt(null===(i=r.slice(0,500).join(" ").match(/1 18 0 3 0 0 0 1 0 (\d)/))||void 0===i?void 0:i[1],10)||1;if(s){var f=n.from(Array.from(a(a({},r),{},{length:Object.keys(r).length}))),h=u.decode(f);t.FS.writeFile("/input",u.encode(h).data)}else t.FS.writeFile("/input",r);if(1===e.SetImageFile(c,o))throw Error("Error attempting to read image.")}},160:(t,e,r)=>{"use strict";function n(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r1&&void 0!==arguments[1]?arguments[1]:s())("readonly",(function(e){return i(e.get(t))}))}function c(t,e){return(arguments.length>2&&void 0!==arguments[2]?arguments[2]:s())("readwrite",(function(r){return r.put(e,t),i(r.transaction)}))}function f(t){return(arguments.length>1&&void 0!==arguments[1]?arguments[1]:s())("readwrite",(function(e){return t.forEach((function(t){return e.put(t[1],t[0])})),i(e.transaction)}))}function h(t){return(arguments.length>1&&void 0!==arguments[1]?arguments[1]:s())("readonly",(function(e){return Promise.all(t.map((function(t){return i(e.get(t))})))}))}function l(t,e){return(arguments.length>2&&void 0!==arguments[2]?arguments[2]:s())("readwrite",(function(r){return new Promise((function(n,o){r.get(t).onsuccess=function(){try{r.put(e(this.result),t),n(i(r.transaction))}catch(t){o(t)}}}))}))}function p(t){return(arguments.length>1&&void 0!==arguments[1]?arguments[1]:s())("readwrite",(function(e){return e.delete(t),i(e.transaction)}))}function d(t){return(arguments.length>1&&void 0!==arguments[1]?arguments[1]:s())("readwrite",(function(e){return t.forEach((function(t){return e.delete(t)})),i(e.transaction)}))}function y(){return(arguments.length>0&&void 0!==arguments[0]?arguments[0]:s())("readwrite",(function(t){return t.clear(),i(t.transaction)}))}function g(t,e){return t.openCursor().onsuccess=function(){this.result&&(e(this.result),this.result.continue())},i(t.transaction)}function v(){return(arguments.length>0&&void 0!==arguments[0]?arguments[0]:s())("readonly",(function(t){if(t.getAllKeys)return i(t.getAllKeys());var e=[];return g(t,(function(t){return e.push(t.key)})).then((function(){return e}))}))}function b(){return(arguments.length>0&&void 0!==arguments[0]?arguments[0]:s())("readonly",(function(t){if(t.getAll)return i(t.getAll());var e=[];return g(t,(function(t){return e.push(t.value)})).then((function(){return e}))}))}function w(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:s();return t("readonly",(function(e){if(e.getAll&&e.getAllKeys)return Promise.all([i(e.getAllKeys()),i(e.getAll())]).then((function(t){var e,r,i=(r=2,function(t){if(Array.isArray(t))return t}(e=t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,i,o,a,s=[],u=!0,c=!1;try{if(o=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=o.call(r)).done)&&(s.push(n.value),s.length!==e);u=!0);}catch(t){c=!0,i=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(c)throw i}}return s}}(e,r)||function(t,e){if(t){if("string"==typeof t)return n(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?n(t,e):void 0}}(e,r)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),o=i[0],a=i[1];return o.map((function(t,e){return[t,a[e]]}))}));var r=[];return t("readonly",(function(t){return g(t,(function(t){return r.push([t.key,t.value])})).then((function(){return r}))}))}))}r.r(e),r.d(e,{clear:()=>y,createStore:()=>o,del:()=>p,delMany:()=>d,entries:()=>w,get:()=>u,getMany:()=>h,keys:()=>v,promisifyRequest:()=>i,set:()=>c,setMany:()=>f,update:()=>l,values:()=>b})},147:t=>{"use strict";t.exports=JSON.parse('{"HO":{"_X":"^5.1.1"}}')}},e={};function r(n){var i=e[n];if(void 0!==i)return i.exports;var o=e[n]={id:n,loaded:!1,exports:{}};return t[n].call(o.exports,o,o.exports,r),o.loaded=!0,o.exports}r.d=(t,e)=>{for(var n in e)r.o(e,n)&&!r.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},r.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),r.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.nmd=t=>(t.paths=[],t.children||(t.children=[]),t),(()=>{function t(e){return t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},t(e)}function e(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function n(e,r,n){return(r=function(e){var r=function(e,r){if("object"!==t(e)||null===e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var i=n.call(e,"string");if("object"!==t(i))return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"===t(r)?r:String(r)}(r))in e?Object.defineProperty(e,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[r]=n,e}var i=r(217),o=r(485),a=r(687),s=r(779);r.g.addEventListener("message",(function(t){var e=t.data;i.dispatchHandlers(e,(function(t){return postMessage(t)}))})),i.setAdapter(function(t){for(var r=1;r { + const { mode } = useDarkMode() + + return ( +
+ }> + + +
+ ) +} + +export const SidepanelRouting = () => { + const { mode } = useDarkMode() + + return ( +
+ }> + + +
+ ) +} diff --git a/src/routes/index.tsx b/src/routes/firefox-route.tsx similarity index 59% rename from src/routes/index.tsx rename to src/routes/firefox-route.tsx index 2a4dd60..a338bf5 100644 --- a/src/routes/index.tsx +++ b/src/routes/firefox-route.tsx @@ -1,22 +1,15 @@ import { Suspense } from "react" -import { useTranslation } from "react-i18next" import { useDarkMode } from "~/hooks/useDarkmode" -import { OptionRoutingChrome, SidepanelRoutingChrome } from "./chrome" import { OptionRoutingFirefox, SidepanelRoutingFirefox } from "./firefox" import { PageAssistLoader } from "@/components/Common/PageAssistLoader" export const OptionRouting = () => { const { mode } = useDarkMode() - const { i18n } = useTranslation() return (
}> - {import.meta.env.BROWSER === "chrome" ? ( - - ) : ( - - )} +
) @@ -24,16 +17,11 @@ export const OptionRouting = () => { export const SidepanelRouting = () => { const { mode } = useDarkMode() - const { i18n } = useTranslation() return (
}> - {import.meta.env.BROWSER === "chrome" ? ( - - ) : ( - - )} +
) diff --git a/src/services/elevenlabs.ts b/src/services/elevenlabs.ts new file mode 100644 index 0000000..d87cdef --- /dev/null +++ b/src/services/elevenlabs.ts @@ -0,0 +1,49 @@ +import axios from 'axios'; +export interface Voice { + voice_id: string; + name: string; +} + +export interface Model { + model_id: string; + name: string; +} + +const BASE_URL = 'https://api.elevenlabs.io/v1'; + +export const getVoices = async (apiKey: string): Promise => { + const response = await axios.get(`${BASE_URL}/voices`, { + headers: { 'xi-api-key': apiKey } + }); + return response.data.voices; +}; + +export const getModels = async (apiKey: string): Promise => { + const response = await axios.get(`${BASE_URL}/models`, { + headers: { 'xi-api-key': apiKey } + }); + return response.data; +}; + +export const generateSpeech = async ( + apiKey: string, + text: string, + voiceId: string, + modelId: string +): Promise => { + const response = await axios.post( + `${BASE_URL}/text-to-speech/${voiceId}`, + { + text, + model_id: modelId, + }, + { + headers: { + 'xi-api-key': apiKey, + 'Content-Type': 'application/json', + }, + responseType: 'arraybuffer', + } + ); + return response.data; +}; \ No newline at end of file diff --git a/src/services/model-settings.ts b/src/services/model-settings.ts index 1993442..730d619 100644 --- a/src/services/model-settings.ts +++ b/src/services/model-settings.ts @@ -32,6 +32,7 @@ type ModelSettings = { useMLock?: boolean useMMap?: boolean vocabOnly?: boolean + minP?: number } const keys = [ @@ -62,7 +63,8 @@ const keys = [ "typicalP", "useMLock", "useMMap", - "vocabOnly" + "vocabOnly", + "minP", ] export const getAllModelSettings = async () => { diff --git a/src/services/ollama.ts b/src/services/ollama.ts index 42046ff..e19d704 100644 --- a/src/services/ollama.ts +++ b/src/services/ollama.ts @@ -231,8 +231,8 @@ export const setOllamaURL = async (ollamaURL: string) => { "http://127.0.0.1:" ) } - await urlRewriteRuntime(cleanUrl(formattedUrl)) await storage.set("ollamaURL", cleanUrl(formattedUrl)) + await urlRewriteRuntime(cleanUrl(formattedUrl)) } export const systemPromptForNonRag = async () => { diff --git a/src/services/tts.ts b/src/services/tts.ts index 847efb4..ace7b05 100644 --- a/src/services/tts.ts +++ b/src/services/tts.ts @@ -4,7 +4,7 @@ const storage = new Storage() const DEFAULT_TTS_PROVIDER = "browser" -const AVAILABLE_TTS_PROVIDERS = ["browser"] as const +const AVAILABLE_TTS_PROVIDERS = ["browser", "elevenlabs"] as const export const getTTSProvider = async (): Promise< (typeof AVAILABLE_TTS_PROVIDERS)[number] @@ -63,22 +63,78 @@ export const setSSMLEnabled = async (isSSMLEnabled: boolean) => { await storage.set("isSSMLEnabled", isSSMLEnabled.toString()) } +export const getElevenLabsApiKey = async () => { + const data = await storage.get("elevenLabsApiKey") + return data +} + +export const setElevenLabsApiKey = async (elevenLabsApiKey: string) => { + await storage.set("elevenLabsApiKey", elevenLabsApiKey) +} + +export const getElevenLabsVoiceId = async () => { + const data = await storage.get("elevenLabsVoiceId") + return data +} + +export const setElevenLabsVoiceId = async (elevenLabsVoiceId: string) => { + await storage.set("elevenLabsVoiceId", elevenLabsVoiceId) +} + +export const getElevenLabsModel = async () => { + const data = await storage.get("elevenLabsModel") + return data +} + +export const setElevenLabsModel = async (elevenLabsModel: string) => { + await storage.set("elevenLabsModel", elevenLabsModel) +} + +export const getResponseSplitting = async () => { + const data = await storage.get("ttsResponseSplitting") + if (!data || data.length === 0 || data === "") { + return "punctuation" + } + return data +} + +export const setResponseSplitting = async (responseSplitting: string) => { + await storage.set("ttsResponseSplitting", responseSplitting) +} + export const getTTSSettings = async () => { - const [ttsEnabled, ttsProvider, browserTTSVoices, voice, ssmlEnabled] = - await Promise.all([ - isTTSEnabled(), - getTTSProvider(), - getBrowserTTSVoices(), - getVoice(), - isSSMLEnabled() - ]) + const [ + ttsEnabled, + ttsProvider, + browserTTSVoices, + voice, + ssmlEnabled, + elevenLabsApiKey, + elevenLabsVoiceId, + elevenLabsModel, + responseSplitting + ] = await Promise.all([ + isTTSEnabled(), + getTTSProvider(), + getBrowserTTSVoices(), + getVoice(), + isSSMLEnabled(), + getElevenLabsApiKey(), + getElevenLabsVoiceId(), + getElevenLabsModel(), + getResponseSplitting() + ]) return { ttsEnabled, ttsProvider, browserTTSVoices, voice, - ssmlEnabled + ssmlEnabled, + elevenLabsApiKey, + elevenLabsVoiceId, + elevenLabsModel, + responseSplitting } } @@ -86,17 +142,29 @@ export const setTTSSettings = async ({ ttsEnabled, ttsProvider, voice, - ssmlEnabled + ssmlEnabled, + elevenLabsApiKey, + elevenLabsVoiceId, + elevenLabsModel, + responseSplitting }: { ttsEnabled: boolean ttsProvider: string voice: string ssmlEnabled: boolean + elevenLabsApiKey: string + elevenLabsVoiceId: string + elevenLabsModel: string + responseSplitting: string }) => { await Promise.all([ setTTSEnabled(ttsEnabled), setTTSProvider(ttsProvider), setVoice(voice), - setSSMLEnabled(ssmlEnabled) + setSSMLEnabled(ssmlEnabled), + setElevenLabsApiKey(elevenLabsApiKey), + setElevenLabsVoiceId(elevenLabsVoiceId), + setElevenLabsModel(elevenLabsModel), + setResponseSplitting(responseSplitting) ]) } diff --git a/src/store/index.tsx b/src/store/index.tsx index 9bdee7b..49b2072 100644 --- a/src/store/index.tsx +++ b/src/store/index.tsx @@ -45,6 +45,9 @@ type State = { selectedQuickPrompt: string | null setSelectedQuickPrompt: (selectedQuickPrompt: string) => void + + useOCR: boolean + setUseOCR: (useOCR: boolean) => void } export const useStoreMessage = create((set) => ({ @@ -79,5 +82,8 @@ export const useStoreMessage = create((set) => ({ setSelectedSystemPrompt: (selectedSystemPrompt) => set({ selectedSystemPrompt }), selectedQuickPrompt: null, - setSelectedQuickPrompt: (selectedQuickPrompt) => set({ selectedQuickPrompt }) + setSelectedQuickPrompt: (selectedQuickPrompt) => set({ selectedQuickPrompt }), + + useOCR: false, + setUseOCR: (useOCR) => set({ useOCR }) })) diff --git a/src/store/model.tsx b/src/store/model.tsx index 5514b24..9ef8546 100644 --- a/src/store/model.tsx +++ b/src/store/model.tsx @@ -30,6 +30,7 @@ type CurrentChatModelSettings = { useMMap?: boolean vocabOnly?: boolean seed?: number + minP?: number setF16KV?: (f16KV: boolean) => void setFrequencyPenalty?: (frequencyPenalty: number) => void @@ -65,6 +66,8 @@ type CurrentChatModelSettings = { reset: () => void systemPrompt?: string setSystemPrompt: (systemPrompt: string) => void + + setMinP: (minP: number) => void } export const useStoreChatModelSettings = create( @@ -103,6 +106,7 @@ export const useStoreChatModelSettings = create( seetSeed: (seed: number) => set({ seed }), setX: (key: string, value: any) => set({ [key]: value }), systemPrompt: undefined, + setMinP: (minP: number) => set({ minP }), setSystemPrompt: (systemPrompt: string) => set({ systemPrompt }), reset: () => set({ @@ -135,7 +139,8 @@ export const useStoreChatModelSettings = create( useMMap: undefined, vocabOnly: undefined, seed: undefined, - systemPrompt: undefined + systemPrompt: undefined, + minP: undefined, }) }) ) diff --git a/src/store/option.tsx b/src/store/option.tsx index 49911cd..f1d27ea 100644 --- a/src/store/option.tsx +++ b/src/store/option.tsx @@ -68,6 +68,9 @@ type State = { temporaryChat: boolean setTemporaryChat: (temporaryChat: boolean) => void + + useOCR: boolean + setUseOCR: (useOCR: boolean) => void } export const useStoreMessageOption = create((set) => ({ @@ -109,4 +112,7 @@ export const useStoreMessageOption = create((set) => ({ temporaryChat: false, setTemporaryChat: (temporaryChat) => set({ temporaryChat }), + + useOCR: false, + setUseOCR: (useOCR) => set({ useOCR }), })) diff --git a/src/utils/human-message.tsx b/src/utils/human-message.tsx index 9c1200f..073a66e 100644 --- a/src/utils/human-message.tsx +++ b/src/utils/human-message.tsx @@ -4,14 +4,33 @@ import { HumanMessage, type MessageContent } from "@langchain/core/messages" type HumanMessageType = { content: MessageContent model: string + useOCR: boolean } -export const humanMessageFormatter = ({ content, model }: HumanMessageType) => { +export const humanMessageFormatter = async ({ + content, + model, + useOCR = false +}: HumanMessageType) => { const isCustom = isCustomModel(model) if (isCustom) { if (typeof content !== "string") { if (content.length > 1) { + if (useOCR) { + //@ts-ignore + const imageUrl = content[1].image_url + const ocrText = await processImageForOCR(imageUrl) + //@ts-ignore + const ocrPROMPT = `${content[0].text} + +[IMAGE OCR TEXT] +${ocrText}` + return new HumanMessage({ + content: ocrPROMPT + }) + } + // this means that we need to reformat the image_url const newContent: MessageContent = [ { @@ -40,6 +59,21 @@ export const humanMessageFormatter = ({ content, model }: HumanMessageType) => { } } + if (useOCR) { + if (typeof content !== "string" && content.length > 1) { + //@ts-ignore + const ocrText = await processImageForOCR(content[1].image_url) + //@ts-ignore + const ocrPROMPT = `${content[0].text} + +[IMAGE OCR TEXT] +${ocrText}` + return new HumanMessage({ + content: ocrPROMPT + }) + } + } + return new HumanMessage({ content }) diff --git a/src/utils/ocr.ts b/src/utils/ocr.ts new file mode 100644 index 0000000..e56a9ab --- /dev/null +++ b/src/utils/ocr.ts @@ -0,0 +1,17 @@ +import { createWorker } from 'tesseract.js'; + +export async function processImageForOCR(imageData: string): Promise { + const worker = await createWorker('eng-fast', undefined, { + workerPath: "/ocr/worker.min.js", + workerBlobURL: false, + corePath: "/ocr/tesseract-core-simd.js", + errorHandler: e => console.error(e), + langPath: "/ocr/lang" + }); + + const result = await worker.recognize(imageData); + + await worker.terminate(); + + return result.data.text; +} diff --git a/src/utils/tts.ts b/src/utils/tts.ts new file mode 100644 index 0000000..c79683b --- /dev/null +++ b/src/utils/tts.ts @@ -0,0 +1,112 @@ +// inspired from https://github.com/open-webui/open-webui/blob/2299f4843003759290cc6bf823595c6578ee4470/src/lib/utils/index.ts + +const CODE_BLOCK_PATTERN = /```[\s\S]*?```/g; + +export const sanitizeEmojis = (text: string): string => { + const EMOJI_PATTERN = /[\uD800-\uDBFF][\uDC00-\uDFFF]|\uD83C[\uDC00-\uDFFF]|\uD83D[\uDC00-\uDE4F]/g; + return text.replace(EMOJI_PATTERN, ''); +}; + +export const sanitizeMarkdown = (text: string): string => { + return text + .replace(/(```[\s\S]*?```)/g, '') + .replace(/^\|.*\|$/gm, '') + .replace(/(?:\*\*|__)(.*?)(?:\*\*|__)/g, '$1') + .replace(/(?:[*_])(.*?)(?:[*_])/g, '$1') + .replace(/~~(.*?)~~/g, '$1') + .replace(/`([^`]+)`/g, '$1') + .replace(/!?\[([^\]]*)\](?:\([^)]+\)|\[[^\]]*\])/g, '$1') + .replace(/^\[[^\]]+\]:\s*.*$/gm, '') + .replace(/^#{1,6}\s+/gm, '') + .replace(/^\s*[-*+]\s+/gm, '') + .replace(/^\s*(?:\d+\.)\s+/gm, '') + .replace(/^\s*>[> ]*/gm, '') + .replace(/^\s*:\s+/gm, '') + .replace(/\[\^[^\]]*\]/g, '') + .replace(/[-*_~]/g, '') + .replace(/\n{2,}/g, '\n'); +}; + +export const sanitizeText = (content: string): string => { + return sanitizeMarkdown(sanitizeEmojis(content.trim())); +}; + +export const parseTextIntoSentences = (text: string): string[] => { + const codeBlocks: string[] = []; + let blockIndex = 0; + + const processedText = text.replace(CODE_BLOCK_PATTERN, (match) => { + const placeholder = `\u0000${blockIndex}\u0000`; + codeBlocks[blockIndex++] = match; + return placeholder; + }); + + const sentences = processedText.split(/(?<=[.!?])\s+/); + + return sentences + .map(sentence => + sentence.replace(/\u0000(\d+)\u0000/g, (_, idx) => codeBlocks[idx]) + ) + .map(sanitizeText) + .filter(Boolean); +}; + +export const parseTextIntoParagraphs = (text: string): string[] => { + const codeBlocks: string[] = []; + let blockIndex = 0; + + const processedText = text.replace(CODE_BLOCK_PATTERN, (match) => { + const placeholder = `\u0000${blockIndex}\u0000`; + codeBlocks[blockIndex++] = match; + return placeholder; + }); + + return processedText + .split(/\n+/) + .map(paragraph => + paragraph.replace(/\u0000(\d+)\u0000/g, (_, idx) => codeBlocks[idx]) + ) + .map(sanitizeText) + .filter(Boolean); +}; + +export const optimizeSentencesForSpeech = (text: string): string[] => { + return parseTextIntoSentences(text).reduce((optimizedTexts, currentText) => { + const lastIndex = optimizedTexts.length - 1; + + if (lastIndex >= 0) { + const previousText = optimizedTexts[lastIndex]; + const wordCount = previousText.split(/\s+/).length; + const charCount = previousText.length; + + if (wordCount < 4 || charCount < 50) { + optimizedTexts[lastIndex] = `${previousText} ${currentText}`; + } else { + optimizedTexts.push(currentText); + } + } else { + optimizedTexts.push(currentText); + } + + return optimizedTexts; + }, [] as string[]); +}; + +export const splitMessageContent = (content: string, splitBy: string = 'punctuation') => { + const messageContentParts: string[] = []; + + switch (splitBy) { + case 'punctuation': + messageContentParts.push(...optimizeSentencesForSpeech(content)); + break; + case 'paragraph': + messageContentParts.push(...parseTextIntoParagraphs(content)); + break; + case 'none': + messageContentParts.push(sanitizeText(content)); + break; + default: + } + + return messageContentParts; +}; \ No newline at end of file diff --git a/wxt.config.ts b/wxt.config.ts index 69c86bd..0aa73c2 100644 --- a/wxt.config.ts +++ b/wxt.config.ts @@ -45,12 +45,13 @@ export default defineConfig({ } } }), - entrypointsDir: "entries", + entrypointsDir: + process.env.TARGET === "firefox" ? "entries-firefox" : "entries", srcDir: "src", outDir: "build", manifest: { - version: "1.3.9", + version: "1.4.0", name: process.env.TARGET === "firefox" ? "Page Assist - A Web UI for Local AI Models" @@ -85,6 +86,12 @@ export default defineConfig({ } } }, + content_security_policy: + process.env.TARGET !== "firefox" ? + { + extension_pages: + "script-src 'self' 'wasm-unsafe-eval'; object-src 'self';" + } : undefined, permissions: process.env.TARGET === "firefox" ? firefoxMV2Permissions